crates.sage_inspector.inspection.canonical_ownership

Navigation uses backend-authored canonical ownership paths. Local and external semantic references carry opaque canonical paths distinct from labels. Paths whose ownership segments are all named survive unrelated/detail edits, sibling movement, and host reconstruction; rename, move, deletion, or a forged path fails explicitly.

Paths containing anonymous ownership segments are best-effort navigation identities, not persistent identities across edits or host reconstruction. Changing or deleting an anonymous entity can invalidate its link or cause it to select another indistinguishable occurrence. The same limitation applies to links to its descendants. Within the current host and source revision, paths still distinguish represented entities, and nonexistent paths fail explicitly. This qualification concerns inspector navigation only; import routes to the same definition do not give that definition different semantic identities. Anonymous import identity derives from its import paths and binding kinds, excluding source positions and database-local handles.

Read in specification context · design/crates/sage_inspector/inspection.sage

Implementation

Implemented crates/sage-ir/src/cst/paths.rs:96–101

sage_ir::cst::paths · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_inspector.inspection.canonical_ownership`
impl<'db> ToTokens<'db> for Path<'db> {
    fn to_tokens(&self, ctx: &TokenCtx<'_, 'db>, sink: &mut dyn TokenSink) {
        match *self {
            Path::Anchored(anchor, segments) => {
                anchor.kind.to_tokens(ctx, sink);

}

See more source ↗

Implemented crates/sage-ir/src/tokens.rs:59–64

sage_ir::tokens · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_inspector.inspection.canonical_ownership`
pub struct StringSink {
    buf: String,
    needs_space: bool,
}


}

See more source ↗

Implemented crates/sage-rustc-bridge/src/tcx_impl.rs:161–166

sage_rustc_bridge::tcx_impl · lib:sage_rustc_bridge

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_inspector.inspection.canonical_ownership`
    pub fn canonical_def_path(
        &self,
        crate_num: CrateNum,
        def_index: DefIndex,
    ) -> Option<sage_ir::tcx::ExternalDefPath> {

}

See more source ↗

Implemented src/inspector.rs:993–998

sage::inspector · lib:sage

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_inspector.inspection.canonical_ownership`
fn canonical_children<'db>(db: &'db dyn Db, symbols: &[Symbol<'db>]) -> Vec<CanonicalChild<'db>> {
    let mut occurrences = HashMap::<String, u32>::new();
    symbols
        .iter()
        .copied()

}

See more source ↗

Tests and review

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

Implemented sage::inspector::canonical_ownership_tests::anonymous_use_paths_survive_sibling_reordering

src/inspector/canonical_ownership_tests.rs · lib:sage

#![allow(unused)]
fn main() {
#[test]
#[sage::test(crates.sage_inspector.inspection.canonical_ownership)]
fn anonymous_use_paths_survive_sibling_reordering() {
    let project = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
        .join("test-projects/semantic-inspector/db-drop-guard");
    let paths = run_sage_host_with(&project, &[], |host| {
        let mut provider = LiveInspectionProvider::new(host);
        let declarations = "mod a { pub struct A; }\nmod b { pub struct B; }\n";
        provider
            .apply_updates(vec![FileUpdate {
                path: "lib.rs".to_owned(),
                text: format!("{declarations}use a::A;\nuse b::B;\n"),
            }])
            .unwrap();
        let index = provider.symbols().unwrap();
        let mut paths = Vec::new();
        for symbol in &index.value.symbols {
            if symbol.label == "use item" {
                let product = provider.product(&symbol.path, "source").unwrap();
                let RenderNode::Code { text, .. } = product.value.content else {
                    panic!("a source-written import has source code");
                };
                paths.push((symbol.path.clone(), text));
            }
        }
        assert_eq!(paths.len(), 2, "both distinct imports must be represented");
        provider
            .apply_updates(vec![FileUpdate {
                path: "lib.rs".to_owned(),
                text: format!("{declarations}use b::B;\nuse a::A;\n"),
            }])
            .unwrap();
        provider.symbols().unwrap();
        for (path, expected_source) in &paths {
            let product = provider
                .product(path, "source")
                .expect("sibling movement preserves an existing ownership path");
            let RenderNode::Code { text, .. } = product.value.content else {
                panic!("a source-written import has source code");
            };
            assert_eq!(
                &text, expected_source,
                "path {path} must retain its original import"
            );
        }
        paths
    });
    run_sage_host_with(&project, &[], |host| {
        let mut provider = LiveInspectionProvider::new(host);
        provider
            .apply_updates(vec![FileUpdate {
                path: "lib.rs".to_owned(),
                text: "mod b { pub struct B; }\nmod a { pub struct A; }\nuse b::B;\nuse a::A;\n"
                    .to_owned(),
            }])
            .unwrap();
        provider.symbols().unwrap();
        for (path, expected_source) in paths {
            let product = provider
                .product(&path, "source")
                .expect("reconstructing the host preserves each distinct import path");
            let RenderNode::Code { text, .. } = product.value.content else {
                panic!("a source-written import has source code");
            };
            assert_eq!(
                text, expected_source,
                "reconstructed path {path} must retain its import"
            );
        }
    });
}
}

Conditional source: #[cfg(test)]

See more source ↗

TODO sage_meta::todo::crates_sage_inspector_inspection_canonical_ownership

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_inspector.inspection.canonical_ownership)]
    fn crates_sage_inspector_inspection_canonical_ownership() {
        // TODO: Associate and review the complete evidence for Path tests cover local association,
        // anonymous and generated ownership, reordered siblings, rename failure, reconstruction,
        // external parent/children, and crate disambiguation. The full exact oracle suite separately
        // proves that navigation-only path detail does not enter the conformance representation.
    }
}

See more source ↗

Review: Accepted · Codex /root/anchor_094.

Reviewed the complete canonical_ownership claim, all four associated implementation files, both associated test entries, and captured inspection.sage plus the live-host helper and fixture manifest/source. This is source inspection; I did not execute the behavioral test or repeat centrally run suites. No source changes were made.

The local implementation in src/inspector.rs separates labels from paths: symbol_identity_parts constructs kind-prefixed, escaped named segments, canonical_children adds occurrence suffixes for repeated bases, and walk_symbols/find_local_reference construct ownership chains. resolve_local_symbol replays each segment against current owned children, so named identity depends on ownership/name rather than sibling location or product detail. Selection returns symbol-not-found when replay fails. This supports unrelated/detail edits and reconstruction while making old rename/move/delete/forged paths fail, subject to the explicit anonymous qualification. Anonymous segments use hashes and duplicate occurrence numbers: within a revision repeated representations are distinguished; these are deliberately not persistent entity IDs, and indistinguishable anonymous changes or descendant links can resolve differently. No stronger anonymous persistence guarantee is inferred.

External references are constructed from backend canonical_def_path, stable crate disambiguator, kind/name/disambiguator segments and a separate label. resolve_external_path validates the crate and each actual child prefix instead of treating client text as a definition ID. The associated rustc bridge implementation walks definition ownership and includes unnamed segments only for canonical navigation; its structured path variant omits them. This separation is relevant to the navigation-versus-semantic-identity qualification, but is not treated as proof of the entire import-route equivalence oracle.

Anonymous imports specifically hash each token-rendered import path, binding-kind discriminant, and named binding text. They do not hash the import span or database-local handles. The associated Path ToTokens implementation renders names/anchors/segments from the stash; the associated StringSink concatenates their textual tokens. These essential helpers are associated, rather than relying on the inspector marker alone. The ordinary anonymous_use_paths_survive_sibling_reordering test obtains two use-item paths and source products, reverses sibling imports, and asserts each saved path still returns its exact original source. It reconstructs a fresh host, reverses modules/imports, and repeats exact source equality. The captured run_sage_host_with helper creates a new SageHost for each callback; the manifest identifies the real fixture root. Thus this test provides concrete evidence for the new position/handle-independent anonymous import behavior, not merely an assertion that navigation succeeds.

The separate TODO entry explicitly retains incomplete association and review of the broader ownership-path evidence: local associated/generated ownership, named stability and failure scenarios, external parent/children and crate disambiguation, and the full exact oracle proving navigation detail does not contaminate semantic identity. Its prerequisite is to associate and review those complete assertion sets. I accept this as an honest visible deferral, not as executable coverage or proof that every claim scenario is complete. In particular the ordinary import regression does not establish all named rename/move/deletion failures, all binding kinds, anonymous descendant edge cases, or route-equivalent semantic identity. Those remain within the stated broader evidence deferral. All entries and claim qualifications are accounted for without weakening the claim or upgrading the TODO to completion. No concrete defect was identified in the reviewed behavior and no edits are 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