Skip to content

Phase 1 / Etch / Cross-file import (resolver pass-1)#35

Merged
guysenpai merged 13 commits into
mainfrom
phase-1/etch/cross-file-import
Jun 29, 2026
Merged

Phase 1 / Etch / Cross-file import (resolver pass-1)#35
guysenpai merged 13 commits into
mainfrom
phase-1/etch/cross-file-import

Conversation

@guysenpai

Copy link
Copy Markdown
Contributor

M1.0.7 — Cross-file import (resolver pass-1)

Brief : briefs/M1.0.7-cross-file-import.md (Status: CLOSED).

Implements cross-file import in Etch end-to-end: graduates import parser-up (lexer → AST → parser), builds the module dependency graph + topological order + cycle detection (E0108), a per-module byte-keyed exports index + import binding (E0103/E0104/E0107), and cross-arena component resolution that unblocks the E1793 false positive for .prefab.etch.

Execution (E1→E6, one commit per slice)

  • E1 feat(etch): graduate import to kw_import tokenkw_import out of non_s3_keywords.
  • E2 feat(etch): add ImportDecl AST node + arena slabsImportDecl/ImportItem + slabs + addImportDecl.
  • E3 feat(etch): parse import directive, 4 forms + recoveryparseImportDecl/parseImportItem, dispatch, sync-set.
  • E4 feat(etch): import module graph, topo order + E0108 cyclederiveModulePath, graph, iterative DFS.
  • E5 feat(etch): per-module exports index + import bindingProjectContext exports, bindImports (E0103/E0104/E0107).
  • E6 feat(etch): cross-file import resolution + E1793 unblock — imported TYPE_IDENT resolution + checkComponentInstance cross-arena.
  • Docs: docs(claude-md): update for M1.0.7, docs: reframe foreign-field-type note as moot (not debt), docs(brief): close M1.0.7.

Closing notes

  • What worked: import was the last reserved top-level keyword in non_s3_keywords; the table-driven lexer made E1 trivial. The M0.9 byte-keyed ProjectContext extended naturally to a per-module exports index; keying cross-file resolution on string BYTES (not per-arena StringIds) is the load-bearing idea and held end-to-end. The iterative DFS gives both the deps-first topological order and the E0108 back-edge in one pass. The cross-arena check localized to checkComponentInstance + one checkInstanceFieldForeign helper (every other validate pass already skips unknown item kinds; pass1Collect ends else => {}).
  • What deviated from the original spec: one accepted deviation (Claude.ai round-trip, GO E5→E6) — test "selective import resolves a cross-file const" dropped (const is M1.0.8, not parseable here); cross-file resolution proven by the imported-component type test + the prefab unblock. FROZEN Acceptance edit logged under Accepted deviations (commit 6d4f344).
  • What to flag explicitly in review: (1) cross-arena field-TYPE check (E1795) is complete for components — validateFieldsInDecl(.component_like) admits only builtin-POD field types, so the named-type branch is unreachable (forward-compat headroom, not a gap). (2) deriveModulePath strips optional src/ + .etch/typed-compound ext, /.; handles bare fixture names and real src/ paths. (3) D-F (m.Type) and D-G (E0107) are wired-but-dormant, recorded so M1.0.8+ is additive.
  • Final measures: no new benchmark (graph + topo + exports are O(files+imports+exports), off any hot path). validateProject cost did not move materially vs M1.0.6.
  • Residual risk / tech debt left deliberately: none for the cross-arena field-type point (moot). Deferred-by-design (not debt): module-alias qualified m.Type (D-F), E0107 activation (D-G, M1.0.8), cross-file const import + test (M1.0.8).

Validation (Étape 4)

  • All Scope deliverables (E1–E6) present
  • No out-of-scope drift (import is the only graduated keyword; const/private/test/override untouched)
  • Acceptance tests green in Debug and ReleaseSafe (import_parse_test, import_resolve_test, crossfile_prefab_import_test)
  • Observable behaviour demonstrable (two-file project validates with zero diagnostics; .prefab.etch importing its components validates clean — asserted by the tests)
  • zig build, zig build test, zig fmt --check, zig build lint green
  • Closing notes filled; Status: CLOSED, close date set
  • commit-msg + pre-push hooks green on every commit

🤖 Generated with Claude Code

@guysenpai guysenpai merged commit 042195e into main Jun 29, 2026
10 checks passed
@guysenpai guysenpai deleted the phase-1/etch/cross-file-import branch June 29, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant