Skip to content

perf(gateway): retain prepared state across channel config reloads - #160274

Merged
steipete merged 10 commits into
mainfrom
steipete/perf-micro-config-reload-channel-change-invalidates-all-20260919
Sep 28, 2026
Merged

steipete merged 10 commits into
mainfrom
steipete/perf-micro-config-reload-channel-change-invalidates-all-20260919

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Changing a channel transport setting could invalidate every prepared session row and temporarily make model catalog reads report that Gateway startup was incomplete.

User Impact

Channel streaming edits retain session-list responsiveness and catalog availability. Agent roster, session policy, visibility, store topology, model/provider/auth, and plugin-activation changes still refresh their affected state. No new configuration or persisted-state migration is needed.

Why This Change Was Made

Config publication now compares channel activation and configured-model facts instead of treating every channel field as a projection input. The lightweight config notification still updates the projection's snapshot. Model-neutral reloads advance the prepared owner's config stamp; model/auth replacements use the existing publication barrier, which catalog reads await before reacquiring the current owner.

Classification includes effective resolved inputs: an unchanged SecretRef can resolve to a rotated credential during a channel or agent edit. Such rotations still replace all affected model owners before publication. Relevant no-action commits use the same hot-reload owner, removing a separate post-commit rebuild.

Slack already classifies streaming as a no-action reload; no special planner rule was needed. Pure channel-activation predicates move with all internal callers so snapshot publication does not import plugin discovery. Net production growth: 47 lines. The only additional test change keeps two independent planner input cases separate without changing their assertions or deadlines.

Evidence

Synthetic real-file reload fixture, 7,908 resident sessions, same Blacksmith Testbox:

Change Dirty / rematerialized rows before → after File change through list read
Slack streaming mode 7,908 / 7,908 → 0 / 0 1,253.21 → 46.06 ms (~96% lower)
UI preferences 0 / 0 → 0 / 0 22.16 → 18.98 ms
Agent roster control Required invalidation retained: 7,908 / 7,908 after 1,258.21 ms after

The fixture reads and validates an actual config file, drives the reload owner, and reads the real session projection. Watcher delivery and the Gateway lifecycle lease are isolated adapters. Catalog regressions fail on the original code and cover channel/UI retention, model replacement, added agents, channel activation/model selection, and plugin rollback. Three managed-auth regressions also fail with the previous owners and pass with the candidate: secret-provider publication ordering, credential rotation during channel edits, and global rotation during agent-local edits.

All heavy validation used provider blacksmith-testbox, profile openclaw-check:

Lease Commands / scope Result
tbx_01m3k6sezp2adfpz5jbwp0xh1b 7,908-row fixture; focused reload/projection/catalog/auth/activation suites Benchmark above; five Vitest shards passed in 173.84 s (run)
tbx_01m3kcajryhsn5ncb5qy1mgsv0 Core and 25 core-test type graphs; format, ratchet, export guards Passed (run)
tbx_01m3kf8wdmw305z468xynf7nz8 Changed-file lint; four changed test files; catalog/auth consumers; pnpm build 228 + 65 tests passed; build passed in 535.8 s (run)
tbx_01m3krpw80gxvbzjb1pkj4m0vz Managed-auth red/green; full handler suite; seven other reload/projection/catalog/auth files; core/gateway-server types and guards 178 handler tests passed in 42.74 s; 599 other tests passed in 91.00 s; types/guards passed (run)
tbx_01m3kw1011n8x8ahxwtm4ryj7k Final core/script lint; storage, media, webhook/auth, architecture guards Passed; zero runtime import cycles (run)
tbx_01m3kx6cwd6eba4bn8xaqar3c8 Conflict-resolution replay: five affected files; core/gateway-server types; line-cap ratchet 223 tests passed in 128.39 s; types/ratchet passed (run)

Fresh independent Codex review of the final resolved 22-file candidate found no actionable P0–P2 issue. Final planner replay passed on tbx_01m3mg9e4p1qp6jmkxg22vvd4m (run 36456981131): all eight cases in 110.85 seconds wall, plus tooling types, targeted lint, and line/max-line/assertion guards. The inherited environment-count issue is resolved on integrated main (484/484). Final CI: run 36456826910, head a1f2414b427e3dbc4fe95db144cedc8244197235, passed: 134 successful jobs, 21 skipped, zero failures. The campaign auto-merge watcher merged this PR at cb3755a3435d3af32a8d7a6a1fe3054baa9808e9 on 2026-09-28 at 17:47:35 UTC; the commit is verified on main. All Testbox leases are stopped. Earlier CI findings and their canonical main repairs are documented below.

Test cost, CI findings, and canonical main repairs

Measured one-worker wall costs: prepared-model runtime 43.79 s (14 tests), reload handlers 42.74 s (178), reload-scope classification 9.69 s (37), projection file fixture 16.26 s (one 16-row default), and final planner integration 110.85 s (eight cases). Catalog regression bodies took 128–174 ms in initial CI; pending-replacement reads took 33 ms. The existing import graph and worker compilation dominate cold setup. Pure classification cases moved from the handler suite without duplicate coverage or Gateway boots.

The initial CI wrapper-inventory omission is fixed here. Subsequent CI failures were investigated through exact job logs and isolated Testbox replays. Main now owns the resulting independent repairs, and their exact maintained versions are adopted in this branch:

  • Canonical skills workspace and broker fixtures: test(ci): align fixtures with canonical runtime owners #160349; requester-wake timer/I/O settlement: fix(test): join requester retry before advancing its clock #160407.
  • Lazy tooltip readiness and progress-widget canonical liveness: fc255f858868 and d6aa710c5091.
  • Targeted source parsing: fix(ci): reduce PR-exempt ownership check runtime #160517 (abb37032e7f7). The first planner case fell from 135.9 to 66.7 hosted seconds. Same-Testbox original group: 143.65 → 119.28 seconds, 114 tests passed; the source-reader regression failed on the original owner, and 2,103 planner-owner tests passed. The later case's two independent edited-path probes are retained as separate rows here: both preserve precise/hub controls and all assertions, measured 32.312/6.963 seconds on the final Testbox head, with the existing 120-second deadline unchanged.
  • Heartbeat delivery lifecycle: d9569745764f. The original five-second fixture failures did not reproduce on the initial Testbox shard replay (303 tests passed); upstream deterministic fault probes establish the repair.
  • AI declaration publication in the fake builder: test(scripts): model AI declarations in bounded E2E preparation fixture #160532 (4902e4ae49a6). Both failing cases reproduced on exact CI merge 0239aefd8ac091c442d98f8d0521cbec07e4fcc3; all 39 bounded-runner cases and eight declaration-owner tests then passed.
  • Roster admission, shared-membership mock response, owner-filter focus, and Side chat readiness/cleanup: 6b9da9dc0287, f03d64f6a56e, 94cbd1335dfb, and e256cbef8ae0. The exact-merge UI replay reproduced the digest, keyboard, and avatar failures. The avatar failure was an invalid default mock membership response causing a header render exception. Side chat could receive Enter while initial history still blocked slash commands, leaving a newline in the draft; its held-module cleanup also needed upstream repair. Every original assertion is retained by the maintained main fixtures.

Follow-up validation used blacksmith-testbox / openclaw-check:

  • tbx_01m3m58rz5mk84cd9fecn3n1x9, run 36433161502: source-reader red/green; 2,103 planner tests; 114-test original planner group; heartbeat 8 + 19 sibling tests; scripts/root/infra types, targeted lint/format and guards passed.
  • tbx_01m3m9ezshfxhv8eab15bg8p9v, run 36442426673: exact-merge AI fixture red/green; 39 bounded-runner, eight declaration-owner, eight planner integration, 37 UI cases across focused runs, and 52 mock-session tests passed. UI types, targeted lint/format, line-cap and assertion guards passed. Scratch type validation required a physical frozen dependency install, which was completed. The 484/483 environment-name mismatch also exists in the untouched committed CI merge; main fix 6e0d8aa1a0c4 owns it. No budget or suppression was raised.

The final conflict resolution integrates main 8f9250180e792e95c85d4a9f592767adfaf081c5. The eight modified runtime owners have no incoming-main changes since the prior validated base, so their existing proof remains valid. All duplicate CI fixes are absent from this PR's diff; only the independent planner-row split remains. All earlier leases and the isolated exact-CI checkout are cleaned up.

No live Gateway was modified. These are synthetic latency/work-count measurements; production CPU/RSS and live channel delivery were not measured. The initial full build emitted a nonblocking startup-JavaScript budget diagnostic of 372,365 B versus 372,347 B (18 B over). No UI source or budget changed here, and no base-build attribution was attempted.

