Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -480,17 +492,13 @@ 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");
// 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;
}

Expand Down Expand Up @@ -523,10 +531,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}"
);
}

Expand Down
9 changes: 8 additions & 1 deletion crates/tracedecay-query/src/native_git/branch_snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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]
Expand Down
18 changes: 15 additions & 3 deletions crates/tracedecay-search-eval/src/candidate_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}

Expand Down
8 changes: 8 additions & 0 deletions crates/tracedecay-temporal-query/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<_>>(),
vec![anchor("left"), anchor("right")]
);
assert!(result.lineage.is_empty());
assert!(result.conflicts.is_empty());
assert!(!result.context.rendered.contains("private-lineage"));
Expand Down
Loading