Skip to content

fix(remote): preserve tenant scope for proxy artifact downloads#1317

Merged
thymikee merged 4 commits into
mainfrom
agent/fix-local-proxy-artifact-tenant
Jul 17, 2026
Merged

fix(remote): preserve tenant scope for proxy artifact downloads#1317
thymikee merged 4 commits into
mainfrom
agent/fix-local-proxy-artifact-tenant

Conversation

@thymikee

@thymikee thymikee commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Carry the configured tenant when materializing remote daemon artifacts.
  • Forward that scope through the local proxy and reconstruct it for the daemon artifact endpoint.
  • Preserve auth-hook-derived tenant identities and cover both successful and cross-tenant downloads.
  • Bump the daemon RPC protocol so mixed peers reject the new artifact authorization contract during health negotiation, before command RPC.

Root cause

Screenshot RPC requests registered artifacts under meta.tenantId, but the later GET /artifacts/:id request only carried the proxy token. Local proxies use a shared proxy token, so the daemon correctly treated that download as unscoped and rejected the tenant-owned artifact.

Validation

  • pnpm check:affected --base origin/main --run
  • pnpm check:unit
  • pnpm test:integration:provider (37 files, 140 tests)
  • Older/newer RPC protocol skew coverage proves rejection after /health and before /rpc
  • Packaged CLI provider smoke
  • Final format, typecheck, lint, and focused provider regression gate

Closes #1316

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.8 MB 1.8 MB +346 B
JS gzip 568.1 kB 568.3 kB +144 B
npm tarball 682.8 kB 683.0 kB +150 B
npm unpacked 2.4 MB 2.4 MB +346 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 25.7 ms 25.7 ms +0.1 ms
CLI --help 56.2 ms 56.2 ms +0.0 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/snapshot-diagnostics.js +376 B +146 B
dist/src/agent-device-client.js -168 B -68 B
dist/src/internal/daemon.js +125 B +49 B
dist/src/cli.js +13 B +16 B
dist/src/session.js 0 B +2 B

@thymikee

Copy link
Copy Markdown
Member Author

Blocked on RPC compatibility: this makes x-agent-device-tenant required to materialize tenant-scoped /artifacts/* through the proxy, but /health still advertises the old DAEMON_RPC_PROTOCOL_VERSION. A new client with an old proxy/server, or an old client with the new server, passes the health compatibility check and only fails after command RPC during artifact download. ADR 0006 explicitly classifies changes to artifact-route authentication requirements as protocol-breaking. Please bump the RPC protocol version and add skew coverage proving incompatible peers fail before command RPC.

The tenant header flow and auth-hook precedence otherwise look correct.

@thymikee

Copy link
Copy Markdown
Member Author

Addressed the RPC compatibility blocker in 68c2be3. The daemon RPC protocol is now v2, and the remote-client regression covers both older and newer peers, asserting that only /health is requested and command RPC is never sent. The packaged CLI health fixture now uses the shared protocol constant. Validation: pnpm check:affected --base origin/main --run (79 Vitest files / 619 tests plus 15 Node integration tests), followed by the chained format, typecheck, lint, and focused 50-test gate.

@thymikee

Copy link
Copy Markdown
Member Author

Code review is clean at 68c2be30d. The RPC protocol bump correctly makes the new artifact tenant-auth requirement fail fast across version skew, both older/newer peer regressions prove /rpc is never sent, and the #1316 tenant flow plus auth-hook precedence remain correct. All 23 checks are green; no remaining blocker found.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jul 17, 2026
@thymikee
thymikee merged commit 3fed8ac into main Jul 17, 2026
23 checks passed
@thymikee
thymikee deleted the agent/fix-local-proxy-artifact-tenant branch July 17, 2026 09:36
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-17 09:37 UTC

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.

Unable to retrieve screenshot when local remote proxy is configured

1 participant