Skip to content

fix: prevent SQLite admission refusals during Gateway delays - #154682

Merged
vincentkoc merged 1 commit into
mainfrom
fix/sqlite-admission-refusal-20260921
Sep 21, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/sqlite-admission-refusal-20260921

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes chat turns and task lists failing with "SQLite transaction admission was refused" when a busy Gateway takes longer than five seconds to service a worker authority request.

User Impact

Accepted database operations wait for the live owner's decision instead of failing solely because the host was delayed. Revoked authority still refuses the operation. No configuration, schema, durability, retention, or permission changes; updating requires no migration or operator action.

Why This Change Was Made

The worker independently expired a request that the host still owned, preventing a later valid grant. Keep the shared decision pending until the host grants or refuses it. Broker failure still terminates and joins the worker before releasing custody; coordinator-lock and broker-capacity deadlines are unchanged. This also removes the race between a late host grant and worker-side refusal.

Evidence

  • Production task-list/chat failures identify this exact refusal path during host scheduling delays; those logs do not measure the precise blocked interval.
  • Deterministic regression: the original implementation fails all three delayed-decision cases. The fix preserves successful admission, revoked-owner refusal, and closure without mutation. No real sleeps or test-only production hooks.
  • Focused admission, physical-alias/revocation, broker cancellation/capacity, and settlement-cleanup suites: 35/35 tests pass, four files, 88.49 seconds wrapper wall including cold worker compilation.
  • Changed test file: 14/14 pass, 2.59 seconds Vitest / 4.92 seconds wrapper wall with one worker. These are preserved results from original SQLite head 2374731264e; the prior recovery verified all three affected SQLite files and their patch byte-identical at 6472c860283. This continuation did not rerun those tests.
  • Fresh standalone AutoReview completed on exact commit 6472c860283613f0d81ba5cfee5d17d6803348b5: scoped-clean, no P0-P2 findings, exit 0. The supplied unchanged-source context and binary patch hashes were verified against the candidate. Earlier authentication failures produced no passing evidence and are superseded by this completed run.
  • Personal source inspection and the completed exact-head ClawSweeper review found no actionable SQLite defects. Inspected host current-authority checks, transaction/commit ordering, caller/worker paths, admission service retention, worker retirement, and settlement cleanup. The ECMAScript Atomics.wait contract confirms an omitted timeout waits indefinitely and the compare-before-wait handles a decision arriving before suspension.
  • Exact-head CI completed successfully on 6472c860283613f0d81ba5cfee5d17d6803348b5. Required CI, dependency-review, and security-sensitive-review gates are successful; the observed rollup has 168 passing and 43 skipped/neutral checks, with no failing or pending checks.
  • Formatting, diff checks, and production typechecking passed in the preserved proof; this continuation also verified the candidate diff has no whitespace errors. Live deployment and chat verification remain the deployment owner's next step and are not claimed here.

Earlier CI failure and conflict resolution

The original CI shard failed Discord audio-worker pacing because fixture readiness preceded real audio consumption. The original shard replay passed 289 files / 4,079 tests; that passing replay alone did not resolve the race.

Main subsequently landed the owning first-packet readiness correction in 761725d03f2. This PR is based on that correction and drops its redundant Discord test commit. The resulting diff is SQLite-only: one production file, its regression test, and matching documentation. Upstream owns the Discord fixture and its repeatability evidence; no thresholds are weakened by this PR.

@clawsweeper

clawsweeper Bot commented Sep 21, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review September 21, 2026 09:31
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S maintainer Maintainer-authored PR labels Sep 21, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 6:50 AM ET / 10:50 UTC (Revision 4).

ClawSweeper review

What this changes

SQLite workers now wait for the host’s admission decision instead of refusing database operations after five seconds, with regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: current main and the latest release retain the premature admission timeout. The previous merge-conflict blocker is resolved, and this review found no actionable defect in the remaining SQLite change.

Priority: P1
Reviewed head: 6472c860283613f0d81ba5cfee5d17d6803348b5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with useful deterministic coverage and no remaining actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored internal scheduling repair is exempt from the external-contributor proof gate. The supplied evidence covers admission regressions and surrounding lifecycle tests; live chat verification is explicitly unclaimed. No unresolved authority change requires additional final-effect proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored internal scheduling repair is exempt from the external-contributor proof gate. The supplied evidence covers admission regressions and surrounding lifecycle tests; live chat verification is explicitly unclaimed. No unresolved authority change requires additional final-effect proof.
Evidence reviewed 9 items Introduced change: The pinned introduction delta removes the five-second worker timeout and worker-side refusal transition, replacing them with a wait for the host-written decision. It contains only admission implementation, regression tests, and matching documentation.
Still necessary on main: The fetched main implementation still waits with ADMISSION_TIMEOUT_MS and then changes a pending decision to REFUSED. Delayed host service therefore remains a source-proven failure path.
Latest release check: The v2026.9.5 source also contains the timed wait followed by worker-side refusal; that release does not contain this repair.
Findings None None.
Security None None.

