crates.sage_ir.modules.parse.syntax_identities

Parsing publishes syntax-backed identities, not semantic conclusions. A represented item has stable local identity, self-contained CST, ordering, ownership, and provenance. Resolution and checking remain downstream operations, and malformed or unsupported top-level syntax is represented explicitly rather than accepted as a definition. Tree-sitter is temporary parser machinery under Tree-sitter for parsing, not the published identity or syntax representation.

Read in specification context · design/crates/sage_ir/modules.sage

Implementation

Implemented crates/sage-ir/src/local_syms/mods.rs:1–6

sage_ir::local_syms::mods · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.modules.parse.syntax_identities`
// {anchor}`crates.sage_test_harness.compile_tests.fixtures`
use sage_stash::{Slice, StashDirect, Stashed};

use crate::Db;
use crate::cst::attrs::{AttrCst, AttrCstKind, is_known_inert_item_attribute};

}

See more source ↗

Implemented crates/sage-ir/src/local_syms/structs.rs:1–6

sage_ir::local_syms::structs · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.modules.parse.syntax_identities`
use sage_stash::{StashDirect, Stashed};

use crate::cst::structs::StructCst;
use crate::name::Name;
use crate::scope::ScopeSymbol;

}

See more source ↗

Implemented crates/sage-ir/src/parse/items.rs:1–6

sage_ir::parse::items · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.modules.parse.syntax_identities`
// {anchor}`crates.sage_ir.modules.parse.dependencies`
// {anchor}`crates.sage_test_harness.compile_tests.fixtures`
// {anchor}`crates.sage_test_harness.compile_tests.checking_scope`
use sage_stash::{Ptr, Stash, Stashed};


}

See more source ↗

Implemented crates/sage-ir/src/parse/mod.rs:27–32

sage_ir::parse · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.modules.parse.syntax_identities`
// {anchor}`crates.sage_ir.modules.parse.detail_firewall`
// {anchor}`crates.sage_ir.modules.parse.dependencies`
// {anchor}`crates.sage_ir.modules.expand.direct_members`
pub fn parse_str_to_cst<'db>(
    db: &'db dyn Db,

}

See more source ↗

Tests and review

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

TODO sage_meta::todo::modules_parse_syntax_identities

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.modules.parse.syntax_identities)]
    fn modules_parse_syntax_identities() {
        // TODO: Complete the claim-specific verification matrix:
        // Source and generated fixtures preserve item order, ownership, CST, and provenance; malformed or
        // unsupported top-level input produces an error item; and a parse-only query trace contains no
        // resolution, signature, body, or solver work.
    }
}

See more source ↗

Implemented sage_test_harness::file_module_scope_tests::items_in_a_file_backed_module_use_that_module_as_their_scope

