Please comment to claim before starting; check current assignees and linked PRs.
Context
On PR #21716 (src/button/ThemeSwitcher.mjs, head 411a81a217), a new engine button shipped with two Neo.setupClass classes (Neo.button.ThemeSwitcherMenu and Neo.button.ThemeSwitcher) in one file and a module-scope const themeLabels = {...} map that workspace consumers could not extend per switcher instance. In the same overnight Engine v14 sprint, six standalone scheduler examples merged with threeClassDeclarations inside a single Viewport.mjs file, and multiple Gantt/board example PRs (#21701, #21732, #21736, #21738) entered review with module-scope functions beside Viewport classes because buildScripts/util/check-class-module-scope.mjs scans src/**/*.mjs only and checks body.some(...) rather than class count.
The Problem
Unenforced one-class-per-file invariant:buildScripts/util/check-class-module-scope.mjs:121-125 already parses Program.body with acorn on commit and CI, using body.some(...) only to test whether at least oneClassDeclaration exists before scanning for module-scope functions. Declaring two or three classes in one .mjs file passes silently.
Unscanned apps/**/*.mjs and examples/**/*.mjs surfaces:#18064 (Out of Scope) initially scoped SCAN_SURFACE / SCAN_ROOTS (check-class-module-scope.mjs:71-77) and package.jsonlint-staged ("src/**/*.mjs") to src/ only so the initial rollout stayed bounded — not as a doctrinal exemption. Because developers and coding agents copy examples/** and apps/** verbatim as reference idioms, leaving them outside the guard allowed 6 multi-class Viewport.mjs files and 60 module-scope functions beside classes to accumulate in examples/.
Over-broad module-scope lookup-table guidance:#18064 added the blanket line "imports, constants and lookup tables stay at module scope: nobody overrides data" in four places (.github/CODING_GUIDELINES.md:70, .github/CODING_GUIDELINES.md:401, buildScripts/util/check-class-module-scope.mjs:30-31, and CLI stderr check-class-module-scope.mjs:270). For consumer-facing vocabulary/label/icon maps on a Neo class (such as themeLabels_ on ThemeSwitcher or fieldLabels_ on CardEditor), developers and workspace apps do extend or override those maps via static config descriptors ({[isDescriptor]: true, merge: 'shallow', value: {...}}) or static class fields (.github/CODING_GUIDELINES.md:98). Telling authors "nobody overrides data" steers extensible component maps into closed module-scope const objects.
examples/: 625.mjs files -> 30 files / 60 module-scope function hits; 6 multi-class files (examples/scheduler/{barRenderer,dragAndResize,nonWorkingTime,resourceColumns,timeZones,zoom}/Viewport.mjs, each declaring 3 classes: resource model + event model + viewport).
The Architectural Reality
.github/CODING_GUIDELINES.md:58 rule (11) and :201-209 rule (20) establish the 1:1 mapping between one file path and one Neo class (class definition -> Neo.setupClass(<ClassName>) -> export default) across the repository (src/, apps/, and examples/).
buildScripts/util/check-class-module-scope.mjs + buildScripts/util/check-class-module-scope-baseline.json run in package.jsonlint-staged and .github/workflows/pr-baseline.yml:66 (baseline / guards, verified by check-guard-ci-parity.mjs), with symmetric upward/downward baseline diffing (diffAgainstBaseline, L210-228) and unit coverage in test/playwright/unit/buildScripts/.
Design authority: ".github/CODING_GUIDELINES.md §3 (11): class names strictly follow the folder and file structure" and "§4 (20): Module order: Import statements ... class definition ... Neo.setupClass(<ClassName>) ... export statement" (with .github/CODING_GUIDELINES.md:98static badgePositions + src/core/ConfigSymbols.mjsmerge: 'shallow' descriptors governing extensible class data).
The Fix
Expand scan surface to src/, apps/, and examples/ and enforce one-class-per-file in buildScripts/util/check-class-module-scope.mjs:
Update SCAN_SURFACE to Object.freeze(['src/**/*.mjs', 'apps/**/*.mjs', 'examples/**/*.mjs']), SCAN_ROOTS to Object.freeze(['src', 'apps', 'examples']), and package.jsonlint-staged key "src/**/*.mjs" to "{apps,examples,src}/**/*.mjs".
Count top-level ClassDeclarations (including export class / export default class) in Program.body for every scanned .mjs file.
Report any additional class declaration beyond the first (e.g., keyed as ${file}::class:${name} in check-class-module-scope-baseline.json, or a dedicated extraClasses section sharing the same symmetric fail-up / fail-down ratchet) and regenerate check-class-module-scope-baseline.json from the live tree so legacy entries (EventSimulator.mjs + existing apps//examples/ hits) are baselined for burndown while any new multi-class file or module-scope function beside a class fails lint-staged and CI guards immediately.
Narrow the lookup-table wording across docs and CLI output:
Update .github/CODING_GUIDELINES.md:70, .github/CODING_GUIDELINES.md:401, buildScripts/util/check-class-module-scope.mjs:30-31, and buildScripts/util/check-class-module-scope.mjs:270 to distinguish immutable internal module constants (regexes, protocol/grammar tables that no consumer customizes) from consumer- or subclass-extensible maps/labels/options on a class, which belong on static config ([isDescriptor]: true, merge: 'shallow') or static class properties.
Scans {src,apps,examples}/**/*.mjs in lint-staged and CI guards; fails when any scanned file declares > 1 top-level ClassDeclaration or an unbaselined module-scope function beside a class (with symmetric fail-down burndown)
Unparseable JS continues to return [] so check-parse remains sole syntax reporter (L113-116)
Clarifies that consumer/subclass-extensible label or option maps belong on static config (merge: 'shallow') or static fields rather than module-scope const tables
Pure internal constants/regexes remain valid at module scope
.github/CODING_GUIDELINES.md §4 & §8
npm run check-guard-ci-parity + unit suite
Decision Record impact: none.
Acceptance Criteria
SCAN_SURFACE, SCAN_ROOTS, and package.jsonlint-staged cover {src,apps,examples}/**/*.mjs, and node ./buildScripts/util/check-guard-ci-parity.mjs passes.
node ./buildScripts/util/check-class-module-scope.mjs fails when any {src,apps,examples}/**/*.mjs file declares more than one top-level ClassDeclaration or a module-scope function beside a class not covered by check-class-module-scope-baseline.json, and fails downward when any baselined entry is burned down without updating the baseline.
.github/CODING_GUIDELINES.md (§4 & §8) and check-class-module-scope.mjs (docblock + CLI error message) replace "nobody overrides data" with guidance steering extensible maps/labels onto static config (merge: 'shallow') or static class properties while keeping internal module constants allowed.
Unit tests cover 0-class, 1-class, and multi-class fixtures (including export class + export default class), and node ./buildScripts/util/check-class-module-scope.mjs exits 0 against {src,apps,examples}.
Out of Scope
Extracting existing baselined classes/helpers (EventSimulator.mjsDriveAbort, examples/scheduler/*/Viewport.mjs inline models, and existing module-scope helpers in apps/ and examples/) in the guard PR itself — those burn down in dedicated cleanup PRs using the symmetric baseline ratchet.
Mechanically linting semantic "is this const object consumer-facing or internal?" (AST cannot tell a private parser table from user-facing theme labels without false positives; guidelines + review own that judgment).
Avoided Traps
Counting Neo.setupClass calls instead of ClassDeclarations: A helper class that omits Neo.setupClass (or calls it conditionally) still violates one-class-per-file; checking AST ClassDeclarations catches both.
Updating SCAN_ROOTS without SCAN_SURFACE and package.jsonlint-staged: Leaving lint-staged on "src/**/*.mjs" would let apps/ and examples/ commits pass pre-commit locally and fail only in CI baseline / guards.
Banning all module-scope ObjectExpression constants: Internal character maps, frozen symbol tables, and regex sets are legitimate internal constants (#18064 Avoided Traps); only the misleading "nobody overrides data" prose should change, not the AST function filter.
Related
Originated from Friction -> Gold review calibration on PR #21716 (#21705) and example reviews #21701, #21732, #21736 (defect-notes b2eb7f291cc46ab9, f2e2cf5ba21f9281, and MESSAGE:81ea4682).
Builds directly on #18064 / PR #18727 (check-class-module-scope.mjs introduction).
unowned-rationale: Ready for a contributor or post-v14 maintainer pickup; maintainers provide planning and review.
Live latest-open + closed sweep: checked latest 20 open (76 open total, red band — folded apps/ + examples/ scan expansion directly into #21737 rather than opening a second guard issue) + open and closed search (check-class-module-scope, ClassDeclaration, one class per file, lookup table; Out of Scope and Avoided Traps read in full on #18064) at 2026-11-21T06:14Z; no other equivalent or prior exclusion found.
A2A in-flight sweep: scanned latest 30 messages across all read states (05:09Z–06:14Z); zero competing claim (promotes own defect-notes MESSAGE:027e42e8, MESSAGE:d177aba1, and MESSAGE:81ea4682).
MC sweep: query_raw_memories ("two classes in one file lookup table module scope rubber stamp review after compaction", 6 results) + ask_knowledge_base (type: 'ticket', 5 refs); no prior decision found.
Own-assignment sweep: 3 open (#21676, #20987, #20671), none overlapping.
Structure-map gate (§1c): N/A — buildScripts/util/ + .github/CODING_GUIDELINES.md, no ai/ touch.
The guard checked whether the module declared any class, then looked only for module-scope functions. The guidelines treated all lookup tables as internal constants.
Within src/**/*.mjs, the guard reports each extra top-level class by name and declaration line. It treats the default-exported class as primary, including exports through Neo.setupClass, and falls back to the first declaration when it cannot identify the primary class from the export.
[QUARANTINED_URL: github.com]
2026-11-21T14:26:21Z @neo-opus-ada cross-referenced by #21785
Please comment to claim before starting; check current assignees and linked PRs.
Context
On PR
#21716(src/button/ThemeSwitcher.mjs, head411a81a217), a new engine button shipped with twoNeo.setupClassclasses (Neo.button.ThemeSwitcherMenuandNeo.button.ThemeSwitcher) in one file and a module-scopeconst themeLabels = {...}map that workspace consumers could not extend per switcher instance. In the same overnight Enginev14sprint, six standalone scheduler examples merged with threeClassDeclarations inside a singleViewport.mjsfile, and multiple Gantt/board example PRs (#21701,#21732,#21736,#21738) entered review with module-scope functions besideViewportclasses becausebuildScripts/util/check-class-module-scope.mjsscanssrc/**/*.mjsonly and checksbody.some(...)rather than class count.The Problem
buildScripts/util/check-class-module-scope.mjs:121-125already parsesProgram.bodywithacornon commit and CI, usingbody.some(...)only to test whether at least oneClassDeclarationexists before scanning for module-scope functions. Declaring two or three classes in one.mjsfile passes silently.apps/**/*.mjsandexamples/**/*.mjssurfaces:#18064(Out of Scope) initially scopedSCAN_SURFACE/SCAN_ROOTS(check-class-module-scope.mjs:71-77) andpackage.jsonlint-staged("src/**/*.mjs") tosrc/only so the initial rollout stayed bounded — not as a doctrinal exemption. Because developers and coding agents copyexamples/**andapps/**verbatim as reference idioms, leaving them outside the guard allowed6multi-classViewport.mjsfiles and60module-scope functions beside classes to accumulate inexamples/.#18064added the blanket line "imports, constants and lookup tables stay at module scope: nobody overrides data" in four places (.github/CODING_GUIDELINES.md:70,.github/CODING_GUIDELINES.md:401,buildScripts/util/check-class-module-scope.mjs:30-31, and CLI stderrcheck-class-module-scope.mjs:270). For consumer-facing vocabulary/label/icon maps on a Neo class (such asthemeLabels_onThemeSwitcherorfieldLabels_onCardEditor), developers and workspace apps do extend or override those maps viastatic configdescriptors ({[isDescriptor]: true, merge: 'shallow', value: {...}}) orstaticclass fields (.github/CODING_GUIDELINES.md:98). Telling authors "nobody overrides data" steers extensible component maps into closed module-scopeconstobjects.Publish-safe instrument receipt (
reviewer-instrument-audit.mdAuthor §2):Program.bodytop-levelClassDeclarationcount +findModuleScopeFunctions()scan across{src,apps,examples}/**/*.mjs.neomjs/neoorigin/devat07b6cbd213fc8d232bfd26b931684a576e20cf4d.src/:574.mjsfiles ->22files /41module-scope function hits;1multi-class file (src/main/addon/EventSimulator.mjs—2classes:DriveAbort,EventSimulator).apps/:373.mjsfiles ->4files /4module-scope function hits;0multi-class files.examples/:625.mjsfiles ->30files /60module-scope function hits;6multi-class files (examples/scheduler/{barRenderer,dragAndResize,nonWorkingTime,resourceColumns,timeZones,zoom}/Viewport.mjs, each declaring3classes: resource model + event model + viewport).The Architectural Reality
.github/CODING_GUIDELINES.md:58rule(11)and:201-209rule(20)establish the 1:1 mapping between one file path and oneNeoclass (class definition->Neo.setupClass(<ClassName>)->export default) across the repository (src/,apps/, andexamples/).buildScripts/util/check-class-module-scope.mjs+buildScripts/util/check-class-module-scope-baseline.jsonrun inpackage.jsonlint-stagedand.github/workflows/pr-baseline.yml:66(baseline / guards, verified bycheck-guard-ci-parity.mjs), with symmetric upward/downward baseline diffing (diffAgainstBaseline,L210-228) and unit coverage intest/playwright/unit/buildScripts/.".github/CODING_GUIDELINES.md §3 (11): class names strictly follow the folder and file structure" and "§4 (20): Module order: Import statements ... class definition ... Neo.setupClass(<ClassName>) ... export statement"(with.github/CODING_GUIDELINES.md:98static badgePositions+src/core/ConfigSymbols.mjsmerge: 'shallow'descriptors governing extensible class data).The Fix
src/,apps/, andexamples/and enforce one-class-per-file inbuildScripts/util/check-class-module-scope.mjs:SCAN_SURFACEtoObject.freeze(['src/**/*.mjs', 'apps/**/*.mjs', 'examples/**/*.mjs']),SCAN_ROOTStoObject.freeze(['src', 'apps', 'examples']), andpackage.jsonlint-stagedkey"src/**/*.mjs"to"{apps,examples,src}/**/*.mjs".ClassDeclarations (includingexport class/export default class) inProgram.bodyfor every scanned.mjsfile.${file}::class:${name}incheck-class-module-scope-baseline.json, or a dedicatedextraClassessection sharing the same symmetric fail-up / fail-down ratchet) and regeneratecheck-class-module-scope-baseline.jsonfrom the live tree so legacy entries (EventSimulator.mjs+ existingapps//examples/hits) are baselined for burndown while any new multi-class file or module-scope function beside a class failslint-stagedand CIguardsimmediately..github/CODING_GUIDELINES.md:70,.github/CODING_GUIDELINES.md:401,buildScripts/util/check-class-module-scope.mjs:30-31, andbuildScripts/util/check-class-module-scope.mjs:270to distinguish immutable internal module constants (regexes, protocol/grammar tables that no consumer customizes) from consumer- or subclass-extensible maps/labels/options on a class, which belong onstatic config([isDescriptor]: true, merge: 'shallow') orstaticclass properties.Contract Ledger Matrix
buildScripts/util/check-class-module-scope.mjs+check-class-module-scope-baseline.json+package.json(lint-staged).github/CODING_GUIDELINES.md§3(11)& §4(20),#18064{src,apps,examples}/**/*.mjsinlint-stagedand CIguards; fails when any scanned file declares> 1top-levelClassDeclarationor an unbaselined module-scope function beside a class (with symmetric fail-down burndown)[]socheck-parseremains sole syntax reporter (L113-116).github/CODING_GUIDELINES.md§4 & §8node ./buildScripts/util/check-class-module-scope.mjs+node ./buildScripts/util/check-guard-ci-parity.mjsexit0.github/CODING_GUIDELINES.md(L70,L401) &check-class-module-scope.mjs(L30-31,L270).github/CODING_GUIDELINES.md§4 (L98) &src/core/ConfigSymbols.mjsstatic config(merge: 'shallow') orstaticfields rather than module-scopeconsttables.github/CODING_GUIDELINES.md§4 & §8npm run check-guard-ci-parity+ unit suiteDecision Record impact: none.
Acceptance Criteria
SCAN_SURFACE,SCAN_ROOTS, andpackage.jsonlint-stagedcover{src,apps,examples}/**/*.mjs, andnode ./buildScripts/util/check-guard-ci-parity.mjspasses.node ./buildScripts/util/check-class-module-scope.mjsfails when any{src,apps,examples}/**/*.mjsfile declares more than one top-levelClassDeclarationor a module-scope function beside a class not covered bycheck-class-module-scope-baseline.json, and fails downward when any baselined entry is burned down without updating the baseline..github/CODING_GUIDELINES.md(§4 & §8) andcheck-class-module-scope.mjs(docblock + CLI error message) replace "nobody overrides data" with guidance steering extensible maps/labels ontostatic config(merge: 'shallow') orstaticclass properties while keeping internal module constants allowed.export class+export default class), andnode ./buildScripts/util/check-class-module-scope.mjsexits0against{src,apps,examples}.Out of Scope
EventSimulator.mjsDriveAbort,examples/scheduler/*/Viewport.mjsinline models, and existing module-scope helpers inapps/andexamples/) in the guard PR itself — those burn down in dedicated cleanup PRs using the symmetric baseline ratchet.constobject consumer-facing or internal?" (AST cannot tell a private parser table from user-facing theme labels without false positives; guidelines + review own that judgment).Avoided Traps
Neo.setupClasscalls instead ofClassDeclarations: A helper class that omitsNeo.setupClass(or calls it conditionally) still violates one-class-per-file; checking ASTClassDeclarations catches both.SCAN_ROOTSwithoutSCAN_SURFACEandpackage.jsonlint-staged: Leavinglint-stagedon"src/**/*.mjs"would letapps/andexamples/commits pass pre-commit locally and fail only in CIbaseline / guards.ObjectExpressionconstants: Internal character maps, frozen symbol tables, and regex sets are legitimate internal constants (#18064Avoided Traps); only the misleading "nobody overrides data" prose should change, not the AST function filter.Related
Friction -> Goldreview calibration on PR#21716(#21705) and example reviews#21701,#21732,#21736(defect-notesb2eb7f291cc46ab9,f2e2cf5ba21f9281, andMESSAGE:81ea4682).#18064/ PR#18727(check-class-module-scope.mjsintroduction).unowned-rationale: Ready for a contributor or post-v14 maintainer pickup; maintainers provide planning and review.
Live latest-open + closed sweep: checked latest 20 open (
76open total, red band — foldedapps/+examples/scan expansion directly into#21737rather than opening a second guard issue) + open and closed search (check-class-module-scope,ClassDeclaration,one class per file,lookup table;Out of ScopeandAvoided Trapsread in full on#18064) at2026-11-21T06:14Z; no other equivalent or prior exclusion found. A2A in-flight sweep: scanned latest 30 messages across all read states (05:09Z–06:14Z); zero competing claim (promotes owndefect-notesMESSAGE:027e42e8,MESSAGE:d177aba1, andMESSAGE:81ea4682). MC sweep:query_raw_memories("two classes in one file lookup table module scope rubber stamp review after compaction", 6 results) +ask_knowledge_base(type: 'ticket', 5 refs); no prior decision found. Own-assignment sweep: 3 open (#21676,#20987,#20671), none overlapping. Structure-map gate (§1c): N/A —buildScripts/util/+.github/CODING_GUIDELINES.md, noai/touch.Origin Session ID: 664ca229-4bbd-4e00-ae41-008707688181
Retrieval Hint: "check-class-module-scope apps examples SCAN_SURFACE multiple ClassDeclaration one class per file lookup table static config merge shallow"