Skip to content

improve: keep first-use session categories off the Gateway thread - #150565

Merged
steipete merged 2 commits into
mainfrom
codex/session-group-registration-worker-main7331-20260916
Sep 20, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/session-group-registration-worker-main7331-20260916

Conversation

@steipete

@steipete steipete commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144592

What Problem This Solves

Creating a session or assigning a first-use category performs synchronous catalog registration on the Gateway thread.

User Impact

Registration runs off the Gateway thread while creation and patch requests still wait for its result before publishing group notifications. Existing categories avoid writer admission. A catalog failure preserves the saved session and produces a warning; repeating the same category assignment can repair the catalog. No schema, configuration, migration, or retention changes are required.

Why This Change Was Made

The existing shared-state worker receives the captured database target and environment. Its registration owner checks for an existing category before writer admission, then rechecks missing names and appends them atomically. Both post-commit callers await completion. The patch path retains the durable-success warnings and catalog-only invalidation introduced by #151689, including uncertain outcomes.

The unchanged session-delivery command selector now lives with its existing worker contract. All 13 tags retain their order and executor. This keeps the shared dispatcher within its existing size guard when category registration is combined with current main's GitHub pending read.

Evidence

The synchronous registration path failed the native-SQL regression with parent-thread calls; the worker path passes with zero parent-thread SQLite calls. The selector composition passes 61 category, actual create/patch RPC, and session-delivery storage/runtime cases. These cover overlapping registrations, captured state-directory identity, existing-category admission avoidance, a competing writer, committed catalog visibility at notifications, durable create success after a controlled registration rejection, delivery claims, retries, owner replacement, and settlement.

The unchanged publication, sticky-model, and batch-tool checks retain their earlier passing evidence. The final main refresh preserves every production and behavior-test byte from the 61-case run; all eight affected routing checks pass after retaining the current sandbox fixtures and the batch-tool fixture together. Core typechecking, scoped type-aware lint, formatting, import-cycle and line-cap checks pass. The exact combined source reproduced the line-cap failure before the shared selector extraction and passes afterward, including the staged candidate. Isolated review found no actionable P0–P2 findings. Exact-head hosted CI remains required before merge.

Proof uses synthetic isolated SQLite state and actual direct RPC handlers. It does not exercise a live provider, operator Gateway, broader catalog worker migration, or native fault injection.

@clawsweeper

clawsweeper Bot commented Sep 17, 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.

@steipete
steipete marked this pull request as ready for review September 17, 2026 03:45
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 17, 2026
@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 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 6:51 AM ET / 10:51 UTC (Revision 8).

ClawSweeper review

What this changes

Moves session category registration into the existing database worker, awaits completion before group notifications, and adds regression coverage and test routing.

Merge readiness

✅ Ready for maintainer review

Keep open: current main and the latest release still perform registration synchronously. The scoped worker conversion remains useful, and source review found no blocking defect.

Priority: P2
Reviewed head: 242cdd545a9b8312c09fde07405b5022da77c214

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused worker conversion with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this verified maintainer-authored internal change. The supplied evidence reports actual SQLite worker and direct RPC tests, including controlled registration rejection; it does not claim a live Gateway run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this verified maintainer-authored internal change. The supplied evidence reports actual SQLite worker and direct RPC tests, including controlled registration rejection; it does not claim a live Gateway run.
Evidence reviewed 9 items Current main still needs the conversion: The fetched main implementation returns a synchronous boolean and performs the catalog read and insertion through synchronous SQLite operations.
Latest release also retains synchronous registration: The v2026.9.5 source performs registration inside the synchronous shared-state transaction owner; the proposed worker conversion is not present there.
Single registration owner and complete caller conversion: Registration captures the existing worker context and dispatches one internal command. Its kernel retains the existing-name shortcut, transactional reread, append ordering, and exact database handle. Both production callers await completion and retain their post-commit failure handling.
Findings None None.
Security None None.

How this fits together

The Gateway saves session categories and maintains the shared catalog used to organize sessions. Registration adds missing category names to SQLite before notifying clients to refresh that catalog.

flowchart TD
  A[Session create or patch] --> B[Save session category]
  B --> C[Shared database worker]
  C --> D{Category exists?}
  D -->|Yes| E[Return unchanged]
  D -->|No| F[Recheck and append atomically]
  F --> G[Publish catalog notification]
  C -->|Failure| H[Preserve session and warn]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +26, Tests +165, Docs +9. Total +200 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 8 91 65 +26
Tests 5 177 12 +165
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 277 77 +200

Review metrics

None.

Technical review

Best possible solution:

Keep category registration within the existing shared-state worker while preserving atomic append order, durable session outcomes, and post-registration notifications.

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

Yes, source inspection establishes that category creation and assignment invoke synchronous SQLite registration on current main; no runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes. Moving the existing operation into the established worker and updating both callers is a narrow solution that preserves the stored representation and recovery behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3c6c393f5136.

Labels