Preserve session rows and model catalog readiness when channel transport settings change. Keep model/auth and roster invalidation under their existing owners and await atomic catalog replacement. A 7,908-row file-reload fixture drops from 1,253 ms to 46 ms with no rematerialization.
@clawsweeper

clawsweeper Bot commented Sep 28, 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 agents Agent runtime and tooling size: L labels Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 08:09
@steipete
steipete enabled auto-merge (squash) September 28, 2026 08:10
@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 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 1:42 PM ET / 17:42 UTC (Revision 13).

ClawSweeper review

What this changes

The branch keeps prepared session rows and model catalogs available during channel transport edits while replacing prepared model and authentication state when effective inputs change.

Merge readiness

✅ Ready for maintainer review

Keep this PR open. Current main still broadly invalidates prepared state on channel config changes, and the branch has useful before-and-after evidence for the affected session-list path. I found no actionable defect introduced by the pinned diff.

Priority: P2
Reviewed head: a1f2414b427e3dbc4fe95db144cedc8244197235

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Direct reload measurements and boundary regressions support a focused patch, with live Gateway performance still unmeasured.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The reported after-fix Testbox fixture reads a real config file through the Gateway reload owner and then reads the resident session projection, observing zero row rematerializations and a 1,253.21-to-46.06 ms improvement for a Slack streaming edit. Separate publication tests cover catalog and resolved-credential replacement; watcher delivery and the lifecycle lease are isolated, and live channel delivery was not measured. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The reported after-fix Testbox fixture reads a real config file through the Gateway reload owner and then reads the resident session projection, observing zero row rematerializations and a 1,253.21-to-46.06 ms improvement for a Slack streaming edit. Separate publication tests cover catalog and resolved-credential replacement; watcher delivery and the lifecycle lease are isolated, and live channel delivery was not measured. No stored-data contract changes.
Evidence reviewed 9 items Current-main behavior: At the fetched main revision, the session projection comparison still treats the entire channels object as significant, so a transport-only edit takes the broad config invalidation path.
Selective session invalidation: The introduced comparison retains channel activation and configured model references while excluding transport settings from the resident-row invalidation decision.
Effective credential classification: The reload decision compares authored paths, effective resolved config paths, configured model references, and channel activation before deciding whether prepared model state must be replaced.
Findings None None.
Security None None.

How this fits together

The Gateway reads validated config changes and decides which runtime state needs replacement. Its publication affects agent model catalogs and the resident session-list projection.

flowchart LR
A[Config edit] --> B[Reload planner]
B --> C{Model or auth input changed?}
C -->|Yes| D[Replace prepared model state]
C -->|No| E[Retain prepared model state]
D --> F[Publish runtime config]
E --> F
F --> G[Catalog and session list]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +47, Tests +337, Docs +6, Other 0. Total +390 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 13 142 95 +47
Tests 6 518 181 +337
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 2 1 1 0
Total 22 667 277 +390

Review metrics

Metric Value Why it matters
Measured session-list reload 1,253.21 → 46.06 ms for 7,908 resident rows The same synthetic real-file fixture reports the improvement; it is not a live production measurement.
Production and test growth production +47, tests and test support +337 net lines Production growth is attributed to selective classification and publication, with focused regression coverage for the changed boundaries.

Technical review

Best possible solution:

Keep selective invalidation in the existing reload and prepared-runtime owners, with effective model and credential changes continuing through the atomic replacement barrier.

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

Yes. Current-main source shows broad invalidation, and the PR provides a specific real-file reload fixture and before-and-after measurements; I did not execute it in this read-only review.

Is this the best way to solve the issue?

Yes. The branch changes the existing reload and prepared-runtime owners, retaining their replacement barrier for effective model and auth changes without adding config or a parallel cache.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 71a551649cbc.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This addresses a bounded Gateway responsiveness and catalog-availability problem during config reload.
  • merge-risk: 🚨 auth-provider: The new retention decision governs whether effective credential changes replace prepared provider state.
  • merge-risk: 🚨 session-state: The new channel comparison governs whether resident session rows retain current model and roster facts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The reported after-fix Testbox fixture reads a real config file through the Gateway reload owner and then reads the resident session projection, observing zero row rematerializations and a 1,253.21-to-46.06 ms improvement for a Slack streaming edit. Separate publication tests cover catalog and resolved-credential replacement; watcher delivery and the lifecycle lease are isolated, and live channel delivery was not measured. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The reported after-fix Testbox fixture reads a real config file through the Gateway reload owner and then reads the resident session projection, observing zero row rematerializations and a 1,253.21-to-46.06 ms improvement for a Slack streaming edit. Separate publication tests cover catalog and resolved-credential replacement; watcher delivery and the lifecycle lease are isolated, and live channel delivery was not measured. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: 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 (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-28T11:50:42.509Z sha 1b45afe :: needs changes before merge. :: none
  • reviewed 2026-09-28T12:00:22.541Z sha 1b45afe :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T12:50:32.531Z sha a884f78 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T13:34:10.278Z sha c0560ea :: blocked before merge. :: none
  • reviewed 2026-09-28T14:12:02.841Z sha 890512e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T15:00:22.383Z sha 5e73957 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T17:00:27.378Z sha 5abd402 :: blocked before merge. :: none
  • reviewed 2026-09-28T17:27:50.483Z sha a1f2414 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as draft September 28, 2026 10:13
auto-merge was automatically disabled September 28, 2026 10:13

Pull request was converted to draft

Route auth-relevant no-action reloads through the existing model publication
barrier, including resolved credential changes. Keep neutral config commits on
the prepared generation and remove the delayed duplicate rebuild.

Include current-main CI repairs, register the pure activation helper with the
PR wrapper, route retained-monitor proof through its host database broker, and
align the skills fixture with canonical-workspace discovery.
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 28, 2026
Publish prior configuration through the runtime snapshot owner used by hot
reload. Keep the agent-local and neutral compaction assertions, share auth
fixture construction with the config test-support module, and use Vitest's
call-order matcher for credential publication ordering.
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 28, 2026
Resolve the skills E2E conflict with main's canonical-workspace fixture and
retain the targeted config reload change. Main also includes the retained
monitor's required host-broker test routing.
@steipete
steipete marked this pull request as ready for review September 28, 2026 11:52
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: a1f2414b427e3dbc4fe95db144cedc8244197235
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-reload-managed-secrets.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@steipete
steipete enabled auto-merge (squash) September 28, 2026 11:56
Wait for the open, positioned popup after the hover timer starts its lazy
module import. Preserve the existing motion and placement assertions instead
of reading shadow parts before custom-element registration completes.
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Sep 28, 2026
Seed the canonical session with the same running facts as its main-scoped
list response. Fresh descriptor snapshots can then reconcile without clearing
fixture-only liveness fields. Preserve the writer-scope negative control and
all existing progress and activity assertions.
Resolve the sidebar tooltip and progress-widget fixture conflicts using
main's maintained versions, including their deterministic response gates.
Keep the config reload performance patch and its validated production code
unchanged; the duplicate UI fixture changes leave this PR's diff.
@openclaw-barnacle openclaw-barnacle Bot removed the app: web-ui App: web-ui label Sep 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Sep 28, 2026
Skip import parsing for files outside a targeted source scan while keeping full-graph reads complete. Synchronize heartbeat delivery fixtures on their existing lifecycle events instead of a shorter wall-clock deadline.
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 28, 2026
Keep independent planner inputs in separate cases, model completed AI declarations in the build stub, and wait for roster or composer readiness before UI interactions. Serve sharing evidence through the canonical mock session owner so owner-role fixtures render without a header error.
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XL and removed size: L labels Sep 28, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 28, 2026
Resolve actual main conflicts using its maintained source-reader, heartbeat, AI-build, and UI fixture owners. Retain the independently timed planner input split. The config reload production patch is unchanged.
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed app: web-ui App: web-ui size: XL labels Sep 28, 2026
@steipete
steipete merged commit cb3755a into main Sep 28, 2026
237 of 239 checks passed
@steipete
steipete deleted the steipete/perf-micro-config-reload-channel-change-invalidates-all-20260919 branch September 28, 2026 17:47
steipete added a commit that referenced this pull request Sep 28, 2026
…tion reloader

#160375 (28f0d26) made startGatewayConfigReloader require a scheduler; #160274 (cb3755a) landed a new test calling it without one, so the gateway-root test typecheck fails on main (TS2741: Property 'scheduler' is missing). Supply the shared test scheduler like the other config-reload tests. Proof: tsgo test/tsconfig/tsconfig.core.test.gateway-root.json passes; the file passes (1 test); targeted oxlint and diff check pass.
vincentkoc pushed a commit that referenced this pull request Sep 28, 2026
…tion reloader

#160375 (28f0d26) made startGatewayConfigReloader require a scheduler; #160274 (cb3755a) landed a new test calling it without one, so the gateway-root test typecheck fails on main (TS2741: Property 'scheduler' is missing). Supply the shared test scheduler like the other config-reload tests. Proof: tsgo test/tsconfig/tsconfig.core.test.gateway-root.json passes; the file passes (1 test); targeted oxlint and diff check pass.

(cherry picked from commit 4bd1054)
vincentkoc added a commit that referenced this pull request Sep 28, 2026
)

* fix(config): retain producer ownership during read compensation

* test(gateway): pass the Gateway scheduler to the config-commit projection reloader

#160375 (28f0d26) made startGatewayConfigReloader require a scheduler; #160274 (cb3755a) landed a new test calling it without one, so the gateway-root test typecheck fails on main (TS2741: Property 'scheduler' is missing). Supply the shared test scheduler like the other config-reload tests. Proof: tsgo test/tsconfig/tsconfig.core.test.gateway-root.json passes; the file passes (1 test); targeted oxlint and diff check pass.

(cherry picked from commit 4bd1054)

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…penclaw#160274)

* perf(gateway): retain prepared state across channel config reloads

Preserve session rows and model catalog readiness when channel transport settings change. Keep model/auth and roster invalidation under their existing owners and await atomic catalog replacement. A 7,908-row file-reload fixture drops from 1,253 ms to 46 ms with no rematerialization.

* test(gateway): align reload fixtures with runtime snapshots

Publish prior configuration through the runtime snapshot owner used by hot
reload. Keep the agent-local and neutral compaction assertions, share auth
fixture construction with the config test-support module, and use Vitest's
call-order matcher for credential publication ordering.

* test(ui): wait for lazy tooltip readiness before measuring motion

Wait for the open, positioned popup after the hover timer starts its lazy
module import. Preserve the existing motion and placement assertions instead
of reading shadow parts before custom-element registration completes.

* test(ui): share canonical liveness in progress widget fixtures

Seed the canonical session with the same running facts as its main-scoped
list response. Fresh descriptor snapshots can then reconcile without clearing
fixture-only liveness fields. Preserve the writer-scope negative control and
all existing progress and activity assertions.

* test: stabilize planner and heartbeat CI proof

Skip import parsing for files outside a targeted source scan while keeping full-graph reads complete. Synchronize heartbeat delivery fixtures on their existing lifecycle events instead of a shorter wall-clock deadline.

* test: stabilize CI fixture readiness and preparation

Keep independent planner inputs in separate cases, model completed AI declarations in the build stub, and wait for roster or composer readiness before UI interactions. Serve sharing evidence through the canonical mock session owner so owner-role fixtures render without a header error.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…tion reloader

openclaw#160375 (c003e36) made startGatewayConfigReloader require a scheduler; openclaw#160274 (f9de1eb) landed a new test calling it without one, so the gateway-root test typecheck fails on main (TS2741: Property 'scheduler' is missing). Supply the shared test scheduler like the other config-reload tests. Proof: tsgo test/tsconfig/tsconfig.core.test.gateway-root.json passes; the file passes (1 test); targeted oxlint and diff check pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…claw#147746)

* fix(config): retain producer ownership during read compensation

* test(gateway): pass the Gateway scheduler to the config-commit projection reloader

openclaw#160375 (c003e36) made startGatewayConfigReloader require a scheduler; openclaw#160274 (f9de1eb) landed a new test calling it without one, so the gateway-root test typecheck fails on main (TS2741: Property 'scheduler' is missing). Supply the shared test scheduler like the other config-reload tests. Proof: tsgo test/tsconfig/tsconfig.core.test.gateway-root.json passes; the file passes (1 test); targeted oxlint and diff check pass.

(cherry picked from commit 9518031)

---------

Co-authored-by: Peter Steinberger <[email protected]>
obviyus added a commit that referenced this pull request Oct 16, 2026
…rebuilds (#173585)

## What Problem This Solves

Fixes: model pickers wait for, fail on, or briefly lose models while the Gateway rebuilds its model catalog after a settings change, sign-in, sign-out, key removal or plugin reload.

## User Impact

`models.list` now answers from the last published list while the catalog owner rebuilds, instead of waiting for the replacement owner or failing with "Chat metadata access changed while preparing its metadata". A provider whose config, credentials, configured models or owning plugin changed is removed from that list at once and returns when the new catalog has it. Additions may appear late; removals are never shown.

Remaining limit (not fixed here): during a reload, synchronous plugin metadata rescans still block the Gateway main thread for 0.3–2 s, so any RPC (including a trivial `last-heartbeat`) is slow in that window. Tracked as a separate follow-up.

## Why This Change Was Made

Two waits sat on the read path:

- `chat-metadata-runtime.ts` `readCurrent` awaited the pending refresh, which awaits the model-runtime replacement gate. Added in #170805 to stop failures for healthy agents: "The existing model-runtime publication barrier owns replacement readiness; metadata follows it rather than constructing partial facts ahead of its commit." That PR states latency was not benchmarked.
- `server-model-catalog.ts` `readPreparedGatewayModelCatalogOwnerSnapshot` awaits the same gate (#160274: "model/auth replacements use the existing publication barrier, which catalog reads await before reacquiring the current owner").

Both waits avoid errors; neither protects data the previous list cannot serve. Hot reloads also retire the previous owners immediately, so reads raced into retired owners and failed.

Changes:

1. **Read side** (`chat-metadata-runtime.ts`, `chat-metadata-model-list.ts`): keep the last result per request shape. While a refresh, replacement, auth change or retired owner is pending, serve it minus providers whose identity changed (provider config slice, `auth.profiles`/order, runtime auth-store profiles, every configured model ref the visibility owner admits (primary, fallbacks, model maps, utility, image and PDF models), owning plugin entries). Any edit to the config `env` section hides every provider until the new catalog publishes, because it can hold any provider's key. A change to `agents.*.modelPolicy` does the same, since a policy can name any provider's models. A requester who now has personal-account links is never served the retained shared list; the read takes the existing personal-projection path. Superseded/unavailable read errors fall back to the same retained list; other errors still surface.
2. **Catalog owner** (`prepared-model-runtime.catalog-source.ts`): a rebuild keeps a provider's discovered rows when only the installed-plugin fingerprint changed and the provider's own source and credentials are unchanged. Those rows are marked provisional and reacquired by the post-commit changed-provider refresh. The owning plugin's package version and install-record hash join the provider source, so an upgraded provider plugin does not carry its old rows. Native harness rows keep the existing rule (dropped when any agent/plugin setting changes), because a harness may list models from any of those settings.

State table used for the change:

| Event | During rebuild | After commit |
|---|---|---|
| Model-neutral setting | previous list | same |
| Provider P config/credentials changed, deleted, or signed out | previous − P | P returns when rediscovered |
| Plugin config change (no provider change) | previous list | provisional rows until rediscovered |
| Sign-in to new provider Q | previous list | Q added when known |
| Remote catalog swap | previous list (not adopted yet) | atomic switch (#158000, #167178) |

## Evidence

Regression test `server-chat-metadata-lifecycle.rebuild.test.ts`: holds the replacement owner's catalog build forever (a provider that never answers), then reads `models.list` with a 1 s budget. On main it fails with `models.list waited for the rebuild`; with this change it passes, and it checks that signing out, removing the configured model and editing the config `env` section each hide `openai/gpt-5.4` before the replacement publishes (the `env`, model-policy and primary-model steps each fail without their identity field). `chat-metadata-runtime.personal-accounts.test.ts` adds a case where a requester connects a personal account while the owner is retired; the read declines the retained shared list (fails without the link check). Two existing tests now assert the new contract: a retired owner without a published replacement serves its last list instead of rejecting (`models.prepared.test.ts`), and the readiness test holds the replacement's own list preparation after the refresh (`chat-metadata-model-list-readiness.test.ts`).

UI guard `chat-loading-deadlines.e2e.test.ts`: an existing chat sends a message while `models.list` never answers (passes on main and here; no UI change needed).

Isolated Gateway bench (real entry point, built `dist`, n = 12 per event): fake vLLM (healthy), Ollama that never answers, Codex app-server whose `model/list` never answers. Back-to-back `models.list {view: "configured"}` reads tagged *during* the triggering RPC. Times in ms.

| Event (during) | main p50 / p99 / max | failed | this PR p50 / p99 / max | failed |
|---|---|---|---|---|
| settings change (model) | 1.5 / 323 / 344 | 0 | 1.5 / 235 / 322 | 0 |
| plugin settings change | 1.6 / 366 / 1547 | 12 | 1.3 / 266 / 752 | 0 |
| sign-in | 2.2 / 613 / 763 | 1 | 2.4 / 624 / 1196 | 0 |
| sign-out | 1.6 / 781 / 907 | 12 | 1.9 / 378 / 537 | 0 |
| provider deleted | 2.3 / 1169 / 1799 | 0 | 2.4 / 825 / 2297 | 0 |
| plugin reload | 1.5 / 490 / 1080 | 12 | 2.0 / 470 / 818 | 0 |
| catalog swap | 1.7 / 84 / 654 | 0 | 1.7 / 94 / 463 | 0 |
| restart (first reads) | 1.5 / 131 / 335 | 0 | 1.6 / 105 / 281 | 0 |

No read after a sign-out or provider deletion returned that provider (0 violations in both runs).

Why p99 is still above 300 ms: a lag probe (`last-heartbeat` issued with each read) is as slow as `models.list` in every slow sample (for example 1453 vs 1445 ms), so the read path no longer waits. A Gateway `--cpu-prof` during sign-in / provider deletion / plugin reload attributes the busy main-thread segments to `loadPluginMetadataSnapshot` → installed plugin index rebuild with synchronous `lstat`/`read`/`realpath` (~26%), module compile/link of reloaded plugin code (~24%) and managed reload `publishRuntime` (~15%). Top callers: `resolveManifestPluginsForModelIdNormalization` and `resolveConfigWidePluginMetadataSnapshot`. That is the follow-up.

Local checks: `tsgo:core`, oxfmt and type-aware oxlint on changed files, focused tests (rebuild, lifecycle integration, catalog renewal, chat-metadata runtime and refresh, scoped refresh, catalog owner, native demand: 119 passed), UI E2E case above. `prepared-model-runtime.catalog-retention.test.ts` fails locally before any product code with `gc is not defined` (the local runner does not expose `gc`); left to CI.

Limits: other Pueue jobs shared the host during both bench runs. The remote catalog is adopted only at startup or every 6 h, so each catalog-swap rep restarts the Gateway with a new catalog URL.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…rebuilds (openclaw#173585)

## What Problem This Solves

Fixes: model pickers wait for, fail on, or briefly lose models while the Gateway rebuilds its model catalog after a settings change, sign-in, sign-out, key removal or plugin reload.

## User Impact

`models.list` now answers from the last published list while the catalog owner rebuilds, instead of waiting for the replacement owner or failing with "Chat metadata access changed while preparing its metadata". A provider whose config, credentials, configured models or owning plugin changed is removed from that list at once and returns when the new catalog has it. Additions may appear late; removals are never shown.

Remaining limit (not fixed here): during a reload, synchronous plugin metadata rescans still block the Gateway main thread for 0.3–2 s, so any RPC (including a trivial `last-heartbeat`) is slow in that window. Tracked as a separate follow-up.

## Why This Change Was Made

Two waits sat on the read path:

- `chat-metadata-runtime.ts` `readCurrent` awaited the pending refresh, which awaits the model-runtime replacement gate. Added in openclaw#170805 to stop failures for healthy agents: "The existing model-runtime publication barrier owns replacement readiness; metadata follows it rather than constructing partial facts ahead of its commit." That PR states latency was not benchmarked.
- `server-model-catalog.ts` `readPreparedGatewayModelCatalogOwnerSnapshot` awaits the same gate (openclaw#160274: "model/auth replacements use the existing publication barrier, which catalog reads await before reacquiring the current owner").

Both waits avoid errors; neither protects data the previous list cannot serve. Hot reloads also retire the previous owners immediately, so reads raced into retired owners and failed.

Changes:

1. **Read side** (`chat-metadata-runtime.ts`, `chat-metadata-model-list.ts`): keep the last result per request shape. While a refresh, replacement, auth change or retired owner is pending, serve it minus providers whose identity changed (provider config slice, `auth.profiles`/order, runtime auth-store profiles, every configured model ref the visibility owner admits (primary, fallbacks, model maps, utility, image and PDF models), owning plugin entries). Any edit to the config `env` section hides every provider until the new catalog publishes, because it can hold any provider's key. A change to `agents.*.modelPolicy` does the same, since a policy can name any provider's models. A requester who now has personal-account links is never served the retained shared list; the read takes the existing personal-projection path. Superseded/unavailable read errors fall back to the same retained list; other errors still surface.
2. **Catalog owner** (`prepared-model-runtime.catalog-source.ts`): a rebuild keeps a provider's discovered rows when only the installed-plugin fingerprint changed and the provider's own source and credentials are unchanged. Those rows are marked provisional and reacquired by the post-commit changed-provider refresh. The owning plugin's package version and install-record hash join the provider source, so an upgraded provider plugin does not carry its old rows. Native harness rows keep the existing rule (dropped when any agent/plugin setting changes), because a harness may list models from any of those settings.

State table used for the change:

| Event | During rebuild | After commit |
|---|---|---|
| Model-neutral setting | previous list | same |
| Provider P config/credentials changed, deleted, or signed out | previous − P | P returns when rediscovered |
| Plugin config change (no provider change) | previous list | provisional rows until rediscovered |
| Sign-in to new provider Q | previous list | Q added when known |
| Remote catalog swap | previous list (not adopted yet) | atomic switch (openclaw#158000, openclaw#167178) |

## Evidence

Regression test `server-chat-metadata-lifecycle.rebuild.test.ts`: holds the replacement owner's catalog build forever (a provider that never answers), then reads `models.list` with a 1 s budget. On main it fails with `models.list waited for the rebuild`; with this change it passes, and it checks that signing out, removing the configured model and editing the config `env` section each hide `openai/gpt-5.4` before the replacement publishes (the `env`, model-policy and primary-model steps each fail without their identity field). `chat-metadata-runtime.personal-accounts.test.ts` adds a case where a requester connects a personal account while the owner is retired; the read declines the retained shared list (fails without the link check). Two existing tests now assert the new contract: a retired owner without a published replacement serves its last list instead of rejecting (`models.prepared.test.ts`), and the readiness test holds the replacement's own list preparation after the refresh (`chat-metadata-model-list-readiness.test.ts`).

UI guard `chat-loading-deadlines.e2e.test.ts`: an existing chat sends a message while `models.list` never answers (passes on main and here; no UI change needed).

Isolated Gateway bench (real entry point, built `dist`, n = 12 per event): fake vLLM (healthy), Ollama that never answers, Codex app-server whose `model/list` never answers. Back-to-back `models.list {view: "configured"}` reads tagged *during* the triggering RPC. Times in ms.

| Event (during) | main p50 / p99 / max | failed | this PR p50 / p99 / max | failed |
|---|---|---|---|---|
| settings change (model) | 1.5 / 323 / 344 | 0 | 1.5 / 235 / 322 | 0 |
| plugin settings change | 1.6 / 366 / 1547 | 12 | 1.3 / 266 / 752 | 0 |
| sign-in | 2.2 / 613 / 763 | 1 | 2.4 / 624 / 1196 | 0 |
| sign-out | 1.6 / 781 / 907 | 12 | 1.9 / 378 / 537 | 0 |
| provider deleted | 2.3 / 1169 / 1799 | 0 | 2.4 / 825 / 2297 | 0 |
| plugin reload | 1.5 / 490 / 1080 | 12 | 2.0 / 470 / 818 | 0 |
| catalog swap | 1.7 / 84 / 654 | 0 | 1.7 / 94 / 463 | 0 |
| restart (first reads) | 1.5 / 131 / 335 | 0 | 1.6 / 105 / 281 | 0 |

No read after a sign-out or provider deletion returned that provider (0 violations in both runs).

Why p99 is still above 300 ms: a lag probe (`last-heartbeat` issued with each read) is as slow as `models.list` in every slow sample (for example 1453 vs 1445 ms), so the read path no longer waits. A Gateway `--cpu-prof` during sign-in / provider deletion / plugin reload attributes the busy main-thread segments to `loadPluginMetadataSnapshot` → installed plugin index rebuild with synchronous `lstat`/`read`/`realpath` (~26%), module compile/link of reloaded plugin code (~24%) and managed reload `publishRuntime` (~15%). Top callers: `resolveManifestPluginsForModelIdNormalization` and `resolveConfigWidePluginMetadataSnapshot`. That is the follow-up.

Local checks: `tsgo:core`, oxfmt and type-aware oxlint on changed files, focused tests (rebuild, lifecycle integration, catalog renewal, chat-metadata runtime and refresh, scoped refresh, catalog owner, native demand: 119 passed), UI E2E case above. `prepared-model-runtime.catalog-retention.test.ts` fails locally before any product code with `gc is not defined` (the local runner does not expose `gc`); left to CI.

Limits: other Pueue jobs shared the host during both bench runs. The remote catalog is adopted only at startup or every 6 h, so each catalog-swap rep restarts the Gateway with a new catalog URL.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed 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