Skip to content

refactor(boards): move session admission and presentation reads to workers - #165799

Merged
steipete merged 3 commits into
mainfrom
dbasync/w5board
Oct 5, 2026
Merged

steipete merged 3 commits into
mainfrom
dbasync/w5board

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Durable Board writes repeatedly read session existence on the Gateway thread, and session presentation could fall back to a native Board-membership query. Board work also needs to reject a replaced session or revoked membership after asynchronous preparation.

Why This Change Was Made

The existing exact-session reader prepares the durable session identity inside the existing write FIFO. The existing Board worker compares that identity and prepared source predicates in its synchronous transaction and again at commit; host grants retain current runtime authority. The existing owner publishes acknowledged changes once and joins cleanup without replaying unknown outcomes. Session rows reuse prepared Board facts and leave missing facts dirty for their reader owner.

Opaque and cross-store callbacks retain native atomicity for the shipped synchronous Gateway request guard contract (v2026.9.8, gateway-runtime.ts:46 and shared-types.ts:477). Bundled Board and GitHub adapters preserve preparation through the existing source-authority composition. The real server-close regression joins accepted Board work before closing database transports.

Production scope: +316 / −89, net +227; 405 changed lines. This is the separate Board owner half of the wave-5 Goal/Board work.

User Impact

Ordinary Board writes and prepared session presentation move those reads off the caller thread while preserving write ordering, current authorization, and acknowledged results. The change preserves schema, durability, retention, dependencies, environment names, and public method signatures. Incognito remains with its existing owner.

Evidence

The real durable write fixture reduces caller-thread session-existence SQL from 12 calls / 0.243249 ms to 0 calls / 0 ms. The physical-target presentation fixture reduces Board-membership SQL from 1 call to 0 (single-call presentation duration 1.737167 ms → 0.621500 ms, not an end-to-end latency benchmark). The baseline was 2a6621faf75c0a5914e5f5e24ce6f2b692d5b85e; the durable admission expressions and membership reader are unchanged at the original base a33accd27f3d and the fresh rebase base 0e54386a46344884e0317c21b81d21b29ccdb615.

The database-worker ratchet passes: T1 848 → 848, Board 12 → 12. The static expressions still serve excluded incognito/native compatibility consumers; no metadata reclassification claims a static reduction. Runtime boundary tests assert zero caller SQL for the moved reads and zero same-owner session/member reads inside ordinary Board worker grants.

Pre-rebase validation covers 241 tests across 21 Board, projection, lifecycle, and configuration files with --maxWorkers=1, plus the import/GitHub/close evidence below. Each initially failing fixture listed below was repaired and its affected suite or cases passed. The existing host-owned/fork projects already supply the necessary owners, so no routing change was needed.

Proof Result and measured wall time
Outcome delivery 5 passed; 14.30 s project time
Gateway methods, session presentation, accepted/prepared/list rows, deletion and face callers 154 passed plus 2 old synchronous-read fixture failures in 517.17 s; the two repaired cases passed in 20.31 s (22.80 s command wall)
Native/incognito/worker/parity 57 passed plus 1 malformed-placeholder fixture failure in 79.70 s; full repaired parity suite passed 21 tests in 53.11 s
Final parity and reset/reclamation callers 43 passed; 124.62 s command wall (53.11 s parity + 52.10 s config projects)
Shared-registry import rule Runtime process build graph, wrapper source closure, eager import closure, all 10 discovered import suites, and GitHub identity tests passed; 340.77 s across 7 shards
Real close order Accepted Board write settles before database transport closure; regression passed (16.081 s test time). The grouped MCP/close/GitHub command took 570.44 s wall time and had one membership-fixture failure, repaired and passed in the final gateway selection
Final typecheck Core passed in 11.00 s; changed-test boundary/graphs passed in 82.12 s (gateway-root, other, gateway-methods)
Other gates Final lint/format, schema/storage/sidecar/auth checks, Madge (0 cycles), worker ratchet and Codex P2 review passed

The fixture repairs preserve behavior rather than accept absent/stale output: keyed reads now use the same withReadySessionRows boundary as sessions.describe, still checking the newest label, source entry, and unchanged generation; they record a second worker read instead of a hidden native reread. The transcript-only case now creates a valid retained placeholder through the real deletion lifecycle and still requires the Board not_found rejection. The outcome fixture supplies prepared process authority so it continues exercising committed worker delivery and cleanup failure. All repaired cases failed before the corresponding fixture update. CI elapsed seconds are not yet available; these are local measured times.

The earlier check-changed run completed production/core-test type graphs, formatting, storage/source guards, and the remaining selected commands, with three inherited Knip findings. Fresh main removes those stale browser/media exports in b2750b2346051; the post-rebase dead-export guard now passes all three scans with zero entries in 85.84s.

Rebased cleanly onto 0e54386a4634, yielding 4cf3d33053ec. git range-diff confirms both commits are patch-identical to the reviewed versions, and all 11 production files have identical blobs. Main added the worker job observation hook to the outcome-test fixture and updated documentation. The prior clean P2 review remains applicable; focused suites are rerun after rebase. The post-rebase focused command passed 139 tests across 11 files, with 1 existing skip, in 337.52s wall time (--maxWorkers=1). It covers outcome delivery, worker/native/incognito/parity behavior, Board/progress admission, MCP authority, row facts, accepted/prepared presentation, and the real server-close order. The refreshed worker ratchet and SDK source-budget check also passed.

The post-rebase SDK source budget passes (151 public entrypoints / 3,648 exports / 2,110 callable exports). The full API diff from a33accd27f3d3331d0d42d8915038d3aa47b2421 to the reviewed pre-rebase head 36f4917caf684faaf9d5598ecc306b9303e98d7c has no entrypoint or direct-export change; digest 75ac1559 reports 128 reachable-export hashes from two internal namespace changes: exporting the shared source-refusal predicate helper and removing the superseded materializer readEntry callback. Existing public method signatures are unchanged. The removed callback is a required input to an internal factory, with its sole construction path migrated; returned callable APIs are unchanged. The landing audit also checked v2026.10.1-beta.1 (latest tag) and v2026.9.8 (latest stable): both expose the synchronous Gateway request guard, which this change preserves. The changed Board backend/kernel and materializer inputs are internal; none is exported through a released SDK subpath or api.runtime. No other-owner host SQL was identified in the bundled Board grant chain; opaque/cross-store callbacks retain the native compatibility route.

Sibling Goal PR: #165785. Potential overlapping work: #165370, #165552, #165205 (session-authority/storage documentation) and #162433 (standing umbrella ownership work). The base already contains #165028, #165454, and #165601; their changes are preserved. Incognito expressions remain outside this PR's scope.

Package and update qualification

Passed: canonical package build/validation and the published 2026.9.8 driver × candidate update cell. The package embeds reviewed commit 4cf3d33053ec82afa1ca1f6a94c6b5ef98c91d50, version 2026.9.8, build ID 2026.9.8-4cf3d33053ec-2026-10-05T21-28-55.262Z; tarball SHA-256 is a12a8015552b673bd48b6e384264ad33733f9afb440082eb81b0e6de961eb491. The final head differs only in the five test files described below: production, package/dependency, schema, and build inputs are unchanged, so this is reused unchanged-input qualification, not a claim that the package embeds the later test-only commit.

AWS run run_67c8f8d8226162c25814cba6f949787c completed package integrity/import validation and the canonical update cell. The cell records phase: finished, /readyz: 200, running version 2026.9.8, updater exit code 0, and a terminated updater process tree. Update time was 400.280s; complete cell 492.83s; package phase 673.587s. Durable sessions across two agents survived and incognito state did not survive restart. This canonical cell does not explicitly seed a Board row; separate real durable Board parity/persistence tests cover that owner, and no Board schema or serialized-data change was introduced.

Testbox timed out without a runner after 15 minutes and was stopped. The initial AWS attempt failed at broker event attribution before payload; its outcome was reconciled before reusing the healthy lease. Both product gates then exited 0. The outer proof command exited 1 only afterward because its evidence archive was created inside the directory being archived (tar: .: file changed as we read it); collection was repaired outside that directory without rerunning either gate. Verified evidence archive SHA-256: 3db1632c2d98d1cfa42bc32d91492a6f92c3a3999936becaa8901ca536e5f641.

Landing validation

Repair commit 2b638d373d499b484a8ed0ee8c7be7355c73a836 updates only five tests. Exact-head CI run 37373560142 found seven failing assertions across those files. Every file failed in five single-file runs on 4cf3d33053ec and passed in five runs on merge base 0e54386a4634: these were deterministic fixture failures introduced by the cutover, not inherited failures or flakes.

The synthetic Board WebSocket registered an admin client but dispatched with client: null. It now dispatches that registered client while preserving stale-root denial, zero writes/events, and fresh-root success. Projection fixtures use the existing prepared-row boundary; all synchronous membership/revocation assertions remain before the await. The worker-race fixture replaces an obsolete native-cache mock with a real committed replacement, immediate old-generation revocation, and a sessions.describe response check. Production files are identical to the reviewed 4cf3d33053ec head.

Repaired proof (pnpm test <file> --maxWorkers=1) Result Local wall time Original CI file time
Board runtime boundaries 13 passed 101.31 s 16.40 s
Session resolution 18 passed 72.493 s Shared 39.67 s shard
Worker reads 17 passed 145.778 s Shared 12.34 s shard
Projection backfill 13 passed 36.221 s Shared 17.23 s shard
Membership publication 4 passed 28.456 s See original CI job

The two affected test-type graphs pass (Gateway root 17.2 s, Gateway methods 16.5 s). Type-aware lint, formatting, diff checks, and a fresh isolated Codex P2 review pass. The review specifically retained the synchronous membership assertions and confirmed real replacement/describe coverage.

The initial PR-context check failed because its required heading was named Problem; the body now uses the repository template headings and passes the local policy evaluator. One UI job was cancelled without a runner or any executed step during the GitHub Actions incident; its coverage was not run. The repaired head passed CI run 37377312855, with no failed jobs.

ClawSweeper completed review of the final head 2b638d373d499b484a8ed0ee8c7be7355c73a836 at 2026-10-05 21:46:09 UTC, with no actionable code or security findings. Its outstanding package/update qualification is supplied above, including exact artifact identity and applicability to the test-only repair.

Prepare durable session existence and sharing authority through the existing readers, then reread the captured session and source predicates at Board transaction and commit. Preserve source preparation through GitHub identity selection and carry worker-prepared Board membership into presentation.

Retain synchronous opaque SDK and cross-store guards and the incognito owner. Join accepted source cleanup, preserve publication and unknown-outcome behavior, and add worker-grant and Gateway-close coverage. No schema, permission-policy, retention, or update migration changes.
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 5, 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. 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 Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 5:46 PM ET / 21:46 UTC (Revision 2).

ClawSweeper review

What this changes

Moves durable Board session admission and session-list Board facts into existing database workers while preserving authorization, write ordering, and committed publication.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/boards/sqlite-board-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 - 3 items remain

This remains useful work beyond current main. The fixture repairs preserve the relevant invariants, and no actionable correctness or security finding remains; the previously required package/update qualification is still outstanding.

Priority: P2
Reviewed head: 2b638d373d499b484a8ed0ee8c7be7355c73a836

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation and repaired boundary coverage are sound, with an explicit package/update qualification gate still outstanding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts ordinary contributor proof. Inspected Board/Gateway fixtures cover replacement, membership revocation, committed publication, and shutdown; their reported passes were not rerun here. Package/update qualification remains separately required, and no stored-data format or schema change was introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts ordinary contributor proof. Inspected Board/Gateway fixtures cover replacement, membership revocation, committed publication, and shutdown; their reported passes were not rerun here. Package/update qualification remains separately required, and no stored-data format or schema change was introduced.
Evidence reviewed 9 items Pinned introduction and review continuity: Reviewed the introduced delta from 0e54386 to 2b638d3. The delta since the previous reviewed head changes only five test files; production code is unchanged. The supplied test merge is stale and was not used to infer merge-result regressions.
Current main still needs the Board cutover: Fetched main still calls requireExistingSession on the caller thread and opens the Board worker without prepared session/source predicates. Its materializer still uses the native readEntry fallback. The adjacent merged session-worker changes therefore do not supersede this Board work.
Authority reaches transaction and commit: The existing FIFO prepares exact session identity and source authority. The Board worker rereads source predicates at transaction and commit admission, checks session identity before mutation and commit, and retains host liveness checks through publication. The MCP boundary case removes real membership during awaited preparation and asserts no destination widget, broadcast, or tool effect.
Findings None None.
Security None None.

How this fits together

Boards store session dashboards and widgets. Gateway requests enter the Board store, which checks session and caller authority before committing changes; prepared database facts then feed session presentation.

flowchart TD
  A[Gateway Board request] --> B[Existing write queue]
  B --> C[Session reader prepares facts]
  C --> D[Board worker checks session and membership]
  E[Live caller authority] --> D
  D --> F[Commit Board changes]
  F --> G[Publish changes and session rows]
Loading

Before merge

  • Resolve merge risk (P1) - Installed worker loading and preservation of existing durable Board/session state remain unqualified until canonical package validation and the required published-driver update cell complete.
  • Complete next step (P2) - Record passing canonical package validation and the published-2026.9.8-driver update cell, with artifact identity and verified applicability to the pinned head.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +227, Tests +213, Docs +11. Total +451 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 11 316 89 +227
Tests 14 297 84 +213
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 26 624 173 +451

Review metrics

Metric Value Why it matters
Production versus test growth production net +227; tests and test support net +213 Production growth supports prepared authority and retained cleanup; the added boundary coverage checks the corresponding cutover invariants.

Stored data model

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

Merge-risk options

Maintainer options:

  1. Complete package and update qualification (recommended)
    Record passing canonical package validation and the published-2026.9.8-driver update result, identifying the artifact and its applicability to the pinned candidate.

Technical review

Best possible solution:

Keep the existing worker and publication owners, preserve released synchronous guards, and qualify the packaged candidate against existing operator state before landing.

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

Not applicable as a refactor; current main source confirms the caller-thread reads being moved. This read-only review did not execute the reported measurements or tests.

Is this the best way to solve the issue?

Yes: extending the existing readers, Board worker, and source-authority composition preserves a single owner for each responsibility; the remaining uncertainty is packaged upgrade behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 89792e5aeb98.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded database-worker improvement without evidence of an urgent user-facing regression.
  • merge-risk: 🚨 compatibility: Moving admission for persisted Board writes requires the explicitly outstanding installed-package and published-driver upgrade qualification.
  • 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 supplied MEMBER association exempts ordinary contributor proof. Inspected Board/Gateway fixtures cover replacement, membership revocation, committed publication, and shutdown; their reported passes were not rerun here. Package/update qualification remains separately required, and no stored-data format or schema change was introduced.

Evidence

What I checked:

  • Pinned introduction and review continuity: Reviewed the introduced delta from 0e54386 to 2b638d3. The delta since the previous reviewed head changes only five test files; production code is unchanged. The supplied test merge is stale and was not used to infer merge-result regressions. (2b638d373d49)
  • Current main still needs the Board cutover: Fetched main still calls requireExistingSession on the caller thread and opens the Board worker without prepared session/source predicates. Its materializer still uses the native readEntry fallback. The adjacent merged session-worker changes therefore do not supersede this Board work. (src/boards/sqlite-board-store.ts:244, 89792e5aeb98)
  • Authority reaches transaction and commit: The existing FIFO prepares exact session identity and source authority. The Board worker rereads source predicates at transaction and commit admission, checks session identity before mutation and commit, and retains host liveness checks through publication. The MCP boundary case removes real membership during awaited preparation and asserts no destination widget, broadcast, or tool effect. (src/boards/sqlite-board-store.worker.ts:62, 2b638d373d49)
  • Revocation boundary coverage: The shared-session case revokes membership before releasing source-policy preparation, then checks rejection and absence of persisted destination state and outward effects. Worker cases separately cover target changes at transaction and commit grants and session replacement during preparation. (src/gateway/server-methods/board.mcp-admission.test.ts:305, 2b638d373d49)
  • Fixture repairs retain immediate invariants: The replacement race now commits a real session replacement, immediately verifies old-generation revocation, and checks the sessions.describe response. Membership observers still verify final committed membership synchronously before the new readiness await. The WebSocket fixture dispatches its registered client and retains stale-root denial and fresh-root success. (src/gateway/session-row-projection.worker-read.test.ts:313, 2b638d373d49)
  • Released synchronous guard contract: The v2026.9.8 gateway-runtime SDK exports GatewayRequestHandlerOptions, whose released shared types include synchronous sessionMutationCommitGuard and SessionMutationAuthorization.assertCurrent. The introduced native route preserves opaque and cross-store callbacks rather than changing that public contract. (src/gateway/server-methods/shared-types.ts:477, fc23bc864e45)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Attach passing canonical package validation and published-driver update evidence for the candidate, with source and artifact identity.

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 (1 earlier review cycle)
  • reviewed 2026-10-05T21:21:46.317Z sha 4cf3d33 :: blocked before merge. :: none

Dispatch the synthetic Board WebSocket's registered client and use the
existing prepared-row boundaries in projection fixtures. Preserve immediate
membership and lifecycle revocation assertions; replace the obsolete native
cache mock with a committed replacement observed through sessions.describe.

The five affected files failed in five runs each on the prior PR head and
passed in five runs each on its merge base. All 65 repaired tests, affected
test typechecks, lint, formatting, and a fresh P2 review pass.
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit c5cce7d into main Oct 5, 2026
144 of 145 checks passed
@steipete
steipete deleted the dbasync/w5board branch October 5, 2026 21:57
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…rkers (openclaw#165799)

* refactor(boards): prepare session admission and authority in workers

Prepare durable session existence and sharing authority through the existing readers, then reread the captured session and source predicates at Board transaction and commit. Preserve source preparation through GitHub identity selection and carry worker-prepared Board membership into presentation.

Retain synchronous opaque SDK and cross-store guards and the incognito owner. Join accepted source cleanup, preserve publication and unknown-outcome behavior, and add worker-grant and Gateway-close coverage. No schema, permission-policy, retention, or update migration changes.

* test(boards): align admission fixtures with worker owners

* test(boards): prepare worker-backed runtime fixtures

Dispatch the synthetic Board WebSocket's registered client and use the
existing prepared-row boundaries in projection fixtures. Preserve immediate
membership and lifecycle revocation assertions; replace the obsolete native
cache mock with a committed replacement observed through sessions.describe.

The five affected files failed in five runs each on the prior PR head and
passed in five runs each on its merge base. All 65 repaired tests, affected
test typechecks, lint, formatting, and a fresh P2 review pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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