Repository navigation
Isolate profile selection behind a minimal selector seam (#36) - #43
Conversation
route() now asks a ProfileSelector for a profile name among the role's ROLE_CANDIDATES and refuses anything outside them. The existing rules move unchanged into rule_selector, the default, so identical inputs give identical profiles, targets, fallbacks and blocks. Workspace policy, the availability gate, fallback, calibration blocking and target resolution stay in route(); a selector returns a name only and cannot skip a gate. The cost estimate prices what the selector would choose.
Review summaryReviewed the full diff from Findings[REV-001] · low · open · blocks:no — Cost estimate ignores a distinct resolve profileFile: When a custom selector chooses different profiles for Security triageSensitive surface: this change alters role-to-profile routing, including review roles. The Verification
Not verified: no non-default selector is wired through the production cycle today, so production integration with a custom selector was not exercised. CIAll reported checks passed across the two Validate package runs: Residual riskFuture callers supplying a custom selector must preserve the security-sensitive reviewer escalation. The resolve-cost issue is limited to the informational estimate. VerdictAPPROVED — no open finding blocks approval. |
Work item: #36 — #36
What changed
scripts/router.py: newROLE_CANDIDATES,ProfileSelector(a plain callableselector(role, candidates, signals) -> (profile, reasons)),candidates_for(),select_profile()andrule_selector. The rules formerly insideprofile_for()moved unchanged intorule_selector, which is the default.profile_for()stays as a compatibility wrapper.route()takes an optionalselector=and calls it throughselect_profile(), which refuses a name outside the role's candidates, a non-string (e.g. aTarget), or malformed reasons. An unknown role is refused before any selector runs.route()in the same order;dispatch, permissions and contract validation are untouched. The seam returns a profile name only, never a target or model.unavailablewithout blocking the route (same as the existing cost behaviour).Verification
origin/main'srouter.pyover 288,000 input combinations (every role plus an unknown one × difficulty × verifiability × security flag × every availability pair for codex/claude × mode × four eligibility sets × strategy × rates × default/overridden profiles): identical profile, target, blocked, fallback, reasons, cost, rate andexplain()text, including identical errors.python3 -m unittest tests.test_router— 58 tests OK (15 new inProfileSelectorTests).python3 scripts/validate-package.py— VALID.python3 -m unittest discover -s tests— 535 tests OK.Closes #36