Skip to content

fix(sqlite): prevent worker timeouts through state path aliases - #152190

Merged
steipete merged 1 commit into
mainfrom
codex/deflake2-sqlite-alias-20260918
Sep 18, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/deflake2-sqlite-alias-20260918

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #152050

What Problem This Solves

Completes the shared-state admission repair in #152050 for symlinked state directories. A worker could register its grant service under a caller's alias while DatabaseSync.location() returned the canonical path. An overlapping synchronous native writer then missed that service, blocked until the existing five-second admission deadline, and caused a valid renewal to fail.

Investigation context: Release Checks run 35382455441. The canonical coordinator-custody fix in #152050 landed as bc9e86ff940cfd22f63744ded4911f89b6476bf8 while this follow-up was being validated. This PR contains only the additional alias defect measured on macOS; the /var alias timing below is separate from the original Linux CI stall.

User Impact

Shared-state worker writes, including native-hook relay renewal, remain serviceable when state directories use filesystem aliases such as macOS /var. Current-owner checks still reject revoked writes. No schema, configuration, permission, deadline, or retry policy changes are introduced.

Why This Change Was Made

The broker already retains the physical actor's admitted raw and canonical paths. Registering those paths alongside the caller's retained locations keeps the grant service reachable without filesystem discovery on the request path or separate fixes in each store caller. The existing operation admission still owns authorization; path registration grants no write authority.

The regression uses a real SQLite worker and an explicit directory alias. It observes the worker's transaction-grant request, then enters the competing synchronous native transaction while the normal host listener remains queued. The current-owner case must renew the persisted record; the revoked-owner case must preserve its previous expiry. It keeps the original five-second admission bound and all outcome assertions.

Production LOC: +21/-13 (net +8); tests: +126; docs: +3. Most of the production diff moves the existing dispatch closure to capture its already-resolved actor. The added behavior carries retained identity into service registration.

Evidence

  • The finalized two-case regression fails on the pre-alias canonical head 2cfd36a9714c0c0f28d69a35df6753834dd23fce and passes with this repair under Node 24.19.0. An explicit fixture type annotation subsequently passed typechecking and the same two runtime cases without changing inputs or assertions.
  • The unchanged standalone diagnostic observed a 5089.9 ms native wait and zero grant-service calls when registration used /var/... and the native handle reported /private/var/.... The repaired raw-path flow completed in 39.6 ms and persisted the expected renewal.
  • The canonical shared-state controls, relay owner tests, and independent forced-order cases passed 32/32, including foreign-owner waiting, cancellation, revocation, worker exit, FIFO, capacity, and cleanup failure. The final typed two-case regression passed again in the publication checkout.
  • Full selected changed-file checks and fresh full-scope P2 review passed before moving this identical patch onto current main. Fresh current-main P2 review returned scoped-clean, and the Node 24.19.0 regression, targeted lint, and formatting checks passed. Fresh production and core-test typechecks also passed on the current-main follow-up.
  • One private-QA build of the composed receipt (fix(codex): deliver delegated results after the parent yields #152172), canonical admission, and alias fixes passed five consecutive subagent-handoff runtime pairs and one subagent-fanout-synthesis sibling pair: 12/12 runtime cells, no retries. Inspection covered 24 Gateway logs and six suite logs, with zero admission refusals or history timeouts; 22 history responses had a maximum handler duration of 734 ms. All five SQLite production files are byte-identical between the frozen proof and this publication candidate. The only fixture difference is the erased record type annotation. This is composed evidence with fix(codex): deliver delegated results after the parent yields #152172, not standalone proof without that receipt prerequisite.
{"handoffPairs":5,"fanoutPairs":1,"runtimes":["openclaw","codex"],"passedCells":12,"failedCells":0,"retries":0,"gatewayLogsInspected":24,"suiteLogsInspected":6,"historyResponses":22,"maxHistoryHandlerMs":734,"admissionOrHistoryTimeouts":0}

Focused command: node --import ./scripts/tsx.mjs scripts/test-projects.mts --maxWorkers=1 --reporter=verbose src/infra/sqlite-worker-shared-state-admission.test.ts.

Register the shared worker's already-admitted raw and canonical database paths with its grant service. Native handles can report a canonical pathname even when the caller opened a symlinked state directory; the service must remain reachable while a synchronous writer waits on the worker's transaction.

Keep current authority, the five-second admission budget, FIFO, and settlement ownership unchanged. Add real-worker forced-order regressions for successful renewal and revoked authority through an explicit directory alias, and document the retained identity boundary.
@clawsweeper

clawsweeper Bot commented Sep 18, 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 size: S maintainer Maintainer-authored PR labels Sep 18, 2026
@steipete
steipete marked this pull request as ready for review September 18, 2026 22:05
@steipete steipete self-assigned this Sep 18, 2026
@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 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 6:11 PM ET / 22:11 UTC.

ClawSweeper review

What this changes

Registers SQLite worker grant services under their retained filesystem aliases so overlapping native writes do not cause worker timeouts.

Merge readiness

✅ Ready for maintainer review

The alias-specific defect remains on current main, and this focused follow-up addresses it without changing authorization or storage contracts. No blocking correctness or security findings were identified.

Priority: P2
Reviewed head: 387a0f9bfb43c20fa380126c9c2ae7f9e244eec3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant before/after observations and persisted-outcome regression coverage.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured macOS diagnostic exercises the broker-to-native-writer path through /var aliases and reports successful persisted renewal after the fix; the real-worker regression also checks revoked-owner rejection. Composed Gateway results are supplemental and are not treated as standalone alias proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured macOS diagnostic exercises the broker-to-native-writer path through /var aliases and reports successful persisted renewal after the fix; the real-worker regression also checks revoked-owner rejection. Composed Gateway results are supplemental and are not treated as standalone alias proof.
Evidence reviewed 8 items Verified introduced change: The pinned merge-base comparison confirms that the production change carries the already-resolved actor into dispatch and adds its retained paths to the existing grant-service registration.
Current main still needs the repair: Fetched main registers retained.nativeLocations alone. Native transaction lookup uses DatabaseSync.location(), so an alias-only registration can miss the canonical filename. The inspected broker-reply path does not exist in the supplied latest release tag; no released alias fix was established.
Existing identity and lifecycle owner: The broker captures raw and canonical paths, rejects collisions with a different physical actor, reference-counts client aliases, and pins the opening paths for the native owner's lifetime. The patch consumes these existing facts without filesystem discovery.
Findings None None.
Security None None.

How this fits together

OpenClaw's SQLite broker coordinates background database workers with synchronous writes in the host process. When a worker needs permission to finish a transaction, the waiting native writer must find and service its grant callback.

flowchart TD
  A[State operation] --> B[SQLite worker broker]
  B --> C[Retained physical database aliases]
  C --> D[Grant service registry]
  E[Competing native writer] --> D
  D --> F[Current authority check]
  F --> G[Commit or reject worker write]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +8, Tests +126, Docs +3. Total +137 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 21 13 +8
Tests 1 126 0 +126
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 150 13 +137

Review metrics

None.

Technical review

Best possible solution:

Keep alias resolution with the physical database owner and reuse its retained paths while preserving existing grant checks, deadlines, and settlement cleanup.

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

Yes: current-main registration and canonical native lookup establish the mismatch, and the supplied forced-order regression exercises it through a symlinked state directory. This review did not execute tests.

Is this the best way to solve the issue?

Yes: reusing the broker's retained physical identity fixes the shared lookup boundary without duplicating canonicalization in callers or changing persistence contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: Repairs a concrete shared-state timeout triggered by filesystem aliases and overlapping native writes.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured macOS diagnostic exercises the broker-to-native-writer path through /var aliases and reports successful persisted renewal after the fix; the real-worker regression also checks revoked-owner rejection. Composed Gateway results are supplemental and are not treated as standalone alias proof.
  • 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. Sufficient (live_output): The captured macOS diagnostic exercises the broker-to-native-writer path through /var aliases and reports successful persisted renewal after the fix; the real-worker regression also checks revoked-owner rejection. Composed Gateway results are supplemental and are not treated as standalone alias proof.

Label justifications:

  • P2: Repairs a concrete shared-state timeout triggered by filesystem aliases and overlapping native writes.
  • 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 captured macOS diagnostic exercises the broker-to-native-writer path through /var aliases and reports successful persisted renewal after the fix; the real-worker regression also checks revoked-owner rejection. Composed Gateway results are supplemental and are not treated as standalone alias proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured macOS diagnostic exercises the broker-to-native-writer path through /var aliases and reports successful persisted renewal after the fix; the real-worker regression also checks revoked-owner rejection. Composed Gateway results are supplemental and are not treated as standalone alias proof.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base comparison confirms that the production change carries the already-resolved actor into dispatch and adds its retained paths to the existing grant-service registration. (src/infra/sqlite-worker-broker-reply.ts:114, 387a0f9bfb43)
  • Current main still needs the repair: Fetched main registers retained.nativeLocations alone. Native transaction lookup uses DatabaseSync.location(), so an alias-only registration can miss the canonical filename. The inspected broker-reply path does not exist in the supplied latest release tag; no released alias fix was established. (src/infra/sqlite-worker-broker-reply.ts:107, 52e409a739b1)
  • Existing identity and lifecycle owner: The broker captures raw and canonical paths, rejects collisions with a different physical actor, reference-counts client aliases, and pins the opening paths for the native owner's lifetime. The patch consumes these existing facts without filesystem discovery. (src/infra/sqlite-worker-broker-admission.ts:119, 387a0f9bfb43)
  • Authorization remains at the write boundary: Relay persistence rechecks database admission and caller authority inside the grant callback. The worker requests that grant inside its transaction before invoking the mutation kernel. Alias registration neither creates authority nor replaces those checks; settlement still releases the registration. (src/agents/harness/native-hook-relay-store.worker.ts:30, 387a0f9bfb43)
  • Meaningful forced-order regression: The added test uses an actual worker and SQLite database through a directory symlink, forces native contention while transaction admission is queued, and checks persisted expiry for both current and revoked owners. It adds no production testing seam. Tests were inspected, not executed during this read-only review. (src/infra/sqlite-worker-shared-state-admission.test.ts:29, 387a0f9bfb43)
  • Captured runtime evidence: The supplied complete PR body reports a macOS alias diagnostic improving from 5089.9 ms with zero grant-service calls to 39.6 ms with the expected persisted renewal, plus before/after execution of the two real-worker cases on Node 24.19.0. Its 12/12 composed runtime cells are explicitly supplemental and depend on fix(codex): deliver delegated results after the parent yields #152172. These are contributor-reported observations, not executions performed by this reviewer. (387a0f9bfb43)

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready for 387a0f9bfb43c20fa380126c9c2ae7f9e244eec3. Exact-head CI 35399942981 completed successfully: 143 jobs passed, 15 skipped, no failures. The prescribed watcher returned GREEN, and native hosted preparation passed without rebasing or changing the head.

Fresh current-main commands passed under Node 24.19.0:

node --import ./scripts/tsx.mjs scripts/test-projects.mts --maxWorkers=1 --reporter=verbose src/infra/sqlite-worker-shared-state-admission.test.ts
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
node scripts/run-tsgo-core-test-shards.mjs
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/infra/sqlite-worker-broker-reply.ts src/infra/sqlite-worker-shared-state-admission.test.ts
node_modules/.bin/oxfmt --check docs/reference/database-schemas/storage-changes.md src/infra/sqlite-worker-broker-reply.ts src/infra/sqlite-worker-shared-state-admission.test.ts
git diff --cached --check

Both real-worker regression cases passed; the same cases failed before the alias repair. Fresh isolated P2 review found no actionable findings. The full selected changed-file gate had already passed for the identical patch and owner bytes before moving it onto current main; exact-byte comparison and these fresh checks preserve that attribution.

The composed runtime proof passed five handoff pairs plus one fanout pair, 12/12 runtime cells without retries. All 24 Gateway logs and six suite logs were inspected; there were no admission refusals or history timeouts, and the maximum of 22 observed history handlers was 734 ms. The five SQLite production files match that proof exactly. Both prerequisites, #152050 and #152172, are now merged. The measured macOS alias defect remains distinct from the original Linux coordinator stall.

ClawSweeper's latest exact-head review lists no findings or before-merge changes. This follow-up adds eight net production lines to reuse retained identity; authorization, settlement, schemas and timeouts remain unchanged.

@steipete
steipete merged commit f64c4e9 into main Sep 18, 2026
283 checks passed
@steipete
steipete deleted the codex/deflake2-sqlite-alias-20260918 branch September 18, 2026 22:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 18, 2026
…pr-149099-main-20260918

* commit '795e460278d4f8f41545dc8b4a66da1d12defd90': (1902 commits)
  refactor(slack): share Markdown preparation (#149129)
  fix(tooling): release completed PR operations with exited loaders (#152209)
  fix(release): allow stable npm bootstrap under an operator soak waiver (#152206)
  fix(daemon): avoid false restart timeouts during slow startup (#151387)
  feat: read agent documents from a host-owned workspace (#150584)
  improve(startup): skip redundant single-agent directory checks (#152192)
  test(ui): await board widget readiness before size reports (#152198)
  perf(browser): move dashboard event discovery to SQLite worker (#151952)
  improve(auth): reduce pauses during concurrent credential reads (#152140)
  improve(ui): load older chat history in smaller pages (#152093)
  fix(release): reject incomplete legacy npm install trees (#152186)
  refactor: share current-conversation binding row serialization (#152134)
  test(tooling): preserve Node and terminal fixture ownership under Bun (#152187)
  fix(sqlite): service worker admission through retained path aliases (#152190)
  improve: reduce CPU work for long CLI reasoning streams (#152191)
  chore(ui): refresh control ui locales (#152196)
  test(subagents): align lifecycle retries with durable completion owners (#152184)
  perf(gateway): defer participant maps for owned sessions (#152097)
  refactor(stream): share auxiliary queue overflow handling (#149282)
  fix(test): execute CLI fixture preloads on Node and Bun (#152076)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
…penclaw#152190)

Register the shared worker's already-admitted raw and canonical database paths with its grant service. Native handles can report a canonical pathname even when the caller opened a symlinked state directory; the service must remain reachable while a synchronous writer waits on the worker's transaction.

Keep current authority, the five-second admission budget, FIFO, and settlement ownership unchanged. Add real-worker forced-order regressions for successful renewal and revoked authority through an explicit directory alias, and document the retained identity boundary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR 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: S 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