Repository navigation
Conversation
Each CLI call to a remote daemon is a new process, so the in-process health cache never hit and every command paid GET /health before POST /rpc. The usable /health answer now also lives in the client state directory, named by a digest of client version, base URL and token. Every RPC sent from it carries the instance preconditions, so a replaced daemon or proxy upstream still answers 409 before dispatch and the client probes again. A cached RPC that fails before it leaves the client opens the /health gate (same recovery budget and typed refusal) and is sent once more. A reply that is not the daemon's JSON-RPC clears the cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Size Report
Startup median (7 runs, lower is better):
|
There was a problem hiding this comment.
All reported issues were addressed across 12 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on 1771b6c. The verdict and the full list are in the summary comment.
- Resend after an unsent cached RPC only on evidence the client's own transport recorded before the connection opened, never on reply details. The gate and resend share the command's remaining budget, and a caller abort during the gate stays request_canceled. - Read the persisted entry only from a bounded regular file the user owns that nobody else can write; links and FIFOs read as a miss. - Clear the cache on any remote 5xx. A timeout clears it only when the timeout route's probe finds the daemon gone or replaced. - Probe /health again before refusing a recording for a capability only the cached answer lacks. - Keep the /health wire declarations in transport (wire-compat), move the request guard and the health gate out of it, and drop the transport -> lifecycle import cycle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fix round at 35e9b68 (security review, Cubic, Apex, CI):
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 35e9b68. The verdict and the full list are in the summary comment.
…eout owner The new daemon-client-request-guard.ts module made src/cli.ts, packages/client and the daemon-client entry evaluate one more module at flat weight plus new transport statements, which the eager-closure no-growth rule refuses. The guard now lives in daemon-client-timeout.ts, which every one of those entries already evaluates, beside the timeout route it must stay apart from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ol too A cached /health answer stands in for the protocol check, so its digest now includes DAEMON_RPC_PROTOCOL_VERSION beside the client version, base URL and token. A protocol change reads as a miss and the client probes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 5a21fb5. The verdict and the full list are in the summary comment.
…tests The request guard now lives in daemon-client-timeout.ts, so a full mock of that module dropped refuseAbortedRequest and the guard with it. The mock now spreads the real module and replaces only handleRequestTimeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A single file held the last identity only, so a client alternating between two remote daemons missed the cache on every call. Each entry now has its own file, named by a prefix of the identity digest; the full digest inside still has to match. The read and write stay the same: verified, bounded, owner-only, atomic 0600. Stale entries are tiny and never read, so nothing evicts them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
|
The change at 84d6878 needs fixes before merge. The saved remote health entry can outlive the evidence that disproves it, and some routes can dispatch or resend without a safe live check. An RPC that relies on saved health, sent to a host that drops packets can time out before it connects (daemon-client-transport.ts:934). The A second independent pass found that a rollback can dispatch to an incompatible daemon (daemon-client-lifecycle.ts:288). After a protocol 3 daemon is saved, the same URL and credential can move to v0.21.16, which speaks protocol 2 and ignores the instance headers. The next CLI call sends the command, while the base probes and refuses first. A current proxy with a rolled-back upstream has the same route. A live compatibility check must run before dispatch whenever a peer can ignore these headers. Saved reuse is safe only when an independently enforced version floor covers both proxy and upstream. A second independent pass found that an RPC error body can pass as a pre-dispatch refusal (daemon-client-transport.ts:570). A JSON-RPC error with A second independent pass found that a second stale-instance refusal keeps a disproved entry (daemon-client-transport.ts:536). The probe saves instance B, C replaces B before the single resend, and the resend refusal is returned without removing B. The next CLI call starts with another refused RPC. Every qualifying mismatch response, including one on the resend, must remove the entry, with no further dispatch. A second independent pass found two timeout eviction errors (daemon-client-transport.ts:373). The probe compares only the endpoint ID, so a proxy that now reports a different upstream keeps the old entry. A caller abort during the probe also reads as unreachable and removes a valid entry. Eviction must compare every saved instance ID, including A second independent pass found that a forced refresh can reuse the entry it should verify (daemon-client-remote-health-gate.ts:77). If the state directory is readable but not writable, removal fails silently and the refresh loads the old entry again. After a daemon upgrade, A second independent pass found that a saved entry can be used without the caller knowing (daemon-client-lifecycle.ts:285). Another CLI can save health between the first lookup and the gate's lookup. The branch then returns without A second independent pass found that upload lease heartbeats have no such recovery (daemon-client-lease-beat.ts:331). A heartbeat that uses saved instance headers and fails before connect removes the entry and reports a failed beat, with no live probe or resend. Every send that relies on saved health, as enumerated by the callers that attach those instance headers, must get the same single refresh and resend, bounded by its own timeout and abort signal. A second independent pass found that a proxy can be saved without an upstream instance ID (saved health, line 45). If the upstream health body is not a readable object, such as JSON A second independent pass found that a reflected credential can reach disk (saved health, line 119). The configured credential is sent on A second independent pass found that an invalid instance ID can lock out a repaired daemon (daemon-client-transport.ts:294). A value with a newline is saved, and Node then rejects it as a header before any request exists, so nothing removes the entry. Every endpoint and upstream instance ID must be a valid HTTP header value before it is saved or accepted from disk. Not blocking: these can be taken or left: a 5xx that is an ordinary daemon command failure also removes the entry (daemon-client-transport.ts:879), so clearing only on other 5xx answers, or documenting this in ADR 0006, could be a follow-up; a rollback to a release without instance headers is an open maintainer choice between documenting the risk and limiting the entry's age (saved health, line 153); the unexplained move of the abort and request guard helpers could be dropped or explained (daemon-client-timeout.ts:461); "after a failed call" in the proxy docs is broader than the code, and "after a connection failure, a server error, or a timeout the daemon did not answer" would fit once timeouts before send are fixed; and the bare These earlier threads no longer apply and can be resolved: docs now name upgrade, credential change and failed calls, docs now cover peers with incomplete instance IDs, an abort now stays Not verified here: the first timeout problem was found by reading code and assumes Node emits All 21 code jobs pass at 84d6878. The Body rules check was cancelled, not failed. It checks PR metadata, so this is likely unrelated to the code and consistent with a newer run replacing it. It still needs a re-run. Before merge, please fix the problems above, starting with the saved entry that survives a timeout before send, add its test, and re-run Body rules. |
…ansport proof - A timeout before the connection opens clears the saved entry, like a failure before connect. - An instance-mismatch resend needs a 409 with the mismatch header that the transport read, not the reason in an error body. A second refusal on the resend clears the entry. - Timeout eviction compares the upstream instance too and ignores a caller abort. - The /health gate always probes live; remote resolution reads the saved entry once and reports whether the answer was saved. - Lease heartbeats get the same single refresh and resend. - Only instance IDs and capabilities are saved, and only header-valid IDs that echo neither the token nor the URL; a proxy answer needs its upstream ID. - The transport failure and timeout builders join the abort guard in daemon-client-timeout.ts to keep the transport under its line limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r own file The transport test file passed the 1000-line limit. The saved-health cases and their remote fixture move unchanged to daemon-client-transport-persisted-health.test.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Response to the review of 84d6878, fixed in 3dd9d76 and b28065b:
Rollback (live check or version floor): not changed in this push. The maintainer is still choosing between opt-in persistence, a bounded entry age, or a conditional route that older peers refuse with 404 before dispatch. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on b28065b. The verdict and the full list are in the summary comment.
|
The change at b28065b still needs fixes before merge: it does not typecheck, and two problems from the 84d6878 review remain. The rollback problem is still open, the credential echo is only partly fixed, and the other nine required fixes are closed. A rollback can still dispatch to an incompatible daemon (daemon-client-lifecycle.ts:288). After a protocol 3 daemon is saved, the same URL and credential can move to a protocol 2 release that ignores the instance headers, or a current proxy can get a rolled-back upstream. The next CLI call then uses the saved health and sends the command. The base probes A second independent pass found that the refresh callback breaks compilation (daemon-client-transport.ts:502). A second independent pass found that the credential sent on The gate parameter type thread still applies, as does one lower-priority open thread. The Lint, Typecheck & Package, Numeric Ranges and Integration Tests jobs fail because of this change. All report the two type errors above, and the failing Integration Tests cases compile TypeScript doc examples that include this file. Not verified here: local tests, the typecheck and the PR benchmark were not re-run, and the benchmark comes from 1771b6c, not this commit. The caller-abort guard in timeout eviction (line 379) was checked only by reading, with no test that aborts during that probe. The handling of a timeout on a reused keep-alive connection, which is treated as possibly sent, looks conservative but was not tested. Before merge, please fix the type error so the three jobs pass, close the credential case, and resolve the rollback with a live check, a version floor, or a maintainer acceptance recorded in ADR 0006. |
…the sent credential - resendAfterRemoteHealthGate takes the gate as NonNullable<SendRequestOptions['remoteHealthGate']>, so the budget and signal it is called with type-check (TS2345/TS2554 at b28065b). - An instance ID is checked against the credential as the auth header builder sends it (trimmed), before saving and when read from disk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a budget A command with no request timeout hands the gate no deadline, so its /health probe ran its own window after the caller aborted. The resend path now runs the gate under the request guard, which settles at once with request_canceled and dispatched: no. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Response to the review of b28065b, at 015189f:
|
Apex Sentinel · ✅ Approve · review of
|
| Finding | Fixed by | Where |
|---|---|---|
| Health gate is typed for one argument but called with two, so the package cannot typecheck | thymikee | 280b4de · reply |
| Health-gate probe runs without the caller's abort signal when the command has no request timeout | thymikee | 39b5386 · reply |
1 finding below minor hidden (user_settings.min_severity).
Reviewed with this repository's own Sentinel configuration (3e0814c574f5).
💬 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.
|
At 015189f, a saved daemon-client-lifecycle.ts:284: For a direct daemon, a second independent pass found this route at daemon-client-lifecycle.ts:288. Health is saved from a protocol 3 daemon, then v0.21.16 replaces it at the same URL with the same credential. A new CLI process applies the saved instance ID and sends For a proxy rollback, a second independent pass found this route at daemon-client-lifecycle.ts:288. Health is saved from a protocol 3 proxy and daemon, then a v0.21.16 proxy takes the same endpoint with the same client and upstream credentials. The next process skips For an upstream rollback, a second independent pass found this route at daemon-client-lifecycle.ts:288. Health is saved from a current proxy and protocol 3 upstream, the proxy stays up, and v0.21.16 replaces the upstream with the same credentials. The saved proxy ID still matches, so the proxy forwards the RPC and passes the saved upstream ID in a header that the old daemon ignores. The command reaches its handler. A live probe would report the upstream protocol, and the base refuses the mismatch before sending the command. Can a persisted hit probe live first, unless the upstream is also independently guaranteed to honor the precondition? Two earlier threads no longer apply and can be resolved. The first is fixed because the gate type now matches its two-argument call, and the typecheck passes. The second is fixed because the gate now runs under the request guard, so a caller abort settles as The code jobs that failed on b28065b now pass. The only failing check is Not verified here: local type checks and the new tests were not re-run, and the relevant CI jobs pass. Abort settling was checked only by reading the code and the new test. It was not checked whether the abandoned unbudgeted probe keeps the CLI process alive until its internal timeout. The benchmark in the description comes from 1771b6c, and the later changes do not touch the measured hot path. Before merge, the rollback problem needs a fix or a recorded maintainer acceptance in ADR 0006. |
Summary
Each CLI call to a remote daemon is a new process, so the in-memory health cache never hit. Every command paid
GET /healthbeforePOST /rpc: one extra network round trip per agent step.The usable
/healthanswer now also lives in the client state dir. Every RPC from it carries the instance preconditions, so a replaced daemon or proxy upstream answers 409 before dispatch and the client probes again (ADR 0006, amended)./healthcheck and is sent once more, within the remaining budget. Heartbeats included.Before / after
session list, 10 calls through a delay proxy in front of a local HTTP daemon:Security
Validation
Head 015189f: touched test files and
tsc -b packages/daemon-clientpass locally. CI pending.🤖 Generated with Claude Code