Skip to content

fix: preserve snapshot cleanup after parent token contention - #161372

Merged
steipete merged 2 commits into
mainfrom
codex/staging-parent-refusal-20260929
Sep 29, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/staging-parent-refusal-20260929

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144592

What Problem This Solves

A parent snapshot token can reject a new allocation before any child directory is created, yet later cleanup reports an unresolved allocation and prevents existing snapshots from retiring normally.

User Impact

A temporary parent-token lock retains its original SQLite contention error and existing retry behavior. Cleanup can finish after the actual child exits when the owner knows that no directory was allocated.

Why This Change Was Made

Extend the existing definite-refusal marker to parent-token admission, preserving the original error object and codes. Carry contention and allocation refusal together through the existing two-field reply, with the old contention prefix first. Reuse the existing native custody owner; lost replies and failures after creation still retain unresolved cleanup custody. The independent Windows directory-creation mechanism, storage schema, retention policy, and protocol version are unchanged.

Evidence

A real parent database held under an exclusive lock reproduced the original cleanup rejection after native child exit. The repaired candidate passed all 72 Node cases across the three owning files and four Bun cases, including real child close, concurrent/nested snapshot lifetimes, the missing-parent refusal, and a failure injected only after actual directory creation. The post-creation failure remains unresolved as required. Registered-worker controls preserve the exact {ok, message} result and the existing parent contention decoder; the original four combined-fact creation rows fail before the repair while ordinary sync/async contention controls pass.

The Node selection used node scripts/run-vitest.mjs --config test/vitest/vitest.infra.config.ts --reporter=verbose src/infra/sqlite-readonly-location.worker.test.ts src/infra/sqlite-readonly-native-resource.test.ts src/infra/sqlite-snapshot-staging.ownership.test.ts, with two workers, and took 41.55 seconds of wrapper wall time. The focused four-case Bun selection took 17.13 seconds. These are group timings, not standalone file or CI timings. Proof used macOS arm64, Node 24.21.0 and Bun 1.4.2; no fresh Windows or full published-updater executable replay is claimed.

The complete selected check passed: core and all 27 test type graphs, three unused-export scans, scoped lint, runtime import-cycle checks, and source guards. Fresh independent review of the complete seven-file change and its owners found no actionable issue. Hosted CI remains separate from these local results.

The first hosted run failed in two separate test roots. The task-replacement pair was independently reproduced on the unchanged baseline and repaired by canonical commit 4cd32ee5657b. The first-signin 90-second timeout did not reproduce in the unchanged single test or original nine-file cohort locally; its cause remains unclassified. This head carries canonical failure-only diagnostics from c4461b537ce3 to distinguish sign-in progress and request phases. Responses, setup order, assertions, and the deadline remain unchanged. Final hosted CI36636502407 passed at 0be5e7eb95d9; the diagnostic change is not claimed as a timeout fix.

A failed parent read-token admission happens before any child directory is
created. Record that definite allocation refusal with the existing owner
marker while preserving the original error and SQLite contention prefix.
Keep unknown allocation custody for lost replies and post-creation failures.

The real parent-lock control failed on the original cleanup result; the
candidate passed 72 Node cases and four Bun cases. Registered-worker controls
preserve the released two-field failure shape and old contention decoder.
Full selected checks and fresh independent review passed. Node/Bun proof is
on macOS; unchanged Windows creation mechanics are not requalified here.

Related: #144592
@clawsweeper

clawsweeper Bot commented Sep 29, 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 September 29, 2026 20:26
@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 Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 29, 2026, 6:33 PM ET / 22:33 UTC (Revision 3).

ClawSweeper review

What this changes

The branch lets SQLite snapshot cleanup recognize parent-token contention before directory creation, preserves the retry signal, adds custody tests, and adds first-signin timeout diagnostics.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: current main still has the reported cleanup gap, and the focused repair has convincing production-boundary proof. No code defect was found in this review.

Priority: P2
Reviewed head: 0be5e7eb95d9a04f3763c00735cdcc1623af556e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused owner repair and real-child fault proof are strong; per-file test-cost disclosure remains the material merge-readiness gap.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR reports a before-fix failure and after-fix recovery through the actual SQLite child, native resource owner, real client transport, and an exclusive parent database lock; the added test checks that cleanup completes after child close and that post-creation failure remains unresolved. No stored-data model or migration changes are introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports a before-fix failure and after-fix recovery through the actual SQLite child, native resource owner, real client transport, and an exclusive parent database lock; the added test checks that cleanup completes after child close and that post-creation failure remains unresolved. No stored-data model or migration changes are introduced.
Evidence reviewed 8 items Pre-creation boundary: The introduced catch marks a parent-token failure before the code attempts to create a child directory.
Worker reply and cleanup: The worker emits contention before the allocation-refusal prefix; the decoder retains both facts, and the native owner suppresses unresolved-allocation custody only for a definite refusal.
Real child boundary test: The added test uses the actual native worker and client with an exclusive lock on the parent SQLite token. It asserts child-close ordering, successful cleanup for the pre-creation failure, and unresolved cleanup for an injected post-creation failure.
Findings None None.
Security None None.

How this fits together

OpenClaw creates private SQLite snapshots in a child process for read-only storage work. A native resource owner tracks allocated directories and settles their cleanup after the child closes.

flowchart LR
  A[Snapshot request] --> B[Parent token admission]
  B --> C[Child directory creation]
  B --> D[Worker failure reply]
  C --> E[Native custody owner]
  D --> E
  E --> F[Child close]
  F --> G[Cleanup outcome]
Loading

