meta.anchors.test_coverage

Every specification anchor must have at least one annotated Rust test. An anchor without a test is an error, independently of its implementation coverage. A placeholder test counts as an entry with its explicit status; an implementation placeholder alone cannot satisfy the test requirement.

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

Implementation

Implemented crates/sage-meta/src/spec.rs:168–173

sage_meta::spec · lib:sage_meta

#![allow(unused)]
fn main() {
    // {anchor}`meta.anchors.test_coverage`
    pub(crate) fn validate_anchors(
        &self,
        tests: &BTreeMap<String, Vec<RustSite>>,
    ) -> Vec<Diagnostic> {
        let mut diagnostics = self.diagnostics.clone();

}

See more source ↗

Tests and review

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

Implemented sage_meta::implementation_placeholders_do_not_replace_explicit_placeholder_tests

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.test_coverage)]
fn implementation_placeholders_do_not_replace_explicit_placeholder_tests() {
    use sage_meta::correspondence::{CorrespondenceIndex, RustSource};
    use sage_meta::review::{TestStatus, inventory};

    let spec = SpecIndex::from_sources(&[source(
        "rules.md",
        "{anchor}`meta.todo` An unfinished behavior.\n\n{anchor}`meta.na` An editorial rule.",
    )]);
    let implementations = r#"
        mod todo {
            // {anchor}`meta.todo`
            // TODO: Implement the unfinished behavior.
            struct Unfinished;
        }
        mod not_applicable {
            // {anchor}`meta.na`
            // N/A: Editorial rules have no runtime implementation.
            struct Editorial;
        }
    "#;
    let mut input = RustSource {
        crate_name: "test_crate".into(),
        target: "test:rules".into(),
        file: "tests/rules.rs".into(),
        source: implementations.into(),
    };
    let implementation_only = CorrespondenceIndex::from_sources(&[input.clone()]).unwrap();
    assert!(implementation_only.diagnostics.is_empty());
    assert!(
        spec.validate_implementations(&implementation_only)
            .is_empty()
    );
    assert!(implementation_only.tests.is_empty());
    let errors = spec.validate(&implementation_only.tests);
    assert_eq!(errors.len(), 2);
    assert!(
        errors
            .iter()
            .all(|error| error.message.contains("no associated Rust test"))
    );

    input.source.push_str(
        r#"
        mod tests {
            mod todo {
                #[test]
                #[sage::test(meta.todo)]
                fn unfinished() {
                    // TODO: Verify the unfinished behavior after implementation.
                }
            }
            mod not_applicable {
                #[test]
                #[sage::test(meta.na)]
                fn editorial() {
                    // N/A: This rule is an editorial requirement reviewed as prose.
                }
            }
        }
    "#,
    );
    let with_tests = CorrespondenceIndex::from_sources(&[input]).unwrap();
    assert!(with_tests.diagnostics.is_empty());
    assert!(spec.validate(&with_tests.tests).is_empty());
    let evidence = inventory(&spec, &with_tests).unwrap();
    assert_eq!(evidence["meta.todo"].tests.len(), 1);
    assert_eq!(evidence["meta.todo"].tests[0].status, TestStatus::Todo);
    assert_eq!(evidence["meta.na"].tests.len(), 1);
    assert_eq!(
        evidence["meta.na"].tests[0].status,
        TestStatus::NotApplicable
    );
}
}

See more source ↗

Implemented sage_meta::test_coverage_is_bidirectional_and_allows_many_to_many_links

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.test_coverage)]
#[sage::test(meta.anchors.test_references)]
fn test_coverage_is_bidirectional_and_allows_many_to_many_links() {
    let index = SpecIndex::from_sources(&[source(
        "rules.md",
        "{anchor}`meta.first` First requirement.\n\n{anchor}`meta.second` Second requirement.",
    )]);
    let mut tests = BTreeMap::from([
        ("meta.first".into(), vec![test_site(), test_site()]),
        ("meta.second".into(), vec![test_site()]),
    ]);
    assert!(index.validate(&tests).is_empty());
    tests.get_mut("meta.second").unwrap().clear();
    tests.insert("meta.typo".into(), vec![test_site()]);
    let diagnostics = index.validate(&tests);
    assert_eq!(diagnostics.len(), 2);
    assert_eq!(diagnostics[0].file, "rules.md");
    assert!(diagnostics[0].message.contains("meta.second"));
    assert!(diagnostics[0].message.contains("no associated Rust test"));
    assert_eq!(diagnostics[1].file, "tests/rules.rs");
    assert_eq!(diagnostics[1].span, test_site().annotation_span);
    assert!(
        diagnostics[1]
            .message
            .contains("unknown specification anchor `meta.typo`")
    );
}
}

See more source ↗

Review: Accepted · Codex /root/anchor_094.

Fresh complete followup assessment of test_coverage against current inputs. Latest shared spec.rs delta adds only an implementation_references association above the unknown-implementation validator; it does not change the coverage algorithm. The entire present claim and both associated tests were nevertheless reassessed.

The claim requires at least one annotated Rust test per specification anchor, missing tests to fail independently of implementation coverage, placeholder tests to count while retaining their explicit status, and implementation placeholders alone not to satisfy test coverage. The sole associated ordinary implementation validate_anchors iterates every anchor and emits the missing-test diagnostic when the tests map has no key or an empty vector. It reads no implementation inventory and makes no status-based exemption, so an ordinary or placeholder implementation cannot supply a test entry. The captured spec.rs also shows validate invokes this check separately from implementation validation. The inspected correspondence dependency accepts module-level annotated test declarations into the test map; the review inventory dependency copies those tests and determines status from the owning module through the captured placeholder_status helper. That helper explicitly preserves TODO/N/A ancestry rather than interpreting the entry as ordinary execution proof. These supporting helpers implement general annotation/status infrastructure; the associated validate_anchors owns the claim's coverage requirement.

Both ordinary test bodies provide meaningful assertions. test_coverage_is_bidirectional_and_allows_many_to_many_links first supplies multiple entries for the first anchor and one for the second and requires validation success. It then empties the second anchor vector and adds an unknown test reference; it requires exactly two diagnostics, identifies the missing-test error with the definition source and anchor name, and separately checks the unknown-reference source/span/message. This exercises the empty-entry failure and at-least-one success without an implementation precondition. implementation_placeholders_do_not_replace_explicit_placeholder_tests uses actual Rust source indexing, with TODO and N/A implementation comments for two anchors. It requires successful implementation validation, no test entries, and exactly two missing-test errors. It then appends explicitly annotated TODO and N/A test functions, requires clean indexing and test validation, and asserts exactly one review test per anchor with Todo and NotApplicable status respectively. This directly establishes missing-key failure, independence of implementation coverage, and acceptance without status erasure for both placeholder kinds.

The source/test_site helper capture was inspected: the former preserves input text; the latter constructs a stable RustSite for the map-level unit test, so that test is not represented as a full annotation-parser test. The actual-source placeholder test supplies the complementary integration path. Additional captured dependencies are correspondence::record_tests, review test inventory construction, and evidence::placeholder_status. There are no TODO/N/A evidence entries for this anchor itself and no deferred clause.

This was source review with fresh start/read/record commands, not a blind refresh. No source changes or test reruns were performed in this review; the coordinator reports central suites passed. All claim aspects are covered by current implementation and substantive assertions. 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