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

A person shares one imported session by a link that hides what the forge redacts #18391

opened this

Merged 3h 19m ago, live in production

An imported session can now be shared by a secret link. Only its importer can make or stop the link, and the shared page redacts every line it serves. The new test file and the existing share and imported-page tests pass, as do the dead-code, duplicate-import and door checks.

Notes

opened this

An imported session can now be shared by a secret link. Only its importer can make or stop the link, and the shared page redacts every line it serves. The new test file and the existing share and imported-page tests pass, as do the dead-code, duplicate-import and door checks. tsc is clean and gate.ts reports nothing that fails. I did not run the whole suite; the forge's check does.

What changed

  • Reuse: the link reuses the crew-run machinery: the trace_share table, src/trace/share.ts, and the same /traces/shared/<secret> page and 60-opens-a-minute limit. The gate has three new functions (shareImported, unshareImported, importedSharedNow in src/actions/trace_share.ts) that use the same seenTraceRow check as the session's own page. Another user, a signed-out visitor, a run's id or an unknown id all get the plain not-found.
  • Page: the importer's /traces/<id> shows Make a share link or Stop sharing in a same-origin POST form. The form says the forge only redacts the credentials it knows. POST /traces/:id/share and /unshare fall through to the imported case when the id is not a crew run. The shared page for a session says the forge cannot know every secret.
  • Redaction: every step line, raw line and the title go through redactHeld. Raw lines are redacted before they are cut to length, so a secret split by the cut does not survive as a prefix.
  • Who and where: the first run of my test showed raw records carrying the importer's cwd (/home/alice/...). I now drop the keys cwd, workdir, working_directory, gitBranch, userEmail, email, user, username, hostname, host, originator and git from each raw record before it is shown.
  • One read per session: rawLinesByStep in src/trace/imported_read.ts finds each step's raw lines in one pass. The existing per-step rawLinesOf would have re-read the whole gzip file once per step.
  • Deleted session: readShared now checks that the run or session still exists before it uses its 30-second cache. A deleted session's link is a 404 straight away, whether or not #18359 has removed the link row.
  • Terminal: in the Traces list, s on an imported row makes the link and z ends it. A second s confirms when a link is already live.
  • Docs: docs/features/traces.md has a new section on sharing an imported session.

Tests (test/trace-imported-share.test.ts)

  • A planted token is [redacted] on the shared page, and the page shows no alice and no /home/.
  • Only the secret's hash is stored.
  • Another user cannot make or end the link.
  • A signed-out post and a cross-site post are refused.
  • A new link ends the old one, and stopping it gives a 404.
  • A deleted session's link is a 404.
  • One address is cut off after 60 opens in a minute.

What I chose not to do

  • No MCP trace tool support for imported sessions, because that tool needs a repo.
  • No change to the crew-run share behaviour. Only linkPage was pulled out of it so both kinds use one page.

Try it: sign in, import a session at /traces, open it and press Make a share link. Open the link in a signed-out window, then press Stop sharing and reload the link to get the not-found.

Review notes

  • The gate printed "one implementation?" notes for shareImported/unshareImported, withoutWho/clean and traceShare/traceUnshare. I left them because each pair is a mirror, not a duplicate.
  • The gate asked for a "No look" line and I supplied one: the page change is a single form on an existing page.

Closes #18377

commented

An imported session can now be shared by a secret link. Only its importer can make or stop the link, and the shared page redacts every line it serves. The new test file and the existing share and imported-page tests pass, as do the dead-code, duplicate-import and door checks. tsc is clean and gate.ts reports nothing that fails. I did not run the whole suite; the forge's check does.

What changed

  • Reuse: the link reuses the crew-run machinery: the trace_share table, src/trace/share.ts, and the same /traces/shared/<secret> page and 60-opens-a-minute limit. The gate has three new functions (shareImported, unshareImported, importedSharedNow in src/actions/trace_share.ts) that use the same seenTraceRow check as the session's own page. Another user, a signed-out visitor, a run's id or an unknown id all get the plain not-found.
  • Page: the importer's /traces/<id> shows Make a share link or Stop sharing in a same-origin POST form. The form says the forge only redacts the credentials it knows. POST /traces/:id/share and /unshare fall through to the imported case when the id is not a crew run. The shared page for a session says the forge cannot know every secret.
  • Redaction: every step line, raw line and the title go through redactHeld. Raw lines are redacted before they are cut to length, so a secret split by the cut does not survive as a prefix.
  • Who and where: the first run of my test showed raw records carrying the importer's cwd (/home/alice/...). I now drop the keys cwd, workdir, working_directory, gitBranch, userEmail, email, user, username, hostname, host, originator and git from each raw record before it is shown.
  • One read per session: rawLinesByStep in src/trace/imported_read.ts finds each step's raw lines in one pass. The existing per-step rawLinesOf would have re-read the whole gzip file once per step.
  • Deleted session: readShared now checks that the run or session still exists before it uses its 30-second cache. A deleted session's link is a 404 straight away, whether or not #18359 has removed the link row.
  • Terminal: in the Traces list, s on an imported row makes the link and z ends it. A second s confirms when a link is already live.
  • Docs: docs/features/traces.md has a new section on sharing an imported session.

Tests (test/trace-imported-share.test.ts)

  • A planted token is [redacted] on the shared page, and the page shows no alice and no /home/.
  • Only the secret's hash is stored.
  • Another user cannot make or end the link.
  • A signed-out post and a cross-site post are refused.
  • A new link ends the old one, and stopping it gives a 404.
  • A deleted session's link is a 404.
  • One address is cut off after 60 opens in a minute.

What I chose not to do

  • No MCP trace tool support for imported sessions, because that tool needs a repo.
  • No change to the crew-run share behaviour. Only linkPage was pulled out of it so both kinds use one page.

Try it: sign in, import a session at /traces, open it and press Make a share link. Open the link in a signed-out window, then press Stop sharing and reload the link to get the not-found.

Review notes

  • The gate printed "one implementation?" notes for shareImported/unshareImported, withoutWho/clean and traceShare/traceUnshare. I left them because each pair is a mirror, not a duplicate.
  • The gate asked for a "No look" line and I supplied one: the page change is a single form on an existing page.
commented

I've made all three requested changes and added the extra 429 test; the new and touched tests pass and tsc is clean. I did not run the whole suite; the forge's check does.

  • Terminal test: test/traces-share-tui.test.ts drives the Traces screen with s and z.
    • The first s makes a link.
    • A second s only asks for confirmation and leaves the old link live.
    • A third s replaces the link.
    • z ends it, and a second z says the session was not shared.
    • Bob, who did not import the session, gets the "share is for an imported session of yours" refusal for both keys, and nothing is shared.
  • withoutWho:
    • It now lives in src/trace/who.ts and drops the who-keys only at a record's top level, in payload and in message.metadata. A tool input with its own user, host or git is kept whole, and docs/features/traces.md says so.
    • test/trace-who.test.ts covers those three places, keys nested inside a tool input (a git object, email in a nested array) kept as they are, and non-JSON lines kept as they are.
    • The payload level is my addition to your suggested list: Codex puts its session header there.
  • Session page: the sub line is back to "Only you can read it." The form's not-shared text is now two sentences: what a link does, then the warning.
  • 60 a minute: one test now requests a shared link 62 times and expects a 429 by the 61st. It uses a link that was never made, because a refused open counts toward the limit.

One gate note: who.ts is a helper of the shared page, so its commit says No door: and points to the terminal keys and how-to already in this pull. The gate otherwise reports nothing that fails.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs