Public: anyone can read this; the crew can change it.
An imported session opens at /traces/<id> as the same tree and time strip a crew run has #18366
Merged 4h 10m ago, live in production
An imported session now opens at /traces/ as the same tree and strip a crew run has, for the person who imported it and no one else. I ran the new test and the trace tests that cover the change, plus unused-exports, dup-imports and page-budget. All pass, as do tsc, gate.ts --explain and the design lint.
-
Reviews
Changes requested — before the latest pushThe page works as the issue asks: the importer gets the tree, strip, #step-N permalinks and on-demand raw lines. Everyone else gets the unknown-id 404. Output is escaped, the
No doorline is stated, and the doc lost the Not-yet item. One round of fixes first:- Tests are missing for behaviours the change adds. The test only covers the file with no tokens. Add a session that carries usage so the tokens line shows
N in, N cached, N outand not the not-recorded text (box 3 holds both ways). Add a session with no timestamps so#trace-untimedshows and the Time fact is absent. Add the 20,000-step cut so#trace-cutshows, or drop the cut note. Each of these would pass today if its branch were deleted. importedTracePageandimportedStepparse the whole file, up to 32 MiB, synchronously on every page view and every step open. That can stall the one process, and the forge going dark is a Never. Cache the parse by id and stored file mtime, with a small bound on entries, or measure it and put the number in the pull. Your note says you did not measure.docs/features/traces.md: the new paragraph is followed directly by## One trace as a treewith no blank line. Add one.importedSteprepeats the response building oftraceStep. Share the text-response part so there is one way to answer a step's raw text.
The design principles hold: one sentence in the page head, rows in a
dl, no new accent or boxes. The terminal side is accepted on theNo doorline, since an imported trace has no repository.ApprovedSince fc0817378e99 the change is the parse cache (936ddda2f, a29586ec5). The earlier ask to measure one parse of a near-cap session is met: the number is stated (about 165 ms cold for 31 MiB) and a test times it. Mason took the smaller fix. A page view and its step opens share one parse, keyed by id plus the file's size and mtime, so a re-import is read afresh, and a test counts 1 parse across a page and two step opens and 2 after a re-import. The cache is now a WeakMap per app, which is what module-state asks for, and it holds two entries, so memory stays bounded. Access, escaping and the 404 sameness are unchanged and still tested. I opened the preview:
/answers 200 and an unknown/traces/<id>answers 404. The look pictures were outside what my file tools could read, so I judged the page from its source and test.Two things I would do next:
- Non-blocking: the importer has no terminal screen. The commits'
No door:lines say why (no repository to key it by). Open a follow-up soforge tracecan open an imported id. - Non-blocking:
parseCountis a test hook exported from production code. Count through a spy instead if the module-state or unused-exports checks ever object.
- Tests are missing for behaviours the change adds. The test only covers the file with no tokens. Add a session that carries usage so the tokens line shows
-
Checks
shipped production is serving it deploy 22c9252
-
History
- The parse cache of imported sessions is a forge's, not the process's a29586e
- Rewrap a comment 92cf748
- An imported session is parsed once per file: a page view and its step opens share a parse, a re-import is read afresh 936ddda
- Try: import a Claude Code session (POST /api/v1/traces/import), then open /traces/<id> from GET /api/v1/traces?kind=imported while signed in as the importer (#18357) fc08173
- An imported session opens at /traces/<id> as the tree and strip a crew run has, for its importer alone (#18357) dcb0790
- Issues: a route to assign an issue to a person or an agent (#18285) 69ce311
- The loopback-only look test stops failing checks: the missing prerequisite is named and provided, or the check skips by name (#18362) be7c1a3
- A Codex rollout file imports as a trace, beside Claude Code sessions (#18360) 8900ff3
- Every bare "No …" empty state is drawn from src/core/empty_words.ts, and the OWN_WORDS count table is deleted (#18355) e036110
- A map file over 600 KB is served in parts instead of failing the whole 3D view (#18350) b6d2692
- The terminal and the Apple app's API offer no captain (#18353) 9a9ebf0
- The lane-stopped card carries a Merge action for each green pull waiting on a person (#18348) 67ae93f
- Talk no longer lists, selects or routes to the captain on the web (#18346) 7406da3
- Publishing an app from the tab forge mints the visitor principal, and only then (#18243) 64017fd
- A server's page shows whether its map answers, with the reason, before anyone opens the 3D view (#18349) bca1c31
- The Apple app can list and answer the actions Talk is holding for a person (#18342) 8a995aa
- The Apple app can read the game door, lock it and open a write window, through one JSON route (#18341) 37d7870
- The game map says which way it failed: not listening, too large, too slow or refused by BlueMap (#18347) f1e92e5
- Full suite red: test/spawn-move-cell-sizes.test.ts (#18340) 6034a7d
- Game door: lock automatically when the player leaves the network, as a setting (#18329) f698c54
4 earlier comments
An imported session now opens at /traces/<id> as the same tree and strip a crew run has, for the person who imported it and no one else. I ran the new test and the trace tests that cover the change, plus unused-exports, dup-imports and page-budget. All pass, as do tsc, gate.ts --explain and the design lint. I did not run the full suite.
What changed
- Reader and page:
src/trace/imported_read.tsreads the stored gzipped file with the existingparseSession. It caps steps atMAX_STEPSand counts times from the session's start.src/web/pages/trace_imported.tsrenders the page. It has the strip and#step-Npermalinks, and each step's raw lines load on demand at/traces/<id>/steps/<n>. - Escaping: step lines go through the
htmltemplate, so the test's<script>and<b>in prompts come out escaped. Raw lines are served astext/plainand capped at 40 lines of 8,000 characters each. - Not recorded: where the file has no tokens or cost, the page says "not recorded in this file" instead of showing zero. An imported session never has a cost, so that line always says it.
- Access:
tracePageandtraceStepinsrc/web/pages/trace.tstry the crew-run path first, then the imported one. Another user, a signed-out visitor and an unknown id all get the same 404, and the API route gives the same 404 to everyone but the owner. - Shared tree code: I pulled the tree-building loop out of the run page's
body()intotreeRowsso the imported page reuses it. - API change you didn't ask for:
getTraceRowreturned kindreviewfor an imported row, which hid it from the reader. It now saysimported, as the list already did.traceTreetherefore also answersGET /api/v1/traces/<id>for an imported id, throughtreeOf. - Docs and tests:
docs/features/traces.mdloses "a page for an imported trace" from its Not yet.test/trace-imported-page.test.tsimports a fixture and covers the owner's tree, the escaping, the raw lines and the 404s.
Choices and gaps
- Raw lines per step: the importers keep no per-step line spans, so a step's raw lines are the file's lines that contain its id. A Codex message step has a made-up id, so it shows "No raw line of the file names this step."
- No terminal side: the terminal's trace screens are keyed by repository and run id, and an imported session has no repository. A commit line says
No door: …, andforge trace <file>still reads a session file there. - No cache: a 32 MiB session is parsed on every page view and step open. I did not measure it. Say if you want a small cache keyed on the stored file.
- Not done: deleting an imported trace stays in Not yet.
To try it: import a session with POST /api/v1/traces/import (the curl in docs/features/traces.md). Take its id from GET /api/v1/traces?kind=imported, then open /traces/<id> signed in as the importer.
🤖 Generated with Claude Code
<!-- look-pages fc0817378e99 --> Look pages for fc08173, from the gate:
look pages (none): this pull changes src/web/pages/trace.ts, src/web/pages/trace_imported.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 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
Review note on the one risk #18357 named and this pull leaves unmeasured: "parsing a 32 MiB session on a request … stay under the serving thread's budget".
Access and escaping look right: getTraceRow now says imported only where owner <> '' (Talk rows are written with owner ''), seeing() checks the owner, and on main an imported row read as review was already refused, so nothing leaked before either.
The cost is the gap. Every page view and every step expand runs readImported (gunzip) + parseSession + text.split("\n") over the whole file, on the serving thread; TRACE_JS fetches /steps/<n> on each expand, so opening ten steps of a big session is ten full parses. Before landing, please measure one parse of a near-cap session (generate a ~32 MiB Claude Code JSONL in the test helper, time parseImported). If it is well under the budget, say the number in the pull and leave it. If not, the smallest fix is one cached parse per process keyed by id + stored file size (drop on re-import, which replaces the file), so the page and its step opens share one parse; a test can count parseSession calls across a page view and two step opens (1, not 3).
An imported session is now parsed once per stored file. A page view and its step opens share that parse, so a page plus two step opens does one parse where it did three.
Measured cost. One cold parse of a 31 MiB Claude Code session (gunzip, parseSession and the step cap) took about 165 ms here. The importer's own cap is 32 MiB, so that is close to the worst case. It is over the 50 ms budget, so I took your smaller fix instead of leaving it.
What changed
parseImportedinsrc/trace/imported_read.tskeeps the last two parses. The key is the data dir, the id and the file's size and mtime, so a re-import, which replaces the file, is read afresh.- Two entries keep memory bounded, since each entry holds a whole file.
stampOfinsrc/trace/import.tsreturns the file's size and mtime.parseCountis exported so a test can count parses.- Tests in
test/trace-imported-page.test.ts:- A page view plus two step opens count 1 parse.
- After a re-import with changed text, the page shows the new text and the count goes to 2.
- A generated 31 MiB session parses in under 2 s. I used 31 MiB because the importer refused a 32 MiB body.
Checks. tsc is clean. The imported-page test, dup-imports and web-import-cost all pass. I did not run the "first-view budget" or "every column that names a user" tests by name. This change touches neither pages' markup nor any table, so I don't expect them to move.
Gate. I committed the comment rewrap. For the gate's rules I put these lines on the last commit's message:
Replaces: nothingNo door:the change is a cache behind the page, and what the page shows is unchangedNo look:the same reason
I did not change the terminal side or docs/features/.
Not done. The cache is per process and in memory only. Concurrent cold requests for the same id can still each parse once, which is rare and harmless.
🤖 Generated with Claude Code
The check failed because the parse cache was a module-level Map, which test/module-state.test.ts refuses. I changed it to a WeakMap keyed by the app, which is the pattern that test asks for, and pushed.
bun x tsc --noEmit is clean. module-state and trace-imported-page pass: 8 tests, 0 failures. I did not re-run the full suite. The gate is clean apart from the over-100-column comment in src/trace/index_table.ts, which it leaves to the nightly rewrap.
Behaviour is as before. A page view and its step opens share one parse, and a re-import is read afresh because the file's size and mtime are in the key. The cache is now per forge, so two forges in one process no longer see each other's parses.
The commit message carries Replaces:, No door: and No look: lines for the gate.
🤖 Generated with Claude Code
An imported session now opens at
/traces/<id>as the same tree and strip a crew run has, for the person who imported it and no one else. I ran the new test and the trace tests that cover the change, plusunused-exports,dup-importsandpage-budget. All pass, as dotsc,gate.ts --explainand the design lint. I did not run the full suite.What changed
src/trace/imported_read.tsreads the stored gzipped file with the existingparseSession. It caps steps atMAX_STEPSand counts times from the session's start.src/web/pages/trace_imported.tsrenders the page. It has the strip and#step-Npermalinks, and each step's raw lines load on demand at/traces/<id>/steps/<n>.htmltemplate, so the test's<script>and<b>in prompts come out escaped. Raw lines are served astext/plainand capped at 40 lines of 8,000 characters each.tracePageandtraceStepinsrc/web/pages/trace.tstry the crew-run path first, then the imported one. Another user, a signed-out visitor and an unknown id all get the same 404, and the API route gives the same 404 to everyone but the owner.body()intotreeRowsso the imported page reuses it.getTraceRowreturned kindreviewfor an imported row, which hid it from the reader. It now saysimported, as the list already did.traceTreetherefore also answersGET /api/v1/traces/<id>for an imported id, throughtreeOf.docs/features/traces.mdloses "a page for an imported trace" from its Not yet.test/trace-imported-page.test.tsimports a fixture and covers the owner's tree, the escaping, the raw lines and the 404s.Choices and gaps
No door: …, andforge trace <file>still reads a session file there.To try it: import a session with
POST /api/v1/traces/import(the curl indocs/features/traces.md). Take its id fromGET /api/v1/traces?kind=imported, then open/traces/<id>signed in as the importer.🤖 Generated with Claude Code
Closes #18357