Skip to content

feat(routing): build the routable model candidate pool - #8891

Merged
lpcox merged 3 commits into
mainfrom
fix/routing-candidate-pool-8872
Sep 23, 2026
Merged

lpcox merged 3 commits into
mainfrom
fix/routing-candidate-pool-8872

Conversation

@lpcox

@lpcox lpcox commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #8872. Builds on the routing configuration and contracts merged in #8853.

  • Share provider-aware allow/deny matching between request guards, model resolution, and candidate filtering using the existing provider alias overlay. Preserve deny precedence, no-provider matching, and HTTP rejection statuses.
  • Preserve copied Copilot effort/endpoint arrays in private runtime metadata and expose routing identity only for native GitHub-token-backed Copilot, excluding BYOK, custom gateways, and OIDC.
  • Add inert routing-catalogue.js and routing-candidates.js: frozen authoritative snapshots, deterministic choice-0001 identifiers, null-prototype reverse lookup, native wire names, and context limits. Offer effortless pairs only on chat completions and effort-bearing pairs only on responses; distinguish missing versus empty efforts and exclude unknown-only efforts.
  • Add regression coverage and document the foundation and shared policy behavior.

Scope and adaptations

Applied to current main (8a3e2d9b), including the recently merged provider changes. Public APIs, pool shapes, ordering, error codes, and endpoint requirements follow the issue's reference. The reference's NUL pair-key separator is represented as a JavaScript \u0000 escape.

One additional correctness adaptation: the resolver's existing auto special pass-through also checks the shared provider-aware policy. Without that check, auto / copilot/auto could still bypass resolver filtering while the request guard rejected them. Tests cover denylist verification, explicit qualified opt-in, and deny precedence. The legacy no-provider matching path remains unchanged.

Not included: runtime imports of the catalogue/candidate modules, routing activation, router execution-catalogue intersection, new policy syntax, fetching/caching changes, Compose/topology changes, or non-Copilot routing.

Validation

Executed with Node v24.8.0 on macOS; Python-dependent tests use installed Python 3.13.15.

  • Targeted policy, resolver, metadata, catalogue, and candidate suites: passed.
  • npm run type-check: passed.
  • npm run lint: passed with 2,238 existing warnings and zero errors.
  • npm run build: passed.
  • npx markdownlint-cli2 docs/awf-config-spec.md: passed.
  • npx jest --runInBand: 384 suites passed; 6,127 tests passed, 4 existing skips.
  • npm --prefix containers/api-proxy test -- --runInBand: 89 suites / 1,794 tests passed.
  • npm --prefix containers/cli-proxy test -- --runInBand: 1 suite / 78 tests passed.
  • git diff --cached --check: passed.

The first root-suite run selected system Python 3.9 and failed Python imports; selecting Python 3.13 resolved those failures. A single enclave harness deadline failure on the targeted retry did not recur in the subsequent complete run. No tests were weakened or newly skipped.

Remaining validation: this host is macOS with UID 1000 and its Docker daemon is unavailable, so the issue's requested Linux/non-root/non-1000 environment was not available locally. Repository CI must pass before merge/issue closure.

Share provider-aware model policy checks and preserve native Copilot capabilities.
Add frozen catalogue snapshots and deterministic endpoint-compatible candidate pools.
Leave routing modules disconnected from the running proxy.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 22, 2026 21:41
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-8891 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit 4c62807

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 92.44% 92.45% 📈 +0.01%
Statements 90.97% 90.98% 📈 +0.01%
Functions 89.76% 89.76% ➡️ +0.00%
Branches 84.53% 84.54% 📈 +0.01%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

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.

Copilot review overview

🟡 Changes recommended

The policy-bypassing resolver fallback and null-policy crash must be fixed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds an inert Copilot routing catalogue and deterministic candidate pool while centralizing provider-aware model-policy matching.

Changes:

  • Adds frozen routing catalogues and filtered candidate generation.
  • Preserves private Copilot routing metadata and native-token identity.
  • Updates policy enforcement, tests, and documentation.
