Context
Leaf of #20667's package host seams. An installed extension package needs to load its own Main-thread addon, for example a native observer that consumes DeltaUpdates' existing update/updated hooks. The Engine and workspace routes already exist; the installed-package route does not.
#20778 remains the workers' loadModule capability. This leaf owns Main's different loader and build context.
The Problem
At 095f7ccfbe84306defcca4209b45af4c64da06ce, Main.importAddonModule accepts an Engine name or WS/<name>. Any other name is appended below Engine src/main/addon.
A read-only probe through the real Main method, using the existing MainWorkspaceAddon test setup, passed the proposed extension-free name node_modules/@fixture/native-hooks/src/main/addon/AnchorObserver. It failed with ERR_MODULE_NOT_FOUND under Engine src/main/addon/node_modules/, not the installed package root. This proves the current routing; it is not yet a physical installed-package build witness.
A package must currently ask the host to supply a workspace shim or custom Main bootstrap. That restates package-owned implementation in each consumer.
Design authority: additive capability under #20667's package-owned manifest precedent; existing Engine and WS contracts remain valid.
The Architectural Reality
src/Main.mjs#importAddon delegates loading to importAddonModule, registers the singleton and waits for remotesReady(). Full addon/library readiness is a separate promise.
buildScripts/webpack/mainAddonContextPlugin.mjs owns the optional WS context. #17907 preserves absent-workspace builds with a matches-nothing fallback; #20697 resolves the actual consuming workspace when the Engine is linked.
check-consumer-runtime-build.mjs already builds Main in development/production, installed/linked layouts and absent/present WS-root arms. Its module graph is the bundle-admission instrument.
test/playwright/unit/main/MainWorkspaceAddon.spec.mjs owns runtime resolution and the remotes-ready contract. The Main Thread Addons guide owns caller-facing usage.
- The package manifest is the owner of shipped module roots, as for neo.scss and the accepted worker direction on #20667. Installing a dependency must not include all of node_modules in a context.
Prescription: extend Main's existing loader plus a distinct package-owned context. Reuse manifest-discovery plumbing if #20778 has supplied it by implementation time, while preserving independent Main/worker admission rules.
The Fix
- Admit explicitly declared Main-addon roots from installed dependencies. Selected shape:
neo.mainAddons, an array of package-relative directory roots, matching #20778's neo.workerModules array-of-roots convention at b053c6ee. Main and worker roots remain separate. Absent/empty means no package Main roots enter a build. This is build inclusion, not a browser security boundary.
- Give
Main.importAddon and configured addon loading one documented package name form, node_modules/<package>/<declared-root>/<Addon> without .mjs, with scoped packages supported. Resolve it in raw development and bundled development/production while retaining the two existing routes.
- Include only the declaring package's roots. Preserve singleton registration, per-window dispatch and remotesReady. No copied addon files in WS, vendor-name allow-list or consumer list of package paths. This does not make a package path a
worker.App#getAddon short registry name; callers use the declared addon namespace for any registered remote methods.
- Document emitted dist/esm behavior explicitly: support the same caller form through the emitted tree, or prove and document the appropriate form. A config that says dist/esm while still running installed Main is a distinct existing case.
Routing: structural-pre-flight for any helper/fixture placement beside the current loader/context tests. The accepted host-seam extension does not introduce a new subsystem or breaking API, so no new ideation sandbox is proposed. Blast radius: bounded runtime/build contract; physical consumer and browser evidence are required.
Contract Ledger
| Surface |
Authority |
Delivered behavior |
Edge / fallback |
Docs |
Evidence |
| Main.importAddon / importAddonModule and configured addon loading |
Existing Main API, extended here |
Explicit package path reaches the installed addon in the target window |
Engine and WS names unchanged; missing module rejects visibly |
JSDoc + Main Thread Addons guide |
Real loader and browser arms |
| Package manifest Main roots |
#20667 manifest ownership |
Declared dependency roots enter only the Main package context |
Absent/empty excluded; no broad dependency scan admitted |
Guide + helper JSDoc |
Declared/undeclared fixtures and module graph |
| Registration/lifetime |
Main.registerAddon and remotesReady |
One instance per window; awaited import supplies registered remotes |
Full readiness remains separate; teardown removes owned listeners |
Existing lifecycle documentation |
Two-window native observer witness |
| Workspace/build boundaries |
#17907, #20697 |
Installed and linked layouts preserve optional WS and Engine graphs |
No empty WS directory required; no absolute build-machine path in emitted output |
Existing guard/header |
Physical consumer builds |
Decision Record: Optional. Decision Record impact: none; preserves accepted root ownership and Main registration semantics.
Acceptance Criteria
Out of Scope
Worker module loading (#20778), changing worker.App#getAddon's short-name lookup, a new generic addon registry, a workspace shim, automatic execution of every installed addon, package-specific rendering features, and changing remotesReady into full readiness.
Avoided Traps
Removing node_modules exclusions wholesale; hardcoding an npm scope; admitting sibling paths outside declared roots; inferring the workspace from a symlink's physical depth; compile-only proof without executing the addon; calling a no-op mock a listener-lifecycle witness.
Ownership and sweeps
Sophie owns this selected host dependency; Vega offered the PR review. Parent #20667's steward and the #20778 owner confirmed the separate Main boundary before filing. No existing contributor claim is displaced.
Live latest-open + closed sweep: all 39 open issues read (orange band), latest20 refreshed immediately before filing; closed searches for Main addon package and mainAddonContextPlugin, with #17907/#20697 bodies and exclusions read. They preserve workspace loading and do not supply package loading. Open #20778 is worker-only; #20820 is the independent Collection contract. Latest30 all-read-state A2A scan found the steward's admission, no competing claim. Own assignments #20820 and #20185 do not cover this loader. Memory sweep recovered Main lifecycle precedent and the steward's current boundary; exact source and the actual failed specifier probe govern. Structural owner: existing Main loader, webpack context helpers and consumer guard; no Agent OS placement.
Origin Session ID: 9bf9ac41-3a89-436f-9bdb-2e38327937eb
Retrieval Hint: "installed package Main addon importAddonModule declared manifest roots WS optional consumer build"
Context
Leaf of #20667's package host seams. An installed extension package needs to load its own Main-thread addon, for example a native observer that consumes
DeltaUpdates' existing update/updated hooks. The Engine and workspace routes already exist; the installed-package route does not.#20778 remains the workers'
loadModulecapability. This leaf owns Main's different loader and build context.The Problem
At
095f7ccfbe84306defcca4209b45af4c64da06ce,Main.importAddonModuleaccepts an Engine name orWS/<name>. Any other name is appended below Enginesrc/main/addon.A read-only probe through the real Main method, using the existing MainWorkspaceAddon test setup, passed the proposed extension-free name
node_modules/@fixture/native-hooks/src/main/addon/AnchorObserver. It failed with ERR_MODULE_NOT_FOUND under Engine src/main/addon/node_modules/, not the installed package root. This proves the current routing; it is not yet a physical installed-package build witness.A package must currently ask the host to supply a workspace shim or custom Main bootstrap. That restates package-owned implementation in each consumer.
Design authority: additive capability under #20667's package-owned manifest precedent; existing Engine and WS contracts remain valid.
The Architectural Reality
src/Main.mjs#importAddondelegates loading toimportAddonModule, registers the singleton and waits forremotesReady(). Full addon/library readiness is a separate promise.buildScripts/webpack/mainAddonContextPlugin.mjsowns the optional WS context. #17907 preserves absent-workspace builds with a matches-nothing fallback; #20697 resolves the actual consuming workspace when the Engine is linked.check-consumer-runtime-build.mjsalready builds Main in development/production, installed/linked layouts and absent/present WS-root arms. Its module graph is the bundle-admission instrument.test/playwright/unit/main/MainWorkspaceAddon.spec.mjsowns runtime resolution and the remotes-ready contract. The Main Thread Addons guide owns caller-facing usage.Prescription: extend Main's existing loader plus a distinct package-owned context. Reuse manifest-discovery plumbing if #20778 has supplied it by implementation time, while preserving independent Main/worker admission rules.
The Fix
neo.mainAddons, an array of package-relative directory roots, matching #20778'sneo.workerModulesarray-of-roots convention atb053c6ee. Main and worker roots remain separate. Absent/empty means no package Main roots enter a build. This is build inclusion, not a browser security boundary.Main.importAddonand configured addon loading one documented package name form,node_modules/<package>/<declared-root>/<Addon>without .mjs, with scoped packages supported. Resolve it in raw development and bundled development/production while retaining the two existing routes.worker.App#getAddonshort registry name; callers use the declared addon namespace for any registered remote methods.Routing: structural-pre-flight for any helper/fixture placement beside the current loader/context tests. The accepted host-seam extension does not introduce a new subsystem or breaking API, so no new ideation sandbox is proposed. Blast radius: bounded runtime/build contract; physical consumer and browser evidence are required.
Contract Ledger
Decision Record: Optional. Decision Record impact: none; preserves accepted root ownership and Main registration semantics.
Acceptance Criteria
Out of Scope
Worker module loading (#20778), changing worker.App#getAddon's short-name lookup, a new generic addon registry, a workspace shim, automatic execution of every installed addon, package-specific rendering features, and changing remotesReady into full readiness.
Avoided Traps
Removing node_modules exclusions wholesale; hardcoding an npm scope; admitting sibling paths outside declared roots; inferring the workspace from a symlink's physical depth; compile-only proof without executing the addon; calling a no-op mock a listener-lifecycle witness.
Ownership and sweeps
Sophie owns this selected host dependency; Vega offered the PR review. Parent #20667's steward and the #20778 owner confirmed the separate Main boundary before filing. No existing contributor claim is displaced.
Live latest-open + closed sweep: all 39 open issues read (orange band), latest20 refreshed immediately before filing; closed searches for Main addon package and mainAddonContextPlugin, with #17907/#20697 bodies and exclusions read. They preserve workspace loading and do not supply package loading. Open #20778 is worker-only; #20820 is the independent Collection contract. Latest30 all-read-state A2A scan found the steward's admission, no competing claim. Own assignments #20820 and #20185 do not cover this loader. Memory sweep recovered Main lifecycle precedent and the steward's current boundary; exact source and the actual failed specifier probe govern. Structural owner: existing Main loader, webpack context helpers and consumer guard; no Agent OS placement.
Origin Session ID: 9bf9ac41-3a89-436f-9bdb-2e38327937eb
Retrieval Hint: "installed package Main addon importAddonModule declared manifest roots WS optional consumer build"