Skip to content

Session History: preserve exact metadata while limiting closing previews - #28925

Closed
brennanb2025 wants to merge 5 commits into
mainfrom
brennanb2025/scan-bounded-read
Closed

brennanb2025 wants to merge 5 commits into
mainfrom
brennanb2025/scan-bounded-read

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Session History can lose a renamed title or the latest working folder when a large transcript is sampled from its opening and closing records. This host change reads every record with the existing parser and limits only the closing preview work, so session identity, location, model, counts, prompts and timestamps stay exact. Bundled clients do not yet request shortened previews; preserving their existing behavior is required before this PR leaves draft.

What Changed

Large Claude and Codex transcripts can produce a capability-gated row with previews collected only from complete records starting in the final 64 KiB. The existing parser still sees the entire transcript; appends resume from its validated cursor. These list reads stay separate from exact search consumers, and an ordinary caller upgrades a shortened-preview cache entry through a complete read.

The read requirement is included in both the list cache and outer request-coalescing keys. The existing parse-cache schema advances to 5 so this implementation rejects previously sampled rows whose metadata may be incomplete. The wire capability stays optional, preserving mixed client and host versions.

Why

Titles, directories and other mutable fields can be recorded anywhere in a transcript. A newer closing timestamp cannot prove the skipped middle contains no relevant update. Reusing the complete parser removes that failure class without another metadata parser or field-specific fallback rules.

The intended difference from the common pattern is preserving the existing complete derivation for imported CLI histories: no verified alternate metadata source covers all supported fields on every execution host. Preview work alone is bounded; byte reads remain complete. The earlier two-window speed and byte measurements are superseded and must not be used as evidence for this implementation. Corrected measurement failed the agreed usefulness requirement, so this PR remains draft.

Measurement result: not useful enough to land

Five alternating fresh-process runs on the original measurement host, with a 250-row scan limit and identical synthetic data, produced these cold medians:

Request Main elapsed Branch elapsed Main CPU Branch CPU Transcript bytes, both
Existing exact client 717.833 ms 740.454 ms 1049.463 ms 1051.277 ms 308,943,713
Explicit shortened-preview client 744.278 ms 524.113 ms 1074.921 ms 1078.874 ms 308,943,713

All 30 cold/warm/append row comparisons match, excluding only the intended preview/coverage fields for capable callers. The elapsed saving is 220.165 ms, about 47% of the earlier 470 ms gain, and CPU does not improve. This fails the agreed usefulness requirement. These are process/cache-cold scans, not cold physical storage; all transcript bytes are still read. The earlier bounded-byte claims are superseded.

A search-enabled sample ran for about 10 seconds but both indexes were still working (694/1200 and 817/1200 files). It does not prove completed search timing or total-work parity. No broader corpus or weaker metadata behavior was added to rescue the result.

Linked Issue

N/A (internal performance work).

Visual Proof

Blocked: none of the available remote QA hosts had safe resources for an Electron launch; no rendered comparison or screenshots were produced.

Testing

The normal pre-commit hook passed on bd6c391. Focused regression cases cover whole-row parity except preview coverage, aligned and crossing cutoff records, unfinished records completed by append, consumer silence and exact upgrades, cache reload and request coalescing. Windows targeted execution on bd6c391 collected 67 tests: 65 passed, including all partial-read, persistence, IPC coalescing and full-prompt tests and the RPC capability case. Two existing RPC assertions expect POSIX separators and failed on Windows; the same two failures reproduce from unchanged main test source. Remote Electron QA and current-head full CI remain unverified; prior-head results do not validate this rewrite. GitHub currently reports mergeability as unknown, and no current-head checks have registered. The final main synchronization is deferred because the PR is otherwise not ready.

Windows, WSL, SSH and folder scopes retain the existing execution-host stream path. Runtime evidence for those paths remains pending. No saved field, setting, new wire operation or client default is added.

Review

