Skip to content

Add cross-module model-routing contract coverage - #67254

Merged
pelikhan merged 6 commits into
mainfrom
copilot/tests-cross-module-routing-coverage
Oct 9, 2026
Merged

pelikhan merged 6 commits into
mainfrom
copilot/tests-cross-module-routing-coverage

Conversation

Copilot AI commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Routing decisions could diverge between harnesses, proxy attribution, session events, and OTEL even when each module passed its own tests. This adds in-process contracts across those stages and measures harness routing coverage directly.

  • Routing contracts: Add fixture-driven cases for all four engines, including endpoint overrides, unsupported endpoints, and proxy/harness model mismatches. Exercise all 28 engine × effort combinations, including Pi’s none → off mapping and fail-closed cases.
  • Harness paths: Extract routing resolution and outcome recording into exported helpers used by production harnesses and tests. Reconcile unified-session outcomes with finalized attribution.
  • OTEL: Assert non-routed runs emit no routing-only attributes.
  • Harness line coverage: Claude 37% → 38.08% · Copilot 46% → 47.02% · Codex 55% → 54.69%.

Example endpoint-override contract:

expect(outcome).toMatchObject({
  status: "selected",
  wireModel: "claude-opus-4-6",
  effectiveEndpoint: "/v1/messages",
  selectedEndpoint: "/chat/completions",
});

Co-authored-by: SivaKesava1 <11771739+SivaKesava1@users.noreply.github.com>
Copilot AI changed the title [WIP] Add cross-module model-routing contract tests and coverage updates Add cross-module model-routing contract coverage Oct 9, 2026
Copilot AI requested a review from SivaKesava1 October 9, 2026 19:08
Comment thread actions/setup/js/unified_session.cjs Outdated
@SivaKesava1

Copy link
Copy Markdown
Collaborator

Verified 637250e1:

  • Tests (Linux): model_routing_contract.test.cjs plus the Claude, Codex, Copilot, pi, awf_model_routing, unified_session and send_otlp_span suites all pass (8 files).
  • Harness routing is now measurable in-process. Function-level coverage of the extracted helpers: resolveClaudeModelRouting 11/11 statements, removeClaudeRoutingOverrides 10/10, resolveCodexModelRouting 14/14, removeCodexRoutingOverrides 16/16, applyCodexRoutingEffort 3/3, resolveCopilotModelRouting 7/7, applyCopilotRoutingSelection 9/9, applyCopilotRoutingArgs 14/14. File-level totals stay at 38–55% only because of non-routing code. One gap: resolvePiModelRouting in pi_models_json.cjs is never called in-process (0 calls, 4/9 statements); the pi contract goes through resolvePiRoutingEndpoint and resolveAndRecordPiModelRoutingEndpoint. Please cover resolvePiModelRouting directly too.
  • No behaviour change in real runs. Routed workflows compiled at this head (default AWF v0.28.50) produce the same attribution as main:
    • Claude t01 37985758616: selected, claude-sonnet-5 medium, endpoint /v1/messages, selected endpoint /chat/completions, footer routed: sonnet50 medium;
    • pi t10 37985771077: claude-opus-5 max on /v1/messages, footer routed: opus50 max;
    • Copilot t01 37985783253: gpt-5.6-luna high on /responses, footer routed: gpt56 high.

@copilot /pr-finisher (and add the resolvePiModelRouting coverage)

Co-authored-by: SivaKesava1 <11771739+SivaKesava1@users.noreply.github.com>

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Verified 637250e1:

  • Tests (Linux): model_routing_contract.test.cjs plus the Claude, Codex, Copilot, pi, awf_model_routing, unified_session and send_otlp_span suites all pass (8 files)....

Added a direct in-process resolvePiModelRouting contract test in commit ac5fd79.

@SivaKesava1
SivaKesava1 marked this pull request as ready for review October 9, 2026 21:04
Copilot AI balanced review requested due to automatic review settings October 9, 2026 21:04
@SivaKesava1

Copy link
Copy Markdown
Collaborator

@copilot Please revert the change to unified_session.cjs (the merge loop around line 549) and the matching appliedEffort edits in unified_session.test.cjs. This is a test-coverage PR, and that change alters production precedence. As the code-scanning thread points out, it also rewrites the model_routing.outcome event with aw_info.json-derived values, which destroys the independent harness evidence.

