Skip to content

fix(daemon): daemon start fails when the HTTP listener cannot bind - #990

Merged
V3RON merged 11 commits into
mainfrom
bug/981
Oct 25, 2026
Merged

V3RON merged 11 commits into
mainfrom
bug/981

Conversation

@V3RON

@V3RON V3RON commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #981

Status

Implement: done Review: fix-check passed, 0 open Hardware: n/a Gate: running
Next: gate

Done when:

  • A daemon whose HTTP listener cannot bind never reports running, emits no daemon.started, and stops with http-start-failed (src/daemon/main.test.ts, "fails a start whose HTTP listener cannot bind before it reports running"), for both worker and gateway, with the bind held until convergence; mutation-probed in audit and review.
  • simlock daemon start on a daemon that cannot bind prints DAEMON_STARTUP_FAILED with the daemon's own error, exit 1, never Daemon running (e2e/start-refusal.test.ts and e2e/console/daemon-start-failure.spec.ts, run green at af921a6).
  • The comments and docs the triage named are true (e2e/helpers/env.ts, http-daemon.ts, docs/internal/flows/startup.md, src/daemon/AGENTS.md, cli.mdx, errors.mdx); the stale-ref sweep was clean and the claims lens checked them.

Assumptions

  • Assumption: how long daemon start waits for starting to end — 90 s (STARTUP_READ_LIMIT_MS 60 s plus 30 s), then DAEMON_STARTUP_FAILED ("still starting") with the daemon left running; bounded above the daemon's own startup read so a slow but healthy start is not failed, and a stuck one cannot hang the CLI (decided in delivery, pending the maintainer).
  • Assumption: a daemon without a child (service manager) — the CLI waits 2 s for an exit, then reads the log for the daemon's own error.

Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 4 blocking, 4 fixed, 1 notes. Claims review: 0 blocking, 0 fixed, 0 notes.
Rounds: 2. Tokens: 31.3M.
Runs: 14. Cost USD: 5.7651. Agent seconds: 3299.
Assessment: complete

Rejected:

  • spec: the 90 s wait decides behaviour the issue left open — [intentional] decided in delivery, pending the maintainer (PR comment "Decision taken").
  • code: the untilStarted guard in failStoppingStart has no test of its own — [nonblocking] without it, only the error code changes, in a rare race.

Written by an agent.

@V3RON

V3RON commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Decision taken

Question. After launching the daemon, how long does simlock daemon start wait for health to leave starting?

Options.

  1. No CLI deadline (what the build did). A user whose daemon hangs in convergence sees daemon start hang with no output until they press Ctrl-C.
  2. A bounded wait, above the daemon's own startup-read cap (STARTUP_READ_LIMIT_MS, 60 s). On expiry the command fails with DAEMON_STARTUP_FAILED saying the daemon is still starting, and leaves the daemon running. A user with a hung daemon gets an error and exit 1 instead of a hang.

Taken: 2. It is closest to today, because the CLI's start is already bounded (DAEMON_STARTUP_TIMEOUT_MS), and it never leaves a script waiting forever. The implementer picks the exact bound above 60 s and records it as an Assumption.

Reverting means removing the deadline from the wait loop and its test.

Written by an agent.

@V3RON

V3RON commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Decision taken

Question. During daemon start, the startup status probe can reach a daemon that is already stopping. What does the user see?

Options.

  1. Pass DAEMON_STOPPING through, as fix(cli): a daemon launched by daemon start that dies during that start reports DAEMON_STARTUP_FAILED #710's test pinned. The user sees "Daemon is stopping" and not why the start failed.
  2. Count it as a failed start: DAEMON_STARTUP_FAILED with the daemon's own error from its log (for example EADDRINUSE and the port).

Taken: 2. It follows the maintainer's #981 decision: a daemon that ends while starting reports its own error. #710's test now expects option 2.

Reverting means restoring #710's pass-through in src/cli/environment.ts and its test (decided in delivery, pending the maintainer).

Written by an agent.

@V3RON

V3RON commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Review ledger

