Skip to content

feat(router): add controlled canary rollout and operations - #911

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
zuyu:codex/model-router-stage6-rollout
Sep 29, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
zuyu:codex/model-router-stage6-rollout

Conversation

@zuyu

@zuyu zuyu commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Qualified offline router candidates can now progress through live shadow and an operator-controlled canary. Auto sessions receive stable control/treatment assignment, with a maximum 10% treatment fraction. Admins can inspect outcome coverage, quality, corrections, cost and latency, then roll back or revoke source evidence.

Publication reruns offline qualification and checks current Offering contracts. Durable decisions pin deployment, candidate, cohort and rubric; recovery and primary execution revalidate treatment. Routing-budget failures remain visible and cannot resume. Delayed outcomes and identical retries remain valid after deployment replacement without stopping the replacement.

Related issue

Related to #764 (model routing, Stage 6). Escalation and child treatment remain subsequent work.

Change type

  • Feature
  • Bug fix
  • Documentation
  • Refactor or performance improvement
  • Test
  • Build, CI, or maintenance

User and compatibility impact

  • Adds authenticated /admin/model-router/{owner} publication/status and canary, rollback, revoke and reviewed-outcome endpoints. Activation is opt-in; explicit model selections retain their behavior.
  • Treatment is limited to primary execution. Child admission from treatment is rejected. Rollback stops pinned treatment instead of silently switching its model; already authorized/in-flight requests cannot be recalled.
  • Schema contract changes from v89 to 2026-09-27-v90, adding model_router_deployments. A fresh database is required under the existing bootstrap policy; no in-place migration or backfill is provided.
  • Online metrics are descriptive and preserve unknown labels/prices. This does not establish production quality or savings, activate a real policy, or automatically promote beyond the capped canary.

Architecture and complexity delta

  • Canonical owner changed or extended: services tuning owns revisioned per-owner deployment state and atomic admin audit; turn-core owns qualification/scoring; the existing runtime Offering admission path applies the decision.
  • Existing implementations and callers searched: Auto preparation/recovery and child inheritance, offline qualification/training, run-event persistence, admin authorization/routes, schema bootstrap and router contract tests.
  • Superseded code, states, tables, shims, or self-only tests removed: none; this extends the existing owners. Decisions, routing failures and reviewed outcomes stay in agent_run_events; no parallel trace or outcome store was added.
  • If parallel implementations remain, their boundary and retirement condition: deterministic Auto is the intentional control/rollback policy; learned scoring is gated treatment. Both share admission and persistence and remain necessary for controlled comparison and rollback.

Verification

  • Commands and results:
    • cargo test --locked --offline -p astra-services --lib evaluation::router -q — 12 passed.
    • cargo test --locked --offline -p astra-turn-core --lib model_routing -q — 24 passed.
    • cargo test --locked --offline -p astra-runtime --lib model_routing -q — 11 passed.
    • cargo test --locked --offline -p astra-runtime --test admin_contract -- --include-ignored --test-threads=1 — 13 passed, including the real MatrixOne HTTP regression.
    • cargo test --locked --offline -p astra-services --test router_rollout_db_it -- --include-ignored --test-threads=1 — 3 passed during initial Stage 6 verification (transaction/CAS/audit and dashboard checks).
    • cargo clippy --locked --offline -p astra-runtime -p astra-services -p astra-turn-core --all-targets -- -D warnings — passed after both review fixes.
    • make format-check and git diff --check — passed.
    • Initial make check passed Rust lint/type/format checks but encountered a sandbox npm network restriction; an authorized make check-web retry passed. No web changes were made afterward.
  • Public entrypoint exercised: shared runtime turn preparation/recovery and admin HTTP status, canary, outcome and revocation workflows. Publication qualification is covered at the canonical core layer; no live-provider or production activation was performed.
  • Unhappy paths exercised: unauthorized/non-admin/no-storage access, insufficient shadow evidence, stale revisions, cross-owner publication, revocation, expiry, contract drift, rollback/recovery, over-budget treatment persistence, unknown outcomes/prices, immutable outcome conflicts, database/application clock skew, wrong historical rubric, and delayed reports/retries after replacement.
  • Database verification: used isolated disposable MatrixOne 4.1.2 containers and explicitly isolated databases with ASTRA_TEST_DB_IT=1, ASTRA_AUTO_CREATE_DATABASE=1, empty database prefix, and matching ASTRA_DATABASE/ASTRA_TEST_DATABASE. Verified fresh v90 schema bootstrap, actual dashboard joins/JSON projections, fenced outcome appends, atomic state/audit writes, concurrent CAS and deployment-scoped safety stops. Containers were removed afterward. Existing databases were not migrated or modified.

