Public: anyone can read this; the crew can change it.

Traces 5b: a trace has a share link, off by default, revocable, served with secrets redacted #18176

opened this

Closed 14h 3m ago

Owners can now share a trace by a revocable link, and GET /t/:token serves it read-only with secrets redacted. My three new tests in test/trace-share.test.ts pass, and tsc and design-lint are clean. I didn't run the rest of the suite (the forge's check runs it on the push).

Notes

opened this

Owners can now share a trace by a revocable link, and GET /t/:token serves it read-only with secrets redacted. My three new tests in test/trace-share.test.ts pass, and tsc and design-lint are clean. I didn't run the rest of the suite (the forge's check runs it on the push). The commits were already on the branch and pushed, so there was nothing new to push.

What changed

  • Storage: a new trace_share table (migration 20261204060000-trace-share plus its pin) holds the run id, the SHA-256 of the token, who created it, and when it was revoked. The raw token is never stored.
  • Create and revoke (src/trace/share.ts):
    • POST /traces/:id/share and POST /traces/:id/unshare are the only ways in, and both go through the form door's same-origin check.
    • Only someone who can see the repo's owner-level facts may use them; this reuses the existing role, with no new grant table or admin shortcut.
    • Someone who can't read the run gets 404, and a reader who isn't an owner gets owner_only.
    • The raw token is shown once, at creation.
  • Public link:
    • GET /t/:token checks the token shape first, so a malformed token is a 404 with no lookup.
    • Unknown or revoked tokens are also 404.
    • Every field goes through the existing redaction before it is rendered.
  • Both doors: the web trace page has "Make a link" and "Revoke every link". The terminal trace screen (src/tui/screens/trace.ts) has s to share and x to revoke. docs/features/traces.md has a new section.
  • Tests: the new tests cover a planted token showing as redacted, the same link returning 404 after revoke, a non-owner being refused, and cross-origin POSTs being rejected.

Left out

  • There are no per-link expiry dates and no list of individual links. Revoke takes back all live links on the run at once.
  • No new dependencies.

Gate notes

  • The gate said it can't map Looks: /traces/:id to a page in forge.json, so the reviewer picks the look.
  • The gate also flagged ownerOf as 0.98 similar to gate in src/actions/origin_read_grant.ts. I left both: they have the same shape but check different rules.

To try it: as the repository owner, open /traces/<a run id> and press "Make a link". Open the /t/<token> shown in a private window, then press "Revoke every link" and reload that window for a 404.

[
 {"go":"/traces/<run id>","look":"Make a link button, then the one-time /t/<token> URL","expect":"token shown once; non-owners see no button"},
 {"go":"/t/<token>","look":"read-only trace in a private window","expect":"secrets show as redacted"},
 {"go":"/traces/<run id>","look":"Revoke every link, then reload /t/<token>","expect":"404"}
]

🤖 Generated with Claude Code

Closes #18084

commented

Owners can now share a trace by a revocable link, and GET /t/:token serves it read-only with secrets redacted. My three new tests in test/trace-share.test.ts pass, and tsc and design-lint are clean. I didn't run the rest of the suite (the forge's check runs it on the push). The commits were already on the branch and pushed, so there was nothing new to push.

What changed

  • Storage: a new trace_share table (migration 20261204060000-trace-share plus its pin) holds the run id, the SHA-256 of the token, who created it, and when it was revoked. The raw token is never stored.
  • Create and revoke (src/trace/share.ts):
    • POST /traces/:id/share and POST /traces/:id/unshare are the only ways in, and both go through the form door's same-origin check.
    • Only someone who can see the repo's owner-level facts may use them; this reuses the existing role, with no new grant table or admin shortcut.
    • Someone who can't read the run gets 404, and a reader who isn't an owner gets owner_only.
    • The raw token is shown once, at creation.
  • Public link:
    • GET /t/:token checks the token shape first, so a malformed token is a 404 with no lookup.
    • Unknown or revoked tokens are also 404.
    • Every field goes through the existing redaction before it is rendered.
  • Both doors: the web trace page has "Make a link" and "Revoke every link". The terminal trace screen (src/tui/screens/trace.ts) has s to share and x to revoke. docs/features/traces.md has a new section.
  • Tests: the new tests cover a planted token showing as redacted, the same link returning 404 after revoke, a non-owner being refused, and cross-origin POSTs being rejected.

Left out

  • There are no per-link expiry dates and no list of individual links. Revoke takes back all live links on the run at once.
  • No new dependencies.

Gate notes

  • The gate said it can't map Looks: /traces/:id to a page in forge.json, so the reviewer picks the look.
  • The gate also flagged ownerOf as 0.98 similar to gate in src/actions/origin_read_grant.ts. I left both: they have the same shape but check different rules.

To try it: as the repository owner, open /traces/<a run id> and press "Make a link". Open the /t/<token> shown in a private window, then press "Revoke every link" and reload that window for a 404.

[
 {"go":"/traces/<run id>","look":"Make a link button, then the one-time /t/<token> URL","expect":"token shown once; non-owners see no button"},
 {"go":"/t/<token>","look":"read-only trace in a private window","expect":"secrets show as redacted"},
 {"go":"/traces/<run id>","look":"Revoke every link, then reload /t/<token>","expect":"404"}
]

🤖 Generated with Claude Code

commented

Declined: already done on main in 7a173148f. I aborted the merge and pushed nothing. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m90b3p8by1ftw8mx05p848hm

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs