Repository navigation
fix(sessions): cancel revoked restores and bound rebuild checks - #149333
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 2:48 PM ET / 18:48 UTC. ClawSweeper reviewWhat this changesThe PR prevents revoked history reads from restoring archived transcripts and bounds the synchronous work used to decide whether transcript indexes need rebuilding. Merge readiness✅ Ready for maintainer review This remains a useful, focused repair: inspected main still lacks both changes, and the related merged PRs do not supersede them. No blocking correctness defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s history reader restores archived transcripts before returning conversation history from SQLite. Database lifecycle ownership governs restoration, while the transcript index owner decides whether rebuilding can run synchronously. flowchart TD
A[History request] --> B[Database lifecycle owner]
B --> C[Queued archive restoration]
C --> D{Authority still current?}
D -->|Yes| E[Commit restoration and read history]
D -->|No| F[Reject and preserve stored rows]
G[Transcript changes] --> H[Bounded index rebuild check]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +21, Tests +173, Docs +2. Total +196 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep restoration under the existing database lifecycle and native commit owners, with bounded preflight queries that preserve transcript bytes and rebuild thresholds. Do we have a high-confidence way to reproduce the issue? Yes: source and the added regression scenarios identify how a paused history read can restore after database retirement and how oversized transcripts trigger unbounded sizing. This review did not execute those scenarios. Is this the best way to solve the issue? Yes: threading the existing owner assertion into the established commit guard fixes the missing check without creating another authority owner, and the limited subquery preserves existing rebuild decisions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e7dde047904e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Related: #148972, #148918
What Problem This Solves
A history read could restore cold transcript rows after its database closed and then reject the result as revoked. Rebuild checks also scanned entire oversized transcripts before deciding to defer the rebuild.
User Impact
Revoked history reads leave replacement database contents intact. Large transcripts spend less synchronous work on rebuild preflight. Existing row/byte thresholds, transcript contents, reader snapshots, and native mutation settlement remain unchanged; no schema or configuration migration is needed.
Why This Change Was Made
Carry the existing history owner's live authority through cold-restoration queue waits and into the existing native commit guard. Bound stored-event sizing to the remaining 4,000-row budget plus one, preserving SQLite's ability to read byte lengths without loading overflow payloads. Reconciliation reuses its newest-sequence observation, and both entry points share the same query and comparison helpers.
Evidence
Three regression paths failed before the repair: a history read paused before restoration or inside its cold queue restored rows into a replacement database despite rejecting as revoked; a native commit-boundary test also ignored caller revocation. All now preserve the cold descriptor and canonical rows. Two row-budget cases failed with 8,000 size evaluations rather than their 4,001/4,000 bounds and now pass.
The five focused session/history files passed 75 cases. After the final query-helper cleanup, all 40 affected index/search cases passed again. Complete changed-file checks and independent P0–P2 review passed.
Warm, alternating measurements use the actual exported owners with synthetic in-memory SQLite on Node 26.8.2 / SQLite 3.53.4. The measured source is hashed before and after the run. These are component timings, not end-to-end Gateway latency.
The million-event check sizes 4,001 rows instead of 1,000,000. The bounded subquery adds about 0.06 ms at the existing 4,000-row threshold. Clean reconciliation executes three selections instead of four. All measured decisions match the original implementation, and the UTF-8/overflow-page regression coverage remains passing.
Required hosted CI passed for
3b2ab0884f33d4a52724169cce5f3c2b5cba5987: run 35008571258. ClawSweeper also reviewed that exact head without findings. The run waited for larger runners but completed without a CI rerun or cancellation request.