Final checklist

  • I added or updated tests at the layer that owns the behavior, or explained why no test is needed.
  • I updated public or design documentation for contract changes, or the change needs no documentation update.
  • I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information.
  • The PR title follows the repository's Conventional Commit format.

@zuyu
zuyu requested a review from XuPeng-SH as a code owner September 28, 2026 14:06

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed commit 00942ca, including all changed files, the existing Auto/child-admission paths, canonical run status and event persistence, and the live MatrixOne CI coverage.

Requesting changes for three outcome-path defects detailed inline:

  1. A conflicting critical report can roll back the deployment even though the report itself is rejected.
  2. The new terminal-status allowlist omits the existing terminal delegated state, permanently preventing reviewed outcomes for those runs.
  3. Concurrent identical outcome submissions conflict because the generated reviewer/timestamp envelope is compared by the canonical immutable-event writer.

Please add regressions for noncritical-then-conflicting-critical reports, delegated terminal runs, and overlapping identical submissions. The existing sequential retry/conflict test does not cover these cases.

Code growth and branch integration:

  • The net increase is 2,649 lines: 1,252 implementation, 1,141 tests/support, and 256 documentation. The main responsibilities justify new code: durable deployment/CAS/audit, canonical qualification/scoring, rollout validity checks, and operational reporting. Reusing the existing run ledger and Offering admission is appropriate. Deterministic Auto remains necessary for control and rollback.
  • Remove the unreachable treatment-rejection check at services/src/evaluation/router/mod.rs:295-300, or move it to a position where it owns a useful diagnostic. authorize requires the deterministic manifest policy; validate_identity requires treatment to use the learned policy; the preceding policy-equality check therefore rejects every valid treatment first. The new test explicitly confirms those earlier errors. Keep the invariant test, but do not maintain an additional rejection branch that cannot fire.
  • RolloutRun.run_id and RolloutRun.reason have no production reader. Remove the unused projection fields and associated SELECT/JSON decoding; the SQL can still order by e.run_id without projecting it.
  • The live path hashes/deserializes the same candidate in score_live and again for pinned_pair. Reuse the validated candidate/contracts within the decision preparation rather than doing the same validation twice.
  • One deliberate restriction still needs a clear product rationale: out-of-scope/non-primary tasks can receive a treatment cohort, abstain to strong, and subsequently have child/skill execution rejected. The PR documents child rejection, so this is an explicit tradeoff rather than an undisclosed implementation bug; nevertheless, primary-only learned routing does not by itself justify removing baseline capabilities from structurally excluded tasks. Please justify that coupling or keep excluded tasks on baseline execution authority, and cover the interaction with parallel subruns/forked skills.

Validation: git diff --check passed. CI is green on the reviewed head; I checked logs confirming the new live scoring/recovery/budget tests, the MatrixOne deployment transaction test, and the MatrixOne admin HTTP workflow actually ran and passed. No local Rust tests were run because this environment has no Rust/Cargo toolchain.

@zuyu
zuyu requested a review from XuPeng-SH September 29, 2026 01:26

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed head fdb643a against base 5f59bad, including the complete follow-up diff from 00942ca and its interaction with canonical event persistence, deployment transitions, and existing Auto execution.

The three previous P2 findings are addressed:

  • Immutable outcome acceptance now precedes the safety-stop side effect. A conflicting report exits before changing deployment state or audit.
  • Outcome admission uses the canonical terminal-status predicate, including delegated runs.
  • A failed concurrent append is reconciled against the durable semantic outcome, preserving the original reviewer/time envelope for identical submissions.

