Repository navigation
feat(observability): persist next-turn assessments - #888
Merged
mergify[bot] merged 1 commit intoSep 27, 2026
Merged
Conversation
zuyu
force-pushed
the
codex/model-router-stage2-assessments
branch
from
September 27, 2026 03:33
89cf7cc to
e95d649
Compare
XuPeng-SH
approved these changes
Sep 27, 2026
XuPeng-SH
left a comment
Collaborator
There was a problem hiding this comment.
Deep review of e95d64938f6fd93e1f01c9545698f5bd806947d2 against base 239f7c2b4ff2ca06f4c656b063052bf34604dc55.
结论:Approve。本轮复核 21 个变更文件及相关消费者,未确认新的 P1/P2。
重点复核:
- 生产 Work classification/planning 路径中的可选 assessment 与执行准入答案分别校验;错误的可选观察不会把有效 Work 决策变成失败,非法或不完整的 authority answers 仍被拒绝。
- TypeSafe 先验证 typed answers,再传递可选观察;classification、planner 和 Work decision 的投影保留 assessment,未增加独立观察调用或新的路由决策。
- 用户消息和前序交换在判断前冻结;延迟结果不会选择后来追加的 assistant/user 消息。来源位置/内容不再匹配时放弃记录,不按文本重新定位。
- 只有明确指向 previous_response 且可建立 canonical snapshot reference 时才关联响应;缺失目标会降为 unknown。reference 排除可变 semantics 注解,保留分支内容差异。
- assessment 补齐保留已有 objective/feedback,既不重放反馈也不重复 reanchor;后续解析 objective 时保留已有 assessment/reference。canonical commit、持久化和恢复继续使用同一 semantics marker。
本地验证:
git diff --check HEAD^、cargo fmt --all -- --check:通过。cargo nextest run --locked --offline,包范围 astra-turn-types / astra-services / astra-runtime / astra-turn-core:57 项筛选测试全部通过,覆盖 assessment、response reference、source freeze、turn semantics、Work admission classification/clarification,以及 Server 内置准入入口延迟完成后 canonical commit 的回归。- 另运行
typesafe_request_judgment_uses_durable_nonstream_and_reports_usage:通过,使用本地 HTTP fixture 验证实际 SummaryClient → TypeSafe adapter → admission parser 的字段保留、执行 provenance 和 usage。 - 合计 58/58 通过;提交前确认 head 未变化,当前相关 GitHub CI 检查通过。
范围:本轮没有运行完整 workspace、真实模型或 live MatrixOne;未验证模型给出的 satisfaction/difficulty/urgency 标签质量。此次确认的是结构、归属、准入隔离和持久化行为。未修改生产代码或用户工作区。
Contributor
Merge Queue Status
This pull request spent 39 seconds in the queue, including 1 second running CI. Required conditions to merge
|
8 of 10 tasks
5 tasks done
mergify Bot
pushed a commit
that referenced
this pull request
Sep 28, 2026
## Summary Synchronize the workspace version from `0.2.9` to `0.2.10`. This pull request only updates release metadata. It does not change runtime behavior, create a tag, publish container images, or create a GitHub Release. `main` already contains the fixes and features that this version names: - Run-lifecycle 409 conflicts carry stable, structured error codes, and the pre-admission rejection contract is complete for session-slot conflicts (#886). - Bounded session recovery is hardened (#883). - Explain artifact recovery and introspection scope is clarified (#885). - Client-owned skills are routed with the server catalog (#881). - Execution evidence and progress feedback are grounded for judgment (#880). - MCP bindings are preserved across chat turns (#887). - The composer no longer goes stale after a coalesced resize (#889). - Next-turn assessments are persisted for observability (#888). - Live run observation load is reduced (#891). - Partial usage summary output is simplified (#890). - Web dependency patch/minor updates (#895). Pinned MatrixOne and Memoria image digests are unchanged. MOI publishes the client from the selected Astra commit. After this change is on `matrixorigin/Astra`, a MOI source build can set `astra_version` to `0.2.10` and check it against this commit's `Cargo.toml`. Publishing the GitHub Release is a separate step: after merge, run `make release-publish VERSION=0.2.10` from a clean `main` checkout. This pull request does not do that. ## Related issue No related issue. ## Change type - [x] Build, CI, or maintenance ## User and compatibility impact Installed clients do not change until a bundle or GitHub Release is built from this commit. There is no configuration migration. The source version becomes `0.2.10`. ## Architecture and complexity delta N/A - Canonical owner changed or extended: none - Existing implementations and callers searched: the version surfaces covered by `make release-prepare` - Superseded code, states, tables, shims, or self-only tests removed: none - If parallel implementations remain, their boundary and retirement condition: none ## Verification - Commands and results: `make release-prepare VERSION=0.2.10` succeeded. `LC_ALL=C make release-check VERSION=0.2.10` passed. - Public entrypoint exercised: not published. - Unhappy paths exercised: `validate-release-version.sh` confirmed the `0.2.10` version surfaces are internally consistent. - Database verification: not applicable. `make check` and `make test-offline` were not run because this change only rewrites version metadata. ## Final checklist - [x] I added or updated tests at the layer that owns the behavior, or explained why no test is needed. - [x] I updated public or design documentation for contract changes, or the change needs no documentation update. - [x] I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information. - [x] The PR title follows the repository's Conventional Commit format. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Approved-by: XuPeng-SH <[email protected]>
mergify Bot
pushed a commit
that referenced
this pull request
Sep 28, 2026
## Summary Add opt-in automatic model selection for Server-catalog chat turns. A confidently easy, read-only task can use an operator-qualified economy Offering; difficult, uncertain, unsupported, or incompatible cases retain the strong Offering. This gives API and SDK users a conservative way to reduce inference cost without changing explicit model selection. The shared runtime persists the selected model and its semantic admission before primary inference, reauthorizes execution, and propagates the choice to child runs. Auto selection starts or awaits the bounded assessment under the default auxiliary policy, so it does not silently pin every request to strong. Learned routing and mid-turn escalation are outside this PR. ## Related issue No linked issue. Follows the next-turn assessment work in #888. ## Change type - [x] Feature - [x] Bug fix - [x] Documentation - [ ] Refactor or performance improvement - [x] Test - [ ] Build, CI, or maintenance ## User and compatibility impact - Configure an operator-qualified economy/strong pair and revision in `[model_routing]` in the Server runtime configuration. Routing is disabled by default; this PR does not establish measured savings or qualify model pairs automatically. - HTTP chat clients opt in with `execution_policy.model_routing = "auto"` and omit `model_selection`. The TypeScript SDK accepts `modelSelection: "auto"`. - Explicit model selection and Server-default Work selection keep their existing behavior and default request serialization. Auto rejects conflicting explicit selections, provider model gateways, bound Work requests, and fixed-default semantic admission. - Auto uses the existing judgment boundary under the default capacity-aware policy, `boundary_only`, and `always`. Disabled or unusable assessments retain strong. Ordinary non-Auto turns keep their existing admission timing. - No database schema migration is required. Deploy Server support before clients send the new opt-in field. CLI/Web selectors and WebSocket chat remain explicit. ## Architecture and complexity delta - Canonical owner changed or extended: pure selection policy in `astra-turn-core`; typed routing configuration in `astra-turn-types`; existing Offering admission and shared agent loop in runtime; generation-fenced run-event transaction in services. - Existing implementations and callers searched: primary HTTP admission, semantic Work admission, model revalidation, shared turn preparation, dynamic-agent/forked-skill inheritance, in-memory/database run stores, SDK serialization, and their tests. - Superseded code, states, tables, shims, or self-only tests removed: none. No new table or parallel execution loop. Reuse the existing semantic judge, admission authority, event ledger, and recovery checks. - If parallel implementations remain, their boundary and retirement condition: none introduced. Explicit selection, Server-default selection, and opt-in Auto converge on the same admitted execution contract. Existing in-memory and database stores implement the same fenced transaction contract. The immutable routing event records policy and algorithm versions, input reference, assessment, selected Offering/model, contract digest, and semantic Work decision. The transaction updates the effective run model alongside that event. Persistence failure, stale execution ownership, revoked access, or changed model contracts prevent dispatch. Credentials and endpoints are not stored in the routing decision. ## Verification - Commands and results: - `cargo test --locked --offline -p astra-runtime --lib --no-default-features model_routing -q` — 8 passed. The entrypoint test covers default, explicit capacity-aware, boundary-only, always, disabled, and malformed-assessment cases, including no duplicate assessment on later preparation. - `cargo test --locked --offline -p astra-runtime --lib --no-default-features ordinary_primary_turn_defers_work_admission_without_a_boundary -q` — 1 passed. - `cargo test --locked --offline -p astra-runtime --lib --no-default-features post_response_work_admission_is_projected_into_the_typed_graph -q` — 1 passed. - `cargo test --locked --offline -p astra-services --test runs_db_batch_it auto_model_routing_memory_commit_is_atomic_and_fenced -q` — 1 passed. - From `packages/sdk`: `npm test -- src/__tests__/client.test.ts` — 85 passed. - `cargo clippy --locked --offline -p astra-runtime --lib --tests -- -D warnings` — passed on the final code. - `make format-check` and `git diff --check` — passed. - `make check` — passed on the rebased implementation before the final default-policy fix; that fix was subsequently verified by the targeted tests, Clippy, and formatting checks above. - The new default-policy regression failed before the fix with zero judgment calls instead of one, then passed after the fix. - `cargo test --locked --offline -p astra-services --test runs_db_batch_it -- --skip auto_model_routing_database_commit_is_atomic_and_fenced` — 2 passed: shared database-isolation contract and in-memory routing transaction; 21 database tests ignored. - With `MATRIXONE_HOST=127.0.0.1`, `MATRIXONE_PORT=6001`, local development credentials, `ASTRA_DATABASE=ASTRA_TEST_DATABASE=astra_runtime_test_router_pr892_20260927_runtime_ignored` (both variables set separately), `ASTRA_DATABASE_PREFIX=""`, `ASTRA_AUTO_CREATE_DATABASE=1`, and `ASTRA_TEST_DB_IT=1`: `cargo test --locked --offline -p astra-services --test runs_db_batch_it auto_model_routing_database_commit_is_atomic_and_fenced -- --ignored --exact --test-threads=1` — 1 passed against real MatrixOne in 0.90s. - Public entrypoint exercised: HTTP request DTO conversion and Auto admission; shared `prepare_turn_iteration` and `execute_turn` against a local mock provider; SDK request serialization. No live HTTP deployment or paid provider was exercised. - Unhappy paths exercised: missing policy, unauthorized Offering, conflicting explicit/provider/fixed selections, unavailable/incompatible/cross-billing economy candidates, unsupported input, disabled/malformed assessments, persistence fencing, missing resume decisions, changed contracts, revoked child inheritance, and credential rotation. - Database verification: no DDL or schema migration. The existing transaction atomically updates model identity with the immutable event. The shared atomicity/idempotency/fencing assertions pass against both the in-memory store and real MatrixOne 4.1.2, including rejected owner/session/generation/status, invalid baseline rollback, duplicate event replay, and conflicting decision rollback. The database test now uses the shared isolation guard, accepting CI lane database names while retaining explicit opt-in, designated/effective database matching, and protected-database rejection. ## Final checklist - [x] I added or updated tests at the layer that owns the behavior, or explained why no test is needed. - [x] I updated public or design documentation for contract changes, or the change needs no documentation update. - [x] I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information. - [x] The PR title follows the repository's Conventional Commit format. Approved-by: XuPeng-SH <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Collect optional next-turn assessments from the existing turn-intent and Work admission judges: expressed response satisfaction, new-task difficulty, urgency, and confidence for each dimension. Store them on the canonical user-message semantics marker, with an exact reference to the previous response when the evidence supports one. This gives future feedback analysis and model routing usable observations without changing routing decisions in this stage.
Related issue
Related to #764. This stage does not close the issue.
Change type
User and compatibility impact
There is no immediate UI or routing change, configuration change, migration, or additional judge call. New canonical turn records may contain optional assessment and response-reference fields. Older records remain readable; older strict readers reject the new fields, so mixed-version deployments need coordinated upgrades.
Architecture and complexity delta
TurnAssessmentcontract andUserTurnSemanticsmarker now own these observations. The agentic loop binds them to a frozen source message; existing judges produce them through their current paths.Verification
Final checklist
explained why no test is needed.
change needs no documentation update.
generated files, and other sensitive information.