Amended by 0265: Gen also writes
.stackra/gen/hooks.ts, which lists every hook point with its implementers in order and their
file paths (decision 1 lists the outputs, and hooks.ts is one of them).Context
stackra gen builds one discovery IR of every module, route, setting, permission and client in the graph. The IR must reach the code
that uses it. Virtual modules (files that exist only inside a bundler) work in Vite, but Metro, Node, the test runner and agents cannot
read them, so each reader would need its own shim. Real files work in every reader. The owner decided on 2026-10-21 that gen writes real
files and the bundler only serves them.
Decision
- One IR, real files.
stackra genwrites typed TypeScript files to.stackra/gen/:routes,navigation,i18n,resources,assets,clients,services,permissions,settings,capabilitiesandwiring. - One alias. Code imports them only as
#stackra/<name>. The member declares the alias in theimportsmap of itspackage.json(0233), for example"#stackra/*": "./.stackra/gen/*.ts". - Every reader uses the real files. Metro, Node, tests and agents read
.stackra/gen/directly. - Vite serves the same modules. In a Vite app,
@stackra/vite-plugin(developer category, 0127) serves the same modules as virtual modules with hot module replacement. The plugin adds no export of its own. - Fresh files.
pnpm gen --watchregenerates the files as sources change. The files are gitignored under.stackra/*, as.stackra/encoreis (0091). The committed artefacts of 0158 are unchanged. - Generated, never edited. Each file opens with a contract block (0007) saying it is generated. A hand edit is overwritten on the next run.
Consequences
- A developer and an agent read the same file that the code runs against, so a finding about a route or a permission can be checked by reading one file.
- The Vite plugin is a thin view. A divergence between the plugin and the file is a bug in the plugin.
- Each consumer must run
stackra genbefore it builds or tests. The Turborepo task graph carries that dependency.
Enforcement
planned —stackra gen --check fails when .stackra/gen/ is stale. Planned: pnpm validate fails a #stackra/* import that names a file gen does not write.
Planned: the conformance test of 0144 checks that the Vite virtual module exports the same names as the real file.
Supersedes and sources
Supersedes: none. Relates to the ADRs listed above. Sources: owner decision in chat, 2026-10-21 (generated modules), and DX10 of the 2026-10-20 DX round (@stackra/vite-plugin).