Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Package-prefixed symbol identity

Platform spec ADR

Package-prefixed symbol identity

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

ItemId(usize) is a dense, phase-local index into Resolution.items. It works for span tables and type maps inside one merged resolution, but cross-unit tooling (LSP workspace references, link-plan discovery, registry docs) needs a stable definition key that survives per-unit re-resolve and prefetch/entry merge.

Qualified names were previously recomputed post-hoc in doc emission (qualified_names.rs) without a single authoritative registry. Duplicate export names could last-win silently in helper scans.

Introduce package-prefixed canonical symbol identity parallel to ItemId:

TypeRole
SymbolQualifier{ package, shape } — package is CompilePlan.project_name for the entry/host unit or the dependency project_name for prefetched units; builtins use fixed package beskid
SymbolShapeEncodes module items, members, methods, and builtins into one ::-separated string
SymbolIdInterned key into SymbolRegistry
Resolution.by_symbolMaps SymbolId → authoritative ItemId after collect

Hot paths keep ItemId. Type maps, scoped span tables, and LocalId stay unchanged. Symbol identity is authoritative for:

  • cross-unit definition identity (IDE references, link-plan callee discovery),
  • api.json symbolKey when the row is registry-backed,
  • @ref / type-ref lookup by full package-prefixed path.

Collection assigns ItemInfo.symbol for exportable rows; duplicate SymbolQualifier values must surface as structured resolve errors instead of silent last-wins in name scans.

Canonical lookup helpers live in resolve/symbol_lookup.rs (symbol_for_item, item_id_for_symbol, canonical_item_id, qualified_name).

ShapeExample key
Module exportcorelib::Std::Console::Capabilities::ShouldEmitAnsi
Membercorelib::Std::Console::Capabilities::colorDisabled
Methodcorelib::Capabilities::ShouldEmitAnsi (receiver string + method name)
Builtinbeskid::range

qualifiedName on api.json rows may retain legacy module-relative strings for display; symbolKey carries the registry string when present (D-TOOL-CLI-0003).

  • ModuleIndex prefetch clones one shared registry into entry and per-unit resolve paths.
  • IDE references_at_offset_workspace matches references by SymbolId when both sides have registry symbols, not raw ItemId equality across unit re-resolve.
  • Codegen FunctionDefIndex and link-plan visitation use by_symbol as the primary callee index; span scans are fallback only.
  • Tests and golden api.json fixtures gain symbolKey on exportable symbols when re-emitted with a current CLI.
  • compiler/crates/beskid_analysis/src/resolve/symbol.rs
  • compiler/crates/beskid_analysis/src/resolve/symbol_lookup.rs
  • compiler/crates/beskid_analysis/src/resolve/collect.rs
  • compiler/crates/beskid_analysis/src/projects/assembly/module_index.rs
  • compiler/crates/beskid_analysis/src/services/document.rs (symbol-aware references)
  • compiler/crates/beskid_codegen/src/linking/def_index.rs