Skip to content

🤖 feat: cite transcript rows in memory files and let the dream check them - #8225

Open
ThomasK33 wants to merge 15 commits into
history-index-project-searchfrom
memory-transcript-citations
Open

ThomasK33 wants to merge 15 commits into
history-index-project-searchfrom
memory-transcript-citations

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Memory files can cite the transcript rows their facts came from (sources: [<workspaceId>:<itemId>, ...] in frontmatter). The dream (memory consolidation) gets a read-only history tool, so it can check cited facts against those rows and newer ones before it keeps, fixes or drops them. Interactive memory writes now refuse credential-like text, as harvest and the dream already did. Stacked on #8224.

Background

No memory entry linked back to its evidence, and the dream rewrote facts without ever seeing a transcript. Anthropic's write-up on dreaming reports that its value comes from correcting notes against the original transcript. Citations make a fact checkable.

Implementation

  • memorySources.ts is the one pure module that parses, formats, merges (dedupe, newest 16) and resolves citations. The line is plain YAML, so old builds keep it through edits. Only numeric item ids are accepted, because the index is keyed by history sequence.
  • The memory tool takes sources on create, str_replace and insert. self:<n> resolves to the caller's workspace. Any other workspace must be in the caller's project scope.
  • checkWriteSources runs inside every write and compares the citations before and after it. Each added citation passes the caller's check, whether it came through the parameter or through the text: the project scope for agents, "read and resolved this run" for the dream, and refusal for harvest and refine. Removing a citation stays free.
  • The dream's history tool (read, search) is bound to the consolidated workspace's project. Its calls count against the run's step ceiling. Each applied op's note records which sources it checked.

Validation

  • A live run in a temp root, with the real tool path and a scripted dream model: an out-of-project source was refused, and a stale fact was corrected from a newer cited row with both citations kept.
  • Verifier: forged citations through text, removed or other-project workspaces and malformed ids are refused. Base 9679e9d193 keeps the sources: line through str_replace, insert and rename.
  • A real Haiku 5.5 turn saved a fact found by project search with sources: [<sibling>:1].

Risks

  • Interactive cleanups: with the secret guard on, cleaning a credential out of memory is no longer journaled, as with harvest and the dream.
  • Unused so far: no run in the recall eval cited sources. The value of this PR rests on the dream check and on future prompting.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $49.27

A memory file can name the transcript rows its facts came from in one
frontmatter line, sources: [<workspaceId>:<itemId>, ...]. The pure module
parses, merges (dedupe, newest 16 kept) and rewrites that line, and resolves
the memory tool's sources input (self:<itemId>, project-scope check).
Harvest and dream writes pass rejectSecretLike; the agent-facing memory tool
did not, so an agent could copy a token from tool output into project or
global memory that other workspaces' models read. Also gives the experiment
gating test the workspace id and history that session_history (registered
with Agent Memory since the project history index) requires.
create, str_replace and insert take an optional sources list. self:<n> names
the caller's own transcript; any other workspace must be in the caller's
project history scope. MemoryService merges the citations into the file's
frontmatter sources: line inside the mutation lock. A caller that resolved no
sources (harvest, refine) refuses them instead of dropping them. The static
memory guidance asks for sources on facts that come from a transcript.
Dream runs get a read-only history tool (read and search through the
project history index) bound to the consolidated workspace's project; a run
without a project identity gets none. A single-row read reports
source_status (resolved, missing, workspace_removed, out_of_scope,
unchecked). The dream may cite only rows it read and found, history calls
share the run's step ceiling, and each applied op's journal note lists the
file's citations and what the run found for each, since the dream's
transcript is not stored. dream.md says how to act on each status.
A create, str_replace or insert whose text added entries to the frontmatter sources:
line skipped the checks the sources parameter gets, so an agent could cite another
project's workspace and the dream could cite rows it never read. MemoryService now
checks, inside every text write and its dry run, each entry the edited file holds that
the file before did not, together with the sources input, through the writer's own
check (checkSources): the interactive tool's format, project scope and self:
resolution; the dream's rows read and resolved this run. A writer without one
(harvest, refine) adds no citation. Removing entries and carrying them over stay free.
A citation copied into another file counts as added, so dream.md now says to read it
first.
createConsolidationMemoryTool built the secret guard and the new source check twice,
once for the dry run and once for the write, and the crap gate counted the extra
decision (CC 16 -> 17). One writeRails() now builds both, so a preview refuses what
the write would.
@ThomasK33
ThomasK33 added this pull request to stack #8226 December 3, 2026 18:38
@mintlify

mintlify Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
Mux 🟢 Ready View Preview Dec 3, 2026, 6:38 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T19:40:49.862819Z 214f6a7 New commits
🔒 Security Review ✅ Completed 2026-12-03T19:47:16.253981Z 214f6a7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8bc78f627

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/memorySources.ts Resolved
@ThomasK33 ThomasK33 changed the title memory transcript citations 🤖 feat: cite transcript rows in memory files and let the dream check them Dec 3, 2026
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

21 agent steps · 6 replayed from cache · 15 model calls · 47.7k tokens (27% cached)
Spend: $0.09 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 1 step · 1 call 6.1s
🟢 a chat survives a restart of the server 1 step · 1 call 6.1s
🟢 compaction.e2e.ts · 1 passed 1 step · 1 call 4.9s
🟢 /compact replaces the old chat with a summary 1 step · 1 call 4.9s
🟢 pluginTrustRestart.e2e.ts · 1 passed 3 steps · 2 calls 10.4s
🟢 a trusted plugin hook stays trusted after the server restarts 3 steps · 2 calls 10.4s
🟢 settingsRoundTrip.e2e.ts · 1 passed 2 steps · 1 call 10.3s
🟢 a chat survives trips through Settings 2 steps · 1 call 10.3s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 5.0s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 5.0s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 3.0s
🟢 the agent opens the playground workspace 2 steps · 1 call 3.0s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 7.5s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 7.5s
🟢 todoNudge.e2e.ts · 1 passed 1 step · 1 call 3.3s
🟢 the agent finishes open TODO items after the turn-end nudge 1 step · 1 call 3.3s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 27.0s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 3.8s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 4.5s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 8.0s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 3.9s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 3.6s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 3.3s

e2e 0.20.0 · 1m 22s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 7.9k tokens (33% cached)
Spend: $0.01 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 7.1s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 7.1s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 7.3s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 7.3s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 6.5s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 6.5s

e2e 0.20.0 · 24.0s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 8.0s · 2 targets (web, phone) · run artifacts

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: b8bc78f627

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: b8bc78f627

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

withSourcesLine read the sources value line by line and left a flow
list's closing ] behind when it stood on its own line. The span now
comes from the YAML parser (key start to value end); the line logic
stays as the fallback for frontmatter that does not parse.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: cf181b2cb4

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf181b2cb4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/memoryDreamHistory.ts Resolved
Comment thread src/node/services/memorySources.ts Resolved
…y row a read returned

An empty sources key with a comment (sources: # note) has a value range
that ends at the comment, so the span now drops all trailing whitespace,
not only newlines. The dream's ledger recorded only from_item; it now
records each row a successful range or cursor read returned.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 9398aaf24d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 9398aaf24d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 214f6a7cc6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 214f6a7cc6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

index: DreamHistoryIndex
): SourceCheckStatus {
if (!result.success) return failedReadStatus(source, result.error, index);
if (result.parts?.some((part) => part.item_id === source.itemId) === true) return "resolved";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep citations distinct across history clears

After a workspace's history is cleared and new messages arrive, an existing citation can resolve to an unrelated replacement row. HistoryService.truncateHistory() resets the sequence counter to zero on full clears, but citations persist in memory files and this check treats any matching item_id as the original source. For example, a saved a1:0 citation becomes resolved against the first message after /clear, allowing the dream to validate or correct an old fact using the wrong evidence rather than recognize its source as missing. Preserve a non-reusable row identity across clears, or otherwise distinguish the transcript generation in persisted citations.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 214f6a7cc6

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

This branch was successfully deployed

1 active (outdated) deployment
staging - docs — b8bc78f6 Deployed Dec 3, 2026 by mintlify[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