crates.sage_test_harness.compile_tests.query_projection

Query snapshots use stable semantic operation names and identities, retain parentage, multiplicity, and available execution/reuse dispositions, and omit allocation-dependent IDs and temporary paths. Only siblings explicitly defined as unordered may be canonically sorted. Unknown operations remain visibly unmapped rather than disappearing. An unmapped query key keeps its operation name and omits allocation-dependent debug arguments; it does not pretend to provide a semantic identity for those arguments. The projection follows the Inspector’s deterministic trace contract instead of inventing an unrelated raw-debug-string golden format.

Read in specification context · design/crates/sage_test_harness/compile-tests.md

Implementation

Implemented crates/sage-test-harness/src/compile/observe.rs:118–123

sage_test_harness::compile::observe · lib:sage_test_harness

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_test_harness.compile_tests.query_projection`
    let queries = if queries {
        let trace = sage_host::trace::snapshot_trace(events);
        serde_json::to_string_pretty(&trace).map_err(|e| e.to_string())? + "\n"
    } else {
        String::new()

}

See more source ↗

Implemented crates/sage-host/src/trace.rs:1–6

sage_host::trace · lib:sage_host

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_test_harness.compile_tests.query_projection`
use sage_inspector::*;

// {anchor}`crates.sage_inspector.inspection.balanced_traces`
// {anchor}`crates.sage_inspector.inspection.unknown_work`
pub fn build_dynamic_trace(

}

See more source ↗

Tests and review

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

Implemented sage_test_harness::compile::tests::cold_queries_are_stable_across_isolated_projects

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_test_harness.compile_tests.query_capture)]
    #[sage::test(crates.sage_test_harness.compile_tests.query_projection)]
    #[sage::test(crates.sage_test_harness.compile_tests.project_isolation)]
    #[sage::test(crates.sage_test_harness.compile_tests.rendering)]
    fn cold_queries_are_stable_across_isolated_projects() {
        let mut first = CompileTest::default();
        first.source("fn f() -> u16 { 22 }");
        first.queries(expect![""]);
        let first = first.prepare().unwrap();
        let mut second = CompileTest::default();
        second.source("fn f() -> u16 { 22 }");
        second.queries(expect![""]);
        let second = second.prepare().unwrap();
        assert_eq!(first.queries, second.queries);
        assert!(first.queries.contains("executed"), "{}", first.queries);
        assert!(first.queries.contains("body"), "{}", first.queries);
        assert!(!first.queries.contains("/tmp/"));
        assert!(!first.queries.contains("Id("));
    }
}

Conditional source: #[cfg(test)]

See more source ↗

Implemented sage_test_harness::query_projection_preserves_structure_and_sorts_only_unordered_siblings

crates/sage-test-harness/tests/review_semantics.rs · test:review_semantics

#![allow(unused)]
fn main() {
#[test]
#[sage::test(crates.sage_test_harness.compile_tests.query_projection)]
fn query_projection_preserves_structure_and_sorts_only_unordered_siblings() {
    use sage_ir::db::{InspectionChildOrder, InspectionEvent, InspectionSource};
    for order in [
        InspectionChildOrder::Sequential,
        InspectionChildOrder::Unordered,
    ] {
        let nodes = sage_host::trace::snapshot_trace(vec![
            InspectionEvent::SpanEnter {
                operation: "parent",
                source: InspectionSource::Sage,
                child_order: order,
            },
            InspectionEvent::QueryLeaf {
                key: "zeta(Id(42))".into(),
                disposition: salsa::QueryDisposition::Reused,
                observations: 3,
            },
            InspectionEvent::QueryLeaf {
                key: "alpha(Id(99))".into(),
                disposition: salsa::QueryDisposition::Executed,
                observations: 1,
            },
            InspectionEvent::SpanExit {
                operation: "parent",
            },
        ]);
        assert_eq!(nodes.len(), 1);
        assert_eq!(nodes[0].operation, "parent");
        assert_eq!(nodes[0].children.len(), 2);
        let operations: Vec<_> = nodes[0]
            .children
            .iter()
            .map(|node| node.operation.as_str())
            .collect();
        assert_eq!(
            operations,
            match order {
                InspectionChildOrder::Sequential => vec!["zeta", "alpha"],
                InspectionChildOrder::Unordered => vec!["alpha", "zeta"],
            }
        );
        let zeta = nodes[0]
            .children
            .iter()
            .find(|node| node.operation == "zeta")
            .unwrap();
        assert_eq!(zeta.observations, 3);
        let json = serde_json::to_value(zeta).unwrap();
        assert_eq!(json["disposition"], "reused");
        assert_eq!(json["key"]["kind"], "unmapped");
        assert_eq!(json["key"]["ingredient"], "zeta");
        assert!(!serde_json::to_string(&nodes).unwrap().contains("Id("));
    }
}
}

See more source ↗

Review: Accepted · Codex anchor_017 refresh.

Fresh review of crates.sage_test_harness.compile_tests.query_projection using the current start inputs and captured dependencies. Both implementation entries and both tests are ordinary; there are no TODO/N/A deferrals. I read the complete supplied implementation files and complete annotated test functions rather than relying on previous review output.

The requirements are stable semantic operation names and available identities; retained dynamic parentage, multiplicity and execution/reuse disposition; omission of allocation IDs and temporary paths; sorting only explicitly unordered siblings; visible unknown operations with honest unmapped keys; and use of the Inspector deterministic projection. In sage-host trace.rs, build_dynamic_trace preserves nested nodes through its stack and attach_trace_node, copies QueryLeaf observations, and maps every supplied Salsa disposition directly. Phase/span identities use the semantic operation; unknown queries and external metadata use Unmapped. query_operation strips parenthesized arguments. snapshot_trace replaces unmapped ingredient text with the operation, recurses through children, then normalizes only explicitly unordered children. It does not change the unmapped tag or invent argument identities. Sequential siblings and root order remain intact, and no unknown operation or multiplicity is filtered out. The second associated implementation, observe.rs collect, obtains the event log and serializes this shared typed snapshot as pretty JSON, so the harness uses Inspector semantics rather than raw debug output.

The captured Inspector deterministic_trace claim agrees with those ordering/structure rules. Captured protocol definitions expose stable serde tags, recursively serialized children and dispositions, and observations with default one. These are representation context; the projection logic itself is in the associated trace implementation. Captured CompileTest preparation shows each invocation creates a temporary project and reaches collect with query capture selected, making the independent-project test relevant.

The complete cold_queries_are_stable_across_isolated_projects test prepares identical source independently, compares the full query output, requires executed and body work, and rejects /tmp/ and Id(. Its current additional rendering annotation does not replace or hide these assertions. This provides end-to-end evidence of stable names/output and omission of unstable project/allocation details. The complete query_projection_preserves_structure_and_sorts_only_unordered_siblings test builds a parent with zeta/alpha children, asserts exact root and child counts and parent operation, verifies sequential zeta/alpha versus unordered alpha/zeta, asserts zeta multiplicity three and serialized reused disposition, requires the unmapped tag and operation-only zeta ingredient, and rejects injected Id arguments in serialized output. Alongside the production executed assertion, these assertions cover retained execution/reuse distinctions and unknown-operation visibility. Direct inspection confirms the other available enum dispositions are mapped without collapse. The explicit closed child list catches dropped nodes; the two ordering cases catch accidental sorting of sequential siblings and missing unordered sorting.

Assessment: the current implementation and visible combined assertions account for the complete claim and its qualifications; no necessary edits identified. I executed review start and review read commands during this refresh, but no behavioral test or workspace build. Root is running centralized validation, and no prior test execution is claimed as current execution here. No source edits were made.

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