Skip to content

fix(sessions): session cleanup leaves GitHub publication receipts behind for workspace-free sessions - #163833

Merged
steipete merged 5 commits into
mainfrom
steipete/session-delete-ghpub-receipts
Oct 4, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/session-delete-ghpub-receipts

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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 / SDK deleteSessionEntry / 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 (withSqliteSessionDeletions in src/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:

  • pins the physical database the deletion selected (canonical path and file identity, captured at owner entry);
  • prepares receipt deletion before the delete runs;
  • after the existing repository-workspace cleanup, settles the receipts once a fresh worker read of that pinned database shows the row gone.

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: true so 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:

  • projection cleanup (the path sessions cleanup --enforce uses), with an unrelated-key control;
  • SDK deleteSessionEntry;
  • retention when a deletion aborts before commit or the context resets;
  • two alias-retarget cases through the real cleanupSessionLifecycleArtifactsCore boundary.

Red-before on the same test file (local, --maxWorkers=1):

production code committed alias aborted alias projection cleanup SDK / retention
main f0b38eda ❌ receipt leaks ✅ ❌ receipt leaks ✅
first PR head's alias-based read ❌ receipt leaks ❌ surviving session's receipt deleted ✅ ✅
this head 45fe84d5 ✅ ✅ ✅ ✅
main / committed alias:  AssertionError: expected { receipt: { …(35) }, …(1) } to deeply equal { receipt: undefined, …(1) }
old read / aborted alias: AssertionError: expected { receipt: undefined, …(1) } to deeply equal { receipt: { …(35) }, …(1) }

PR CI on the intermediate head b62aa90c caught the incognito-namespace defect: src/state/openclaw-agent-execution-incognito.lifecycle.test.ts cascaded with "Incognito namespace already belongs to the native owner". It reproduced locally and is fixed in 45fe84d5. Local run on 45fe84d5, 9 files / 118 tests passing in 744 s:

  • openclaw-agent-execution-incognito.{lifecycle,history}.test.ts;
  • the new receipts test and session-accessor.sqlite-deletion.test.ts;
  • the contract suites: sqlite-prepared-admission (cold maintenance), sqlite-reclamation-admission-race (alias pin), sqlite-archive-session, legacy-main-session-migration.race (ops store), and github-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-aware run-oxlint-shards.mts --only=core (including max-lines), oxfmt, and git diff --check. Codex autoreview (P0–P2) is clean on 45fe84d5.

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 6:20 PM ET / 22:20 UTC (Revision 3).

ClawSweeper review

What this changes

The 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
Reviewed head: 45fe84d58f1f79a39b67f4ef1ffd4ab7d1f55151

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported repair with real CLI evidence and meaningful lifecycle regressions; no blocking finding remains.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied isolated sessions-cleanup CLI run exercises the shared deletion owner and observes receipts and sidecars disappear after the fix. Current-head regressions supplement that evidence for alias retargeting, aborted deletion, incognito ownership, and successor preservation. No stored-data model or migration contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied isolated sessions-cleanup CLI run exercises the shared deletion owner and observes receipts and sidecars disappear after the fix. Current-head regressions supplement that evidence for alias retargeting, aborted deletion, incognito ownership, and successor preservation. No stored-data model or migration contract changes.
Evidence reviewed 10 items Pinned introduction: Reviewed the merge-base-to-head delta only. It adds workspace-free receipt settlement and opts the existing durable and incognito single-session owners out of duplicate settlement.
Existing deletion contract: The documented contract preserves personal receipts across archive/reset and removes them and their lifecycle bindings on permanent session deletion.
Still necessary on current main: The fetched main revision still prepares and settles bulk receipt deletion only while iterating repository workspaces; it lacks the new workspace-free path.
Findings None None.
Security None None.

How this fits together

Session 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +147, Tests +236. Total +383 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 156 9 +147
Tests 2 236 0 +236
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 392 9 +383

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +147 lines; tests/support +236 lines The companion module adds physical-source custody and settlement while regression coverage exercises cleanup, abort, reset, and alias behavior.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded session-cleanup leak of local GitHub publication receipts without changing remote publications or user configuration.
  • 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 (live_output): The supplied isolated sessions-cleanup CLI run exercises the shared deletion owner and observes receipts and sidecars disappear after the fix. Current-head regressions supplement that evidence for alias retargeting, aborted deletion, incognito ownership, and successor preservation. No stored-data model or migration contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied isolated sessions-cleanup CLI run exercises the shared deletion owner and observes receipts and sidecars disappear after the fix. Current-head regressions supplement that evidence for alias retargeting, aborted deletion, incognito ownership, and successor preservation. No stored-data model or migration contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-02T22:49:47.667Z sha b6a6716 :: blocked before merge. :: [P2] Read receipt presence from the pinned deletion database
  • reviewed 2026-10-04T21:16:38.903Z sha b62aa90 :: needs maintainer review before merge. :: none

…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.
@steipete
steipete force-pushed the steipete/session-delete-ghpub-receipts branch from b6a6716 to b62aa90 Compare October 4, 2026 21:09
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 4, 2026
…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.
@steipete
steipete merged commit 989bd3f into main Oct 4, 2026
135 checks passed
@steipete
steipete deleted the steipete/session-delete-ghpub-receipts branch October 4, 2026 22:50
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…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.
steipete added a commit that referenced this pull request Oct 10, 2026
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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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