Repository navigation
perf(gateway): fold session touched-files incrementally via transcript delta - #114401
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 3:39 AM ET / 07:39 UTC. ClawSweeper reviewWhat this changesThis PR changes the gateway’s session-files API to retain a bounded per-session touched-file fold and advance it from SQLite transcript deltas instead of rescanning the complete transcript on every Files-panel request. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep this PR open. Its stated target is a real gateway-performance regression, and the branch has a plausible bounded-cache design with focused contract tests, but it still lacks reviewed after-fix evidence from a representative long-running SQLite session; the existing Priority: P1 Review scores
Verification
How this fits togetherThe Control UI Files panel calls the gateway for files referenced by an agent session. The gateway resolves the canonical session transcript, folds tool-call paths into a response, and returns that derived file list to the UI. flowchart LR
A[Control UI Files panel] --> B[Gateway session-files API]
B --> C[Canonical session transcript]
C --> D[SQLite transcript delta reader]
D --> E[Incremental touched-file fold]
E --> F[Bounded process cache]
F --> G[Files list response]
Decision needed
Why: The source path intentionally trades process-local retained state for lower gateway latency; tests describe its invariants, but the cache size and operational result need the owner’s judgment after live evidence. Before merge
Agent review detailsSecurityNone. PR surfaceSource +226, Tests +146. Total +372 across 5 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the canonical SQLite-delta implementation, add redacted after-fix runtime evidence from a representative long-running session that shows both the returned files and materially improved repeated-request timing, then let the owning gateway reviewer decide whether the bounded cache limits are appropriate. Do we have a high-confidence way to reproduce the issue? No high-confidence current-main live reproduction was established in this read-only review. The current-main full-visitor path and the PR’s pre-fix production measurements make the scaling problem source-reproducible, but the supplied record does not include a repeatable representative session fixture or after-fix run. Is this the best way to solve the issue? Unclear: incrementally folding the canonical SQLite transcript delta is the narrowest apparent fix because it removes the repeated full scan, but live proof is still needed to confirm that the delta contract preserves complete Files-panel results under realistic history size and resets. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d4ed57bc8847. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…t delta (openclaw#114401) * perf(gateway): fold session touched-files incrementally via transcript delta * refactor(gateway): keep session touched-files fold on the canonical sqlite path * test(gateway): split session files transcript-fold coverage * test(gateway): drop unused session-files test-support exports
What Problem This Solves
sessions.files.liston production (team.openclaw.ai) averaged 4.7s with tails to 78s. Every request ran a full transcript scan — reading andJSON.parseing every message event from SQLite, synchronously — to rebuild the touched-files list. On long-running agent sessions (tens of thousands of messages) each Files-panel open burned seconds of CPU and blocked the gateway event loop, inflating latency of unrelated methods; journal analysis showssessions.list/sessions.catalog.listspikes clustering exactly around Files-panel usage windows.Why This Change Was Made
Request latency must not scale with transcript size. The transcript store already exposes an append-stable paged read (
readSessionTranscriptVisibleMessageDelta) with an opaque continuation cursor and a rewrite-generation reset signal — exactly the seam an incremental fold needs. This PR folds touched files incrementally: a bounded (16-entry LRU, keyed agent + session + store) process-local cache stores the fold and its cursor; each request consumes only messages appended since the last fold. A deltareset(rewrite/branch switch) discards and refolds;missingclears. Entry-scoped reads always resolve to the canonical SQLite marker, so the old full-visitor call at this call site is deleted rather than kept as a fallback (legacy transcript files are doctor-owned migration debt, not a runtime read path).User Impact
Files panel opens in milliseconds after first fold instead of multi-second (worst-case 78s) stalls, and unrelated Control UI requests stop spiking while it loads. No response-shape or behavior change.
Evidence
sessions.files.listn=46, avg 4722ms, max 78s pre-fix; slow-neighbor correlation documented in fix(gateway): stop fabricating assistant agent id "main" before roster resolution #114257 (comment)node scripts/run-vitest.mjs src/gateway/server-methods/sessions-files.test.ts— 39/39 passing, with new regressions: incremental fold after cached cursor, reset rebuild, cross-store cache isolation, aggregation paritySibling note:
artifacts.listand MCP app reconstruction still use full transcript visitation but are cold in production (n=13, avg 79ms); left for a follow-up if they heat up.