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

Traces 5: compare two traces, and share one with secrets redacted #18017

opened this in answer to

Merged 6h 30m ago, live in production

Traces 5 is pushed: two runs of one issue can be compared, and an owner can share one trace by a revocable link with secrets redacted. I ran bun x tsc --noEmit, bun scripts/gate.ts and the tests that cover the change, and all pass. I did not run the whole suite; scripts/fast.ts named 3,729 files, too broad to run here.

Notes

opened this

Traces 5 is pushed: two runs of one issue can be compared, and an owner can share one trace by a revocable link with secrets redacted.

I ran bun x tsc --noEmit, bun scripts/gate.ts and the tests that cover the change, and all pass. I did not run the whole suite; scripts/fast.ts named 3,729 files, too broad to run here. I did not try the pages against a running app.

What changed

  • Compare: /traces/<run>/compare/<other> shows steps, failed steps, time, tokens, cost and outcome, with B − A beside each. Time is each run's own start-to-finish clock. Tokens read "not recorded", because a run's log holds none. Cost is shown only to those who may see the owner's facts. Runs of two different issues, or one the viewer can't read, get the not-found a missing run gets. A trace page lists the issue's other runs to compare with.
  • Share: off until the repository's owner presses Make a share link (same-origin form).
    • The link is /traces/shared/<secret>, shown once; only its hash is kept in a new trace_share table.
    • Anyone holding it reads the steps and raw lines with no sign-in. Everything is passed through the forge's existing redactHeld before it is parsed. The page shows no cost and no people.
    • A new link ends the old one, Stop sharing ends it, and a revoked link is the plain not-found.
  • Terminal: on a run's trace screen, c compares with the issue's newest other run, s shares and x stops sharing. Page, terminal and MCP all go through the same owner check in src/actions/trace_share.ts.
  • MCP: one new tool, trace, with action list, read, compare (with with), share and unshare. Reads are never held; share and unshare are writes. test/mcp-size.test.ts passes.
  • Tests: test/trace-share.test.ts compares two recorded runs and checks the difference against a hand calculation: 240 s and $1.50. It plants a token in a log file and checks the shared page serves [redacted] while the file keeps the token. It also checks revoke, non-owner and cross-site refusals, and that a new link withdraws the old. I added a query-plan test for the new read in test/hot-reads-indexed.test.ts and the new routes to the route-list tests.
  • Reused: readTrace as the one gate, traceRows and spanWords, redactHeld, ownsRepo, getRepoRun, readForm, and the run_issue index. No dependency was added.

What I chose not to do

  • No per-step tokens or cost: run logs hold none.
  • Compare is for crew runs only, not imported outside-agent sessions, which aren't stored yet.
  • No new terminal screen file: the door is the existing src/tui/screens/trace.ts, so a commit line says No door: for that rule.
  • The look rule is waived with No look: because the pages need a crew run with a log, which the look seed doesn't have.

Try it Open a run's trace at /traces/<run id> as the repository owner and press Make a share link. Open the link signed out, then press Stop sharing and confirm the link now 404s. For compare, open /traces/<run>/compare/<other run of the same issue>.

[
  {"go": "/traces/<run id>", "look": "the Share form and the compare links under the run's links", "expect": "Make a share link shows for the owner only; other runs of the same issue are listed to compare with"},
  {"go": "/traces/<run id>/compare/<other run id>", "look": "the table", "expect": "steps, failed steps, time, tokens, cost and outcome, with B − A beside each"},
  {"go": "/traces/shared/<secret from the share form>", "look": "signed out, the steps and raw lines", "expect": "credential shapes read [redacted]; no cost; after Stop sharing the same address is not found"}
]

🤖 Generated with Claude Code

Closes #17995

Show 5 earlier items

7 earlier comments
commented

<!-- look-pages 9eb9c9a93ead --> Look pages for 9eb9c9a, from the gate:

  • look pages (none): this pull changes src/web/pages/trace.ts, src/web/pages/trace_compare.ts, src/web/pages/trace_share.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

Compare two runs of an issue, and share a trace by a link that hides secrets and can be revoked. Both were already in the branch. This push adds only one commit, which carries the Replaces: and Looks: lines the gate asked for. I didn't change the code.

The check had failed 3 times because the page-budget walk found trace routes it couldn't fill. The earlier commit 9eb9c9a93 already lists them under test/budgets/unfixtured/ (/traces/:id/compare/:other, /traces/shared/:token, plus the existing trace ones). I confirmed that fix holds.

The branch on the forge had moved ahead, because main was merged into it. I rebased onto that merge before pushing. After the rebase I ran tsc and these tests, all green:

  • The page-budget walk and its file check (pages-budget, page-budget-files).
  • The dead-code check (unused-exports).
  • The module-state check (module-state).
  • The during job-timing check (route-timing-coverage, job-slices).
  • The share tests (trace-share).

I did not run the whole suite. I also didn't run the earlier security-floor and OpenAPI checks again after the rebase.

  • Door rule: the terminal side is the existing trace screen, where c compares, s shares and x stops sharing. A commit line already says so.
  • Not done:
    • Compare and share are not in the page-budget walk, because no fixture holds a crew run with a log. They are listed on purpose.
    • The gate's "one implementation?" similarity notes in src/actions/trace_share.ts and src/web/pages/trace_share.ts are advisory, and I didn't merge those functions.
  • Try it:
    1. Open a crew run's trace at /traces/<run id>.
    2. Press Make a share link, then open the link signed out.
    3. Press Stop sharing.
    4. To compare, open /traces/<run id>/compare/<other run id> for another run of the same issue.
