Repository navigation
feat(router)!: add a versioned JSON Schema for routing tables at version 1 - #10129
Conversation
…ion 1 Routing tables are the router's second input contract, but their format was defined only by routing_table.py and contracts.py. Add a hand-written draft 2020-12 schema at containers/router/schemas/routing-table.v1.schema.json, frozen once published, so the table format is an explicit, versioned contract. Start the published numbering at 1: the loader, bundled tables, synthetic fixtures and openapi.yaml move from schema_version 5 to 1. The loader now also rejects a boolean schema_version, which Literal[1] would otherwise accept because True == 1. tests/test_table_schema.py checks that: - the schema is valid and every bundled, synthetic and contract-corpus table conforms; - its version, profiles, label-key and model-identity patterns and closed objects match the runtime models and enums; - the schema and RoutingTable.from_bytes reject the same single-field defects, and the cross-reference rules that only the loader enforces stay documented in the schema; - published schema files keep their pinned SHA-256. Include schemas/ in the source distribution and document the schema and its versioning policy in the router README. BREAKING CHANGE: the router accepts only routing tables with schema_version 1. Tables with schema_version 5 are rejected and must be regenerated with the new version. Closes #10124 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
There was a problem hiding this comment.
🟡 Changes recommended
Exported archive metadata and cross-engine whitespace validation still disagree with the table contract.
2 open findings
What changed in this PR
Introduces a versioned JSON Schema for the router’s offline table format, complementing its HTTP API contract.
Changes:
- Adds schema validation, runtime-parity tests, and immutability checks.
- Resets table markers to version 1 and rejects boolean versions.
- Includes schemas in source distributions and documents versioning.
| File | Description |
|---|---|
containers/router/tests/test_table_schema.py |
Adds schema and loader-parity tests. |
containers/router/tests/test_routing.py |
Checks rejection of unsupported versions. |
containers/router/tests/test_package.py |
Checks schema inclusion in source distributions. |
containers/router/tests/contract_corpus.py |
Updates generated tables to version 1. |
containers/router/src/gh_aw_router/routing_table.py |
Enforces version 1 and rejects booleans. |
containers/router/schemas/routing-table.v1.schema.json |
Defines the version 1 contract. |
containers/router/routing/cost-speed-robust.json |
Updates format marker to 1. |
containers/router/routing/cost-speed-economy.json |
Updates format marker to 1. |
containers/router/routing/cost-speed-balanced.json |
Updates format marker to 1. |
containers/router/routing/cost-robust.json |
Updates format marker to 1. |
containers/router/routing/cost-economy.json |
Updates format marker to 1. |
containers/router/routing/cost-balanced.json |
Updates format marker to 1. |
containers/router/README.md |
Documents schema and versioning policy. |
containers/router/pyproject.toml |
Includes schemas in source distributions. |
containers/router/openapi.yaml |
Updates the table-version description only. |
🧠 Review effort: Max
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Replace \s and lookarounds in the routing-table schema with an explicit list of the whitespace characters the loader strips, plus a trimmed definition that rejects outer whitespace. ECMA-262, Python re and RE2 validators now agree with the loader. Derive the contract archive's routing_table_schema from the loader instead of hard-coding it, and check that every embedded table matches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Copilot review passed with no inline comments. @rabeckett Add the |
|
✅ Smoke Claude passed
|
|
✅ Build Test Suite completed successfully!
|
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅
|
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.
|
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤
|
|
💎 Smoke Gemini is crystallizing results on this pull request... |
|
Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.
|
|
🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅
|
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓
|
|
✅ Security Guard completed successfully! Security GuardOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟
|
|
🔌 Smoke Services — All services reachable! ✅
|
|
🔑 Smoke Copilot BYOK AOAI (api-key) is testing Azure OpenAI BYOK (api-key) mode on this pull request... |
|
🪪 Smoke Copilot BYOK AOAI (Entra) is testing Azure OpenAI BYOK (Entra / GitHub OIDC) mode on this pull request... |
|
Cloud Hypervisor + Copilot smoke test
|
Smoke Test: Claude Engine Validation
Overall result: ✅ PASS
|
|
EGRESS_RESULT allow=pass deny=pass
|
|
Smoke Copilot: PASS ✅
|
|
Smoke services: ✅ Redis PONG · ✅ pg_isready · ✅ SELECT 1 → PASS
|
Copilot BYOK Smoke Test ✅ PASS
Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY via api-proxy sidecar → api.githubcopilot.com) All smoke tests passed.
|
|
OTEL smoke test
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — PASS Notes: Bun/Deno were installed via npm (the curl installers were not permitted in this sandbox). .NET and Maven needed writable temp/cache dirs under
|
|
Smoke test results:
|
Chroot version comparison
Node.js differs, so not all tests passed and the
|

Closes #10124
Summary
The router's routing tables are an input contract, like its HTTP API, but their format was
defined only by
TableDocumentandRoutingTable.from_bytesinrouting_table.pyand the enumsin
contracts.py. This PR adds a hand-written, versioned JSON Schema for the table files, andtests that keep the schema, the loader and the bundled tables in step. It mirrors what
openapi.yamlandtests/test_openapi.pyalready do for the HTTP API.All changes are in
containers/router/.Changes
Schema. New file
schemas/routing-table.v1.schema.json, a JSON Schema (draft 2020-12).It encodes everything a schema can express:
schema_versionrequired and fixed to 1;auto;repository;provider/model[:effort]patterns built from the enums;Patterns use only syntax that ECMA-262, Python
reand RE2 share: no\sor other escapes,and no lookaround. Whitespace is the explicit set of characters the loader strips, and a
trimmeddefinition rejects leading and trailing whitespace.Its
descriptionlists the cross-reference rules only the loader enforces. The file is keptout of
routing/(the loader reads every*.jsonthere), out of the image and out of the wheel.Format marker reset to 1. The schema is the first published version of the format, so the
marker moves from 5 to 1 in:
schema_versionline changes);openapi.yaml.The loader now also rejects a boolean
schema_version, becauseLiteral[1]accepts JSONtrue(True == 1). The new agreement test caught this.Tests. New file
tests/test_table_schema.py:object fields;
trailing whitespace for every character the loader strips;
rejects, and rejects a missing
schema_versionthat the loader defaults;test_routing.pynow checks that versions 0 and 2–5 are rejected.Packaging.
schemas/**is added to the source distribution and to the release-test fixture.Docs. The router README describes the schema and the versioning policy: a published schema
never changes, and a format change adds
routing-table.v<N+1>.schema.jsonand bumpsschema_version.Compatibility
This is a breaking change to the table format marker only. The router now rejects tables with
schema_version5, so such tables must be regenerated with 1. Table content, routing behaviourand the HTTP API don't change. There's no router version bump; the next router release picks
this up.
Validation
ruff check,ruff format --checkandty checkare clean.tests from the extracted tree.
TaskComplexityvalue fails the pattern parity and conformance tests;TableDocumentfails the field parity test;for every whitespace character in leading, trailing and pre-effort positions. The schema
matches the loader in every case.