meta.anchors.region_excerpts

A reference ending in << opens an explicit region, and a standalone // >> comment closes the nearest open region in the same file. Regions may nest. The excerpt spans the opening marker line through its closing marker line, with access to the surrounding source. A point reference inside a region remains a point reference and does not close or replace that region.

// {anchor}`meta.language.calls.declared`<<
let caller = current_operation();
check_declared_call(caller, callee)?;
record_call(caller, callee);
// >>

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

Implementation

Implemented crates/sage-meta/src/evidence.rs:181–186

sage_meta::evidence · lib:sage_meta

#![allow(unused)]
fn main() {
        // {anchor}`meta.anchors.region_excerpts`
        if region {
            open.push(pending.len());
        }
        pending.push((name.to_owned(), site));
    }

}

See more source ↗

Tests and review

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

Implemented sage_meta::nested_regions_close_the_nearest_opener_and_points_keep_their_own_preview

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.region_excerpts)]
fn nested_regions_close_the_nearest_opener_and_points_keep_their_own_preview() {
    let source = "// {anchor}`example.outer`<<\n// outer\n// {anchor}`example.inner`<<\n// {anchor}`example.point`\n// >>\n// after inner\n// >>\n// after outer\n// last\n";
    let rust = index(source);
    assert!(rust.diagnostics.is_empty());
    let outer = &rust.implementations["example.outer"][0];
    let inner = &rust.implementations["example.inner"][0];
    let point = &rust.implementations["example.point"][0];
    assert!(outer.region && inner.region && !point.region);
    assert_eq!((outer.line, outer.end_line), (1, 7));
    assert_eq!((inner.line, inner.end_line), (3, 5));
    assert_eq!((point.line, point.end_line), (4, 9));
    assert_eq!(
        outer.excerpt,
        source.lines().take(7).collect::<Vec<_>>().join("\n") + "\n"
    );
    assert_eq!(
        inner.excerpt,
        "// {anchor}`example.inner`<<\n// {anchor}`example.point`\n// >>\n"
    );
    assert_eq!(&source[point.span.start..point.span.end], point.excerpt);
    assert!(point.excerpt.ends_with("// last\n"));
}
}

See more source ↗

TODO sage_meta::todo::nested_region_excerpts

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(meta.anchors.region_excerpts)]
    fn nested_region_excerpts() {
        // TODO: Verify explicit boundaries, nearest-opener nesting, point
        // references within regions, and navigation to surrounding source.
    }
}

See more source ↗

Review: Accepted · /root/final_quality.

Fresh reassessment of meta.anchors.region_excerpts against the current complete claim, one associated implementation entry with evidence.rs helpers, one ordinary test and the explicit TODO test. Captured the index helper, generated source link and browser source-route/focus implementation. The settled spec.rs association-only change does not change region indexing semantics: the actual region mechanism resides in evidence.rs and was inspected again. No source edits or tests executed; review start rebuilt the sage-meta tool as needed, which is not a full-workspace build or behavioral test result.

Region semantics: marker accepts an immediate << suffix as a region. index_source initializes its pending entries and opener stack per source file, pushes only region entries and processes comments in source order. A standalone line-comment body exactly >> pops the nearest opener and sets its end_line/span.end through the full closing line. This gives nested LIFO matching without crossing files. Point references add independent pending entries but never push, pop or replace the region stack; their five-following-lines preview is computed separately. Final excerpts are exact slices from the opening line start through closing line end. Invalid unmatched boundaries receive separate diagnostics rather than a guessed region, although exhaustive balance errors belong to the related balance claim.

Surrounding-source access: the captured page renderer shows each excerpt plus a See more source link carrying file/start/end. The browser route displays every line from the source snapshot, highlights the selected range and marks the start for scrolling. This preserves surrounding context outside the explicit region rather than treating the excerpt as the entire file. This is inspection of the route implementation, not an interactive navigation run.

Ordinary test: nested_regions_close_the_nearest_opener_and_points_keep_their_own_preview indexes an outer region, inner region and intervening point. It requires no diagnostics; asserts region flags, outer 1..7 and inner 3..5 exact boundaries and point 4..9; checks the outer excerpt includes its closing line, exact inner marker-to-closer source, and point span/source equality continuing past both closers through the final line. Those assertions would detect closing the wrong opener or converting the interior point into a region boundary.

Explicit deferral: todo::nested_region_excerpts has no assertions and still records broader explicit-boundary/nesting/point/navigation verification. Core nesting/point semantics now have the ordinary fixture above; browser navigation to surrounding source remains deferred. Completing that TODO requires an interaction-level assertion that the generated source route opens full surrounding text at the intended lines, plus any broader region matrix retained there. Source inspection does not turn that TODO into executed coverage. Full claim accounting reveals no concrete new defect or requested edit.

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