Round one found incomplete metadata derivation and record-boundary loss. A design review selected the complete fold with bounded preview collection, and a fresh pre-code verifier approved it. Independent round-two source reviews confirmed the metadata, cache and request-isolation fixes, then found a wrong predicate in the moved full-prompt capture function and a concurrency fixture using the wrong scanner boundary. A fresh independent design review unanimously kept the mechanism and authorized only those two narrow corrections. Both narrow corrections are pushed in bd6c391. Fresh independent source verification agrees both corrections are fixed. The benchmark below fails the agreed usefulness requirement. Remote rendered validation and exact-head CI remain unverified; this PR is not ready.

Agent skill upstream boundary

  • Not applicable: this change copies no upstream skill-installer material.

Checklist

  • Explained the problem, resulting behavior, mechanism and alternatives.
  • Cross-platform and mixed-host compatibility considered.
  • Focused tests and real remote Electron QA passed on the final head.
  • Corrected before/after performance evidence recorded.
  • Full PR workflow passed, review threads resolved and merge state clean.

…ts that accept partial rows

A list row only needs the opening and closing records of a transcript. A new
partial read mode feeds the existing per-agent fold the first 256 KB and last
64 KB, marks the row partial, and never publishes to transcript consumers.
Hosts serve such rows only to clients advertising aiVault.list.partial-rows.v1;
nothing advertises it yet, so behaviour is unchanged.
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change adds capability-gated partial rows for AI Vault session lists. For eligible requests, large transcripts can produce rows with suffix-limited previews and partial-coverage metadata. Exact-read callers retain full transcript parsing. The scanner and parse cache distinguish partial and exact read requirements, and list caching separates requests by partial-row setting. Tests cover RPC routing, scan coalescing, transcript parsing, and persistence.

Priority: ⬇️ Low

Merge Risk: 🟠 High · up to dc39d

A refactor of the first-user-prompt helper makes it call itself instead of checking the capture mode. Session rows would stop recording the full first user prompt for all agents, not only for partial reads. The build's type check is also likely to fail. Replace the guard with the capture-mode check before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly summarizes the main change: preserving exact session metadata while limiting closing preview collection.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, measurements, testing, compatibility, and current validation limits. It identifies that the PR remains draft and that…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch brennanb2025/scan-bounded-read
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025 brennanb2025 changed the title Session History: read large transcripts by their ends for clients that accept partial rows (no visible change) Session History: preserve exact metadata while limiting closing previews Oct 15, 2026
@brennanb2025
brennanb2025 marked this pull request as draft October 15, 2026 22:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 39702b7f-2843-4bb9-acce-47df02d23c32
📥 Commits

Reviewing files that changed from the base of the PR and between e9a8bf1 and dc39d22.

📒 Files selected for processing: 16
  • src/main/ai-vault/session-parse-cache-persistence.test.ts
  • src/main/ai-vault/session-parse-cache-snapshot-serialization.ts
  • src/main/ai-vault/session-parse-cache-store.ts
  • src/main/ai-vault/session-partial-transcript-read.test.ts
  • src/main/ai-vault/session-scanner-accumulator.ts
  • src/main/ai-vault/session-scanner-codex-parser.ts
  • src/main/ai-vault/session-scanner-first-user-prompt.ts
  • src/main/ai-vault/session-scanner-jsonl-reader.ts
  • src/main/ai-vault/session-scanner-parse-cache.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts
  • src/main/ai-vault/session-scanner-types.ts
  • src/main/ai-vault/session-transcript-reader.ts
  • src/main/ipc/ai-vault-scan-coalescing.test.ts
  • src/main/ipc/ai-vault.ts
  • src/shared/ai-vault-partial-rows-capability.ts
  • src/shared/ai-vault-types.ts
🚧 Files skipped from review as they are similar to previous changes: 4
  • src/shared/ai-vault-partial-rows-capability.ts
  • src/main/ai-vault/session-parse-cache-store.ts
  • src/shared/ai-vault-types.ts
  • src/main/ai-vault/session-scanner-parse-cache.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment on lines +124 to +129
