From 869a67bc2a9d6e7e506ac3a56bb6d923a13e445e Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Tue, 29 Sep 2026 09:22:02 +0000 Subject: [PATCH 1/2] test(code-index): assert exact scheduler and snapshot outcomes --- .../src/code_index_generations/scope_roots.rs | 5 ++- .../registry/convergence_park_tests.rs | 40 ++++++++++++------- .../tests/code_index_suite/import_evidence.rs | 10 ++++- .../src/native_git/branch_snapshots.rs | 9 ++++- .../src/candidate_output.rs | 18 +++++++-- crates/tracedecay-temporal-query/src/tests.rs | 8 ++++ 6 files changed, 68 insertions(+), 22 deletions(-) diff --git a/crates/tracedecay-code-index-retention/src/code_index_generations/scope_roots.rs b/crates/tracedecay-code-index-retention/src/code_index_generations/scope_roots.rs index 453ac0ecf1..d77938be83 100644 --- a/crates/tracedecay-code-index-retention/src/code_index_generations/scope_roots.rs +++ b/crates/tracedecay-code-index-retention/src/code_index_generations/scope_roots.rs @@ -1164,8 +1164,9 @@ mod worktree_inventory_tests { #[test] fn live_roots_fail_closed_outside_a_repository() { let temporary = tempfile::TempDir::new().expect("non-repository root"); - assert!( - resolve_live_code_index_roots(temporary.path()).is_err(), + assert_eq!( + resolve_live_code_index_roots(temporary.path()).expect_err("non-repository"), + "git_repository_unavailable", "an unresolvable repository must never produce a smaller live set" ); } diff --git a/crates/tracedecay-code-index-runtime/src/code_index_scheduler/registry/convergence_park_tests.rs b/crates/tracedecay-code-index-runtime/src/code_index_scheduler/registry/convergence_park_tests.rs index c9638ad7ab..635f023f85 100644 --- a/crates/tracedecay-code-index-runtime/src/code_index_scheduler/registry/convergence_park_tests.rs +++ b/crates/tracedecay-code-index-runtime/src/code_index_scheduler/registry/convergence_park_tests.rs @@ -185,6 +185,18 @@ impl Fixture { } } +fn assert_seated_fixture_generation(seated: &super::super::CodeIndexPublishedGenerationV1) { + assert_eq!(seated.snapshot().files.len(), 1); + assert_eq!(seated.snapshot().files[0].logical_path, "src/main.rs"); + let symbols: Vec<(&str, &str)> = seated + .symbols() + .symbols + .iter() + .map(|symbol| (symbol.simple_name.as_str(), symbol.kind.as_str())) + .collect(); + assert_eq!(symbols, [("main", "function")]); +} + /// A permissive artifacts root violates the owner-privacy contract; the /// worker never re-permissions it. It parks typed, leaves the mode exactly as /// found, and resumes on the ordinary wake cadence once the operator restores @@ -480,17 +492,16 @@ async fn text_seats_while_graph_activation_keeps_failing_retryably() { set_injected_activation_failures(&scope.worktree_id, UNDRAINABLE_ACTIVATION_FAILURES); drop(admission); - let seated = fixture.wait_for_seated_generation().await; - let attempts = injected_activation_attempt_count(&scope.worktree_id); - assert!( - attempts > 0, - "the fixture must observe a real graph activation attempt, otherwise the seat proves nothing" - ); - assert!( - seated.is_some(), - "the sealed generation must take the serving seat while graph activation retries \ - (activation attempts: {attempts})" + let seated = fixture + .wait_for_seated_generation() + .await + .expect("the sealed generation must take the serving seat while graph activation retries"); + assert_eq!( + injected_activation_attempt_count(&scope.worktree_id), + 1, + "the fixture observes one graph activation attempt for the seated generation" ); + assert_seated_fixture_generation(&seated); fixture.registry.shutdown().await; } @@ -523,10 +534,11 @@ async fn a_spent_graph_publication_budget_is_refused_once_and_never_replayed() { .expect("freshness is observable"); assert_eq!(settled.code_graph_serving.as_ref(), Some(&refused)); assert!(!settled.rebuild_in_flight, "{settled:?}"); - assert!( - fixture.wait_for_seated_generation().await.is_some(), - "exact and lexical keep serving the generation whose graph was refused" - ); + let seated = fixture + .wait_for_seated_generation() + .await + .expect("exact and lexical keep serving the generation whose graph was refused"); + assert_seated_fixture_generation(&seated); // Past the whole retry backoff ladder, with the worker woken throughout. let observe_until = tokio::time::Instant::now() + Duration::from_secs(2); diff --git a/crates/tracedecay-code-index/tests/code_index_suite/import_evidence.rs b/crates/tracedecay-code-index/tests/code_index_suite/import_evidence.rs index 8a7f009483..9b70377ff5 100644 --- a/crates/tracedecay-code-index/tests/code_index_suite/import_evidence.rs +++ b/crates/tracedecay-code-index/tests/code_index_suite/import_evidence.rs @@ -1225,8 +1225,14 @@ fn sealed_import_generation_rejects_semantic_tampering_after_segment_readdress() rows[0]["imported_name"] = Value::String("Forged".to_owned()); }); assert!( - error.to_string().contains("import_authority_mismatch"), - "semantic tamper reached the wrong authority rejection: {error}" + matches!( + &error, + CodeIndexProductionErrorV1::Chunk( + tracedecay_code_index::chunks::ChunkingFailureV1::NonCanonicalIdentity(cause) + ) if cause.reason_code() + == tracedecay_code_index::noncanonical::NonCanonicalReasonCodeV1::ImportAuthorityMismatch + ), + "semantic tamper reached the wrong authority rejection: {error:?}" ); } diff --git a/crates/tracedecay-query/src/native_git/branch_snapshots.rs b/crates/tracedecay-query/src/native_git/branch_snapshots.rs index 1a47d35c02..7c066361d9 100644 --- a/crates/tracedecay-query/src/native_git/branch_snapshots.rs +++ b/crates/tracedecay-query/src/native_git/branch_snapshots.rs @@ -145,6 +145,7 @@ pub fn local_branch_snapshots_controlled( mod tests { use std::process::Command; + use tracedecay_contracts::branch_snapshots::LocalBranchSnapshotErrorV1; use tracedecay_contracts::{CancellationSignal, Deadline, clock}; use super::*; @@ -220,7 +221,13 @@ mod tests { resolved.commit.as_str(), git(root.path(), &["rev-parse", "HEAD"]) ); - assert!(local_branch_revision_controlled(root.path(), "missing", &control(1)).is_err()); + assert_eq!( + local_branch_revision_controlled(root.path(), "missing", &control(1)) + .expect_err("missing ref"), + LocalBranchSnapshotErrorV1::NotFound { + branch: "missing".to_owned(), + } + ); } #[test] diff --git a/crates/tracedecay-search-eval/src/candidate_output.rs b/crates/tracedecay-search-eval/src/candidate_output.rs index 84b321d391..f450e75c5b 100644 --- a/crates/tracedecay-search-eval/src/candidate_output.rs +++ b/crates/tracedecay-search-eval/src/candidate_output.rs @@ -1823,13 +1823,25 @@ pub(crate) mod tests { fn profile_material_digest_binds_every_checked_in_weight() { let workload = workload(); let profile = workload.profile_matrix.first().expect("profile"); + assert_eq!(profile.profile_id, "query-fallback"); + assert_eq!(profile.lexical_weight_ppm, 1_000_000); + assert_eq!(profile.graph_weight_ppm, 250_000); let digest = compute_profile_material_digest(profile).expect("digest"); - let mut changed = profile.clone(); - changed.graph_weight_ppm = changed.graph_weight_ppm.saturating_add(1); + let mut lexical = profile.clone(); + lexical.lexical_weight_ppm = 1_000_001; + let mut graph = profile.clone(); + graph.graph_weight_ppm = 250_001; + + assert_ne!( + digest, + compute_profile_material_digest(&lexical).expect("lexical digest"), + "the material digest must bind the checked-in lexical weight" + ); assert_ne!( digest, - compute_profile_material_digest(&changed).expect("changed digest") + compute_profile_material_digest(&graph).expect("graph digest"), + "the material digest must bind the checked-in graph weight" ); } diff --git a/crates/tracedecay-temporal-query/src/tests.rs b/crates/tracedecay-temporal-query/src/tests.rs index d3fd661b3f..918a4e74e1 100644 --- a/crates/tracedecay-temporal-query/src/tests.rs +++ b/crates/tracedecay-temporal-query/src/tests.rs @@ -1083,6 +1083,14 @@ fn unauthorized_assertion_metadata_never_enters_resolution_or_context() { .await .expect("unauthorized assertion is ignored"); + assert_eq!( + result + .ranked + .iter() + .map(|row| row.anchor_id.clone()) + .collect::>(), + vec![anchor("left"), anchor("right")] + ); assert!(result.lineage.is_empty()); assert!(result.conflicts.is_empty()); assert!(!result.context.rendered.contains("private-lineage")); From f9dc9c77edaa22455bb7508ef0f1eb1c3b71d465 Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Tue, 29 Sep 2026 10:05:21 +0000 Subject: [PATCH 2/2] test(code-index): pin the seated generation, not a racing attempt count --- .../registry/convergence_park_tests.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/tracedecay-code-index-runtime/src/code_index_scheduler/registry/convergence_park_tests.rs b/crates/tracedecay-code-index-runtime/src/code_index_scheduler/registry/convergence_park_tests.rs index 635f023f85..b642c7d941 100644 --- a/crates/tracedecay-code-index-runtime/src/code_index_scheduler/registry/convergence_park_tests.rs +++ b/crates/tracedecay-code-index-runtime/src/code_index_scheduler/registry/convergence_park_tests.rs @@ -496,11 +496,8 @@ async fn text_seats_while_graph_activation_keeps_failing_retryably() { .wait_for_seated_generation() .await .expect("the sealed generation must take the serving seat while graph activation retries"); - assert_eq!( - injected_activation_attempt_count(&scope.worktree_id), - 1, - "the fixture observes one graph activation attempt for the seated generation" - ); + // Retries stay armed, so the attempt counter is already past 1 on some + // observations. The seated file and symbol are the stable outcome. assert_seated_fixture_generation(&seated); fixture.registry.shutdown().await; }