Skip to content

feat(observability): attribute inference traces to admitted routes - #819

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
zuyu:codex/model-routing-trace
Sep 19, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
zuyu:codex/model-routing-trace

Conversation

@zuyu

@zuyu zuyu commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Add admitted-route attribution to inference request traces as a foundation for model-router evaluation. Accepted and terminal records now identify the route, logical invocation, upstream model, execution placement, and access source.

Correct usage diagnostics so unavailable usage remains unknown and partial usage does not produce full-request budget errors or cache-read ratios. This helps maintainers distinguish retries, execution outcomes, and incomplete telemetry when analyzing model performance.

Related issue

Related to #764. This PR adds tracing foundations; it does not implement automatic model selection.

Change type

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

User and compatibility impact

Existing request diagnostics and session observability expose an optional route projection. Model-selection behavior and configuration remain unchanged.

Older stored records deserialize with unknown route attribution. Because diagnostic readers reject unknown fields, deployment requires upgraded readers and recovery workers before new producers, or a coordinated upgrade that drains older instances.

Unavailable usage now produces absent usage values and nullable diagnostic token columns. Aggregate request counters still include these attempts; token totals represent observed usage rather than complete billing.

Architecture and complexity delta

  • Canonical owner changed or extended: The existing inference ledger and ModelRequestContextEvent projection. No new tables or execution authority.

  • Existing implementations and callers searched: Offering admission, inference planning and settlement, recovery, request-context queries, session observability, reflection, and integration tests.

  • Superseded code, states, tables, shims, or self-only tests removed: Replaced duplicated foreground/recovery usage calculations with one shared projection helper.

  • If parallel implementations remain, their boundary and retirement condition: Foreground settlement and recovery retain their existing persistence responsibilities and share usage-projection semantics. No parallel routing implementation was introduced.

Verification

  • Commands and results: cargo test --locked --offline -p astra-services --lib -q, 1,950 passed, 69 ignored. Rerun outside the sandbox after local mock-server socket restrictions caused failures.

  • Public entrypoint exercised: Public entrypoint exercised: No live HTTP/UI entrypoint exercised. Tests cover inference planning and request-event generation; existing request queries and session observability consume the extended projection.

  • Unhappy paths exercised: Physical retries, distinct logical invocations and owners, failed/cancelled outcomes, unavailable and partial usage, measured zero usage, stale diagnostic measurements, legacy records without route attribution, recovery projection, and exclusion of admission/owner tokens.

  • Database verification: No schema migration. Updated MatrixOne integration assertions cover route linkage, nullable unavailable-usage columns, and aggregate request accounting. These tests were statically checked but not executed against MatrixOne because no disposable test database was configured. Query and transaction behavior still requires live database verification.

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 18, 2026 18:35
@mergify mergify Bot added the queued label Sep 19, 2026
@mergify

mergify Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-19 09:07 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-09-19 09:25 UTC · at fccb14f45f2e4198a560b7ee5986cc3c16cfe4e9 · squash

This pull request spent 18 minutes 6 seconds in the queue, including 17 minutes 50 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-skipped = Test: core crates + bridge hooks
    • check-neutral = Test: core crates + bridge hooks
    • check-success = 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 fccb14f into matrixorigin:main Sep 19, 2026
26 of 27 checks passed
@mergify mergify Bot removed the queued label Sep 19, 2026
@zuyu
zuyu deleted the codex/model-routing-trace branch September 25, 2026 18:14
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