Skip to content

Isolate profile selection behind a minimal selector seam (#36) - #43

Merged
datacas merged 1 commit into
mainfrom
issue-36-profile-selector
Sep 23, 2026
Merged

datacas merged 1 commit into
mainfrom
issue-36-profile-selector

Conversation

@datacas

@datacas datacas commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Work item: #36 — #36

What changed

  • scripts/router.py: new ROLE_CANDIDATES, ProfileSelector (a plain callable selector(role, candidates, signals) -> (profile, reasons)), candidates_for(), select_profile() and rule_selector. The rules formerly inside profile_for() moved unchanged into rule_selector, which is the default. profile_for() stays as a compatibility wrapper.
  • route() takes an optional selector= and calls it through select_profile(), which refuses a name outside the role's candidates, a non-string (e.g. a Target), or malformed reasons. An unknown role is refused before any selector runs.
  • Workspace policy, the availability gate, fallback, calibration blocking and target resolution stay in route() in the same order; dispatch, permissions and contract validation are untouched. The seam returns a profile name only, never a target or model.
  • The informational cost estimate prices the implement/review profiles the same selector would pick; a selector failing only there makes the cost unavailable without blocking the route (same as the existing cost behaviour).
  • No new dependency, no configuration change, nothing in the cycle passes a non-default selector yet.

Verification

  • Equivalence check against origin/main's router.py over 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 and explain() text, including identical errors.
  • python3 -m unittest tests.test_router — 58 tests OK (15 new in ProfileSelectorTests).
  • python3 scripts/validate-package.py — VALID.
  • python3 -m unittest discover -s tests — 535 tests OK.

Closes #36

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.
@datacas

datacas commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

Review summary

Reviewed the full diff from main to 47b22dd0d8b70fe88af4adc8bc4475a538ddd3eb for PR #43, including scripts/router.py, selector tests, and routing documentation. The default selector preserves the existing route decisions and keeps availability and workspace checks in route().

Findings

[REV-001] · low · open · blocks:no — Cost estimate ignores a distinct resolve profile

File: scripts/router.py, line 492

When a custom selector chooses different profiles for implement and resolve, route() asks it only for the implement and review profiles before calling estimate_cost(). Since it omits resolve_profile, the estimate assumes resolution uses the implement profile. A runtime reproduction with cheap_coder for implementation and deep_coder for resolution reported 4.0 expected resolution cost instead of the selector-aware 5.5. This affects the informational estimate only; it does not change dispatch. Ask the selector for resolve and pass that profile to estimate_cost().

Security triage

Sensitive surface: this change alters role-to-profile routing, including review roles. The cc-security-review pass found no confirmed vulnerabilities. A custom selector can choose reviewer for a security-sensitive review even though the default selector escalates to senior_reviewer; the current production cycle does not pass a custom selector. Treat preserving that escalation as a constraint for future selector integrations.

Verification

  • python3 -m unittest tests.test_router — 58 tests passed.
  • python3 -m unittest discover -s tests -q — 535 tests passed.
  • python3 scripts/validate-package.py — VALID.
  • Runtime reproductions confirmed the resolve-cost discrepancy and that a custom selector can return reviewer for a security-sensitive review.

Not verified: no non-default selector is wired through the production cycle today, so production integration with a custom selector was not exercised.

CI

All reported checks passed across the two Validate package runs: Skills, manifests, and Bash installer (2 passes) and PowerShell installer (2 passes). These workflows include the Linux and Windows test/installation gates.

Residual risk

Future callers supplying a custom selector must preserve the security-sensitive reviewer escalation. The resolve-cost issue is limited to the informational estimate.

Verdict

APPROVED — no open finding blocks approval. REV-001 is an open, non-blocking finding.

@datacas
datacas merged commit 66b903c into main Sep 23, 2026
4 checks passed
@datacas
datacas deleted the issue-36-profile-selector branch September 24, 2026 09:21
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.

Aislar una interfaz mínima de selección de perfil

1 participant