Skip to content

fix(models): stop interrupted catalog reads across CLI diagnostics - #197174

Merged
obviyus merged 5 commits into
openclaw:mainfrom
Alix-007:alix/fix-model-catalog-read-cancellation-20261111
Nov 11, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
Alix-007:alix/fix-model-catalog-read-cancellation-20261111

Conversation

@Alix-007

@Alix-007 Alix-007 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: interrupting a pending published model-catalog read in the CLI acknowledges Ctrl-C but leaves the request alive until the launcher kills the command.

User Impact

User impact: model inventory, status and model-reference lint stop their pending catalog reads with the normal SIGINT/SIGTERM status. Explicit catalog refresh still returns its already-admitted result. Ordinary offline diagnostics, independent lease-abort findings, configuration and schemas keep their existing behavior.

Why This Change Was Made

Forward explicit read-owner cancellation through the shared selected-Gateway catalog boundary. Keep cancellation from becoming offline fallback or lint findings, and check the existing command signal before publishing a lint report. Quiet the public read formatter before it can misreport interruption as failure; read and refresh ownership remain separate.

Evidence

Product head: 38a03aa8f497a9647bbcf87c00c325bd49305be8; acceptance-red base: 83872e599d5720c0bc97d313283a2bc245046699.

  • Normal CLI / PTY / network: identical frozen scenarios exercise models list, models status, and doctor --lint --only core/doctor/model-references against a compatible loopback WebSocket recorder advertising the published-model-catalog capability. Both versions use the normal qaRuntime build and launcher. Ctrl-C arrives through the controlling PTY; SIGTERM targets only the owned process group.
  • Acceptance red → green: all eight held catalog reads on BASE acknowledge interruption but require the CLI launcher's emergency SIGKILL after 2062.31–2069.29 ms. The harness watchdog never fires. HEAD naturally exits 130/143 within 200.58 ms, closes the peer within 41.91 ms, and remains quiet after the interruption notice: no result JSON, cancellation-error JSON, lint finding, or generic CLI-failure banner. Every owned CLI process is gone before peer cleanup.
  • Six legal controls: normal list connect/RPC, status and Doctor produce their expected JSON; Doctor runs exactly one selected check with no findings. Explicit models list --refresh retains its ordinary result and its delayed already-admitted result after SIGINT, then exits 130. Config hashes remain unchanged. 14/14 expected outcomes pass on each version. The recorder proves CLI request, result, interruption and connection lifecycle; it does not claim real Gateway catalog persistence or provider behavior.
  • Checks: node scripts/run-vitest.mjs src/commands/models/list.prepared-catalog.test.ts src/commands/models/list.status.test.ts src/flows/doctor-model-reference-check.test.ts src/flows/doctor-lint-flow.test.ts src/commands/doctor-lint.snapshot-cleanup.test.ts src/cli/program/register.maintenance.test.ts src/cli/route.test.ts src/cli/capability-cli/model.auth-status.test.ts --maxWorkers=1: 151 passed across eight files, 163.534 seconds total command wall time. The canonical runner includes multiple Vitest shards and real read-only snapshot/cleanup fixtures; time includes worker startup and collection. Targeted types, lint, format, exact staged test-line budget, unchanged mock-factory check, normal build and fresh independent adversarial review pass; findings: None. No timeout or shared baseline was relaxed.

Frozen collector, paired raw receipts/streams, checks and independent review. Evidence assets are outside the product branch.

Replay, complete owner coverage and limitations
python3 models-catalog-cancel-proof-v4.py CHECKOUT NEW_OUTPUT NODE26 EXPECTATION

Use tracked-clean BASE/HEAD checkouts normally built with node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime, fresh output directories and red / green expectations. Frozen collector SHA-256: 1ca902758c242f0a8146ece44e5a91dd7908a268e8ad7f6662f3f26f704a4da8; peer: 86f3bdb05b79415dcb3d800510d1dbe6ded327d2d40764878faaae4750c2e294. Scenarios, fixture configuration, entry and controls are the same; only checkout/output and expectation change. Earlier v2 runs were blocked by a fixture flag hiding Doctor's public surfaces; v3 corrected that input before production edits. An unpublished v3 HEAD replay then caught unwanted cancellation-error output; v4 preserves all transport/control assertions and strengthens the output oracle to the quiet-read behavior accepted in #197110. Both published receipts use the same frozen v4.

Twelve files: eight production files +121/-32, three test files +89/-13 (net 76 LF) and an exact own-regression allocation. This covers the complete selected-catalog caller set: public list, public status (also the bare models command), and Doctor model references. Non-cancellation diagnostic failures keep their offline fallback; independent state-lease-aborted findings still allow later checks. The list regression table retains the original authorization-failure case and adds pre-abort, late success/error and admitted-refresh controls; lint tests cover cancellation before/during detection and skipping later checks. Existing status, Doctor reference and snapshot-cleanup suites remain covered. Mock factories and their ledger are unchanged; full repository checking remains for CI.

Public list/status leaves own quiet cancellation across the lightweight route, Commander and capability callers. Their private implementations receive the captured signal explicitly; shared catalog reads never acquire ambient policy. Existing status options and synthetic-auth types move to the related types owner, reducing the oversized status file from1463 to1457 LF without changing the two-argument public command contract. Doctor supplies its existing read/process owner, and final report publication checks the outer command signal, which survives normal read-scope cleanup. Explicit refresh retains its existing 210-second budget and response/local-state-owner/proxy lifecycle.

Cleanup: The collector verifies actual peer disconnect and an empty owned CLI process group before retiring its protocol peer. Its allowlisted environments and HOME/config/state/workspace are isolated; all credentials, models and responses are synthetic. Only Doctor cases enable the bundled public surfaces required by the real lint entry. Fixtures, raw streams and request records remain inspectable. No production service, external provider/channel or real user data is used.

Not tested: real Gateway catalog refresh/persistence, real provider discovery/authentication, later provider-usage HTTP stages in status, mutating Doctor maintenance/update flows, Windows/macOS and the full repository CI matrix.

Maintainer update

Scope change by the maintainer (owner call): this PR now covers only the models list and models status catalog reads. The Doctor lint changes (doctor-lint-runner.ts, doctor-lint-flow.ts, doctor-model-reference-check.ts and the Doctor CLI handling in register.maintenance.ts) and their tests are dropped, because Doctor code is outside this fix's scope. The added unit tests and the test-line allocation are also dropped so the PR adds no test lines; the runtime proof covers both commands: #197174 (comment)

@clawsweeper

clawsweeper Bot commented Nov 11, 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 cli CLI command changes commands Command implementations size: M labels Nov 11, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR cancels interrupted model list/status catalog reads quietly while preserving explicit refresh results.

Example: Press Ctrl-C while openclaw models list --json waits for a Gateway catalog response.

  • Before: The command acknowledges interruption but retains the connection until the launcher force-kills it.
  • After: The command closes the connection and exits 130 without late JSON or an error banner.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair using existing cancellation owners, supported by shipped-CLI transport proof and a recorded owner decision; broad CI is still pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The normally built CLI exercises interrupted list/status catalog reads through its real WebSocket client in a secretless Docker PTY; current-head runs show quiet exit 130 and peer disconnect, with ordinary-output controls preserved, while inspected earlier-head receipts additionally cover SIGTERM, pending connection setup, and admitted-refresh results.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Ctrl-C acknowledges interruption of model inspection but leaves its catalog request alive until forced termination.
Reason: The bounded lifecycle repair has demonstrated user value and follows obviyus's recorded scope decision to retain only model list/status changes.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI cancellation bug within the maintainer-approved scope; no actionable introduced defect was found, and exact-head CI remains pending.

Priority: P2
Reviewed head: 6ab1bbf256452b6763faf2bf2253077709aefdf5

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI model inspection reads published inventory through the selected-Gateway catalog reader; command cancellation now reaches the existing WebSocket client cleanup, while explicit refresh retains its existing lifecycle.

flowchart TD
  A[CLI command signal] --> B[Model list or status]
  B --> C[Selected catalog reader]
  C --> D[Gateway WebSocket client]
  D --> E[Published model catalog]
  C --> F[Diagnostic output]
  A --> D
Loading

Technical review

Best possible solution:

Use the existing command signal and Gateway cancellation owner for passive catalog reads while preserving refresh result custody.

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

The supplied paired PTY runs reproduce forced termination on main and natural cancellation on the reviewed head; current-main source retains the same missing signal.

Is this the best way to solve the issue?

The patch repairs the existing ownership chain without a new transport or state owner, and the shared public wrapper covers routed, Commander, and capability callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2c2249188e2c.

Provenance checked

  • Selected-Gateway inventory and explicit refresh ownership keeps the original intent (refactor(models): read published catalog inventory through the Gateway #142063: Passive browsing consumes published inventory; explicit refresh owns acquisition and selected-server failures must not switch inventories.)
  • Shared catalog reader and offline diagnostic fallback keeps the original intent (1bee6ae: Share server-catalog diagnostics while preserving selectable declarations and ordinary offline behavior.)
  • Diagnostic reader reuse keeps the original intent (fix(doctor): recognize models published by the selected Gateway #179907: Reuse the selected Gateway's prepared catalog for model membership diagnostics without configuration or provider-discovery changes.)
  • Status options and synthetic-auth types keeps the original intent (6861671: Existing status and synthetic-auth contracts are moved unchanged to the related types module so the oversized status implementation does not grow.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +69. Total +69 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 99 30 +69
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 99 30 +69

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Interrupted model inspection retains a pending connection until forced termination, affecting a bounded CLI diagnostic workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-11T10:49:25.739Z sha 38a03aa :: needs maintainer review before merge. :: none

Reviewed November 11, 2026, 6:36 AM ET / 11:36 UTC (Revision 2).

Drop the Doctor lint changes (owner call: Doctor code is out of this fix's scope)
and the test additions; the runtime proof covers the models list/status paths.
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed cli CLI command changes size: M labels Nov 11, 2026
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Runtime proof: main 6a411d6 against this PR at 6ab1bbf (main merged in, Doctor part dropped), two runs each.

Setup

  • The built CLI runs on node:24.22.1 in a secretless Docker container, in a real PTY with the normal launcher. Ctrl-C is the PTY interrupt key.
  • The catalog read is held by a local Gateway stand-in. It speaks the Gateway WebSocket handshake (connect.challenge, hello-ok with the published-model-catalog capability) and holds models.list for 6 s, like a busy Gateway.
  • The CLI is pointed at the stand-in with OPENCLAW_GATEWAY_PORT. Ctrl-C goes in 300 ms after the stand-in reports the held read.
  • I first tried a stalled provider stand-in behind a real built Gateway. It does not hold the read: models list --json returned in 1.8 s while LM Studio's /api/v1/models was stalled, because the Gateway serves already-published rows.
Run Main This PR
models list --json, Ctrl-C while held run 1: SIGKILL 2,032 ms after Ctrl-C; run 2: SIGKILL 2,169 ms run 1: exit 130 after 137 ms; run 2: exit 130 after 70 ms
models status --json, Ctrl-C while held run 1: SIGKILL 2,156 ms; run 2: SIGKILL 2,030 ms run 1: exit 130 after 66 ms; run 2: exit 130 after 31 ms
  • On main the launcher's emergency SIGKILL ends both commands: they print Command interrupted by SIGINT. Waiting for cleanup before exiting. and then wait on the read.
  • On this PR both exit 130 on their own. After the same interrupt notice they print nothing: no late JSON and no error.
  • In every interrupted run the stand-in saw the client disconnect before it released the held response.

Controls (same output on main and this PR, apart from the Node process id in a deprecation warning)

  • Uninterrupted models list --json and models status --json against the stand-in, both runs.
  • Built Gateway with an unreachable LM Studio provider: uninterrupted models list --json and models status --json, exit 0.

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@obviyus
obviyus merged commit 55faec0 into openclaw:main Nov 11, 2026
127 of 130 checks passed
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Landed in 55faec0. Thanks @Alix-007.

@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for narrowing the scope and checking the built CLI interruption behavior in a real PTY!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…penclaw#197174)

fix(models): stop models list and models status promptly on Ctrl+C

Pressing Ctrl+C while openclaw models list or models status was waiting on the model catalog did not stop the read, so the CLI kept waiting until the launcher force-killed it about 2 seconds later. Both commands now pass the command's existing abort signal into their catalog reads, including the catalog warnings read used by models status, and exit without further output. No text changes. The Doctor lint changes from the original PR were dropped by owner call.

Evidence: the built CLI on node:24.22.1 in a real PTY with a local Gateway stand-in holding models.list, Ctrl+C sent while held, two runs each. On main both commands were force-killed about 2.0-2.2 s after Ctrl+C; with this change they exit 130 within 31-137 ms with nothing printed after the interrupt notice. Uninterrupted runs and a built Gateway with an unreachable provider give identical output on both. Net 0 test lines. Details: openclaw#197174 (comment).

Thanks @Alix-007.

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

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

2 participants