Round 1: 8ae75fd
Round 2: ab584d8
Round fix-check: af921a6

Runs: 14. Cost USD: 5.7651. Agent seconds: 3299.
Tokens input 556, output 134814, cache read 12530571, cache write 769326.
- build implementer: claude-sonnet-5-5 548 s $0.6848
- build implementer: claude-sonnet-5-5 159 s $0.3337
- audit implementer: claude-sonnet-5-5 358 s $0.3194
- fix implementer: claude-sonnet-5-5 128 s $0.2248
- review 1 reviewer: claude-sonnet-5-5 524 s $0.3704
- review 1 spec: claude-sonnet-5-5 21 s $0.1266
- review 1 code both: claude-opus-5-5 419 s $1.4497
- review 1 claims: claude-sonnet-5-5 25 s $0.1371
- fix 1 implementer: claude-sonnet-5-5 254 s $0.4209
- review 2 reviewer: claude-sonnet-5-5 60 s $0.1786
- fix 2 implementer: claude-sonnet-5-5 181 s $0.1526
- review fix-check reviewer: claude-sonnet-5-5 323 s $0.17
- review fix-check code both: claude-opus-5-5 255 s $1.0294
- review fix-check claims claims: claude-sonnet-5-5 44 s $0.1671
Finding outcomes: {"duplicate":1,"fixed":4,"intentional":1,"nonblocking":1}. Classes: {"assumption decides unspecified user-visible behaviour":1,"documentation 9":1,"error on stopping daemon hides start cause":1,"test premise made false by PR":1,"testing 10":1,"testing 3":1,"testing 7":1}.
{
 "findings": [
  {
   "id": "R1",
   "role": "code",
   "class": "error on stopping daemon hides start cause",
   "outcome": "fixed",
   "path": "src/cli/environment.ts",
   "round": "1",
   "fix": "ab584d8de4224bad5427fa7886043aeb6bbcb0f2"
  },
  {
   "id": "R2",
   "role": "code",
   "class": "testing 10",
   "outcome": "fixed",
   "path": "src/cli/index.test.ts",
   "round": "1",
   "fix": "ab584d8de4224bad5427fa7886043aeb6bbcb0f2"
  },
  {
   "id": "R3",
   "role": "code",
   "class": "documentation 9",
   "outcome": "fixed",
   "path": "website/src/content/docs/docs/reference/errors.mdx",
   "round": "1",
   "fix": "ab584d8de4224bad5427fa7886043aeb6bbcb0f2"
  },
  {
   "id": "R4",
   "role": "spec",
   "class": "assumption decides unspecified user-visible behaviour",
   "outcome": "intentional",
   "path": "src/cli/environment.ts",
   "round": "1"
  },
  {
   "id": "R5",
   "role": "spec",
   "class": "testing 7",
   "outcome": "duplicate",
   "canonicalId": "R4",
   "path": "src/cli/index.test.ts",
   "round": "1"
  },
  {
   "id": "R6",
   "role": "code",
   "class": "test premise made false by PR",
   "outcome": "fixed",
   "path": "e2e/console/daemon-start-failure.spec.ts",
   "round": "2",
   "fix": "af921a62557af3e7a211321d4064290b6e9e7f21"
  },
  {
   "id": "R7",
   "role": "code",
   "class": "testing 3",
   "outcome": "nonblocking",
   "path": "src/cli/environment.ts",
   "round": "fix-check"
  }
 ]
}

Written by an agent.

@V3RON

V3RON commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

Not blocking and not verified. Each is one reviewer's claim.

  • code: src/cli/environment.ts:129. Deleting the options?.untilStarted === true guard in failStoppingStart keeps all 383 tests green. Without it, a command that auto-launches a daemon and meets a stopping one would report DAEMON_STARTUP_FAILED instead of DAEMON_STOPPING.

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review October 25, 2026 09:27
@V3RON
V3RON merged commit 8d79006 into main Oct 25, 2026
62 checks passed
@V3RON
V3RON deleted the bug/981 branch October 25, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

daemon start reports success when the daemon cannot bind its HTTP port

1 participant