Skip to content

feat(sqlite): run Team Reports storage in owned workers - #144871

Merged
steipete merged 2 commits into
mainfrom
codex/sqlite-worker-team-reports-final
Sep 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/sqlite-worker-team-reports-final

Conversation

@steipete

@steipete steipete commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144592

What Problem This Solves

Awaiting Node SQLite calls does not move their work off the application thread. Team Reports can still block timers and requests during database operations or lock contention even though its store methods return promises.

Why This Change Was Made

Move Team Reports opening, schema work, prepared queries, complete transactions, WAL maintenance and close into a long-lived worker owned by a bounded shared broker. The plugin sends typed domain commands to a static private backend and locates it from the loader-selected runtime entry. Its existing service lifetime retains admitted work through shutdown.

The broker allows four lazy workers, 64 opening/live store clients, 128 requests and a bounded input queue. Physical aliases share an owner; admitted pathnames remain protected through client drainage. Queued cancellation removes unstarted work; dispatched operations retain their settlement. Worker loss or an undecodable committed result reports an uncertain outcome without automatically replaying writes. Local overload before dispatch does not retire a healthy shared worker.

This first consumer supports file-backed stores from the application main thread. Incognito, shared canonical databases and callers hosted in other application workers remain separate campaign work. Native synchronous SQLite primitives stay entirely inside the worker; no main-thread blocking RPC bridge is introduced.

User Impact

Team Reports preserves its schema, report formats, UTF-8 limits, retention and HTTP behavior while SQLite work stops blocking its host event loop. Existing connection and prepared-statement ownership stays with the database worker.

Release context: publish this Team Reports change with the first host release containing the worker SDK and selected-runtime-entry capability. The regular release workflow must synchronize its plugin API compatibility floor; this PR does not publish or guess a future version.

Evidence

  • 296 focused tests passed on current main: 27 broker cases, 243 Team Reports cases and 26 test-routing checks. Full selected checks and both root-bundled and standalone builds passed.
  • Fresh independent Codex review through P2 passed. The final 29-file remainder exactly matches that reviewed source after the two prerequisite PRs landed.
  • Strict native instrumentation observed zero SQLite calls on the main thread for source execution and both plain-Node 24 compiled package layouts, including opening, HTTP reads/writes, drainage, close and fresh reopening. Compiled proofs imported no TypeScript/source fallback.
  • A 751.386 ms external writer lock allowed 128 main-thread timer ticks; the largest gap was 6.665 ms and event-loop p99 was 6.480 ms. All 25 queued writes drained before close. Four actual HTTP routes returned 200, and report/Unicode data survived service restart and fresh-process reopening.
  • Thirty warm source samples observed read median/p95 of 0.312/0.580 ms and write median/p95 of 0.408/0.610 ms. These are descriptive timings, not a paired throughput improvement claim.
  • Regressions reproduce alias replacement, premature close, uncertain result decoding, invalid async backend execution, leaked client capacity and overload that previously disrupted unrelated writes.
  • Proof uses synthetic reports and an isolated registered-service/HTTP harness; it does not claim a production Gateway deployment or completion of all SQLite migrations.

The exact CI wrapper failure is repaired by including the worker-path module in the canonical extracted dependency closure; all 70 wrapper regressions pass. The scheduler fixture waits for actual collector entry while retaining its immediate concurrent-run rejection and no-overlap assertions; all 31 scheduler cases and the original delayed-read reproduction pass. Full candidate checks and fresh P2 review passed for these two fixes.

@clawsweeper

clawsweeper Bot commented Sep 11, 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 scripts Repository scripts plugin: team-reports size: XL maintainer Maintainer-authored PR labels Sep 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 11, 2026, 9:01 AM ET / 13:01 UTC (Revision 3).

ClawSweeper review

What this changes

Moves Team Reports database operations into bounded, shared SQLite workers, exposes a typed plugin SDK interface, and updates lifecycle tests and test routing.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/infra/sqlite-store.worker.ts, src/infra/sqlite-worker-store.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains necessary: current main still runs Team Reports SQLite operations on the application thread. No blocking correctness or security defect was found. The previous publication concern is addressed by the documented coordinated release plan and existing compatibility-floor synchronization.

Priority: P2
Reviewed head: 57ec881ea053b5448045613038198aa90ce45f64

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent worker conversion with useful production-boundary observations and substantive lifecycle coverage; no actionable blocker remains from this review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured PR body reports the actual Team Reports service, HTTP handlers, worker broker, and native SQLite backend exercised in source and compiled Node layouts, with external lock contention, responsive timers, drained writes, and durable reopening. The latest commit only repairs test synchronization and wrapper packaging.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured PR body reports the actual Team Reports service, HTTP handlers, worker broker, and native SQLite backend exercised in source and compiled Node layouts, with external lock contention, responsive timers, drained writes, and durable reopening. The latest commit only repairs test synchronization and wrapper packaging.
Evidence reviewed 10 items Current main still needs the worker conversion: The pinned main store exposes asynchronous methods but directly calls synchronous SQLite queries and transactions; its factory also opens and initializes SQLite on the caller's thread.
Release boundary: The latest supplied release's SQLite SDK has no worker-store export. This work is not already shipped in v2026.9.4.
Owned drainage and failure handling: Each client tracks accepted operations and drains them before releasing its actor. Worker failure joins native exit before rejecting uncertain dispatched operations; queued writes are not replayed.
Findings None None.
Security None None.

How this fits together

Team Reports collects activity and serves stored reports through authenticated Gateway routes. Its storage adapter now sends domain commands to workers that own SQLite connections, transactions, and cleanup.

flowchart LR
  A[Report scheduler] --> C[Team Reports storage adapter]
  B[Authenticated report requests] --> C
  C --> D[Bounded worker broker]
  D --> E[Database worker]
  E --> F[Plugin SQLite database]
  E --> G[Results or explicit failures]
  G --> C
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +988, Tests +986, Docs +60, Config +3, Other +3. Total +2040 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 10 1469 481 +988
Tests 15 1026 40 +986
Docs 2 60 0 +60
Config 1 3 0 +3
Generated 0 0 0 0
Other 2 3 0 +3
Total 30 2561 521 +2040

Review metrics

Metric Value Why it matters
Production versus validation growth Production/tooling net +992 lines; tests and test routing net +988 lines The production growth has a stated purpose: a reusable bounded worker owner with Team Reports as its first consumer.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/infra/sqlite-store.worker.ts, unknown-data-model-change: src/infra/sqlite-worker-store.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #144592
Summary: This PR implements the Team Reports worker boundary within a broader asynchronous storage campaign.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Retain one worker-owned SQLite backend per database and publish the plugin with its supporting host through the existing release compatibility synchronization.

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

Yes, source establishes the mechanism: current main directly executes synchronous SQLite operations inside asynchronous store methods. The supplied lock-contention observations exercise the repaired boundary; this review did not rerun them.

Is this the best way to solve the issue?

Yes. Complete domain operations move behind one generic worker owner while existing schema and caller contracts remain intact; asynchronous transaction admission alone would not move queries or schema work off-thread. The host/plugin publication dependency is already covered by explicit release context.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a bounded runtime responsiveness improvement for Team Reports, without evidence of an urgent widespread outage.
  • 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 (live_output): The captured PR body reports the actual Team Reports service, HTTP handlers, worker broker, and native SQLite backend exercised in source and compiled Node layouts, with external lock contention, responsive timers, drained writes, and durable reopening. The latest commit only repairs test synchronization and wrapper packaging.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body reports the actual Team Reports service, HTTP handlers, worker broker, and native SQLite backend exercised in source and compiled Node layouts, with external lock contention, responsive timers, drained writes, and durable reopening. The latest commit only repairs test synchronization and wrapper packaging.

Evidence

What I checked:

  • Current main still needs the worker conversion: The pinned main store exposes asynchronous methods but directly calls synchronous SQLite queries and transactions; its factory also opens and initializes SQLite on the caller's thread. (extensions/team-reports/src/store.ts:173, 66c7fad06385)
  • Release boundary: The latest supplied release's SQLite SDK has no worker-store export. This work is not already shipped in v2026.9.4. (src/plugin-sdk/sqlite-runtime.ts:1, 3a9d69db306c)
  • Owned drainage and failure handling: Each client tracks accepted operations and drains them before releasing its actor. Worker failure joins native exit before rejecting uncertain dispatched operations; queued writes are not replayed. (src/infra/sqlite-worker-store.ts:388, 57ec881ea053)
  • Storage behavior preserved: The backend retains the existing schema, report encoding, conditional run completion, retention queries, and synchronous transaction boundaries. Native database opening and maintenance move into the worker. (extensions/team-reports/src/store.worker.ts:397, 57ec881ea053)
  • Real production-boundary observations: The supplied PR body records source and plain-Node compiled registered-service/HTTP runs: zero main-thread SQLite calls, 128 timer ticks during a 751.386 ms external writer lock, all 25 queued writes drained, four HTTP routes returned 200, and report/Unicode data survived restart and fresh-process reopening. These are bounded synthetic-input observations, not a deployed Gateway claim; no runtime execution was performed during this read-only review. (57ec881ea053)
  • Previous review continuity: The previous review recorded no findings. The latest commit changes only the scheduler fixture's collector-entry synchronization and the extracted wrapper dependency list, preserving immediate concurrent-run rejection. (extensions/team-reports/src/scheduler.test.ts:511, 57ec881ea053)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-11T11:07:45.584Z sha c31bbc7 :: blocked before merge. :: none
  • reviewed 2026-09-11T11:33:31.428Z sha c31bbc7 :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review September 11, 2026 11:28
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/team-reports/package.json

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfiles or workspace dependency policy changes are present.
  • Treat pnpm-lock.yaml and package-lock.json diffs as dependency security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin, a member of @openclaw/openclaw-secops, or an OpenClaw organization member with Maintain or Admin repository access.

  • Current SHA: 57ec881ea053b5448045613038198aa90ce45f64
  • Trusted actor: @steipete
  • Trusted role: pull request author; openclaw-secops

Security review is still recommended before merge when the dependency graph change is intentional.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Compatibility confirmation: Team Reports uses the same SQLite schema, tables, report encodings, UTF-8 limits and retention policy. The existing SQL implementation moved into its private worker; the frontend preserves the awaited domain API introduced in #144646. This requires no stored-data migration.

The final source and both compiled package layouts write synthetic reports, close every store/worker, reopen the same database in a fresh process and verify exact values. The 296-case suite includes existing store behavior and worker failure/drainage controls; all checks and both builds pass. Native instrumentation records zero SQLite calls on the application main thread for those flows.

This plugin must publish with a host containing the new worker/runtime-entry capabilities via the existing release-time plugin API floor synchronization. The PR does not publish a plugin separately or guess a future host version. File-backed application-main-thread callers are this first scope; incognito and other application-worker callers remain explicitly outside the supported first slice.

@steipete
steipete merged commit 979c0fc into main Sep 11, 2026
185 checks passed
@steipete
steipete deleted the codex/sqlite-worker-team-reports-final branch September 11, 2026 13:28
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 11, 2026
* commit 'f2ce199238e974b1d4caff8f11112aa51eb00d9e': (310 commits)
  refactor(copilot): deduplicate transcript user text (#144888)
  refactor(sessions): await discovery and config readiness (#144854)
  refactor(e2e): deduplicate release file assertions (#144904)
  ci: keep growing hosted test plans within the job cap (#144965)
  fix(macos): avoid stale dashboard command assertions (#144710)
  refactor(memory): await standing intent operations (#144832)
  refactor(ui): derive native device settings types from schemas (#144705)
  refactor(memory): await journal operations and allocate sequences atomically (#144824)
  refactor(tests): share command field assertions (#144955)
  refactor(matrix): share bounded context cache insertion (#144939)
  refactor(i18n): share Apple catalog reader (#144848)
  fix(doctor): preserve legacy registry files when quarantine fails (#144787)
  refactor(tests): reuse PixVerse auth fixtures (#144926)
  fix(bonjour): silence transient ENODEV socket warnings (#144870)
  fix(matrix): preserve unrelated files when migration fails (#144883)
  feat(sqlite): run Team Reports storage in owned workers (#144871)
  fix(update): install explicit same-version artifacts (#144894)
  refactor(ui): share cached message extraction (#144244)
  refactor: normalize Claude usage responses at one boundary (#144707)
  refactor: simplify CLI child listener registration (#144929)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
)

* feat(sqlite): run Team Reports storage in owned workers

* fix(sqlite): include worker test routing in maintainer tools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: team-reports proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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