refactor: add compact trim lifecycle seam#93695
Conversation
2f5c278 to
7504f0e
Compare
7504f0e to
1877d0f
Compare
|
Codex review: needs maintainer review before merge. Reviewed June 17, 2026, 4:11 PM ET / 20:11 UTC. Summary PR surface: Source +230, Tests +192, Other +27. Total +449 across 6 files. Reproducibility: not applicable. this is a planned internal refactor, not a bug report. Source comparison and the PR's focused tests cover the behavior-neutral manual trim path. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this as a focused Path 3 accessor-seam slice only after maintainer session-state review confirms the backend transaction contract and exact-head checks stay green. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a planned internal refactor, not a bug report. Source comparison and the PR's focused tests cover the behavior-neutral manual trim path. Is this the best way to solve the issue? Yes: moving tail selection, archive/rewrite, and stale token metadata cleanup behind AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5304a5b871ba. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +230, Tests +192, Other +27. Total +449 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
* clawdbot-d02.1.9.1.32: add compact trim lifecycle seam * fix: repair session compact type narrowing
* clawdbot-d02.1.9.1.32: add compact trim lifecycle seam * fix: repair session compact type narrowing
What
Adds a storage-neutral accessor operation for manual
sessions.compacttranscript trimming. The gateway now calls one operation for transcript tail selection,.bakarchive/rewrite, and stale token metadata cleanup.Why
Path 3 needs SQLite to trim transcript rows and update
session_entries.entry_jsonmetadata in one backend transaction, rather than composing transcript artifact mutation and entry metadata writes in the gateway.Changes
SQLite follow-up
The SQLite adapter should implement
trimSessionTranscriptForManualCompactas one transaction: select/copy/delete transcript rows through the trim boundary and update entry JSON token/updated fields together. No SQLite schema or runtime storage flip is included here.Testing
/Users/phaedrus/Projects/clawdbot/node_modules/.bin/oxfmt --check --threads=1 scripts/check-session-accessor-boundary.mjs test/scripts/check-session-accessor-boundary.test.ts src/config/sessions/session-accessor.ts src/config/sessions/session-accessor.test.ts src/gateway/server-methods/sessions.ts src/gateway/server.sessions.list-changed.test.tsnode scripts/run-vitest.mjs src/config/sessions/session-accessor.test.ts src/gateway/server.sessions.list-changed.test.ts test/scripts/check-session-accessor-boundary.test.tsnode scripts/check-session-accessor-boundary.mjsgit diff --check.agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/mainTracker: #88838
Real behavior proof
Behavior addressed: Manual
sessions.compactwithmaxLinestrims the selected session transcript through the accessor seam, archives the original transcript, and clears stale token/context metadata.Real environment tested: Local live LaunchAgent gateway from
clawdbot, built from PR head1877d0f48e489ee6ec6a798f2d780eaf65c17112;pnpm openclaw --versionreportedOpenClaw 2026.6.8 (1877d0f). HTTP/healthzreturned{"ok":true,"status":"live"}; HTTP/readyzreturned{"ready":true,"failing":[]};gateway status --jsonreported RPCok: trueand gateway version2026.6.8.Exact steps or command run after this patch:
Evidence after fix:
sessions.compactreturnedok: true,compacted: true,kept: 2, and archive98ea11ca-b9f3-4d0b-a108-3683544b9a3c.jsonl.bak.2026-06-17T18-36-31.559Zfor keyagent:main:dashboard:911bdccc-ddc6-4350-8d0c-200bf2c35bf9. On disk, the active transcript contained onlypr93695-created-line-3andpr93695-created-line-4; the archive contained 4 original lines; the session store entry no longer hadinputTokens,outputTokens,totalTokens,totalTokensFresh, orcontextBudgetStatus;updatedAtchanged to1781721391567. Cleanup deleted the proof session and a final artifact scan returnedleftovers: [].Observed result after fix: The live gateway preserved the previous manual compact response shape while moving transcript tail selection, archive/rewrite, and stale token metadata cleanup behind the session accessor boundary.
What was not tested: Future SQLite adapter implementation, SQLite transactionality, doctor migration, SDK compatibility, broad CI completion after later
mainmovement, and live gateway behavior on a post-1877d0frebased head.