Skip to content

refactor(channels): reuse wildcard model matcher - #129125

Merged
steipete merged 1 commit into
mainfrom
codex/channel-routing-dedupe
Aug 25, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/channel-routing-dedupe

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

channels.modelByChannel wildcard fallback had a second, hand-written resolution branch when a conversation produced no direct or parent candidates. That duplicated wildcard-selection policy already owned by the shared channel-entry matcher and created an unnecessary drift point in channel model routing.

Why This Change Was Made

The stale early return is deleted so empty candidate lists flow through resolveChannelEntryMatchWithFallback, the canonical direct/parent/wildcard matcher. That matcher already returns the wildcard entry with matchKey: "*" and matchSource: "wildcard"; model and channel normalization continue through the existing common result path.

Rejected alternatives: adding a result-builder abstraction would add production code for the same behavior, while changing direct-match resolution would widen the routing-policy surface. This deletion keeps precedence, plugin-owned candidate construction, config shape, and provider behavior unchanged.

Production LOC: −13 (+0/−13). Test LOC: 0. No new test was added because the retained applies provider wildcard model overrides to direct chats regression already exercises the exact no-candidate wildcard boundary.

User Impact

No user-visible behavior or compatibility change. Operators retain identical direct, group, parent-session, plugin-owned, and wildcard model override behavior with one fewer duplicate routing branch.

Evidence

Exact reviewed head: 481ab0110e7bf3d8a40cd8575e6a64e7423a33fb

  • node scripts/run-vitest.mjs src/channels/model-overrides.test.ts — 19/19 passed.
  • node scripts/check-changed.mjs -- src/channels/model-overrides.ts — all selected production, typecheck, lint, architecture, and guard lanes passed.
  • git diff --check and targeted oxfmt --check — passed.
  • Deslop — clean; final diff is deletion-only.
  • Autoreview (Codex, high) — clean, patch correct (0.99), no accepted/actionable findings.
  • Independent Codex review of the frozen head — PASS, no findings.
  • Open issue/PR and history checks found no active overlap on src/channels/model-overrides.ts; related session/model PRs own different files and behavior.
  • Hosted CI: pending on this draft head; exact-head results will be verified before landing.

Credit: investigation and patch authored by Amp for @steipete.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 07:44
@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 Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 3:50 AM ET / 07:50 UTC.

ClawSweeper review

What this changes

The PR deletes a duplicate wildcard-only channel model-override branch so empty candidate lists use the shared direct/parent/wildcard matcher.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: this is a focused, behavior-preserving refactor from a member author, and source review supports the canonical matcher path. Rebase onto current main and require exact-head CI before landing.

Priority: P3
Reviewed head: 481ab0110e7bf3d8a40cd8575e6a64e7423a33fb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, source-supported canonicalization with retained boundary coverage; only exact-head rebase and CI remain before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored internal refactor is outside the external-contributor real-behavior-proof gate; the PR body supplies focused test evidence as supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored internal refactor is outside the external-contributor real-behavior-proof gate; the PR body supplies focused test evidence as supplemental validation.
Evidence reviewed 7 items Patched owner boundary: The PR now always passes normal and empty candidate lists to the shared matcher, then normalizes its selected entry through the common return path.
Current-main matcher contract: The shared matcher checks direct and parent candidates before returning the configured wildcard with wildcard metadata, including when both candidate arrays are empty.
Retained boundary coverage: Current-main coverage invokes a direct chat with no peer identifiers and asserts the wildcard model, key, and source; this is the deleted branch’s observable boundary.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129125-PD9sFL/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 104.84 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.6s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4585ms (slowest: built plugin control-plane loads 3663ms)

OpenClaw 2026.8.1 (481ab01) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw [options] [command]

How this fits together

Channel model overrides select a configured model from an incoming conversation’s channel, peer, group, or parent-session identifiers. The selected override feeds agent reply and command model routing.

flowchart LR
  A[Incoming channel message] --> B[Conversation identifiers]
  B --> C[Model override resolver]
  C --> D[Shared channel matcher]
  D --> E[Direct or parent match]
  D --> F[Wildcard match]
  E --> G[Selected model route]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main and hosted exact-head checks are still incomplete; rebase and rerun the focused gate before landing.
  • Complete next step (P2) - No repair lane is needed: the patch is correct, and the only remaining action is normal rebase and exact-head validation for this maintainer-owned PR.
Agent review details

Security

None.

PR surface

Source -13. Total -13 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 0 13 -13
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 1 0 13 -13

Review metrics

Metric Value Why it matters
Production versus test delta production −13, tests 0 The deletion removes duplicate routing policy while retained boundary coverage already protects the no-candidate wildcard result.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one canonical wildcard-resolution path in the shared matcher, then land this deletion after an exact-head rebase and green focused validation.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one canonical wildcard-resolution path in the shared matcher, then land this deletion after an exact-head rebase and green focused validation.

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

Not applicable: this PR refactors an existing resolver rather than reporting a standalone failure; the retained test exercises the relevant wildcard boundary.

Is this the best way to solve the issue?

Yes: the shared matcher already owns direct, parent, normalized, and wildcard precedence, so removing the special branch avoids policy drift without changing configuration behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a small internal routing-policy deduplication with no intended user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored internal refactor is outside the external-contributor real-behavior-proof gate; the PR body supplies focused test evidence as supplemental validation.

Label justifications:

  • P3: This is a small internal routing-policy deduplication with no intended user-visible behavior change.
  • 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: This member-authored internal refactor is outside the external-contributor real-behavior-proof gate; the PR body supplies focused test evidence as supplemental validation.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main history and blame associate Peter Steinberger with the channel matcher, resolver, and retained wildcard regression. (role: recent area contributor and current-surface author; confidence: high; commits: 4e8e22f5b17f, 0790d9f593ad; files: src/channels/model-overrides.ts, src/channels/channel-config.ts, src/channels/model-overrides.test.ts)
  • thomas.szbay: History identifies the direct-user model-override work as an earlier contributor to the same resolver and test surface. (role: direct-message override contributor; confidence: medium; commits: 9bf681d663e9; files: src/channels/model-overrides.ts, src/channels/model-overrides.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and confirm the focused model-override test and changed-path checks are green on the resulting head.

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.

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 481ab0110e7bf3d8a40cd8575e6a64e7423a33fb:

  • Root simplification: the no-candidate wildcard early return duplicated wildcard policy already owned by resolveChannelEntryMatchWithFallback; the shared matcher now handles empty candidate lists and the existing common normalization/result path remains authoritative.
  • Surface/LOC: src/channels/model-overrides.ts only; production +0/-13, tests +0/-0. Direct, normalized-direct, parent-session, plugin-owned candidate, and wildcard precedence are unchanged.
  • Focused proof: node scripts/run-vitest.mjs src/channels/model-overrides.test.ts (19/19 passed), then node scripts/check-changed.mjs -- src/channels/model-overrides.ts (all selected production/typecheck/lint/architecture/guard lanes passed), targeted oxfmt --check, and git diff --check.
  • Exact-head hosted CI: run 32823099808 succeeded; the sparse watcher reached GREEN with no pending or failed checks.
  • Native landing gate: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 129125 passed at 2026-08-25T08:11:28Z in hosted_exact_or_recent_parent mode and verified the remote PR tree. No separate Testbox lease/run was dispatched because the wrapper accepted the already-green exact hosted head.
  • Reviews: deslop clean; mandatory autoreview clean (patch is correct, 0.99, no accepted/actionable findings); independent exact-head Codex review PASS/no findings; latest ClawSweeper review found no code or security findings.

ClawSweeper rank-up move disposition: skip the optional rebase. Current main has not changed src/channels/model-overrides.ts, src/channels/model-overrides.test.ts, or src/channels/channel-config.ts since this PR's merge base; merge simulation is conflict-free; and repository landing policy says not to rewrite a reviewed branch solely for behind-main drift. The substantive part of the move—exact-head focused/changed-path/hosted validation—is complete and green. Native prepare-run likewise intentionally initialized without rebasing and accepted the exact hosted gate.

Known proof gap: no live provider/channel credential run. This is intentional and non-blocking because the deletion changes no provider API call, config contract, or channel delivery behavior; the retained owner-boundary regression directly exercises the deleted no-candidate wildcard outcome and metadata.

@steipete
steipete merged commit f08443e into main Aug 25, 2026
305 checks passed
@steipete
steipete deleted the codex/channel-routing-dedupe branch August 25, 2026 08:13

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: XS 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