crates/sage-test-harness/src/lib.rs · lib:sage_test_harness

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.modules.parse.syntax_identities)]
    fn items_in_a_file_backed_module_use_that_module_as_their_scope() {
        with_test_crate_files(
            &[("lib.rs", "mod child;"), ("child.rs", "struct Holder;")],
            |db, root| {
                let child = root
                    .expanded_module_items(db)
                    .iter()
                    .find_map(|symbol| match symbol.data(db) {
                        SymbolData::ModSymbol(ModSymbol::Local(module)) => Some(module),
                        _ => None,
                    })
                    .expect("child module");
                let holder = ModSymbol::Local(child)
                    .expanded_module_items(db)
                    .iter()
                    .find_map(|symbol| match symbol.data(db) {
                        SymbolData::StructSymbol(StructSymbol::Local(strukt)) => Some(strukt),
                        _ => None,
                    })
                    .expect("Holder struct");

                assert_eq!(holder.scope(db), ScopeSymbol::Module(child));
            },
        );
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Review: Accepted · Codex /root/macro_fix_anchor.

Reviewed the complete syntax_identities claim, all four ordinary implementation associations, one ordinary test, and the explicit TODO test. Captured the linked Tree-sitter rationale, fixture/root setup, and parse span utilities. No source edits were made.

parse_str_to_cst creates temporary Tree-sitter parser/tree machinery and returns a Vec<LocalModItemSym>, not Tree-sitter identities. parse_item_list dispatches represented top-level syntax in source iteration order, retains pending attributes on their owning item, rejects tree nodes with errors, and converts unknown/unsupported top-level nodes and trailing unsupported attributes into explicit Error entries. parse/items.rs constructs per-item owned CST data with scope and absolute ParseSource provenance; macro invocation syntax stores path/input tokens without resolving its macro. Inline module children are parsed under ScopeSymbol::Module(new_module), while file-backed modules defer membership parsing. mods.rs unexpanded_items parses file-backed text with the module itself as scope. LocalStructSym demonstrates a stable name/scope identity with tracked CST/span detail and separately demanded sig/fields operations; its signature resolution and field checking are downstream calls, not parse actions. LocalModSym has the same identity/detail separation and a distinct membership query. Captured span utilities preserve supplied source provenance and item-relative syntax placement.

The current mods.rs edit only exposes symbol_local_item and adds a final-import-validation association; parsing, module ownership, identity fields and publication stay unchanged. All four associated files account for the stated parse architecture. This inspection does not imply every Rust syntax form is represented: unsupported syntax remains explicit recovery, and the current test coverage is intentionally partial.

The ordinary items_in_a_file_backed_module_use_that_module_as_their_scope fixture supplies lib.rs containing mod child and child.rs containing Holder. It finds the actual child module and struct via expanded membership and asserts Holder.scope equals that child module. Captured helpers register both real source files, parse the root and specify membership; the assertion therefore catches accidentally assigning file-module contents to the parent scope. It does not prove ordering, generated provenance, persistent identity stability, all recovery forms, or a parse-only execution firewall.

The modules_parse_syntax_identities TODO explicitly retains those missing source/generated fixture and query-trace cases: item order, ownership, CST/provenance, explicit malformed/unsupported recovery, and absence of resolution/signature/body/solver work in parse-only traces. Completing source/generated multi-item fixtures with direct CST/provenance assertions and a parse-only trace remains its prerequisite. This no-op is deferred evidence, not executable verification; no N/A entries apply.

Executed cargo test -p sage-test-harness --lib items_in_a_file_backed_module_use_that_module_as_their_scope: 1 passed, zero failures. Source inspection plus the concrete scope assertion and explicit remaining verification TODO account for the current claim without claiming full behavioral coverage. No edits requested.

Browse crates anchors

139 anchors

Specification anchors and declared coverage
AnchorImplementationTests
crates (139)114 Implemented37 TODO2 N/A74 Implemented107 TODO
crates.sage_inspector (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
crates.sage_inspector.inspection (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
balanced_tracesImplementedTODO
canonical_ownershipImplementedImplementedTODO
derive_reflectionImplementedImplementedTODO
detail_free_indexImplementedTODO
deterministic_traceImplementedTODO
durable_navigationN/ATODO
generic_browserN/ATODO
owned_reflectionImplementedImplementedTODO
product_availabilityImplementedTODO
revision_and_demandImplementedTODO
semantic_phase_boundaryImplementedTODO
source_evidenceImplementedTODO
typed_serviceImplementedTODO
unknown_workImplementedTODOTODO
workspace_actorImplementedTODO
crates.sage_ir (90)67 Implemented34 TODO40 Implemented88 TODO
crates.sage_ir.checking (12)12 Implemented3 TODO5 Implemented12 TODO
crates.sage_ir.checking.body (5)5 Implemented2 TODO3 Implemented5 TODO
elaborationImplementedImplementedTODO
expected_typesImplementedTODOTODO
interface_dependenciesImplementedImplementedTODO
isolated_completionImplementedImplementedTODO
operator_callsImplementedTODOTODO
identity_mintingImplementedTODO
owned_productsImplementedImplementedTODO
crates.sage_ir.checking.signature (4)4 Implemented1 TODO1 Implemented4 TODO
body_independenceImplementedTODO
narrow_detailImplementedTODOTODO
owner_binderImplementedImplementedTODO
storageImplementedTODO
symbol_keyed_interfacesImplementedTODO
crates.sage_ir.crate (9)9 TODO9 TODO
explicit_restrictionsTODOTODO
identity_before_detailTODOTODO
incremental_evidenceTODOTODO
narrow_demandsTODOTODO
reexecution_and_invalidationTODOTODO
represented_completenessTODOTODO
restrictions_and_gapsTODOTODO
semantic_query_boundariesTODOTODO
terminal_incompletenessTODOTODO
crates.sage_ir.inference (8)8 Implemented6 Implemented8 TODO
atomic_checkingImplementedImplementedTODO
body_local_quiescenceImplementedImplementedTODO
canonical_boundaryImplementedImplementedTODO
completed_body_boundaryImplementedTODO
numeric_domainsImplementedImplementedTODO
subtyping_and_coercionImplementedImplementedTODO
terminal_obligationsImplementedTODO
transaction_isolationImplementedImplementedTODO
crates.sage_ir.metadata (4)4 Implemented1 TODO4 TODO
explicit_incompletenessImplementedTODO
keyed_reuseImplementedTODOTODO
product_boundariesImplementedTODO
provider_authorityImplementedTODO
crates.sage_ir.modules (8)7 Implemented1 TODO4 Implemented8 TODO
crates.sage_ir.modules.expand (4)4 Implemented2 Implemented4 TODO
completenessImplementedImplementedTODO
dependenciesImplementedTODO
direct_membersImplementedTODO
recursion_and_fixpointImplementedImplementedTODO
crates.sage_ir.modules.parse (4)3 Implemented1 TODO2 Implemented4 TODO
dependenciesImplementedTODO
detail_firewallImplementedImplementedTODO
recovery_completenessTODOTODO
syntax_identitiesImplementedImplementedTODO
crates.sage_ir.resolution (5)5 Implemented1 TODO3 Implemented4 TODO
crates.sage_ir.resolution.lookup (5)5 Implemented1 TODO3 Implemented4 TODO
completenessImplementedTODOImplementedTODO
dependenciesImplementedTODO
expansion_import_ambiguityImplementedImplemented
identity_onlyImplementedTODO
precedenceImplementedImplementedTODO
crates.sage_ir.solver (9)7 Implemented7 TODO5 Implemented9 TODO
alternative_isolationImplementedTODOImplementedTODO
bounded_completenessImplementedTODOTODO
candidate_completenessImplementedTODO
canonical_cyclesTODOTODO
canonical_outputsImplementedImplementedTODO
local_index_firewallTODOTODO
normalization_demandImplementedTODOImplementedTODO
schedule_independenceImplementedTODOImplementedTODO
shared_final_resultImplementedTODOImplementedTODO
crates.sage_ir.symbols (8)8 Implemented4 Implemented7 TODO
associated_identityImplementedImplemented
associated_interfacesImplementedTODO
body_interfacesImplementedImplementedTODO
definition_identityImplementedTODO
external_fact_queriesImplementedTODO
external_identityImplementedTODO
kind_wrappersImplementedImplementedTODO
local_identityImplementedImplementedTODO
crates.sage_ir.types (27)16 Implemented12 TODO13 Implemented27 TODO
crates.sage_ir.types.aliases (2)1 Implemented1 TODO1 Implemented2 TODO
identityImplementedImplementedTODO
revelationTODOTODO
crates.sage_ir.types.binder (1)1 Implemented1 TODO1 Implemented1 TODO
owner_parametersImplementedTODOImplementedTODO
crates.sage_ir.types.body (13)4 Implemented9 TODO3 Implemented13 TODO
awaitTODOTODO
closuresTODOTODO
conditional_patternsTODOTODO
coroutinesTODOTODO
diagnosed_recoveryImplementedImplementedTODO
elaboratedTODOImplementedTODO
for_iterationTODOTODO
indexingTODOTODO
macro_expansionTODOTODO
no_inferenceImplementedImplementedTODO
resolved_referencesImplementedTODO
try_residualTODOTODO
typed_provenanceImplementedTODO
crates.sage_ir.types.calls (2)1 Implemented1 TODO1 Implemented2 TODO
dispatch_familiesTODOTODO
selected_semanticsImplementedImplementedTODO
crates.sage_ir.types.lifetimes (2)2 Implemented2 Implemented2 TODO
dummyImplementedImplementedTODO
unchecked_borrowsImplementedImplementedTODO
crates.sage_ir.types.operators (2)2 Implemented1 Implemented2 TODO
lazy_control_flowImplementedTODO
trait_callsImplementedImplementedTODO
scoped_identitiesImplementedTODO
crates.sage_ir.types.spans (4)4 Implemented4 Implemented4 TODO
generated_identityImplementedImplementedTODO
item_originImplementedImplementedTODO
offset_reuseImplementedImplementedTODO
relative_compositionImplementedImplementedTODO
crates.sage_oracle_harness (4)4 Implemented2 TODO1 Implemented4 TODO
crates.sage_oracle_harness.crate (4)4 Implemented2 TODO1 Implemented4 TODO
deterministic_emissionImplementedTODO
exact_comparisonImplementedTODOImplementedTODO
fixed_projectionImplementedTODO
independent_coverageImplementedTODOTODO
crates.sage_stash (5)5 Implemented5 Implemented
crates.sage_stash.storage (5)5 Implemented5 Implemented
handle_ownershipImplementedImplemented
immutable_entriesImplementedImplemented
query_valueImplementedImplemented
rooted_equalityImplementedImplemented
typed_interningImplementedImplemented
crates.sage_test_harness (25)25 Implemented25 Implemented
crates.sage_test_harness.compile_tests (25)25 Implemented25 Implemented
annotation_validationImplementedImplemented
blessing_gateImplementedImplemented
callsite_updatesImplementedImplemented
checking_scopeImplementedImplemented
compiler_conditionsImplementedImplemented
completed_typesImplementedImplemented
coordinatesImplementedImplemented
dependenciesImplementedImplemented
diagnostic_countsImplementedImplemented
diagnostic_locationsImplementedImplemented
editionImplementedImplemented
fixturesImplementedImplemented
grouped_observationsImplementedImplemented
invocationImplementedImplemented
production_executionImplementedImplemented
project_isolationImplementedImplemented
query_captureImplementedImplemented
query_projectionImplementedImplemented
renderingImplementedImplemented
resolved_symbolsImplementedImplemented
review_visibilityImplementedImplemented
rustc_executionImplementedImplemented
rustc_lintsImplementedImplemented
starting_expressionsImplementedImplemented
target_lineImplementedImplemented