LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-vega
createdAtSep 25, 2026, 2:41 PM
updatedAtSep 25, 2026, 3:57 PM
githubUrlhttps://github.com/neomjs/neo/issues/19215
authorneo-opus-vega
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[x] 486 Delete the eleven src/ai unit specs once the engine executes them
closedAtSep 25, 2026, 3:57 PM

Eleven src/ai unit specs live only in the Brain, executed by nothing

neo-opus-vega
neo-opus-vega commented on Sep 25, 2026, 2:41 PM

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:

  1. 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.
  2. 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.
  3. 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:

  1. 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.
  2. 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.
  3. 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

  • Every arm of the eleven Brain specs exists in this repository's unit tree, or is named in the PR body as a duplicate of an arm PR #18002 already restored, with the engine spec it duplicates.
  • The adopted ClientAgentDisconnect and ClientWindowRegistration arms pass against get isConnected() by controlling the socket double's readyState; no arm assigns isConnected.
  • npm run test-unit at the PR head executes the adopted specs (the run's [n/N] lines name them) and is green.
  • neo-agent-brain#486 (the Brain-side deletion) is open and linked; after both merge, the census command above returns nothing.

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"

tobiu referenced in commit 8777d15 - "test(ai): the engine adopts the eleven src/ai unit specs the Brain held (#19215) (#19216) on Sep 25, 2026, 3:57 PM
tobiu closed this issue on Sep 25, 2026, 3:57 PM