crates.sage_ir.symbols.body_interfaces

Checking and elaborating one function may read its own source and signature plus demanded signatures, fields, associated items, impl headers, metadata facts, and solver results. It must not read a callee or sibling body; a callee-body-only edit must not change or reexecute the caller’s completed body.

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

Implementation

Implemented crates/sage-ir/src/check/expr.rs:1233–1238

sage_ir::check::expr · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.symbols.body_interfaces`
fn def_to_ty<'db>(
    cx: &InferCtx<'_, 'db>,
    sym: crate::symbol::Symbol<'db>,
    span: RelativeSpan,
) -> Ptr<Ty<'db>> {

}

See more source ↗

Implemented crates/sage-ir/src/local_syms/fns.rs:250–255

sage_ir::local_syms::fns · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.symbols.body_interfaces`
    // {anchor}`crates.sage_ir.checking.body.interface_dependencies`
    // {anchor}`crates.sage_ir.checking.identity_minting`
    // {anchor}`crates.sage_ir.inference.completed_body_boundary`
    // {anchor}`crates.sage_ir.inference.body_local_quiescence`
    pub fn body(self, db: &'db dyn crate::Db) -> CheckedBody<'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::symbols_body_interfaces

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.symbols.body_interfaces)]
    fn symbols_body_interfaces() {
        // TODO: Cold/warm clone traces establish one case; add the full callee-body edit
        // matrix and sibling-body trace cases.
    }
}

See more source ↗

Implemented sage_test_harness::derive_expansion_tests::clone_method_body_has_a_narrow_reusable_semantic_query_trace

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.symbols.body_interfaces)]
    #[sage::test(crates.sage_ir.checking.body.interface_dependencies)]
    fn clone_method_body_has_a_narrow_reusable_semantic_query_trace() {
        let (tcx, tcx_calls) = BuiltinDeriveTcx::tracing();
        let mut database = Database::new(tcx);
        let source_file = database.add_source_file(
            "lib.rs".to_owned(),
            "#[derive(Clone)]\nstruct Db { shared: bool }\nstruct DbDropGuard { db: Db }\nimpl DbDropGuard { fn db(&self) -> Db { self.db.clone() } }"
                .to_owned(),
        );

        database.attach(|db| force_db_method(db, source_file));
        let first_salsa_trace = database.take_query_log();
        let first_tcx_trace = std::mem::take(&mut *tcx_calls.lock().unwrap());
        let mut semantic_calls: Vec<_> = first_tcx_trace
            .iter()
            .filter(|call| {
                call.starts_with("associated_items")
                    || call.starts_with("trait_signature")
                    || call.starts_with("fn_signature")
            })
            .cloned()
            .collect();
        semantic_calls.sort();
        assert_eq!(
            semantic_calls,
            [
                "associated_items(2,2)",
                "associated_items(2,3)",
                "fn_signature(2,7)",
                "trait_signature(2,2)",
                "trait_signature(2,5)",
            ]
        );
        assert!(
            first_tcx_trace.iter().all(|call| !call.contains("body")),
            "callee bodies must not be metadata dependencies: {first_tcx_trace:?}"
        );
        assert!(
            first_tcx_trace.iter().any(|call| call == "item_name(2,7)"),
            "external associated-item names are currently separate metadata dependencies: {first_tcx_trace:?}"
        );
        assert!(
            first_salsa_trace.contains("LocalFnSym < 'db >::body_"),
            "the requested body query must execute: {first_salsa_trace}"
        );

        database.attach(|db| force_db_method(db, source_file));
        let second_salsa_trace = database.take_query_log();
        let second_tcx_trace = std::mem::take(&mut *tcx_calls.lock().unwrap());
        assert!(
            second_tcx_trace.is_empty(),
            "unchanged body reuse must not reread metadata: {second_tcx_trace:?}"
        );
        assert!(
            !second_salsa_trace.contains("LocalFnSym < 'db >::body_"),
            "unchanged body query must be reused: {second_salsa_trace}"
        );
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Review: Accepted · Codex /root/anchor_094.

Reviewed the complete symbols.body_interfaces claim, both associated implementation files and both tests. Captured the symbols design, metadata trace fixture, body-forcing/root setup helpers and execution-log collection/draining. Source inspection only; no behavioral tests rerun and no source changes.

The claim permits a function's own source/signature and demanded semantic interfaces/metadata/solver facts, forbids callee or sibling body reads, and requires caller body stability and no reexecution after callee-body-only edits. LocalFnSym::body reads self.sig and self.cst, constructs its own checking context, imports signature/environment and checks only that CST before finalization. expr.rs def_to_ty handles local callees by reading local.sig, instantiating type parameters and submitting its parameter environment before producing FnPtr. It does not invoke local.body. Other expression paths consume demanded field/member/call facts rather than eagerly iterating function bodies. These entry paths support the semantic interface boundary; they do not alone prove the persistent edit requirement.

clone_method_body_has_a_narrow_reusable_semantic_query_trace forces DbDropGuard::db through a helper that asserts no checking diagnostics. The cold test compares the selected signature/item metadata operations against an exact sorted five-call list, forbids metadata call labels containing body, requires the separate item-name read and confirms a body query executed. It then repeats the request, requiring an empty metadata log and absence of body execution. Captured BuiltinDeriveTcx logging and Database WillExecute/draining show these are real cold/warm observations rather than reused log output. This is one meaningful interface/reuse scenario, but metadata labels do not prove the absence of every local sibling/callee body read, and the test performs no edit.

The symbols_body_interfaces TODO expressly retains the full callee-body edit matrix and sibling-body trace cases. Its prerequisite is persistent tests asserting both equal caller output and no caller reexecution after callee-body-only changes, alongside explicit forbidden local body dependencies. It contains no assertions and remains deferred. I do not weaken the claim's no-reexecution requirement to mere equal-output backdating or infer it from unchanged warm requests. All implementation entries and claim components are accounted for, with partial ordinary coverage clearly separated from the remaining verification. No concrete additional defect was identified in the inspected paths 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