Skip to content

refactor(sessions): settle GitHub receipts on session deletion in one owner - #168363

Merged
steipete merged 1 commit into
mainfrom
steipete/ghpub-receipt-owner
Oct 10, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/ghpub-receipt-owner

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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.delete and the SDK's deleteSessionEntry), and incognito session deletion. The two single-session paths captured and settled receipts themselves after their own commit and switched the owner off with callerSettlesReceipts. 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 (withSqliteSessionMutations with session-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:

  • Lifecycle and incognito deletion declare the exact generations they remove in receiptsOnCommit.generations: alias store keys, snapshot keys and agent, unchanged from before. After their known commit they call the owner's one-shot settleReceipts(assertCurrent).
  • In this commit-reported mode the owner captures receipts before the delete and settles them only when the caller reports the commit, using only the caller's assertion. It never falls back to a presence check. That preserves same-key successor protection and the failure-path error contracts.
  • Bulk deletion keeps presence-based settlement against the pinned database or incognito actor, exactly as before. The repository-workspace path is unchanged.
  • callerSettlesReceipts and both callers' direct preparePersonalGitHubSessionReceiptDeletion calls 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

  • Live Gateway, isolated state, source build: created two sessions through sessions.create, seeded one personal publication receipt for each, then called sessions.delete over 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_requests read with sqlite3 before and after).
  • Contracts that broke earlier designs, all passing unmodified: 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, and session-accessor.sqlite-deletion-receipts.test.ts. That is 63 tests across 6 files.
  • Caller inventory: every test file under src/config/sessions, src/gateway, src/state, src/commands, src/plugin-sdk and extensions that reaches the deletion owner, lifecycle or incognito deletion, maintenance, sessions.delete or receipt preparation, plus every src/state/*incognito* test. 161 files, each run as pnpm test <file> --maxWorkers=1 on Blacksmith Testbox and Hetzner Crabbox: 159 pass. Two failures are inherited:
  • New regression: "removes a deleted incognito session's personal receipt during maintenance" fails on 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, core tsgo shards, oxlint on changed files, and Codex autoreview are clean.

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.
@clawsweeper

clawsweeper Bot commented Oct 10, 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.

@steipete
steipete marked this pull request as ready for review October 10, 2026 09:20
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

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

  • Before: The session disappears, but its personal GitHub publication receipt and lifecycle binding remain.
  • After: Maintenance removes the session, receipt, and lifecycle binding.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent correction with supplied Gateway observations and meaningful boundary coverage; source inspection found no blocking defect, and the stored format and selector remain unchanged.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied isolated Gateway observation exercises the changed deletion owner through sessions.delete and records receipt removal with a retained-session control; the inactive maintenance correction is additionally covered through the real actor and maintenance owner by a reported red-before/green-after regression.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Incognito maintenance can remove a session while leaving its local GitHub publication receipt behind.
Reason: The concrete cleanup correction accompanies a previously anticipated consolidation of existing behavior, with no new public surface.

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
Reviewed head: bb2aa18c96d5103ea6234749d36267884a7a0f3b

Before merge

None.

Findings

None.

Agent review details

How this fits together

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

Technical review

Best 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

  • Workspace-free receipt capture and pinned presence settlement keeps the original intent (989bd3f: Remove receipts after bulk session deletion while preserving surviving sessions and physical-database custody; commit-aware consolidation was explicitly deferred.)
  • Per-agent receipt batching keeps the original intent (c1ccd1d: Avoid repeated receipt preparation and target scans during large repairs while retaining generation and pinned-source checks.)
  • Commit-aware lifecycle receipt deletion keeps the original intent (26dffe7: Delete historical and late old-generation receipts while preserving recreated-session receipts.)
  • Incognito maintenance receipt bypass changes intended behavior with a stated reason (65365c8: Compose maintenance through the explicitly bound inactive actor path; the added bypass did not provide replacement receipt settlement.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 989bd3f adds src/config/sessions/session-accessor.sqlite-deletion-receipts.ts:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 989bd3f055fa; files: src/config/sessions/session-accessor.sqlite-deletion-receipts.ts)

PR surface

Source +30, Tests +38. Total +68 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 175 145 +30
Tests 1 38 0 +38
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 213 145 +68

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +175/-145 lines; tests +38 lines The net production growth expresses two existing settlement modes centrally; the focused regression covers the previously bypassed incognito maintenance boundary.

Labels

Label changes:

  • add P2: This is a bounded receipt-cleanup correction and ownership consolidation; production incognito acquisition remains inactive.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This is a bounded receipt-cleanup correction and ownership consolidation; production incognito acquisition remains inactive.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 10, 2026, 5:25 AM ET / 09:25 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

CI attribution for head bb2aa18c96d5103ea6234749d36267884a7a0f3b:

CI run 38041039715 has two inherited failures:

  • checks-ui-e2e (1/2): the dashboard cases “shows a bounded visible outcome when a Canvas dashboard pin fails” and “pins an inline MCP App using only its session-bound view identity” time out because chat-gutter-stack intercepts the pin button's pointer events. These use a mocked Gateway; the UI and imported package, plugin, and sandbox inputs are identical to the tested main baseline.
  • check-guards-architecture: Kysely guardrail violations in src/commands/doctor-migration-preservation.ts and src/state/openclaw-migration-witness.ts. Both modules and the static guard are identical to the tested main baseline.

The CI fail-fast monitor cancelled 19 other jobs; that coverage remains unrun. security-fast passed. The tested merge is 07ed84a95a9a52a789a751d1fde0d9c5bad789c4, with main parent afafe747c340cd0b400e2f86b5549ad8fbfbbccd (main push run). That main push ran its normal push checks; it is not a reproduction of these full lanes. The inherited attribution is based on unchanged failing inputs and independence from this PR's six session-deletion files.

Using the authorized native inherited-failure exception with the completed candidate proof already recorded above. No CI rerun or source change was made.

@steipete
steipete merged commit a466986 into main Oct 10, 2026
175 of 198 checks passed
@steipete
steipete deleted the steipete/ghpub-receipt-owner branch October 10, 2026 09:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

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