perf(coding-agent): batch saved session catalog - #990
Open
fettpl wants to merge 1 commit into
Open
Conversation
fettpl
marked this pull request as ready for review
August 8, 2026 15:32
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Design
The metadata cache records file identity, size, timestamps, a safe newline offset, rolling session metadata, and bounded opening/old-EOF proofs. A larger file resumes from the cached offset only when identity and both proofs still match. Truncation, same-size rewrites, replacement, proof mismatch, and malformed or unterminated tails use a full scan.
Session files are defined as append-only. The bounded proofs detect header and append-boundary rewrites without rereading the complete prefix; arbitrary same-inode rewrites confined to the middle remain outside that storage contract. Atomic replacements are detected by identity.
If a live file grows during a scan, a verified newline-safe prefix remains visible at its old offset and catches up on the next refresh. Unsafe boundaries retry against the newer file.
The agents view owns a generation-scoped batch scheduler. Superseding refreshes and view shutdown cancel pending timers, while successful and failed terminal responses each publish exactly one final state.
Scaling
For synchronous progressive input, reconciliation counts change from
N + 1to:Time-based flushes keep slow scans progressive. Safe appends read only the appended range plus at most 8 KiB of verification windows instead of rescanning the full file.
Verification
npm run checkNo daemon command, event, response, schema, or protocol behavior changes.
Integration note
Draft PR #959 changes JSONL tail repair in the same
session-manager.tsfile and the coding-agent changelog. The features are complementary: this PR only reads/falls back on malformed tails and does not copy or perform #959's repair. The imports/changelog may need conflict resolution when one branch rebases.Fixes #944
Note
Batch saved-session catalog refreshes with incremental append-only scanning
ProgressiveCatalogBatcherin progressive-catalog-batcher.ts to coalesce per-session updates into bounded flushes (by count and time), reducing redundant agents-view rebuilds.SESSION_LIST_METADATA_CONCURRENCY=16with deterministic output ordering and diagnostics callbacks for bytes read and read mode.dev,ino,birthtimeMs) andctimeMsin addition to size and mtime.Macroscope summarized 4d3a670.