if (
role === 'user' &&
seedFirstUserPrompt !== false &&
!accumulator.firstUserPrompt &&
seedFullFirstUserPrompt()
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Replace the self-call with shouldCaptureFullFirstUserPrompt().

At Line 128, the guard calls seedFullFirstUserPrompt() with no arguments. This recursive call is wrong in two ways:

  • Inside the call, role is undefined, so the function returns void. The outer condition is then always falsy. As a result, firstUserPrompt is never set, even in 'full' capture mode. The copyable first prompt is lost for every parser that uses this helper.
  • TypeScript does not allow a missing required argument. It also does not allow a truthiness test on a void expression (TS1345). The node typecheck should fail.

The old accumulator code gated on the capture mode. shouldCaptureFullFirstUserPrompt is defined in this file for that purpose.

🐛 Proposed fix
     !accumulator.firstUserPrompt &&
-    seedFullFirstUserPrompt()
+    shouldCaptureFullFirstUserPrompt()
   ) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (
role === 'user' &&
seedFirstUserPrompt !== false &&
!accumulator.firstUserPrompt &&
seedFullFirstUserPrompt()
) {
if (
role === 'user' &&
seedFirstUserPrompt !== false &&
!accumulator.firstUserPrompt &&
shouldCaptureFullFirstUserPrompt()
) {

@brennanb2025

brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Session History rebuilds spend CPU extracting previews from large transcripts. Skipping the middle of a transcript can also lose a renamed title or the latest working folder. This revision keeps the complete metadata parser and limits only closing-preview extraction for explicitly capable clients; bundled clients keep exact rows.

Not ready; remaining in draft at bd6c391adc20ea242a90e73a7a6ee80acf86309b.

  • Review repaired the metadata omissions, record-boundary loss, old sampled-cache acceptance and request isolation. A subsequent correction restored full opening-prompt copying and corrected the concurrency test. Independent source verification found both corrections fixed.
  • Windows targeted execution: 65/67 passed, including all partial-preview, persistence, first-prompt and IPC tests plus the RPC capability case. The two path-separator assertion failures also reproduce from the unchanged main test source on Windows.
  • Five alternating fresh-process runs on the original measurement host passed row parity for cold, warm and deterministic append scans. Capable cold median: 744.278 → 524.113 ms; CPU: 1074.921 → 1078.874 ms; transcript bytes: 308,943,713 → 308,943,713. The elapsed saving retains about 47% of the prior 470 ms gain and CPU does not improve, so the agreed usefulness requirement was not met. Exact-client cold median was 717.833 → 740.454 ms. These are process/cache-cold measurements, not cold physical storage.
  • The search-enabled sample stopped after about 10 seconds while both indexes were still working; it does not establish completed search timing or total work.
  • Real remote Electron comparison and screenshots were blocked by unsafe resource levels on all available QA hosts. The current head has no green full PR workflow, and GitHub currently reports merge conflicts. The final synchronization with main was deferred because the PR is otherwise not ready. Remote/WSL rendered behavior, review-thread clearance and a clean merge state have not been established.

No broader benchmark or weaker metadata behavior is being added to rescue the result. The earlier bounded-byte performance claims are superseded. Runtime QA, a useful measured result and final conflict/CI validation remain required before this PR can leave draft.

@OrcaWin

OrcaWin commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Closing this implementation under the performance PR guidance: free performance wins, or tradeoffs justified by a substantial benefit.

I reviewed the full production diff at bd6c391adc20ea242a90e73a7a6ee80acf86309b. The corrected reader deliberately starts at byte zero and folds every record, limiting only suffix-preview collection. This preserves metadata correctness, but adds a partial-preview mode, capability negotiation, a cache-schema bump and exact/partial cache upgrade rules, while reducing preview completeness. Bundled clients currently keep the existing exact mode.

The corrected five-run comparison already documented in this PR establishes the tradeoff, rather than merely leaving it unmeasured:

  • Explicit shortened-preview client: 744.278 → 524.113 ms elapsed, but 1074.921 → 1078.874 ms CPU and the same 308,943,713 transcript bytes read.
  • Existing exact client: 717.833 → 740.454 ms elapsed.
  • The earlier bounded-byte/470 ms improvement claims were withdrawn. The author explicitly records that the corrected result failed the agreed usefulness requirement.

Given those costs and that result, this approach does not meet the bar to land. Faster Session History remains a useful objective for a different implementation. This is not a closure for merge conflicts, missing QA or draft status, and the earlier two-window measurements should not be used to justify its client follow-ups.

@OrcaWin OrcaWin closed this Oct 26, 2026
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.

2 participants