Skip to content

fix(gateway): keep slow catalogs from blocking other session sources - #155114

Merged
steipete merged 3 commits into
mainfrom
codex/catalog-provider-fairness
Sep 21, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/catalog-provider-fairness

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes healthy session catalogs waiting behind repeated requests to a slow catalog provider. Four remote-node waits could occupy the entire shared queue's execution capacity.

User Impact

Other catalog providers can publish their results and serve provider-specific requests while the slow provider is still waiting. Requests to the same provider run one foreground step at a time, so independent requests to that provider may wait longer under load. An aggregate request still waits for every selected provider. No schema, configuration, permission, or timeout changes are required.

Why This Change Was Made

The existing admission owner now allows one active foreground step per provider ID within the existing four-step global limit and 32-step queue. It starts the oldest eligible queued step, preserves each provider's FIFO order, and keeps cancelled work admitted until its native promise settles. Multi-step continuations retain their queue reservation and original request context. Provider fanout and background-publication ownership are unchanged.

Evidence

The new timer-free provider-boundary regression failed on the original code because the healthy provider never started while four slow requests were held; it passes with this change. All 98 focused tests across the nine changed test files pass, including cancellation, overflow, scope retention, lifecycle retirement, request sharing, progress delivery, and current privacy checks. Three additional catalog suites also passed.

A separate synthetic benchmark held four requests to one provider for 500 ms: another provider started after 501.40 ms before the change and 0.44 ms afterward. This measures local admission, not production response latency. The candidate has not been deployed to a live Gateway.

Measured single-worker command wall times: list-admission 3.18 s; provider-access 2.94 s; provider-steps 3.87 s; owner-steps 46.65 s. The existing RPC-owner fixture spends most of its 46.65 s in cold worker compilation and source transformation; its four test bodies took 40 ms in total. This change only updates that fixture to use distinct provider IDs and adds no Gateway boot or timer.

The first CI run exposed existing fixtures that required concurrent foreground calls from one provider. Those fixtures now use distinct providers for global-cap saturation or the existing stepped-list contract for bounded progress. They retain the original sharing, privacy, cancellation, and publication assertions. The real Gateway proof still holds a request across 128 completed queries and verifies follower progress. No assertions were suppressed and no timeouts increased.

Additional single-worker command wall times: provider diagnostics 9.04 s; progress 53.21 s; privacy 110.73 s; real Gateway sharing 104.45 s; native registration 24.63 s. These are existing suites; the change adds no Gateway boot or timer.

Independent review completed. A reported abort-settlement issue was rejected: the existing post-step signal.throwIfAborted() rejects before queuing a continuation. A direct held-successor probe confirmed the aborted caller settles while its same-provider successor remains unresolved. There are no accepted unresolved findings.

The complete changed checks and focused follow-up checks passed. In CI run 35647111450, all 98 catalog tests passed. Hosted test-body totals by changed file were: list-admission 0.022 s; provider-access 0.021 s; provider-steps 0.016 s; owner-steps 0.040 s; diagnostics 0.020 s; progress 0.172 s; privacy 25.386 s; Gateway sharing 1.059 s; native registration 1.095 s (27.831 s total).

That run failed two existing process-heavy fixtures outside the catalog path. The Matrix Doctor fixture bypassed the shared CLI child-process owner, omitting its Node compiler safeguards, diagnostic capture, and cleanup time reservation. It now uses that existing owner through the private repository-only test facade. The real Doctor/data/archive assertions and outer 120-second test budget are unchanged. Independent review and the affected type, lint, formatting, import-boundary, SDK surface/export, and repository guards passed. The original 11-file shard passes all 99 tests with the correction (95.350 s wall; Doctor body 59.078 s); the required single-file command passes in 64.282 s wall (body 40.210 s, cold worker preparation 11.554 s). The unchanged original shard also passed locally, so this establishes the fixture policy correction, not the cause of the original hosted timeout. The corrected-head Matrix test also passed in hosted CI in 58.754 seconds (job 106504842324).

The other failure was the managed-worktree large-index GC fixture's 60-second child-process deadline. Its original 56-file shard passed all 1,184 tests in the same order locally (652.049 s wall). Passive observation showed the child continuing CPU/filesystem work and exiting naturally at roughly 59 seconds under contention. The fixture and owner match the tested head and current main. No safe causal repair was established; its code, timeout, and assertions remain unchanged. The unchanged GC fixture also passed on corrected-head hosted CI. Neither passing run proves the original failure resolved. Corrected-head CI run 35651367205 completed successfully: all 131 executed jobs passed, including the aggregate CI gate; 16 jobs were skipped.

@clawsweeper

clawsweeper Bot commented Sep 21, 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: S labels Sep 21, 2026
@steipete
steipete marked this pull request as ready for review September 21, 2026 19:16
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Sep 21, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 21, 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:

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: L and removed size: M labels Sep 21, 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 Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 5:15 PM ET / 21:15 UTC.

ClawSweeper review

What this changes

The PR serializes foreground session discovery per provider, preserves concurrency across providers, updates scheduling documentation and regression fixtures, and moves the Matrix Doctor test onto the shared process helper.

Merge readiness

✅ Ready for maintainer review

This fix remains useful: current main and the latest release still allow one slow provider to occupy every admission slot. No blocking introduced defect was found, and CI passed for the reviewed head.

Priority: P2
Reviewed head: 26b899f2599b9cc7190927575bda7165897e49af

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage, documented tradeoffs, and successful CI at the reviewed head.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER classification exempts this internal scheduling repair from external-contributor proof requirements. Provider-boundary regressions and real Gateway socket coverage support the change; the synthetic benchmark is not live-deployment evidence.
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 classification exempts this internal scheduling repair from external-contributor proof requirements. Provider-boundary regressions and real Gateway socket coverage support the change; the synthetic benchmark is not live-deployment evidence.
Evidence reviewed 8 items Introduced scheduling change: The pinned merge-base-to-head diff adds provider identity to the existing admission owner and selects the oldest eligible queued step. Active work retains its slot until settlement; continuations retain their request context and queue reservation.
Still necessary on main and release: Both fetched main and v2026.9.5 retain the active-counter/global-FIFO implementation without provider isolation. Four unsettled requests to one provider can therefore delay another provider. The original merge-base blob was also inspected.
Released implementation check: The supplied latest-release commit also lacks per-provider admission; this PR's central fix is not present in that release.
Findings None None.
Security None None.

How this fits together

The Gateway gathers session lists from plugin-provided catalogs for clients. Its admission queue controls when provider work runs before results and progress updates reach each authorized caller.

flowchart TD
  A[Client session-list requests] --> B[Gateway catalog selection]
  B --> C[Provider-aware admission queue]
  C --> D[One active step per provider]
  D --> E[Catalog provider work]
  E -->|More steps| C
  E --> F[Current visibility checks]
  F --> G[Results and progress updates]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +11, Tests +98, Docs +6. Total +115 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 3 35 24 +11
Tests 10 271 173 +98
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 312 197 +115

Review metrics

Metric Value Why it matters
Provider concurrency Up to 4 → 1 foreground step per provider; global cap remains 4 This intentionally trades same-provider throughput for progress across independent session sources.

Technical review

Best possible solution:

Keep provider fairness in the existing admission owner while preserving bounded work, cancellation settlement, and current per-caller visibility checks.

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

Yes, from source: four unsettled same-provider lists consume current main's four global slots and prevent a healthy provider from starting. The PR supplies a focused regression; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. Extending the existing queue provides provider fairness without a second scheduler, and the tests retain the relevant cancellation, continuation, sharing, and privacy contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 14f8ec46c133.

Labels

Label changes:

  • add P2: This repairs bounded session-discovery contention without evidence of a core outage or urgent widespread regression.
  • add merge-risk: 🚨 compatibility: Catalog calls from the same provider now serialize across clients; the maintainer-authored body explicitly accepts the resulting longer waits and the SDK documentation records that tradeoff.
  • 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: The supplied MEMBER classification exempts this internal scheduling repair from external-contributor proof requirements. Provider-boundary regressions and real Gateway socket coverage support the change; the synthetic benchmark is not live-deployment evidence.

Label justifications:

  • P2: This repairs bounded session-discovery contention without evidence of a core outage or urgent widespread regression.
  • merge-risk: 🚨 compatibility: Catalog calls from the same provider now serialize across clients; the maintainer-authored body explicitly accepts the resulting longer waits and the SDK documentation records that tradeoff.
  • 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 classification exempts this internal scheduling repair from external-contributor proof requirements. Provider-boundary regressions and real Gateway socket coverage support the change; the synthetic benchmark is not live-deployment evidence.

Evidence

What I checked:

  • Introduced scheduling change: The pinned merge-base-to-head diff adds provider identity to the existing admission owner and selects the oldest eligible queued step. Active work retains its slot until settlement; continuations retain their request context and queue reservation. (src/gateway/server-methods/session-catalog-list-admission.ts:152, 26b899f2599b)
  • Still necessary on main and release: Both fetched main and v2026.9.5 retain the active-counter/global-FIFO implementation without provider isolation. Four unsettled requests to one provider can therefore delay another provider. The original merge-base blob was also inspected. (src/gateway/server-methods/session-catalog-list-admission.ts:28, 14f8ec46c133)
  • Released implementation check: The supplied latest-release commit also lacks per-provider admission; this PR's central fix is not present in that release. (src/gateway/server-methods/session-catalog-list-admission.ts:28, ec9c1a13db89)
  • Regression and lifecycle coverage: The new provider-boundary regression holds four slow requests and requires another provider to start. Reviewed surrounding tests retain FIFO, overflow, cancellation, continuation, request-context, retirement, privacy, and follower-progress assertions. The reported abort-settlement concern is contradicted by the post-step abort check before continuation admission. (src/gateway/server-methods/session-catalog-provider-access.test.ts:21, 26b899f2599b)
  • Accepted scheduling tradeoff: The supplied repository context identifies a MEMBER author. The PR body explicitly accepts longer waits for independent requests to the same provider and preserves aggregate waiting semantics. The documentation states the matching one-step-per-provider policy, four-step global cap, and 32-step queue. No configuration, persistence, permission, or public signature migration is introduced. Public docs: docs/plugins/sdk-entrypoints/define-plugin-entry.md. (docs/plugins/sdk-entrypoints/define-plugin-entry.md:95, 26b899f2599b)
  • Private test-support boundary: The added export reuses the existing CLI child-process owner for the Matrix fixture. package.json excludes test-env JavaScript and declarations from distribution; this is not a new supported third-party SDK API. Doctor state and archive assertions remain intact. (src/plugin-sdk/test-env.ts:2, 26b899f2599b)

Likely related people:

  • 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.

@steipete
steipete merged commit 9950ed5 into main Sep 21, 2026
220 of 221 checks passed
@steipete
steipete deleted the codex/catalog-provider-fairness branch September 21, 2026 21:18
@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 22, 2026
…penclaw#155114)

* fix(gateway): keep slow catalogs from blocking other session sources

* test(gateway): preserve catalog proofs with provider serialization

* test(matrix): use the shared Doctor process fixture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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