crates.sage_ir.modules.parse.detail_firewall

Item identity is separate from tracked syntax detail. Rebuilding a module may update an item’s CST or absolute location without minting a new symbol when its semantic identity is unchanged. Every represented definition owns a separate CST stash so an equal sibling can be backdated independently. This applies Symbols form the uniform semantic identity family and Stash for type-level interning at the parse boundary.

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

Implementation

Implemented crates/sage-ir/src/local_syms/fns.rs:89–94

sage_ir::local_syms::fns · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.modules.parse.detail_firewall`
// {anchor}`crates.sage_ir.types.spans.offset_reuse`
pub struct LocalFnSym<'db> {
    pub name: Name<'db>,
    pub scope: ScopeSymbol<'db>,
    pub owner: Option<LocalAssociatedOwner<'db>>,

}

See more source ↗

Implemented crates/sage-ir/src/local_syms/mods.rs:19–24

sage_ir::local_syms::mods · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.modules.parse.detail_firewall`
// {anchor}`crates.sage_ir.symbols.local_identity`
pub struct LocalModSym<'db> {
    pub name: Name<'db>,

    /// The crate edition is copied onto modules so resolution performed while

}

See more source ↗

Implemented crates/sage-ir/src/parse/items.rs:68–73

sage_ir::parse::items · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.modules.parse.detail_firewall`
    pub(super) fn parse_fn(
        &self,
        node: tree_sitter::Node<'a>,
        pending_attrs: &[tree_sitter::Node<'a>],
    ) -> LocalModItemSym<'db> {

}

See more source ↗

Implemented crates/sage-ir/src/parse/mod.rs:28–33

sage_ir::parse · lib:sage_ir

#![allow(unused)]
fn main() {
// {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,
    source: ParseSource<'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_detail_firewall

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.modules.parse.detail_firewall)]
    fn modules_parse_detail_firewall() {
        // TODO: Complete the claim-specific verification matrix:
        // Persistent edit tests move an item, edit one body, and insert or reorder siblings while
        // checking symbol identity, per-item CST fingerprints, and downstream reexecution separately for
        // affected and unaffected items, including generated items.
    }
}

See more source ↗

Implemented sage_test_harness::trait_system_tests::detail_edits_preserve_local_symbol_query_keys

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.symbols.local_identity)]
    #[sage::test(crates.sage_ir.modules.parse.detail_firewall)]
    fn detail_edits_preserve_local_symbol_query_keys() {
        use salsa::Setter as _;

        struct Case {
            label: &'static str,
            before: &'static str,
            after: &'static str,
            item_index: usize,
        }

        fn force_observer(db: &dyn Db, source_file: SourceFile, item_index: usize) {
            let (_, root) = setup_root_module(db, source_file);
            let ModSymbol::Local(root) = root else {
                panic!("expected a local root module")
            };
            let item = root
                .unexpanded_items(db)
                .get(item_index)
                .copied()
                .expect("expected observed item");
            assert!(
                !matches!(item, sage_ir::local_syms::LocalModItemSym::Error(_)),
                "expected a represented item, got a parse error"
            );
            let symbol: Symbol<'_> = item.into();
            observe_symbol_identity(db, ObservedSymbol::new(db, symbol));
        }

        let cases = [
            Case {
                label: "function",
                before: "fn item() -> bool { false }",
                after: "fn item() -> bool { true }",
                item_index: 0,
            },
            Case {
                label: "struct",
                before: "struct Item { value: bool }",
                after: "struct Item { value: u32 }",
                item_index: 0,
            },
            Case {
                label: "enum",
                before: "enum Item { Value(bool) }",
                after: "enum Item { Value(u32) }",
                item_index: 0,
            },
            Case {
                label: "trait",
                before: "trait Item { fn value() -> bool; }",
                after: "trait Item { fn value() -> u32; }",
                item_index: 0,
            },
            Case {
                label: "impl",
                before: "struct Item; impl Item { fn value() -> bool { false } }",
                after: "struct Item; impl Item { fn value() -> bool { true } }",
                item_index: 1,
            },
            Case {
                label: "type alias",
                before: "type Item = bool;",
                after: "type Item = u32;",
                item_index: 0,
            },
            Case {
                label: "const",
                before: "const ITEM: bool = false;",
                after: "const ITEM: bool = true;",
                item_index: 0,
            },
            Case {
                label: "static",
                before: "static ITEM: bool = false;",
                after: "static ITEM: bool = true;",
                item_index: 0,
            },
            Case {
                label: "module",
                before: "#[doc = \"before\"] mod item {}",
                after: "#[doc = \"after\"] mod item {}",
                item_index: 0,
            },
            Case {
                label: "use",
                before: "use crate::before;",
                after: "use crate::after;",
                item_index: 0,
            },
            Case {
                label: "macro definition",
                before: "macro_rules! item { () => { struct Before; } }",
                after: "macro_rules! item { () => { struct After; } }",
                item_index: 0,
            },
            Case {
                label: "macro invocation",
                before: "item!(before);",
                after: "item!(after);",
                item_index: 0,
            },
        ];

        for case in cases {
            let mut database = Database::default();
            let source_file = database.add_source_file("lib.rs".to_owned(), case.before.to_owned());
            database.attach(|db| force_observer(db, source_file, case.item_index));
            database.take_query_log();

            database.attach(|db| force_observer(db, source_file, case.item_index));
            assert_eq!(
                database.take_query_log(),
                "",
                "{} must have a warm observer",
                case.label
            );

            source_file
                .set_text(&mut database)
                .to(case.after.to_owned());
            database.attach(|db| force_observer(db, source_file, case.item_index));
            let edit_trace = database.take_query_log();
            assert!(
                !edit_trace.contains("observe_symbol_identity"),
                "{} detail edit reminted its symbol:\n{edit_trace}",
                case.label
            );
        }
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Review: Accepted · Codex /root/macro_fix_anchor.

Freshly reviewed the complete parse.detail_firewall claim, four ordinary implementation associations, the ordinary twelve-case edit test, and the explicit TODO verification entry. Captured supporting rooted-storage equality, item-relative span construction, associated-member copying, fixture setup, observer identity, query execution logging, and both linked architectural rationales. No production edits.

LocalFnSym stores name/scope/owner as identity fields while CST and absolute span are tracked details. LocalModSym similarly separates name/edition/parent identity from body source, attributes and absolute span, with membership in a separate query. parse_str_to_cst dispatches item constructors rather than placing all module syntax in one shared returned value. parse_fn creates a fresh Stash, parses declaration/body coordinates relative to its item start, roots that syntax in Stashed, and passes its absolute span separately. Other item constructors in associated items.rs likewise establish separate rooted syntax stores for represented definitions; modules and imports retain separate attribute/import details. Captured associated.rs copies each minted function/type/const member into its own item stash rather than publishing owner-stash pointers as the member product. Captured util.rs keeps relative coordinates independent of absolute source placement. Stashed equality compares a rooted fingerprint rather than allocation identity, allowing rebuilt equal siblings to backdate independently.

The current associated mods.rs change exposes symbol_local_item for final import checking and adds an association; it does not modify LocalModSym identity/detail fields, parsing, or stash ownership. The claim does not promise parsing avoids rereading the containing file; it promises identity/detail separation and per-definition products.

The ordinary test detail_edits_preserve_local_symbol_query_keys covers function body, struct field, enum payload, trait member signature, impl member body, alias target, const/static values, module doc attributes, use target, macro-definition output and macro invocation tokens. Each fixture uses a persistent Database and SourceFile setter, rejects Error items, observes the semantic symbol, checks a warm empty query log, edits source and checks that observe_symbol_identity did not execute again. Captured setup_root_module genuinely reparses/specifies membership. The observer is tracked on an interned Symbol-only key, and the captured WillExecute logging/drain implementation makes the no-reexecution assertion meaningful evidence for unchanged identity. It intentionally does not establish detail-content equivalence or downstream detail-consumer cache behavior.

The modules_parse_detail_firewall TODO correctly retains moves, sibling insertion/reordering, affected/unaffected CST fingerprints and downstream reexecution, including generated items. Its prerequisite is persistent multi-item and generated-item fixtures observing identity and detail consumers independently. The existing single-item identity tests are substantive partial evidence, not completion of that matrix. No N/A evidence applies.

Executed cargo test -p sage-test-harness --lib detail_edits_preserve_local_symbol_query_keys: 1 passed (all twelve internal cases), no failures. Source inspection accounts for all four associated implementation entries; test assertions and visible TODO account for remaining verification limits. 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