0071. Package-qualified identity
- Status: Accepted
- Date: 2026-10-31
- Plan: M9.2 Step 2 (dependency loading and logical sources follow in Step 3)
- Review: Making Tenon plugin-first
Context
Packages can declare the same module and item paths as local files. Their identities must remain distinct through whole-program checking and C emission, without changing existing root-package names, ordering or output. Dependency source locations must also remain reproducible across checkout locations.
Decision
- Graph keys are
ModuleId { package: String, path: String }, in that field order. The root is deliberately unnamed (package = ""), independent of its manifest name; existing path-order topo ties are unchanged. Dependency paths are nonempty;import util { x }selectsutil.lib, whose entry islib.hn. - Dependency identity is its manifest
[package].name, validated as[a-z][a-z0-9_]*. Dependency keys must also be importable (not keywords). E0938 rejects a key different from the manifest name, so dependents cannot create multiple identities for one package under different keys. - Root internal item names stay
trimora.b.trim. Dependency names areutil::lib.trim; the unspellable::separates package identity from local module paths. Diagnostics render import providers asutil.lib. - Nongeneric dependency function names split
::before dotted paths and usehp<len><package><len><segment>..._<item>, e.g.hp4util3lib_trim. Lengths make segment boundaries injective, including digit-ending names. The prefix is disjoint fromhm,hn_,hiandht; their output stays byte-identical, including ID-bearing generic/interface and layout names. - When dependency loading lands, register logical source names
such as
[email protected]/str.hn, never checkout paths. Traps and emitted file tables then remain machine-independent. Dependency edits go through that package's own root;edit --rootrefuses dependency files. Directory walkers forrenameandfmtskip nested package roots and.harness; root module imports cannot cross a nested manifest (E0934: declare a dependency). Package versions belong in source names, not mangling, under the one-version-per-name policy.
Alternatives considered
- Dotted package prefixes collide with local paths such as
util.lib.trim, including collisions introduced only by transitive dependencies. - Absolute paths as identities or source names make C output and traps depend on checkout location and expose dependency storage details to source tools.
- Renaming all root items would churn existing goldens and digests without improving dependency isolation.
Consequences
Existing name-keyed phases remain usable and this refactor has no user-visible change. The loader still creates only root-package modules in Step 2. Step 3 must resolve imports per package and restrict suggestions to accessible providers; the current missing-name scan stays within the importer's package.