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

Read what you show: the log tail reads half a megabyte to print a dozen lines #157

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The studio's "Now" tail box (`src/web/studio/app.ts`) and the deploy tail beside a coming-up production head card (`src/web/studio/previews.ts`) both called `readRunLog` with no byte cap, so each paint read up to the default 512KB of a run's log and split it into every line just to show `LOG_TAIL_CAP` (6). Added `readRunLogTail(dataDir, runId, maxLines)` to `src/runs/log.ts`, which sizes its byte…

shipped production is serving it deploy d5b2fe2

opened this

The studio's "Now" tail box (src/web/studio/app.ts) and the deploy tail beside a coming-up production head card (src/web/studio/previews.ts) both called readRunLog with no byte cap, so each paint read up to the default 512KB of a run's log and split it into every line just to show LOG_TAIL_CAP (6). Added readRunLogTail(dataDir, runId, maxLines) to src/runs/log.ts, which sizes its byte cap arithmetically from the line count — maxLines worst-case lines at MAX_LINE each, plus one for the partial line a mid-cut drops — so it's provably enough to always return at least that many whole lines, however long they run, without reading past what could ever be shown. Both call sites now use it.

Left src/crew/dispatch.ts's judgeFailedCheck (the caller the issue cites as already doing this right) unchanged: its own 8KB/25-line ratio is tuned to real check-log line lengths, and widening it to the same worst-case-per-line math would have made it read six times more per failed check for a line length nothing in this codebase produces.

Added tests: test/apps-adversarial.test.ts covers readRunLogTail directly — a log far larger than the window still ends at its true last line, a line near MAX_LINE still yields at least the cap's worth of whole lines, and a log shorter than the cap comes back whole and untruncated. test/studio.test.ts adds a page-level test with 20,000 appended lines confirming the rendered page still ends at the true last line and shows the "holding the last 6" notice.

bun x tsc --noEmit and the full check suite (bun test) pass except for 6 pre-existing failures (git push/clone auth errors) that reproduce identically on a clean checkout of this branch — confirmed unrelated to this change.

Closes #146

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs