refactor(stdlib/S1.2): delete module_fns; dissolve legacy_direct_any [additive]

Delete module_fns as a separate function-author fact source. Its authors
already live in the module_decls raw facts, so lowerRetainedSameNameAuthors now
reads function authors straight out of module_decls (filtered to *FnDecl via
fnDeclOfRaw) — the same path → name → RawDeclRef store, fn-filtered. Remove
imports.ModuleFns / FnIndex / indexModuleFns / buildModuleFns / fnDeclOf, the
Compilation.module_fns field + its build + wiring, and ProgramIndex.module_fns.

Remove VisibilityMode.legacy_direct_any (the quarantined own-scope-plus-full-
import_graph mode): no production caller passed it, so the collectVisibleAuthors
and isVisible switch arms that handled it are dead and go too, collapsing
VisEdgeSet to the single flat-import walk. No semantic fallback is introduced;
import_graph stays the transitive-visibility source for findVisibleImpls.

Additive: the old maps stay active and lowering still consumes them — no
lowering consumer is cut over to the DeclTable (that is S3), and no resolution
behavior changes. Tests that drove the removed symbols are rerouted through
module_decls / the flat-edge walk.

Gate over the baseline-green corpus: zig build, zig build test (424/424),
bash tests/run_examples.sh (540 passed) — all exit 0; single-author output
byte-identical; multi-author 0722–0740 stdout/exit unchanged.
This commit is contained in:
agra
2026-06-09 11:36:04 +03:00
parent 8058be2538
commit cd7510067f
8 changed files with 98 additions and 180 deletions

View File

@@ -3,8 +3,7 @@
//! A read-only facade over the borrowed Phase A import facts on a
//! `*ProgramIndex` (`module_decls` / `namespace_edges`) and the existing
//! `import_graph` / `flat_import_graph` views. It OWNS nothing import-derived;
//! those maps live in `imports.zig`/`core.zig` and are borrowed here, exactly
//! like `module_fns`.
//! those maps live in `imports.zig`/`core.zig` and are borrowed here.
//!
//! Two collectors sit on top of these facts (R5 §1 #1):
//! - `collectVisibleAuthors` — own author the flat-import edge walk. THE one
@@ -69,10 +68,6 @@ pub const VisibilityMode = enum {
/// Registration / lazy lowering: falls open (visible), emits no user
/// diagnostic, performs no graph walk.
lowering_internal,
/// own scope `import_graph` (flat AND namespaced edges) — an
/// over-permissive set. QUARANTINE: reserved for sites PROVEN to be internal
/// scans, never a user-facing lookup. Deleted in Phase K.
legacy_direct_any,
};
/// Read-only facade over the borrowed import facts. `alloc` backs the
@@ -91,10 +86,10 @@ pub const Resolver = struct {
/// this. `from` is the querying module's source path.
///
/// Edge set by mode: `flat_import_graph` for `user_bare_flat`/
/// `c_import_bare`; `import_graph` for the quarantined `legacy_direct_any`.
/// `impl_transitive` (a transitive closure owned by `findVisibleImpls`) and
/// `lowering_internal` (no graph walk) are not single-hop author walks —
/// reaching them here is a wiring bug, so we trip loudly.
/// `c_import_bare`. `impl_transitive` (a transitive closure owned by
/// `findVisibleImpls`) and `lowering_internal` (no graph walk) are not
/// single-hop author walks — reaching them here is a wiring bug, so we trip
/// loudly.
pub fn collectVisibleAuthors(
self: *Resolver,
name: []const u8,
@@ -111,7 +106,6 @@ pub const Resolver = struct {
const graph = (switch (vis) {
.user_bare_flat, .c_import_bare => self.index.flat_import_graph,
.legacy_direct_any => self.index.import_graph,
// findVisibleImpls owns transitive visibility; lowering_internal
// performs no graph walk. Neither selects a single-hop edge set.
.impl_transitive, .lowering_internal => @panic(