crates.sage_ir.checking.body.isolated_completion

Speculation is isolated and completion is quiescent. Candidate matching and other speculative relations occur in child inference versions; failure discards their equalities, wakeups, and staged obligations, while a successful operation commits them atomically. The public result is frozen only after fallback and terminal obligation processing leave no live work. Versioned egraph children are inference transactions defines the shared transaction rules.

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

Implementation

Implemented crates/sage-ir/src/check/expr.rs:22–27

sage_ir::check::expr · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.checking.body.isolated_completion`
    // {anchor}`crates.sage_ir.checking.body.expected_types`
    // {anchor}`crates.sage_ir.checking.body.operator_calls`
    pub(crate) async fn check_with(
        &self,
        cx: &InferCtx<'_, 'db>,

}

See more source ↗

Implemented crates/sage-ir/src/check/infer_ctx.rs:1059–1064

sage_ir::check::infer_ctx · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.checking.body.isolated_completion`
    // {anchor}`crates.sage_ir.inference.atomic_checking`
    pub(crate) fn commit_branch(&self, version: Version) {
        let effects = {
            let mut stash = self.target_stash.borrow_mut();
            let mut egraph = self.egraph.borrow_mut();

}

See more source ↗

Implemented crates/sage-ir/src/check/infer_ctx.rs:2216–2221

sage_ir::check::infer_ctx · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.checking.body.isolated_completion`
    // {anchor}`crates.sage_ir.inference.terminal_obligations`
    pub fn finalize(&self) {
        // First consume every proof that current inference already enables.
        self.process_ready_obligations();


}

See more source ↗

Implemented crates/sage-ir/src/check/infer_ctx.rs:2311–2316

sage_ir::check::infer_ctx · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.checking.body.isolated_completion`
    // {anchor}`crates.sage_ir.checking.body.elaboration`
    // {anchor}`crates.sage_ir.types.body.no_inference`
    // {anchor}`crates.sage_ir.inference.body_local_quiescence`
    // {anchor}`crates.sage_ir.inference.completed_body_boundary`
    pub fn finish(self, root: Ptr<TyExpr<'db>>, span: RelativeSpan) -> CheckedBody<'db> {

}

See more source ↗

Implemented crates/sage-ir/src/check/method.rs:310–315

sage_ir::check::method · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.checking.body.isolated_completion`
// {anchor}`crates.sage_ir.inference.atomic_checking`
fn instantiate_external_inherent_signature<'db>(
    cx: &InferCtx<'_, 'db>,
    signature: &sage_stash::Stashed<crate::ty::Binder<'db, FnSig<'db>>>,
    receiver_ty: Ptr<Ty<'db>>,

}

See more source ↗

Tests and review

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

Implemented sage_ir::check::method::tests::external_method_mismatch_discards_partial_generic_bindings

crates/sage-ir/src/check/method.rs · lib:sage_ir

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.inference.atomic_checking)]
    #[sage::test(crates.sage_ir.checking.body.isolated_completion)]
    fn external_method_mismatch_discards_partial_generic_bindings() {
        let database = Database::new(SignatureTcx {
            ordinary_complete: true,
        });
        database.attach(|db| {
            let source_stash = Stash::new();
            let cx = InferCtx::new(db, &source_stash, None);
            let function =
                FnSymbol::Ext(SymExt::new(db, CrateNum(1), DefIndex(11), SymExtKind::Fn));
            let signature = function.sig(db).expect("synthetic external signature");

            let bool_ty = cx.alloc_ty(Ty::Bool);
            let char_ty = cx.alloc_ty(Ty::Char);
            let caller_var = cx.fresh_ty_var();
            let owner = StructSymbol::Ext(SymExt::new(
                db,
                CrateNum(1),
                DefIndex(10),
                SymExtKind::Struct,
            ));
            let owner_args = cx.stash_mut().alloc_slice(&[bool_ty]);
            let receiver_ty = cx.alloc_ty(Ty::Adt(owner.into(), owner_args));
            let span = RelativeSpan { start: 0, end: 0 };
            let root_revision = cx.root_semantic_revision();

            assert!(
                instantiate_external_inherent_signature(
                    &cx,
                    &signature,
                    receiver_ty,
                    &[(caller_var, span), (char_ty, span)],
                    span,
                )
                .is_err(),
                "the second argument must reject the selected signature"
            );
            assert_eq!(cx.get_bound(caller_var), Bound::None);
            assert_eq!(
                cx.root_semantic_revision(),
                root_revision,
                "the first argument's method-generic binding must roll back"
            );
        });
    }
}

Conditional source: #[cfg(test)]

See more source ↗

TODO sage_meta::todo::checking_body_isolated_completion

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.checking.body.isolated_completion)]
    fn checking_body_isolated_completion() {
        // TODO: Complete the claim-specific verification matrix:
        // Rejected-candidate tests observe no leaked generic bindings, wakes, or obligations; accepted-
        // candidate tests observe one atomic commit; unresolved residual obligations become diagnostics;
        // and successful completion asserts an empty runtime, wake queue, obligation registry, and root
        // transaction set.
    }
}

See more source ↗

Review: Accepted · Codex /root/anchor_094.

Independently reviewed the entire isolated_completion claim, all five implementation associations across expr.rs, infer_ctx.rs and method.rs, and both test entries. Captured the checking design, accepted transaction RFD, egraph lifecycle helper, staged-obligation type and body-query caller. Source inspection only; no behavioral suites rerun and no source edits.

The claim requires child-version speculation, rollback of equalities/wakes/staged obligations, atomic successful publication, and fallback plus terminal obligation processing before freezing a result with no live work. The associated external method instantiator creates a ROOT child, allocates generic inference variables there, and relates receiver/arguments within that version. Any mismatch discards the child and returns before publishing obligations. On success it stages the parameter environment, commits the child, then publishes that batch. The captured egraph lifecycle enforces an exclusive leaf child/direct-parent collapse, transfers equality/bound/domain/revision state and returns collected wake effects; discard removes child states. InferCtx commit_branch rebuilds before collapse and publishes wakes only from committed effects. The obligation batch is ordinary owned staging data and is published explicitly, so failure before publication does not register its obligations.

expr.rs is the body expression entry that invokes method resolution and consumes its successful target; infer_ctx.rs supplies the shared transaction/completion lifecycle. finalize processes ready obligations, defaults deferred never targets, resolves final bounds and diagnoses unresolved variables, retries obligations after fallback, terminally discharges remaining obligations, and drains wakes/runtime. finish consumes the context and asserts no pending obligations, live root child, active runtime task, unpublished wake or unfilled expression slot before producing CheckedBody. The captured LocalFnSym::body confirms the caller invokes finalize before finish. These are concrete safeguards, not proof that every speculative relation and completion scenario has been exhaustively exercised.

The ordinary external_method_mismatch_discards_partial_generic_bindings test uses the in-file SignatureTcx fixture with owner generic T, method generic E and parameters E then bool. The receiver binds T to bool; the first argument can partially bind E to a caller variable; the second char argument then rejects bool. The test requires failure, verifies the caller variable remains Bound::None and verifies the root semantic revision is unchanged. This genuinely checks rollback after partial matching, rather than immediate rejection. Its fixture and helper are present in the associated method.rs source. It does not observe wake queues, staged obligations, accepted commits or a complete body-finalization run.

The explicit checking_body_isolated_completion TODO retains exactly those wider prerequisites: rejected-candidate checks for leaked bindings/wakes/obligations, accepted-candidate atomic commit observations, residual-obligation diagnostics, and successful completion with empty runtime/wake/obligation/live-transaction state. The prerequisite is completing that claim-specific matrix across representative speculative operations and finalization paths. It contains no executable assertions and remains visibly deferred. The narrow ordinary rollback regression and inspected guards are not promoted to proof of all shared transaction rules. Every implementation entry, test and claim requirement is accounted for; no concrete additional defect was found 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