Documentation

Docs / Reference

ADR 0031 — Angular declaration metadata and scopes

Status: Accepted (developer review, 2026-10-25) Date: 2026-10-25

Context

ADR 0030 records syntax without Angular proof. T014c1 needs class roles, template resources and NgModule scopes rebuilt after configuration/import edits. Existing HTTP client facts and identities must survive. The ten-checkout inventory is in the T014c1 task records (internal); a private corpus contributes aggregates only.

Options considered

Decision

Add internal/extract/angular. Direct non-type-only imports whose specifier is exactly @angular/core need ADR 0014 external-package proof. Aliases and namespaces qualify. Barrels are indirect; scanned core packages block roles. Conflicting primary decorators yield only null role and conflict markers.

Add a versioned declarations payload beside template_syntax: original metadata wrapper kinds, ordered array elements/spans, function returns, module const arrays and mutation receivers. Existing fields keep their meanings. Capture a mutation receiver only when its root identifier, followed through member/subscript access, is unshadowed and names an import binding or a module-level single-declarator const in that file. Other receivers cannot affect the const arrays or namespaces used by declaration evaluation. Require complete payload arrays on replay; invalidate with extractors-21. Contract v1, dependencies, identities, store interfaces and schemas are unchanged.

Expose only existing ADR 0020 evaluation and ignore-provenance lookups to the new package. Read project/package/lock inputs at link time through the existing JSONC parser. Use ADR 0022's deepest sourceRoot/root ownership rule and the owning angular.json's nearest declaring package. Unowned files start at their directory. Matching core/compiler-cli majors determine the implicit standalone value at Angular 19. Disagreeing co-located lock versions are unknown. Only an absent standalone key uses that default. An explicit unknown or wrong-type value stays null with source unknown, without a version lookup or version diagnostic. The optional sorted unknown_keys array names present selector, exportAs, standalone, name, pure and templateUrl keys whose evaluated values are unknown or have the wrong type; scalar diagnostics are unchanged.

Apply class attributes as snapshot overlays after source facts are cached. New edges reuse class, file and package-level external identities. Resolve imports/barrels, const arrays, forwardRef and external ModuleWithProviders; reject mutations/cycles and preserve contributing source spans. Scope counts partition flattened leaves into local linked, external, unresolved and invalid. Edge deduplication does not reduce entry counts. Invalid scope entries require a proven class declaration with a rejected role or standalone value. Conflicted classes and non-class identities are unresolved; the latter report "target is not a class declaration", including aliases and unproven const arrays. A directive with an unknown selector is unresolved as a declaration target; only an absent or empty selector proves it selectorless.

Suppress duplicate declarations among distinct modules only within the same ADR 0021 production/test scope. Traversal behavior is unchanged. Host capture panics are diagnosed every failing run, preserving graph facts and forcing retry.

Consequences

Metadata and template edits relink unchanged TypeScript. Uncertain metadata remains visible without guessed facts. Declaration and scanned-core-shadow fixtures have goldens and independent assertions; the storage round-trip case is registered for both SQLite and Postgres.

Known gaps

Template matching, transitive exports, DI edges, router facts, providers, bootstrap, schemas and host directives remain deferred. Non-call decorators remain outside ADR 0030 capture. Arbitrary expressions, local ModuleWithProviders and unsupported function bodies remain unresolved. Existing code has no yarn or pnpm lock parser, so neither is added.

Review notes (developer, 2026-10-25)

Review notes (developer, verification, 2026-10-25)

Checked against v21.2.12 reflection/typescript.ts, transform/compilation.ts and annotations/src/injectable.ts, plus the 15.2.3 diffs.

Review notes (developer, verification, 2026-10-26)

Checked against v21.2.12 compiler-cli resource/src/loader.ts and its 15.2.3 diff (resolution logic unchanged).

Report a problem with this pageSource: docs/adr/0031-angular-declarations.md