Skip to content

Show and copy the lines a Codex memory citation points to (CF-5) - #299

Merged
BunsDev merged 17 commits into
mainfrom
cf5-memory-citations
Oct 19, 2026
Merged

BunsDev merged 17 commits into
mainfrom
cf5-memory-citations

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Now also carries #302. Val merged #302 (compare a turn's patch with the working tree, file by file) into this branch as eda8445. This PR's tree now matches #302's last head 4fd4af8, which passed every CI check and the local runs listed on #302. Merging this PR lands both CF-5 changes. Details are in #302.

Part of #278 (CF-5), tracker #273. This takes one open item from the CF-5 first-part checkpoint: a Codex memory citation can now be read. The cf5-evidence worktree was released after #287; the claim is here.

What changes

A reply's "From Codex memory" citation was display-only. Each one now has Show lines and Copy. Both call a new main-process command, evidence:memory.

main/engine/memory-citations.ts reads only inside Codex's memories folder: $CODEX_HOME/memories, else ~/.codex/memories. It refuses:

  • an absolute path, or any ..;
  • a symlink that resolves outside the folder (a symlink that stays inside is followed);
  • a directory;
  • a file over 8 MiB;
  • a range that starts past the end of the file.

It returns only the cited lines, 1-based and inclusive, cut to 64 KiB, and says when the range ran past the end or the excerpt was cut.

It opens nothing in another app, executes nothing and fetches nothing.

Mac only. The command is registered local-only. A paired desktop never reads this Mac's memory files, and its card says so instead of showing an unknown-command error. The offline Store demo refuses it like its other system commands.

Streamer Mode masks the shown lines; Copy puts the lines themselves on the clipboard, as with other copies.

Native evidence

From local codex-cli 0.163.0 sessions on this Mac:

  • agentMessage.memoryCitation.entries[] carry path, lineStart, lineEnd and note.
  • The paths are relative to the memories folder, for example MEMORY.md.
  • For a one-line citation, 3 of the note's 5 words appear on the cited line counted from 1, and none on it counted from 0, so lines are 1-based.

No memory text was copied into the repository; fixtures are synthetic.

Tests, red first

  • test/memory-citations.test.ts, 7 tests:

    • the folder resolution;
    • 1-based inclusive ranges;
    • a range past the end, cut and flagged;
    • absolute paths, .., symlink escapes, a directory and an empty path refused;
    • an inside symlink followed;
    • bad ranges, a missing file, an oversized file and a missing folder refused;
    • a long excerpt bounded and flagged.

    These failed to compile before the module existed.

  • e2e/conversation-evidence.spec.ts, 2 new tests. The app runs with a test-only CODEX_HOME, never the developer's.

    • Show lines gives exactly lines 3–5 with "Lines 3–5 of 7". Copy puts exactly those lines on the clipboard, no tool item is added, and the thread stays idle.
    • A citation to ../secret.txt shows "does not point inside Codex's memory folder" and nothing from that file.

    Both failed before the UI existed: 2 failed, 4 passed. All 6 pass now.

Checks

