Context
Grace's coverage question on neo-agent-brain PR #484 (the Brain's engine pin moved a month, 17b59aad → 7f16355a) asked for the full Brain unit suite at that head diffed against dev's known-red baseline. The receipt is on neo-agent-brain#482. Its only pin-attributable delta is nine red arms in two Brain specs whose subject is this repository's src/ai/Client.mjs:
test/playwright/unit/ai/ClientAgentDisconnect.spec.mjs (6 arms)
test/playwright/unit/ai/ClientWindowRegistration.spec.mjs (3 arms)
Both set client.isConnected = false in beforeEach. 4802862b73 (#18956, PR #18970) made isConnected a getter that reads this.socket?.socket?.readyState === WebSocket.OPEN (src/ai/Client.mjs:110), so the assignment throws TypeError: Cannot set property isConnected of #<Client> which has only a getter. Same tree minus the bump (77bfa56, engine 17b59aad): all nine arms pass. Head (c749efc, engine 7f16355a): all nine fail. Nothing else in the two runs' failing sets differs by more than the arms PR #484 added.
No engine runtime path changed for the Brain: no Brain runtime module assigns isConnected or imports the client (checked at neo-agent-brain origin/dev), so the plane recut that ships the new pin is unaffected. The break is confined to tests, and it stayed invisible for 20 days because the tests live in a repository whose CI never executes them.
The Problem
c623b2f63c (#17806) moved the unit specs of the Engine-side src/ai/** surface into the Brain together with the Brain implementation. #17968 (PR #18002) restored twelve of them; eleven more remain, all brain-only (no engine spec of the same name), all importing the engine as a package:
Brain spec (test/playwright/unit/ai/) |
engine subject |
ClientAgentDisconnect.spec.mjs |
src/ai/Client.mjs |
ClientDispatcher.spec.mjs |
src/ai/Client.mjs |
ClientWindowRegistration.spec.mjs |
src/ai/Client.mjs |
InstanceServiceCreateInstance.spec.mjs |
src/ai/client/InstanceService.mjs, TransactionService.mjs, WriteGuard.mjs |
InstanceServiceCreateUndoCapture.spec.mjs |
same |
InstanceServiceListTransactions.spec.mjs |
src/ai/client/InstanceService.mjs, TransactionService.mjs |
InstanceServiceNamedTransaction.spec.mjs |
same |
InstanceServiceRedo.spec.mjs |
src/ai/client/InstanceService.mjs, TransactionService.mjs, WriteGuard.mjs |
InstanceServiceRemoveUndoCapture.spec.mjs |
same |
InstanceServiceUndo.spec.mjs |
same |
InstanceServiceUndoCapture.spec.mjs |
same |
Census: git grep -l 'neo\.mjs/src/ai/' origin/dev -- test/playwright/unit in neo-agent-brain (11 files, 2026-09-25), basenames compared against git ls-tree -r --name-only 7f16355a test/playwright/unit here (0 shared).
Three consequences, in the order they bit:
- The engine cannot fail on its own contract change. #18970 changed how
isConnected is read; the engine's unit check had nothing to run against it, and the PR merged green.
- The Brain cannot fail either.
brain-unit.yml executes a named run list (neo-agent-brain#201, the collected-not-executed class); none of the eleven is on it. The reds surfaced only through a manual full-suite run 20 days later.
- The Brain's next pin bump inherits the break and has to reason about a test failure whose fix is not in its repository.
This is the general sweep #17968 scoped out ("a general 'does this deleted spec's subject still exist in the Engine?' sweep is worth doing and is not this"), bounded to the population that still imports src/ai/**.
The Architectural Reality
src/ai/Client.mjs:110 — get isConnected() reads the socket; its docblock states why a flag was wrong (a failing socket reports error before close, and a stale flag routes the failure's own log through the failed socket).
- The engine's unit tree already holds this subject family:
test/playwright/unit/ai/{LockRegistry,TransactionService,WriteGuard,admitWrite,deriveSubtreePath,parseAgentEnvelope,resolveWriteLock}.spec.mjs and test/playwright/unit/ai/client/{ComponentService,DockService,InstanceService,InteractionService,RuntimeService,TourRunner,…}.spec.mjs, restored by PR #18002 with relative src/ imports (test/playwright/unit/ai/TransactionService.spec.mjs:2-5). That is the placement precedent; no new directory.
npm run test-unit (playwright.config.unit.mjs, project unit-engine, testDir: unit) executes everything under test/playwright/unit/; test.yml's unit suite runs exactly that whenever the change classifier's run_unit fires, so an adopted spec executes on every engine PR that touches its subject.
- The Brain specs run under its
unit-brain project and import the engine as a package (await import('neo.mjs/src/ai/Client.mjs'), ClientAgentDisconnect.spec.mjs:64) with a Brain-local setup helper; adoption replaces both with the engine's relative-import shape.
The Fix
One engine PR:
- Adopt the eleven specs under
test/playwright/unit/ai/ (Client*) and test/playwright/unit/ai/client/ (InstanceService*), with relative src/ imports and the engine's own unit setup, following PR #18002's shape. Arms that duplicate an already-restored engine spec are dropped, not copied.
- In the two
isConnected specs, drive the getter's real input instead of assigning it: give the client a socket double whose socket.readyState is WebSocket.OPEN / CLOSED per arm. The assertion set stays; only the fixture moves to the contract #18970 defined.
- The Brain deletes its eleven copies once this merges (neo-agent-brain#486), so neither repository holds a second authority.
Decision Record impact: none. Custody precedent: #17968 / PR #18002.
Acceptance Criteria
Out of Scope
- The Brain's other retained-suite classes (missing inputs, order pollution, obsolete surfaces): neo-agent-brain#201 / #191 own their dispositions.
- Changing
isConnected back to a flag, or any src/ai runtime change.
- The engine's
checkEngineBrainBoundary.spec.mjs, which references src/ai/Client.mjs as a boundary fixture, not as a subject.
Related
- #17968 / PR #18002 — the first twelve restored; the custody decision this continues.
- #18956 / PR #18970 (
4802862b73) — the contract change that broke the two specs.
- neo-agent-brain#482 / PR #484 — the pin bump and the full-suite receipt.
- neo-agent-brain#201 — the Brain's run list; the reason the reds were invisible.
- neo-agent-brain#486 — the Brain-side deletion plus the
prepare.spec.mjs run-list line.
Live latest-open sweep: checked the latest 20 open issues in neomjs/neo and neomjs/neo-agent-brain at 2026-09-25T12:40:25Z; no equivalent found. A2A in-flight sweep: the last 30 messages (12:04–12:35Z), no claim on this scope.
MC sweep: two query_raw_memories calls on the symptom's nouns (tests of engine code held by the Brain breaking at a pin bump; spec assigns a property the engine changed) — the only prior decision is #17968's custody ruling, which this continues; no competing decision.
Own-assignment sweep: 6 open in neomjs/neo, none on this surface.
Structure map: npm run ai:structure-map -- --files --loc run in the Brain (exit 0); no row owns unit-test placement — the precedent is the engine's own test/playwright/unit/ai/ tree above.
Origin Session ID: d19add67-d33c-489d-99aa-27ad2782ed5e
Retrieval Hint: "Brain-held src/ai unit specs isConnected getter custody move"
Context
Grace's coverage question on neo-agent-brain PR #484 (the Brain's engine pin moved a month,
17b59aad→7f16355a) asked for the full Brain unit suite at that head diffed against dev's known-red baseline. The receipt is on neo-agent-brain#482. Its only pin-attributable delta is nine red arms in two Brain specs whose subject is this repository'ssrc/ai/Client.mjs:test/playwright/unit/ai/ClientAgentDisconnect.spec.mjs(6 arms)test/playwright/unit/ai/ClientWindowRegistration.spec.mjs(3 arms)Both set
client.isConnected = falseinbeforeEach.4802862b73(#18956, PR #18970) madeisConnecteda getter that readsthis.socket?.socket?.readyState === WebSocket.OPEN(src/ai/Client.mjs:110), so the assignment throwsTypeError: Cannot set property isConnected of #<Client> which has only a getter. Same tree minus the bump (77bfa56, engine17b59aad): all nine arms pass. Head (c749efc, engine7f16355a): all nine fail. Nothing else in the two runs' failing sets differs by more than the arms PR #484 added.No engine runtime path changed for the Brain: no Brain runtime module assigns
isConnectedor imports the client (checked at neo-agent-brainorigin/dev), so the plane recut that ships the new pin is unaffected. The break is confined to tests, and it stayed invisible for 20 days because the tests live in a repository whose CI never executes them.The Problem
c623b2f63c(#17806) moved the unit specs of the Engine-sidesrc/ai/**surface into the Brain together with the Brain implementation. #17968 (PR #18002) restored twelve of them; eleven more remain, allbrain-only(no engine spec of the same name), all importing the engine as a package:test/playwright/unit/ai/)ClientAgentDisconnect.spec.mjssrc/ai/Client.mjsClientDispatcher.spec.mjssrc/ai/Client.mjsClientWindowRegistration.spec.mjssrc/ai/Client.mjsInstanceServiceCreateInstance.spec.mjssrc/ai/client/InstanceService.mjs,TransactionService.mjs,WriteGuard.mjsInstanceServiceCreateUndoCapture.spec.mjsInstanceServiceListTransactions.spec.mjssrc/ai/client/InstanceService.mjs,TransactionService.mjsInstanceServiceNamedTransaction.spec.mjsInstanceServiceRedo.spec.mjssrc/ai/client/InstanceService.mjs,TransactionService.mjs,WriteGuard.mjsInstanceServiceRemoveUndoCapture.spec.mjsInstanceServiceUndo.spec.mjsInstanceServiceUndoCapture.spec.mjsCensus:
git grep -l 'neo\.mjs/src/ai/' origin/dev -- test/playwright/unitin neo-agent-brain (11 files, 2026-09-25), basenames compared againstgit ls-tree -r --name-only 7f16355a test/playwright/unithere (0 shared).Three consequences, in the order they bit:
isConnectedis read; the engine'sunitcheck had nothing to run against it, and the PR merged green.brain-unit.ymlexecutes a named run list (neo-agent-brain#201, the collected-not-executed class); none of the eleven is on it. The reds surfaced only through a manual full-suite run 20 days later.This is the general sweep #17968 scoped out ("a general 'does this deleted spec's subject still exist in the Engine?' sweep is worth doing and is not this"), bounded to the population that still imports
src/ai/**.The Architectural Reality
src/ai/Client.mjs:110—get isConnected()reads the socket; its docblock states why a flag was wrong (a failing socket reportserrorbeforeclose, and a stale flag routes the failure's own log through the failed socket).test/playwright/unit/ai/{LockRegistry,TransactionService,WriteGuard,admitWrite,deriveSubtreePath,parseAgentEnvelope,resolveWriteLock}.spec.mjsandtest/playwright/unit/ai/client/{ComponentService,DockService,InstanceService,InteractionService,RuntimeService,TourRunner,…}.spec.mjs, restored by PR #18002 with relativesrc/imports (test/playwright/unit/ai/TransactionService.spec.mjs:2-5). That is the placement precedent; no new directory.npm run test-unit(playwright.config.unit.mjs, projectunit-engine,testDir: unit) executes everything undertest/playwright/unit/;test.yml'sunitsuite runs exactly that whenever the change classifier'srun_unitfires, so an adopted spec executes on every engine PR that touches its subject.unit-brainproject and import the engine as a package (await import('neo.mjs/src/ai/Client.mjs'),ClientAgentDisconnect.spec.mjs:64) with a Brain-localsetuphelper; adoption replaces both with the engine's relative-import shape.The Fix
One engine PR:
test/playwright/unit/ai/(Client*) andtest/playwright/unit/ai/client/(InstanceService*), with relativesrc/imports and the engine's own unit setup, following PR #18002's shape. Arms that duplicate an already-restored engine spec are dropped, not copied.isConnectedspecs, drive the getter's real input instead of assigning it: give the client a socket double whosesocket.readyStateisWebSocket.OPEN/CLOSEDper arm. The assertion set stays; only the fixture moves to the contract #18970 defined.Decision Record impact: none. Custody precedent: #17968 / PR #18002.
Acceptance Criteria
ClientAgentDisconnectandClientWindowRegistrationarms pass againstget isConnected()by controlling the socket double'sreadyState; no arm assignsisConnected.npm run test-unitat the PR head executes the adopted specs (the run's[n/N]lines name them) and is green.Out of Scope
isConnectedback to a flag, or anysrc/airuntime change.checkEngineBrainBoundary.spec.mjs, which referencessrc/ai/Client.mjsas a boundary fixture, not as a subject.Related
4802862b73) — the contract change that broke the two specs.prepare.spec.mjsrun-list line.Live latest-open sweep: checked the latest 20 open issues in neomjs/neo and neomjs/neo-agent-brain at 2026-09-25T12:40:25Z; no equivalent found. A2A in-flight sweep: the last 30 messages (12:04–12:35Z), no claim on this scope. MC sweep: two
query_raw_memoriescalls on the symptom's nouns (tests of engine code held by the Brain breaking at a pin bump; spec assigns a property the engine changed) — the only prior decision is #17968's custody ruling, which this continues; no competing decision. Own-assignment sweep: 6 open in neomjs/neo, none on this surface. Structure map:npm run ai:structure-map -- --files --locrun in the Brain (exit 0); no row owns unit-test placement — the precedent is the engine's owntest/playwright/unit/ai/tree above.Origin Session ID: d19add67-d33c-489d-99aa-27ad2782ed5e Retrieval Hint: "Brain-held src/ai unit specs isConnected getter custody move"