Skip to content

fix(daemon-client): decide that a daemon is unresponsive with the same three probes on every path - #4808

Merged
thymikee merged 3 commits into
mainfrom
t3/shared-liveness-verdict
Nov 20, 2026
Merged

thymikee merged 3 commits into
mainfrom
t3/shared-liveness-verdict

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Problem

Two paths end a daemon because it answers nothing, and they required different evidence:

  • ensureDaemon() asks three liveness probes (1 s each, 200 ms apart) before it force-retires a daemon.
  • A timed-out reset-eligible request (daemon-client-timeout.ts) asked one probe, then sent SIGKILL.

One missed probe is the weaker evidence on the path that kills without a grace period. On an overloaded shared host a healthy daemon can miss a single 1 s window.

Change

answersLivenessProbe moves from daemon-client-ensure.ts into daemon-client-liveness-probe.ts, with its probe count and gap, and takes the same session parameter as one probe. Both paths call it. The copy and its two constants in daemon-client-ensure.ts are deleted.

Cost: a timed-out request against a daemon that answers nothing reports its error up to 2.4 s later (three windows and two gaps, 3.4 s in total, was 1 s). A daemon that answers the first probe costs the same as before. The verdict stays far under the shortest reset-eligible request envelope (90 s default).

Evidence

  • daemon-client-timeout-route.test.ts: the rows "resets a daemon that answers no probe endpoint" and "an attach client leaves a daemon that answers no probe running" now observe 4 connections (the request and three probes). They fail on main's code, which makes 2.
  • packages/daemon-client: 39 files, 348 tests pass. Typecheck, lint, the production-exports audit, the eager-closure gate and the layering scan pass. No allowlist, baseline or budget rows.
  • The pin test still holds one probe window an order of magnitude under the envelope. I did not export the whole verdict budget to pin it directly: the production-exports audit refuses an export that only a test reads.

Size

Production: +24 −16, net +8 lines (the helper's doc comment and the session parameter). No new module on an entry closure, so the built CLI startup cost does not change.

Note: this touches lines next to #4806 in daemon-client-ensure.ts; whichever merges second needs a trivial rebase.

Part of #4649.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

…e three probes on every path

A timed-out request retired a daemon after one missed 1 s liveness probe,
while ensureDaemon required three. Both now ask one helper in the probe
module, so the evidence for ending a daemon is the same everywhere.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.46 MB 6.46 MB +37 B
Package (unpacked) 6.46 MB 6.46 MB +37 B
Package (download) 1.97 MB 1.97 MB +46 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 19.8 ms 21.4 ms +1.6 ms
CLI --help 41.1 ms 45.9 ms +4.8 ms

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 06f1bc6. The code has no problems, all 19 checks pass at this commit, and there are no conflicts. This change is daemon-client liveness policy, so no live device run is needed.

Not blocking, and you can take or leave these: the route test at daemon-client-timeout-route.test.ts:286 asserts the probe count, but no row covers the reported failure, where a healthy daemon misses the first probe and answers a later one (a row with resets: false, the kept-alive hint and the daemon pid still alive would pin it); the comment at daemon-client-liveness-probe.test.ts:49 says a request pays three probe windows while the assertion pins one; and the hint at daemon-client-timeout.ts:195 still says "liveness probe" in the singular, as does its pattern in the route test.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
thymikee and others added 2 commits November 20, 2026 15:58
* origin/main:
  refactor(apple-runner): generate the Swift runner error-code enums from runner-contract.ts (#4810)
  fix(daemon-client): report a newer daemon that won a startup race as daemon-incompatible (#4801)
  feat(shake): add a shake command for iOS simulators and Android emulators (#4741)
  fix(daemon): give a closing daemon its full teardown before anything kills it (#4806)
  fix(android): use typed evidence in the readiness boot poller (#4717)
…nswers a later one

Also makes the unanswered-probe hints plural and corrects the pin comment.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Review notes addressed in e20757d (main merged in; no conflict with #4806).

  • Route row: "keeps a daemon that misses the first probe and answers a later one". The stand-in drops the first probe connection and answers the next. The row expects 3 connections, the kept-alive hint, and resets: false, so the registration and the lock stay. On main this daemon is reset after the single missed probe.
  • Pin comment: now says the assertion pins one window and that three stay under the same envelope.
  • Hint: "did not answer the liveness probes" in both timeout hints; the two tests that pin the text are updated.

packages/daemon-client passes locally, with lint and typecheck.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of e20757d

Since the review of 06f1bc6: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (520e2ca3c27d).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee
thymikee merged commit ae9f203 into main Nov 20, 2026
18 checks passed
@thymikee
thymikee deleted the t3/shared-liveness-verdict branch November 20, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant