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

/traces narrows by the tool a run used and the file it touched, on the page, the API and the terminal #18373

opened this

Merged 3h 22m ago, live in production

/traces now narrows by tool and file, on the page, in GET /api/v1/traces, in the MCP trace list action and in the terminal. The new tests, the neighbouring trace tests, test/mcp-size.test.ts, tsc --noEmit, the gate and the design lint pass. I didn't run the full suite, and the preview isn't checked.

Notes

opened this

/traces now narrows by tool and file, on the page, in GET /api/v1/traces, in the MCP trace list action and in the terminal. The new tests, the neighbouring trace tests, test/mcp-size.test.ts, tsc --noEmit, the gate and the design lint pass. I didn't run the full suite, and the preview isn't checked.

  • Facets: tool is a tool name (Edit, Bash). file is a whole path, matched exactly, relative to the session's directory when it has one, with a leading ./ dropped. The page drops a malformed value; the API answers 400 invalid_tool or invalid_file.
  • Index: a new trace_touch table holds each trace's distinct tool names (up to 40) and file paths (up to 50, edits before reads). Edit, Write, MultiEdit, NotebookEdit and Read steps name files. It is written when a run or Talk turn is indexed and when a session is imported. The facets read only this table, never a log. A test shows the query plan uses the key, not a scan.
  • Older traces: a background pass at boot fills them 20 at a time (src/trace/touched_fill.ts).
  • Unindexed count: until a trace is filled, a tool or file search can miss it. The page and the terminal say how many traces the viewer may open are still unindexed, and the API adds unindexed when either facet is used. The count follows the same gate as the list.
  • Page: Tool and File text fields under Filters.
  • Terminal: u types the tool and e types the file.
  • MCP: tool and file are new arguments on the existing trace tool, so there is no new tool.
  • Migration: adds trace_index.touched and a partial index over the rows still to fill. It is pinned.
  • Tests: test/traces-touch.test.ts and test/traces-touch-tui.test.ts cover each facet, a viewer who may not read a run, an unindexed row, a hostile value escaped on the page, the caps and the query plan.
  • Docs: docs/features/traces.md names the two facets.

Not done:

  • Fill on request: a filtered list does not trigger the fill. It would make the count racy, so only the boot pass fills.
  • Unindexed crew runs: a crew run the one-time backfill hasn't reached is not in the count.
  • Partial paths: file doesn't match a partial path. respond.ts finds nothing; src/http/respond.ts does.
  • Viewer visibility: a viewer who isn't on the crew or the owner sees no crew runs, even in public repositories, because a run's log is the crew's and the owner's.

The gate notes that my test's press helper looks like the one in test/tui-steer.test.ts. I left it.

To try it, open /traces?tool=Bash and /traces?file=src/http/respond.ts on the preview, or call GET /api/v1/traces?tool=Edit.

🤖 Generated with Claude Code

Closes #18368

commented

/traces now narrows by tool and file, on the page, in GET /api/v1/traces, in the MCP trace list action and in the terminal. The new tests, the neighbouring trace tests, test/mcp-size.test.ts, tsc --noEmit, the gate and the design lint pass. I didn't run the full suite, and the preview isn't checked.

  • Facets: tool is a tool name (Edit, Bash). file is a whole path, matched exactly, relative to the session's directory when it has one, with a leading ./ dropped. The page drops a malformed value; the API answers 400 invalid_tool or invalid_file.
  • Index: a new trace_touch table holds each trace's distinct tool names (up to 40) and file paths (up to 50, edits before reads). Edit, Write, MultiEdit, NotebookEdit and Read steps name files. It is written when a run or Talk turn is indexed and when a session is imported. The facets read only this table, never a log. A test shows the query plan uses the key, not a scan.
  • Older traces: a background pass at boot fills them 20 at a time (src/trace/touched_fill.ts).
  • Unindexed count: until a trace is filled, a tool or file search can miss it. The page and the terminal say how many traces the viewer may open are still unindexed, and the API adds unindexed when either facet is used. The count follows the same gate as the list.
  • Page: Tool and File text fields under Filters.
  • Terminal: u types the tool and e types the file.
  • MCP: tool and file are new arguments on the existing trace tool, so there is no new tool.
  • Migration: adds trace_index.touched and a partial index over the rows still to fill. It is pinned.
  • Tests: test/traces-touch.test.ts and test/traces-touch-tui.test.ts cover each facet, a viewer who may not read a run, an unindexed row, a hostile value escaped on the page, the caps and the query plan.
  • Docs: docs/features/traces.md names the two facets.

Not done:

  • Fill on request: a filtered list does not trigger the fill. It would make the count racy, so only the boot pass fills.
  • Unindexed crew runs: a crew run the one-time backfill hasn't reached is not in the count.
  • Partial paths: file doesn't match a partial path. respond.ts finds nothing; src/http/respond.ts does.
  • Viewer visibility: a viewer who isn't on the crew or the owner sees no crew runs, even in public repositories, because a run's log is the crew's and the owner's.

The gate notes that my test's press helper looks like the one in test/tui-steer.test.ts. I left it.

To try it, open /traces?tool=Bash and /traces?file=src/http/respond.ts on the preview, or call GET /api/v1/traces?tool=Edit.

🤖 Generated with Claude Code

commented

I fixed both points from the review and pushed. test/traces-touch.test.ts passes (9 tests), tsc --noEmit is clean, and the design lint passes. I did not run the full suite, so the three recurring check failures you listed (duplicate imports, module-level state, first-view budget) are untested. I added no imports or module-level state, so I expect none of the three to be hit.

  • Count leak: unindexedFor in src/trace/touched_count.ts now returns early when there is no signed-in viewer, after counting repository runs. It no longer matches the empty owner id against other people's unindexed Talk turns. The new test inserts an unindexed Talk row with no owner and checks that a guest and bob both get 0. I did not run that test with the fix removed.
  • Header: src/trace/touched_fill.ts no longer says a filtered list asks for a batch. Only the boot pass fills.
  • Tool input: the page's Tool field has maxlength=64. File stays at 300.

The commit says No door:, because these change no behaviour the terminal or docs/features/ describe differently. The gate's --fix rewrapped one file's comments, which is in the commit. The gate also flagged that the press helper in test/traces-touch-tui.test.ts is nearly identical to the one in test/tui-steer.test.ts. I left that alone because it is a note, not a failure.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs