meta.reviews.selector_test

Selector::Test { crate_name, target, rust_path } selects the complete annotated Rust test function within the fragment’s source file, including attributes, signature, body, and comments. crate_name identifies the Cargo package; target uses the correspondence target identity, including kind and name (for example lib:sage_meta or test:review); rust_path identifies the fully qualified function within that target. Identically named functions in different targets are distinct. The containing file need not be included. The selector stores no line numbers or byte offsets; inserting unrelated lines before an unchanged test does not make the fragment stale.

Read in specification context · design/meta/reviews.md

Implementation

Implemented crates/sage-meta/src/correspondence.rs:578–583

sage_meta::correspondence · lib:sage_meta

#![allow(unused)]
fn main() {
                // {anchor}`meta.reviews.selector_test`
                syn::Item::Fn(function) => {
                    self.record(
                        &function.attrs,
                        &function.sig.ident,
                        item.span(),

}

See more source ↗

Implemented crates/sage-meta/src/review.rs:350–355

sage_meta::review · lib:sage_meta

#![allow(unused)]
fn main() {
        // {anchor}`meta.reviews.selector_test`
        Selector::Test {
            crate_name,
            target,
            rust_path,
        } => {

}

See more source ↗

Tests and review

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

Implemented sage_meta::ambiguous_initial_test_selector_cannot_be_recorded_as_complete_context

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.selector_test)]
#[sage::test(meta.reviews.fragment_freshness)]
fn ambiguous_initial_test_selector_cannot_be_recorded_as_complete_context() {
    let fixture = Fixture::new();
    fixture.write(
        "src/tests.rs",
        &format!(
            "#[cfg(unix)]\n{TEST}\n#[cfg(windows)]\n{}",
            TEST.replace("2 + 2", "1 + 3")
        ),
    );
    // One target/path identity resolves to two distinct annotated function spans.
    // Initial context must reject the ambiguity just as an explicit read does.
    match review::start(&fixture.0, "demo.rule", vec![]) {
        Err(_) => {}
        Ok(input) => {
            assert_eq!(input.tests.len(), 2);
            assert!(
                review::record(&fixture.0, "demo.rule", &Fixture::report()).is_err(),
                "recording must reject an ambiguous initial selector, not silently keep one function body"
            );
        }
    }
    assert!(!sage_meta::check(&fixture.0).is_valid());
}
}

See more source ↗

Implemented sage_meta::ambiguous_test_identity_across_anchors_is_rejected

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.selector_test)]
#[sage::test(meta.reviews.fragment_freshness)]
fn ambiguous_test_identity_across_anchors_is_rejected() {
    let fixture = Fixture::new();
    fixture.write(
        "md/design/README.md",
        &format!("{CLAIM}\n{{anchor}}`demo.other`\nAnother claim.\n"),
    );
    fixture.write(
        "src/behavior.rs",
        "// {anchor}`demo.rule`\nfn result() {}\n// {anchor}`demo.other`\nfn other() {}\n",
    );
    fixture.write(
        "src/tests.rs",
        &format!(
            "#[cfg(unix)]\n{TEST}\n#[cfg(windows)]\n{}",
            TEST.replace("demo.rule", "demo.other")
        ),
    );
    assert!(
        review::start(&fixture.0, "demo.rule", vec![]).is_err(),
        "a selector is ambiguous even when its conflicting function is associated with a different anchor"
    );
    assert!(!sage_meta::check(&fixture.0).is_valid());
}
}

See more source ↗