I also traced both orders of concurrent critical reports, a manual rollback winning the race, replacement during an older report, and retry after outcome acceptance. The deployment-row check preserves the winning stop reason/revision/audit, and an older report cannot stop a replacement. Acceptance and stopping remain separate transactions: an interrupted request depends on an identical retry to finish the stop before successful acknowledgment, as now documented and covered by the retry regression.

No additional blocking correctness findings in this pass. Approving the code review.

Complexity assessment: the follow-up adds 478 net lines, consisting of 29 implementation, 442 tests/support, and 7 documentation. The five new HTTP/MatrixOne regressions exercise public behavior and relevant unhappy paths; this increase has a concrete purpose. The whole PR now adds 3,127 net lines (1,281 implementation, 1,583 tests/support, 263 documentation). The new production branches reconcile existing authority rather than introducing another outcome store or weakening immutable-event validation.

The earlier nonblocking cleanup suggestions remain: remove the unreachable dataset treatment check and unused RolloutRun projections, and avoid parsing/validating the candidate twice per decision. The documented coupling between treatment assignment and child restrictions for out-of-scope abstentions also remains a product limitation; this follow-up does not change it.

Validation: git diff --check passed. I read the new HTTP regressions and the updated transaction/audit assertions. Local Rust execution is unavailable in this environment. Test Suite and Static Checks for this exact head are still running, so their results remain required before merge; the previous head's green CI is not evidence that these new regressions passed.

@mergify mergify Bot added the queued label Sep 29, 2026
@mergify

mergify Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-29 01:45 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-09-29 01:45 UTC · at 62dc136082a0a77df99172ad15b7bfe48e6a389d · squash

This pull request spent 14 seconds in the queue, including 3 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Check PR title
    • check-neutral = Check PR title
    • check-skipped = Check PR title
  • any of [🛡 GitHub branch protection]:
    • check-success = check
    • check-neutral = check
    • check-skipped = check
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: core crates + bridge hooks
    • check-neutral = Test: core crates + bridge hooks
    • check-skipped = Test: core crates + bridge hooks
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-runtime
    • check-neutral = Test: astra-runtime
    • check-skipped = Test: astra-runtime
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-fs-tools)
    • check-neutral = Test: astra-cli (edge-fs-tools)
    • check-skipped = Test: astra-cli (edge-fs-tools)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-git-gix)
    • check-neutral = Test: astra-cli (edge-git-gix)
    • check-skipped = Test: astra-cli (edge-git-gix)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-rest)
    • check-neutral = Test: astra-cli (edge-rest)
    • check-skipped = Test: astra-cli (edge-rest)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-shell)
    • check-neutral = Test: astra-cli (edge-shell)
    • check-skipped = Test: astra-cli (edge-shell)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (non-edge)
    • check-neutral = Test: astra-cli (non-edge)
    • check-skipped = Test: astra-cli (non-edge)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: online (core)
    • check-neutral = Test: online (core)
    • check-skipped = Test: online (core)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: online (integration)
    • check-neutral = Test: online (integration)
    • check-skipped = Test: online (integration)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: turn-core + services + plan
    • check-neutral = Test: turn-core + services + plan
    • check-skipped = Test: turn-core + services + plan
  • any of [🛡 GitHub branch protection]:
    • check-skipped = web (typecheck, test, build)
    • check-neutral = web (typecheck, test, build)
    • check-success = web (typecheck, test, build)
  • any of [🛡 GitHub branch protection]:
    • check-skipped = Astra SDK (typecheck, test+coverage, build)
    • check-neutral = Astra SDK (typecheck, test+coverage, build)
    • check-success = Astra SDK (typecheck, test+coverage, build)

@mergify
mergify Bot merged commit 62dc136 into matrixorigin:main Sep 29, 2026
35 of 36 checks passed
@zuyu
zuyu deleted the codex/model-router-stage6-rollout branch September 29, 2026 01:45
@mergify mergify Bot removed the queued label Sep 29, 2026
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.

2 participants