Skip to content

refactor(boards): move cross-store dashboard writes off the main thread - #170541

Merged
steipete merged 4 commits into
mainfrom
dbasync/boardauth
Oct 13, 2026
Merged

steipete merged 4 commits into
mainfrom
dbasync/boardauth

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cross-database Board writes fell back to a synchronous target transaction, blocking the Gateway while rereading source permission that the request owner already retains.

User Impact

Durable dashboard writes run in the existing target worker. Revoking source access denies new writes; a write admitted before revocation may still finish saving its widget or layout. This is the explicitly accepted, bounded exception: only writes already in flight at revocation. Target identity/lifecycle checks and private-content disclosure checks remain current.

Why This Change Was Made

Board checks the caller's source authority once, after asynchronous preparation and queue admission, immediately before dispatching the mutation. Ordinary Gateway callers read the sharing owner's retained facts: its pending publications block admission, committed receipts install facts before releasing the denial, and unknown outcomes remain denied. Board no longer prepares a second source snapshot, sends source predicates to the target, rereads them at transaction/commit, or chooses a native target transaction for a cross-store source. Existing synchronous callbacks remain callable at admission; no SDK exports or schema change.

Removed checks and accepted edge cases:

  • Duplicate source preparation/read: the request owner holds current source facts; arbitrary legacy callbacks still own their own assertion implementation.
  • Source revalidation at target transaction and commit: a write already admitted may finish after source revocation.
  • Source revalidation during publication cleanup/return: committed results and invalidation remain attached to the original target after revocation; independent disclosure checks are preserved.

The legacy process-held incognito database remains native under the scoped escape hatch. It is a live configuration contract, demonstrated by src/gateway/board-store.test.ts using the production singleton without an actor. Moving it requires the separate session-storage owner cutover; reopening its sentinel in a worker would lose data. Thus the assigned write-site inventory remains 8 → 8 T1 sites, all still reachable from that legacy path; durable cross-database Board target calls move off main. The shared mutation kernel cannot honestly be classified as worker-only yet.

Evidence

  • Regression coverage uses real Gateway request authorization and the existing publication owner: retained-fact admission without host SQL for put/layout/grant, revoke-then-write rejection, admitted write completion across revocation, pending/unknown revocation denial, and cold authorization parity.
  • CI passed the existing Board worker (26 tests, 19.64 s), batching (2, 9.76 s), incognito (10, 3.72 s), and outcome (5, 5.36 s) suites. This includes target replacement, queued writes, read-after-write, and unknown target outcomes. The first run exposed a missing host-worker test registration in the new regression; the follow-up also corrects its membership fixture to use the authenticated profile ID.
  • Local corrected boundary regression: pnpm test src/boards/sqlite-board-source-authority.test.ts --maxWorkers=1 passed all three tests; command wall time 927.17 s on the loaded host. Measured-head CI run 38343772697 passed in 770 s (45 successful jobs, 25 skipped; 8,929 aggregate successful job-seconds).
  • Changed-file formatting, lint, and git diff --check: passed.
  • Codex review: two completed rounds, both scoped-clean with no actionable P0–P2 findings (production cutover, then test-fixture/routing corrections).
  • Prior-head CI passed, including all Board tests, types, lint, source contracts, architecture/Madge, docs, and database ratchets. The separate Knip scan found a pre-existing exported admission type; main already fixed it in 0e0e87d465c9b, so main was merged without changing the reviewed Board patch. Refreshed-head CI run 38343772697 passed in 770 s (45 successful jobs, 25 skipped; 8,929 aggregate successful job-seconds). The separate Knip scan on measured head b2d7d083264c reported only ui/src/components/board/board-widget-cell-render.ts: renderBoardWidgetError. The identical production-unused-export finding was reproduced on clean main base f7d7425192bd using pinned Knip 6.32.2; that UI file is untouched here. The candidate script-export scan passed. The finding was assigned to the main-repair inbox. Final main integration removed that UI file, so the earlier inherited-static exception is no longer needed.
  • Production LOC: +14/−109 (net −95), below the expanded 600-line budget.
  • After the coordination hold lifted, main e65c0bd16568 was merged as 217844199512. The Board production diff is byte-identical to measured/reviewed head b2d7d083264c; changed-file formatting and lint passed again. Integration-head CI run 38349905389 passed: 45 successful jobs, 25 skipped, 734 s wall time and 8,405 aggregate successful job-seconds. The existing pair is retained as evidence for the unchanged Board patch; no additional local suites or harness runs were started.
  • No update/Doctor/schema/plugin-loading/service-lifecycle changes; the published-driver update cell does not apply.

The shared v2.1 workload contains no Board writes. Its baseline/candidate pair is a shared-read regression check; Board boundary tests establish the mutation behavior and zero host SQL for retained source admission. No per-Board total-statement saving is claimed from this workload.

One alternating pair, base f7d7425192bd then candidate b2d7d083264c, with ten warmed turns each. Both complete runs passed all 13 top-level turns, the child turn, 39 RPCs, cron, compaction, graceful shutdown, and child-process cleanup. A task-local harness copy corrects its obsolete synthetic tool_call alias to dispatch_action and places fixtures on external storage; observer and workload are unchanged. An earlier uncorrected baseline stopped at that alias mismatch and is excluded.

Metric Base Candidate
Warmed turn-caused statements/turn (mean) 170.2 170.2
Warmed turn-caused requests/turn (mean) 41.3 41.3
Warmed statements: turn median [min–max] 170 [170–171] 170 [170–171]
Warmed requests: turn median [min–max] 41 [41–42] 41 [41–42]
Warmed MAIN statements/turn 0 0
Background statements/min during warmed windows 651.83 640.44
Legacy window statements/turn 196.8 203.3
Exact-entry facts / actor hydration / entry-cache snapshots / row facts / watermark, per warmed turn 4 / 1.1 / 0 / 0 / 1 4 / 1.1 / 0 / 0 / 1
Whole-workload statements 6,590 6,598
Whole-workload requests 1,207 1,233
Boot + connect + first-turn window statements / requests 2,911 / 292 2,881 / 292

Every warmed SELECT fingerprint has the same execution count. The legacy warmed increase is background work in longer windows (24.485 s versus 31.010 s); the turn-caused statement and request deltas are zero. First-turn causal SQL is 375 → 380: one extra six-statement canonical-validation load and one exact-entry cohort read, offset by two fewer schema/quarantine checks, all in unchanged session admission owners. No changed Board mutation runs in this workload. The whole-workload difference is +8 statements / +26 requests from unchanged admission/background activity, accepted under attribution-over-raw. Host load was 90.14 → 76.50 for base and 78.31 → 46.71 for candidate on 32 CPUs; latency is unmeasured.

Run durable Board writes in the target worker with source authority checked once at admission. Access revocation denies new writes while already admitted writes may complete. Preserve target lifecycle and disclosure checks, and retain the legacy incognito escape hatch.
@clawsweeper

clawsweeper Bot commented Oct 13, 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 gateway Gateway runtime size: M labels Oct 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 13, 2026
@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR moves durable cross-store dashboard mutations into the existing database worker and checks source access once before dispatch.

Example: The board-member caller saves an in-flight widget in agent:target:board while source membership is revoked.

  • Before: The cross-store mutation uses a synchronous target transaction with repeated source-authority checks.
  • After: The admitted mutation may finish in the worker, while subsequent mutations are denied.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch repairs the previous finding, but required authorization evidence does not yet cover the final disclosure and capability effects.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Cross-store dashboard saves can block the Gateway while synchronous SQLite work runs.
Reason: The existing worker absorbs the work with less production code, and maintainer authorship establishes direction for the documented admission tradeoff.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this maintainer-directed worker cutover remains useful and distinct from current main; the follow-up fixes the prior test-registration finding, and no new discrete code defect was found.

Priority: P2
Reviewed head: 8f268c86239883007864b881c2ec49214280e344

Before merge

  • Add real behavior proof - Authority-chain proof required: the supplied body reports storage-boundary coverage, but provides no successful observations showing permitted saving, forbidden or revoked callers producing no new target writes, and revocation after admission blocking private-result delivery and widget capability execution while allowing the accepted saved mutation. Provide redacted logs or terminal output through the real owners or an authorized production-path harness, excluding IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security review attention item - No concrete exploit was established, but the changed authority boundary still needs final-effect proof.

Findings

None.

Tests

  • Missing end-to-end proof: Supply final-effect observations for allowed and forbidden callers, including revocation blocking private responses and widget actions; base-fail/head-pass execution of the replacement regression was not supplied.
Agent review details

How this fits together

Gateway dashboard handlers pass mutations and retained source authority to the Board store, which dispatches durable writes to the existing agent database worker and publishes committed invalidations.

flowchart TD
  A[Gateway dashboard request] --> B[Retained sharing authority]
  B --> C[Board admission]
  C --> D[Agent database worker]
  D --> E[Dashboard rows]
  D --> F[Committed invalidation]
  F --> G[Current disclosure check]
Loading

Technical review

Best possible solution:

Complete the existing worker cutover while preserving current authorization at private disclosure and widget capability effects.

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

Current-main source establishes the synchronous cross-store target fallback; no target code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Reusing the existing worker and sharing-facts owner is a focused solution, with an explicitly accepted revocation tradeoff and the legacy incognito owner retained.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 992724e0fd1f.

Provenance checked

  • Prepared Board source authority and native cross-store fallback changes intended behavior with a stated reason (c5cce7d: Preserve source authorization through transaction and commit while retaining synchronous opaque and cross-store guards.)
  • Actor Board authority composition changes intended behavior with a stated reason (cbc2017: Prepare Board consumers for the session actor storage owner while composing caller authority into actor mutations.)
  • Cross-store source regression coverage changes intended behavior with a stated reason (6f41a20: Verify target-read reduction while retaining source-permission enforcement through the native write effect.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete exploit was established, but the changed authority boundary still needs final-effect proof.

Evidence

What I checked:

  • Current main still uses the cross-store fallback: Fetched main prepares source authority and selects the native target transaction for nativeSource; the introduced worker cutover remains necessary. (src/boards/sqlite-board-store.ts:268, 992724e0fd1f)
  • Maintainer accepted the persistence tradeoff: The maintainer-authored body explicitly accepts completion after source revocation for already admitted writes and explains removal of transaction, commit, and cleanup source checks; another product approval is unnecessary. (src/boards/sqlite-board-store.ts:309, 8f268c862398)
  • Prior finding repaired: The follow-up registers the authority suite in databaseWorkerCoreTestFiles and uses the authenticated profile ID for membership and revocation. (test/vitest/vitest.database-worker-core-paths.mjs:571, 8f268c862398)
  • Disclosure and capability checks remain separate: Dashboard mutation handlers check authority after awaited writes before responding; capability execution separately checks the live widget ticket and stored grant through useCurrent. (src/gateway/board-host-tools.ts:105, 8f268c862398)
  • No stored-format migration introduced: The introduced diff changes routing and runtime authority inputs while retaining the existing Board mutation kernels, schemas, and serialized formats. (src/boards/sqlite-board-store.worker.ts:23, 8f268c862398)
  • Authority coverage does not reach all final effects: The added production-owner harness covers permitted mutations, revoked-source rejection, admitted completion, and pending or unknown publication denial, but does not exercise private RPC response delivery or widget capability execution after revocation. (src/boards/sqlite-board-source-authority.test.ts:48, 8f268c862398)

PR surface

Source -95, Tests +63, Docs +13. Total -19 across 11 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 14 109 -95
Tests 3 144 81 +63
Docs 3 25 12 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 183 202 -19

Review metrics

Metric Value Why it matters
Production versus test changes Production +14/−109; tests +143/−81 The cutover removes duplicate authority machinery, while replacement tests cover the changed admission contract.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded dashboard storage improvement that reduces synchronous Gateway work.
  • merge-risk: 🚨 security-boundary: Source authorization moves from transaction and commit to admission; the maintainer accepts in-flight persistence after revocation, while final-effect authorization evidence remains required.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect proof showing that revoked or never-authorized callers cannot write, receive private snapshots, or execute widget capabilities, while already admitted persistence may complete.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-13T02:52:59.915Z sha 393f995 :: needs real behavior proof before merge. :: [P2] Register the authority suite in the database-worker test lane

Reviewed October 12, 2026, 11:03 PM ET / October 13, 2026, 03:03 UTC (Revision 2).

Use the authenticated profile ID for shared-session membership and revocation, and register the boundary tests in the existing database-worker core lane.
@steipete

Copy link
Copy Markdown
Contributor Author

Reviewed the additional final-effect proof request. The new production-owner regression covers allowed writes, revoked-source denial, pending/unknown denial, and the explicitly accepted completion of an already-admitted write. The RPC mutation handlers still call authority.assertActive() after the awaited mutation and before publishing a response; widget capability dispatch and result delivery retain their separate useCurrent checks. Those security boundaries are unchanged.

Follow-up: add a combined RPC-level scenario that demonstrates admitted persistence alongside denied private response delivery and denied widget capability execution after revocation. The review identifies no concrete exploit or new code defect; this broader proof request is non-blocking under the maintainer's relaxed landing policy. No further review round is requested.

@steipete
steipete merged commit 6b654df into main Oct 13, 2026
141 checks passed
@steipete
steipete deleted the dbasync/boardauth branch October 13, 2026 05:22
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…ad (openclaw#170541)

Check retained source authority once at admission and dispatch durable Board mutations through the existing target worker. Source revocation denies new admissions while already-admitted writes may finish.

Remove duplicate source preparation and worker revalidation; preserve target identity, lifecycle, and private-content disclosure checks. Add boundary regressions and document revocation behavior. Legacy process-held incognito retains its native path pending the session-storage owner cutover.

Warmed causal SQL is unchanged at 170.2 statements and 41.3 requests per turn, with zero MAIN statements; the shared harness contains no Board writes. Production diff: +14/-109 lines.
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 gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant