Skip to content

fix(cli): validate the selected model during config writes - #144474

Merged
steipete merged 2 commits into
mainfrom
codex/cli-model-validation-main-20260910-v5
Sep 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/cli-model-validation-main-20260910-v5

Conversation

@steipete

@steipete steipete commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130706. Builds on #144429.

What Problem This Solves

Fixes an issue where CLI config validation can resolve an authored model alias twice and validate a different model. With entry → middle → final, a cold primary can materialize final at 4,096 tokens instead of middle at 32,000. A matching warm fallback can call its runtime normalizer before applying the manifest alias.

Why This Change Was Made

Derive primary and fallback references from metadata captured during read-only runtime admission, then materialize the selected model without another input-alias pass. The existing helpers receive that snapshot explicitly, including bare defaults repaired by #144429. The read-only acquisition facade reuses the existing lease-options contract while preserving ephemeral ownership, live defaults, cancellation and release. Production delta: +19 lines.

User Impact

Config writes validate the intended model while preserving the authored reference. Cold and warm validation use the same static-before-runtime normalization order, and rejected writes leave config bytes unchanged.

Evidence

Production/runtime validation is bound to 8216e47759774f63abb1f8ff284bce3cbb12417c against the actual #144429 merge, cc748884201771eeac74dc6d8cf0c5b758bade76.

  • Matching baseline: three intended failures and 20 passing controls. Candidate: 201 tests across 10 files, full pinned changed-file gate and clean independent P2 review.
  • One normal full build passed with natural metadata bound to the committed source.
  • All 21 compiled CLI cases passed using 21 ordinary validation commands and 10 fixture installs. Eighteen accepted writes preserved authored refs; three rejected writes left config bytes identical.
  • Covered cold aliases/exact IDs, bare defaults, batch enable/disable, native API ownership, runtime-only and foreign controls, and actual warm primary/fallback commands. The matching warm fallback receives middle before its runtime hook and materializes middle-runtime at 64,000 tokens. Native cases retain configured pin-customer while the admitted ollama hook runs.
  • All 31 children joined without timeout. All 14,639 build outputs and source remained unchanged; 3,387 executed files verified. Successful-case state was removed after exit.

The first compiled matrix passed 19/21 cases but lacked native hook observations because its fixture did not declare the configured logical namespace. That failed attempt remains recorded. The final matrix corrected only external manifest ownership and strengthened namespace assertions; source and build stayed unchanged. This proves compiled CLI/config-write and provider-hook behavior, not hosted vendor inference.

Current test-only follow-up: 7a4d91c8a9a990777de0c1dfa6f8c6efe0d58420. CI found a missed adapter in an existing isolated-probe fixture: it still treated the new options object as a positional AbortSignal. The fixture now reads options.abortSignal and expects the exact { abortSignal, catalogMode: "static" } call, preserving all cancellation, isolation, release and queue-cleanup assertions. The local baseline reproduced all three failures; the correction passed 61 affected/sibling tests, the full changed-file gate and fresh P2 review. Production and package inputs are identical; the original 8216 build and 21-case/31-child compiled proof are explicitly carried after byte verification. No build was repeated or restamped. Fresh CI is required for this updated head.

Resolve primary and fallback selections from the metadata captured during
read-only runtime admission, then materialize the selected identity without
reapplying authored input aliases. Forward the snapshot explicitly so bare
defaults use the canonical resolver's captured-metadata path.

Reuse the lease options contract while preserving ephemeral read-only ownership,
live catalog defaults, cancellation, and the isolated runner's static mode.
Cover cold, matching, foreign, runtime-only, and bare-default model validation,
including manifest normalization before the matching fallback runtime hook.
@clawsweeper

clawsweeper Bot commented Sep 10, 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 agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 10, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 7:59 PM ET / 23:59 UTC (Revision 3).

ClawSweeper review

What this changes

CLI config validation now uses captured provider metadata to validate the selected model without resolving its aliases again, while preserving authored configuration and updating runtime lease callers.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on fetched main and addresses the documented validation contract. No blocking introduced defect was found; the test-only follow-up preserves the production implementation and its recorded proof.

Priority: P2
Reviewed head: 7a4d91c8a9a990777de0c1dfa6f8c6efe0d58420

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant compiled CLI observations, meaningful regression coverage, and no blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The recorded compiled CLI runs exercise config writes through provider admission and model materialization, observing correct selected identities and preserved config bytes; the latest test-only adapter change leaves those production inputs unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The recorded compiled CLI runs exercise config writes through provider admission and model materialization, observing correct selected identities and preserved config bytes; the latest test-only adapter change leaves those production inputs unchanged.
Evidence reviewed 11 items Introduced production repair: The pinned merge-base comparison shows reference selection moving into the existing admission callback and model materialization receiving modelIdSource: selected. The authored configuration is not rewritten.
Existing owner and normalization contract: Admission already derives selections under captured metadata; the model resolver already distinguishes authored input from selected identities. The patch consumes these OpenClaw-owned contracts without adding a public plugin API or depending on Codex harness behavior.
Lease lifecycle preserved: The read-only facade retains ephemeral ownership and its live catalog default while forwarding the existing options contract. Production call sites preserve cancellation and isolated-probe static catalog selection.
Findings None None.
Security None None.

How this fits together

CLI configuration writes validate changed primary and fallback models before saving. Provider metadata and an isolated runtime supply the selected model’s identity and capabilities, allowing validation to accept or reject the write.

flowchart TD
  A[CLI configuration change] --> B[Collect changed model references]
  B --> C[Capture provider metadata]
  C --> D[Resolve aliases once]
  D --> E[Materialize selected model]
  E --> F{Model supported?}
  F -->|Yes| G[Save authored reference]
  F -->|No| H[Reject without changing config]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +19, Tests +165. Total +184 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 3 47 28 +19
Tests 13 198 33 +165
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 245 61 +184

Review metrics

None.

Technical review

Best possible solution:

Keep model selection within captured admission metadata and materialize that identity once, preserving authored references and existing rejection behavior.

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

Yes, from source: a chained alias can be normalized during selection and again during materialization on fetched main. The PR records failing baseline cases; this read-only review did not execute tests.

Is this the best way to solve the issue?

Yes. The patch reuses existing captured-metadata and selected-identity contracts, with focused coverage for normalization order, unchanged configuration, and runtime cleanup.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 48b319e240fa.

Labels

Label justifications:

  • P2: This repairs a bounded CLI validation defect where chained model aliases can select the wrong model metadata.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The recorded compiled CLI runs exercise config writes through provider admission and model materialization, observing correct selected identities and preserved config bytes; the latest test-only adapter change leaves those production inputs unchanged.
  • proof: sufficient: Contributor real behavior proof is sufficient. The recorded compiled CLI runs exercise config writes through provider admission and model materialization, observing correct selected identities and preserved config bytes; the latest test-only adapter change leaves those production inputs unchanged.

Evidence

What I checked:

  • Introduced production repair: The pinned merge-base comparison shows reference selection moving into the existing admission callback and model materialization receiving modelIdSource: selected. The authored configuration is not rewritten. (src/cli/config-model-validation.ts:442, 7a4d91c8a9a9)
  • Existing owner and normalization contract: Admission already derives selections under captured metadata; the model resolver already distinguishes authored input from selected identities. The patch consumes these OpenClaw-owned contracts without adding a public plugin API or depending on Codex harness behavior. (src/agents/prepared-model-runtime-lease.ts:157, 7a4d91c8a9a9)
  • Lease lifecycle preserved: The read-only facade retains ephemeral ownership and its live catalog default while forwarding the existing options contract. Production call sites preserve cancellation and isolated-probe static catalog selection. (src/agents/prepared-model-runtime.ts:393, 7a4d91c8a9a9)
  • Current-main necessity: Fetched main still selects references before admission and materializes them without modelIdSource: selected, retaining the second alias pass addressed by this PR. (src/cli/config-model-validation.ts:414, 48b319e240fa)
  • Latest-release comparison: The v2026.9.3 validator also uses the earlier selection/materialization sequence; this repair is not already present in the supplied latest release. (src/cli/config-model-validation.ts, 1391f7cd2d40)
  • Documented write behavior: The CLI documentation requires validation of the selected primary or fallback without replacing it, and rejection of unknown references without changing active configuration. Public docs: docs/cli/config.md. (docs/cli/config.md:199, 7a4d91c8a9a9)

Likely related people:

  • steipete: 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-10T23:12:53.653Z sha 8216e47 :: needs changes before merge. :: none
  • reviewed 2026-09-10T23:22:07.797Z sha 8216e47 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 10, 2026 23:17
Read the AbortSignal from the existing lease options object and assert the
static catalog mode in that same object. Preserve the isolated-generation,
cancellation reason, parent signal, release, and queue cleanup assertions.
@steipete
steipete merged commit 773b9df into main Sep 11, 2026
181 of 183 checks passed
@steipete
steipete deleted the codex/cli-model-validation-main-20260910-v5 branch September 11, 2026 01:04
@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 11, 2026
…144474)

* fix(cli): validate model refs with captured provider metadata

Resolve primary and fallback selections from the metadata captured during
read-only runtime admission, then materialize the selected identity without
reapplying authored input aliases. Forward the snapshot explicitly so bare
defaults use the canonical resolver's captured-metadata path.

Reuse the lease options contract while preserving ephemeral read-only ownership,
live catalog defaults, cancellation, and the isolated runner's static mode.
Cover cold, matching, foreign, runtime-only, and bare-default model validation,
including manifest normalization before the matching fallback runtime hook.

* test(agents): adapt isolated probe mock to lease options

Read the AbortSignal from the existing lease options object and assert the
static catalog mode in that same object. Preserve the isolated-generation,
cancellation reason, parent signal, release, and queue cleanup assertions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes maintainer Maintainer-authored PR 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. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant