Context
The Fleet Manager's Electron packaging (neomjs/neo-agent-institution harness/pack.mjs) stages the organism and runs npm install on a generated manifest that pins the engine by commit: neo.mjs: github:neomjs/neo#d85060795d8abc99a7d6186968a35e9b8b77188b. On 2026-09-25 that install failed:
npm error code: 'EEXIST', syscall: 'symlink',
npm error path: '../../node_modules/neo-agent-skills/.agents/skills/architecture-pre-flight',
npm error dest: '/Users/Shared/…/neo-agent-institution/harness/.stage/organism/.claude/skills/architecture-pre-flight'
The stage root had gained .agents/skills and .claude/skills/* symlinks it never asked for, dangling (the stage's own node_modules/neo-agent-skills was not installed yet). Observation and inference are separated below.
The Problem
buildScripts/util/prepare.mjs is the engine's prepare lifecycle: husky, then neo-agent-skills-materialize. Its header says the materializer runs from prepare "never from postinstall: npm runs a dependency's postinstall inside every consumer's install … while a registry or tarball install never runs prepare" (prepare.mjs:28-31). That sentence is true for registry installs and false for git-dependency installs: npm builds a git dependency by cloning it to a cache directory and running its prepare there — with INIT_CWD set to the directory the top-level npm install was invoked from, i.e. the consumer's root.
The materializer resolves its target as args.root || consumerRoot(), and consumerRoot() returns INIT_CWD when set (neo-agent-skills/scripts/materialize-harness-skills.mjs, consumerRoot). So an engine pinned as github:neomjs/neo#<sha> materializes the engine's skills façade into whatever directory installed it. In the Institution's stage that root also receives the brain's postinstall materialization (the second git dependency, neo-agent-brain#8e09275, declares postinstall: neo-agent-skills-materialize); npm runs the two in parallel, and the loser of the rm→mkdir→symlink race exits with EEXIST. Every consumer that pins the engine by commit gets the façade written into its root on install; the race only makes it loud.
Falsifier run (2026-09-25, same tree): npm_config_ignore_scripts=true node pack.mjs — the stage completes, @electron/rebuild rebuilds the natives, organism staged … (rebuilt=true), exit 0. Nothing else in the install depends on the engine's prepare.
The Architectural Reality
buildScripts/util/prepare.mjs — runPrepare({root, env, spawnFn}) returns {skipped, stage, status}; the only guard today is npm_config_package_lock_only === 'true' → {skipped: 'package-lock-only'}. Both stages spawn with cwd: root.
- The stages provision the engine's own checkout: husky writes the checkout's git hooks, the materializer projects the checkout's
.agents/skills + .claude/skills. Neither has a meaning inside a consumer's node_modules or a cache clone.
- npm sets
INIT_CWD for every lifecycle script to the invoking directory; a prepare running in the engine's own checkout sees INIT_CWD === repoRoot (also under npm ci, npm install, npm run prepare from the root); a git-dependency build sees a foreign INIT_CWD. That is the discriminator — no npm flag or cwd heuristic is needed.
test/playwright/unit/buildScripts/prepare.spec.mjs pins the lock-only guard, stage order and failure propagation with an injected spawnFn; the new guard pins into the same spec.
The Fix
runPrepare gains a second guard beside the lock-only one: when env.INIT_CWD is set and does not resolve (realpath, falling back to lexical resolution) to root, return {skipped: 'dependency-build', stage: 'guard', status: 0} before any stage spawns. Header docs correct the "never runs prepare" sentence to name the git-dependency case. Nothing changes for a checkout install: husky and the materializer run exactly as today.
Contract Ledger Matrix
| Target surface |
Source of authority |
Proposed behavior |
Fallback |
Docs |
Evidence |
runPrepare (buildScripts/util/prepare.mjs) |
npm lifecycle contract (INIT_CWD); this ticket |
foreign INIT_CWD → skipped: 'dependency-build', status 0, no spawn; same or unset INIT_CWD → unchanged |
none — the guard is total |
the file header |
red-first spec arms below |
Decision Record impact
none — no ADR governs the prepare lifecycle; ADR 0020 §3 (consumers install the engine as a dependency, no source-tree mixing) is the reason the guard is correct.
Acceptance Criteria
Out of Scope
- The materializer's
INIT_CWD root resolution in neomjs/neo-agent-skills (correct for a consumer's own postinstall; the caller is what is wrong here).
neomjs/neo-agent-brain's postinstall: neo-agent-skills-materialize running inside its consumers (defect-noted separately; the Brain's call).
- Making
pack.mjs ignore lifecycle scripts — the probe used that to falsify the cause, not as the fix; the stage must keep running the natives' install scripts.
Related
neomjs/neo-agent-institution#7 (the Electron shell epic; the failing pack) · neomjs/neo-agent-skills scripts/materialize-harness-skills.mjs (consumerRoot) · #19198 (the engine's skills pin 0.1.16) · Ada's 2026-09-05 Institution-CI EEXIST diagnosis (same symptom class at the Institution root)
Live latest-open sweep: checked the latest 20 open issues at 2026-09-25 10:13Z; no equivalent. A2A claim sweep (last 60 min): no overlapping [lane-claim]. Memory Core sweep: the 2026-09-05 EEXIST diagnosis is the nearest prior art (Institution CI, root materialization), no prior decision on the engine's prepare. Own-assignment sweep: none on this surface.
Origin Session ID: 0fbfde3a-e817-4859-9351-2269eabdda9a
Retrieval Hint: "prepare.mjs git-dependency INIT_CWD materializer EEXIST harness pack stage"
Context
The Fleet Manager's Electron packaging (
neomjs/neo-agent-institutionharness/pack.mjs) stages the organism and runsnpm installon a generated manifest that pins the engine by commit:neo.mjs: github:neomjs/neo#d85060795d8abc99a7d6186968a35e9b8b77188b. On 2026-09-25 that install failed:The stage root had gained
.agents/skillsand.claude/skills/*symlinks it never asked for, dangling (the stage's ownnode_modules/neo-agent-skillswas not installed yet). Observation and inference are separated below.The Problem
buildScripts/util/prepare.mjsis the engine'spreparelifecycle: husky, thenneo-agent-skills-materialize. Its header says the materializer runs fromprepare"never frompostinstall: npm runs a dependency'spostinstallinside every consumer's install … while a registry or tarball install never runsprepare" (prepare.mjs:28-31). That sentence is true for registry installs and false for git-dependency installs: npm builds a git dependency by cloning it to a cache directory and running itspreparethere — withINIT_CWDset to the directory the top-levelnpm installwas invoked from, i.e. the consumer's root.The materializer resolves its target as
args.root || consumerRoot(), andconsumerRoot()returnsINIT_CWDwhen set (neo-agent-skills/scripts/materialize-harness-skills.mjs,consumerRoot). So an engine pinned asgithub:neomjs/neo#<sha>materializes the engine's skills façade into whatever directory installed it. In the Institution's stage that root also receives the brain'spostinstallmaterialization (the second git dependency,neo-agent-brain#8e09275, declarespostinstall: neo-agent-skills-materialize); npm runs the two in parallel, and the loser of the rm→mkdir→symlink race exits with EEXIST. Every consumer that pins the engine by commit gets the façade written into its root on install; the race only makes it loud.Falsifier run (2026-09-25, same tree):
npm_config_ignore_scripts=true node pack.mjs— the stage completes,@electron/rebuildrebuilds the natives,organism staged … (rebuilt=true), exit 0. Nothing else in the install depends on the engine'sprepare.The Architectural Reality
buildScripts/util/prepare.mjs—runPrepare({root, env, spawnFn})returns{skipped, stage, status}; the only guard today isnpm_config_package_lock_only === 'true'→{skipped: 'package-lock-only'}. Both stages spawn withcwd: root..agents/skills+.claude/skills. Neither has a meaning inside a consumer'snode_modulesor a cache clone.INIT_CWDfor every lifecycle script to the invoking directory; apreparerunning in the engine's own checkout seesINIT_CWD === repoRoot(also undernpm ci,npm install,npm run preparefrom the root); a git-dependency build sees a foreignINIT_CWD. That is the discriminator — no npm flag or cwd heuristic is needed.test/playwright/unit/buildScripts/prepare.spec.mjspins the lock-only guard, stage order and failure propagation with an injectedspawnFn; the new guard pins into the same spec.The Fix
runPreparegains a second guard beside the lock-only one: whenenv.INIT_CWDis set and does not resolve (realpath, falling back to lexical resolution) toroot, return{skipped: 'dependency-build', stage: 'guard', status: 0}before any stage spawns. Header docs correct the "never runsprepare" sentence to name the git-dependency case. Nothing changes for a checkout install: husky and the materializer run exactly as today.Contract Ledger Matrix
runPrepare(buildScripts/util/prepare.mjs)INIT_CWD); this ticketINIT_CWD→skipped: 'dependency-build', status 0, no spawn; same or unsetINIT_CWD→ unchangedDecision Record impact
none— no ADR governs the prepare lifecycle; ADR 0020 §3 (consumers install the engine as a dependency, no source-tree mixing) is the reason the guard is correct.Acceptance Criteria
runPrepare({env: {INIT_CWD: '<other dir>'}, spawnFn})returns{skipped: 'dependency-build', stage: 'guard', status: 0}andspawnFnis never called (red ondev).runPrepare({env: {INIT_CWD: <root>}})andrunPrepare({env: {INIT_CWD: <symlink to root>}})run both stages as today.runPrepare({env: {}})(noINIT_CWD) runs both stages as today.harness/pack.mjs's stage install completes with the engine pinned at a commit that carries this guard (recorded on the Institution pin bump, not here).Out of Scope
INIT_CWDroot resolution inneomjs/neo-agent-skills(correct for a consumer's ownpostinstall; the caller is what is wrong here).neomjs/neo-agent-brain'spostinstall: neo-agent-skills-materializerunning inside its consumers (defect-noted separately; the Brain's call).pack.mjsignore lifecycle scripts — the probe used that to falsify the cause, not as the fix; the stage must keep running the natives' install scripts.Related
neomjs/neo-agent-institution#7 (the Electron shell epic; the failing pack) · neomjs/neo-agent-skills
scripts/materialize-harness-skills.mjs(consumerRoot) · #19198 (the engine's skills pin 0.1.16) · Ada's 2026-09-05 Institution-CI EEXIST diagnosis (same symptom class at the Institution root)Live latest-open sweep: checked the latest 20 open issues at 2026-09-25 10:13Z; no equivalent. A2A claim sweep (last 60 min): no overlapping
[lane-claim]. Memory Core sweep: the 2026-09-05 EEXIST diagnosis is the nearest prior art (Institution CI, root materialization), no prior decision on the engine'sprepare. Own-assignment sweep: none on this surface.Origin Session ID: 0fbfde3a-e817-4859-9351-2269eabdda9a Retrieval Hint: "prepare.mjs git-dependency INIT_CWD materializer EEXIST harness pack stage"