Skip to content

Keep a long command's full log and read it back a page at a time (CF-5) - #311

Merged
BunsDev merged 25 commits into
mainfrom
cf5-retained-log
Oct 19, 2026
Merged

BunsDev merged 25 commits into
mainfrom
cf5-retained-log

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Part of #278 (CF-5), tracker #273. #299 has landed (f85a5b3), and this now targets main. Against main it changes only its own 17 files: #299's final head was merged in, and its squash was recorded with -s ours, which leaves the tree unchanged. The claim is here.

This takes CF-5's last runner-bound item, the retained full log. The acceptance line is: a log larger than the configured cap is visibly truncated with bounded updates and retained outcome; reopening it cannot execute anything.

What changes

A command whose output passed the transcript's 256 KB preview now has Show full log under "Showing the last 256 KB of …". It reads the output back from its first line, a page at a time:

  • Earlier, Later, Copy page and Hide.
  • A status line: "Kept all 3.1 MB", "Kept the first 10.0 MB of 12.0 MB", or "the tool did not finish, so the rest is unknown", plus "Page i of n".

What main keeps (main/engine/tool-logs.ts):

  • The Codex backend hands each raw item/commandExecution/outputDelta chunk to a new optional TurnSink.output. That's one line in codex.ts.
  • The runner maps the chunk to the tool's transcript item with toolItemId, which reads the conversation state's own native-id map.
  • The store holds the output in memory until it passes the preview. Output that fits in the preview is never written.
  • Past that, it writes up to 10 MiB from the first byte to app/tool-logs/<thread>/<item id, hex>.log, and records the total when the tool finishes.
  • The runner closes open logs when the attempt ends. The logs are deleted with their thread.

What stays still:

  • Raw chunks are never journaled, and never sent to the window except as pages asked for with evidence:tool-log.
  • Every observation still carries only the bounded preview.
  • Thread ids are checked and item ids are hex-encoded, so no id becomes a path.
  • runner.toolLog reads only for a tool item of that thread.
  • Pages are at most 256 KiB and end on a UTF-8 character boundary. The 10 MiB cap also stops before a character it would split.
  • Reading runs nothing. Streamer Mode masks the page; Copy puts the page itself on the clipboard.
  • The offline Store demo refuses the command.

Claude needs none. Claude Code 2.1.302 hands Claude at most bashOutputMaxChars of a Bash result: 30,000 characters by default, clamped to 4,000–128,000. It keeps the rest in its own file and gives Claude the path; the source is the CLI's bundled settings text. So a Claude result never outgrows the preview, and the Claude backend doesn't call the hook. Modex doesn't read the path Claude Code names.

