Skip to content

docs(agents): database access belongs in worker threads - #154189

Merged
steipete merged 1 commit into
mainfrom
steipete/docs-db-access-in-workers-20260920
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/docs-db-access-in-workers-20260920

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Gateway main thread still performs synchronous SQLite work on request, event, and timer paths. On team.openclaw.ai (2026-09-20) profiles showed 47% of main-thread time blocked inside the exclusive state-database coordinator from ensureProfileForEmail and the exec-approvals timer, and earlier the same day 84% in a synchronous task-registry refresh.

User Impact

Docs only. Establishes the rule that database access runs in worker threads (readers through the read-only worker scope, writers through the SQLite worker broker), with boot admission, migrations, Doctor/CLI one-shots, and lock primitives as the only synchronous exceptions, and that existing synchronous main-thread access is legacy to migrate when touched.

Why This Change Was Made

Maintainer directive (Peter, 2026-09-20): database access always in workers; legacy code and design get migrated. The rule lives with the other runtime safeguards in AGENTS.md so every lane that touches a synchronous path migrates it instead of extending it.

Evidence

git diff --check clean; one bullet added under "Runtime and code safeguards". No code changes.

Peter's directive: readers use the read-only worker scope, writers the SQLite
worker broker; the Gateway main thread only awaits results and installs
published facts. Boot admission, migrations, Doctor/CLI one-shots, and lock
primitives remain the synchronous exceptions. Existing synchronous
main-thread access is legacy to migrate when touched, never to extend.

Context: Team profiles on 2026-09-20 showed 47% of main-thread time blocked
in synchronous state-database write coordination from request and timer paths.
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 21, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 20, 2026, 8:16 PM ET / September 21, 2026, 00:16 UTC.

ClawSweeper review

What this changes

Adds contributor guidance requiring database work off the Gateway main thread, with explicit synchronous exceptions and migration guidance for legacy paths.

Merge readiness

✅ Ready for maintainer review

Keep open with no blocking findings. The policy clarification remains useful, matches the existing worker architecture, and is absent from the reviewed main revision. The maintainer label also precludes automatic closure.

Priority: P3
Reviewed head: 4cc826a79a9933e359bd9aa33582b832bc48ed9a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coherent policy clarification with appropriate documentation validation and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored policy change has no changed runtime entrypoint to demonstrate; source inspection, the clean diff check, and supplied docs CI cover this documentation scope.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored policy change has no changed runtime entrypoint to demonstrate; source inspection, the clean diff check, and supplied docs CI cover this documentation scope.
Evidence reviewed 6 items Pinned introduced change: The merge-base-to-head patch adds only the database-worker policy bullet at line 59; it introduces no runtime, dependency, permission, or persistent-format changes.
Current-main necessity: The reviewed main revision retains the SQLite and synchronous-transaction guidance but does not contain the proposed database-worker rule.
Latest-release comparison: The supplied latest release also contains the SQLite and Kysely guidance without this worker-placement rule; no shipped implementation of this documentation change was established.
Findings None None.
Security None None.

How this fits together

The Gateway coordinates requests and background tasks that access SQLite state. Worker owners perform database operations and return results for the Gateway to publish.

flowchart LR
  A[Requests and background tasks] --> B[Gateway]
  B --> C[Read worker scope]
  B --> D[SQLite worker broker]
  C --> E[SQLite databases]
  D --> E
  E --> F[Results returned to Gateway]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Docs +1. Total +1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 1 0 +1

Review metrics

None.

Technical review

Best possible solution:

Keep the worker-placement rule in the root contributor guidance while preserving detailed lifecycle and authority contracts with their storage owners.

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

Not applicable: this PR documents engineering policy; the motivating production profiling claims were not independently reproduced.

Is this the best way to solve the issue?

Yes. A root guidance bullet is a narrow way to establish the shared rule while leaving concrete database migrations to their existing owners.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused contributor-documentation clarification with no immediate runtime change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored policy change has no changed runtime entrypoint to demonstrate; source inspection, the clean diff check, and supplied docs CI cover this documentation scope.

Label justifications:

  • P3: This is a focused contributor-documentation clarification with no immediate runtime change.
  • 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: The maintainer-authored policy change has no changed runtime entrypoint to demonstrate; source inspection, the clean diff check, and supplied docs CI cover this documentation scope.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head patch adds only the database-worker policy bullet at line 59; it introduces no runtime, dependency, permission, or persistent-format changes. (AGENTS.md:59, 4cc826a79a99)
  • Current-main necessity: The reviewed main revision retains the SQLite and synchronous-transaction guidance but does not contain the proposed database-worker rule. (AGENTS.md:58, 68def4154c7c)
  • Latest-release comparison: The supplied latest release also contains the SQLite and Kysely guidance without this worker-placement rule; no shipped implementation of this documentation change was established. (AGENTS.md:58, ec9c1a13db89)
  • Existing storage contracts: Storage guidance already describes worker-owned maintenance, read workers, broker admission, retained legacy synchronous paths, and host authority checks. The new bullet states migration direction without replacing those operation-specific contracts. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md:27, 4cc826a79a99)
  • Validation and discussion: The complete supplied body describes a maintainer-directed documentation change and reports whitespace validation; the independent diff check passed. Supplied check-docs CI succeeded. No runtime tests were run, and no maintainer-notes directory was present. (AGENTS.md:59, 4cc826a79a99)
  • Routing history: Main-branch history records recent AGENTS.md work by Peter Steinberger, and GitHub commit metadata maps the author to steipete. Local blame could not complete because a historical object was unavailable; no source-line introduction attribution is claimed. (AGENTS.md, 1894325ef720)

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
steipete merged commit 7d14778 into main Sep 21, 2026
63 checks passed
@steipete
steipete deleted the steipete/docs-db-access-in-workers-20260920 branch September 21, 2026 01:12
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
)

Peter's directive: readers use the read-only worker scope, writers the SQLite
worker broker; the Gateway main thread only awaits results and installs
published facts. Boot admission, migrations, Doctor/CLI one-shots, and lock
primitives remain the synchronous exceptions. Existing synchronous
main-thread access is legacy to migrate when touched, never to extend.

Context: Team profiles on 2026-09-20 showed 47% of main-thread time blocked
in synchronous state-database write coordination from request and timer paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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