meta.anchors.content.unmatched_end

An explicit end marker with no active anchor is a validation error. Another end marker after an explicit or implicit end, without an intervening definition, is therefore also an error. An anchor ending at another definition, a heading, or its source boundary does not require an explicit end marker.

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

Implementation

Implemented crates/sage-meta/src/spec.rs:307–312

sage_meta::spec · lib:sage_meta

#![allow(unused)]
fn main() {
                    // {anchor}`meta.anchors.content.unmatched_end`
                    if active.is_none() {
                        diagnostics.push(Diagnostic {
                            file: source.file.clone(),
                            span: span.clone(),
                            message: "an explicit anchor end marker has no active anchor".into(),

}

See more source ↗

Tests and review

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

Implemented sage_meta::an_end_marker_in_another_sage_prose_block_is_unmatched

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.source_end)]
#[sage::test(meta.anchors.content.unmatched_end)]
fn an_end_marker_in_another_sage_prose_block_is_unmatched() {
    let fixture = BookFixture::new("- [Crates](design/crates/README.md)\n");
    fixture.write("design/crates/README.md", "# Crates\n");
    fixture.write(
        "design/crates/demo/crate.sage",
        "crate demo { \"\"\"Demo.\"\"\" module nodes; }",
    );
    let sage = r#"module crate::nodes;
struct Value {
    """
    {anchor}`value` Une règle précise.

    Last qualification.
    """
    """
    <!-- end anchor -->
    """
    number: Value,
}
"#;
    fixture.write("design/crates/demo/nodes.sage", sage);
    let index = fixture.load();
    assert_eq!(
        index.anchors["crates.demo.nodes.value"].content,
        "Une règle précise.\n\nLast qualification."
    );
    assert_eq!(index.diagnostics.len(), 1, "{:?}", index.diagnostics);
    let error = &index.diagnostics[0];
    assert_eq!(error.file, "design/crates/demo/nodes.sage");
    assert!(error.message.contains("no active anchor"));
    assert_eq!(
        &sage[error.span.start..error.span.end],
        "<!-- end anchor -->"
    );
}
}

See more source ↗

Implemented sage_meta::claims_retain_all_blocks_until_the_next_definition_or_document_end

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.blocks)]
#[sage::test(meta.anchors.content.next_anchor)]
#[sage::test(meta.anchors.content.source_end)]
#[sage::test(meta.anchors.content.explicit_end)]
#[sage::test(meta.anchors.content.unmatched_end)]
fn claims_retain_all_blocks_until_the_next_definition_or_document_end() {
    let body = "Cachés retain **results**.\n\nA later paragraph qualifies the rule.\n\n- Keep unchanged inputs.\n- Recompute edited inputs.\n\n| Input | Result |\n| --- | --- |\n| same | reused |\n\n```rust\nlet résultat = cached();\n```\n\n    An indented example.\n\n> A quoted qualification.";
    let text = format!(
        "# Règles\n\n{{anchor}}`meta.first`\n{body}\n\n{{anchor}}`meta.second` Réévaluate.\n\nFinal qualification.  \n\n"
    );
    let index = SpecIndex::from_sources(&[source("rules.md", &text)]);
    assert!(index.diagnostics.is_empty(), "{:?}", index.diagnostics);
    let first = &index.anchors["meta.first"];
    let second = &index.anchors["meta.second"];
    assert_eq!(first.content, body);
    assert_eq!(second.content, "Réévaluate.\n\nFinal qualification.");
    for anchor in [first, second] {
        assert_eq!(
            &text[anchor.content_span.start..anchor.content_span.end],
            anchor.content
        );
    }
    assert!(first.content_span.end < second.span.start);
}
}

See more source ↗

Implemented sage_meta::unmatched_ends_are_errors_after_explicit_implicit_and_source_boundaries

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.unmatched_end)]
fn unmatched_ends_are_errors_after_explicit_implicit_and_source_boundaries() {
    for text in [
        "<!-- end anchor -->",
        "{anchor}`meta.first` Claim.\n\n<!-- end anchor -->\n<!-- end anchor -->\n",
        "{anchor}`meta.first` Claim.\n\n# Heading\n\n<!-- end anchor -->\n",
        "{anchor}`meta.first` Claim.\n\nHeading\n-------\n\n<!-- end anchor -->\n",
    ] {
        let index = SpecIndex::from_sources(&[source("ends.md", text)]);
        assert_eq!(
            index.diagnostics.len(),
            1,
            "{text}: {:?}",
            index.diagnostics
        );
        let error = &index.diagnostics[0];
        assert!(error.message.contains("no active anchor"));
        assert_eq!(
            &text[error.span.start..error.span.end],
            "<!-- end anchor -->"
        );
    }
    let index = SpecIndex::from_sources(&[
        source("first.md", "{anchor}`meta.first` Claim."),
        source("second.md", "<!-- end anchor -->"),
    ]);
    assert_eq!(index.diagnostics.len(), 1);
    assert_eq!(index.diagnostics[0].file, "second.md");
    assert_eq!(index.anchors["meta.first"].content, "Claim.");
}
}

See more source ↗

Review: Accepted · Codex /root/anchor_094.

Fresh final followup review of unmatched_end. Saved/read previous report and captures before start, recaptured all three dependencies, and compared every fragment. Claim, all three associated tests, source/BookFixture helpers and supplementary heading test are unchanged. The only implementation delta is an implementation_references association comment on another spec.rs method, with no parser behavior change.

The complete claim requires no-active-anchor explicit ends to be errors, including repeated ends after explicit or implicit closure without a new definition, and permits implicit closure at another definition/heading/source boundary without any explicit end. The sole ordinary implementation emits a file/span diagnostic when a recognized standalone end occurs with active None, then finish_anchor takes any active anchor. Headings also consume active state; valid new definitions close the previous rule and establish a new one; source completion needs no explicit end. Each source or Sage prose-block parse starts independent state, and dedented Sage error spans map back to original bytes. The added comment affects none of these paths.

All ordinary test evidence remains meaningful. unmatched_ends_are_errors_after_explicit_implicit_and_source_boundaries covers standalone and consecutive explicit markers and ends after hash/underline headings, asserting exactly one inactive-anchor diagnostic and its exact source slice; its separate-file case checks the second filename and preserved first rule. an_end_marker_in_another_sage_prose_block_is_unmatched checks independent Sage blocks through real workspace loading, exact first content, one error, correct file/message and exact original marker slice. claims_retain_all_blocks_until_the_next_definition_or_document_end omits end markers and requires clean diagnostics, exact contents/source slices and disjoint extents across definition and source-end closure. The separately captured semantic heading test exercises all six ATX levels and both Setext forms with omitted ends, requiring clean diagnostics and exact before/after contents/boundary. It is supporting dependency evidence, not represented as an initially associated unmatched_end test. source and BookFixture helpers pass real text/files to production parsing/loading.

No TODO/N/A entries or deferred requirements exist. The full prior assessment remains justified after checking the actual marker-only delta and unchanged substantive evidence. This review used fresh start/read/record and source inspection, with no source edits or behavioral test 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