Skip to content

fix(storage): publish sandbox, worktree, and GitHub authority receipts - #168025

Merged
steipete merged 7 commits into
mainfrom
dbasync/sw4b
Oct 10, 2026
Merged

steipete merged 7 commits into
mainfrom
dbasync/sw4b

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Sandbox, worktree, and GitHub publication mutations did not consistently publish their committed authority facts. Worker acknowledgments and shared lifecycle notifications could omit the changed rows, private publication transitions, or deletion tombstones.

User Impact

Internal correctness foundation; no public API, schema, stored-byte, retention, or permission change. Existing dispatch, cleanup, and publication guards remain in place. Confirmed commits survive ordinary reply loss without replaying the write.

Why This Change Was Made

The existing owners capture exact postimages or tombstones from already-selected rows or RETURNING, using the shared postcommit contract to install all facts before observers. Pending worker writes remain fenced through native settlement, and newer native publications supersede late receipts. Publication facts retain content digests without materializing title/body/next-action text; oversized worktree receipts preserve commit evidence and distinguish an unavailable recovery result.

Other processes must route writes through the Gateway or hold offline custody while it is stopped. This change adds no foreign-commit probes or schema checks.

Writer coverage and retained boundaries
Family Covered typed writers
Sandbox Container/browser update, reserve, complete, begin removal, exact generation removal, cleanup, and insert-if-missing import; exact registry generation, backend, workspace/config, activity, and state facts.
Worktree Insert/update/delete, retirement and cleanup deferral, offline discard/path rewrite, run-lease admission/release, stale-lease pruning, removal claim/abort/finalize, and synchronous process-exit release. Existing run-end tokens remain intact.
Shared publication Request plus lifecycle insertion, claim, workspace snapshot/accepted-claim binding, publishing facts, completion, defer, and reporting.
Personal publication Request plus lifecycle insertion, claim, head/effect/complete/interrupt closures, restart confirmation, reporting, and worker request/lifecycle deletion.
Repository publication Insert, checkpoint binding, preparation failure, claim, head/effect/complete/interrupt closures, stale failure, deferred claims, reporting, and worker deletion. Private rows publish facts without expanding shared UI notifications.

Exact typed row deltas do not certify arbitrary raw SQL, trigger/cascade effects, unmanaged transactions, or generic lease writers. Complete sandbox runtime-ID and protecting session/placement sets, worktree provisioned-chunk/pending/template facts, and personal credential-selection/profile-merge publication remain incomplete or with their existing owners and validators. No final guard is removed; no cross-store exclusion or native-to-worker migration is claimed.

Evidence

  • Node 26.10.0: 47 owner tests passed across 8 files; one-worker combined command wall time 409.57 s. Follow-up boundary checks passed after the claim-type, portable oversize fixture, and export cleanup.
  • Bun 1.4.2: receipt ordering, late native supersession, real worker reply loss, lifecycle cleanup, and oversized receipt/result boundaries passed. Bun deduplicates identical strings, so the oversize fixture uses distinct stored JSON and decoded data to exercise the actual limit.
  • All selected changed-file gates passed, including core and all core-test typecheck lanes, targeted lint, Knip's production/full-tree/scripts export scans, import cycles, database-worker/line/assertion/test ratchets, and generated inventory. The pipeline's type/lint/dead-export findings were fixed and the remaining gates completed; no inherited failures are waived.
  • Three scoped Codex review rounds; the full second review and final correction review were clean at P0–P2. The size finding from round one is fixed and regression-tested.
  • SDK export check passed. API/source-root comparison has no direct export or entrypoint changes; 148 reachable hashes change solely because of claim-row declaration property ordering and making the unused internal WORKTREE_RECORD_COLUMNS export private. No SDK migration is required.
  • Actual native owner operations, 10 repetitions each: baseline/candidate statement counts match exactly. Sandbox update 7.4, remove 6; worktree insert 6, update 7, delete 8; publication insert 13, claim 11, defer 6, report 8. Transaction and admission statements are included. SQL shapes differ only in terminal RETURNING projections.
  • Source inventory at baseline and candidate is identical: 616 files / 2,420 counted call expressions, with T1 707, T2 386, T3 243, and W 1,084. No SQL-count reduction or guard retirement is claimed.

Production delta: +1,257 / −228 lines. Tests: +515 / −28. Docs: +79 / −48. The new per-family code supplies capture, exact-key installation, pending/settlement handling, and supersession through the shared receipt primitives.

Focused test execution costs

The one-worker Node owner command took 409.57 s including compilation/import and cleanup. Per-file summed test execution times were: sandbox registry 57.59 s; worktree registry-publication 0.28 s, migration 6.76 s, run-end worker 19.70 s, run-lease store 4.33 s; GitHub personal lifecycle 80.78 s, shared events 13.15 s, and SQLite materialization 4.35 s. The slow existing sandbox/lifecycle fixtures exercise actual worker admission, native settlement, and deletion authority; helper-only tests cannot replace those boundaries. CI seconds are pending the PR run.

All three baseline negative controls fail on unchanged producer kernels for missing facts (empty sandbox/worktree observer maps and undefined publication request/lifecycle facts), and pass with the candidate producers.

Shared workload, attribution, and statement-gate disposition

Isolated Testbox proof, provider blacksmith-testbox, lease tbx_01m4heemayve5bb5cqynwvex9k: three alternating baseline/candidate pairs, with CPU-idle preflight, synthetic provider, source-map instrumentation, exact source/file hashes, and successful workload receipts. Baseline 31c35d5f5b093b7f84e7fbd1a6107f8b17454b67; candidate 784c73666007b9112ae2bcb4bb9ebcfe37690272. Lease stopped and verified completed.

Phase MAIN baseline → candidate All threads baseline → candidate Worker requests Envelopes Duration ratio
01.boot 1984 → 1984 3320 → 3320 67 → 67 4 → 4 1.061
01.connect 69 → 73 489 → 488 72 → 72 7 → 7 1.008
02.first-turn 59 → 55 1806 → 1799 263 → 264 26 → 26 1.075
03.warmed-mean 8.4 → 8.4 1035.3 → 1059.4 195.2 → 196.4 20.6 → 20.6 1.040
04.second-session 120 → 121 4132 → 4089 666 → 686 66 → 68 1.006
05.control-plane 33 → 0 427 → 34 74 → 5 0 → 0 0.997
06.cron 44 → 44 1203 → 1204 173 → 173 16 → 16 1.005
07.compaction 25 → 25 404 → 404 83 → 83 13 → 13 0.963
08.shutdown 129 → 129 195 → 195 14 → 14 9 → 9 0.942

Raw warmed median is red: 1,035.3 → 1,059.4 statements/turn (+24.1, +2.33%); it is not represented as a raw gate pass. First-turn median decreases 1,806 → 1,799; every duration ratio is ≤1.5. Applying the same-statements-per-operation allowance for this internal receipt-owner refactor: all nine changed operations are statement-neutral, their SQL shapes differ only in terminal RETURNING projections, and all six remote strict-window traces contain zero changed-owner SQL, zero receipt-installer request stacks, and zero sandboxRegistry/worktrees/githubPublication commands. No new PR-caused hot requests were found.

Warmed excess, per turn Delta Attribution
database.prepareWrite +19.4 Unchanged session-entry patch admission → execution preparation → agent registration settlement; native identity/schema readmission.
session-row-facts +2.6 Unchanged row reader.
session.maintenance.read +2.0 Unchanged maintenance reader.
session.entry.read +1.3 Unchanged entry reader.
sessionRows.sharedFacts +0.8 Unchanged shared-facts reader.
session.entry.patch.commit +0.6 Unchanged entry writer.
Other unchanged groups, net −2.6 Includes fewer turn-commit and helper auth-profile statements.
Total +24.1 MAIN median is unchanged at 8.4/turn; excess is worker admission/read variance.