File Review
docs/​awf-config-spec.md Documents routing and policy behavior.
containers/​api-proxy/​runtime-model-catalog.test.js Tests private routing metadata retention.
containers/​api-proxy/​runtime-model-catalog.js Preserves copied routing metadata.
containers/​api-proxy/​routing-catalogue.test.js Tests frozen catalogue snapshots.
containers/​api-proxy/​routing-catalogue.js Builds authoritative Copilot catalogue records.
containers/​api-proxy/​routing-candidates.test.js Tests candidate filtering, ordering, and protocols.
containers/​api-proxy/​routing-candidates.js Moderate: A null policy causes dereference errors; normalize it to an empty unrestricted policy.
containers/​api-proxy/​providers/​copilot.js Exposes native Copilot routing identity.
containers/​api-proxy/​provider-pricing-overlays.js Exports provider aliases.
containers/​api-proxy/​model-resolver.test.js Tests provider-aware policy resolution.
containers/​api-proxy/​model-resolver.js Critical: The no-alias middle-power fallback can select a disallowed model. Apply the policy predicate to fallback selection or disable fallback when policy is active.
containers/​api-proxy/​guards/​model-policy-guard.test.js Tests provider-aware guard behavior.
containers/​api-proxy/​guards/​model-policy-guard.js Implements shared provider-aware matching.
containers/​api-proxy/​guards/​common-guard-checks.js Passes provider context to policy guards.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

const familyCandidates = providerModels.filter(m => m.toLowerCase().startsWith(familyPrefix));
const permittedCandidates = modelPolicyConfig
? familyCandidates.filter(c => _isModelPermittedByPolicy(c, modelPolicyConfig))
? familyCandidates.filter(c => _isModelPermittedByPolicy(c, modelPolicyConfig, currentProvider))

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

Open

@lpcox
lpcox dismissed manamansor’s stale review September 23, 2026 01:50

Dismissed at the pull request owner’s request.

@lpcox

lpcox commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Copilot AI and others added 2 commits September 23, 2026 01:54
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Fixed in d3458a5 (refined in a follow-up commit): _resolveDirectMatch's no-alias middle-power fallback now filters the provider's model list through _isModelPermittedByPolicy before selection, so it can no longer synthesize a policy-blocked model. Added regression tests for both the blocked and still-permitted fallback cases.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@lpcox Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github github deleted a comment from manamansor Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • api.github.com
  • example.com

