Repository navigation
fix: sessions_yield keeps long transcript history available - #137381
Conversation
Replace SessionManager trailing-entry full rewrites with an exact writer-fenced SQLite suffix mutation that preserves generation and active projection availability. Restore in-memory state when the compare-and-swap loses a concurrent race. Refs yield-transcript-incremental-v2-e0d.
|
Codex review: blocked before merge. Reviewed September 9, 2026, 12:42 AM ET / 04:42 UTC (Revision 150). ClawSweeper reviewWhat this changesReplaces full transcript rewrites during trailing-entry cleanup with fenced SQLite suffix updates, preserves retained metadata, and checks the private session SDK facade only in private-QA builds. Merge readiness⛔ Blocked before merge - 4 items remain The build-profile correction is sound, and the prior public-persist finding remains resolved. Current main mitigates the queued-turn failure, but this PR retains distinct incremental-storage value that the related maintainer discussion explicitly preserves. Priority: P2 Review scores
Verification
How this fits togetherSessionManager maintains the conversation history used by agent turns. Yield cleanup removes temporary trailing entries from SQLite and updates the searchable history and bounded context read by the next turn. flowchart TD
A[Agent yields] --> B[Identify removable transcript tail]
B --> C[Prepare bounded suffix update]
C --> D{Writer and history still current?}
D -->|No| E[Preserve durable and live history]
D -->|Yes| F[Commit rows and projections atomically]
F --> G[Adopt committed live history]
G --> H[Continue next agent turn]
Decision needed
Why: The implementation has meaningful preservation and continuation evidence, but accepting its operating envelope is an explicit repository storage-design decision. Before merge
Agent review detailsSecurityNone. PR surfaceSource +2088, Tests +3113, Other +15. Total +5216 across 37 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep atomic suffix cleanup and the existing handoff wait, with storage-owner-approved recovery behavior and synchronous-work limits. Do we have a high-confidence way to reproduce the issue? No current-main end-to-end failure was reproduced in this read-only review. Current main now waits through the rebuild, while source still shows the full-history replacement that this PR optimizes. Is this the best way to solve the issue? Yes for the latest build correction: it follows the canonical private-QA declaration contract without weakening public checks. The wider storage approach remains subject to acceptance of its documented operating envelope. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8b673f9962a6. LabelsLabel 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 (149 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ript-incremental-v3
|
@clawsweeper re-review exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ript-incremental-v3
|
@clawsweeper re-review exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ript-incremental-v3
|
Merged current Validation on the merged head:
ClawSweeper's preceding exact-head review reported no concrete code finding; storage-owner acceptance of bounded-cleanup refusal recovery and synchronous full-history fallback costs remains the human decision. @clawsweeper re-review exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Keep retained custom data in SQLite while bounded suffix planning repairs its envelope. Preserve atomic payload copying, writer and mutation fences, projection updates, and post-commit live-state adoption without raising planning limits or hydrating the whole transcript. Verified with retained-data regressions, changed-file checks, full builds, and an isolated AWS Gateway continuation/restart proof. Mandatory autoreview could not run because its isolation checks reject the host proxy shape; commit and push were explicitly authorized with that limitation disclosed. Worked on by: - @jalehman Co-authored-by: jalehman <[email protected]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Keep the orchestration plan contract private and let the projection helper return its concrete shape without importing its caller. Replace raw Kysely identifier references with schema-checked expression references, and reuse the aliasable input expression instead of wrapping it in raw SQL. The original Madge cycle was reproduced. The complete architecture gate and recovery suite pass; query comparisons retain identical SQL and bound parameters. No guard exclusions, schema changes, or limit changes. Autoreview remains unavailable due to the disclosed host proxy isolation constraint; this in-scope correction and push were explicitly authorized. Worked on by: - @jalehman Co-authored-by: jalehman <[email protected]>
|
Pushed exact-head repair
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Count compaction and reset boundaries only when adopting an appended entry locally; reloaded bounded views already contain the committed count. Restore rewrite-race and boundary replay tests, original narrow yield handoff limits, and exact retained-state assertions. Repair the bounded no-hydration fixture to target the real transcript database. Remove unused inspection and mutation-receipt plumbing, duplicate reads and ownership predicates, dead scans, and impossible projection branches. Preserve existing concurrency fences, recovery limits, and the public SDK contract; add calls through the packaged SDK consumer check. Validation: 175 affected tests plus follow-up targeted reruns, core/test/ script types, lint, architecture, and the canonical strict SDK build. Autoreview remains unavailable due to proxy-isolation preflight; publication was explicitly requested with that limitation disclosed. Worked on by: - @jalehman Co-authored-by: jalehman <[email protected]>
|
@clawsweeper re-review Please review the new head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
agent-sessions is a private runtime facade whose declarations are only emitted in private-QA builds. The unconditional typed consumer broke the ordinary CI artifact profile with TS7016 and an unused expect-error. Select that consumer using the canonical private-QA build flag. Keep all public-package consumers unconditional and retain the positive persist calls and invalid-entry control whenever the private declarations apply. Do not add declarations, widen public exports, or change typecheck budgets. Reproduced the CI-profile failure locally. The public CI artifact build and private-QA strict build both pass after the fix; selecting private QA against public-only artifacts still rejects the missing declaration. Autoreview remains blocked by the disclosed proxy-isolation preflight. Worked on by: - @jalehman Co-authored-by: jalehman <[email protected]>
|
@clawsweeper re-review Head |
|
🦞🧹 I asked ClawSweeper to review this item again. |
What Problem This Solves
Fixes an issue where
sessions_yieldcleanup on long SQLite-backed sessions temporarily made transcript history and bounded context unavailable while a full transcript replacement rebuilt its projection.Related: #109638
Related: #113190
Why This Change Was Made
Trailing-entry cleanup now performs one exact, writer-fenced SQLite suffix mutation instead of deleting and reinserting the full transcript. It rotates the transcript generation to invalidate stale cursors and repairs the affected identity, active-branch, FTS, watermark, parent, and leaf-control state in the same transaction, while retaining PR #113190's continuable non-assistant-tail behavior.
If the compare-and-swap loses a concurrent write race, both SQLite and the live
SessionManagerremain on the original history.User Impact
Yielded sessions with long histories remain immediately readable and continuable after cleanup instead of entering a projection-rebuild unavailable window.
Evidence
pnpm check:changed— passed on the final patch before rebase; includes core/test typechecks, dead-export scans, lint, import-cycle checks, and repository guardrails.pnpm check:assertion-safety— passed.Changes Walkthrough
src/config/sessions/session-accessor.sqlite-transcript-suffix.tssrc/config/sessions/session-transcript-index.tssrc/config/sessions/session-accessor.sqlite-transcript-write.tssrc/config/sessions/session-accessor.sqlite-transcript-store.tssrc/config/sessions/session-accessor.transcript.tssrc/config/sessions/session-accessor.tssrc/agents/sessions/session-manager-persistence.tssrc/config/sessions/session-accessor.sqlite-transcript-store.test.tssrc/agents/sessions/session-manager.persistence-compat.test.tssrc/agents/sessions/session-manager-bounded.test.tssrc/agents/embedded-agent-runner/run/attempt.sessions-yield.test.tsconfig/assertion-safety-baseline.txtCoordinator session: https://openclaw-fsn1.tailf72dd7.ts.net/chat/main/dashboard/660ed975-cf31-4aee-bb0f-4e7cf9c8edc5
Retained-metadata recovery update
Commit:
68022cdf8d622dab954af0858bb295988b68f1b8Bounded cleanup now keeps retained custom data in SQLite while planning and repairing its envelope. It preserves the existing writer/mutation fences, atomic projection update, and post-commit live-state adoption without increasing planning limits or hydrating the whole transcript.
Verification on the patch-identical committed tree:
Limitations: mandatory autoreview could not start because its isolation checks reject this host's credentialed proxy URL. Commit/push were explicitly requested with that limitation disclosed; no review success or merge approval is claimed. Recovery covers retained loaded custom data, not every bounded-window refusal, and SQLite payload-copy cost remains proportional to retained bytes.
Architecture gate correction
Follow-up:
70a8ece5d7c0549bc558732be46b12a59b2ee053. The projection helper no longer imports its caller's mutation-plan type; the typed dispatcher keeps that contract private. Retained-data queries now use schema-checked Kysely expression references and a common aliasable-expression contract instead of raw identifier shortcuts. No ignore rules, schema, or planning-limit changes.pnpm check:architecturegate now passes locally, including both cycle checks and Kysely guardrails.Autoreview remains unrun for the previously disclosed isolation limitation. This is a correction/push, not a merge.
Audit follow-up and measured operating envelope
Commit:
993c856f042a449b311e446609e7d6980d83a775. This follows and preservesb6232b03e6e's public SDK fix.Validation
Local synchronous-cost probes
Real SessionManager and SQLite; constructed warm datasets on a shared host, three repetitions per scenario. These are not production incidence estimates, Gateway round-trip measurements, controlled before/after speedups, or latency guarantees. Representative medians from the final run:
All 45 constructed trials produced their expected path; targeted row/byte/window refusals preserved raw history and live entries. Keyed-tail cleanup can still perform historical JSON searches for idempotency ownership even without full-row hydration.
A separate default-like 1,024,000-byte bounded-reopen probe with 3/5 MiB retained metadata selected no payload entries: the cleanup target was not loaded, removal returned zero, and raw history remained unchanged. Large-payload cleanup success therefore assumes the relevant payloads are loaded or the read window is sufficient; it is not a universal recovery promise. No global read/planning budget was increased.
Storage-owner acceptance of the remaining refusal/read-window behavior and synchronous cost remains required before merge. Autoreview was attempted again and stopped at the existing proxy-isolation preflight; no successful autoreview or merge approval is claimed. Publication was explicitly requested with that limitation disclosed.
CI build-profile correction
Commit:
449cc4c59d50f95b09b2fa78a79dfac5595c08aa. Fixes thebuild-artifactsfailure on993c856f042without changing transcript runtime behavior.The added consumer incorrectly imported
agent-sessionsas a typed public package subpath in every build. The canonical SDK inventory classifies it as a private runtime facade: normal CI artifacts retain its JavaScript but intentionally omit its declarations. The private-QA build used for the earlier local validation did emit those declarations, masking this profile mismatch.The facade consumer now runs only in the canonical private-QA profile. All public-package consumers remain unconditional. Both valid
persistcalls and the invalid-entry negative control remain in the private declaration check; no declaration shim, public-export promotion, budget change, or check suppression was added.Verification:
pnpm build:ci-artifacts: TS7016 for the private facade and TS2578 for the now-unused negative control.pnpm build:ci-artifactsprofile passes after the correction, including the UI/metadata stages.OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build:strict-smokeprofile passes.The earlier local build evidence was private-QA evidence, not proof that the normal public CI artifact profile passed. Autoreview remains unavailable at the disclosed proxy-isolation preflight. Storage-owner acceptance remains a separate pre-merge decision; this correction does not claim it or request merging.
Worked on by
View the OpenClaw team session