How this fits together

OpenClaw runs database operations in workers while the Gateway retains caller authority. Workers request permission before protected operations, and the broker retains custody until execution settles or the worker exits.

flowchart TD
  A[Chat and task operations] --> B[SQLite worker broker]
  B --> C[Worker admission request]
  C --> D[Host checks current authority]
  D -->|Grant| E[Database operation]
  D -->|Refuse| F[Operation rejected]
  E --> G[Settlement and custody release]
  B -->|Worker failure| H[Join worker exit]
  H --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +47, Docs +5. Total +55 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 3 +3
Tests 1 47 0 +47
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 58 3 +55

Review metrics

None.

Technical review

Best possible solution:

Keep admission decisions with the live host owner while preserving revocation checks and broker-owned settlement.

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

Yes, from source: delaying host admission service beyond five seconds makes the current-main worker refuse a still-pending request. This read-only review did not execute the reproduction.

Is this the best way to solve the issue?

Yes. Removing the competing worker deadline repairs the existing admission owner without adding retries, configuration, or another authorization path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The reported failure interrupts chat turns and task lists during Gateway scheduling delays, and current source supports the mechanism.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored internal scheduling repair is exempt from the external-contributor proof gate. The supplied evidence covers admission regressions and surrounding lifecycle tests; live chat verification is explicitly unclaimed. No unresolved authority change requires additional final-effect proof.

Evidence

What I checked:

  • Introduced change: The pinned introduction delta removes the five-second worker timeout and worker-side refusal transition, replacing them with a wait for the host-written decision. It contains only admission implementation, regression tests, and matching documentation. (src/infra/sqlite-worker-operation-admission.ts:301, 6472c8602836)
  • Still necessary on main: The fetched main implementation still waits with ADMISSION_TIMEOUT_MS and then changes a pending decision to REFUSED. Delayed host service therefore remains a source-proven failure path. (src/infra/sqlite-worker-operation-admission.ts, 56455cb33377)
  • Latest release check: The v2026.9.5 source also contains the timed wait followed by worker-side refusal; that release does not contain this repair. (src/infra/sqlite-worker-operation-admission.ts, ec9c1a13db89)
  • Authority remains live: The write admission owner calls assertCurrent immediately before granting transaction and commit requests. The admission receiver refuses thrown or ungranted requests. Waiting longer does not turn a pending request into a grant or preserve a previously revoked authorization. (src/infra/sqlite-worker-store.ts:115, 6472c8602836)
  • Failure retains custody: Broker failure retires the worker before settling affected jobs; retirement awaits termination and exit before releasing coordinator custody. Normal settlement closes admission only after the worker result. The patch does not alter these owners. (src/infra/sqlite-worker-broker-reply.ts:477, 6472c8602836)
  • Regression coverage and reported validation: Three deterministic cases exercise delayed grant, revoked-owner refusal, and closure without mutation through the admission owner. The captured PR body reports 14/14 focused tests and 35/35 surrounding tests passing, with 4.92 seconds focused wrapper wall time. These are reported test results, not reviewer execution or live deployment proof. (src/infra/sqlite-worker-operation-admission.test.ts:18, 6472c8602836)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (3 earlier review cycles)
  • reviewed 2026-09-21T09:40:09.860Z sha 2374731 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T10:02:09.389Z sha d902c09 :: needs changes before merge. :: none
  • reviewed 2026-09-21T10:38:09.982Z sha d902c09 :: needs changes before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the channel: discord Channel integration: discord label Sep 21, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 21, 2026
@vincentkoc
vincentkoc force-pushed the fix/sqlite-admission-refusal-20260921 branch from d902c09 to 6472c86 Compare September 21, 2026 10:42
@vincentkoc vincentkoc self-assigned this Sep 21, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the channel: discord Channel integration: discord label Sep 21, 2026
@vincentkoc
vincentkoc merged commit c47c7fb into main Sep 21, 2026
228 checks passed
@vincentkoc
vincentkoc deleted the fix/sqlite-admission-refusal-20260921 branch September 21, 2026 12:23
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

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 P1 High-priority user-facing bug, regression, or broken workflow. 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