Skip to content

refactor(sessions): finish suggestion list worker reads - #163546

Merged
steipete merged 1 commit into
mainfrom
dbasync/s17
Oct 2, 2026
Merged

steipete merged 1 commit into
mainfrom
dbasync/s17

Conversation

@steipete

@steipete steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Related: #148951, #163030

What Problem This Solves

Suggestion listing still queried SQLite on the Gateway thread after suggestion writes moved to the collaboration worker.

Why This Change Was Made

Route listing through the existing read-only session worker and retain the original store and session facts through the asynchronous read. Normalize bare session keys after the reader discovers the store owner. Recheck the caller, committed sharing policy, membership, and session lifetime before returning rows. A member downgraded to viewer receives only their own suggestions. Remove the synchronous list API and the unused native-write re-exports from the sessions barrel.

The existing add, claim, release, and finalization worker operations retain their transaction/commit authority checks and the distinction between revocable requests and accepted-input settlement.

User Impact

Listing preserves ordering and visibility while its database work executes in a worker. No configuration or migration is needed.

  • Registered list-handler proof: 11 caller-thread SQLite calls on the pinned base → 0 on the candidate, including a rejected-read path with no native fallback.
  • Static owner inventory: 13 T1 → 13 T1 (session-suggestion-store.ts: 4; kernel: 9). These shared implementations still serve the process-held incognito owner; no inventory classification was changed.
  • Production LOC: +182 / −55 / net +127. No changes to the worker broker.

Evidence

Initial base: 37ae73947bf07fc562ba935c4581283b4b80ecb2. Main was integrated at pinned base cee0906f3877c436725a079d4e41537fc204f75c without changing the suggestion write protocol. The complete final selection passed 76 tests in 178.65 s after the bare-key correction (OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=1800000 pnpm test with all seven files below and --maxWorkers=1).

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=1800000 pnpm test <file> --maxWorkers=1 individual-file cost measurements are below (the storage and visibility measurements include the final read correction):

File Tests Wall time
src/config/sessions/session-suggestion-store.test.ts 10 90.32 s
src/gateway/server-methods/sessions-suggestions.visibility.test.ts 10 44.37 s
src/gateway/server-methods/sessions-suggestions.test.ts 29 116.77 s
src/gateway/server-methods/session-metadata.admission.test.ts 14 71.16 s
src/gateway/server-methods/sessions-suggestions.provider-review.test.ts 5 45.36 s
src/gateway/server-methods/sessions-suggestions.store-binding.test.ts 4 53.31 s
src/gateway/server-methods/sessions-suggestions.custody.test.ts 4 110.70 s

The existing fixture-heavy suites protect transaction admission, exactly-once dispatch, real chat custody, provider refusal, and alias/incognito ownership; only their list assertions now await the read. New visibility cases use deferred worker replies, without timers or new production test seams. Wall times include compilation on the loaded development host; hosted CI seconds are not yet available.

The negative boundary proof restored the list owner, barrel, and registered handler to the pinned base and failed on 4 prepares, 5 gets, and 2 alls. Candidate source bytes were restored before the passing tests.

  • node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime: passed before integration; integrated tests compile the current worker sources.
  • node scripts/check-changed.mjs --base 37ae73947bf07fc562ba935c4581283b4b80ecb2: passed before integration, including all 27 test typecheck graphs and touched-file lint.
  • Final node scripts/check-changed.mjs --base cee0906f3877c436725a079d4e41537fc204f75c -- <16 changed paths> stops at an inherited environment-name budget failure from improve(agents): explain unknown tool outcomes and assert append-only request history #163379: 477 names versus budget 476. Using the repository collector on that exact base and this candidate proves both contain the identical 477 names, with no added or removed names in this PR. The budget is unchanged; this unrelated failure is reported rather than suppressed.
  • Post-integration pnpm tsgo:core, targeted node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json on the changed read/type files, and the line-cap ratchet: passed.
  • Post-integration pnpm check:madge-import-cycles: 0 cycles.
  • pnpm check:database-worker-ratchet --base cee0906f3877c436725a079d4e41537fc204f75c: passed; unchanged owner counts were also measured directly on this base and the candidate.
  • node scripts/database-worker-inventory.mjs --json, plus its inventory(root, pinnedBase) API for the base: owner counts above.
  • Fresh Codex autoreview through P2 against the pinned integration base: no actionable findings.

Local validation recovered from a test-fixture measurement error and an artifact snapshot collision by moving client setup outside the observer and serializing build/test compilation. The missing-table test now expects the existing worker admission error and still proves the table is not recreated. A new bare-key assertion caught eager owner resolution during implementation; it passes with normalization deferred until worker discovery.

Compatibility Retained

Process-held incognito databases keep their existing native owner. The synchronous add/claim/release/finalize helpers remain internal worker/incognito implementations; no public plugin SDK contract changed. Disk listing has one asynchronous path, with no synchronous fallback.

Update Behavior

No schema, stored-format, durability, retention, configuration, or permission changes. Existing installed state remains valid; no migration or Doctor/updater changes are required.

Move durable listing through the existing read worker and recheck current caller, sharing policy, and retained session facts before responding. Preserve the existing claim and accepted-input settlement protocol and native incognito owner. Integrate the pinned main snapshot for the session worker contract.
@clawsweeper

clawsweeper Bot commented Oct 2, 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 gateway Gateway runtime size: M labels Oct 2, 2026
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 9:31 AM ET / 13:31 UTC (Revision 3).

ClawSweeper review

What this changes

Moves disk-backed session suggestion listing into the existing read worker and rechecks access before returning results, while preserving native incognito reads.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main and the latest release still list suggestions synchronously. No actionable introduced defect or additional merge blocker was found.

Priority: P2
Reviewed head: b798a01e2d9b6347a75d45d1904f3e664081f699

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coherent worker cutover with meaningful boundary coverage and no actionable introduced findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The host identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Inspected production-handler/real-worker coverage and the captured execution report support the listing cutover, rejection propagation, and final-response access checks; no unresolved authority-chain proof requirement was established. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The host identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Inspected production-handler/real-worker coverage and the captured execution report support the listing cutover, rejection propagation, and final-response access checks; no unresolved authority-chain proof requirement was established. No stored-data contract changes.
Evidence reviewed 9 items Introduced change ownership: Reviewed the pinned merge-base-to-head delta, rather than attributing endpoint drift to this PR. The introduced changes concern suggestion reads, worker contracts, the registered handler, and their regression coverage.
Current main still needs the cutover: Fetched main retains the synchronous handler and calls listSessionSuggestions directly before responding. The requested worker read is therefore not already implemented there.
Latest release retains synchronous listing: The v2026.9.7 source also calls the synchronous listing API. This release does not supersede the PR.
Findings None None.
Security None None.

How this fits together

Session suggestions let people propose input to shared conversations. The Gateway reads their stored suggestions, applies current sharing permissions, and returns the visible rows to the requesting client.

flowchart TD
  A[Client list request] --> B[Retain session and store facts]
  B --> C{Storage owner}
  C --> D[Disk read worker]
  C --> E[Native incognito reader]
  D --> F[Recheck current access]
  E --> F
  F --> G[Filtered response or refusal]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +127, Tests +158. Total +285 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 10 182 55 +127
Tests 6 190 32 +158
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 372 87 +285

Review metrics

Metric Value Why it matters
Code growth justification Production net +127 lines; tests net +158 lines Growth supplies the worker read contract and response-time access checks while reusing the existing query kernel and worker broker.

Technical review

Best possible solution:

Keep one worker-backed disk listing owner with current-access filtering at response time and the existing incognito lifecycle owner.

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

Not applicable to a functional bug reproduction: this is an execution-boundary refactor, and current-main source directly confirms synchronous listing. No tests were executed in this read-only review.

Is this the best way to solve the issue?

Yes: extending the existing read worker and shared query kernel is a focused cutover, and the final response uses current access facts rather than pre-await authorization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 155613d6dd6e.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded runtime improvement that removes synchronous database work from suggestion listing.
  • 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 host identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Inspected production-handler/real-worker coverage and the captured execution report support the listing cutover, rejection propagation, and final-response access checks; no unresolved authority-chain proof requirement was established. No stored-data contract changes.

Evidence

What I checked:

  • Introduced change ownership: Reviewed the pinned merge-base-to-head delta, rather than attributing endpoint drift to this PR. The introduced changes concern suggestion reads, worker contracts, the registered handler, and their regression coverage. (b798a01e2d9b)
  • Current main still needs the cutover: Fetched main retains the synchronous handler and calls listSessionSuggestions directly before responding. The requested worker read is therefore not already implemented there. (src/gateway/server-methods/sessions-suggestions.ts:192, 155613d6dd6e)
  • Latest release retains synchronous listing: The v2026.9.7 source also calls the synchronous listing API. This release does not supersede the PR. (src/gateway/server-methods/sessions-suggestions.ts:279, c074824a27c9)
  • One disk read path: The new reader delegates disk access to the existing worker and shared query kernel, normalizes bare keys after owner discovery, and retains existing process-held incognito access. Repository-wide references show callers use the asynchronous API; no synchronous disk fallback was introduced. (src/config/sessions/session-suggestion-store.read.ts:11, b798a01e2d9b)
  • Final response authorization: The handler retains the original session/store facts and checks cancellation, connection authority, identity, committed sharing policy, and current membership before and after the worker read. Filtering and response occur synchronously after the final check. No stored authority or changed permission policy was introduced. (src/gateway/server-methods/sessions-suggestions.ts:260, b798a01e2d9b)
  • Boundary and stale-access coverage: Inspected cases invoke the production handler and real worker, inject rejection or delay after a real reply, and check zero caller-thread SQLite, policy downgrade filtering, profile/disconnection refusal, and session replacement rejection. Existing cases cover hidden roles, drafts, committed policy, and incognito access. The captured PR body reports 76 passing cases and a negative control of 11 caller-thread SQLite calls on the base versus zero on the candidate; these executions were not repeated during this review. (src/gateway/server-methods/sessions-suggestions.visibility.test.ts:37, b798a01e2d9b)

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-10-02T13:19:59.812Z sha b798a01 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-02T13:24:52.677Z sha b798a01 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 2, 2026
@steipete
steipete merged commit 05c3782 into main Oct 2, 2026
134 checks passed
@steipete
steipete deleted the dbasync/s17 branch October 2, 2026 13:33
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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