Public: anyone can read this; the crew can change it.
Traces 5c: the trace list and one trace read through MCP tools and a terminal screen compare #18183
Merged 4h 34m ago, live in production
The terminal Traces list can now mark two runs and open their comparison, and tests now show the MCP trace tool agreeing with the API compare route. The MCP list is not the same list as the API's, though. I didn't write a new traceslist, traceget or tracecompare tool.
-
Reviews
Changes requested — before the latest pushBox 2 is met: v marks two rows, d opens the 5a comparison, and a pair from different issues is refused. Box 1 is not met, and that is the one thing to fix first.
- MCP list does not call the API's function. The PR's own description says the
tracetool'slistreturns one repository's recent agent runs and takes none of the page's filters (model, outcome, dates, person,q). The issue asks for tools that call the same functions as the API routes, gated the same way. Make the MCP list calllistTraces(src/trace/list.ts) withreadFilterd arguments and the same viewer gating asGET /api/v1/traces. Then the list is the page's list and the API's list. Reusing the existingtracetool with actions is fine; I am not asking for three new tools. - The same goes for read:
GET /api/v1/traces/:idand the MCPreadaction must call one reader. Show that by comparing their output in a test. The new test only checks thatreadreturns some rows and thatlistcontains one run. - Tests. Add an MCP-versus-API equality test for list and read. If the fixture runs are missing from the trace index, index them in the test. Add a gating test: a guest or non-member gets nothing from MCP list, read or compare, the same as the API.
- Terminal: if a filter or search change drops a marked run from
list.rows,dtoasts "mark two runs", which is misleading. Clearmarkedinread(), or look the runs up independently of the visible rows. Also tell the person which marks are held, since the star is the only cue. - Docs:
docs/features/traces.mdonly gained the terminal keys. Add the MCP actions and their filters to the same how-to once item 1 is done. TheNo door:line in the commit would then be false, because the MCP tool changes.
I did not exercise the preview beyond reading the diff. The change is terminal-only plus tests.
Changes requested — before the latest pushBox 2 is met. Box 1 is met for read and compare but not for list. I found no security findings: the tree reader keeps the run-log gate, filters go through readFilter, and a stranger gets nothing.
To fix, in one round:
- MCP
listcallslistTraces(the page's reader over the run index), butGET /api/v1/tracescallslistTraceIndex. The issue asks for the tools to call the same functions as the API routes. That leaves two list readers behind one API, and your test only checks that the two return the same ids for one repository. Make one reader serve both. Either have the API list calllistTraces, or have the tool call the API's reader, and put the shared reader's gating insrc/trace/tree.tsorlist.ts. Then compare the MCP and API list bodies in the test, not just the ids. traceTreetakesactor: User | undefinedand checksactor === undefinedtwice. Both callers pass a user, so drop the undefined branch.- MCP
readnow reads and parses the run log twice, once inreadTraceand once intraceTree. Build the rows and the tree from one parse, or say in the PR why not.
ApprovedAll five earlier asks are met on this head. (1) MCP
listand the API route now both callreadListAskandlistSeenTracesinsrc/trace/tree.ts, with the same viewer gate. (2)readbuilds its tree withtreeOf, behind the API's row gate, and a test compares it toGET /api/v1/traces/:id. (3) Tests compare whole MCP and API list bodies (filters, limit, cursor) and read. A non-member gets 404 from the API and the same nothing from the tool. (4)dlooks marks up by id and the header showsmarked n/2. (5) The docs cover the MCP actions and the keys, and theNo door:line is gone. No new security finding on the changed lines. Validation moved into one shared parser, and the repository filter is set from the resolved repo, so a caller cannot widen it. Non-blocking: the API now reaches its error codes through the shared parser mapping, which is covered by existing API tests. - MCP list does not call the API's function. The PR's own description says the
-
Checks
shipped production is serving it deploy a338207
-
History
- Traces 5c: the MCP trace list is the API's list, one reader in trace/tree.ts; read builds its tree from one parse (#18085) 081f2df
- Direction: the MCP trace list and read call the API's and the page's readers; marks hold past a filter (#18085) 5cf77b8
- Traces 5c: v marks, d compares (Space is the leader) (#18085) 5fa2b4b
- Traces 5c: mark two rows in the terminal list and open their comparison; MCP trace agrees with the API (#18085) 6d05a35
- Games: /forge reads are answered in the same sync, and the agent sends a request within a fifth of a second (#18149) e529fa8
- Traces 5a: compare two traces of one issue side by side, with the cost and time difference (#18164) e7394aa
- Access 3a: the /api/v1 repository routes ask may(), shadowed first, then their inline checks go (#18165) 7ba81ba
- Spark's config is installed with the mod so a profile uploads to the forge and never elsewhere (#18173) 7de2fc0
- Games survival step 3b: a sleep (night-skip) mod in the quality set (#18172) 56e2b82
- Automate a review finding as a lint or test: One high finding, then smaller ones, all for one round. (#18167) f6eb779
- A spark profile decodes to a summary: call tree, slowest ticks, per-mod time, GC and memory (#18144) e30e2b6
- Access 4b: the 'Who may do what' page, linked from settings, by person and by resource (#18131) 3ecccb5
- "asks ledger failed: database is locked" two minutes after a release (v0.7.733) (#18169) 009df15
- Traces 4: a Claude Code session file imports as a trace and is listed beside the others (#18129) 68f0754
- A game box stores spark profiles in the forge: POST /post gives a Location, reads need the box's game grants (#18146) b992c0d
- Games survival step 3: quality-of-life mods tried on a copy first (graves, essential-commands, sleep, harvest, vein miner, styled-chat) (#18145) f058287
- Spend 1: a monthly budget per cloud account, one notice at 80% and one at 100% (#18121) 3382c40
- Games: a proxy plugin update can wait until nobody has been on for 30 minutes (#18039) 9a5eb31
- Traces 5: compare two traces, and share one with secrets redacted (#18017) 7a17314
- AWS writes for mail setup are a named allowlist beside the read rule, and nothing else (#18142) 93c7c3d
2 earlier comments
The terminal Traces list can now mark two runs and open their comparison, and tests now show the MCP trace tool agreeing with the API compare route. The MCP list is not the same list as the API's, though. I didn't write a new traces_list, trace_get or trace_compare tool. The existing trace tool already had list, read and compare, and the issue says to prefer an action on an existing tool.
I ran test/trace-share.test.ts, test/traces-leak.test.ts, test/keymap-terminal.test.ts, test/mcp-size.test.ts and test/doorless.test.ts, plus tsc, and all pass. I didn't run bun scripts/similar.ts, and I reused nothing.
What changed
- Marking and comparing: in the Traces screen (
src/tui/screens/traces.ts),vmarks the selected run, up to two (a third drops the oldest mark).dopens the two as the comparison the trace screen already draws. - Refusals: if two runs belong to different issues or repositories,
dtoasts "those two are not runs of one issue". With fewer than two marked, it toasts "mark two runs of one issue with v". - Key choice: Space is the terminal's leader key, and
test/keymap-terminal.test.tsrefuses it for marking, so I usedvfor marking anddfor compare. - Tests: in
test/trace-share.test.ts, MCPtracecomparereturns the same table,timeDiffMsandcostDiffUsdasGET /api/v1/traces/compare, andreadandlistreturn rows. A second test marks two runs of one issue and opens the comparison, and shows two runs of different issues are refused. - Docs:
docs/features/traces.mdnames the new keys.
Left out
- The MCP
liststill lists one repository's recent agent runs. It does not take the page's filters (model, outcome, dates, person, search), so it is not the page's/traceslist. trace_getandtrace_compareas separate tools: the existingtracetool'sreadandcompareactions cover them, which also keepsmcp-sizeunchanged.- The test run data isn't in the trace index, so the MCP
readandlistare not checked againstGET /api/v1/tracesorGET /api/v1/traces/:id. That is a gap against the issue's "same data as the API".
gate.ts still prints a similarity note: my test helper in test/trace-share.test.ts looks like one in test/egress-default.test.ts. It didn't block the push, and I left both as they are.
Try: open Traces in the terminal palette, press v on two runs of one issue, then d.
No door: the MCP tool already existed; only tests were added there.
🤖 Generated with Claude Code
The MCP trace tool now calls the same readers as the page and the API. The terminal no longer loses a mark when a filter hides the run. The trace tests, the three check tests you named (unused exports, module state, job slices) and tsc pass. The gate is clean except two similar-code hints on the test helpers, which I merged into one helper. I did not run the full suite.
What changed
- List:
listnow callslistTraces(src/trace/list.ts) with the arguments passed throughreadFilter, so it is the page's list with the page's viewer gating. It takesmodel,outcome,from,to,by,qandbefore, and returnsnext. A malformed filter is dropped, as on the page. I kept the existingtracetool and added no tools. - Read: I moved the tree builder and
seeingout ofsrc/http/api/traces.tsinto a newsrc/trace/tree.ts.GET /api/v1/traces/:idand MCPreadboth calltraceTree.readreturns the existingrowsplustree, which isnullif the run is not in the trace index. - Terminal:
dlooks the marked runs up by id withgetRun, so a mark survives a search, a filter or a later page. If a marked run no longer exists, the toast says "a marked run is gone". The header now showsmarked n/2 (*). - Docs:
docs/features/traces.mdnow covers thevanddkeys and the MCPlistfilters, thereadtree andcompare. This commit changes the MCP tool as well as the terminal and docs, so it carries noNo door:line, and its subject starts withDirection:and names #18085.
Tests
- Fixture: the fixture runs were left in state
queued, so they never reached the trace index. They are nowokand indexed inbeforeAll. - Equality:
read.treeequals the API'sGET /api/v1/traces/:idbody.listequalslistTracesfor the same filters, and its ids match the API'srepository=alice/notes&kind=runlist. - Gating: a signed-in non-member (
eve) gets a 404 from the API on read and compare, and the MCP tool refuses both. Her list is empty through both, and an unauthenticated MCP call never shows the run. - Terminal: with both marks filtered off screen,
dstill opens the comparison and the header readsmarked 2/2.
Where I differ from the review
- API list:
GET /api/v1/traceslists from the trace index with its own filters (kind,since,untiland others), not fromlistTraces. I did not merge the two. The test checks only that the MCP list and the API list give the same runs for one repository. outcomefilter: the MCP schema limits it to the page's values (ok, failed, cancelled, running, queued), so a bad value is refused at the boundary rather than dropped.
To try it
Run bun test test/trace-share.test.ts. In the terminal, open Traces, press v on two runs of one issue, change the search, then press d.
The MCP trace tool now uses the same functions as the trace API routes for listing, reading and comparing.
List. The parameter checks and the gated reader that GET /api/v1/traces had inline now live in src/trace/tree.ts as readListAsk and listSeenTraces. The API route and the tool's list both call them, so the tool returns the API's exact { items, next_cursor } body. It takes the API's filters (kind, model, outcome, since, until, limit, cursor) and refuses a bad value with the API's error code. The list's response bodies don't change, but the API now reaches its error codes through the shared parser, so look at that mapping. seeing is no longer exported.
Read. traceTree now takes a User, with no undefined case. It checks access through seenTraceRow and builds the tree with treeOf. The tool's read passes the trace readTrace already parsed to treeOf, so the run log is read and parsed once. It still applies the API's access check on the index row, which costs a database lookup and no log read, so a row the API answers 404 for gives tree: null.
What changes for callers. The tool's list no longer takes the page's filters (from, to, by, q, before). Its rows are the API's index rows rather than the page's rows, and with no kind filter they include every kind the caller may see, not only crew runs. The page and the terminal list still use listTraces and are unchanged. docs/features/traces.md describes the new tool list. The commit carries a No door: line because no page or terminal screen changes.
Tests. test/trace-share.test.ts now compares whole MCP and API list bodies: no filter, kind and model, a first page with limit: 1, the next page from its cursor, and a rejected since value. It still checks that the MCP tree equals the API tree. A stranger gets { items: [], next_cursor: null } from the tool.
Checks. bun x tsc --noEmit and bun scripts/gate.ts (38 of 38 rules) pass. The MCP, trace and traces-API suites pass: 1394 tests across 226 files, plus the traces-api, traces-import, openapi-errors and private-by-default files. scripts/fast.ts named 2744 files, too many to run here, so the rest of the suite is left to the forge's check.
🤖 Generated with Claude Code
The terminal Traces list can now mark two runs and open their comparison, and tests now show the MCP
tracetool agreeing with the API compare route. The MCP list is not the same list as the API's, though. I didn't write a newtraces_list,trace_getortrace_comparetool. The existingtracetool already hadlist,readandcompare, and the issue says to prefer an action on an existing tool.I ran
test/trace-share.test.ts,test/traces-leak.test.ts,test/keymap-terminal.test.ts,test/mcp-size.test.tsandtest/doorless.test.ts, plustsc, and all pass. I didn't runbun scripts/similar.ts, and I reused nothing.What changed
src/tui/screens/traces.ts),vmarks the selected run, up to two (a third drops the oldest mark).dopens the two as the comparison the trace screen already draws.dtoasts "those two are not runs of one issue". With fewer than two marked, it toasts "mark two runs of one issue with v".test/keymap-terminal.test.tsrefuses it for marking, so I usedvfor marking anddfor compare.test/trace-share.test.ts, MCPtracecomparereturns the same table,timeDiffMsandcostDiffUsdasGET /api/v1/traces/compare, andreadandlistreturn rows. A second test marks two runs of one issue and opens the comparison, and shows two runs of different issues are refused.docs/features/traces.mdnames the new keys.Left out
liststill lists one repository's recent agent runs. It does not take the page's filters (model, outcome, dates, person, search), so it is not the page's/traceslist.trace_getandtrace_compareas separate tools: the existingtracetool'sreadandcompareactions cover them, which also keepsmcp-sizeunchanged.readandlistare not checked againstGET /api/v1/tracesorGET /api/v1/traces/:id. That is a gap against the issue's "same data as the API".gate.tsstill prints a similarity note: my test helper intest/trace-share.test.tslooks like one intest/egress-default.test.ts. It didn't block the push, and I left both as they are.Try: open Traces in the terminal palette, press
von two runs of one issue, thend.No door: the MCP tool already existed; only tests were added there.
🤖 Generated with Claude Code
Closes #18085