Tests, red first

  • test/tool-logs.test.ts, 8 tests:

    • output under the preview leaves nothing on disk;
    • output over it is kept from the first byte and reads back in bounded pages;
    • the 10 MiB cap and the recorded total;
    • pages and chunks never split a character;
    • unsafe thread ids are refused and item ids encoded (nothing lands outside the thread's folder);
    • removing a thread removes only its logs;
    • an unfinished tool claims no total.

    It failed to compile before the module existed (TS2307). Three tests first failed because of a bug in the tests: a kept log is always longer than one page, and they read only one. I fixed the tests, not the store.

  • test/codex-backend.test.ts: a 12 MiB Codex stream reaches the hook in full, while every tool.update and tool.done carries at most the preview. The hook didn't exist before the change.

  • test/evidence.test.ts: the runner keeps a fake backend's 840 KB of raw output for its item and pages it back whole. No event carries the raw log, non-tool and missing items are refused, and the logs go with the thread. It failed to compile before the change (TS2339: no output, no toolLog).

  • e2e/tool-full-log.spec.ts, 2 tests, through the real app, main and the Codex backend, against a codex-cli 0.163.0-shaped app-server streaming 3.1 MB:

    • The preview lacks line 1. Show full log starts at line 1, says "Kept all 3.1 MB · Page 1 of 13", and pages forward and back. The fixture still ran exactly one command, and the thread stays idle.
    • After a restart, the log reads back the same.
    • Red: on the source before the UI (4a1b1d6), both failed waiting for tool-log-show.

Checks

The change is three signed commits plus a docs commit:

  • eb215b5: main side.
  • 0cd8a0e: the e2e test.
  • 40b41f5: UI.
  • 1829b4b: docs.

4a1b1d6 merges #299's branch, which carries main at 3560064. macOS (Apple Silicon), Node 24.18.1, pnpm 10.34.5.

Command Result
pnpm typecheck passed
pnpm build passed
pnpm --filter @modex/desktop test on eb215b5 1,591 passed, 16 skipped of 1,607 (existing skips); second stage 21/21, at load average ~415
Unit: tool-logs, evidence, codex-backend, patch-state on the merged head 58/58
e2e on 40b41f5: tool-full-log, conversation-evidence, turn-patch-state, transcript-measure, typed-turns, conversation-fidelity 22/22

After the merge with main (dd20818, which includes #299, #288, #304 and #315):

  • Build and typecheck passed.
  • Unit tests: tool-logs, evidence, codex-backend and notes-projects passed 52/52.
  • e2e: tool-full-log and sidebar-workspaces passed 5/5.

On 5bf7607 (#299's final head and its recorded squash):

  • Install, build and typecheck passed.
  • Desktop unit tests: 1,622 passed, 16 skipped of 1,638; second stage 21/21.
  • e2e: 23/23 across the full log, patch state, evidence, human requests, transcript measurement and fidelity.

Not run locally: the full pnpm test:e2e. CI runs it.

Still open on #278

  • Structured web-search results. Codex's results are opaque, and there's no local sample without a live Codex run.
  • Comparing removal-only edits and notebook edits.

Coven-Harness: Claude Code / claude-opus-5-5

A reply's "From Codex memory" citation was display-only. Each one now
has Show lines and Copy, which ask main (evidence:memory) for the cited
lines. main/engine/memory-citations.ts reads only inside Codex's
memories folder ($CODEX_HOME/memories, else ~/.codex/memories) and
refuses an absolute path, any "..", a symlink that resolves outside, a
directory, a file over 8 MiB, and a range past the end. It returns the
1-based, inclusive lines, cut to 64 KiB, and opens, runs and fetches
nothing. The command is local-only: a paired desktop never reads this
Mac's memory files. Streamer Mode masks the shown lines.

Local codex-cli 0.163.0 sessions cite paths relative to the memories
folder (MEMORY.md), and a one-line citation's note matched its line
counted from 1, not 0.

Tests first: memory-citations.test.ts (7) and two e2e cases in
conversation-evidence.spec.ts (show/copy exact lines with nothing
started; an escaping citation refused), red before the code.

Part of #278.

Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
* Keep each Codex file change's path, kind and share of the patch

codex-cli 0.163.0 sends a fileChange's files with absolute paths and
each file's diff separately. Modex joined the diffs into args.patch and
dropped the paths, so a turn's patch could not be checked file by file.

args.files now keeps each file's path, kind, move target and how many
lines of args.patch are its diff, so the diffs are not stored twice.

Coven-Harness: Claude Code / claude-opus-5-5

* Compare a turn's patch with the working tree, file by file

A patch tool was labelled as the turn's, but nothing said whether the
files still matched it. A patch the CLI reported as applied now has
Compare with working tree. Main takes the patch from the thread's own
record and reads only the files it names, inside the thread's folder,
and answers per file: as this turn left it, still has this turn's edit,
changed since, deleted since, or not compared with the reason.

Only verdicts reach the window. Opening a row reads nothing; comparing
writes and runs nothing. Links out of the folder, directories, files
over 8 MiB, removal-only edits, notebook edits and Codex patches saved
before per-file records are not compared, and say why.

Part of #278 (CF-5), tracker #273.

Coven-Harness: Claude Code / claude-opus-5-5
Both entries kept in docs/status.md.

Coven-Harness: Claude Code / claude-opus-5-5
… slice

Coven-Harness: Claude Code / claude-opus-5-5
The transcript keeps a tool's last 256 KiB; the rest of a long Codex
command's output was dropped. Codex streams every chunk
(item/commandExecution/outputDelta), so its backend now hands each raw
chunk to an optional main-only sink hook, TurnSink.output. The runner
maps it to the tool's transcript item and ToolLogStore keeps it.

Output that fits in the preview is never written. Past that, the store
keeps up to 10 MiB from the first byte in one file per item under
app/tool-logs/<thread>/, records the total when the tool finishes,
reads back 256 KiB pages ending on character boundaries, and is removed
with its thread. Thread ids are checked and item ids are hex-encoded,
so no id becomes a path. Nothing raw is journaled or sent to the window.

Claude Code 2.1.302 hands Claude at most bashOutputMaxChars (default
30,000, up to 128,000 characters) and keeps the rest in its own file,
so a Claude result never outgrows the preview and its backend does not
call the hook.

Part of #278 (CF-5), tracker #273.

Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
…log slice

Coven-Harness: Claude Code / claude-opus-5-5
A tool whose output passed the 256 KB preview now has Show full log
under its truncation notice. It asks main (evidence:tool-log) for the
kept output from the first byte, 256 KB per page, with Earlier, Later,
Copy page and Hide. The status says whether all of it was kept, the
first part of how much, or that the tool never finished. Streamer Mode
masks the page; nothing is read until asked, and reading runs nothing.

The page shape, sizes and byte formatter move to shared/evidence.ts.
The offline Store demo refuses the command like its other evidence reads.

Part of #278 (CF-5), tracker #273.

Coven-Harness: Claude Code / claude-opus-5-5
…aude needs none

Coven-Harness: Claude Code / claude-opus-5-5
@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Oct 19, 2026 6:32am UTC

Request Review

@github-code-quality

github-code-quality Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main f435065 cf5-retained-log dd20818 +/-
63% 63% 0%
View coverage of the 8 most impacted files.
File main f435065 cf5-retained-log dd20818 +/-
apps/desktop/sr...red/evidence.ts 100% 99% -1%
apps/desktop/sr...ngine/runner.ts 98% 98% 0%
apps/desktop/sr...ation-events.ts 98% 98% 0%
apps/store-desk...rc/main/demo.ts 95% 95% 0%
apps/desktop/sr...ckends/codex.ts 96% 96% 0%
apps/desktop/sr...ckends/types.ts 100% 100% 0%
apps/desktop/sr...ipt/ToolLog.tsx 0% 0% 0%
apps/desktop/sr...ne/tool-logs.ts 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 19, 2026 07:05 UTC

…ch-comparison slice

Coven-Harness: Claude Code / claude-opus-5-5
…nd patch-comparison slice

Coven-Harness: Claude Code / claude-opus-5-5
… patch-comparison slice

Coven-Harness: Claude Code / claude-opus-5-5
Base automatically changed from cf5-memory-citations to main October 19, 2026 04:29
Coven-Harness: Claude Code / claude-opus-5-5
The tree already holds it: #299's final head was merged in, and the
squash has that head's exact tree.

Coven-Harness: Claude Code / claude-opus-5-5
Both entries kept in docs/status.md.

Coven-Harness: Claude Code / claude-opus-5-5
catch (err) { setError(err instanceof Error ? err.message : String(err)); }
};

if (none) return <p className="tool-log-none" data-testid="tool-log-none">Modex kept nothing more than this. The CLI's own logs may have the rest.</p>;
@BunsDev
BunsDev merged commit cad3e54 into main Oct 19, 2026
13 checks passed
@BunsDev
BunsDev deleted the cf5-retained-log branch October 19, 2026 07:05
BunsDev added a commit that referenced this pull request Oct 19, 2026
Brings in #304 (move to a new workspace) and #311 (CF-5 retained full log).

Coven-Harness: Claude Code / claude-opus-5-5

This branch was successfully deployed

1 active deployment
Preview — dd208189 Deployed Oct 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant