Skip to content

refactor(sessions): move persisted member writes off the Gateway thread - #153194

Closed
steipete wants to merge 1 commit into
mainfrom
codex/session-sharing-member-writes-20260919
Closed

steipete wants to merge 1 commit into
mainfrom
codex/session-sharing-member-writes-20260919

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Builds on the agent database execution foundation in #153150 and test isolation in #153286, both landed on main. This PR targets main.

What Problem This Solves

Adding or removing a persisted session member executes ordinary SQLite writes on the Gateway thread.

User Impact

Membership row mutations now run through the existing agent database worker. Authorization, responses, events, private database permissions, duplicate adds, and absent removals keep their existing behavior. Incognito membership retains its process-held native owner. No schema, retention, RPC, SDK, or migration contract changes.

Why This Change Was Made

Finite membership commands use the canonical agent executor and synchronous connection-bound kernels. Transaction and commit admission revalidate live manager authority, and the transaction checks the exact session instance and removal compare-and-swap conditions. Callers await durable completion.

The current-main integration preserves retained sharing facts: acknowledged writes update the existing projection before row observers run, while uncertain outcomes invalidate it. The retained-authorization regression fails with raw publication and passes for both durable and incognito stores after this integration. Existing evidence codecs moved to their sharing-identity owner without changing values or policy.

Evidence

Local validation below is bound to 054198a9a5394b5c8ab8c452479897ffb341b09f, based on main 7fb336731e19227871609972fb6f6c7cb071b6c0. Hosted checks and review must bind the new published head.

  • All 141 focused cases across 11 files passed, including registered Gateway mutations, recovery and GitHub publication callers, retained authorization, exact-instance/removal checks, events, permission repair, physical ownership, and worker cleanup.
  • All 247 routing controls, the complete normal selected checks, and pnpm build passed on the frozen current-main candidate. Fresh source and proof-harness review through P2 found no actionable findings.
  • Actual signed loopback Gateway proof passed 19 RPCs/nine mutations across cold, warm, and reopen flows, six durable readbacks, and two private-permission drift checks. It exited naturally with code 0 and no cleanup errors. Source, build artifacts, installation topology, runtime bytes, and the mapped SQLite provider stayed bound through final postflight.
  • Each RPC recorded zero host session_members DML. The full protected interval through reopen, cleanup, and exit also added no membership DML. All eight native methods plus construction were calibrated before product imports, with no reset. Late-write and unknown-database controls fail final acceptance.

The 11-file behavior wrapper took 664.11 seconds, including imports and transforms. The native worker/lifecycle and registered authorization boundaries require these real flows; helper-only tests would not exercise commit admission, physical store custody, or publication before observers.

This is the membership mutation cutover, not complete Gateway SQLite offload. The raw capture contains 5,488 native calls during RPCs and 17,477 overall, including calibration, fixture/bootstrap, authority/projection reads, and other native work. The only three membership-DML counter hits were intentional positive calibration. This compiled proof covers Node 24 on macOS, with its actual SQLite 3.53.4 provider; it makes no Bun claim.

@clawsweeper

clawsweeper Bot commented Sep 19, 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 commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 19, 2026
@steipete
steipete marked this pull request as ready for review September 19, 2026 22:32
Base automatically changed from codex/agent-foundation-protocol-policy-20260919 to main September 20, 2026 00:08
@steipete
steipete force-pushed the codex/session-sharing-member-writes-20260919 branch from 21cbbbb to 0604340 Compare September 20, 2026 00:57
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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 Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 5:34 AM ET / 09:34 UTC (Revision 2).

ClawSweeper review

What this changes

Moves persisted session membership changes to the existing database worker, updates callers to await completion, and preserves authorization and event ordering.

Merge readiness

✅ Ready for maintainer review

The change remains useful: current main and v2026.9.5 still perform membership writes synchronously. No actionable introduced defect was found, and the current mergeable head resolves the previous conflict concern.

Priority: P2
Reviewed head: 054198a9a5394b5c8ab8c452479897ffb341b09f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent worker cutover with relevant regression coverage and no blocking source finding; runtime results remain author-reported.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository-member author is exempt from the ordinary external proof gate. The head-bound body reports real Node 24/macOS Gateway membership RPCs with durable readbacks and zero host membership DML; raw traces were not independently inspected. Source preserves authorization and stored-data contracts.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository-member author is exempt from the ordinary external proof gate. The head-bound body reports real Node 24/macOS Gateway membership RPCs with durable readbacks and zero host membership DML; raw traces were not independently inspected. Source preserves authorization and stored-data contracts.
Evidence reviewed 10 items Current main still needs the change: Both membership operations still execute their SQL through synchronous runOpenClawAgentWriteTransaction on fetched main.
Latest release comparison: GitHub's v2026.9.5 source also contains synchronous membership writes. The release blob was inspected through GitHub after local retrieval failed.
Worker admission and publication: Persisted writes use the existing executor; its admission invokes current-authority checks at transaction and commit. Successful results update retained sharing facts before observers; uncertain outcomes invalidate them. Incognito writes retain their existing native owner.
Findings None None.
Security None None.

How this fits together

Session sharing controls who can access a conversation. Gateway membership requests authorize the caller, update the agent database, and publish committed access facts to readers and event subscribers.

flowchart TD
  A[Membership request] --> B[Current manager authorization]
  B --> C{Storage owner}
  C --> D[Persisted database worker]
  C --> E[Process-local incognito store]
  D --> F[Session check and transaction]
  E --> F
  F --> G[Committed sharing facts]
  G --> H[Events and RPC response]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +243, Tests +201, Docs +8. Total +452 across 39 files.

View PR surface stats
Area Files Added Removed Net
Source 7 393 150 +243
Tests 31 393 192 +201
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 39 794 342 +452

Review metrics

Metric Value Why it matters
Production versus test growth Production net +243 lines; tests and test support net +195 lines Production growth has a stated purpose: adapting membership operations to the existing worker and preserving completion semantics.

Technical review

Best possible solution:

Keep membership writes with the canonical worker while preserving live authorization, durable completion, and publication through the existing sharing owner.

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

Yes, source establishes that current-main membership RPCs execute synchronous SQLite writes on the Gateway thread; no runtime reproduction was executed during this review.

Is this the best way to solve the issue?

Yes, the patch extends the existing worker owner and migrates its callers without adding a competing persistence or authorization contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9dc3d48e789c.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Gateway responsiveness improvement with no demonstrated urgent user outage.
  • 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 repository-member author is exempt from the ordinary external proof gate. The head-bound body reports real Node 24/macOS Gateway membership RPCs with durable readbacks and zero host membership DML; raw traces were not independently inspected. Source preserves authorization and stored-data contracts.

Evidence

What I checked:

  • Current main still needs the change: Both membership operations still execute their SQL through synchronous runOpenClawAgentWriteTransaction on fetched main. (src/config/sessions/session-sharing-store.ts:76, 9dc3d48e789c)
  • Latest release comparison: GitHub's v2026.9.5 source also contains synchronous membership writes. The release blob was inspected through GitHub after local retrieval failed. (src/config/sessions/session-sharing-store.ts, ec9c1a13db89)
  • Worker admission and publication: Persisted writes use the existing executor; its admission invokes current-authority checks at transaction and commit. Successful results update retained sharing facts before observers; uncertain outcomes invalidate them. Incognito writes retain their existing native owner. (src/config/sessions/session-sharing-store.ts:65, 054198a9a539)
  • Authorization and caller cutover: Both production membership callers await completion and supply current manager checks. The worker retains exact session-instance validation and conditional removal; repository searches found no remaining synchronous production caller. (src/gateway/server-methods/sessions-sharing.ts:593, 054198a9a539)
  • Regression coverage: Inspected coverage checks revoked authority without a persisted member, stale session rejection, committed publication ordering, physical-store ownership, permission repair, and retained authorization after add/remove. Existing executor coverage checks rollback when authority is revoked before commit. Tests were not executed in this read-only review. (src/config/sessions/session-sharing-store.test.ts:25, 054198a9a539)
  • Head-bound validation report: The supplied body snapshot, sourceRevision a52a9387cc637120cae34dcb18180ece420f5587ddc16288951977dec4326c4c, reports signed loopback Gateway validation on this head: 19 RPCs, nine mutations, six durable readbacks, two permission-drift checks, and zero host membership DML outside positive calibration. It also reports 141 focused cases and 247 routing controls passing. These are author-reported observations; no raw capture or linked media was supplied for independent inspection. (054198a9a539)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (1 earlier review cycle)
  • reviewed September 22, 2026, 12:47 AM ET / 04:47 UTC sha unknown :: needs changes before merge. :: none

Run persisted membership mutations in the canonical agent executor while retaining exact session and commit authority checks. Publish committed member facts through the current sharing projection owner before observers, keep uncertain outcomes invalidating, and migrate internal callers to awaited completion.
@steipete
steipete force-pushed the codex/session-sharing-member-writes-20260919 branch from 0604340 to 054198a Compare September 22, 2026 09:26
@steipete

Copy link
Copy Markdown
Contributor Author

Superseded by #155620 (cf32d5a), which landed the durable membership writes through the existing worker and write-admission owners alongside the membership projection work. This PR’s implementation and qualification remain useful provenance, but carrying its separate worker now would duplicate the landed owner.

I checked the remaining behavior difference using the registered sharing handlers and real SQLite with the write queue held. The landed implementation retains the originally selected physical store across a route-only config change, as the storage contract permits. It still rejects revoked manager authority and replacement session instances. All 20 sharing tests and controls passed on the landed commit; the identical route comparison also confirmed why 054198 behaved more strictly. No missing required behavior was established.

The earlier compiled measurements remain attributed to 054198 and are not a claim about all native SQLite calls on current main. Closing as superseded, not merged through this PR.

@steipete steipete closed this Sep 22, 2026
@RomneyDa
RomneyDa deleted the codex/session-sharing-member-writes-20260919 branch October 22, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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