Repository navigation
perf(daemon-client): send opted-in standalone remote commands as one checked RPC - #5145
Conversation
Size Report
Startup median (7 runs, lower is better):
|
There was a problem hiding this comment.
All reported issues were addressed
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: 1 new finding on 7f69b8b. The verdict and the full list are in the summary comment.
142ca31 to
42e039f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
At 8728027, nine likely problems need fixes. They affect where checked mode sends requests, which setups it accepts, what it exposes about the daemon URL, and what it records and documents. Each code fix needs a regression test that drives the described case and fails without the fix. A second independent pass found that checked approval can likely move to a different HTTP route (remote-connection-state.ts:407). Connect approves a daemon under a non-root prefix, and a later base URL adds a query parameter named A second independent pass found that connect can likely approve a proxy chain without checking its last daemon (daemon-client-checked-rpc.ts:216). With an embedded proxy forwarding to another proxy, each one includes its upstream health verbatim, but the client drops the nested upstream. If the last daemon lacks checked RPC, connect succeeds and the first standalone command gets a 404. Every link through the terminal daemon must be validated, or a proxy's advertised upstream must be required to identify as a daemon. A second independent pass found that checked failures likely attach the daemon URL to caller-visible errors (daemon-client-checked-rpc.ts:202, also lines 143, 153, 177 and 182). The new connect and recovery calls expose it too, through URL and trust validation, the health protocol comparison and A second independent pass found that an unknown refusal header is likely copied as-is into A second independent pass found that a checked request timeout likely records the endpoint in diagnostics (daemon-client-timeout.ts:215, reached from daemon-client-transport.ts:419). The host and path survive redaction into debug output and the failure log. No checked timeout diagnostic should include A second independent pass found that checked approval likely writes another copy of the endpoint URL into the connection record, as A second independent pass found that direct SDK lease calls likely skip the instance fence (daemon-client-lifecycle.ts:152). With A second independent pass found that some checked opens with save-script likely keep their publication record although nothing was sent (session-script-destination.ts:57). This happens when recovery after a connect timeout finds protocol skew (daemon-client-remote-resend.ts:52, daemon-client-rpc.ts:285), and on the pre-send size refusal. Every transport branch that proves the request did not leave must set A second independent pass found that the base compatibility guide still says remote clients always read Is there a simpler shape, where daemon-client owns the whole eligibility rule? It would send checked only when the connection records checked RPC for this endpoint, the request uploads nothing (one predicate exported from daemon-artifacts.ts), and the process holds no instance-pinned Not blocking: each of these can be taken or left: share one These earlier threads no longer apply and can be resolved: the stored health response is now invalidated before recovery (#5145 (comment)); the docs now separate the two dispatch requests from uploads, downloads and lease calls (#5145 (comment)); connect behavior is now covered through Not verified here: tests and mutations were not run, so the claim that the regression tests fail without their fixes was judged by reading only. The before/after bench was not re-run. It used a direct HTTP daemon, so the proxy hop has no live run in this PR and relies on unit tests here and in #5144. The server-side guarantees from #5144 were not re-checked. The only check not passing is "Body rules", which was cancelled rather than failed. It is likely unrelated to the code, possibly replaced by a newer run, and the other 22 checks pass. It was not verified whether this check is required or why it was cancelled. Before merge, the problems above need fixes and "Body rules" needs a re-run. |
8728027 to
5f95f06
Compare
|
Thanks. Fixed in 5f95f06, rebased on #51447be2a52. Each code fix has a test that fails without it (checked by mutation). I took the simpler shape: daemon-client owns eligibility. It sends checked only when (a) the recorded approval fingerprints this exact target, (b)
Non-blocking: the route parameter is typed. The docs cover an unreachable Not done: |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 5f95f06. The verdict and the full list are in the summary comment.
This comment has been minimized.
This comment has been minimized.
|
At 976d47f, all nine blocking findings from the earlier review of 8728027 are closed, but one problem remains in lease materialization. A second independent pass found a likely failure when a leased session is connected while the proxy and daemon support checked RPC, and the daemon is then rolled back to a protocol-compatible version that serves lease RPCs without an instance ID, with the same endpoint and profile. In connection-runtime.ts, a leased Not blocking: these can be taken or left: remote-proxy.md could say "Only a connection attempt that timed out before it opened is retried, after /health answers again; a refused connection fails at once", and the new This earlier thread no longer applies and can be resolved: a refused connection now skips the health retry loop, and the test "a refused checked POST fails at once even while /health answers 503" covers it. Not verified here: tests and mutations were not run, and whether each new test fails without its fix was judged by reading the code at 987dc5a (the rebased 8728027). Not verified here: the before/after bench was not re-run, and this PR has no live run through a proxy hop. Not verified here: the server-side behavior from the base PR #5144 was not re-reviewed, and the base movement from 8efd3fb to 7be2a52 was not reviewed as part of this PR. The 'Body rules' check was cancelled, not failed, and this is likely unrelated to the code: it validates the PR body and template, and no file in the diff is on its route. The other 22 checks pass at 976d47f. Not verified here: whether 'Body rules' is a required check. Before merge, the lease problem needs a fix and 'Body rules' needs a re-run. |
…checked RPC A connection with daemonRpc: checked (profile field, --daemon-rpc, or AGENT_DEVICE_DAEMON_RPC) sends standalone commands on POST /rpc/checked with no /health probe first. connect accepts the field only when every link advertises checked-rpc. Installs keep health-first and the instance fences. A route miss fails typed with dispatched unknown and is never resent; refusals keep today's upgrade message. Only a connection that never opened is acted on: refused fails at once, a connect timeout runs the existing /health recovery loop and sends once. Without the field the client path is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…se flows fenced - Only connect enables checked RPC: daemonRpc is a remote-config profile field with no flag or environment variable, recorded in the connection after every link proves checked-rpc; a proxy must prove its upstream. The connect probe goes through the client's URL and trust validation. - A command that allocates or renews its lease first, and the lease calls themselves, go health-first with the instance fences. - Checked connect recovery decides on fresh /health probes, and an abort during it rejects with the typed cancellation. - A protocol refusal keeps its typed reason and the refusing side; an unknown refusal value is an unreadable reply, never resent. - Script-record cleanup on proven non-dispatch applies to checked opens only. The resend rules take transport powers as a port, so the lazily loaded modules import nothing back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he resend rules The transport type-imported RemoteResendPort from the resend module, which closed a 9-file type cycle through the checked-RPC, recovery and lifecycle modules (R9/R10). The port and the health facts it reads now live in daemon-client-remote-resend-port.ts, which imports neither side. The SDK daemonRpc field documents that setting it is an explicit opt-in the server enforces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…obe live in recovery - The recorded checked mode holds only for the base URL connect validated; a command that names another endpoint goes health-first. - Checked connect recovery probes /health through the live reader, so a concurrent call that refills the cache never stands in for its probe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… probed connect now records the sanitized URL it probed (checkedRpcBaseUrl) in place of a bare mode, and checked RPC applies only when a command's effective endpoint, from its flags or the environment, sanitizes to that URL. A connection with no probed URL, such as a direct-provider one, never applies checked mode to a URL that arrives later. Equivalent spellings (host case, default port, trailing slash) keep checked mode through the existing URL sanitizer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the endpoint out of errors - daemon-client decides alone: checked only when the connection's recorded approval fingerprints this exact target (one route resolution, shared with the send), the request uploads nothing (requestUploadsArtifacts, shared with the artifact preparer), it is not a lease allocate or heartbeat, and the process holds no instance-pinned /health answer. The leasePrepared plumbing is gone. - connect records only the target fingerprint, refuses a checked profile with no base URL, and requires a proxy's upstream to be the daemon itself. - No error at the checked connect or send boundary, and no checked timeout diagnostic, names the endpoint. An unknown refusal value is recorded as 'unknown'. - The pre-send size refusal and recovery that finds protocol skew set dispatched: no. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…connect verdict The recovery loop now takes the observed verdict as its first failed probe: a refused connection is not transient and fails at once with remote_daemon_unavailable and dispatched: no, and only a connect that timed out enters the probe loop. Adds a regression test for a refused checked POST while /health answers 503. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…not be pinned A process that read /health for an endpoint and got an answer with no complete instance ID, such as a lease call's against a rolled-back daemon, now sends later commands health-first instead of on the checked route; a pinned answer is still reused, fenced and free. Docs say a refused connection fails at once, and daemonLifecycle keeps its own doc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
976d47f to
18e86fc
Compare
|
Fixed in 18e86fc, rebased on #51441633e10. The process health cache now also remembers an endpoint whose last reachable Non-blocking items applied: the remote-proxy.md wording ("Only a connection attempt that timed out before it opened is retried, after |
This comment has been minimized.
This comment has been minimized.
|
At 18e86fc, the lease case from the earlier review is fixed for the ordinary health probe. The stale-instance retry can still send the following A second independent pass found this likely defect. A leased proxy Every reachable unpinnable health answer must be recorded, whichever caller of CI is green at 18e86fc, including the re-run of Not verified here: tests and mutations were not run, and there was no live run against a daemon that reports no instance ID. Whether the new test fails without the fix was judged only by reading the code at bc7c806. The CLI route from Before merge, the retry case needs a fix, and the base PR #5144 has to merge. |
… is cached cacheRemoteDaemonHealth now remembers a reachable answer with no complete instance ID itself, so the stale-instance retry registers it as the ordinary probe does: after a retry onto a daemon that reports no instance ID, the next checked-eligible command stays health-first. The probe generation guard and complete-pin reuse are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fixed in 5217b08. New test: a leased flow first pins instance |
Apex Sentinel · ✅ Approve · review of
|
| 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.
|
No blocking problems were found at 5217b08. The stale-instance retry case from the earlier review is fixed: a reachable health answer without complete instance IDs is now recorded for both the ordinary probe and the retry, so the following Not verified here: tests and mutations were not run, and there was no live run against a real proxy or daemon that reports no instance ID. That the new test fails at 18e86fc was judged only by reading the code; it uses a local HTTP stand-in through the real The only check not passing is Before merge, |
Summary
Stacked on #5144. Replaces closed #5134. A connection whose remote-config profile sets
daemonRpc: "checked"sends a standalone command's dispatch as onePOST /rpc/checked. Without it, the client path is unchanged.connectprobes the endpoint, requires a proxy'supstreamto be the daemon itself, and records only a fingerprint of the exact checked target./healthanswer. After a lease call, the command reuses that answer on fenced/rpcwith no extra round trip.remote_checked_rpc_unsupported,dispatched: unknown), never resent.Security
/healthlive.unknown.dispatched: no.retryAfterRemoteInstanceMismatchstays in the resend module: moving it back puts the transport over the 1000-line cap.Before / after
session listafterconnect, n=10, http daemon behind a 50 ms each-way delay proxy:Validation
Head 5217b08. New tests fail without their fixes (checked by mutation). daemon-client, connection, remote, wire-compat, eager-closure, layering and
fallow auditpass locally. CI pending.🤖 Generated with Claude Code