meta.reviews.source_representation

Claim, implementation, and annotated test source snapshots are stored in input.json as arrays of source lines. Joining an array with newline characters recovers the snapshot’s text, including internal blank lines, whitespace, and markup.

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

Implementation

Implemented crates/sage-meta/src/review.rs:134–139

sage_meta::review · lib:sage_meta

#![allow(unused)]
fn main() {
// {anchor}`meta.reviews.source_representation`
fn source_lines(text: &str) -> Vec<String> {
    text.split('\n').map(str::to_owned).collect()
}

fn claim_path(workspace: &Path, file: &str) -> Result<String, Box<dyn Error>> {

}

See more source ↗

Tests and review

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

Implemented sage_meta::complete_claim_blocks_are_selected_but_unrelated_movement_is_not_stale

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.claim_text)]
#[sage::test(meta.reviews.selector_claim)]
#[sage::test(meta.reviews.staleness)]
#[sage::test(meta.reviews.source_representation)]
fn complete_claim_blocks_are_selected_but_unrelated_movement_is_not_stale() {
    let fixture = Fixture::new();
    let body = "First **paragraph**.\n\nSecond paragraph.\n\n- list item\n\n| A | B |\n|---|---|\n| 1 | 2 |\n\n```rust\nlet x = 4;\n```";
    let claim =
        format!("# Heading\n\n{{anchor}}`demo.rule`\n{body}\n\n<!-- end anchor -->\nOutside\n");
    fixture.write("md/design/README.md", &claim);
    let input = fixture.start();
    let fragment = input
        .fragments
        .iter()
        .find(|f| matches!(f.selector, Selector::Claim { .. }))
        .unwrap();
    assert_eq!(fragment.contents.join("\n"), body);
    review::record(&fixture.0, "demo.rule", &Fixture::report()).unwrap();
    fixture.write(
        "md/design/README.md",
        &format!("\n\n{}", claim.replace("Outside", "Changed outside")),
    );
    assert!(sage_meta::check(&fixture.0).is_valid());
    for text in ["Second paragraph", "list item", "| 1 | 2 |", "let x = 4"] {
        fixture.write("md/design/README.md", &claim.replace(text, "changed"));
        assert!(!sage_meta::check(&fixture.0).is_valid(), "{text}");
    }
}
}

See more source ↗

Implemented sage_meta::initial_context_preserves_instructions_and_exact_uniform_fragments

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.input_format)]
#[sage::test(meta.reviews.input_fragments)]
#[sage::test(meta.reviews.fragment_format)]
#[sage::test(meta.reviews.review_instructions)]
#[sage::test(meta.reviews.review_scope)]
#[sage::test(meta.reviews.source_representation)]
#[sage::test(meta.reviews.preparation)]
fn initial_context_preserves_instructions_and_exact_uniform_fragments() {
    let fixture = Fixture::new();
    let instructions = vec![
        "Check all scenarios.\nKeep this newline.".into(),
        "Account for TODO rationale.".into(),
    ];
    let input = review::start(&fixture.0, "demo.rule", instructions.clone()).unwrap();
    assert_eq!(input.coordinator_instructions, instructions);
    assert_eq!(input.prompt, review::PROMPT);
    assert_eq!(input, fixture.input());
    let claim = input
        .fragments
        .iter()
        .find(|f| matches!(&f.selector, Selector::Claim { anchor_id } if anchor_id == "demo.rule"))
        .unwrap();
    assert_eq!(claim.path, "md/design/README.md");
    assert_eq!(claim.contents.join("\n"), "The result is four.");
    let implementation = input
        .fragments
        .iter()
        .find(|f| f.path == "src/behavior.rs" && matches!(f.selector, Selector::WholeFile))
        .unwrap();
    assert_eq!(
        implementation.contents.join("\n"),
        std::fs::read_to_string(fixture.0.join("src/behavior.rs")).unwrap()
    );
    let test = input
        .fragments
        .iter()
        .find(|f| matches!(f.selector, Selector::Test { .. }))
        .unwrap();
    assert_eq!(test.path, "src/tests.rs");
    assert_eq!(test.contents.join("\n"), TEST);
    assert!(
        !input
            .fragments
            .iter()
            .any(|f| f.path == "src/tests.rs" && matches!(f.selector, Selector::WholeFile))
    );
    assert_eq!(input.implementations.len(), 1);
    assert_eq!(input.implementations[0].file, "src/behavior.rs");
    assert_eq!(input.implementations[0].status, TestStatus::Ordinary);
    assert_eq!(input.tests.len(), 1);
}
}

See more source ↗

Implemented sage_meta::whole_files_and_ranges_preserve_exact_line_endings_and_detect_selected_edits

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

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.reviews.selector_whole_file)]
#[sage::test(meta.reviews.selector_line_range)]
#[sage::test(meta.reviews.recorded_reads)]
#[sage::test(meta.reviews.fragment_freshness)]
#[sage::test(meta.reviews.input_format)]
#[sage::test(meta.reviews.input_fragments)]
#[sage::test(meta.reviews.source_representation)]
#[sage::test(meta.reviews.staleness)]
fn whole_files_and_ranges_preserve_exact_line_endings_and_detect_selected_edits() {
    let fixture = Fixture::new();
    fixture.start();
    fixture.write("helper.txt", "first\r\n\r\nthird\nlast");
    assert_eq!(
        review::capture_read(
            &fixture.0,
            "demo.rule",
            "helper.txt",
            Selector::LineRange { start: 1, end: 2 }
        )
        .unwrap(),
        "first\r\n\r\n"
    );
    assert_eq!(
        review::capture_read(
            &fixture.0,
            "demo.rule",
            "helper.txt",
            Selector::LineRange { start: 4, end: 4 }
        )
        .unwrap(),
        "last"
    );
    for (start, end) in [(0, 1), (3, 2), (1, 5), (5, 5)] {
        assert!(
            review::capture_read(
                &fixture.0,
                "demo.rule",
                "helper.txt",
                Selector::LineRange { start, end }
            )
            .is_err()
        );
    }
    review::record(&fixture.0, "demo.rule", &Fixture::report()).unwrap();
    fixture.write("helper.txt", "first\r\n\r\nUNSELECTED\nlast");
    assert!(sage_meta::check(&fixture.0).is_valid());
    fixture.write("helper.txt", "changed\r\n\r\nthird\nlast");
    assert!(!sage_meta::check(&fixture.0).is_valid());
    fixture.start();
    for _ in 0..2 {
        assert_eq!(
            review::capture_read(&fixture.0, "demo.rule", "helper.txt", Selector::WholeFile)
                .unwrap(),
            "changed\r\n\r\nthird\nlast"
        );
    }
    let input = fixture.input();
    let tail = &input.fragments[input.fragments.len() - 2..];
    assert_eq!(tail[0], tail[1]);
    assert_eq!(tail[0].contents.join("\n"), "changed\r\n\r\nthird\nlast");
    review::record(&fixture.0, "demo.rule", &Fixture::report()).unwrap();
    fixture.write("helper.txt", "changed\r\n\r\nthird\nlast\n");
    assert!(!sage_meta::check(&fixture.0).is_valid());
}
}

See more source ↗

Review: Accepted · final_quality.

Fresh final marker followup of meta.reviews.source_representation. Preserved prior input/output, started fresh and assessed the complete claim, sole ordinary implementation entry and all three ordinary tests. Recaptured all prior dependencies: review fixture lines 1–106 and spec.rs/correspondence.rs/check.rs. Compared every fragment by path/selector and both metadata sets. Only an implementation_references association comment in supplementary spec.rs changed. All source representation behavior, claim, test bodies, helper captures and metadata are unchanged; no fragments were removed. The isolated marker was checked against the full prior assessment and the current assertions below.

InputFragment.contents is a serialized Vec<String>. The associated source_lines helper splits only on newline, preserving whitespace and markup, internal empty components for blank lines, terminal empty components for terminal newlines and carriage returns in CRLF input. Newline joining exactly reconstructs the snapshot, including empty text. inventory applies this same conversion to full selected claim content, implementation source files and complete annotated test spans; capture_read uses it for later dependencies. JSON round trips preserve the strings, and freshness reassembles them with newline. Captured spec/correspondence sources establish the selected input text and check.rs establishes the validation path. This uniform lossless representation does not perform additional claim normalization; claim selection already defines the snapshot content.

initial_context_preserves_instructions_and_exact_uniform_fragments verifies returned input equals saved/deserialized input, joined claim equals exact text, joined implementation equals the on-disk file and joined semantic test fragment equals annotated TEST with indentation/comment. It also rejects substitution of a whole test file. complete_claim_blocks_are_selected_but_unrelated_movement_is_not_stale compares exact joined rich Markdown with blank lines, emphasis, later paragraph/list/table/fenced code; selected edits invalidate review while outside movement/text does not. whole_files_and_ranges_preserve_exact_line_endings_and_detect_selected_edits checks exact mixed CRLF/LF, blank-line and unterminated-final-line reconstruction, duplicate whole-file equality, inclusive range strings and invalid boundaries, then requires a changed terminal newline to invalidate the record. These test bodies were already read in the immediately preceding claim_text/fragment_format reviews; current capture comparison verifies they are identical here. Fixture helpers provide actual temporary sources and deserialize real saved input, not mocked representations.

All three snapshot categories and required text-preservation cases are supported; no TODO/N/A entries exist. The supplementary marker change does not alter these conclusions. No source edits, formatting, tests or workspace build were performed; executed review start/read, capture comparison 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