Skip to content

feat(route-audit): check pool ordering — OpenAI final reserve (#1173) - #12666

Open
dezren39 wants to merge 5 commits into
mainfrom
xaltha/1173-pool-ordering
Open

dezren39 wants to merge 5 commits into
mainfrom
xaltha/1173-pool-ordering

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes nothing yet — this is the next slice of #1173 (daily model + route audit). It automates the one pool-ordering rule that is decidable from the tracked config alone: OpenAI as final reserve. New checker bin/check-pool-ordering.mjs resolves each tier's effective pool order (reusing inspectRouteRules) and verifies that, in every ordered chain, an OpenAI-backed pool comes last, with fallback targets checked as separate passes (a tier's regular chain runs first and completely; each fallback is a second pass). Weighted/round-robin mixing is reported as a note (no reserve encoding is visible there), never a finding. Fixtures + the canonical-config check are wired into opencode-config-guard.

Rule reading decided in this slice (decision record on #1173): "final reserve" applies to ordered chains; in weighted/round-robin routes list position is not burn order, so mixing there is unknown, not a violation. Burn-by-expiry and cheapest-sufficient are NOT checked here — the tracked config carries no machine-readable expiry/cost fields, and the decided source for them (the #1270 plan store, per the 2026-11-16 triage) is not in this repo. That wiring is the named next slice.

Evidence

Before (on origin/main, no checker exists):

  • node bin/check-pool-ordering.mjs .opencode/opencode.jsonc — file does not exist; pool ordering was a by-hand step in the audit block.

After (this branch, commit 8f9affa2c, local run, no Rust involved):

  • node --test bin/check-pool-ordering.test.mjs — 6 pass, 0 fail. The violation fixture (ordered chain with the OpenAI-backed pool before a non-OpenAI pool) fires; the fallback-pass and weighted-mixing fixtures prove the pass split and the note-not-finding treatment.
  • node --test bin/*.test.mjs — 336 pass, 0 fail (full bin suite, incl. the route-rules, catalog-sync/snapshot, and metered-provider fixtures).
  • node bin/check-pool-ordering.mjs .opencode/opencode.jsonc — exit 0, 0 issues. Reserve verdicts: specialist pass (sol-plan last), summit pass (sol-plan last in the main chain), scout/workhorse n/a-or-pass per pass. Two notes, both the same underlying fact: luna-effort-rr shares workhorse-weighted (weighted) with non-OpenAI pools at equal/default weight — no reserve encoding is visible; needs the feat(quota-plane): plan-store / tracker / measured reconciliation diff (daily) #1270 plan store.
  • bash .github/scripts/check-suite-registry.sh — no entry needed; the new test file is covered by the existing bin/*.test.mjs glob.
  • Workflow YAML parses (python3 -c yaml.safe_load).

Evidence level: ran locally in the sandbox at 8f9affa2c (pure Node, no compile). The guard workflow runs nightly + on dispatch, not on PRs, so CI on this PR does not execute the new steps; the first nightly after merge is the CI run.

Merge Danger

Low. Additive only: two new files under bin/ plus two steps in opencode-config-guard.yml. No config change (the canonical config passes as-is), no routing behavior change, no dependency on the #1270 store yet. Revert is deleting the two files and the two workflow steps.


Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Add bin/check-pool-ordering.mjs: per tier, resolve the effective pool
order from the tracked config (reusing inspectRouteRules) and check the
OpenAI-final-reserve rule over ordered chains — an OpenAI-backed pool
must come last in every ordered chain, with fallback targets checked as
separate passes. Weighted/round-robin mixing is reported as a note
(no reserve encoding visible), never a finding. Wire the fixtures and
the canonical-config check into opencode-config-guard.

After this PR, 'node bin/check-pool-ordering.mjs
.opencode/opencode.jsonc' reports each tier's pool order with the
reserve verdict (pass on the canonical config).
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 20:16
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d17f3dc7-89fa-4ea3-874f-63a407f11c70
Commits

Reviewing files that changed from the base of the PR and between 1dd4c90 and 8ce87d8.

Files selected for processing: 3

  • .github/workflows/opencode-config-guard.yml
  • bin/check-pool-ordering.mjs
  • bin/check-pool-ordering.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T00:12:28.644317Z 8ce87d8 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f9affa2ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/check-pool-ordering.mjs Resolved
Comment thread bin/check-pool-ordering.test.mjs Resolved
Comment thread bin/check-pool-ordering.mjs Resolved
Comment thread bin/check-pool-ordering.mjs Resolved
…g args (#1173)

parseArgs only rejected '--'-prefixed tokens, so '-j' fell through to
the config-path positional and the checker audited whatever file it
named instead of reporting a usage error. Reject any dash-prefixed
token that is not a declared flag, before the config is read (operator
script argument contract #3352). Adds a parseArgs test covering '-j',
'-h', bare '-', '--bogus', duplicate --json and a second positional.
…#1173)

leafPool identified every direct leaf by provider alone, so two
direct leaves from one provider (e.g. _muse Spark then _muse Wonder)
collapsed to one pool and a trailing non-OpenAI seat after an
OpenAI-backed pool disappeared from the check. Identify a direct
door by provider/model instead. Adds an example test for the
Spark -> sol-plan -> Wonder chain (now a violation) and the Wonder
seat to the fixture catalog. Real config still passes: summit now
reports direct:_muse/muse-wonder-1.0-contributor ahead of sol-plan.
)

Passes were grouped only by the tier route's own fallback tail, so
when a fallback target's chain ended in its own declared fallback
(e.g. scout -> background -> workhorse), the fallback's chain and its
fallback's chain collapsed into one ordered sequence and a valid
configuration was reported as a reserve violation. Group leaves by
the sequence of fallback hops on their trace instead, so every
class-fallback edge — at any depth — starts a new pass; passes with
no leaves are no longer reported. Adds an example test for the
scout/background/workhorse shape plus a no-boundary control. Real
config still passes, now reporting the transitive passes (scout
fallback via background -> workhorse -> specialist, and the same
under workhorse fallback via scout).
Example fixtures alone do not cover the reserve-order invariant, so
add a seeded deterministic generator (mulberry32, no new dependency):
32 fixed seeds build route configs — pool permutations, selection
modes, direct leaves including same-provider distinct models and
direct OpenAI leaves, and transitive scout -> background -> workhorse
fallback boundaries — and check them against an independent model
computed from the generated spec (expected passes + reserve verdicts
+ exact violation texts). Negative control: the generated test and
the transitive-boundary example test both fail against the pre-fix
checker (9/11 pass), and all 11 pass with the fix. Generator stats:
17/32 seeds yield violations (22 total), 12/32 hit the transitive
boundary, 27/32 have unordered passes, 134 passes checked in ~50ms.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ce87d87d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

ordered[leaf.pool] = leaf.ordered && (ordered[leaf.pool] ?? true);
backed[leaf.pool] = openaiBacked[leaf.pool] ?? false;
}
const orderedSeq = pools.filter((pool) => ordered[pool]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve outer ordering around unordered subroutes

For an ordered tier with targets [sol-plan, relief], where relief is a weighted route containing non-OpenAI pool routes such as spark-plan and haiku-plan, this filter removes both relief pools and reports reserve: pass. Their internal order is unknown, but their position after Sol is guaranteed: resolveRoute in bin/opencode-route-proxy.mjs:826–838 reorders each route's own targets and recursively expands them before advancing to the next parent target. Thus OpenAI is deterministically consumed before non-OpenAI capacity in this configuration, yet the guard silently approves it. Preserve the ordered relationship between sibling subtrees while treating only the ordering within the weighted subtree as unknown.

Useful? React with 👍 / 👎.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant