crates.sage_test_harness.compile_tests.review_visibility

An anchor-associated inline test contains its source fixtures, annotations, explicit configuration, and expected observations directly in the annotated Rust function. The ordinary claim/test review captures the entire macro invocation as part of that function’s source. The harness macro implementation is not included in that snapshot; it is reviewed and tested independently. Reviewers evaluate whether the visible scenario and assertions establish the associated claim. A changed ERROR/WARN marker or compiler condition is a changed assertion of intended behavior and requires semantic justification, not merely a successful blessing run.

Read in specification context · design/crates/sage_test_harness/compile-tests.md

Implementation

Implemented crates/sage-test-harness/src/compile/mod.rs:84–89

sage_test_harness::compile · lib:sage_test_harness

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_test_harness.compile_tests.review_visibility`
    pub fn run(self) {
        let output = self
            .prepare()
            .unwrap_or_else(|error| panic!("compile_test: {error}"));
        if let Some(expect) = self.observations {

}

See more source ↗

Implemented crates/sage-meta/src/review.rs:216–221

sage_meta::review · lib:sage_meta

#![allow(unused)]
fn main() {
        // {anchor}`crates.sage_test_harness.compile_tests.review_visibility`
        let mut tests = Vec::new();
        let mut test_fragments = BTreeMap::new();
        for site in rust.tests.get(name).into_iter().flatten() {
            let source = rust
                .files

}

See more source ↗

Tests and review

Indexed tests and the implementation-completeness and test-adequacy review; no test run is implied.

Implemented sage_meta::inline_test_capture_preserves_intent_and_excludes_macro_implementation

crates/sage-meta/tests/review.rs · test:review

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.test_source)]
#[sage::test(crates.sage_test_harness.compile_tests.review_visibility)]
fn inline_test_capture_preserves_intent_and_excludes_macro_implementation() {
    let fixture = Fixture::new();
    let inline = r##"#[test]
#[sage::test(demo.rule)]
fn inline_case() {
    compile_test! {
        source: "fn f() { missing; } //# ERROR if SAGE\n//# WARN if rustc",
        edition: "2021",
        diagnostics: expect![[r#"expected diagnostic"#]],
    }
}"##;
    let macro_source = "macro_rules! compile_test { ($($tt:tt)*) => {} }\n";
    fixture.write("src/tests.rs", &format!("{macro_source}{inline}"));
    let input = fixture.start();
    let captured = input
        .fragments
        .iter()
        .find(|fragment| matches!(fragment.selector, Selector::Test { .. }))
        .unwrap();
    assert_eq!(captured.contents.join("\n"), inline);
    assert!(input.fragments.iter().all(|fragment| {
        !fragment
            .contents
            .join("\n")
            .contains("macro_rules! compile_test")
    }));
    review::record(&fixture.0, "demo.rule", &Fixture::report()).unwrap();
    assert!(sage_meta::check(&fixture.0).is_valid());
    let changed_macro = macro_source.replace("=> {}", "=> { panic!() }");
    fixture.write("src/tests.rs", &format!("{changed_macro}{inline}"));
    assert!(sage_meta::check(&fixture.0).is_valid());
    // Severity and compiler qualifiers express intended behavior. Each edit
    // must invalidate approval even without any changed observed snapshot.
    for changed in [
        inline.replace("ERROR", "WARN"),
        inline.replace("WARN", "ERROR"),
        inline.replace("if SAGE", "if rustc"),
        inline.replace("if rustc", "if SAGE"),
    ] {
        fixture.write("src/tests.rs", &format!("{changed_macro}{changed}"));
        assert!(!sage_meta::check(&fixture.0).is_valid(), "{changed}");
    }
}
}

See more source ↗

Implemented sage_test_harness::blessing_edits_the_inline_callsite_and_then_passes_without_updates

crates/sage-test-harness/tests/callsite_updates.rs · test:callsite_updates

#![allow(unused)]
fn main() {
#[test]
#[sage::test(crates.sage_test_harness.compile_tests.annotation_validation)]
#[sage::test(crates.sage_test_harness.compile_tests.callsite_updates)]
#[sage::test(crates.sage_test_harness.compile_tests.invocation)]
#[sage::test(crates.sage_test_harness.compile_tests.blessing_gate)]
#[sage::test(crates.sage_test_harness.compile_tests.review_visibility)]
fn blessing_edits_the_inline_callsite_and_then_passes_without_updates() {
    // Compile a disposable copy: expect-test must never update this test suite
    // while exercising update mode. The complete fixture and assertion remain
    // visibly inside the annotated function's source for anchor review.
    let project = tempfile::tempdir().unwrap();
    let harness = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
    std::fs::create_dir(project.path().join("src")).unwrap();
    std::fs::write(
        project.path().join("Cargo.toml"),
        format!(
            r#"
[package]
name = "inline_callsite_probe"
version = "0.0.0"
edition = "2024"
[workspace]
[dependencies]
sage-test-harness = {{ path = {:?} }}
expect-test = "1.5.1"
[patch.crates-io]
salsa = {{ path = {:?} }}
"#,
            harness,
            harness.join("../../vendor/salsa")
        ),
    )
    .unwrap();
    // Reuse the repository's pinned dependency resolution, not a fresh online
    // resolution of the disposable package's transitive dependencies.
    std::fs::copy(
        harness.join("../../Cargo.lock"),
        project.path().join("Cargo.lock"),
    )
    .unwrap();
    let source = r##"#![feature(rustc_private)]
use sage_test_harness::compile_test;
use expect_test::expect;
#[test]
fn inline_source() {
    compile_test! {
        source: "fn answer() -> u16 {\n    22 //# ty\n}",
        observations: expect![[r#""#]],
        diagnostics: expect![""],
    }
}
"##;
    let path = project.path().join("src/lib.rs");
    std::fs::write(&path, source).unwrap();
    let target = harness.join("../../target");
    let run = |update, expected_success| {
        let mut command = Command::new("cargo");
        command
            .args(["test", "--offline", "--lib", "--quiet"])
            .current_dir(project.path())
            .env("CARGO_TARGET_DIR", &target)
            .env("RUSTC", sage_host::metadata::our_rustc());
        if update {
            command.env("UPDATE_EXPECT", "1");
        } else {
            command.env_remove("UPDATE_EXPECT");
        }
        let output = command.output().unwrap();
        assert_eq!(
            output.status.success(),
            expected_success,
            "{}\n{}",
            String::from_utf8_lossy(&output.stdout),
            String::from_utf8_lossy(&output.stderr)
        );
        String::from_utf8_lossy(&output.stdout).to_string()
    };
    // A rustc-only warning is an unexpected diagnostic even with UPDATE_EXPECT.
    // The stale observation must remain byte-for-byte unchanged on failure.
    let unexpected = source.replace("fn answer()", "#[warn(dead_code)] fn answer()");
    std::fs::write(&path, &unexpected).unwrap();
    let failure = run(true, false);
    assert!(
        failure.contains("Rustc diagnostic markers do not match"),
        "{failure}"
    );
    assert_eq!(std::fs::read_to_string(&path).unwrap(), unexpected);
    std::fs::write(&path, source).unwrap();
    let stale = run(false, false);
    assert!(stale.contains("expect test failed"), "{stale}");
    assert_eq!(std::fs::read_to_string(&path).unwrap(), source);
    run(true, true);
    let blessed = std::fs::read_to_string(&path).unwrap();
    assert!(
        blessed.contains("src/lib.rs: literal `22`") && blessed.contains("type: u16"),
        "{blessed}"
    );
    assert!(blessed.contains("22 //# ty"));
    assert!(blessed.contains("diagnostics: expect![\"\"]"));
    assert_eq!(blessed.matches("src/lib.rs: literal").count(), 1);
    run(false, true);
    assert_eq!(std::fs::read_to_string(path).unwrap(), blessed);
}
}

See more source ↗

Review: Accepted · /root/final_quality.

Fresh review of review_visibility's complete claim, two ordinary implementation entries and two ordinary tests. Captured the meta test fixture helpers and correspondence registration/span handling needed by the review capture path. No TODO/N/A evidence. Source review only: no source edits, build or tests executed.

Review capture: correspondence records the annotated module-level test as a source-spanned RustSite, retaining the function rather than substituting macro expansion. review.rs extracts that site's source range into a semantic Test fragment keyed by file/crate/target/Rust path. Thus fixture strings, annotations, explicit configuration and Expect expressions written in the function remain verbatim review input. It does not follow inline compile_test invocations into the harness implementation as part of the test fragment. Harness implementation associations are separately captured for harness claims, including this claim's compile/mod.rs run entry. Current macro forwarding retains user expressions, and run prepares outputs before invoking caller expectations, so the reviewable invocation remains the author-written test rather than generated glue.

Freshness and author intent: review.rs re-resolves each semantic Test selector and compares saved inputs against current function source. ERROR/WARN spelling and compiler conditions are source assertions, so changing them invalidates the saved review even if the expectation literal stays the same. This tooling establishes review visibility/freshness; it does not mechanically infer semantic justification. The claim's requirement that reviewers evaluate whether scenario/assertions establish behavior remains a reviewer responsibility under the captured review prompt and checklist, not something a successful blessing run can prove.

Test evidence: inline_test_capture_preserves_intent_and_excludes_macro_implementation builds a disposable meta fixture with a standalone macro definition and an associated inline test containing source, ERROR if SAGE, WARN if rustc, edition and an explicit diagnostic expectation. It asserts exact equality between the captured Test fragment and the whole inline function, asserts no captured fragment contains the macro definition, records a review and verifies validity. Changing only that unrelated macro definition keeps the semantic test capture current. It then independently changes each severity/condition spelling and requires the check to become invalid. The fixture helpers create the specification, associated implementation and normal Cargo test target, and invoke real review start/record/check, so this is substantive capture/freshness evidence rather than a string-only mock. Excluding the macro definition here does not exempt harness implementation changes from their own associated reviews.

The second test, blessing_edits_the_inline_callsite_and_then_passes_without_updates, keeps the full disposable caller fixture and its expectations visibly inside the annotated function. Its subprocess assertions prove an unexpected rustc diagnostic cannot update snapshots, stale expectations fail without writes, successful blessing edits the literal at that caller, preserves the source marker and diagnostics field, and a separate non-updating run succeeds without changes. It demonstrates why blessing is representation updating rather than authorization to change diagnostic intent. Together these tests cover whole-invocation visibility, separate harness implementation review, source-sensitive marker/condition invalidation and preserved inline assertion text. No concrete defect or requested edit found.

Browse crates anchors

139 anchors

Specification anchors and declared coverage
AnchorImplementationTests
crates (139)114 Implemented37 TODO2 N/A74 Implemented107 TODO
crates.sage_inspector (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
crates.sage_inspector.inspection (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
balanced_tracesImplementedTODO
canonical_ownershipImplementedImplementedTODO
derive_reflectionImplementedImplementedTODO
detail_free_indexImplementedTODO
deterministic_traceImplementedTODO
durable_navigationN/ATODO
generic_browserN/ATODO
owned_reflectionImplementedImplementedTODO
product_availabilityImplementedTODO
revision_and_demandImplementedTODO
semantic_phase_boundaryImplementedTODO
source_evidenceImplementedTODO
typed_serviceImplementedTODO
unknown_workImplementedTODOTODO
workspace_actorImplementedTODO
crates.sage_ir (90)67 Implemented34 TODO40 Implemented88 TODO
crates.sage_ir.checking (12)12 Implemented3 TODO5 Implemented12 TODO
crates.sage_ir.checking.body (5)5 Implemented2 TODO3 Implemented5 TODO
elaborationImplementedImplementedTODO
expected_typesImplementedTODOTODO
interface_dependenciesImplementedImplementedTODO
isolated_completionImplementedImplementedTODO
operator_callsImplementedTODOTODO
identity_mintingImplementedTODO
owned_productsImplementedImplementedTODO
crates.sage_ir.checking.signature (4)4 Implemented1 TODO1 Implemented4 TODO
body_independenceImplementedTODO
narrow_detailImplementedTODOTODO
owner_binderImplementedImplementedTODO
storageImplementedTODO
symbol_keyed_interfacesImplementedTODO
crates.sage_ir.crate (9)9 TODO9 TODO
explicit_restrictionsTODOTODO
identity_before_detailTODOTODO
incremental_evidenceTODOTODO
narrow_demandsTODOTODO
reexecution_and_invalidationTODOTODO
represented_completenessTODOTODO
restrictions_and_gapsTODOTODO
semantic_query_boundariesTODOTODO
terminal_incompletenessTODOTODO
crates.sage_ir.inference (8)8 Implemented6 Implemented8 TODO
atomic_checkingImplementedImplementedTODO
body_local_quiescenceImplementedImplementedTODO
canonical_boundaryImplementedImplementedTODO
completed_body_boundaryImplementedTODO
numeric_domainsImplementedImplementedTODO
subtyping_and_coercionImplementedImplementedTODO
terminal_obligationsImplementedTODO
transaction_isolationImplementedImplementedTODO
crates.sage_ir.metadata (4)4 Implemented1 TODO4 TODO
explicit_incompletenessImplementedTODO
keyed_reuseImplementedTODOTODO
product_boundariesImplementedTODO
provider_authorityImplementedTODO
crates.sage_ir.modules (8)7 Implemented1 TODO4 Implemented8 TODO
crates.sage_ir.modules.expand (4)4 Implemented2 Implemented4 TODO
completenessImplementedImplementedTODO
dependenciesImplementedTODO
direct_membersImplementedTODO
recursion_and_fixpointImplementedImplementedTODO
crates.sage_ir.modules.parse (4)3 Implemented1 TODO2 Implemented4 TODO
dependenciesImplementedTODO
detail_firewallImplementedImplementedTODO
recovery_completenessTODOTODO
syntax_identitiesImplementedImplementedTODO
crates.sage_ir.resolution (5)5 Implemented1 TODO3 Implemented4 TODO
crates.sage_ir.resolution.lookup (5)5 Implemented1 TODO3 Implemented4 TODO
completenessImplementedTODOImplementedTODO
dependenciesImplementedTODO
expansion_import_ambiguityImplementedImplemented
identity_onlyImplementedTODO
precedenceImplementedImplementedTODO
crates.sage_ir.solver (9)7 Implemented7 TODO5 Implemented9 TODO
alternative_isolationImplementedTODOImplementedTODO
bounded_completenessImplementedTODOTODO
candidate_completenessImplementedTODO
canonical_cyclesTODOTODO
canonical_outputsImplementedImplementedTODO
local_index_firewallTODOTODO
normalization_demandImplementedTODOImplementedTODO
schedule_independenceImplementedTODOImplementedTODO
shared_final_resultImplementedTODOImplementedTODO
crates.sage_ir.symbols (8)8 Implemented4 Implemented7 TODO
associated_identityImplementedImplemented
associated_interfacesImplementedTODO
body_interfacesImplementedImplementedTODO
definition_identityImplementedTODO
external_fact_queriesImplementedTODO
external_identityImplementedTODO
kind_wrappersImplementedImplementedTODO
local_identityImplementedImplementedTODO
crates.sage_ir.types (27)16 Implemented12 TODO13 Implemented27 TODO
crates.sage_ir.types.aliases (2)1 Implemented1 TODO1 Implemented2 TODO
identityImplementedImplementedTODO
revelationTODOTODO
crates.sage_ir.types.binder (1)1 Implemented1 TODO1 Implemented1 TODO
owner_parametersImplementedTODOImplementedTODO
crates.sage_ir.types.body (13)4 Implemented9 TODO3 Implemented13 TODO
awaitTODOTODO
closuresTODOTODO
conditional_patternsTODOTODO
coroutinesTODOTODO
diagnosed_recoveryImplementedImplementedTODO
elaboratedTODOImplementedTODO
for_iterationTODOTODO
indexingTODOTODO
macro_expansionTODOTODO
no_inferenceImplementedImplementedTODO
resolved_referencesImplementedTODO
try_residualTODOTODO
typed_provenanceImplementedTODO
crates.sage_ir.types.calls (2)1 Implemented1 TODO1 Implemented2 TODO
dispatch_familiesTODOTODO
selected_semanticsImplementedImplementedTODO
crates.sage_ir.types.lifetimes (2)2 Implemented2 Implemented2 TODO
dummyImplementedImplementedTODO
unchecked_borrowsImplementedImplementedTODO
crates.sage_ir.types.operators (2)2 Implemented1 Implemented2 TODO
lazy_control_flowImplementedTODO
trait_callsImplementedImplementedTODO
scoped_identitiesImplementedTODO
crates.sage_ir.types.spans (4)4 Implemented4 Implemented4 TODO
generated_identityImplementedImplementedTODO
item_originImplementedImplementedTODO
offset_reuseImplementedImplementedTODO
relative_compositionImplementedImplementedTODO
crates.sage_oracle_harness (4)4 Implemented2 TODO1 Implemented4 TODO
crates.sage_oracle_harness.crate (4)4 Implemented2 TODO1 Implemented4 TODO
deterministic_emissionImplementedTODO
exact_comparisonImplementedTODOImplementedTODO
fixed_projectionImplementedTODO
independent_coverageImplementedTODOTODO
crates.sage_stash (5)5 Implemented5 Implemented
crates.sage_stash.storage (5)5 Implemented5 Implemented
handle_ownershipImplementedImplemented
immutable_entriesImplementedImplemented
query_valueImplementedImplemented
rooted_equalityImplementedImplemented
typed_interningImplementedImplemented
crates.sage_test_harness (25)25 Implemented25 Implemented
crates.sage_test_harness.compile_tests (25)25 Implemented25 Implemented
annotation_validationImplementedImplemented
blessing_gateImplementedImplemented
callsite_updatesImplementedImplemented
checking_scopeImplementedImplemented
compiler_conditionsImplementedImplemented
completed_typesImplementedImplemented
coordinatesImplementedImplemented
dependenciesImplementedImplemented
diagnostic_countsImplementedImplemented
diagnostic_locationsImplementedImplemented
editionImplementedImplemented
fixturesImplementedImplemented
grouped_observationsImplementedImplemented
invocationImplementedImplemented
production_executionImplementedImplemented
project_isolationImplementedImplemented
query_captureImplementedImplemented
query_projectionImplementedImplemented
renderingImplementedImplemented
resolved_symbolsImplementedImplemented
review_visibilityImplementedImplemented
rustc_executionImplementedImplemented
rustc_lintsImplementedImplemented
starting_expressionsImplementedImplemented
target_lineImplementedImplemented