You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
flaky: usage-projection 'newer stored projection version' gets exit 13 (unsettled top-level await) from simlock daemon start under load #790
bug:blockedAgent stopped on a blocker in its handoff. Maintainer re-adds the label it came from.flaky-testNames a test that fails without a code change. Delivery skips its base-commit check.
Test: `e2e/usage-projection.test.ts` > usage projection > `a history.db with a newer stored projection version makes simlock daemon start fail with exit 1 and leaves the file's rows unchanged`.
Failure: `expected 13 to be 1` at the `started.code` assertion. The CLI's stderr in a failing run is Node's `Warning: Detected unsettled top-level await at dist/cli/main.js:3` (`process.exitCode = await runCli(...)`): exit 13 is Node's code for a never-settling promise, not a Simlock error code. The passing runs print `DAEMON_STARTUP_FAILED` with exit 1.
Reproduced on base commit 80cba39 (before task #774): 3 of 18 runs of that one test, 6 at a time in parallel to load the machine. Also failed in CI run 39481062187 (E2E 2/3) on PR #788, whose diff touches no CLI, launcher or history code.
Likely area: `simlock daemon start` waiting on the detached, unref'd daemon child exiting while no ref'd handle keeps the event loop alive.
Defect, confirmed. src/cli/index.test.ts > "fails a start with DAEMON_STARTUP_FAILED, exit 1, when the daemon it launched closes the socket before the CLI's hello" (branch bug/790-repro, 39b047b). A real Unix socket accepts and destroys the connection; the CLI gets it already closed.
pnpm exec vitest run --project unit src/cli/index.test.ts -t "closes the socket before the CLI's hello"
AssertionError: simlock daemon start still had not settled at 5000ms: expected false to be true
Root cause
src/simlock-client/wire.ts:132 subscribes to close with connection.onClose, which is socket.once("close") (src/ports/ipc.ts:107) and never fires for a socket that has already closed; then write on a closed connection resolves without sending (src/ports/ipc.ts:118). So hello (wire.ts:144) waits forever. The window: src/cli/environment.ts:233 resolves the credential (3 admin.token reads, 50 ms apart) between the socket connect and new SimlockWire. The daemon listens first, then refuses the newer projection version asynchronously and stops (src/daemon/main.ts:1503), closing that connection inside the window. The detached child is unref'd and no timer is pending, so Node's loop drains: exit 13. The 20 s startup deadline does not cover hello.
Simplest fix
SimlockWire: in the constructor, if (connection.closed) this.#die(DAEMON_CONNECTION_LOST); move the #dead check from call into #send so hello rejects too.
Both together turn the test green, along with the 403 other tests in src/cli/index.test.ts, src/simlock-client and src/admin (tried locally, not pushed).
Alternatives rejected
Replay close in NodeIpcConnection.onClose: the fake transports have the same gap; the wire covers all transports.
Keep a ref'd timer in main.ts: hides the hang as a 20 s timeout.
Done: fix built and audited in PR #805 (head 40a3dc2); review round 1 complete, 0 blocking; review ledger and notes posted; PR is ready.
Not done: merge. merge-pr.sh 805 refused twice: CI not green (Unit tests, so Quality).
Findings: the only failing test is src/agent-device/gateway-front.test.ts "a download with no content-length that passes 2147483648 bytes…" (flaky-test #807). A fix run reproduced it 3/3 on both this branch and origin/main 4cc44f8 (about 2.144–2.146 GB delivered, under the 2 GiB assertion), so it is not caused by this PR. Main itself is likely red on this test.
Blocked on: #807. Once fixed, run the gate on #805 again; no code change needed.
Merged: #804 (#802)
Parked: #790 — gate refused twice, red CI only from flaky-test #807 (also fails on main); PR #805 is ready and reviewed
Waiting: #790 — on #807
bug:blockedAgent stopped on a blocker in its handoff. Maintainer re-adds the label it came from.flaky-testNames a test that fails without a code change. Delivery skips its base-commit check.
Activity
V3RON commentedon Oct 21, 2026
Reproduction
Defect, confirmed.
src/cli/index.test.ts> "fails a start with DAEMON_STARTUP_FAILED, exit 1, when the daemon it launched closes the socket before the CLI's hello" (branchbug/790-repro, 39b047b). A real Unix socket accepts and destroys the connection; the CLI gets it already closed.Root cause
src/simlock-client/wire.ts:132subscribes to close withconnection.onClose, which issocket.once("close")(src/ports/ipc.ts:107) and never fires for a socket that has already closed; thenwriteon a closed connection resolves without sending (src/ports/ipc.ts:118). Sohello(wire.ts:144) waits forever. The window:src/cli/environment.ts:233resolves the credential (3admin.tokenreads, 50 ms apart) between the socket connect andnew SimlockWire. The daemon listens first, then refuses the newer projection version asynchronously and stops (src/daemon/main.ts:1503), closing that connection inside the window. The detached child isunref'd and no timer is pending, so Node's loop drains: exit 13. The 20 s startup deadline does not coverhello.Simplest fix
SimlockWire: in the constructor,if (connection.closed) this.#die(DAEMON_CONNECTION_LOST); move the#deadcheck fromcallinto#sendsohellorejects too.AutoLaunchAdminConnector.connect(environment.ts:55): after a launch, aDAEMON_CONNECTION_LOSTfrom the handshake becomesDAEMON_STARTUP_FAILED, likefinishConnectiondoes for the probe (daemon start reports DAEMON_CONNECTION_LOST for a daemon that never came up #684).Both together turn the test green, along with the 403 other tests in
src/cli/index.test.ts,src/simlock-clientandsrc/admin(tried locally, not pushed).Alternatives rejected
NodeIpcConnection.onClose: the fake transports have the same gap; the wire covers all transports.main.ts: hides the hang as a 20 s timeout.DAEMON_CONNECTION_LOST, contradicting daemon start reports DAEMON_CONNECTION_LOST for a daemon that never came up #684.Risk
DAEMON_STARTUP_FAILEDtoo.DAEMON_CONNECTION_LOST(existing daemon start reports DAEMON_CONNECTION_LOST for a daemon that never came up #684 test).Written by an agent.
test: report a closed handshake as a failed start only after launch (#…
fix(mcp): classify handshake loss after launch as startup failure (#790)
test: close startup handshake audit gaps (#790)
V3RON commentedon Oct 21, 2026
Handoff
Done: fix built and audited in PR #805 (head 40a3dc2); review round 1 complete, 0 blocking; review ledger and notes posted; PR is ready.
Not done: merge.
merge-pr.sh 805refused twice: CI not green (Unit tests, so Quality).Findings: the only failing test is
src/agent-device/gateway-front.test.ts"a download with no content-length that passes 2147483648 bytes…" (flaky-test #807). A fix run reproduced it 3/3 on both this branch and origin/main 4cc44f8 (about 2.144–2.146 GB delivered, under the 2 GiB assertion), so it is not caused by this PR. Main itself is likely red on this test.Blocked on: #807. Once fixed, run the gate on #805 again; no code change needed.
Written by an agent.
V3RON commentedon Oct 21, 2026
Delivery run
Merged: #804 (#802)
Parked: #790 — gate refused twice, red CI only from flaky-test #807 (also fails on main); PR #805 is ready and reviewed
Waiting: #790 — on #807
Written by an agent.