Documentation

Docs / Reference

ADR 0036 — Angular routes

Status: Accepted (delegated review, 2026-11-01)

Context

ADR 0035 caches Angular router syntax (registration calls, bootstrapModule calls, loader forms and previously uncached arrays) without proof. T014d2 turns that payload, the declaration constants, the captured class decorators and the ADR 0031 module scopes into routing facts. The Router reads every ROUTES multi provider of the root environment injector, flattened (router.ts, v21.2.12 and 15.2.3): provideRouter in application providers and forRoot/forChild providers of every NgModule in the bootstrapped module's transitive import closure. A lazy NgModule's own injector (self: true) holds the ROUTES of that module and the modules it imports transitively. validateNode (dev mode) rejects malformed routes with truthiness tests. Both Angular corpora's 28 route objects are covered by existing caches (the T014d2 investigation, B0a).

Options considered

Decision

internal/extract/angular emits, on every relink:

Proof: provideRouter and RouterModule must resolve through the ADR 0014 resolver to the external @angular/router exports, not ambiguous, not type-only and not locally shadowed. A bootstrap needs a proven platformBrowserDynamic()/platformBrowser() receiver and a first argument that resolves to an active local ng_module. forRoot/forChild calls are registrations of the NgModules whose imports flatten to that exact call (transient module/file/span tuples captured during ADR 0031 flattening, never cached). provideRouter inside a captured decorator of an active NgModule registers for that module; in any other class decorator it is unproven. Otherwise (Revision 1) a production provideRouter is a root only when proven inside the providers of the options of a proven bootstrapApplication / createApplication call (@angular/platform-browser): an object literal, or an identifier or member chain (for example ns.cfg) resolving to an unmutated module const object, whose own providers value is read through array literals, nested arrays and proven unmutated const arrays; call sites match by file and full span. Every other production provideRouter is unproven. Test files keep the location rule (A1). Roots and bootstrap closures compose from "", lazy NgModules from the loading route's paths; closures follow local NgModule import and export leaves. Every other proven registration emits its nodes with empty paths and one info diagnostic. Paths of chains that touch a test file carry scope test (ADR 0021). Qualified names are ROUTE <raw path literal> segments under the nearest emitted lexical owner, nested under literal parents, with @N repeats; they never depend on evaluation.

Reviewer decisions recorded with this ADR (the investigation design notes):

  1. R6 follows the verified truthiness semantics of validateNode exactly (path && matcher, redirectTo && children, ...; === void 0 only where Angular uses it). path: '' with a matcher and redirectTo: '' with children are therefore valid.
  2. outlet: '' and outlet: 'primary' are both the primary outlet.
  3. requireStandaloneComponents checks only component (recursing into literal children of a lazily loaded array); loadComponent targets always require a standalone component.
  4. component: linked when the resolved class has role component (standalone checked only under requireStandaloneComponents); invalid with a warning and no edge for a class with another proven role or no decorator at all (ADR 0031 leaf precedent); unresolved otherwise, including decorated classes whose role is unproven and conflict classes.
  5. A proven forRoot/forChild that no NgModule imports is not a registration; its routes are not emitted and no diagnostic is raised (no listed code fits: angular_route_root_unproven describes registrations that emit nodes).
  6. Guard, resolver and title targets link only an exact identity from target() (class or other kind), or the unique function/variable/constant/class node of a local File+Name; otherwise they are unresolved.
  7. Root provideRouter was decided by location only; replaced by Revision 1 (bootstrap-proven roots) for production files.

Revisions

Revision 1 (review 1). The reviewer's decisions on review 1 amend the T014d2 task (the committed task record is not edited):

Consequences

Contract v1 is unchanged: ui_route, routes_to and loads_children are new extensible kinds. Revision 1 changes the router payload to version 2 and the aggregate version to extractors-24 (every fact cache misses once); dependencies, schema and store interface are unchanged; existing nodes, edges, attributes and diagnostics are untouched. Graph records of files that import or load a changed routes file are relinked without reparsing them. The new fixture angular-routes has a routing-projection golden, independent assertions and shared backend round-trip coverage (Postgres runs only in CI). In the self-index the new records are those of the new testdata/fixtures/angular-routes fixture (test scope there, so the location rule applies) plus the C7 records of testdata/fixtures/angular-router-syntax/calls.ts (Revision 1 changes only their message columns); counts are in the T014d2 summary.

Known gaps

Review notes (delegated review, 2026-11-01)

Report a problem with this pageSource: docs/adr/0036-angular-routes.md