Skip to content

fix(sessions): unblock cold history during unrelated cleanup - #156338

Merged
steipete merged 1 commit into
mainfrom
codex/team-archive-admission-20260923
Sep 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/team-archive-admission-20260923

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening a cold archived conversation can wait for another store's entire archive cleanup, even while that cleanup is only reclaiming SQLite pages.

User Impact

Cold history restoration can proceed between unrelated reclamation units. Archive deletion order, retained data, and database formats stay unchanged.

Why This Change Was Made

The page-reclamation owner now supplies archive-before-writer admission for each removal unit. It retains both permits across the pressure recheck, canonical selection, derived-file removal, and conditional row deletion. The global archive FIFO still protects publication and removal, while page reclamation and filesystem inventory run outside it. This removes the whole-sweep hold and the caller's separate writer wrapper while preserving cancellation and settlement ownership.

Evidence

The real cross-store history regression fails on the original code: history finishes only after the paused unrelated sweep is released. With the fix, the same history read finishes while the sweep remains paused, preserving message IDs, complete transcript bytes, foreground writer progress, retention, and the final disk budget.

35 focused tests passed, including queued retirement, admitted-work settlement, live authority and CAS checks, native maintenance/incognito behavior, physical alias binding, and WAL/close-receipt fencing.

Measured local serial cost (--maxWorkers=1, loaded macOS host):

Changed test file Wrapper wall Test time
session-history-eviction.writer-fairness.test.ts 80.18 s 19.464 s
session-history-archive-pruning.admission.test.ts 178.32 s 112.861 s total; three new cases: 9.004 s

These files exercise real SQLite workers, cold restoration, physical-store identity, and retirement. A queue mock cannot prove those ownership boundaries. Wall time includes imports and worker compilation; it is not a production performance comparison. Exact-head CI run 35835926746 passed. Its verbose test output and job timestamps report:

Changed test file Reported test time Containing CI job elapsed
session-history-eviction.writer-fairness.test.ts 5.210 s (1 test) compact-small-2: 384 s
session-history-archive-pruning.admission.test.ts 27.675 s total (19 tests); three new cases: 2.273 s compact-small-4: 469 s

The test column sums the reporter's individual case durations. The containing-job times include setup, compilation, and other test files; they are not this PR's marginal cost or per-file wall time. These Linux CI measurements and the loaded macOS local measurements are separate environments, not a before/after performance comparison.

Independent managed review found no actionable P0–P2 findings. The full changed-file gate passed, including core and test typechecks, lint, dead-export scans, and storage/authority guards. Production deployment and whole-server CPU improvement are not claimed.

Scope archive admission to each canonical or legacy removal unit while
retaining archive-before-writer ordering and the original lifetime.

Cold restores in other stores can progress between page-reclamation units.
Preserve current authority, conditional deletion, and native settlement.
@clawsweeper

clawsweeper Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review September 23, 2026 08:13
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels Sep 23, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 23, 2026, 5:55 AM ET / 09:55 UTC.

ClawSweeper review

What this changes

The PR lets archived conversation history load between unrelated SQLite cleanup units while keeping each archive deletion serialized and cancellable.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix: current main still holds archive admission across the entire cleanup sweep. The reviewed patch has no blocking correctness findings.

Priority: P2
Reviewed head: 63999efafcb6641a4fb704ac0d63ec289c7d046a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful real-worker boundary evidence and no actionable correctness findings.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied before/after account and inspected production-path harness exercise real chat-history restoration and SQLite workers during an injected cleanup pause, with preserved transcript bytes and observed progress; GitHub confirms the cited jobs passed at this head. Raw log download was blocked by reviewer infrastructure. No stored-data contract changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The supplied before/after account and inspected production-path harness exercise real chat-history restoration and SQLite workers during an injected cleanup pause, with preserved transcript bytes and observed progress; GitHub confirms the cited jobs passed at this head. Raw log download was blocked by reviewer infrastructure. No stored-data contract changes require migration proof.
Evidence reviewed 8 items Pinned change ownership: Inspected the merge-base-to-head changes and original page-reclamation implementation. The verified test merge has the recorded base followed by the exact PR head as parents; unrelated endpoint drift is excluded from this review.
Current main still needs the fix: The page-reclamation file has identical blob identity at the merge base and fetched main. Its worker path wraps the complete sweep in global archive admission, including page reclamation. The earlier merged writer-fairness repair does not resolve this remaining cross-store history wait.
Admission and settlement remain owned: The new removal wrapper acquires archive admission before the physical writer and retains the existing lifetime signal. Canonical removal holds both through pressure measurement, selection, file removal, and conditional row deletion. Page reclamation retains separate writer admission; live execution and physical identity checks remain in place.
Findings None None.
Security None None.

How this fits together

Session storage restores archived transcripts for chat-history requests and reclaims disk space during maintenance. Both operations share archive admission, so cleanup scheduling affects how quickly older conversations open.