[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.github.com"
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

❌ Security Guard failed. Please review the logs for details.

Generated by Security Guard for #8891

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.anthropic.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.anthropic.com"

See Network Configuration for more information.

Generated by Smoke Claude for #8891

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • clients2.google.com
  • github.com
  • github.githubassets.com
  • msfeed25.pkgs.visualstudio.com
  • update.googleapis.com
  • www.google.com
  • www.gstatic.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "clients2.google.com"
    - "github.com"
    - "github.githubassets.com"
    - "msfeed25.pkgs.visualstudio.com"
    - "update.googleapis.com"
    - "www.google.com"
    - "www.gstatic.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • o205451.ingest.us.sentry.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "o205451.ingest.us.sentry.io"

See Network Configuration for more information.

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

❌ Smoke Gemini reports failed. Facets need polishing...

💎 Faceted by Smoke Gemini

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

❌ Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed...

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

❌ Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed...

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "github.com"

See Network Configuration for more information.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • api.nuget.org
  • bun.sh
  • dc.services.visualstudio.com
  • deno.land
  • dl.deno.land
  • github.com
  • releaseassets.githubusercontent.com
  • repo.maven.apache.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.nuget.org"
    - "bun.sh"
    - "dc.services.visualstudio.com"
    - "deno.land"
    - "dl.deno.land"
    - "github.com"
    - "releaseassets.githubusercontent.com"
    - "repo.maven.apache.org"

See Network Configuration for more information.

Generated by Build Test Suite for #8891

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode ✅

  • ✅ GitHub MCP: Connected (2 merged PRs confirmed)
  • ✅ GitHub.com: HTTP 200
  • ✅ File I/O: /tmp/gh-aw/agent/smoke-test-copilot-byok.txt exists
  • ✅ BYOK Inference: Running in direct mode via api-proxy → api.githubcopilot.com

Result: PASS

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (api.github.com): reachable, HTTP 200
✅ Blocked domain (example.com): blocked (SSL/proxy denial)

Overall status: PASS

@lpcox

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • api.github.com
  • example.com

[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.github.com"
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Sep 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Cloud Hypervisor + Copilot

  • PR list (github-list_pull_requests): PASS
  • github.com reachable (200): PASS
  • File write/read in /tmp/gh-aw/agent: PASS
  • example.com blocked (000): PASS

All checks passed.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "github.com"

See Network Configuration for more information.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Result
API status ✅ PASS
gh check ✅ PASS
File status ✅ PASS

Overall result: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.anthropic.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.anthropic.com"

See Network Configuration for more information.

Generated by Smoke Claude for #8891 · claude · haiku45 · 55.8 AIC · ⊞ 4.7K · ◷
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Engine

Overall: PASS

cc @lpcox

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

  • Redis PING: ✅ (PONG)
  • Postgres pg_isready: ✅ (accepting connections)
  • Postgres SELECT 1: ✅ (1)

Overall: PASS

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

📡 OTel Tracing Smoke Test Results

Scenario Result
1. Module Loading ✅ otel.js loaded successfully; isEnabled() → true; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, _parseEndpoints, _parseOtlpHeaders, _buildResourceSpans, and internal exporter classes
2. Test Suite ✅ 68/68 tests passed across 3 suites (otel.test.js, otel-fanout.test.js, otel-workload-identity.test.js) — span creation, GenAI token attributes, OTLP serialization, fan-out/proxy exporters all covered
3. Env Var Forwarding ✅ env-passthrough.ts forwards GITHUB_AW_OTEL_TRACE_ID / GITHUB_AW_OTEL_PARENT_SPAN_ID to the agent; api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, and the trace context to the api-proxy sidecar
4. Token Tracker Integration ✅ onUsage callback present in token-tracker-http.js as the OTEL hook point; confirmed live token-usage records emitted during this run (token-usage.jsonl)
5. OTEL Diagnostics ⚠️ No dedicated api-proxy/otel.jsonl span file found in this run's sandbox logs (only the workflow-level gh-aw.agent.setup span in /tmp/gh-aw/otel.jsonl); token-usage tracking confirmed active. Absence of api-proxy OTLP spans is consistent with graceful degradation when the Sentry OTLP endpoint isn't reachable/configured in this environment — no errors observed

Overall: ✅ Pass — module loading, unit tests, env var wiring, and token-tracker hook all validated. Scenario 5 shows expected graceful degradation rather than a regression.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • o205451.ingest.us.sentry.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "o205451.ingest.us.sentry.io"

See Network Configuration for more information.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.14 Python 3.12.14 ✅ YES
Node.js v24.21.0 v22.23.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: FAILED — Node.js version differs between host and chroot environment (v24.21.0 vs v22.23.2). The smoke-chroot label was not added since not all tests passed.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia ✅ 1/1 passed ✅ PASS
Bun hono ✅ 1/1 passed ✅ PASS
C++ fmt ✅ N/A (build only) ✅ PASS
C++ json ✅ N/A (build only) ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world ✅ N/A (run output correct) ✅ PASS
.NET json-parse ✅ N/A (run output correct) ✅ PASS
Go color ✅ pass ✅ PASS
Go env ✅ pass ✅ PASS
Go uuid ✅ pass ✅ PASS
Java gson ✅ 1/1 passed ✅ PASS
Java caffeine ✅ 1/1 passed ✅ PASS
Node.js clsx ✅ passed ✅ PASS
Node.js execa ✅ passed ✅ PASS
Node.js p-limit ✅ passed ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — PASS

Notes:

  • All 8 repositories cloned successfully; no CLONE_FAILED entries.
  • Java: Maven's default ~/.m2/repository was not writable in this sandbox (unrelated to the firewall/proxy). Worked around locally with -Dmaven.repo.local=<writable dir> while keeping the required squid-proxy:3128 proxy settings in ~/.m2/settings.xml; both gson and caffeine compiled and tested successfully through the proxy.
  • No egress/firewall-related failures observed across any ecosystem.

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • api.nuget.org
  • bun.sh
  • dc.services.visualstudio.com
  • deno.land
  • dl.deno.land
  • github.com
  • releaseassets.githubusercontent.com
  • repo.maven.apache.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.nuget.org"
    - "bun.sh"
    - "dc.services.visualstudio.com"
    - "deno.land"
    - "dl.deno.land"
    - "github.com"
    - "releaseassets.githubusercontent.com"
    - "repo.maven.apache.org"

See Network Configuration for more information.

Generated by Build Test Suite for #8891 · copilot · auto · 44.7 AIC · ⊞ 11.8K · ◷
Add label ready-for-aw to run again

@lpcox
lpcox merged commit 6b24f3f into main Sep 23, 2026
144 of 150 checks passed
@lpcox
lpcox deleted the fix/routing-candidate-pool-8872 branch September 23, 2026 13:45

This branch was successfully deployed

1 active deployment
aoai-model — cf80e9bf Deployed Sep 23, 2026 by lpcox via conclusion #1742
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(routing): build the routable model candidate pool

4 participants