crates.sage_ir.modules.expand.direct_members

Expansion returns direct module members, not a visible-name environment. The result preserves deterministic order and provenance for source and generated direct items. Child-module members remain in the child, while imports and namespace lookup are interpreted later by resolution.

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

Implementation

Implemented crates/sage-ir/src/derive.rs:41–46

sage_ir::derive · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.modules.expand.direct_members`
    pub fn parse_output(self, db: &'db dyn crate::Db) -> Vec<LocalModItemSym<'db>> {
        let Some(output) = self.text(db) else {
            return Vec::new();
        };
        let scope = match self.source_item(db) {

}

See more source ↗

Implemented crates/sage-ir/src/local_syms/macro_invocations.rs:48–53

sage_ir::local_syms::macro_invocations · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.modules.expand.direct_members`
    pub fn parse_output(
        self,
        db: &'db dyn Db,
        macro_def: MacroDefSymbol<'db>,
    ) -> Vec<LocalModItemSym<'db>> {

}

See more source ↗

Implemented crates/sage-ir/src/local_syms/mods.rs:100–105

sage_ir::local_syms::mods · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.modules.expand.direct_members`
// {anchor}`crates.sage_ir.modules.expand.completeness`
// {anchor}`crates.sage_ir.modules.expand.dependencies`
// {anchor}`crates.sage_ir.modules.expand.recursion_and_fixpoint`
pub fn local_expanded_module_items<'db>(
    db: &'db dyn Db,

}

See more source ↗

Implemented crates/sage-ir/src/parse/items.rs:687–692

sage_ir::parse::items · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.modules.expand.direct_members`
    pub(super) fn parse_mod(
        &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:30–35

sage_ir::parse · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.modules.expand.direct_members`
pub fn parse_str_to_cst<'db>(
    db: &'db dyn Db,
    source: ParseSource<'db>,
    text: &str,
    scope: ScopeSymbol<'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_expand_direct_members

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.modules.expand.direct_members)]
    fn modules_expand_direct_members() {
        // TODO: Complete the claim-specific verification matrix:
        // Fixtures cover ordinary items, `use` items, inline child modules, recursively generated items,
        // and derives, asserting direct membership, ordering, ownership, and generated provenance without
        // treating imported or child names as direct parent members.
    }
}

See more source ↗

Review: Accepted · Codex /root/macro_fix_expand_deps.

Reviewed the complete direct_members claim, all five implementation associations, and its complete test set (one explicit TODO). Requirements are: expansion results contain direct module members rather than the visible-name environment; source/generated ordering is deterministic; provenance is retained; children stay owned by child modules; imports and namespaces are interpreted later.

Parser::parse_str_to_cst supplies a source identity and scope to parse_item_list, which visits syntax children in order and creates one direct item per supported declaration. parse_mod constructs a child module with the parent scope, parses inline children with ScopeSymbol::Module(child), stores those via unexpanded_items::specify, and returns only the child module to the parent. File-backed modules likewise return the module identity without flattening its contents. parse_use stores a LocalUseSym and syntax import edges rather than imported target symbols. Other declaration constructors retain self.scope and the originating AbsoluteSpan; associated members remain nested CST under their owning trait/impl.

local_expanded_module_items traverses unexpanded items in vector order. expand_unexpanded_items_at_depth expands bang invocations recursively at their position; ordinary declarations including Use and Mod are appended, not traversed as visible-name environments. Derive expansion appends generated sibling items immediately after its input item, preserving attribute/list order. Error/unrepresented expansion handling is explicit and handled by completeness contracts; it does not flatten child or imported names. The recent symbol_local_item visibility change and generated-binding audit do not alter this traversal or ordering.

LocalMacroInvocationSym::parse_output creates ParseSource::BangMacro(selected definition, invocation), parses output in the invocation scope, and retains that provenance on generated items. DeriveExpansion::parse_output similarly supplies ParseSource::Derive with source item and occurrence identity and the source item's enclosing scope. Captured ParseSource/AbsoluteSpan, parser utility, and LocalModItemSym helpers show that generated and source identities survive span construction and symbol conversion. Captured resolver context confirms use edges, globs, and namespace filtering are interpreted during lookup rather than copied into expansion results; current ambiguity validation remains separate from module membership construction.

The associated todo::modules_expand_direct_members test has no assertions and is not behavioral evidence. Its comment explicitly defers a fixture matrix for ordinary/use/child/generated/derive items with direct membership, ordering, ownership, and provenance assertions. This is an adequate visible deferral: meaningful completion requires tests inspecting module vectors and origin/ownership identities, not merely accepting a fixture or observing one resolved name. No N/A evidence or executable associated tests are present. Source inspection supports the architectural contract for represented expansion; the TODO remains necessary for claim-specific executable verification. This reviewer ran review start/read commands, inspected captured source, and made no production edits or behavioral test runs. No requested edits for the changed inputs.

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