Documentation

Docs / Reference

ADR 0032 — Angular requested-token injection facts

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

Context

T014c2 requires requested-token facts independently of the HttpClient receiver proof in ADR 0022. Constructor dependencies include plain parameters; types without runtime values must never become edges. Provider changes must relink unchanged sources. The investigation census and results are in the T014c2 task record (internal).

Options considered

Decision

Add a versioned injections payload beside declarations, invalidate aggregate cache entries with extractors-22, and require complete payload arrays on replay. Keep constructor implementation presence, extends, original parameter type grammar, direct decorator syntax, type-only bindings, single module const new initializers and own injection contexts. Preserve binding-pattern parameter names separately: the historical receiver scopes also traverse default expressions, which can introduce false parameter shadows. A private proof view removes those false shadows only for the new consumer. Existing facts are never mutated, and the original client resolver keeps its prior behavior.

At link time, eligible Angular classes receive partitioned leaf counts. Emit fact injects edges at confidence 1 to scanned class declarations or existing package external nodes, merging evidence without merging leaf counts. Function owners receive edges only for their own non-nested calls outside class bodies. Ignore static fields, methods, anonymous callbacks and nested functions.

Parameter decorators follow direct @angular/core specifier proof. Runtime inject and forwardRef follow the unchanged shared resolver, including barrels. Capture runtime sites only for named imports whose imported name is inject (including aliases), or namespace.inject, from any specifier. Retain only the callee and first argument, without duplicate whole-call syntax or options. Retain parameter scope corrections only for ancestors of captured sites or recorded classes. Type-only imports, unavailable type syntax and non-class targets remain unresolved. InjectionToken constants and Attribute/HostAttributeToken requests have counts without speculative targets.

Expose ADR 0022's existing production override lookup with provider evidence; supplement eligible Injectable own useClass/useFactory/useValue/useExisting keys. Keep requested-token edges even when overridden. Diagnose each source/token once, while counting each overridden leaf. Reuse ADR 0021 test classification.

C1 requires a single Injectable argument to be an object literal itself. Wrapped or referenced objects make metadata invalid, including combined decorators.

Consequences

Contract v1, identities, dependencies, storage interfaces/schema, source node hashes and all existing client/wrapper behavior remain unchanged. Configuration, package and provider edits relink on cached replay. Cache size increases for the additional syntax; timings and store sizes are recorded in the task summary. SQLite and Postgres round-trip tests include the new fixture.

Revision 1 uses injection payload version 2, keeping aggregate extractors-22. The Angular Link API receives the injection syntax map as an ordinary parameter. Checkpoint and truncated payloads miss. Field initializers resolve in the class decorator's enclosing lexical scope. Source-only shadow names cover declarations between sites and their resolution scope, including blocks, loop headers and catch clauses. Retain only names used by the callee or token. A shadowed callee creates no leaf; a shadowed token is unresolved with reason locally shadowed. The field-initializer case with an enclosing local class is conservative and unresolved as required by Revision 1, rather than linking a nested class. Nested arrows never acquire their enclosing emitted owner's injection edge.

Known gaps

No provider selection, injector hierarchy execution or inherited dependency expansion. Edges describe requested tokens rather than the eventual provider. External declarations have no scanned class inventory. Unsupported token expressions remain explicit unresolved diagnostics. Existing ADR 0022's indirect Inject behavior is intentionally unchanged pending a separate correction.

Renaming inject through a scanned barrel (export {inject as acquire}, then importing acquire) is not captured. Importing an export named inject under a local alias still qualifies. Type names resolve through value bindings, so a local interface shadowing an imported class name is not detected; Angular rejects such source. Historical ADR 0022 receiver scopes still treat identifiers in parameter default expressions as parameter bindings; only the injection proof uses the separate corrected binding patterns.

Review notes (developer, 2026-10-26)

Report a problem with this pageSource: docs/adr/0032-angular-injects.md