meta.anchors.content.source_end

An anchor’s content ends at the end of its containing Markdown document or .sage triple-quoted prose block. A .sage anchor never captures surrounding language syntax or content from another prose block, declaration, or method.

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

Implementation

Implemented crates/sage-meta/src/spec.rs:403–408

sage_meta::spec · lib:sage_meta

Each Sage prose block is parsed independently by add_chapter_text, so the end of this input cannot include another prose block or language syntax.

#![allow(unused)]
fn main() {
    // {anchor}`meta.anchors.content.source_end`
    // Each Sage prose block is parsed independently by add_chapter_text, so the
    // end of this input cannot include another prose block or language syntax.
    finish_anchor(
        &source.source,
        source.source.len(),

}

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::sage_prose_rules_have_precise_spans_model_owners_and_cross_source_references

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.canonical_sources)]
#[sage::test(meta.anchors.context_navigation)]
#[sage::test(meta.anchors.content.source_end)]
#[sage::test(meta.reviews.claim_text)]
#[sage::test(meta.anchors.unique_names)]
fn sage_prose_rules_have_precise_spans_model_owners_and_cross_source_references() {
    let fixture =
        BookFixture::new("- [Meta](design/meta.md)\n- [Crates](design/crates/README.md)\n");
    fixture.write(
        "design/meta.md",
        "{anchor}`rule` A rule refers to {spec}`crates.demo.nodes.member`.\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`
    A value with **meaning**.

    Précise values survive edits.

    - Keep the cached value.

    ```text
        Preserve relative indentation.
    ```
    """
    """
    {anchor}`member`
    Fields obey {spec}`meta.rule`.
    """
    number: Value,
}
class Node {
    """A node."""
    query value() -> Value {
        """
        {anchor}`query`
        Query results have stable identity.
        """
        envelope {}
    }
}
"#;
    fixture.write("design/crates/demo/nodes.sage", sage);
    let index = fixture.load();
    assert!(index.diagnostics.is_empty(), "{:?}", index.diagnostics);
    let value = &index.anchors["crates.demo.nodes.value"];
    assert_eq!(value.entity.as_deref(), Some("demo::nodes::Value"));
    assert_eq!(
        value.content,
        "A value with **meaning**.\n\nPrécise values survive edits.\n\n- Keep the cached value.\n\n```text\n    Preserve relative indentation.\n```"
    );
    assert_eq!(&sage[value.span.start..value.span.end], "{anchor}`value`");
    assert_eq!(
        &sage[value.content_span.start..value.content_span.end],
        "A value with **meaning**.\n\n    Précise values survive edits.\n\n    - Keep the cached value.\n\n    ```text\n        Preserve relative indentation.\n    ```"
    );
    let rust = sage_meta::correspondence::CorrespondenceIndex::from_sources(&[]).unwrap();
    let inputs = sage_meta::review::inventory(&index, &rust).unwrap();
    assert_eq!(
        inputs["crates.demo.nodes.value"].fragments.iter().find(|fragment| matches!(&fragment.selector, sage_meta::review::Selector::Claim { anchor_id } if anchor_id == "crates.demo.nodes.value")).unwrap().contents.join("\n"),
        "A value with **meaning**.\n\nPrécise values survive edits.\n\n- Keep the cached value.\n\n```text\n    Preserve relative indentation.\n```"
    );
    assert_eq!(
        index.anchors["crates.demo.nodes.member"].entity.as_deref(),
        Some("demo::nodes::Value::number")
    );
    assert_eq!(
        index.anchors["crates.demo.nodes.member"].content,
        "Fields obey {spec}`meta.rule`."
    );
    assert_eq!(
        index.anchors["crates.demo.nodes.query"].entity.as_deref(),
        Some("demo::nodes::Node::value")
    );
    let query = &index.anchors["crates.demo.nodes.query"];
    assert_eq!(query.content, "Query results have stable identity.");
    assert_eq!(
        &sage[query.content_span.start..query.content_span.end],
        query.content
    );
    assert_eq!(
        value.context_url,
        "design/crates/demo/nodes.html#anchor:crates.demo.nodes.value"
    );
    assert_eq!(index.references.len(), 2);
    for reference in &index.references {
        assert_eq!(
            &index.sources[&reference.file][reference.span.start..reference.span.end],
            format!("{{spec}}`{}`", reference.name)
        );
    }
}
}

See more source ↗

Review: Accepted · final_quality.

Fresh final marker followup of meta.anchors.content.source_end. Preserved the prior input/output, started fresh, read the full claim and three associated test bodies, and recaptured all prior dependencies: parser tokenization lines 1–57, prose recording lines 139–156, test source helper lines 1–15, BookFixture lines 536–565, and review claim construction lines 175–185. Compared every fragment by path/selector and implementation/test metadata. Only an implementation_references comment in spec.rs changed. Claim, parser/finalization behavior, tests, helper captures and metadata are unchanged, with no removed fragments. The unrelated marker delta was checked against the complete prior assessment below.

The sole ordinary source-end implementation association calls finish_anchor with the current parse input's byte length after all Markdown events. Each parse starts without an active anchor. Finalization takes the active anchor and stores only its own source slice through that boundary, trimming outer whitespace; it cannot extend into another document and does not require an explicit end at EOF. For Sage, captured tokenizer code yields precisely the triple-quoted interior and diagnoses unterminated prose. Prose recording excludes delimiter bytes and saves the owner/source span. spec.rs loops each prose block independently, dedents it with an offset map and calls add_chapter_text with a fresh SpecSource/parser state, then remaps locations to the original Sage file. Delimiters, field/declaration syntax, another prose block and following method syntax are outside that input. The review Claim fragment uses the bounded anchor.content. Helpers involved in this assessment are all captured.

The three ordinary tests cover the full boundary claim. claims_retain_all_blocks_until_the_next_definition_or_document_end checks final Markdown content including a later paragraph and trailing whitespace, with exact content and original-source span equality. an_end_marker_in_another_sage_prose_block_is_unmatched creates adjacent prose blocks, checks exact Unicode rule/qualification content from the first, and requires exactly one no-active-anchor diagnostic at the second block's precise marker slice; this detects leaked active state. sage_prose_rules_have_precise_spans_model_owners_and_cross_source_references separates value/member prose and a later class method prose block followed by envelope syntax. Exact rich multiline value text, source marker/content slices, member/query content and owners and review Claim text establish that surrounding syntax and other blocks/declarations/methods are excluded. The real workspace/book fixtures invoke production inventory loading. There are no TODO or N/A entries.

All aspects remain supported after the comment-only change. No source edits, formatting, tests or workspace build were performed in this followup; executed review start/read, capture comparisons and record only. 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