The underlying problem is real, but it's on main and broader than this loop: since #67114, the agent-writable agent/awf-routing-outcome.json overrides the runner-written routing both in collectUnifiedSession and in pkg/cli/model_routing_session.go (status, wire model, endpoints, efforts, failure code). We'll file that as a separate issue, so keep this PR to tests: the contract tests should assert main's current behaviour, or be marked as a known gap that references the new issue.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The contract assertions leave mapped session effort and footer contents insufficiently verified, while failure classification remains duplicated.

3 open findings
What changed in this PR

Adds cross-module contracts to keep model-routing behavior consistent across harnesses, attribution, sessions, and telemetry.

Changes:

  • Extracts reusable routing-resolution helpers for all four engines.
  • Adds endpoint, mismatch, and 28-case effort-matrix contract coverage.
  • Reconciles finalized routing attribution and verifies non-routed OTEL output.
File Description
actions/​setup/​js/​awf_model_routing.cjs Adds routing failure classification.
actions/​setup/​js/​claude_harness.cjs Extracts Claude routing resolution.
actions/​setup/​js/​codex_harness.cjs Improves Codex failure outcomes.
actions/​setup/​js/​copilot_harness.cjs Extracts Copilot routing resolution.
actions/​setup/​js/​pi_models_json.cjs Extracts Pi endpoint outcome recording.
actions/​setup/​js/​unified_session.cjs Reconciles outcomes with finalized attribution.
actions/​setup/​js/​unified_session.test.cjs Tests finalized effort reconciliation.
actions/​setup/​js/​send_otlp_span.test.cjs Tests non-routed telemetry attributes.
actions/​setup/​js/​model_routing_contract.test.cjs Adds cross-module routing contracts.
actions/​setup/​js/​fixtures/​model_routing_contract.cjs Provides routing contract fixtures.

🧠 Review effort: Balanced

Comment thread actions/setup/js/awf_model_routing.cjs
Comment thread actions/setup/js/model_routing_contract.test.cjs Outdated
Comment thread actions/setup/js/model_routing_contract.test.cjs Outdated
Co-authored-by: SivaKesava1 <11771739+SivaKesava1@users.noreply.github.com>

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please revert the change to unified_session.cjs (the merge loop around line 549) and the matching appliedEffort edits in unified_session.test.cjs. This is a test-coverage PR, and that c...

Reverted the unified-session merge and matching appliedEffort expectations to their pre-637250e state in commit 392b544. The contract now asserts the current harness/attribution disagreement; no production precedence change remains.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/unified_session.cjs:550): This inversion makes the workflow.info modelRouting values (derived from aw_info.json) overwrite the fields of the model_routing.outcome event, which is provenance-tagged as coming from agent/awf-routing-outcome.json. The session artifact then reports harness-advisory values that the harness never wrote (the updated test shows applied_effort: "medium" in the advisory file being reported as "low"), destroying the independent evidence needed to detect harness/post-run disagreement — the exact mismatch clas... - Add cross-module model-routing contract coverage #67254 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 392b544
Sous-chef work: 2cdb222ba3458a8bd5969ac5f8061f3a1177c57ee32209d53214717f595c8d36
Sous-chef state: bd3e81341770d3716f4ffeb9764d6503498dfdc5c04206a585d271a8d5bba9c9

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · 4.85 AIC · ⌖ 9.47 AIC · ⊞ 1K · ◷
Comment /souschef to run again

…odule-routing-coverage

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes....

Merged latest main with make merge-main in 5ff9078. The provenance concern is covered by the revert and current-behavior contract assertions in 392b544; focused tests and the final local gate passed. I did not trigger CI.

Copilot AI requested a review from gh-aw-bot October 9, 2026 22:06
@SivaKesava1

Copy link
Copy Markdown
Collaborator

Ready for review. Verified 5ff90789 on Linux (contract + harness suites, 880 tests). Routing logic moved out of each harness main() into exported helpers, now covered in-process (100% of the routing helpers; pi's resolvePiModelRouting included). Sandbox Claude t01, pi t10 and Copilot t01 runs built from this branch produce the same attribution and footers as main. The unified_session.cjs precedence change was reverted; the underlying trust issue is tracked in #67279. Possible follow-up: the shared failure-code classifier duplicates getModelRoutingSelectionFailureCode in parse_token_usage.cjs (left as is to keep this PR test-scoped). Review threads resolved.

@SivaKesava1
SivaKesava1 requested a review from pelikhan October 9, 2026 22:40
@pelikhan
pelikhan merged commit 3ea471b into main Oct 9, 2026
13 checks passed
@pelikhan
pelikhan deleted the copilot/tests-cross-module-routing-coverage branch October 9, 2026 22:49
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.

Tests: cross-module model-routing contract tests and measurable harness routing coverage

6 participants