Repository navigation
Conversation
…ection Move session_history's row sanitizer into historyIndex/projection.ts and add projectMessageParts, which yields one searchable entry per text or tool part with a human flag, a kind and clipped tool I/O.
…tch-up table decideCatchUp decides noop/remove/rebuild/incremental from file stats; toFtsMatchQuery quotes every term so punctuation never breaks MATCH.
… queries HistoryIndexStore keeps one SQLite row per transcript part, catches sessions up from file stats (append, rotation, rewrite, removal, torn tails), applies the manual-reset floor in the same transaction, and answers search, list and read queries.
The worker solely owns the SQLite database and runs catch-ups and queries in order. HistoryIndexService resolves the caller's project scope from config (analytics attribution), posts requests in call order, and keeps the index warm with a newest-first backfill and stream-end/removal hints. Worker path resolution moves to resolveWorkerScriptPath, shared with analytics and the tokenizer pool.
scope "project" reads every workspace of the caller's project through the history index: ranked FTS search with role/tool/human/date/workspace filters, newest-first session listing, and part-level reads with cursors. Results are redacted at the tool boundary, stay under 16 KiB, and report coverage. scope "self" keeps today's behavior. session_history is now offered with Agent Memory alone; new_context stays token-budget only. The tool card renders project rows and coverage.
HistoryIndexService joins the cross-cutting services: tool config gets it through the turn request bindings, stream-end and workspace removal send hints, startup housekeeping starts the backfill, and both dispose paths stop the worker. The Docker runtime bundles historyIndexWorker.js beside server-bundle.js.
Its UMD build requires ./impl/* at run time, which the bundle does not ship; the server bundle uses the same ESM alias.
Adds a project-search section to the token-budget page and regenerates hooks/tools.mdx. Marks the worker-only sync fs reads, replaces object-literal assertions in tests, folds the service's three query methods into one dispatcher, and accepts three shape-coincidence DRY matches with reasons.
…cope edges Regression tests from the Phase 1 verifier that pass at this base: a reset plus a rotation keeps the floor and indexes each row once (a rebuild gives the same rows), a file that is not SQLite is rebuilt, multi-project and scratch scopes, and a workspace dropped from config leaves every project action.
FTS5 snippet marks landed inside a matched secret (`ghp_«abc…»`), so output-time redaction no longer matched it and search returned the token body. Each part is now redacted once in projectMessageParts (tool sides through redactWithinCap before the clip, so a secret that crosses the cut is not kept as a readable prefix), and titles and names in upsertMeta. No secret reaches history.sqlite, and the tool no longer redacts what it reads. Schema version 2 rebuilds existing indexes. Cost on the 160 MB synthetic session (bun, first build): 4.4 s -> 12.4 s (36 -> 13 MB/s); redactSecretLike runs at about 8 MB/s.
A query catches its scope up newest first under a 3 s budget, so a session behind a large newer one could stay pending and still serve rows from before its latest reset or /clear. catchUp now names the sessions whose index matches their files, and search, list_sessions and read answer from those only; pending sessions are left out and counted in coverage.pending. WorkspaceService emits history-reset once a manual reset, a full clear or a destructive replace is durable, and the desktop root sends it to the index as a catch-up hint, wired like the stream-end hint.
Every change to chat.jsonl re-read it whole, so a 160 MB session took 10.3 s to re-index after each stream end. A stream end replaces the file by temp file + rename (updateHistory), with the rows before the changed one copied byte for byte, so the archive rule (same inode, grown size, 64-byte anchor) would miss every stream end. The index now keeps the offset through the last row that yielded entries (an empty placeholder or a reset row after it is read again), the floor state there, and a sha256 of the bytes before it. When those bytes still hash the same on any inode, and the archive did not change, only the rows after the offset are read; anything else re-reads the file whole. Schema version 3. 160 MB synthetic session (bun): stream end 10254 -> 152 ms, mtime touch 10994 -> 160 ms; the floor is the sha256 of the prefix (about 1.8 GB/s).
…imit observeFiles reads the archive anchor and the chat prefix digest through one named helper each, and decideCatchUp keeps its noop/incremental step in planIncremental.
On a random 1.4 GB sample of real sessions (545 sessions, read-only, temp db), 2,000/2,000 built an 830 MB index in 123 s (0.59x); 1,000/600 builds 717 MB in 102 s (0.51x). Content fell from 318 to 255 MB; of what is left, 141 MB is agent-written user rows (sub-agent briefs and reports) and 89 MB tool calls, and the FTS index is the rest. Schema version 4 rebuilds indexes built with the old clips.
dispose() waited for the shutdown reply, which queues behind a running catch-up slice (4.2 s seen at quit). It now posts shutdown, waits up to HISTORY_INDEX_SHUTDOWN_GRACE_MS (1 s) for the worker to exit (the worker exits right after closing the database), and then terminates it; SQLite rolls back the cut-off transaction. Requests still pending fail at once, and later ones are refused. terminate() is not awaited: a long native call, or Bun until its task ends, holds the thread, and a quit must not wait for it. Test with a 100 ms grace and a slow catch-up (bun): dispose 3400 -> 105 ms.
With the grace timer armed on every dispose (and the worker calling process.exit), Bun segfaulted the test process in 6 of 44 runs of the history index and tool suites (0 of 100 without a timer). An idle worker (no request pending) now answers shutdown at once and is terminated, as before 405c24c001; only a busy one gets the timer, and is terminated without waiting when the grace runs out. Measured: 0 of 15 combined runs and 0 of 15 dispose-test runs crashed.
Each part is its own index row, so a question whose words land in two parts found nothing ANDed. When the all-terms query finds no hit, the same request asks once more with the terms ORed, ranked by bm25, and the result says so (match: "any"; "all" otherwise). Control characters now split terms in the query builder: a NUL ended the MATCH string early (SQLite "unterminated string", index_unavailable), and under Bun it crashed the worker. A seeded fuzz of 2,000 typed queries raises no FTS5 error.
… args Models carry max_chars_per_item over from scope "self", and 26 of 103 project-scope calls in the recall eval failed on it with filters_unsupported. search, list_sessions and read now take it as their per-item cap (snippet, first_ask, part text), clipped with a marker and kept within each action's own limit. An argument an action cannot take (window_id, task_id, item_id, offset_chars, limit_chars, ...) still fails with filters_unsupported, and unsupported_args now names it.
Bun's statSync reports mtimeMs in whole milliseconds and Node's keeps the fraction, so an index built under one runtime looked stale to the other (110 of 3801 sessions indexed for a Node server reading a Bun-built index). Stats are stored floored, and sameStat compares Math.floor of both sides, so watermarks already stored with a fraction stay current. No schema change.
…st lint Clears the two DRY gate findings (toFtsMatchQuery/toFtsAnyTermQuery, hitRow/partRow) by extracting the shape each pair must change together, and the oxlint errors in the redaction and fuzz tests (sync fs reads, a useless escape).
The crashes that b451987025 avoided came from Bun 1.2.15, which this host puts first on PATH: its crash report is a JavaScriptCore DFG compiler segfault, and the same build crashes the whole tools suite at other commits too. Under the pinned Bun 1.4.3 (package.json, CI) and Node, terminate() stops a busy worker at once and nothing crashes (combined history index and tool suites: 0 of 10 runs). So dispose waits for the shutdown reply for at most the grace on every call, and the comments no longer blame a timer.
In a real-transcript eval, 9 of 14 remaining project-search errors were models passing match: "any", which the description named as an output. It is now a nullish input of scope "project" search: "all" (default) keeps the all-terms pass with its any-term fallback, "any" asks the ORed terms at once. Other actions and scope "self" refuse it.
HistoryIndexStore.open deleted and rebuilt the index on any open error, so a second backend that opened it while the first held a write lock (SQLITE_BUSY) deleted a live index. Now: - Each connection waits out another's lock (busy_timeout 5 s). - An open of a current index makes no write (user_version is written only when it changes), so it takes no write lock at all. - Only SQLITE_CORRUPT and SQLITE_NOTADB, read from either driver's error (sqliteResultCode), and an old schema version rebuild the index. Any other error fails the open; the query answers index_unavailable. - The service drops a worker whose open failed, so the next request opens again instead of failing "used before init" until restart.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6a5aab699
ℹ️ 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".
🟢 e2e stories (Haiku): 14 passed21 agent steps · 6 replayed from cache · 15 model calls · 47.7k tokens (23% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 16s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 8.0k tokens (22% cached) All 3 tests in 3 files
e2e 0.20.0 · 25.2s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 8.0s · 2 targets (web, phone) · run artifacts |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…p sealed rows archive-owned
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Quality / CRAP flagged sessionItem and scalarText as new untested functions. The tests pin archived-over-agent roles, title over name, the first ask, and that numbers and booleans in a tool output are searchable while functions are not. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
With Agent Memory on,
session_historytakesscope: "project"and searches the transcripts of every workspace in the caller's project, archived and sub-agent ones included. New actionslist_sessions,search(SQLite FTS5, bm25-ranked snippets,match: "all" | "any") andread(a verbatim item range) run against a derived index at~/.xum/index/history.sqlite.scope: "self"(the default) is unchanged.Background
Agents could read only their own workspace tree, by literal substring scan, and only with the Token Budget experiment on. Every other transcript (15 GB on one dev host) was unreachable. Following The bitter lesson for agent memory, the transcripts stay the source of truth and the agent searches them at query time. Memory citations build on this in the next PR of the stack.
Implementation
HistoryIndexService(main thread) talks to one worker that alone owns the SQLite file.sqliteDriver.tsloadsbun:sqliteunder Bun (tests) andnode:sqliteunder Node and Electron 44.decideCatchUpis a pure table over file stats. The archive is append-only, andchat.jsonlis re-read only after the stored prefix hash, because stream-end writes are temp file + rename./clearis a hard floor, the same rulesession_historyuses. Only sessions whose watermark matches the disk answer, and pending ones are counted incoverage. Text is redacted once withredactSecretLikewhen it is written, so FTS snippet marks cannot split a secret.session_historyis offered with Agent Memory or Token Budget.new_contextstays Token Budget only.Validation
distran index + search under Electron 44.5.1 (Node 24.21, SQLite 3.53.4) and Node 22.scope: "project"and never saw the other project's decoy.Screenshots
Risks
xum runroots (they exclude memory by design), transcripts of removed sub-agents that are archived into the parent, andpartial.json.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$49.27