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
feat(remote): name the held lease on upload, artifact download and diagnostics requests - #3594
A gateway in front of many daemons routes each request to the daemon that holds the request's lease. RPC calls already name the lease in their body, but the plain HTTP calls do not, so such a gateway cannot route them:
uploads: POST /upload, POST /upload/preflight, PUT /upload/direct/<ticket>, POST /upload/finalize
artifact downloads: GET /artifacts/<id>
request diagnostics: GET /sessions/<s>/requests/<r>/diagnostics
When the client talks to a remote daemon and holds a lease, it now sends x-agent-device-lease-id: <leaseId> on these requests. This is the same lease id it puts in its RPC calls. With no lease held, it sends no header. A direct upload ticket on another origin, such as a signed storage URL, gets only the headers the daemon handed out.
Nothing reads the header yet. The daemon ignores it, and the proxy forwards only its allowlist of headers, so it drops this one. The client never sends GET /artifacts (the list), so that route is unchanged.
The wire-compat ledger gets new digests and additive acks for the changed client declarations. The stale #2946 acks on the same upload functions are dropped.
New daemon-client-lease-header.test.ts runs sendToDaemon against a loopback remote daemon (install upload, screenshot download, failing command diagnostics). With a lease, every one of these requests carries the header. Without a lease, none does. The lease test fails when the call-site wiring is removed.
New unit tests in upload-client, artifact-download, remote-request-diagnostics and daemon-http cover the header on each request kind, its absence without a lease, and that a foreign-origin ticket gets no header.
The lease header change in 0bd157d looks right to me, but Coverage fails on the test-file-size ratchet that this PR caused: src/__tests__/upload-client.test.ts grew from 988 to 1134 lines. Before merge, that file must stay at or below 988 lines. Collapse the four new lease tests into one table-driven test over {direct, legacy, foreign-origin ticket} x {lease, none} on the existing startServer helper, or move them into a lease-focused test that mirrors upload-client.ts. Smoke Tests is still queued, and its device routes do not exercise this remote HTTP header code. I did not run the new tests, and I did not inspect the wire-compat ledger digests beyond the diffstat. The direct-upload PUT and finalize lease path is covered only by the upload-client unit tests, not by the sendToDaemon loopback test.
Not blocking, and you can take or leave these: the scope headers (auth, tenant, lease) are now built by hand at six sites in upload-client.ts, artifact-download.ts and remote-request-diagnostics.ts, and the upload sites already drift because they send no tenant header while download and diagnostics do. Both new test files also hard-code x-agent-device-lease-id because DAEMON_HTTP_LEASE_HEADER is not exported like the tenant header.
Could RemoteDiagnosticsEndpoint become a shared {baseUrl, token, tenantId, leaseId} endpoint, built once per request and passed to upload, download and diagnostics, with one contracts helper that builds all scoped headers from it? That would remove the five threaded leaseId option fields and make a missing header impossible. The upload option types are internal to src/remote, so nothing has to change first.
No conflicts.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A gateway in front of many daemons routes each request to the daemon that holds the request's lease. RPC calls already name the lease in their body, but the plain HTTP calls do not, so such a gateway cannot route them:
POST /upload,POST /upload/preflight,PUT /upload/direct/<ticket>,POST /upload/finalizeGET /artifacts/<id>GET /sessions/<s>/requests/<r>/diagnosticsWhen the client talks to a remote daemon and holds a lease, it now sends
x-agent-device-lease-id: <leaseId>on these requests. This is the same lease id it puts in its RPC calls. With no lease held, it sends no header. A direct upload ticket on another origin, such as a signed storage URL, gets only the headers the daemon handed out.Nothing reads the header yet. The daemon ignores it, and the proxy forwards only its allowlist of headers, so it drops this one. The client never sends
GET /artifacts(the list), so that route is unchanged.The wire-compat ledger gets new digests and additive acks for the changed client declarations. The stale #2946 acks on the same upload functions are dropped.
Validation
pnpm check:affected --run: all runnable checks passed (format, lint, typecheck, layering, fallow, build, vitest-related 366 files / 2465 tests, daemon-wire-compat).daemon-client-lease-header.test.tsrunssendToDaemonagainst a loopback remote daemon (install upload, screenshot download, failing command diagnostics). With a lease, every one of these requests carries the header. Without a lease, none does. The lease test fails when the call-site wiring is removed.upload-client,artifact-download,remote-request-diagnosticsanddaemon-httpcover the header on each request kind, its absence without a lease, and that a foreign-origin ticket gets no header.