Skip to content

fix: session patches hang while the model catalog is loading - #166376

Merged
steipete merged 1 commit into
mainfrom
fix/session-catalog-sibling-waits
Oct 7, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/session-catalog-sibling-waits

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session updates and bulk updates can hang indefinitely while model-catalog publication is stalled.

Fixes #161409.

Follow-up to #165989 and #166089.

User Impact

Catalog-dependent sessions.patch and sessions.patchMany operations now return retryable UNAVAILABLE after their shared 20-second catalog budget expires, or when their request, connection, or available captured authority is canceled. A rejected target remains unchanged, including after late catalog publication, and can be retried. Bulk updates retain ordered per-target outcomes and independent successful targets.

Why This Change Was Made

One shared helper now owns the monotonic catalog deadline and cancellation policy for patch, bulk patch, creation, and Gateway catalog continuation. It derives the budget from two-thirds of DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, retains response headroom, and prevents a later read from starting after the budget expires. Existing commit guards and creation idempotency remain in their owners.

Source tracing also established that sessions.catalog.import never calls its supplied model-catalog loader: it passes none of the selection or fork options that consume it. This removes that unused callback and proves that import and re-import still succeed with a never-publishing catalog, preserving existing selection and transcript deduplication. Import therefore has preservation coverage, not a fabricated failing timeout regression; it already succeeds on main.

Production LOC: +85 / -91 = -6; tests +130 / -0; docs +2 / -0. No configuration, protocol, SDK, schema, or changelog changes.

Evidence

Pinned base: 7880834c19616b5efb871e1755cd4b30cf2f2481.

Reviewed head: 0bd1de9ae5f88e1f2bfbb9c8d2f860d062307fee.

The final new handler tests were run with only production reverted to that main commit, then with candidate production restored. Negative control: 2 failed, 1 passed, 83.89 seconds wall. Both patch tests accepted and committed the late catalog result on main; import correctly passed on main.

sessions.patch:
  expected response: false, UNAVAILABLE, retryable: true
  main response:    true

sessions.patchMany:
  expected target outcomes: ok: false, UNAVAILABLE
  main target outcomes:     ok: true

Candidate patch/import suites: 26 passed

An earlier baseline probe also confirmed that neither patch handler had responded at 20 seconds of fake time. Candidate assertions await the actual handler outcome after releasing the late catalog result, then check unchanged persisted entries and a successful retry. No real sleeps, polling, or per-test Gateway boots were added.

Validation uses node scripts/run-vitest.mjs <explicit files> --maxWorkers=1:

Suite Passing cases Reported case time
sessions-mutations.catalog-queue.test.ts 14 53.256 s
session-catalog-import.integration.test.ts 12 23.590 s
session-model-catalog-wait.test.ts 4 0.005 s
Existing server.sessions.create.catalog-wait.test.ts 8 25.359 s
Existing session-catalog-gateway-copy.test.ts 11 1.588 s

Test cost: the full patch/import invocation took 157.78 seconds wall, including cold worker compilation/imports. Its two new patch cases took 4.048 s / 1.603 s. The existing patch suite exceeds the 30-second file budget because it proves real database-writer release, alias/identity revalidation, cross-store commits, and authority behavior; this change adds two cases to that existing owner fixture. The helper and unchanged create/continue cases passed in the earlier four-file invocation (128.89 seconds wall); its two new patch assertions initially ran before database-worker completion, were corrected, and passed in the final full patch/import run above. There are 49 distinct passing cases across the final evidence. CI is attached to the reviewed head and is in progress; final CI seconds are pending completion. The earlier draft run was skipped.

  • pnpm tsgo:core: passed.
  • pnpm tsgo:core:test --ci-graphs-json '["core-test-gateway-methods","core-test-gateway-server"]': passed.
  • Targeted oxlint using config/tsconfig/oxlint.core.json, oxfmt, and git diff --check: passed.
  • Line-cap, max-lines, assertion-safety, test-timeout-race, and mock-export ratchets: passed.
  • Deslop completed; independent Codex autoreview at P2: scoped-clean, no accepted/actionable findings.

This is direct Gateway-handler and durable-state proof, not a live Gateway transport run. Existing create/continue regressions are unchanged. Catalog-worker performance and other model-runtime waits remain outside this change.

Share the monotonic catalog deadline across creation, continuation, and session patch handlers. Return retryable UNAVAILABLE for affected targets without a late commit, retaining ordered bulk outcomes and live commit guards. Remove the unused import loader and preserve catalog-independent import and re-import.

Follow-up to #165989 and #166089.
@clawsweeper

clawsweeper Bot commented Oct 7, 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 7, 2026
@steipete
steipete marked this pull request as ready for review October 7, 2026 01:14
@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 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 9:21 PM ET / October 7, 2026, 01:21 UTC.

ClawSweeper review

What this changes

The PR bounds model-catalog waits during single and bulk session updates, shares that policy with creation and catalog continuation, and preserves catalog-independent imports.

Merge readiness

✅ Ready for maintainer review

This PR still provides a distinct repair: current main leaves catalog-dependent session patches unbounded. No actionable introduced defect was found.

Likely related people: steipete and ericcaiwx-star are routing candidates based on prior merged work in these paths; exact source-line attribution remains unverified.

Priority: P2
Reviewed head: 0bd1de9ae5f88e1f2bfbb9c8d2f860d062307fee

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful negative controls and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies the author as MEMBER, so the external-contributor proof gate does not apply. Recorded production-handler tests exercise patch timeout, late publication, unchanged SQLite entries, and retry using an injected catalog callback; they are supplemental boundary evidence, not real transport proof. No stored-data contract changes or material authority transfer were introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies the author as MEMBER, so the external-contributor proof gate does not apply. Recorded production-handler tests exercise patch timeout, late publication, unchanged SQLite entries, and retry using an injected catalog callback; they are supplemental boundary evidence, not real transport proof. No stored-data contract changes or material authority transfer were introduced.
Evidence reviewed 7 items Pinned introduced change: Reviewed the merge-base-to-head delta at the supplied immutable identities. The patch adds a shared wait owner, threads the request signal into patch execution, and removes the superseded create and continuation wait implementations.
Repair remains absent from current main: Fetched main still passes the model-catalog loader directly to patch preparation without a deadline. Comparing the merge base with fetched main showed no intervening change to this patch engine or the proposed shared wait file.
Timeout and persistence ownership: The helper checks cancellation and remaining monotonic budget before starting a catalog read. Patch preparation retains failed catalog results, maps the owned error to retryable UNAVAILABLE, and preserves synchronous authority and snapshot checks at commit; racing catalog observation does not race the durable write itself.
Findings None None.
Security None None.

How this fits together

Gateway session-control requests prepare model selections before persisting session changes. Catalog publication feeds that preparation; timeout failures return to callers while existing commit guards protect durable session state.

flowchart TD
  A[Session control request] --> B[Prepare session changes]
  B --> C{Catalog required?}
  C -->|Yes| D[Bounded catalog observation]
  D -->|Ready| E[Revalidate and commit]
  D -->|Timeout or cancellation| F[Retryable unavailable outcome]
  C -->|No| E
  E --> G[Ordered request outcomes]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -6, Tests +130, Docs +2. Total +126 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 7 85 91 -6
Tests 3 130 0 +130
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 217 91 +126

Review metrics

None.

Technical review

Best possible solution:

Keep one request-owned catalog deadline while preserving independent bulk outcomes, catalog-independent imports, and live commit-time authorization.

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

Yes, source establishes a clear path: a catalog-dependent patch awaits the unbounded loader on current main. The captured negative controls corroborate it; this review did not execute a reproduction.

Is this the best way to solve the issue?

Yes, sharing the existing request-owned deadline is a focused repair that leaves catalog publication, durable writes, and authorization with their existing owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 98567acd6060.

Labels

Label changes:

  • add P2: This repairs a bounded session-control availability defect when catalog publication stalls, without evidence of a broader urgent regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies the author as MEMBER, so the external-contributor proof gate does not apply. Recorded production-handler tests exercise patch timeout, late publication, unchanged SQLite entries, and retry using an injected catalog callback; they are supplemental boundary evidence, not real transport proof. No stored-data contract changes or material authority transfer were introduced.

Label justifications:

  • P2: This repairs a bounded session-control availability defect when catalog publication stalls, without evidence of a broader urgent regression.
  • 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: Repository State identifies the author as MEMBER, so the external-contributor proof gate does not apply. Recorded production-handler tests exercise patch timeout, late publication, unchanged SQLite entries, and retry using an injected catalog callback; they are supplemental boundary evidence, not real transport proof. No stored-data contract changes or material authority transfer were introduced.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ericcaiwx-star: 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.

@steipete
steipete merged commit c3c55ea into main Oct 7, 2026
204 of 205 checks passed
@steipete
steipete deleted the fix/session-catalog-sibling-waits branch October 7, 2026 01:30
@steipete

steipete commented Oct 7, 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 7, 2026
Share the monotonic catalog deadline across creation, continuation, and session patch handlers. Return retryable UNAVAILABLE for affected targets without a late commit, retaining ordered bulk outcomes and live commit guards. Remove the unused import loader and preserve catalog-independent import and re-import.

Follow-up to openclaw#165989 and openclaw#166089.
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
Share the monotonic catalog deadline across creation, continuation, and session patch handlers. Return retryable UNAVAILABLE for affected targets without a late commit, retaining ordered bulk outcomes and live commit guards. Remove the unused import loader and preserve catalog-independent import and re-import.

Follow-up to #165989 and #166089.

(cherry picked from commit c3c55ea)
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 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.

[Bug]: sessions.create waits with no deadline on model catalog publication; Control UI New Session hangs 7-17 min, then FORBIDDEN after reconnect

1 participant