src/worker/Data.mjs#createInstance narrows its dynamic import with a webpackInclude magic comment:
let module = await import(
`../../${path}.mjs`
);The context base is the repository root, and the include is what keeps that from meaning "every
.mjs in the tree". It is unanchored, and webpack matches include/exclude against the absolute
resource path — so any workspace with an ancestor directory named apps, examples, or docs/app
matches on the ancestor, and the include stops narrowing anything.
The exclude on the very next line is separator-anchored ((?:\/|\\)(buildScripts|…)), so the
anchoring question was clearly considered for one of the two and not the other.
Measured, with a control
Same engine version (13.1.0), same config, two dist/development/dataworker.js builds:
| build |
context map entries |
entries matching the include relative to the root |
this repo — no ancestor named apps |
797 |
762 (95.6%) |
a workspace nested under a parent directory named apps |
1244 |
7 (0.6%) |
In this repo the include works, because the apps/ it matches is the one at the context root. That
is why the defect is invisible here and why it survived: the pattern is correct exactly when the
repository is the thing being built.
In the nested workspace 1237 of 1244 registered modules match no relative form of the include. Files
that reach the bundle include root-level Node-only scripts — a bootstrap.mjs and a devServer.mjs,
each dragging a node_modules/url vendor chunk — and unrelated application trees such as
client/src/**. A dev server is registered as a lazily-importable module inside a browser Web
Worker.
Why it is worth fixing rather than tolerating
- It is silent. The build succeeds, the app runs, and the only symptom is bundle size plus code
that could never execute in a worker being reachable from one.
- It is invisible to this repo's own builds, so no amount of testing here surfaces it.
- The trigger is the consumer's directory name, not anything the consumer wrote. Nesting a
workspace under
apps/ is an ordinary layout choice, and nothing reports that it changed the build.
The shape of the fix
Filtering a too-wide context with a pattern is the fragile part; the pattern has to encode "relative
to the context root" in a language that only sees absolute paths. Making the context base explicit
avoids the class rather than tightening the regex — e.g. separate narrow imports per supported root
(../../apps/…, ../../examples/…, ../../src/data/…) selected from the already-parsed path, so
each context is rooted where it should be and an ancestor's name cannot widen it.
Tightening the include to require a separator ((?:\/|\\)(?:apps|…)) is not sufficient: an
ancestor path still supplies the separator.
Contract Ledger Matrix
Backfilled 2026-08-30 at @neo-gpt's RA-3. The ticket originally prescribed one layer; the defect
spans two, and the ledger has to say which layer owns what or the next change repeats the mistake.
| Target Surface |
Source of Authority |
Behavior |
Fallback |
Docs |
Evidence |
createInstance({config, path}) |
src/worker/Data.mjs |
consumed RMA method. Accepted roots: apps/, examples/, docs/app/, src/data/. A trailing .mjs suffix is stripped before dispatch, so apps/x/M and apps/x/M.mjs name the same module |
unsupported root throws, and is never resolved through a wider context |
method JSDoc |
unit suite; physical consumer build |
loadModule({path}) |
src/worker/Data.mjs |
consumed RMA method; same four roots, same suffix rule, same refusal, via the shared helper |
as above |
method JSDoc |
as above |
importAppSpaceModule(path) |
src/worker/Data.mjs |
one static-prefixed lazy context per root. Package-relative only — this layer never decides what apps/ means on disk |
typed refusal: Unsupported module root: <path> |
method JSDoc, which names the config-side half |
in-repo 930-chunk identity |
workerContextRebasePlugin(insideNeo) |
buildScripts/webpack/workerContextRebasePlugin.mjs |
ownership boundary. App-space roots (apps, examples, docs/app) resolve to the consumer workspace; src/data stays package-local. An absent optional root keeps its package-relative request with an emptied match, so it contributes no modules and raises no resolution error |
insideNeo is a total no-op — the framework's own build is unaffected |
factory JSDoc |
0 request mutations at insideNeo=true |
| development / dist parity |
both buildScripts/webpack/{development,production}/webpack.config.worker.mjs |
both modes install the same factory, so the mapping cannot differ between a dev build and a shipped one |
none — divergence is the defect this row exists to prevent |
workflow comment |
consumer fixture built in both modes |
The invariant the two layers share: Data.mjs decides which roots exist; the worker configs
decide where those roots live once the framework is a dependency. Changing the prefixes in one
without the other breaks module resolution for every consumer, and the framework's own build cannot
observe it.
Acceptance Criteria
Out of Scope
- The identical
webpackInclude/webpackExclude pairs elsewhere in src/worker/Data.mjs and
src/worker/App.mjs — same class, but each needs its own before/after count rather than being
swept along on the strength of this one.
src/worker/Data.mjs#createInstancenarrows its dynamic import with awebpackIncludemagic comment:let module = await import( /* webpackInclude: /(?:apps|docs\/app|examples|src\/data)\/.*\.mjs$/ */ /* webpackExclude: /(?:\/|\\)(buildScripts|dist|node_modules(?:\/|\\)(?!neo\.mjs)|ai(?:\/|\\)|\.claude(?:\/|\\)|server\.mjs|test(?:\/|\\))/ */ /* webpackMode: "lazy" */ `../../${path}.mjs` );The context base is the repository root, and the include is what keeps that from meaning "every
.mjsin the tree". It is unanchored, and webpack matches include/exclude against the absolute resource path — so any workspace with an ancestor directory namedapps,examples, ordocs/appmatches on the ancestor, and the include stops narrowing anything.The exclude on the very next line is separator-anchored (
(?:\/|\\)(buildScripts|…)), so the anchoring question was clearly considered for one of the two and not the other.Measured, with a control
Same engine version (13.1.0), same config, two
dist/development/dataworker.jsbuilds:appsappsIn this repo the include works, because the
apps/it matches is the one at the context root. That is why the defect is invisible here and why it survived: the pattern is correct exactly when the repository is the thing being built.In the nested workspace 1237 of 1244 registered modules match no relative form of the include. Files that reach the bundle include root-level Node-only scripts — a
bootstrap.mjsand adevServer.mjs, each dragging anode_modules/urlvendor chunk — and unrelated application trees such asclient/src/**. A dev server is registered as a lazily-importable module inside a browser Web Worker.Why it is worth fixing rather than tolerating
apps/is an ordinary layout choice, and nothing reports that it changed the build.The shape of the fix
Filtering a too-wide context with a pattern is the fragile part; the pattern has to encode "relative to the context root" in a language that only sees absolute paths. Making the context base explicit avoids the class rather than tightening the regex — e.g. separate narrow imports per supported root (
../../apps/…,../../examples/…,../../src/data/…) selected from the already-parsedpath, so each context is rooted where it should be and an ancestor's name cannot widen it.Tightening the include to require a separator (
(?:\/|\\)(?:apps|…)) is not sufficient: an ancestor path still supplies the separator.Contract Ledger Matrix
Backfilled 2026-08-30 at @neo-gpt's RA-3. The ticket originally prescribed one layer; the defect spans two, and the ledger has to say which layer owns what or the next change repeats the mistake.
createInstance({config, path})src/worker/Data.mjsapps/,examples/,docs/app/,src/data/. A trailing.mjssuffix is stripped before dispatch, soapps/x/Mandapps/x/M.mjsname the same moduleloadModule({path})src/worker/Data.mjsimportAppSpaceModule(path)src/worker/Data.mjsapps/means on diskUnsupported module root: <path>workerContextRebasePlugin(insideNeo)buildScripts/webpack/workerContextRebasePlugin.mjsapps,examples,docs/app) resolve to the consumer workspace;src/datastays package-local. An absent optional root keeps its package-relative request with an emptied match, so it contributes no modules and raises no resolution errorinsideNeois a total no-op — the framework's own build is unaffectedinsideNeo=truebuildScripts/webpack/{development,production}/webpack.config.worker.mjsThe invariant the two layers share:
Data.mjsdecides which roots exist; the worker configs decide where those roots live once the framework is a dependency. Changing the prefixes in one without the other breaks module resolution for every consumer, and the framework's own build cannot observe it.Acceptance Criteria
apps,examples, ordocs/appcannot widen it.createInstancestill resolves the same modules it does today.Out of Scope
webpackInclude/webpackExcludepairs elsewhere insrc/worker/Data.mjsandsrc/worker/App.mjs— same class, but each needs its own before/after count rather than being swept along on the strength of this one.