The change is one signed commit, 3165795 (3165795508646a0f2b33faf57c20449b5bb15dba). The PR head merges main at db0bbfd (#296, docs only, no app files) on top of it. Full local run on 3165795 on macOS (Apple Silicon), Node 24.18.1, pnpm 10.34.5:

Command Result
pnpm install --frozen-lockfile passed
pnpm build passed
pnpm typecheck passed
pnpm test passed: desktop 1,530 passed and 16 skipped of 1,546 (existing skips); every other package fully green
pnpm test:e2e desktop 333 passed, 3 skipped, 1 failed; site 7/7

The one failure was owner-removal.spec.ts:75: "Test timeout of 90000ms exceeded while running afterEach". That hook closes the app and deletes its temp folder; the test body itself passed. The machine's disk dropped to 1.9 GB free during the run. This PR does not touch that spec or what it covers. Run alone afterwards, owner-removal.spec.ts passed 6/6. CI decides.

Still open on #278

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
@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 3:30am UTC

Request Review

@BunsDev

BunsDev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Coordination note from the #273 tracker session: #297 and #299 compose cleanly in either order. Both edit e2e/conversation-evidence.spec.ts. #299 adds a test-only CODEX_HOME to the setup, one more cited reply, and two memory-citation tests.

I trial-merged cf5-evidence-race into #299's head 3111e72; there were no conflicts. The combined conversation-evidence.spec.ts passed 6 of 6, with #297's per-test beforeEach. I then aborted the trial merge; nothing was pushed to either branch.

BunsDev added a commit that referenced this pull request Oct 18, 2026
Val decided on #290. The In flight entry for native conversation fidelity
listed open PRs by number, and the list went stale within hours. It already
named #291 (merged into #286) and missed #295, #297, #298 and #299. The entry
now says the tracker's child issues link their open PRs, which GitHub keeps
current.

Coven-Harness: Claude Code / claude-opus-5-5
@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main 396b17c cf5-memory-citations 9321b3b +/-
63% 63% 0%
View coverage of the 7 most impacted files.
File main 396b17c cf5-memory-citations 9321b3b +/-
apps/desktop/sr...ckends/codex.ts 96% 96% 0%
apps/store-desk...rc/main/demo.ts 95% 95% 0%
apps/desktop/sr...atchCompare.tsx 0% 0% 0%
apps/desktop/sr...red/evidence.ts 100% 100% 0%
apps/desktop/sr...shared/types.ts 100% 100% 0%
apps/desktop/sr.../patch-state.ts 0% 98% +98%
apps/desktop/sr...ry-citations.ts 0% 100% +100%

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


Updated October 19, 2026 04:07 UTC

Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 18, 2026
…tore grant (steward cycle 2) (#300)

* Settle three claims cycle 1 left unverified

Docs and plans steward, cycle 2 (#290).

- modex-signin: 43821 is only the default callback registered with WorkOS. The
  listener has used a system-assigned port since #141 (workos-auth.ts,
  listen(0)), and the wildcard entry covers it. The doc now says so.
- auto-routing: unknown models fall back to tier 2 of 0-3 (catalog.ts tierOf),
  which "the middle tier" did not pin down.
- update-recovery: the test counts are from the 2026-10-12 local acceptance run
  the paragraph links, so it now gives that date.

Checked and left as they are: the analytics demo figures (471 calls, 147
sessions, 45 days, 11 sources, 212 unpriced) match sample.ts when run, and Codex
threads do keep their Pages tools until the app-server restarts, because the
config is sent only when a thread is first loaded.

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

* Point In flight at the tracker instead of listing CF PRs

Val decided on #290. The In flight entry for native conversation fidelity
listed open PRs by number, and the list went stale within hours. It already
named #291 (merged into #286) and missed #295, #297, #298 and #299. The entry
now says the tracker's child issues link their open PRs, which GitHub keeps
current.

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

* Record the GUI Connect grant as Val's manual testing

Val answered on #290. In the October 11 signed Store acceptance, a GUI Connect
run acquired a grant before the Host dialog was captured, and three reviews left
its attribution awaiting Val. Val confirmed the grant came from Val's own manual
testing.

- The signed-acceptance review gains a dated "Attribution resolved" section.
- The Store and Companion readiness reviews each gain a one-line dated note
  pointing to it. Their original text is unchanged.
- status.md's Store Open list drops the attribution item.

The Cancel check stays open: no Cancel success was recorded.

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
BunsDev added a commit that referenced this pull request Oct 18, 2026
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
…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
@BunsDev
BunsDev merged commit f85a5b3 into main Oct 19, 2026
13 checks passed
@BunsDev
BunsDev deleted the cf5-memory-citations branch October 19, 2026 04:29
BunsDev added a commit that referenced this pull request Oct 19, 2026
Brings in #299 (CF-5 memory citations).

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 19, 2026
Both entries kept in docs/status.md.

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 19, 2026
Brings in #299 (CF-5 memory citations) and #315 (macOS CI timeout).

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 19, 2026
Both entries kept in docs/status.md.

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 19, 2026
Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 19, 2026
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

This branch was successfully deployed

1 active deployment
Preview — 9321b3ba 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