flowchart TD
  A[Chat history request] --> B[Cold transcript restoration]
  C[Disk budget cleanup] --> D[Reclaim SQLite pages]
  C --> E[Archive removal unit]
  B --> F[Shared archive queue]
  E --> F
  F --> G[Store writer and authority checks]
  G --> H[Restored history or completed deletion]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +193, Docs +3. Total +199 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 128 125 +3
Tests 2 195 2 +193
Docs 1 11 8 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 334 135 +199

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +3 lines; tests net +193 lines The small production increase centralizes removal admission, while the added coverage exercises cross-store progress, queued retirement, and native ownership.

Technical review

Best possible solution:

Keep cleanup admission scoped to individual removal units while preserving shared FIFO ordering, live authority checks, and settlement before permit release.

Do we have a high-confidence way to reproduce the issue?

Yes: the two-store scenario pauses cleanup after a page unit and requests cold history from the other store; current-main source retains the blocking global permit. This reviewer did not execute the scenario.

Is this the best way to solve the issue?

Yes: moving admission into the existing reclamation owner removes the unnecessary sweep-wide hold while preserving deletion ordering and existing storage contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2dd3b8a589b1.

Labels

Label changes:

  • add P2: This fixes a bounded history-loading delay caused by unrelated archive maintenance without evidence of a broader runtime outage.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied before/after account and inspected production-path harness exercise real chat-history restoration and SQLite workers during an injected cleanup pause, with preserved transcript bytes and observed progress; GitHub confirms the cited jobs passed at this head. Raw log download was blocked by reviewer infrastructure. No stored-data contract changes require migration proof.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The supplied before/after account and inspected production-path harness exercise real chat-history restoration and SQLite workers during an injected cleanup pause, with preserved transcript bytes and observed progress; GitHub confirms the cited jobs passed at this head. Raw log download was blocked by reviewer infrastructure. No stored-data contract changes require migration proof.

Label justifications:

  • P2: This fixes a bounded history-loading delay caused by unrelated archive maintenance without evidence of a broader runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The supplied before/after account and inspected production-path harness exercise real chat-history restoration and SQLite workers during an injected cleanup pause, with preserved transcript bytes and observed progress; GitHub confirms the cited jobs passed at this head. Raw log download was blocked by reviewer infrastructure. No stored-data contract changes require migration proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied before/after account and inspected production-path harness exercise real chat-history restoration and SQLite workers during an injected cleanup pause, with preserved transcript bytes and observed progress; GitHub confirms the cited jobs passed at this head. Raw log download was blocked by reviewer infrastructure. No stored-data contract changes require migration proof.

Evidence

What I checked:

  • Pinned change ownership: Inspected the merge-base-to-head changes and original page-reclamation implementation. The verified test merge has the recorded base followed by the exact PR head as parents; unrelated endpoint drift is excluded from this review. (63999efafcb6)
  • Current main still needs the fix: The page-reclamation file has identical blob identity at the merge base and fetched main. Its worker path wraps the complete sweep in global archive admission, including page reclamation. The earlier merged writer-fairness repair does not resolve this remaining cross-store history wait. (src/config/sessions/session-accessor.sqlite-page-reclamation.ts:239, 2dd3b8a589b1)
  • Admission and settlement remain owned: The new removal wrapper acquires archive admission before the physical writer and retains the existing lifetime signal. Canonical removal holds both through pressure measurement, selection, file removal, and conditional row deletion. Page reclamation retains separate writer admission; live execution and physical identity checks remain in place. (src/config/sessions/session-accessor.sqlite-page-reclamation.ts:93, 63999efafcb6)
  • Production-boundary regression evidence: The inspected fairness scenario calls readChatHistoryPage with a genuinely cold transcript in a separate SQLite store while the real cleanup owner is paused after its first reclamation unit. It checks completion before releasing cleanup, message identities, complete transcript preservation, foreground writer progress, retention, and final disk usage. The captured PR body reports failure before the fix and success afterward on macOS, plus passing Linux CI. (src/config/sessions/session-history-eviction.writer-fairness.test.ts:122, 63999efafcb6)
  • Retirement and forbidden-owner coverage: The admission suite exercises queued retirement with unchanged archive bytes, rejection of another agent's archive, revocation around reads and unlink, changed-publication conditional deletion, and native maintenance/incognito behavior. These scenarios retain real SQLite operations while injecting scheduling boundaries. (src/config/sessions/session-history-archive-pruning.admission.test.ts:148, 63999efafcb6)
  • Exact-head validation and inspection limits: GitHub confirms CI run 35835926746 and both cited test jobs succeeded at the reviewed head. The body distinguishes local and CI test durations from whole-job elapsed time. Detailed log retrieval redirected to a host blocked by this environment; no tests or target code were executed during this read-only review. The checkout remained clean and diff whitespace checks passed. (63999efafcb6)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 7c9f272 into main Sep 23, 2026
273 of 274 checks passed
@steipete
steipete deleted the codex/team-archive-admission-20260923 branch September 23, 2026 10:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
…156338)

Scope archive admission to each canonical or legacy removal unit while
retaining archive-before-writer ordering and the original lifetime.

Cold restores in other stores can progress between page-reclamation units.
Preserve current authority, conditional deletion, and native settlement.
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant