Repository navigation
fix(harness): verify build identity before live probes - #863
Conversation
Require matching clean harness, CLI and Server revisions for comparison runs. Bound subprocess probes and retain sanitized diagnostics with ordering and cleanup tests.\n\nRefs #862
Reuse known expiry for rows inserted in the current admission transaction and verify replay does not duplicate accepted context events. Refs #862
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 8c44f41 against base 4d0c40e.
Verdict: REQUEST CHANGES — two P2 findings in the new revision-verification contract (inline). Both allow the checked Server and the actual execution target to differ: omitted execution-profile routing, and per-case endpoint overrides after the global preflight. They require separate fixes; forwarding the profile alone does not close the second path.
Scope reviewed: every changed hunk in all eight files, plus the build-metadata implementation, CLI endpoint/native-auth resolution, case loading/execution, and inference-attempt admission/context-expiry paths.
The database optimization is sound on the examined path: the plain INSERT must affect exactly one new row, context_expired_at is nullable with a NULL default, and the accepted event is written in that same transaction. No intervening operation changes that expiry. Reusing None avoids one single-row SELECT FOR UPDATE without adding a write, transaction, schema object, or weakening existing-row/terminal/recovery handling. The combined first-attempt admission path already uses this optimization, so the incremental saving applies to successful new inserts through begin_inference_provider_attempt; it is not a newly saved query on every inference path. Duplicate-admission tests retain the exact two-accepted/two-terminal event assertions.
The harness direction is useful and proportionate: reuse existing build metadata, bound both output streams and the child lifetime, reject unsupported certification modes, and keep metadata output ahead of configuration/runtime startup. Roughly half the additions are tests. I found no need for a new framework or persistence layer, and no additional production database load from this PR. Its value is reliable experiment setup plus a small, concrete SQL reduction; it does not implement TOP1–3 or establish quality, latency, or net-cost improvements.
Validation limits: source-level review; Cargo and a live MatrixOne/provider environment were not available here, so I did not independently run the author's 520-test or 50-database-test claims. At the last CI check, Static Checks, runtime, and services/plan/core test shards had passed; online and PTY jobs were still running. The two findings are established by the command construction and endpoint-resolution paths and are not covered by the added identity tests.
Submitted as COMMENT with an explicit request-changes verdict because the connected account is the PR author and GitHub does not permit a formal self REQUEST_CHANGES review.
| let readiness = check_server(&astra_bin).await?; | ||
| if let Some(expected) = expected_build.as_deref() { | ||
| validate_build_identity( | ||
| "Server", | ||
| expected, | ||
| Some(&readiness.build_git_sha), | ||
| readiness.build_git_dirty, |
There was a problem hiding this comment.
[P2] Verify the Server selected by the execution profile
The new revision check trusts check_server(&astra_bin), which invokes plain astra health, while check_model and the executor pass the selected --profile. These can target different Servers: native_auth::bind_process uses the active MOI endpoint without an explicit legacy profile, but bypasses that binding when --profile is supplied.
For example, with an active MOI login pointing to clean revision A and an authenticated legacy profile using the configured local Server at revision B, astra-test --profile local with expected A validates A, prints that the Server matches, and then sends its paid model probe to B. Conversely, expected B can reject the correctly selected local Server because the health probe checked A.
Resolve the effective execution profile before Server validation and pass the same routing context to health and model execution; revalidate if auto-registration changes that context. Keep the artifact-only --build-info-json invocation separate, since it intentionally accepts exactly one argument. Add a regression covering different MOI and explicit-profile endpoints and assert that the mismatched execution target is rejected before chat.
| if std::env::var_os("ASTRA_EXPECTED_BUILD_GIT_SHA").is_some() | ||
| && (args.live_dashboard.is_some() || args.executor_cmd.is_some()) | ||
| { | ||
| anyhow::bail!( | ||
| "revision verification requires the built-in CLI executor without --live-dashboard" | ||
| ); |
There was a problem hiding this comment.
[P2] Prevent per-case endpoint overrides from escaping revision verification
Rejecting dashboard/external executors does not make the remaining built-in path revision-bound. A loaded case may legally contain cli_env: { ASTRA_API_URL: "http://another-server" }; the one global preflight runs without that environment, and run_case_subprocess subsequently applies it to the actual CLI. CLI endpoint resolution honors this override.
Thus an explicit-profile run can pass all identity/model probes against clean revision A, then execute a case against revision B without checking B at all. This is independent of forwarding the profile to the health probe: the per-case environment changes only afterward. The disclaimer about not fingerprinting runtime configuration does not establish the claimed Server revision for this new target.
In expected-revision mode, either reject endpoint-changing case overrides before any live probes, or validate each effective execution target with its actual environment before allowing model work. An offline regression with distinct preflight and case endpoints should verify that a mismatch prevents the case chat from starting.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of 829cb09 against base 4d0c40e.
Verdict: REQUEST CHANGES — two remaining P2 gaps in the new revision-bound execution contract, detailed inline: the verified canonical CLI path is not propagated to execution, and preflight/execution use different inherited proxy bypass policies.
The previous findings have been addressed at source level: public preflight resolves the effective legacy profile before health, forwards it through the probes, rechecks the auto-registration route, and validates selected cases before live probes. The startup explicit-env propagation also prevents a case working-directory dotenv from silently changing routing. I am not reopening those original findings.
Scope: all changed hunks in all eight files, plus executable build metadata, CLI startup/config/native-auth routing, credentials/profile resolution, runner/executor command construction, ThinClient proxy selection, and provider-attempt admission/context-event/schema paths.
Database assessment: the optimization remains sound. Only a successful one-row INSERT reaches the changed accepted-event call; the nullable expiry starts as NULL and the event is written in the same transaction. The intervening canonical-transition update does not change that expiry. Existing-row/terminal/recovery reads remain intact. This removes one single-row SELECT FOR UPDATE per successful insert through begin_inference_provider_attempt without adding writes, transactions or schema. The combined first-attempt admission path already had the same optimization, so this is not a newly saved query on every inference path.
Non-blocking test note: the new duplicate-admission loop runs after the second attempt is already started. Both the terminal-first-attempt replay and the open-second-attempt replay therefore hit the invocation-level open-attempt guard before INSERT. To exercise duplicate terminal admission independently, replay the first attempt after its failed terminal is persisted but before starting the second attempt; retain the exact accepted/terminal event-count checks. This is a coverage limitation, not evidence that the SQL change is incorrect.
Complexity/value: 788 of the 1,200 added lines are tests; the runtime change reuses existing owners and introduces no production persistence framework. Build validation, bounded probe output/lifetime and isolated auth checks are useful prerequisites. The remaining fixes should consolidate the actual execution context, not add more case-specific denylist entries. This PR still does not implement TOP1–3 or demonstrate quality, latency or net-cost gains.
Validation: source review plus local executable/CWD and direct-vs-proxy mechanism reproductions. Cargo and a live MatrixOne/provider environment are unavailable here, so I did not independently rerun the reported Rust or database suites. At the latest check, the exact-head Test Suite and Static Checks workflows were still in progress; PR Title passed. The head was rechecked and remains 829cb09.
Submitted as COMMENT with an explicit request-changes verdict because the authenticated account is the PR author and GitHub does not allow formal self REQUEST_CHANGES reviews.
| Some(harness.git_sha), | ||
| Some(harness.git_dirty), | ||
| )?; | ||
| check_client_build(&astra_bin, expected).await?; |
There was a problem hiding this comment.
[P2] Reuse the verified absolute CLI path for actual case execution
The new CLI identity gate checks the canonical path local to run_preflight_with_build, but that path never reaches the executor: main.rs builds RunnerConfig from the original astra_bin, and run_case_subprocess uses that path after applying cfg.working_dir.
On Linux, launch from checkout A with --astra-bin ./target/debug/astra --working-dir /path/to/checkout-B, with an existing CLI at the same relative path in B. Preflight verifies A's CLI and runs all probes with A's absolute path, but the real case launches B's CLI without checking its revision. No binary replacement, concurrent modification, or setup script is needed. If B has no such binary, the same supported invocation passes preflight and then fails to spawn.
Canonicalize once at the entrypoint and pass that same absolute path to preflight, executor, judge and other subprocess consumers (or return a verified execution configuration). Add a regression with distinct binaries under the two directories and assert that the case uses the binary whose identity was checked. I reproduced the underlying Linux exec/CWD behavior with local executable shims; this was not an Astra integration-test run.
| .env("NO_PROXY", "localhost,127.0.0.1") | ||
| .env("no_proxy", "localhost,127.0.0.1") |
There was a problem hiding this comment.
[P2] Keep the inherited proxy bypass policy consistent with execution
This helper replaces both NO_PROXY variables with localhost,127.0.0.1; the model probes do the same. However, the case executor inherits the caller's original proxy environment. The new case-override denylist does not close this difference, because it exists without any cli_env override. ThinClient deliberately honors environment proxy routing for non-loopback endpoints.
For example, with ASTRA_API_URL=http://astra.internal, an HTTP proxy and NO_PROXY=astra.internal, preflight checks through the proxy while the actual case connects directly. A proxy-side DNS/backend mapping to clean revision A and a direct endpoint running B lets expected A pass before cases execute on unverified B. A proxy that cannot reach the private host instead rejects a working direct deployment. These are existing transport differences that the newly added revision certification must not treat as one verified target.
Preserve the inherited bypass policy across health, model, registration, cleanup and case subprocesses, preferably using the existing shared ThinClient loopback handling rather than hard-coded replacements. Add a regression with a non-loopback URL and distinct direct/proxy responders. A local curl experiment reproduced proxy A for the preflight environment and direct B for the execution environment; the Rust routing conclusion also follows from the linked ThinClient code.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of 4d4a6f5 against base 4d0c40e; incremental follow-up from 829cb09.
Verdict: APPROVE at the code-review level. No remaining actionable findings identified in the reviewed changes. This supersedes my previous REQUEST CHANGES verdict for 829cb09. The exact-head CI checks still need to finish before merge.
Closure evidence:
- Verified CLI path: main now canonicalizes the selected binary before constructing any consumer. Preflight, RunnerConfig/executor, judge, digest, summarizer and dashboard all receive this absolute path. Changing the case working directory therefore cannot select the other checkout's relative executable.
- Proxy consistency: the hard-coded NO_PROXY/no_proxy replacements are removed from readiness/model probes, registration/login, session cancellation/deletion, and dashboard subprocesses. The execution and auxiliary CLI consumers inherit the same caller environment. Existing ThinClient loopback handling remains the owner of direct loopback connections; remote endpoints preserve the user's proxy policy.
- Regression coverage: the new public-entrypoint test uses distinct executable shims in the startup and case directories. It covers selection through --astra-bin, ASTRA_BIN and a relative PATH entry, both present and absent bypass variables, authentication retry, actual case execution and session cleanup. This exercises the shared routing mechanics in smoke mode; the existing separate identity tests cover strict revision rejection.
- Database test coverage: terminal-attempt replay now occurs after the first failed attempt is terminal and before the next attempt opens. The open-attempt replay is tested separately. This closes the prior masking issue while retaining the accepted/terminal event-count assertions.
I also retraced the earlier profile forwarding, auto-registration revalidation, case routing restrictions, startup explicit-env inheritance, build-info-before-configuration entrypoint, malformed/mismatched/dirty identity rejection, bounded readiness output and child timeout handling. The previously reported profile and case-environment gaps remain addressed.
Database assessment is unchanged: the successful new-row branch reuses the known NULL expiry inside the inserting transaction, saving one SELECT FOR UPDATE on that path. Existing-row/terminal/recovery handling is unchanged; no production write, transaction or schema is added. The combined first-attempt path already had this saving. Additional readiness checks are harness startup/auth-recovery work, not recurring inference-path overhead.
Design and scope: the latest fix simplifies the production implementation by removing duplicated proxy overrides and resolving the executable at the entrypoint. Across the full PR, 969 of 1,390 added lines are tests. I found no justification for a new framework or additional lifecycle state, and none was added. This is useful S0 experiment infrastructure plus a small SQL reduction; it does not implement or establish effectiveness of TOP1–3.
Validation limits: source-level re-review of all current changed hunks using the previous full review plus the exact one-commit follow-up, with caller tracing through executor, judge, digest, summarizer, memory/session cleanup and CLI routing. Cargo and live MatrixOne/provider execution are unavailable in this environment, so the added Rust test and database fixture were inspected, not independently executed. At the final check, the head was unchanged; PR Title passed, while Static Checks/clippy and the main Test Suite jobs were still in progress.
Submitted as COMMENT with an explicit APPROVE verdict because the authenticated account is the PR author and GitHub does not permit formal self-approval.
Summary
Draft delivery for the realtime judgment TOP3 work. Current changes are S0 prerequisites: revision-bound harness preflight, bounded readiness probes, and removal of one redundant database read for each newly admitted provider attempt. No TOP1/TOP2/TOP3 effectiveness claim is made.
Related issue
Refs #862.
Change type
User and compatibility impact
ASTRA_EXPECTED_BUILD_GIT_SHArequires matching clean harness, CLI and Server builds before model probes. Skip-preflight, dashboard and external executor modes cannot certify this identity. Without an expected revision, preflight explicitly reports deployment-smoke scope.astra-test --build-info-jsonis configuration-independent.Architecture and complexity delta
Verification
cargo test --locked -p astra-test-harness: 520 tests passed, including doctest.cargo clippy --locked -p astra-test-harness --all-targets -- -D warnings: passed.make format-check,git diff --check: passed.Final checklist
TOP1–3 implementation, paired Jev/LLM/baseline comparisons, database-cost evidence and final adoption decisions remain open. This PR is deliberately draft.