Skip to content

refactor(models): share selector reference traversal - #139571

Merged
steipete merged 1 commit into
mainfrom
fix/model-selector-traversal
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/model-selector-traversal

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintainer-requested follow-up to #139523. Five readers repeated the scalar/primary/fallback traversal for model selectors. Keeping those copies aligned made model discovery and Doctor repair harder to maintain.

Why This Change Was Made

One read-only visitor in the private model-catalog package now owns selector traversal. Callers retain their field inventories, trimming rules and primary-only runtime attribution. The cleanup also removes unused boolean bookkeeping from Doctor collectors. Existing mutation helpers keep their current behavior and ownership.

User Impact

No behavior change intended. Raw values, blank and duplicate ordering, original fallback indices, model inventories and migration behavior are preserved. No operator configuration, provider policy, stored representation, schema, protocol or dependency change.

Evidence

  • Current-main owner/sibling run: 252 tests across five files passed through node scripts/run-vitest.mjs. Coverage includes model-catalog readers, Doctor warnings/migrations, startup providers and harness routing.
  • The existing selector fixture is frozen and now checks both raw output and trimmed collector paths with blank/non-string index gaps and duplicates.
  • Full local changed-file gate passed. Final branch autoreview at ac0fe5a99108ffe0216f9cbc655bcc3afb6d5817 is scoped-clean P0–P2.
  • Patch-identical rebase onto the existing CI repair test(gateway): observe native drain without a lint exception #139576; 155 post-rebase tests passed (19 selector, 132 Doctor, four inventory guards). The initial CI failure came from the inherited suppression in improve: replace forced Gateway lifetime waits with real barriers #139483; no inventory exception was added.
  • Exact-head CI: 34003001204, GREEN.
  • First follow-up Blacksmith Testbox run 34002124939 passed at 5ef586738dcd386c387e2a5ed9e78b841f448e57: two baseline HTTP400 calls, two guarded failures with zero inference requests, typed history/actionable notices, persisted Doctor clear, and success on the unchanged default. Lease stopped.
  • Fresh exact-head Blacksmith Testbox 34002934680, lease tbx_01m1t3xamzynmp61kddhz8eddv, passed on verified source ac0fe5a99108ffe0216f9cbc655bcc3afb6d5817. Candidate and baseline full builds passed; source/tree identities were verified before and after execution. The native run exited 0. A later portal synchronization timeout did not affect the command or verdict.
  • ClawSweeper compatibility follow-through: this diff changes read traversal only. Mutation helpers, existing serialized references, schema and persistence owners are unchanged. The 132 Doctor cases cover migration/pin/inheritance behavior, and the Gateway proof exercises repair persistence and restart. No data-model migration or operator action is added.
  • Real ChatGPT-account proof was unavailable during the parent fix because the existing CI token needed refresh; no authenticated provider request is claimed. Shared notice rendering is covered by the real Gateway with a synthetic capture channel; no Telegram adapter changed.

git diff --numstat: production +45/−91 (net −46); tests +15/−6 (net +9). Three files, no generated or dependency changes.

Final live-proof transcript (synthetic HTTP provider and capture channel, real public CLI and isolated Gateway; free ports and task-owned state):

source: ac0fe5a99108ffe0216f9cbc655bcc3afb6d5817
baseline: 3383007573b010e3fb1387315eebca2853c4bf78
provider: blacksmith-testbox
lease: tbx_01m1t3xamzynmp61kddhz8eddv
baseline cron run x2: HTTP 400, two inference requests
candidate cron run x2: model_not_found recorded, two remedy notices, zero inference requests
openclaw doctor --fix: retired override cleared; agent default unchanged
restart isolated Gateway; run same cron job: ok, OPENCLAW_RETIRED_MODEL_RECOVERED
source/tree identities after run: verified
native command exit: 0
{"status":"pass","candidateSha":"ac0fe5a99108ffe0216f9cbc655bcc3afb6d5817","beforeProviderRequests":2,"guardedRuns":2,"guardedProviderRequests":0,"failureCode":"model_not_found","deliveredRemedyNotices":2,"overrideCleared":true,"agentDefaultUnchanged":true,"recoveredStatus":"ok","sourceIdentityVerifiedAfterRun":true}

This completes the requested separate refactor pass. No additional refactor is needed in these reader paths. Related bug/reporters remain credited in #139523 and #139235 (@alessi0p on X and Séraphin on Discord).

@clawsweeper

clawsweeper Bot commented Sep 6, 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 commands Command implementations size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 00:48
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 9:17 PM ET / September 6, 2026, 01:17 UTC.

ClawSweeper review

What this changes

Shares read-only traversal of configured primary and fallback models between model discovery and Doctor, preserving existing reference handling.

Merge readiness

⛔ Blocked before merge - 1 item remains

The maintainer-requested cleanup remains useful and is not present on inspected main. No actionable defect was found. The earlier migration-proof blocker is unsupported by this diff: traversal changes preserve existing outputs, and mutation and persistence semantics remain unchanged.

Priority: P3
Reviewed head: ac0fe5a99108ffe0216f9cbc655bcc3afb6d5817

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving refactor with useful contract coverage and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored read-only traversal cleanup is exempt from external-contributor proof requirements and introduces no material authority change; reported Gateway/Doctor recovery evidence remains supplemental, with the exact-head receipt unverified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored read-only traversal cleanup is exempt from external-contributor proof requirements and introduces no material authority change; reported Gateway/Doctor recovery evidence remains supplemental, with the exact-head receipt unverified.
Evidence reviewed 9 items Introduced traversal preserves the existing contract: The pinned base-to-head diff centralizes string and primary/fallback enumeration while retaining ordering, original fallback indices, caller-owned trimming, and primary-only runtime attribution. Rewrite helpers below the changed collectors are unchanged.
Caller compatibility: All located callers of the two collectors discard their former boolean results. Doctor's scanner retains its field inventory, runtime attribution, and blocked-model inputs. The previous and replacement record guards use the same non-array-object predicate.
Behavior-focused fixture: The existing fixture now freezes the selector and fallback array and checks raw values alongside trimmed paths, including blanks, non-string index gaps, and duplicates. The complete test file was inspected; tests were not executed during this read-only review.
Findings None None.
Security None None.

How this fits together

Model selectors contain a primary model and optional ordered fallbacks. OpenClaw reads these references for model discovery, startup requirements, and Doctor diagnostics and repairs.

flowchart TD
  A[Configured model selectors] --> B[Shared reference traversal]
  B --> C[Raw model references]
  B --> D[Paths and primary or fallback roles]
  C --> E[Model discovery and startup]
  D --> F[Doctor reference collectors]
  F --> G[Existing diagnostics and repair owners]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -46, Tests +9. Total -37 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 45 91 -46
Tests 1 15 6 +9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 60 97 -37

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor/shared/codex-route-model-slots.ts, unknown-data-model-change: src/commands/doctor/shared/codex-route-model-slots.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep one read-only selector traversal while leaving field inventories, normalization, and mutation decisions with their existing owners.

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

Not applicable: this PR consolidates existing readers and does not claim to repair a new observable defect.

Is this the best way to solve the issue?

Yes. The shared visitor removes duplicate traversal while preserving caller-specific semantics; inspected callers do not consume the removed return values.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1d9ce1ac9ffa.

Labels

Label justifications:

  • P3: This is a bounded maintenance cleanup that preserves model-selection and Doctor behavior.
  • 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 maintainer-authored read-only traversal cleanup is exempt from external-contributor proof requirements and introduces no material authority change; reported Gateway/Doctor recovery evidence remains supplemental, with the exact-head receipt unverified.

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)
  • Vincent Koc: 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 (2 earlier review cycles)
  • reviewed 2026-09-06T00:53:08.056Z sha 5ef586738dcd386c387e2a5ed9e78b841f448e57 :: blocked before merge. :: none
  • reviewed 2026-09-06T01:11:04.268Z sha ac0fe5a :: blocked before merge. :: none

@steipete
steipete force-pushed the fix/model-selector-traversal branch from 5ef5867 to ac0fe5a Compare September 6, 2026 01:05
@steipete
steipete merged commit abd18df into main Sep 6, 2026
185 checks passed
@steipete
steipete deleted the fix/model-selector-traversal branch September 6, 2026 01:21
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* origin/main: (302 commits)
  test(gateway): preserve held-work close failures (#139593)
  refactor(exec): share package argument scanning (#139560)
  fix(audit): preserve sequence range validation before numeric decoding (#139587)
  fix(transcripts): retain capture ownership through failed cleanup (#139572)
  refactor(models): share selector reference traversal (#139571)
  perf(agents): classify allowlists without intermediate sets (#138392)
  chore(release): update appcast for 2026.9.2 (#139575)
  fix(ci): synchronize cloud retries and board widget input (#139506)
  fix(plugins): explain SDK incompatibilities after core updates (#139458)
  fix(voice-call): retain installed WebSocket behavior under Bun (#139567)
  test(text): consolidate literal sanitizer cases (#139579)
  test(gateway): observe native drain without a lint exception (#139576)
  test(memory): consolidate visibility fixtures without policy defaults (#139569)
  fix(ui): show shimmer skeletons while loading Control UI (#139525)
  test(qa): make cleanup child logging deterministic (#139566)
  test(cli): keep Unix socket fixtures within path limits (#139565)
  fix: avoid slow incognito key checks in large session stores (#139528)
  feat(macos): open Gateway windows from the Gateways menu (#139522)
  test(workshop): isolate marker casing fixture identities (#139554)
  fix(process): require cleanup evidence before releasing owned work (#139517)
  ...

# Conflicts:
#	scripts/release-check.ts
vincentkoc added a commit that referenced this pull request Sep 6, 2026
* commit '047587a542ce205ee78354fbd88ba8ec05c07844': (45 commits)
  chore(ui): refresh control ui locales (#139481)
  fix(slack): keep prototype-named emoji shortcodes intact (#136374)
  fix(gateway): deliver upgrade rejection responses under Bun (#139516)
  refactor(test): simplify catalog guards and fix native report fixture (#139496)
  fix(macos): prevent dashboard fixture loopback timeouts (#139556)
  fix(matrix): preserve selected reply targets inside threads (#139479)
  test(gateway): preserve held-work close failures (#139593)
  refactor(exec): share package argument scanning (#139560)
  fix(audit): preserve sequence range validation before numeric decoding (#139587)
  fix(transcripts): retain capture ownership through failed cleanup (#139572)
  refactor(models): share selector reference traversal (#139571)
  perf(agents): classify allowlists without intermediate sets (#138392)
  chore(release): update appcast for 2026.9.2 (#139575)
  fix(ci): synchronize cloud retries and board widget input (#139506)
  fix(plugins): explain SDK incompatibilities after core updates (#139458)
  fix(voice-call): retain installed WebSocket behavior under Bun (#139567)
  test(text): consolidate literal sanitizer cases (#139579)
  test(gateway): observe native drain without a lint exception (#139576)
  test(memory): consolidate visibility fixtures without policy defaults (#139569)
  fix(ui): show shimmer skeletons while loading Control UI (#139525)
  ...
vincentkoc added a commit that referenced this pull request Sep 6, 2026
* commit 'refs/openclaw/tasks/pr-135167-main': (2467 commits)
  refactor(ios): reuse shared integer conversion (#139581)
  fix(sessions): prevent database lock failures during reclamation (#139469)
  perf(test): reuse transforms within owned scheduler slots (#139553)
  test(agents): share sparse transcript input fixtures (#139589)
  chore(ui): refresh control ui locales (#139481)
  fix(slack): keep prototype-named emoji shortcodes intact (#136374)
  fix(gateway): deliver upgrade rejection responses under Bun (#139516)
  refactor(test): simplify catalog guards and fix native report fixture (#139496)
  fix(macos): prevent dashboard fixture loopback timeouts (#139556)
  fix(matrix): preserve selected reply targets inside threads (#139479)
  test(gateway): preserve held-work close failures (#139593)
  refactor(exec): share package argument scanning (#139560)
  fix(audit): preserve sequence range validation before numeric decoding (#139587)
  fix(transcripts): retain capture ownership through failed cleanup (#139572)
  refactor(models): share selector reference traversal (#139571)
  perf(agents): classify allowlists without intermediate sets (#138392)
  chore(release): update appcast for 2026.9.2 (#139575)
  fix(ci): synchronize cloud retries and board widget input (#139506)
  fix(plugins): explain SDK incompatibilities after core updates (#139458)
  fix(voice-call): retain installed WebSocket behavior under Bun (#139567)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

1 participant