Label justifications:

  • P2: This is a bounded Gateway responsiveness improvement for session category registration.
  • 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 external-contributor proof gate does not apply to this verified maintainer-authored internal change. The supplied evidence reports actual SQLite worker and direct RPC tests, including controlled registration rejection; it does not claim a live Gateway run.

Evidence

What I checked:

  • Current main still needs the conversion: The fetched main implementation returns a synchronous boolean and performs the catalog read and insertion through synchronous SQLite operations. (src/gateway/session-groups.ts:288, 3c6c393f5136)
  • Latest release also retains synchronous registration: The v2026.9.5 source performs registration inside the synchronous shared-state transaction owner; the proposed worker conversion is not present there. (src/gateway/session-groups.ts:288, ec9c1a13db89)
  • Single registration owner and complete caller conversion: Registration captures the existing worker context and dispatches one internal command. Its kernel retains the existing-name shortcut, transactional reread, append ordering, and exact database handle. Both production callers await completion and retain their post-commit failure handling. (src/gateway/session-group-registration.kernel.ts:17, 242cdd545a9b)
  • Meaningful boundary coverage: Inspected tests cover zero parent-thread SQLite calls, overlapping registrations, captured state-directory identity, competing insertion, catalog visibility at notifications, and durable create success after registration rejection. The captured PR body reports 61 passing category/RPC/delivery cases; this read-only review did not execute tests. (src/gateway/session-groups.test.ts:285, 242cdd545a9b)
  • Introduced scope and merge parentage verified: The recorded test merge has the pinned base followed by the exact PR head as parents. Its changes match the introduced scope; unrelated ONNX and package differences are base-branch work. The 13 delivery command tags retain their existing executor. The introduced diff passes git diff --check. (src/state/openclaw-state-worker-runtime.ts:471, 9f938bdd0a56)
  • Existing recovery behavior preserved: The merged change at fix: session group moves lag while requests are pending #151689 established durable patch success and catalog-only invalidation after registration failure. This branch preserves those behaviors while awaiting registration; that earlier change does not supply the worker conversion. (src/gateway/server-methods/sessions-patch-effects.ts:82, 730b8e75bebf)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • 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 (7 earlier review cycles)
  • reviewed 2026-09-17T03:55:43.878Z sha 1aa206c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-17T04:38:36.106Z sha e755de5 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-17T05:27:49.245Z sha 78a434b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T08:07:30.732Z sha ed95134 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T08:51:20.933Z sha ed95134 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T10:33:52.098Z sha d917db8 :: blocked before merge. :: none
  • reviewed 2026-09-20T10:42:37.212Z sha 242cdd5 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/session-group-registration-worker-main7331-20260916 branch from 78a434b to ed95134 Compare September 20, 2026 08:00
steipete added a commit that referenced this pull request Sep 20, 2026
Move registration into the existing shared-state worker while preserving existing-category admission avoidance, atomic append ordering, durable session success, and catalog-only patch invalidation. Both post-commit callers await registration before notification. Refs #144592 and #150565.
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 20, 2026
@steipete
steipete force-pushed the codex/session-group-registration-worker-main7331-20260916 branch from ed95134 to d917db8 Compare September 20, 2026 10:26
steipete added a commit that referenced this pull request Sep 20, 2026
Move registration into the existing shared-state worker while preserving existing-category admission avoidance, atomic append ordering, durable session success, and catalog-only patch invalidation. Both post-commit callers await registration before notification. Refs #144592 and #150565.
steipete added a commit that referenced this pull request Sep 20, 2026
Reuse the canonical 13-command selector without changing tag order or the delivery executor. This keeps the current-main dispatcher within its existing line cap when category registration and the GitHub pending read are combined. Refs #150565.
@openclaw-barnacle openclaw-barnacle Bot removed the agents Agent runtime and tooling label Sep 20, 2026
Move registration into the existing shared-state worker while preserving existing-category admission avoidance, atomic append ordering, durable session success, and catalog-only patch invalidation. Both post-commit callers await registration before notification. Refs #144592 and #150565.
Reuse the canonical 13-command selector without changing tag order or the delivery executor. This keeps the current-main dispatcher within its existing line cap when category registration and the GitHub pending read are combined. Refs #150565.
@steipete
steipete force-pushed the codex/session-group-registration-worker-main7331-20260916 branch from d917db8 to 242cdd5 Compare September 20, 2026 10:36
@steipete
steipete merged commit e2eae6a into main Sep 20, 2026
215 checks passed
@steipete
steipete deleted the codex/session-group-registration-worker-main7331-20260916 branch September 20, 2026 11:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…enclaw#150565)

* refactor(sessions): register first-use categories off thread

Move registration into the existing shared-state worker while preserving existing-category admission avoidance, atomic append ordering, durable session success, and catalog-only patch invalidation. Both post-commit callers await registration before notification. Refs openclaw#144592 and openclaw#150565.

* refactor(state): keep session delivery dispatch with its contract

Reuse the canonical 13-command selector without changing tag order or the delivery executor. This keeps the current-main dispatcher within its existing line cap when category registration and the GitHub pending read are combined. Refs openclaw#150565.
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 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: 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