Each of the six isolated runs recorded one rejected database is locked statement during connect on both baseline and candidate; all workload receipts still completed. Failed executions are recorded separately from successful-statement totals.

The retained async stack ends at the writer queue, so this is attributed to unchanged admission variance rather than claiming a proven timer origin. The shared workload does not demonstrate a speedup. Seven earlier shared-host macOS pairs also passed their workload receipts but had higher raw strict-window medians (first 2,169 → 2,300; warmed 1,061.6 → 1,088.8); those results are retained, not discarded as passing evidence. The isolated run followed a wrapper staging stall before upload and an expired idle lease; the successful native route fetched and independently hash-verified both exact commits.

Published-driver × candidate update cell: passed on dbc76f2eaf7aaa89920aa4fb6edb4df0e36ac2c6, using published 2026.9.9; completed in 268.52 seconds with phase finished and readiness HTTP 200. Receipt changes are process-local; the installed updater needs no migration.

Landing corrections

The wrapper extraction inventory now includes both new registry-publication modules. This fixes the five import-closure failures in the initial CI run; all 17 tests in test/scripts/eager-import-closure.test.ts passed locally in 140.06 seconds.

The existing lost-admission-reply cases now verify recovery of a completed native receipt: the exact worktree ID and token survive pending cleanup, the Git guard stays live until release, and incumbent ownership remains intact. Unknown settlement still rejects and retains custody. All 23 tests passed with pnpm test src/agents/worktrees/run-lease.test.ts --maxWorkers=1 in 170.43 seconds; targeted lint and formatting passed. Both corrections received scoped independent review with no P0/P1 findings. Pre-conflict head CI passed in 451 seconds elapsed.

The required single alternating baseline/candidate pair passed on pre-conflict head dbc76f2eaf7aaa89920aa4fb6edb4df0e36ac2c6 against baseline 31c35d5f5b093b7f84e7fbd1a6107f8b17454b67: all-thread successful SQL statements from startup through shutdown fell from 22,394 to 22,250 (−144). Main-thread statements were 2,548 → 2,513; worker-thread statements 19,400 → 19,291; helper-process statements stayed 446. Each side had one rejected statement, excluded consistently from successful totals. The published-driver update cell also passed. Pre-conflict head Testbox proof run; a runner portal-sync timeout was nonfatal after the successful proof.

Main was merged with a merge commit (no rebase), producing d6a328a6e29c76ab2e24882eedda88aa75bff33f. The only manual resolutions preserve both additions in the worker-access documentation and retain the correct inventory source line. Source code merged automatically. Formatting, all 14,943 internal documentation links, and git diff --check passed. Runtime proofs above are reused for this conflict-only push; the exact-head CI watcher reports green for run 38012076206.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: d6a328a6e29c76ab2e24882eedda88aa75bff33f
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/registry-import.worker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/registry-lifecycle.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/registry-publication.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/registry-write.worker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/registry.kernel.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/registry.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR publishes committed sandbox, worktree, and GitHub publication facts before observers and preserves known write outcomes after reply loss.

Example: A worktree run-lease admission commits, but its ordinary worker reply is lost.

  • Before: Admission rejects despite the committed lease, requiring uncertain-outcome handling.
  • After: The native receipt recovers the admitted lease while its Git protection remains active until release.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful owner-boundary repair with substantive native settlement coverage, preserved storage contracts, resolved earlier blockers, and passing exact-head CI.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Supplied native and real-worker owner runs cover committed row installation, rollback, reply loss, late supersession, cleanup tombstones, and oversized results; source inspection confirms those scenarios exercise the changed producers, whose runtime code is unchanged by the final conflict resolution.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Committed storage changes can lack their corresponding published facts, and a lost worker reply can reject an already accepted worktree operation.
Reason: The maintainer-directed change completes typed-writer publication without adding configuration, permission, or persistent-format contracts.

Merge readiness

✅ Ready for maintainer review

This PR provides useful, maintainer-directed storage correctness work; the previous wrapper-inventory and conflict blockers are resolved, and no introduced defect remains identified.

Priority: P2
Reviewed head: d6a328a6e29c76ab2e24882eedda88aa75bff33f

Before merge

None.

Findings

None.

Agent review details

How this fits together

Existing SQLite domain writers accept registry and publication mutations and emit exact committed row facts or deletion tombstones through the shared publication and worker-settlement owners.

flowchart TD
A[Registry and publication callers] --> B[Existing domain writers]
B --> C[SQLite transaction]
C --> D[Committed receipt]
D --> E[Fact installation]
E --> F[Observers and worker reply]
D --> G[Native settlement recovery]
Loading

Technical review

Best possible solution:

Land exact committed-fact publication through the existing owners while preserving their live authority and unknown-outcome safeguards.

Do we have a high-confidence way to reproduce the issue?

Current-main source lacks the added fact producers and rejects lost run-lease replies even after completed settlement; supplied baseline controls target those paths, but this read-only review ran no code.

Is this the best way to solve the issue?

The change fixes the existing producers, reuses shared postcommit ordering, and retains final guards rather than treating incomplete receipts as authorization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d12658c4c9dd.

Provenance checked

  • Sandbox registry transactions and live generation checks keeps the original intent (7f4cf34: Move reservation and removal transactions to the existing executor while retaining synchronous generation checks and joining accepted cleanup.)
  • Worktree guards, retirement, and settlement keeps the original intent (623d8e0: Keep worker-owned predicates, lifecycle fencing, offline custody, FIFO, and synchronous effect guards.)
  • Requester-bound GitHub publication keeps the original intent (65e49fa: Retain the original requester and grant across deferral and restart without authorizing new effects after revocation.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 623d8e0 adds src/agents/worktrees/registry-run-end.worker.ts:211 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 623d8e02a5d8; files: src/agents/worktrees/registry-run-end.worker.ts)
  • Shakker: Raw commit 65e49fa adds src/state/github-publication-session-lifecycles.ts:47 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 65e49fa2008c; files: src/state/github-publication-session-lifecycles.ts)

PR surface

Source +1029, Tests +495, Docs +32, Other +2. Total +1558 across 37 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 25 1257 228 +1029
Tests 9 526 31 +495
Docs 2 53 21 +32
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 37 1838 280 +1558

Review metrics

Metric Value Why it matters
Production versus test LOC Production +1,257/−228; tests +526/−31 The production growth supplies domain-specific capture, publication, supersession, and native settlement recovery using existing shared receipt primitives.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs bounded internal publication and reply-loss recovery without evidence of an urgent user-facing outage.
  • 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-09T23:49:21.083Z sha 784c736 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T23:55:17.158Z sha 784c736 :: needs changes before merge. :: [P2] [P2] Include the new receipt modules in the trusted wrapper inventory
  • reviewed 2026-10-10T00:36:43.825Z sha dbc76f2 :: needs changes before merge. :: none
  • reviewed 2026-10-10T00:59:20.157Z sha dbc76f2 :: needs changes before merge. :: none

Reviewed October 9, 2026, 9:38 PM ET / October 10, 2026, 01:38 UTC (Revision 5).

@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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 9, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 10, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 10, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@steipete
steipete merged commit cbff5bd into main Oct 10, 2026
154 of 155 checks passed
@steipete
steipete deleted the dbasync/sw4b branch October 10, 2026 01:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
openclaw#168025)

* fix(sandbox): publish committed registry facts

* fix(storage): publish worktree and GitHub authority receipts

* fix(storage): preserve claim types and portable receipt proof

* refactor(storage): keep receipt production on domain owners

* fix(scripts): include registry publications in wrapper inventory

* test(worktrees): expect committed admission recovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime 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. scripts Repository scripts security-sensitive-changed size: XL 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