Repository navigation
fix(sessions): session cleanup leaves GitHub publication receipts behind for workspace-free sessions - #163833
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 October 4, 2026, 6:20 PM ET / 22:20 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR removes GitHub publication receipts after bulk deletion of workspace-free sessions, checks the original database, and preserves existing single-session settlement paths. Merge readiness✅ Ready for maintainer review This remains a useful fix: current main and v2026.9.8 still omit workspace-free sessions from bulk receipt cleanup. The earlier pinned-database finding is resolved, and no blocking introduced defect was found. Likely related people: steipete, supported by prior merged session and publication work. Priority: P2 Review scores
Verification
How this fits togetherSession cleanup removes conversation state from agent databases. Its shared deletion owner also retires GitHub publication receipts in the shared state database while preserving records for surviving sessions. flowchart TD
A[Cleanup and maintenance callers] --> B[Shared session deletion owner]
B --> C[Capture receipt generations]
B --> D[Delete session state]
D --> E[Check original database or actor]
E --> F{Session remains?}
F -->|Yes| G[Keep receipts]
F -->|No| H[Remove captured receipts and bindings]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +147, Tests +236. Total +383 across 6 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep receipt retirement in the shared deletion flow, using physical database custody and generation-specific selection while preserving commit-aware single-session settlement. Do we have a high-confidence way to reproduce the issue? Yes: a workspace-free session with a publication receipt reaches bulk deletion without entering main's workspace-gated receipt settlement. The supplied isolated CLI before/after run confirms the mechanism; this review did not execute it. Is this the best way to solve the issue? Yes: extending the shared deletion owner reuses the existing receipt selector and covers bulk callers without duplicating single-session commit-aware cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b48245c41428. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
…tes a session Bulk deletions through the shared SQLite deletion owner (sessions cleanup --enforce, maintenance pruning, agent purge, reset, and artifact cleanup) settled personal GitHub receipts only for sessions with a retained repository workspace. The owner now also prepares receipt deletion for workspace-free targets before the delete and settles it after a post-run worker read shows the row gone. Receipt selection is generation-precise, so it needs no source binding. The presence read addresses the database the deletion wrote. The repository-workspace path is unchanged. Single-session lifecycle deletion keeps its own commit-aware receipt settlement (alias keys, same-key successors, pinned database) and opts out via callerSettlesReceipts.
Native-only deletion scopes (schema maintenance, maintenance authority, agent-database cleanup, incognito paths) may not be regular files, so the receipt settlement keeps main's unpinned read there instead of failing the deletion on a file-identity stat.
b6a6716 to
b62aa90
Compare
…ement An actor-less deletion on an incognito database path (or under maintenance authority) has no worker execution, so the receipt settlement fell back to a main-thread open of that database. On an incognito path that claimed the namespace for the native owner and broke the incognito actor. The owner now settles workspace-free receipts only through an incognito actor or a worker read of the pinned file; native-only scopes keep main's behavior.
|
Merged via squash.
|
…ind for workspace-free sessions (openclaw#163833) * fix(sessions): remove personal GitHub receipts when bulk cleanup deletes a session Bulk deletions through the shared SQLite deletion owner (sessions cleanup --enforce, maintenance pruning, agent purge, reset, and artifact cleanup) settled personal GitHub receipts only for sessions with a retained repository workspace. The owner now also prepares receipt deletion for workspace-free targets before the delete and settles it after a post-run worker read shows the row gone. Receipt selection is generation-precise, so it needs no source binding. The presence read addresses the database the deletion wrote. The repository-workspace path is unchanged. Single-session lifecycle deletion keeps its own commit-aware receipt settlement (alias keys, same-key successors, pinned database) and opts out via callerSettlesReceipts. * fix(sessions): read receipt presence from the pinned deletion database * fix(sessions): keep incognito session deletion's own receipt settlement * fix(sessions): pin receipt presence only for worker-executable databases Native-only deletion scopes (schema maintenance, maintenance authority, agent-database cleanup, incognito paths) may not be regular files, so the receipt settlement keeps main's unpinned read there instead of failing the deletion on a file-identity stat. * fix(sessions): leave native-only deletion scopes out of receipt settlement An actor-less deletion on an incognito database path (or under maintenance authority) has no worker execution, so the receipt settlement fell back to a main-thread open of that database. On an incognito path that claimed the namespace for the native owner and broke the incognito actor. The owner now settles workspace-free receipts only through an incognito actor or a worker read of the pinned file; native-only scopes keep main's behavior.
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: #163833
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
What Problem This Solves
Fixes: bulk session cleanup (
openclaw sessions cleanup --store <path> --enforce, and likewise maintenance pruning, agent purge, reset, artifact cleanup, and incognito reclamation) deletes a session but leaves its personal GitHub publication receipt behind when the session has no retained repository workspace.User Impact
User impact: deleting a session now removes its "My GitHub" publication receipts (and their lifecycle sidecars) on every deletion path, not only
sessions.delete/ SDKdeleteSessionEntry/ incognito delete or sessions that still own a repository workspace. Receipts of sessions that survive (failed or aborted deletion, reset, context cut) and of a same-key successor session are kept. No schema, retention, config, or publication-store change.Why This Change Was Made
The shared SQLite deletion owner (
withSqliteSessionDeletionsinsrc/config/sessions/session-accessor.sqlite-deletion.ts) only prepared receipt deletion for targets with a retained repository workspace, so every bulk caller leaked receipts in the common workspace-free case.The owner now hands workspace-free targets to a small companion module,
session-accessor.sqlite-deletion-receipts.ts. That module:The read never rediscovers the logical store alias (ClawSweeper's review finding), so an alias retargeted mid-cleanup can neither leak a deleted session's receipts nor delete a surviving session's receipts. If the pinned database was replaced, settlement fails closed and keeps the receipts. The read does not depend on the agent-DB execution staying current, because cold maintenance closes the database during native preparation. Receipt selection is already generation-precise (historical capture plus session id and lifecycle revision binding), so it needs no absence admission. Native-only scopes (incognito paths without an actor, maintenance authority) are left out of owner receipt settlement and keep main's behavior. A main-thread open there would claim an incognito namespace for the native owner. Incognito actors read presence through the actor. The repository-workspace path is unchanged.
Single-session lifecycle deletion and incognito session deletion already settle receipts right after their known commit, covering alias keys, same-key successors, and pinned databases. Both pass
callerSettlesReceipts: trueso the owner does not settle a second time. Folding everything into one commit-aware settlement is a follow-up once the publication-store worker refactor (#163523) lands; this PR stays out of those files.Evidence
Regression tests live in
src/config/sessions/session-accessor.sqlite-deletion-receipts.test.ts:sessions cleanup --enforceuses), with an unrelated-key control;deleteSessionEntry;cleanupSessionLifecycleArtifactsCoreboundary.Red-before on the same test file (local,
--maxWorkers=1):f0b38eda45fe84d5PR CI on the intermediate head
b62aa90ccaught the incognito-namespace defect:src/state/openclaw-agent-execution-incognito.lifecycle.test.tscascaded with "Incognito namespace already belongs to the native owner". It reproduced locally and is fixed in45fe84d5. Local run on45fe84d5, 9 files / 118 tests passing in 744 s:openclaw-agent-execution-incognito.{lifecycle,history}.test.ts;session-accessor.sqlite-deletion.test.ts;sqlite-prepared-admission(cold maintenance),sqlite-reclamation-admission-race(alias pin),sqlite-archive-session,legacy-main-session-migration.race(opsstore), andgithub-personal-publication.lifecycle(same-key successor).Real entry point, isolated profile/HOME/state with one synthetic session and one synthetic personal receipt:
pnpm openclaw sessions cleanup --store <isolated>/agents/main/sessions/sessions.json --enforce --fix-missing --json. Session / receipt / sidecar went from 1/1/1 to 0/1/1 on base, and from 1/1/1 to 0/0/0 with the fix. On the first PR head, all 67 deletion-owner caller files passed on Blacksmith Testbox (965 tests). Testbox stayed queued for 45+ minutes twice today, so the rebased head relies on the local runs above plus PR CI.Static checks:
pnpm run tsgo:core, type-awarerun-oxlint-shards.mts --only=core(including max-lines), oxfmt, andgit diff --check. Codex autoreview (P0–P2) is clean on45fe84d5.