Repository navigation
refactor(sessions): settle GitHub receipts on session deletion in one owner - #168363
Conversation
Keep receipt preparation and settlement in the SQLite deletion owner and its receipts module. Lifecycle callers declare the exact session generations and report their commit through the owner's one-shot settlement callback. Preserve generation-precise successor protection, pinned presence settlement, and repository-workspace absence admission. Let incognito maintenance use the actor-backed presence path so it removes receipts for deleted sessions.
|
🦞👀 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. What this changesThis PR centralizes session-deletion receipt settlement and enables receipt cleanup during incognito maintenance. Example: Maintenance prunes agent:main:dashboard:incognito-maintenance-receipt with session ID cleanup-session and lifecycle revision generation-1.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides useful, focused work that current main still needs: it consolidates receipt settlement and fixes the inactive incognito maintenance path without an identified introduced defect. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSession lifecycle and maintenance callers delete agent session state through the shared SQLite deletion owner, which also settles related GitHub publication records in the shared state database. flowchart TD
A[Lifecycle and maintenance callers] --> B[Shared deletion owner]
B --> C[Capture receipt identities and generations]
B --> D[Commit session deletion]
D --> E[Commit report or pinned presence check]
C --> F[Shared state receipt writer]
E --> F
F --> G[Remove eligible receipts and bindings]
Technical reviewBest possible solution: Keep receipt preparation in the shared deletion owner while preserving explicit commit settlement and pinned presence settlement. Do we have a high-confidence way to reproduce the issue? Current main visibly disables owner receipt settlement for incognito maintenance without a replacement, and the added production-owner regression targets that exact path; no tests were run during this read-only review. Is this the best way to solve the issue? The change addresses the bypass at the shared owner, removes duplicate caller preparation, and retains the existing generation, physical-database, and post-commit contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5554f7c81ff6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +30, Tests +38. Total +68 across 6 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 10, 2026, 5:25 AM ET / 09:25 UTC. |
|
CI attribution for head CI run 38041039715 has two inherited failures:
The CI fail-fast monitor cancelled 19 other jobs; that coverage remains unrun. Using the authorized native inherited-failure exception with the completed candidate proof already recorded above. No CI rerun or source change was made. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Deleting a session previously settled personal GitHub publication receipts in three places. Lifecycle and incognito deletion prepared and settled their own receipts while disabling the shared SQLite deletion owner. Incognito maintenance also disabled the owner but never settled receipts, leaving them behind. Make the SQLite deletion owner the only place that prepares and settles receipts. Single-session callers declare the exact removed generations and report their committed deletion through the owner's one-shot settlement callback. Preserve same-key successor protection, caller assertion and error contracts, and bulk deletion's pinned presence checks. Remove callerSettlesReceipts and duplicate caller preparation so the upcoming per-session actor has one deletion entry point. Regular session behavior stays the same; incognito maintenance now removes receipts for the sessions it prunes. Incognito acquisition remains inactive in production builds. Validation: isolated source-built Gateway sessions.create/sessions.delete receipt removal with a retained-session control; 63 key contract tests; 159 passing caller-inventory files; regression fails before and passes after; changed checks, core types, oxlint and autoreview clean. ClawSweeper completed with no actionable findings. Hosted CI retained two inherited failures in unchanged dashboard UI and migration-guard inputs, with 19 collateral cancelled jobs, under the native inherited-failure exception. See the PR CI attribution for exact run and main baseline links. Related: openclaw#163833
Related: #163833
What Problem This Solves
Deleting a session removes its personal GitHub publication receipts, but three separate code paths did that work: the shared SQLite deletion owner, single-session lifecycle deletion (Gateway
sessions.deleteand the SDK'sdeleteSessionEntry), and incognito session deletion. The two single-session paths captured and settled receipts themselves after their own commit and switched the owner off withcallerSettlesReceipts. Incognito maintenance passed the same flag without settling anything, so it never cleaned up receipts at all.User Impact
No user-visible change for regular sessions: the same receipts are removed and the same ones are kept. Incognito maintenance now removes receipts for the sessions it prunes, matching incognito reclaim. Incognito acquisition is still inactive in production builds.
Why This Change Was Made
The SQLite deletion owner (
withSqliteSessionMutationswithsession-accessor.sqlite-deletion-receipts.ts) is now the only code that prepares and settles session receipts. Callers state what they delete and when it committed:receiptsOnCommit.generations: alias store keys, snapshot keys and agent, unchanged from before. After their known commit they call the owner's one-shotsettleReceipts(assertCurrent).callerSettlesReceiptsand both callers' directpreparePersonalGitHubSessionReceiptDeletioncalls are gone.This gives the upcoming per-session actor one deletion entry point to call into. Production LOC is +175/−145, test LOC +38. The deletion owner itself is two lines smaller.
Evidence
sessions.create, seeded one personal publication receipt for each, then calledsessions.deleteover RPC for one of them. Afterwards the deleted session's receipt row was gone and the control session's receipt remained (deleted: true;github_personal_publication_requestsread withsqlite3before and after).github-personal-publication.lifecycle.test.ts(same-key successor),session-accessor.sqlite-reclamation-admission-race.test.ts(alias retarget),session-accessor.sqlite-archive-session.test.ts(error messages),session-accessor.sqlite-prepared-admission.test.ts(cold maintenance),legacy-main-session-migration.race.test.ts, andsession-accessor.sqlite-deletion-receipts.test.ts. That is 63 tests across 6 files.src/config/sessions,src/gateway,src/state,src/commands,src/plugin-sdkandextensionsthat reaches the deletion owner, lifecycle or incognito deletion, maintenance,sessions.deleteor receipt preparation, plus everysrc/state/*incognito*test. 161 files, each run aspnpm test <file> --maxWorkers=1on Blacksmith Testbox and Hetzner Crabbox: 159 pass. Two failures are inherited:gateway-codex-harness.live.test.ts: excluded by the default runner on both sides ("No test files found").openclaw-agent-execution-incognito.memory.test.ts: stale Active Memory status text on this branch's base, already fixed onmainby fix(test): expect Active Memory status diagnostics in incognito #168182. All 11 tests pass on currentmain.main(the receipt remains) and passes here.pnpm test src/config/sessions/session-accessor.sqlite-deletion-receipts.test.ts --maxWorkers=1: 40 s locally for the whole file, 31 s on Crabbox. The new case uses no real timers.pnpm check:changed, coretsgoshards, oxlint on changed files, and Codex autoreview are clean.