Implemented sage_meta::another_anchors_test_read_tracks_body_and_identity

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.fragment_freshness)]
#[sage::test(meta.reviews.selector_test)]
#[sage::test(meta.reviews.recorded_reads)]
fn another_anchors_test_read_tracks_body_and_identity() {
    for change in ["body", "missing", "ambiguous"] {
        let fixture = Fixture::new();
        fixture.write(
            "md/design/README.md",
            &format!("{CLAIM}\n{{anchor}}`demo.other`\nOther scenario.\n"),
        );
        fixture.write("src/behavior.rs", "// {anchor}`demo.rule`\npub fn result() -> u32 { 4 }\n// {anchor}`demo.other`\npub fn other() -> u32 { 5 }\n");
        let other = "#[test] #[sage::test(demo.other)] fn other() { assert_eq!(2 + 3, 5); }";
        fixture.write("src/tests.rs", &format!("{TEST}\n{other}"));
        let initial = fixture.start();
        let selector = Selector::Test {
            crate_name: "demo".into(),
            target: "lib:demo".into(),
            rust_path: "demo::tests::other".into(),
        };
        assert_eq!(
            review::capture_read(&fixture.0, "demo.rule", "src/tests.rs", selector).unwrap(),
            other
        );
        let changed = match change {
            "body" => other.replace("2 + 3", "1 + 4"),
            "missing" => other.replace("fn other()", "fn renamed()"),
            _ => format!("#[cfg(unix)] {other}\n#[cfg(windows)] {other}"),
        };
        fixture.write(
            "src/tests.rs",
            &format!("// unrelated line\n{TEST}\n{changed}"),
        );
        if change != "ambiguous" {
            let spec = sage_meta::spec::SpecIndex::load_workspace(&fixture.0).unwrap();
            let rust = sage_meta::correspondence::CorrespondenceIndex::load(&fixture.0).unwrap();
            let current = review::inventory(&spec, &rust).unwrap();
            assert_eq!(initial.fragments, current["demo.rule"].fragments);
            assert_eq!(initial.tests, current["demo.rule"].tests);
        }
        assert!(
            review::record(&fixture.0, "demo.rule", &Fixture::report()).is_err(),
            "{change}"
        );
        assert!(!fixture.0.join("validations/demo.rule/output.json").exists());
    }
}
}

See more source ↗

Implemented sage_meta::test_selector_preserves_metadata_and_ignores_unrelated_line_movement

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.test_source)]
#[sage::test(meta.reviews.selector_test)]
#[sage::test(meta.reviews.staleness)]
#[sage::test(meta.reviews.fragment_associations)]
#[sage::test(meta.reviews.input_format)]
#[sage::test(meta.reviews.fragment_freshness)]
fn test_selector_preserves_metadata_and_ignores_unrelated_line_movement() {
    let fixture = Fixture::new();
    fixture.write(
        "src/tests.rs",
        &format!("#[cfg(unix)]\nmod nested {{\n{TEST}\n}}\n"),
    );
    let input = fixture.start();
    let test = &input.tests[0];
    assert_eq!(test.crate_name, "demo");
    assert_eq!(test.target, "lib:demo");
    assert_eq!(test.rust_path, "demo::tests::nested::verifies_result");
    assert_eq!(test.file, "src/tests.rs");
    assert!(test.cfg.iter().any(|cfg| cfg.contains("unix")));
    assert!(test.cfg.iter().any(|cfg| cfg.contains("test")));
    assert_eq!(test.status, TestStatus::Ordinary);
    let selector = Selector::Test {
        crate_name: test.crate_name.clone(),
        target: test.target.clone(),
        rust_path: test.rust_path.clone(),
    };
    assert_eq!(
        review::capture_read(&fixture.0, "demo.rule", "src/tests.rs", selector).unwrap(),
        TEST
    );
    review::record(&fixture.0, "demo.rule", &Fixture::report()).unwrap();
    fixture.write(
        "src/tests.rs",
        &format!("// Unrelated\n\n#[cfg(unix)]\nmod nested {{\n{TEST}\n}}\n"),
    );
    assert!(sage_meta::check(&fixture.0).is_valid());
    fixture.write(
        "src/tests.rs",
        &format!("#[cfg(windows)]\nmod nested {{\n{TEST}\n}}\n"),
    );
    assert!(!sage_meta::check(&fixture.0).is_valid());
}
}

See more source ↗

Implemented sage_meta::test_selectors_disambiguate_identical_paths_by_cargo_target

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.selector_test)]
#[sage::test(meta.reviews.recorded_reads)]
fn test_selectors_disambiguate_identical_paths_by_cargo_target() {
    let fixture = Fixture::new();
    // The same physical source is compiled as two independently named targets.
    fixture.write("Cargo.toml", "[package]\nname = 'demo'\nversion = '0.0.0'\nedition = '2024'\n[workspace]\n[[test]]\nname = 'first'\npath = 'tests/shared.rs'\n[[test]]\nname = 'second'\npath = 'tests/shared.rs'\n");
    fixture.write(
        "tests/shared.rs",
        "#[test] #[sage::test(demo.rule)] fn shared() { assert_eq!(4, 4); }",
    );
    let input = fixture.start();
    let tests: Vec<_> = input
        .tests
        .iter()
        .filter(|test| test.file == "tests/shared.rs")
        .collect();
    assert_eq!(tests.len(), 2);
    assert_ne!(tests[0].target, tests[1].target);
    for test in tests {
        let result = review::capture_read(
            &fixture.0,
            "demo.rule",
            &test.file,
            Selector::Test {
                crate_name: test.crate_name.clone(),
                target: test.target.clone(),
                rust_path: test.rust_path.clone(),
            },
        )
        .unwrap();
        assert_eq!(
            result,
            "#[test] #[sage::test(demo.rule)] fn shared() { assert_eq!(4, 4); }"
        );
    }
    assert!(
        review::capture_read(
            &fixture.0,
            "demo.rule",
            "tests/shared.rs",
            Selector::Test {
                crate_name: "other".into(),
                target: "test:first".into(),
                rust_path: "demo::shared".into()
            }
        )
        .is_err()
    );
}
}

See more source ↗

Review: Accepted · final_quality.

Fresh followup review of meta.reviews.selector_test. Preserved previous input/output, started fresh, read the complete claim and all five test bodies, recaptured prior fixture helpers (review.rs tests lines 1–103) and review design. Compared every previous/current fragment by path/selector and association metadata. The sole change is a placeholder_status association comment in review.rs; implementation/test metadata, claim, test bodies, correspondence source, helpers and design are unchanged. No fragments were removed. The comment does not affect the complete prior assessment, which I reassessed as follows.

Both ordinary implementation associations are necessary and present: correspondence.rs function extraction and review.rs Selector::Test selection. Correspondence builds package identity, kind:name target identity and fully qualified Rust path, preserving a shared file independently per target. Function extraction records item.span(), including attributes/signature/body and internal comments from original source; byte_span converts parsed positions into source byte ranges. Annotated module-level standard tests are admitted by record_tests. Selector::Test matches package, target and Rust path plus the fragment's resolved source file, deduplicates repeated associations to the same span, and requires exactly one span before slicing original text. inventory records complete function fragments without requiring the containing file, constructs identity-only Selector::Test values without line/byte offsets and rejects conflicting identities across anchors. input_errors compares initial captures and reselects added test reads; unchanged function text/identity therefore survives unrelated preceding lines. Essential extraction and resolution helpers are covered by the two associated whole files.

All five tests provide concrete evidence. test_selector_preserves_metadata_and_ignores_unrelated_line_movement asserts package/target/nested path/file/cfg/status and exact capture equality with TEST, whose fixture visibly includes attributes, signature, internal comment and assertion body; approval remains valid after unrelated leading lines but becomes invalid after cfg changes. This fixture has a separate implementation file, so its test fragment does not depend on a whole test-file snapshot. test_selectors_disambiguate_identical_paths_by_cargo_target creates two targets sharing a physical file, asserts distinct targets and exact selection in each, then rejects a wrong package. another_anchors_test_read_tracks_body_and_identity captures another anchor's test exactly and then checks body changes, renamed/missing identity, and ambiguous alternatives reject recording without an output file; unchanged initial context cannot hide stale additional reads. ambiguous_initial_test_selector_cannot_be_recorded_as_complete_context prevents two cfg-separated spans under the same identity from becoming completed review context. ambiguous_test_identity_across_anchors_is_rejected requires start to reject the corresponding conflict split across two anchors. These assertions cover complete text, identity disambiguation, positional independence and stale/ambiguous identity rejection.

There are no TODO or N/A implementation/test entries for this anchor. No missing requirement or behavioral defect was identified in the comment-only delta or full claim accounting. Executed review start/read and capture comparisons, followed by record; no source edits, tests, formatting or workspace build were performed in this followup. Historical execution in the previous report was not treated as new execution. No requested edits.

Browse meta anchors

116 anchors

Specification anchors and declared coverage
AnchorImplementationTests
meta (116)102 Implemented24 TODO103 Implemented36 TODO
meta.anchors (22)22 Implemented21 Implemented12 TODO
anchor_pagesImplementedImplementedTODO
book_explorerImplementedImplementedTODO
canonical_sourcesImplementedImplementedTODO
meta.anchors.content (7)7 Implemented7 Implemented
blocksImplementedImplemented
explicit_endImplementedImplemented
headingImplementedImplemented
literal_syntaxImplementedImplemented
next_anchorImplementedImplemented
source_endImplementedImplemented
unmatched_endImplementedImplemented
context_navigationImplementedImplementedTODO
evidence_statusImplementedImplementedTODO
explorer_navigationImplementedTODO
implementation_coverageImplementedImplementedTODO
implementation_referencesImplementedImplementedTODO
placeholder_statusImplementedImplementedTODO
point_excerptsImplementedImplementedTODO
region_balanceImplementedImplemented
region_excerptsImplementedImplementedTODO
test_coverageImplementedImplemented
test_referencesImplementedImplemented
unique_namesImplementedImplementedTODO
meta.book (21)10 Implemented18 TODO12 Implemented18 TODO
anchor_movesImplementedTODOImplementedTODO
authorityImplementedTODOImplementedTODO
browser_deliveryTODOImplementedTODO
browser_dependenciesTODOTODO
browser_rust_sourceTODOTODO
browser_searchTODOTODO
browser_serveTODOTODO
browser_structureTODOTODO
chapter_namesImplementedTODOImplementedTODO
crate_ownershipImplementedImplemented
crates_landingImplementedImplemented
entity_linksTODOTODO
index_groupsImplementedTODOImplementedTODO
index_namespace_pagesImplementedImplemented
index_rowsImplementedTODOImplementedTODO
index_statusImplementedTODOImplementedTODO
rfd_changesTODOTODO
sage_chaptersTODOImplementedTODO
self_descriptionTODOTODO
shared_modelImplementedTODOImplementedTODO
source_rolesTODOTODO
meta.contracts (4)4 Implemented3 TODO4 Implemented3 TODO
cache_invocationsImplementedTODOImplementedTODO
correspondenceImplementedImplemented
observation_coverageImplementedTODOImplementedTODO
validated_sessionImplementedTODOImplementedTODO
meta.language (39)39 Implemented39 Implemented
meta.language.calls (2)2 Implemented2 Implemented
declaredImplementedImplemented
forbiddenImplementedImplemented
meta.language.classes (3)3 Implemented3 Implemented
abstract_completeImplementedImplemented
override_signatureImplementedImplemented
single_inheritanceImplementedImplemented
meta.language.contexts (1)1 Implemented1 Implemented
inheritanceImplementedImplemented
meta.language.envelopes (7)7 Implemented7 Implemented
class_callsImplementedImplemented
createsImplementedImplemented
direct_callsImplementedImplemented
leafImplementedImplemented
permissionsImplementedImplemented
readsImplementedImplemented
receiver_callsImplementedImplemented
meta.language.fields (2)2 Implemented2 Implemented
context_stateImplementedImplemented
kindsImplementedImplemented
meta.language.methods (2)2 Implemented2 Implemented
kindsImplementedImplemented
proseImplementedImplemented
meta.language.model (3)3 Implemented3 Implemented
forbidden_pathsImplementedImplemented
inherited_prohibitionsImplementedImplemented
virtual_dispatchImplementedImplemented
meta.language.types (19)19 Implemented19 Implemented
argument_arityImplementedImplemented
declaration_proseImplementedImplemented
enum_variantsImplementedImplemented
field_proseImplementedImplemented
generic_parametersImplementedImplemented
member_commasImplementedImplemented
name_resolutionImplementedImplemented
opaque_representationImplementedImplemented
preludeImplementedImplemented
qualified_namesImplementedImplemented
recursive_valuesImplementedImplemented
struct_fieldsImplementedImplemented
tuplesImplementedImplemented
type_expressionsImplementedImplemented
unique_fieldsImplementedImplemented
unique_parametersImplementedImplemented
unique_variantsImplementedImplemented
unknown_namesImplementedImplemented
variant_proseImplementedImplemented
meta.reviews (27)27 Implemented27 Implemented
claim_textImplementedImplemented
complete_test_setImplementedImplemented
decisionsImplementedImplemented
fragment_associationsImplementedImplemented
fragment_formatImplementedImplemented
fragment_freshnessImplementedImplemented
gateImplementedImplemented
input_formatImplementedImplemented
input_fragmentsImplementedImplemented
output_formatImplementedImplemented
preparationImplementedImplemented
record_requiredImplementedImplemented
recorded_readsImplementedImplemented
recordingImplementedImplemented
review_delegationImplementedImplemented
review_diagnosticsImplementedImplemented
review_instructionsImplementedImplemented
review_scopeImplementedImplemented
selector_claimImplementedImplemented
selector_line_rangeImplementedImplemented
selector_testImplementedImplemented
selector_whole_fileImplementedImplemented
source_representationImplementedImplemented
stalenessImplementedImplemented
summary_formatImplementedImplemented
test_sourceImplementedImplemented
validation_layoutImplementedImplemented
meta.validation (3)3 TODO3 TODO
claim_specific_evidenceTODOTODO
independent_inspectionTODOTODO
review_packetsTODOTODO