Before merge

  • Resolve merge risk (P1) - The four materially changed test files still lack individual one-worker wall times and CI seconds in the PR body, so their recurring test cost cannot be checked against the repository budget.
  • Complete next step (P2) - Add individual one-worker wall times and CI seconds for the four materially changed test files to the PR body; justify any file above 30 seconds.
Agent review details

Security

None.

PR surface

Source +8, Tests +333. Total +341 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 26 18 +8
Tests 4 413 80 +333
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 439 98 +341

Review metrics

Metric Value Why it matters
Test-cost disclosure 0 of 4 materially changed files have individual one-worker times The reported two-worker group timing cannot establish each file's recurring CI cost.
Production versus test growth production net +8 lines; tests net +333 lines The small production repair is backed by substantial custody and real-child regression coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep native staging custody with its existing owner: recognize only proven pre-creation refusals as empty allocations, preserve contention retries, and retain conservative cleanup for lost replies and post-creation failures.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep native staging custody with its existing owner: recognize only proven pre-creation refusals as empty allocations, preserve contention retries, and retain conservative cleanup for lost replies and post-creation failures.

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

Yes, from source and the submitted real-child test: hold the parent token database under an exclusive lock, request a nested snapshot, then close its native owner. The reviewer did not execute the test.

Is this the best way to solve the issue?

Yes. The patch extends the existing refusal marker and custody owner while preserving the contention error and unresolved handling for failures after creation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against dc50ffd8a4a5.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair addresses a bounded SQLite snapshot cleanup failure under parent-token contention.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports a before-fix failure and after-fix recovery through the actual SQLite child, native resource owner, real client transport, and an exclusive parent database lock; the added test checks that cleanup completes after child close and that post-creation failure remains unresolved. No stored-data model or migration changes are introduced.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports a before-fix failure and after-fix recovery through the actual SQLite child, native resource owner, real client transport, and an exclusive parent database lock; the added test checks that cleanup completes after child close and that post-creation failure remains unresolved. No stored-data model or migration changes are introduced.

Evidence

What I checked:

  • Pre-creation boundary: The introduced catch marks a parent-token failure before the code attempts to create a child directory. (src/infra/sqlite-snapshot-staging.ts:288, 0be5e7eb95d9)
  • Worker reply and cleanup: The worker emits contention before the allocation-refusal prefix; the decoder retains both facts, and the native owner suppresses unresolved-allocation custody only for a definite refusal. (src/infra/sqlite-readonly-worker-protocol.ts:166, 0be5e7eb95d9)
  • Real child boundary test: The added test uses the actual native worker and client with an exclusive lock on the parent SQLite token. It asserts child-close ordering, successful cleanup for the pre-creation failure, and unresolved cleanup for an injected post-creation failure. (src/infra/sqlite-readonly-native-resource.test.ts:269, 0be5e7eb95d9)
  • Current main still needs the fix: The fetched main revision still calls parent-token admission without the new refusal marker; its worker decoder also lacks the combined-fact handling. (src/infra/sqlite-snapshot-staging.ts:287, dc50ffd8a4a5)
  • Contributor proof: The PR body reports a baseline failure under a real parent database lock, an improved after-fix cleanup result, 72 Node cases, four Bun cases, and a successful final hosted CI run. The stated 41.55-second Node timing covers three files together with two workers. (0be5e7eb95d9)
  • Test-cost contract: Repository guidance requires a one-worker cost for every materially changed test file and CI seconds once available. The PR body gives group timings but no per-file measurements for its four changed test files. Public docs: docs/help/testing/writing-tests.md. (docs/help/testing/writing-tests.md:92, 0be5e7eb95d9)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record one-worker wall time for each of the four materially changed test files and CI seconds in the PR body, explaining any file above 30 seconds.

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-09-29T20:34:20.587Z sha f50d9c3 :: blocked before merge. :: none
  • reviewed 2026-09-29T22:03:00.545Z sha 0be5e7e :: blocked before merge. :: none

Record fixed request and progress categories with elapsed times in the
existing abort report. Check browser/testing suffixes before the retained
device-code presentation, and count the independent catalog refresh.

Keep setup order, responses, assertions, and the 90-second deadline intact.
The Linux timeout remains under investigation; this adds failure evidence
without logging URLs, messages, device codes, payloads, or context objects.

Validated the focused flow, gateway-root types, scoped lint/format, and
independent review. The local passes do not clear the original Linux failure.
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Sep 29, 2026
@steipete
steipete merged commit 6af71e3 into main Sep 29, 2026
256 of 257 checks passed
@steipete
steipete deleted the codex/staging-parent-refusal-20260929 branch September 29, 2026 22:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…w#161372)

* fix: preserve snapshot cleanup after parent token contention

A failed parent read-token admission happens before any child directory is
created. Record that definite allocation refusal with the existing owner
marker while preserving the original error and SQLite contention prefix.
Keep unknown allocation custody for lost replies and post-creation failures.

The real parent-lock control failed on the original cleanup result; the
candidate passed 72 Node cases and four Bun cases. Registered-worker controls
preserve the released two-field failure shape and old contention decoder.
Full selected checks and fresh independent review passed. Node/Bun proof is
on macOS; unchanged Windows creation mechanics are not requalified here.

Related: openclaw#144592

* test(gateway): clarify first-signin timeout phases

Record fixed request and progress categories with elapsed times in the
existing abort report. Check browser/testing suffixes before the retained
device-code presentation, and count the independent catalog refresh.

Keep setup order, responses, assertions, and the 90-second deadline intact.
The Linux timeout remains under investigation; this adds failure evidence
without logging URLs, messages, device codes, payloads, or context objects.

Validated the focused flow, gateway-root types, scoped lint/format, and
independent review. The local passes do not clear the original Linux failure.

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. size: L 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