[
  {"go":"/traces/<run id>","look":"Make a share link","expect":"A /traces/shared/<token> link appears with secrets redacted"},
  {"go":"/traces/shared/<token> (signed out)","look":"the shared trace","expect":"Opens read-only with secrets redacted"},
  {"go":"/traces/<run id>","look":"Stop sharing","expect":"The old link now answers not found"},
  {"go":"/traces/<run id>/compare/<other run id>","look":"the two traces side by side","expect":"Both runs belong to one issue and their steps line up"}
]

🤖 Generated with Claude Code

commented

The wide background test run was stopped at its time limit, so it never finished. I'm not restarting it, because it was an estimated 5-hour run.

The merge itself is pushed (1729b2c2c). What I did run before the push passed:

  • the six trace test files (42 tests)
  • bun x tsc --noEmit
  • the gate

The forge's full check on the push will cover the rest.

commented

Still red on current main: the walk covers the open GET routes, and nothing fills is left unlisted. Fix it and push.

commented

I fixed the five failing tests and pushed the fix as 6ec367be7. All five failures came from the new trace routes, tool and table missing from the lists that guard them.

When I re-ran them locally, the tests behind four of the failures and the one that had failed alongside the walk test (conversation-holds) passed. tsc --noEmit is clean. I did not run the full suite. The forge's check does that on this push.

bun scripts/gate.ts --fix printed two "one implementation?" similarity notes about traceShare and traceUnshare in src/web/pages/trace_share.ts. I did not act on them or check whether they block the push. If the check flags them, they are the place to look.

  • Route walk: the walk test now fills the :other segment of /traces/:id/compare/:other.
  • MCP tool list: trace is added to the expected tool list in the protocol test.
  • Mixed reads and writes: trace is added to the table of tools that mix reads and writes. Its list, read and compare actions are never held.
  • Ask first: the trace tool now asks for confirmation before share and unshare, since a share link publishes a redacted trace. The other actions never ask.
  • Account purge: trace_share.created_by is covered as DELETE, so a share link ends with the account that made it. This follows the existing rule for a game client-pack link.
commented

Still red on current main: the held action, in the person's words > every tool the agent can be held on has a form, and every form is a tool. Fix it and push.

commented

The failing check is fixed and pushed. The trace tool can write (share and unshare), so it can be held for confirmation, but it had no wording in src/crew/conversation_ask.ts. I added one. I only re-ran test/conversation-ask.test.ts (6 pass), not the full suite.

  • New wording: ASKED_AS now has a trace entry. It reads "Make a redacted share link for the trace of run X in repo." or, for unshare, "Stop sharing the trace of run X in repo."
  • Tests: I added both sentences to the SAID table in test/conversation-ask.test.ts. That test requires the table and ASKED_AS to list the same tools, so it would fail if either side were missing.
  • Type check and gate: bun x tsc --noEmit printed nothing. bun scripts/gate.ts --fix printed "one implementation?" similarity warnings and didn't fail. Several concern code from this pull (revokeShare, traceShare, traceUnshare). I left them alone.

To try it, run bun test test/conversation-ask.test.ts.

commented

All five points from the review are addressed, and the branch is pushed. bun test passes for the trace suites, the module-state test and the dead-code test. tsc is clean and design-lint is clean. I ran no browser or preview checks.

What changed

  • Terminal s confirms (1). When a share link is live, s now asks for a second press and says it ends the old link. Any other key cancels the confirmation.
  • Terminal s/x limited to one trace (1). They no longer act on the compare screen.
  • Owner refusal. A reader who isn't the owner still gets the "only the repository's owner shares a trace" toast.
  • Compare page (2). I dropped the notes paragraph, so it keeps the one "Difference is B − A" sentence.
  • Share-made page (3). The hand-rolled size=70 input is now the shared field component, mono, with a hidden label. The one sentence is in the page head and now also says that making another link ends this one.
  • Terminal test (4). test/trace-share.test.ts now covers c, s with its confirm, x, the compare screen having neither key, and the owner refusal.
  • Shared page cost (5). src/trace/shared.ts keeps the redacted trace for 30 seconds per link, up to 32 per forge.
    • It is keyed by the hash of the link's secret, so a new link never reads the old one's.
    • The link is still checked on every request, so a revoked one is a 404 at once.
    • It is also limited to 60 opens a minute per address, then a 429 with Retry-After.
    • Both the cache and the limiter are WeakMaps keyed by the forge, the same pattern reports.ts uses, so the module-state test stays green.
  • Compare links on the trace page (6). They are now a nav.bar of rows labelled with the model, state and run date instead of the last six characters of the id.
  • Docs. docs/features/traces.md says all of this.

Not done

  • The gate still prints "one implementation?" notes and a note about as never casts at test/trace-share.test.ts:182. The as never on the key event is fixed. The remaining cast is the as unknown as Ctx stub, built the way test/adapter-tui.test.ts builds its own.
  • A 30-second cache means a run that is still writing shows its log up to 30 seconds late on the shared page. I accepted that for the cost bound.
[
  {"go": "/traces/<run id>", "look": "the Compare with row", "expect": "a single bar of links labelled model · state · date"},
  {"go": "/traces/<run id>/compare/<other>", "look": "under the table", "expect": "no notes paragraph; one sentence in the head"},
  {"go": "POST Make a share link on a trace you own", "look": "the link field on a phone width", "expect": "full width, mono, no horizontal overflow"},
  {"go": "terminal: open a trace, press s twice when a link is live", "look": "the toast after the first press", "expect": "asks to press s again; the old link works until the second press"}
]
Sign in to join this conversation.

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

Keyboard shortcuts

Docs