@nifrajs/cli 5.0.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/CHANGELOG.md +3211 -0
  2. package/README.md +10 -2
  3. package/dist/agent-files.d.ts +19 -11
  4. package/dist/agent-files.d.ts.map +1 -1
  5. package/dist/agent-files.js +26 -18
  6. package/dist/agent-files.js.map +1 -1
  7. package/dist/assure-hydration.d.ts.map +1 -1
  8. package/dist/assure-hydration.js +5 -2
  9. package/dist/assure-hydration.js.map +1 -1
  10. package/dist/assure.d.ts +12 -2
  11. package/dist/assure.d.ts.map +1 -1
  12. package/dist/assure.js +73 -9
  13. package/dist/assure.js.map +1 -1
  14. package/dist/capabilities-tool.d.ts.map +1 -1
  15. package/dist/capabilities-tool.js +152 -49
  16. package/dist/capabilities-tool.js.map +1 -1
  17. package/dist/check-diagnostics.d.ts +7 -0
  18. package/dist/check-diagnostics.d.ts.map +1 -1
  19. package/dist/check-diagnostics.js +3 -0
  20. package/dist/check-diagnostics.js.map +1 -1
  21. package/dist/check-scan.d.ts +8 -2
  22. package/dist/check-scan.d.ts.map +1 -1
  23. package/dist/check-scan.js +49 -13
  24. package/dist/check-scan.js.map +1 -1
  25. package/dist/check.d.ts.map +1 -1
  26. package/dist/check.js +91 -45
  27. package/dist/check.js.map +1 -1
  28. package/dist/cli.d.ts +2 -0
  29. package/dist/cli.d.ts.map +1 -1
  30. package/dist/cli.js +128 -59
  31. package/dist/cli.js.map +1 -1
  32. package/dist/client-module.d.ts +5 -3
  33. package/dist/client-module.d.ts.map +1 -1
  34. package/dist/client-module.js +34 -10
  35. package/dist/client-module.js.map +1 -1
  36. package/dist/command-catalog.d.ts +9 -1
  37. package/dist/command-catalog.d.ts.map +1 -1
  38. package/dist/command-catalog.js +75 -26
  39. package/dist/command-catalog.js.map +1 -1
  40. package/dist/dev-bun-config.d.ts +6 -3
  41. package/dist/dev-bun-config.d.ts.map +1 -1
  42. package/dist/dev-bun-config.js +13 -10
  43. package/dist/dev-bun-config.js.map +1 -1
  44. package/dist/dev-feed-tool.d.ts +19 -1
  45. package/dist/dev-feed-tool.d.ts.map +1 -1
  46. package/dist/dev-feed-tool.js +114 -0
  47. package/dist/dev-feed-tool.js.map +1 -1
  48. package/dist/doctor.d.ts +15 -1
  49. package/dist/doctor.d.ts.map +1 -1
  50. package/dist/doctor.js +79 -61
  51. package/dist/doctor.js.map +1 -1
  52. package/dist/fix-recipes.d.ts +2 -0
  53. package/dist/fix-recipes.d.ts.map +1 -1
  54. package/dist/fix-recipes.js +93 -12
  55. package/dist/fix-recipes.js.map +1 -1
  56. package/dist/i18n-check.d.ts +11 -1
  57. package/dist/i18n-check.d.ts.map +1 -1
  58. package/dist/i18n-check.js +170 -17
  59. package/dist/i18n-check.js.map +1 -1
  60. package/dist/init-agents.d.ts +60 -4
  61. package/dist/init-agents.d.ts.map +1 -1
  62. package/dist/init-agents.js +196 -33
  63. package/dist/init-agents.js.map +1 -1
  64. package/dist/internal/config-paths.d.ts +16 -0
  65. package/dist/internal/config-paths.d.ts.map +1 -0
  66. package/dist/internal/config-paths.js +124 -0
  67. package/dist/internal/config-paths.js.map +1 -0
  68. package/dist/internal/installed-package.d.ts +4 -0
  69. package/dist/internal/installed-package.d.ts.map +1 -0
  70. package/dist/internal/installed-package.js +17 -0
  71. package/dist/internal/installed-package.js.map +1 -0
  72. package/dist/internal/project-specifiers.d.ts +14 -1
  73. package/dist/internal/project-specifiers.d.ts.map +1 -1
  74. package/dist/internal/project-specifiers.js +63 -16
  75. package/dist/internal/project-specifiers.js.map +1 -1
  76. package/dist/internal/source-facts.d.ts +12 -1
  77. package/dist/internal/source-facts.d.ts.map +1 -1
  78. package/dist/internal/source-facts.js +117 -5
  79. package/dist/internal/source-facts.js.map +1 -1
  80. package/dist/internal/typescript-import.d.ts.map +1 -1
  81. package/dist/internal/typescript-import.js +5 -3
  82. package/dist/internal/typescript-import.js.map +1 -1
  83. package/dist/internal/workspace-packages.d.ts +22 -0
  84. package/dist/internal/workspace-packages.d.ts.map +1 -0
  85. package/dist/internal/workspace-packages.js +215 -0
  86. package/dist/internal/workspace-packages.js.map +1 -0
  87. package/dist/introspect.d.ts +9 -0
  88. package/dist/introspect.d.ts.map +1 -1
  89. package/dist/introspect.js +32 -1
  90. package/dist/introspect.js.map +1 -1
  91. package/dist/levels-tool.d.ts.map +1 -1
  92. package/dist/levels-tool.js +5 -8
  93. package/dist/levels-tool.js.map +1 -1
  94. package/dist/load.d.ts +9 -4
  95. package/dist/load.d.ts.map +1 -1
  96. package/dist/load.js +32 -3
  97. package/dist/load.js.map +1 -1
  98. package/dist/lock-links.d.ts +42 -0
  99. package/dist/lock-links.d.ts.map +1 -0
  100. package/dist/lock-links.js +144 -0
  101. package/dist/lock-links.js.map +1 -0
  102. package/dist/mcp-context.d.ts.map +1 -1
  103. package/dist/mcp-context.js +6 -21
  104. package/dist/mcp-context.js.map +1 -1
  105. package/dist/mcp-delegate.d.ts +2 -2
  106. package/dist/mcp-delegate.d.ts.map +1 -1
  107. package/dist/mcp-delegate.js +19 -7
  108. package/dist/mcp-delegate.js.map +1 -1
  109. package/dist/mcp-exec.d.ts +1 -0
  110. package/dist/mcp-exec.d.ts.map +1 -1
  111. package/dist/mcp-exec.js +13 -5
  112. package/dist/mcp-exec.js.map +1 -1
  113. package/dist/mcp-http.js +1 -1
  114. package/dist/mcp-io.d.ts +13 -0
  115. package/dist/mcp-io.d.ts.map +1 -1
  116. package/dist/mcp-io.js +23 -0
  117. package/dist/mcp-io.js.map +1 -1
  118. package/dist/mcp-path.d.ts +2 -1
  119. package/dist/mcp-path.d.ts.map +1 -1
  120. package/dist/mcp-path.js +9 -24
  121. package/dist/mcp-path.js.map +1 -1
  122. package/dist/mcp-root.d.ts +6 -4
  123. package/dist/mcp-root.d.ts.map +1 -1
  124. package/dist/mcp-root.js +12 -8
  125. package/dist/mcp-root.js.map +1 -1
  126. package/dist/mcp.d.ts.map +1 -1
  127. package/dist/mcp.js +40 -17
  128. package/dist/mcp.js.map +1 -1
  129. package/dist/migrate-layout.d.ts +41 -1
  130. package/dist/migrate-layout.d.ts.map +1 -1
  131. package/dist/migrate-layout.js +1729 -236
  132. package/dist/migrate-layout.js.map +1 -1
  133. package/dist/output-schemas.d.ts +34 -0
  134. package/dist/output-schemas.d.ts.map +1 -1
  135. package/dist/output-schemas.js +132 -21
  136. package/dist/output-schemas.js.map +1 -1
  137. package/dist/project-path.d.ts +6 -0
  138. package/dist/project-path.d.ts.map +1 -1
  139. package/dist/project-path.js +48 -14
  140. package/dist/project-path.js.map +1 -1
  141. package/dist/project-site.d.ts +7 -0
  142. package/dist/project-site.d.ts.map +1 -0
  143. package/dist/project-site.js +19 -0
  144. package/dist/project-site.js.map +1 -0
  145. package/dist/recipes/4.0.0.d.ts.map +1 -1
  146. package/dist/recipes/4.0.0.js +2 -0
  147. package/dist/recipes/4.0.0.js.map +1 -1
  148. package/dist/recipes/5.1.0.d.ts +9 -0
  149. package/dist/recipes/5.1.0.d.ts.map +1 -0
  150. package/dist/recipes/5.1.0.js +22 -0
  151. package/dist/recipes/5.1.0.js.map +1 -0
  152. package/dist/recipes/5.2.0.d.ts +10 -0
  153. package/dist/recipes/5.2.0.d.ts.map +1 -0
  154. package/dist/recipes/5.2.0.js +32 -0
  155. package/dist/recipes/5.2.0.js.map +1 -0
  156. package/dist/recipes/index.d.ts +3 -0
  157. package/dist/recipes/index.d.ts.map +1 -1
  158. package/dist/recipes/index.js +7 -0
  159. package/dist/recipes/index.js.map +1 -1
  160. package/dist/release-verification.d.ts +5 -0
  161. package/dist/release-verification.d.ts.map +1 -1
  162. package/dist/release-verification.js +14 -0
  163. package/dist/release-verification.js.map +1 -1
  164. package/dist/review.d.ts.map +1 -1
  165. package/dist/review.js +7 -0
  166. package/dist/review.js.map +1 -1
  167. package/dist/rule-explain.d.ts +26 -0
  168. package/dist/rule-explain.d.ts.map +1 -0
  169. package/dist/rule-explain.js +49 -0
  170. package/dist/rule-explain.js.map +1 -0
  171. package/dist/rules/codes.d.ts +5 -1
  172. package/dist/rules/codes.d.ts.map +1 -1
  173. package/dist/rules/codes.js +5 -1
  174. package/dist/rules/codes.js.map +1 -1
  175. package/dist/rules/contract-visibility.d.ts.map +1 -1
  176. package/dist/rules/contract-visibility.js +93 -21
  177. package/dist/rules/contract-visibility.js.map +1 -1
  178. package/dist/rules/data-guard.d.ts +6 -0
  179. package/dist/rules/data-guard.d.ts.map +1 -1
  180. package/dist/rules/data-guard.js +37 -0
  181. package/dist/rules/data-guard.js.map +1 -1
  182. package/dist/rules/explanations.d.ts +14 -0
  183. package/dist/rules/explanations.d.ts.map +1 -0
  184. package/dist/rules/explanations.js +316 -0
  185. package/dist/rules/explanations.js.map +1 -0
  186. package/dist/rules/legacy.d.ts.map +1 -1
  187. package/dist/rules/legacy.js +44 -2
  188. package/dist/rules/legacy.js.map +1 -1
  189. package/dist/rules/merge-auth.d.ts +12 -0
  190. package/dist/rules/merge-auth.d.ts.map +1 -0
  191. package/dist/rules/merge-auth.js +52 -0
  192. package/dist/rules/merge-auth.js.map +1 -0
  193. package/dist/rules/pages.d.ts +56 -3
  194. package/dist/rules/pages.d.ts.map +1 -1
  195. package/dist/rules/pages.js +412 -23
  196. package/dist/rules/pages.js.map +1 -1
  197. package/dist/rules/routes.d.ts +3 -2
  198. package/dist/rules/routes.d.ts.map +1 -1
  199. package/dist/rules/routes.js +4 -3
  200. package/dist/rules/routes.js.map +1 -1
  201. package/dist/rules/security.d.ts +3 -2
  202. package/dist/rules/security.d.ts.map +1 -1
  203. package/dist/rules/security.js +42 -11
  204. package/dist/rules/security.js.map +1 -1
  205. package/dist/rules/zones.d.ts.map +1 -1
  206. package/dist/rules/zones.js +34 -11
  207. package/dist/rules/zones.js.map +1 -1
  208. package/dist/stylex-migrate.d.ts.map +1 -1
  209. package/dist/stylex-migrate.js +127 -17
  210. package/dist/stylex-migrate.js.map +1 -1
  211. package/dist/test-tool.d.ts.map +1 -1
  212. package/dist/test-tool.js +3 -9
  213. package/dist/test-tool.js.map +1 -1
  214. package/dist/typecheck-coverage.d.ts +11 -0
  215. package/dist/typecheck-coverage.d.ts.map +1 -1
  216. package/dist/typecheck-coverage.js +50 -7
  217. package/dist/typecheck-coverage.js.map +1 -1
  218. package/dist/upgrade.d.ts +57 -6
  219. package/dist/upgrade.d.ts.map +1 -1
  220. package/dist/upgrade.js +247 -19
  221. package/dist/upgrade.js.map +1 -1
  222. package/dist/verification-plan.d.ts.map +1 -1
  223. package/dist/verification-plan.js +7 -2
  224. package/dist/verification-plan.js.map +1 -1
  225. package/dist/version-drift.d.ts.map +1 -1
  226. package/dist/version-drift.js +66 -3
  227. package/dist/version-drift.js.map +1 -1
  228. package/dist/web-app-options.d.ts +1 -1
  229. package/dist/web-app-options.d.ts.map +1 -1
  230. package/dist/web-app-options.js.map +1 -1
  231. package/docs/examples.json +21 -3
  232. package/docs/llms-full.txt +1083 -168
  233. package/docs/types.json +535 -112
  234. package/package.json +13 -12
  235. package/src/agent-files.ts +27 -17
  236. package/src/assure-hydration.ts +5 -1
  237. package/src/assure.ts +99 -11
  238. package/src/capabilities-tool.ts +188 -53
  239. package/src/check-diagnostics.ts +10 -0
  240. package/src/check-scan.ts +65 -12
  241. package/src/check.ts +122 -51
  242. package/src/cli.ts +127 -45
  243. package/src/client-module.ts +45 -9
  244. package/src/command-catalog.ts +92 -28
  245. package/src/dev-bun-config.ts +13 -9
  246. package/src/dev-feed-tool.ts +146 -1
  247. package/src/doctor.ts +102 -66
  248. package/src/fix-recipes.ts +101 -10
  249. package/src/i18n-check.ts +254 -18
  250. package/src/init-agents.ts +225 -44
  251. package/src/internal/config-paths.ts +154 -0
  252. package/src/internal/installed-package.ts +15 -0
  253. package/src/internal/project-specifiers.ts +78 -17
  254. package/src/internal/source-facts.ts +147 -5
  255. package/src/internal/typescript-import.ts +5 -3
  256. package/src/internal/workspace-packages.ts +218 -0
  257. package/src/introspect.ts +39 -1
  258. package/src/levels-tool.ts +7 -9
  259. package/src/load.ts +46 -4
  260. package/src/lock-links.ts +173 -0
  261. package/src/mcp-context.ts +5 -18
  262. package/src/mcp-delegate.ts +22 -10
  263. package/src/mcp-exec.ts +14 -4
  264. package/src/mcp-http.ts +1 -1
  265. package/src/mcp-io.ts +33 -0
  266. package/src/mcp-path.ts +8 -22
  267. package/src/mcp-root.ts +14 -8
  268. package/src/mcp.ts +48 -19
  269. package/src/migrate-layout.ts +1968 -245
  270. package/src/output-schemas.ts +179 -23
  271. package/src/project-path.ts +44 -13
  272. package/src/project-site.ts +18 -0
  273. package/src/recipes/4.0.0.ts +2 -0
  274. package/src/recipes/5.1.0.ts +23 -0
  275. package/src/recipes/5.2.0.ts +33 -0
  276. package/src/recipes/index.ts +7 -0
  277. package/src/release-verification.ts +20 -0
  278. package/src/review.ts +7 -0
  279. package/src/rule-explain.ts +75 -0
  280. package/src/rules/codes.ts +5 -1
  281. package/src/rules/contract-visibility.ts +118 -20
  282. package/src/rules/data-guard.ts +40 -0
  283. package/src/rules/explanations.ts +329 -0
  284. package/src/rules/legacy.ts +46 -2
  285. package/src/rules/merge-auth.ts +55 -0
  286. package/src/rules/pages.ts +486 -25
  287. package/src/rules/routes.ts +4 -3
  288. package/src/rules/security.ts +49 -11
  289. package/src/rules/zones.ts +33 -9
  290. package/src/stylex-migrate.ts +117 -17
  291. package/src/test-tool.ts +3 -9
  292. package/src/typecheck-coverage.ts +51 -6
  293. package/src/upgrade.ts +312 -19
  294. package/src/verification-plan.ts +15 -2
  295. package/src/version-drift.ts +68 -2
  296. package/src/web-app-options.ts +9 -1
@@ -575,7 +575,7 @@ hydrates that, then renders the component with the data it already has. A client
575
575
  to the page renders the component directly. For a component that reads `window`,
576
576
  a canvas, or a browser-only library while it renders.
577
577
 
578
- ```ts
578
+ ```tsx
579
579
  // routes/map.tsx - a page whose component needs a browser to render.
580
580
  import type { Route } from "./+types/map"
581
581
 
@@ -611,12 +611,12 @@ combined with `hydrate = false`: nothing would ever render the page.
611
611
  Export a `searchSchema` - any Standard Schema (valibot, zod, arktype) - and the URL
612
612
  query becomes typed and validated on both sides: the loader receives it as
613
613
  `ctx.search` and the component reads the same value with
614
- `useSearch()`. Invalid or hostile input fails closed to the
614
+ `useSearch<typeof searchSchema>()`. Invalid or hostile input fails closed to the
615
615
  schema's defaults (never a 500), and the value is derived identically on the server and on each
616
616
  client navigation - so a query-reading page hydrates with no mismatch and never touches
617
617
  `window.location.search` by hand.
618
618
 
619
- ```ts
619
+ ```tsx
620
620
  // routes/reports.tsx - a typed, validated ?page=&sort= query.
621
621
  import { useSearch } from "@nifrajs/web-react/router"
622
622
  import * as v from "valibot" // any Standard Schema works (valibot, zod, arktype)
@@ -645,7 +645,7 @@ export async function loader({ search, api }: Route.LoaderArgs) {
645
645
  ```
646
646
 
647
647
  Without a `searchSchema`, `ctx.search` and `useSearch()` are
648
- the raw parsed query (`Record`). `useSearch` ships on
648
+ the raw parsed query (`Record<string, unknown>`). `useSearch` ships on
649
649
  every adapter (React, Preact, Vue, Solid, Svelte), each in that framework's shape - a value on
650
650
  React/Preact, a `Ref` on Vue, an accessor on Solid/Svelte. For imperative reads and
651
651
  writes of the raw query, `useSearchParams()` mirrors react-router's
@@ -679,7 +679,7 @@ around it (the nearest one wins), says when:
679
679
  -
680
680
  `none`: never; the route loads when the link is followed.
681
681
 
682
- ```ts
682
+ ```tsx
683
683
  // A docs sidebar: each link loads as it scrolls into view.
684
684
  <nav data-nifra-prefetch="viewport">
685
685
  <a href="/docs/routing">Routing</a>
@@ -712,7 +712,7 @@ query), `params` the ones it declares, and `data` its loader data (`null` withou
712
712
  can therefore build breadcrumbs, a title, or a section nav from what the routes below it
713
713
  export.
714
714
 
715
- ```ts
715
+ ```tsx
716
716
  // routes/orgs/[org]/_layout.tsx
717
717
  import type { ReactNode } from "react"
718
718
  import { useMatches } from "@nifrajs/web-react/router"
@@ -757,7 +757,7 @@ call `proceed()` to continue or `reset()` to stay. It mirrors
757
757
  react-router's shape - a plain boolean can't express an async "are you sure?", these two
758
758
  callbacks can.
759
759
 
760
- ```ts
760
+ ```tsx
761
761
  // routes/posts/[id]/edit.tsx - don't lose a half-finished edit to a stray click.
762
762
  import { useState } from "react"
763
763
  import { useBlocker } from "@nifrajs/web-react/router"
@@ -873,9 +873,9 @@ answers `422`.
873
873
  `GET /users/:id?` throws at registration, because both serve
874
874
  `GET /users`. Nothing of a rejected route is left registered.
875
875
 
876
- Other param modifiers (`:id+`, `:id*`, `:id(\\d+)`) are not
876
+ Other param modifiers (`:id+`, `:id*`, `:id(\d+)`) are not
877
877
  part of the path grammar and match as literal text. Where that text is intended, put
878
- `// nifra-expect NF-C026: ` above the registration.
878
+ `// nifra-expect NF-C026: <reason>` above the registration.
879
879
 
880
880
  ### Param constraints
881
881
 
@@ -902,10 +902,10 @@ A constraint is one of two things:
902
902
 
903
903
  -
904
904
  **One character class, with an optional count.** `[0-9]`,
905
- `[a-z0-9_-]`, `\\d` or `\\w`, followed by nothing
905
+ `[a-z0-9_-]`, `\d` or `\w`, followed by nothing
906
906
  (exactly one character), `+`, `{n}`, `{n,}` or
907
- `{n,m}`. A class holds letters, digits, ranges of them, `\\d`,
908
- `\\w` and the characters `. _ ~ ! $ & ' ( ) + , ; = @ -`. There
907
+ `{n,m}`. A class holds letters, digits, ranges of them, `\d`,
908
+ `\w` and the characters `. _ ~ ! $ & ' ( ) + , ; = @ -`. There
909
909
  is no negated class, and a count starts at one.
910
910
 
911
911
  -
@@ -916,7 +916,7 @@ is no negated class, and a count starts at one.
916
916
  Anything else in braces (`:id{int}`, `:id{[0-9]+|[a-z]+}`,
917
917
  `:id{.+}`) is not a constraint. It is literal text, as before, and
918
918
  `nifra check` reports it as `NF-C026`. In a JavaScript string
919
- `\\d` is written `{'"\\\\d"'}`.
919
+ `\d` is written `"\\d"`.
920
920
 
921
921
  -
922
922
  **The value is checked as it was sent,** before percent-decoding. `/users/4%32`
@@ -938,7 +938,7 @@ the same rule a literal route follows beside a param route.
938
938
 
939
939
  -
940
940
  **Two spellings of one constraint are one route.** `:id{[0-9]+}`,
941
- `:id{\\d+}` and `:id{[0-9]{1,}}` accept the same values, so
941
+ `:id{\d+}` and `:id{[0-9]{1,}}` accept the same values, so
942
942
  registering two of them for one method throws `DUPLICATE_ROUTE`, and different
943
943
  methods on them share one `Allow` list.
944
944
 
@@ -953,14 +953,14 @@ not look for another split.
953
953
  `/users/:id{[0-9]+}` serve no request in common, so `nifra check`
954
954
  (`NF-C024`) has nothing to report. A constrained route beside a bare
955
955
  `:param` route still overlaps and is still reported; mark the pair with
956
- `// nifra-expect NF-C024: ` where it is intended.
956
+ `// nifra-expect NF-C024: <reason>` where it is intended.
957
957
 
958
958
  -
959
959
  **OpenAPI and the typed client use the bare name.** The path is
960
960
  `/users/{id}`; the parameter's schema is
961
- `{'{ type: "string", pattern: "^[0-9]+$" }'}` for a class and an `enum`
961
+ `{ type: "string", pattern: "^[0-9]+$" }` for a class and an `enum`
962
962
  for a list, unless the route declares a `params` schema. The client call is
963
- `{'api.users({ id: "42" }).get()'}`. The client does not check the value: a value
963
+ `api.users({ id: "42" }).get()`. The client does not check the value: a value
964
964
  that does not fit is sent, and answered by whichever route it does match. Where two param
965
965
  routes share a position, give their params different names so that the call picks the route
966
966
  by name.
@@ -1052,8 +1052,11 @@ export const app = server()
1052
1052
 
1053
1053
  Prefer `c.set` over returning a raw `Response`. A `Response`
1054
1054
  return makes the typed client infer `data: never`, so you silently lose drift
1055
- detection for that route (`nifra check` flags it). `c.set` keeps your
1056
- plain-object return fully typed.
1055
+ detection for that route (`nifra check` flags it, NF-C007). `c.set`
1056
+ keeps your plain-object return fully typed. The check reads the functions a route
1057
+ registration or an `implement()` map passes, and a local function one returns a
1058
+ call to; a helper that answers an auth stage, or a handler registered from a list of route
1059
+ objects, is not read.
1057
1060
 
1058
1061
  A `Response` a handler or hook returns or throws still gets the
1059
1062
  `c.set.headers` it lacks and the queued cookies, so a guard's
@@ -1145,6 +1148,37 @@ A strict `t.object` here would reject real traffic. A signed cookie arrives as i
1145
1148
  `hasDuplicateCookie`. The OpenAPI document lists each declared field as an
1146
1149
  `in: cookie` parameter.
1147
1150
 
1151
+ ### Typed request headers (schema.headers)
1152
+
1153
+ A `headers` schema is validated before the handler like the other slots: a missing
1154
+ or malformed header is a `422` (`onValidationError` receives the kind
1155
+ `"headers"`), and `c.headers` becomes the schema&rsquo;s typed output.
1156
+ Every client sends headers no route declares - `host`, `user-agent`,
1157
+ `accept` - so a closed `t.object` validates only the names it declares,
1158
+ each read case-insensitively, which is also how the OpenAPI document lists them: one
1159
+ `in: header` parameter per declared name.
1160
+
1161
+ ```ts
1162
+ import { server } from "@nifrajs/core/server"
1163
+ import { t } from "@nifrajs/schema"
1164
+
1165
+ export const app = server()
1166
+ // Closed: validates only the names it declares, whatever else the client sends.
1167
+ .get("/reports", { headers: t.object({ "x-tenant": t.string() }) }, (c) => ({
1168
+ tenant: c.headers["x-tenant"], // string - a request without it is a 422
1169
+ }))
1170
+ // Open: every header arrives, names lower-cased, declared values coerced from text.
1171
+ .get("/jobs", { headers: t.headers({ "x-retry": t.optional(t.integer()) }) }, (c) => ({
1172
+ retry: c.headers["x-retry"] ?? 0, // number
1173
+ }))
1174
+ ```
1175
+
1176
+ `t.headers` is the open form: it receives every header with its name lower-cased,
1177
+ so it takes lower-case names only, and like `t.query` it coerces declared
1178
+ `t.integer()` / `t.number()` / `t.boolean()` fields from text.
1179
+ A schema nifra cannot read the names of - a Zod `.strict()` object or a Valibot
1180
+ `strictObject` - receives every header, so declare it open.
1181
+
1148
1182
  ### Requests no route matched (notFound)
1149
1183
 
1150
1184
  A path no route matches is answered `404` with
@@ -1271,12 +1305,12 @@ await api.files("report.json").get() // /files/:name.json
1271
1305
 
1272
1306
  A segment that is part literal, part param - `/files/:name.json`,
1273
1307
  `/post-:id`, `/v:major.:minor` - has no single param to name, so it is
1274
- called with the segment as the request carries it: `{'api.files("report.json")'}`,
1275
- `{'api("post-42")'}`, `{'api("v1.2")'}`. The argument is typed as the
1276
- segment's literal text around any string, so `{'api.files("report.txt")'}` does
1308
+ called with the segment as the request carries it: `api.files("report.json")`,
1309
+ `api("post-42")`, `api("v1.2")`. The argument is typed as the
1310
+ segment's literal text around any string, so `api.files("report.txt")` does
1277
1311
  not compile, and it is sent as one encoded segment: a `/` in it never adds a path
1278
1312
  level. `RequestPath` from `@nifrajs/core` is the same reading for a
1279
- whole path: `{'RequestPath'}` is
1313
+ whole path: `RequestPath<"/files/:name.json">` is
1280
1314
  ``/files/${string}.json``.
1281
1315
 
1282
1316
  **Reserved proxy keys.** The client proxy resolves a fixed set of property names
@@ -1293,7 +1327,7 @@ same call params use, accepting exactly the colliding segment names. The client
1293
1327
  the dot access at compile time with that guidance, and `nifra check` reports the
1294
1328
  collision (`NF-C018`, advisory). Prefer a verb-free segment
1295
1329
  (e.g. `/api/remove`) when you control the path; mark a route served only to
1296
- non-typed-client consumers with `// nifra-expect NF-C018: ` above its
1330
+ non-typed-client consumers with `// nifra-expect NF-C018: <reason>` above its
1297
1331
  registration.
1298
1332
 
1299
1333
  ### Results never throw
@@ -1404,7 +1438,9 @@ that is not JSON, says so in a comment, and marks what it wrote with a
1404
1438
  under the line was edited (reformatting it is not an edit); delete the line to own the
1405
1439
  schema by hand. A hand-written schema is never rewritten: the report lists the
1406
1440
  returned fields it drops, by path. Nothing is derived at request time - the schema in the
1407
- file is the one the guard enforces.
1441
+ file is the one the guard enforces. `nifra fix --code NF-C030` writes the same
1442
+ draft for one flagged route, and `nifra migrate layout` drafts one for each
1443
+ route it splits whose loader or action returns data without a schema.
1408
1444
 
1409
1445
  A field named like a credential (`password`, `token`,
1410
1446
  `apiKey`) fails the route when it loads unless its schema is wrapped in
@@ -1448,6 +1484,18 @@ export default function NewUser() {
1448
1484
  }
1449
1485
  ```
1450
1486
 
1487
+ A form can post to another site and the browser sends that site's cookies with it, so an action
1488
+ refuses a POST whose `Origin` is another site's with 403, before middleware, gates or
1489
+ the action run. A request without an `Origin`, such as one from a server, passes, and
1490
+ so does a form on the app's own page sent under `Referrer-Policy: no-referrer`, which
1491
+ arrives as `Origin: null` with `Sec-Fetch-Site: same-origin`.
1492
+ Same-origin is judged from the request URL's host, so a proxy in front must forward the
1493
+ `Host` header. A route that takes posts from elsewhere, such as an identity
1494
+ provider's `form_post` callback, exports `allowedOrigins` from its backend
1495
+ file: an array of exact origins, or a function that receives the origin (`null` when
1496
+ absent). It checks where the browser says the request comes from, not who sent it, so keep the
1497
+ action's own authentication.
1498
+
1451
1499
  ### Layout loaders on navigation
1452
1500
 
1453
1501
  A `_layout.backend.ts` can have a `loader` too; its output reaches the
@@ -1455,7 +1503,11 @@ layout component as `data`. On a client navigation that keeps the layout on scre
1455
1503
  browser already holds that data, so the loader runs again only when a param the layout owns
1456
1504
  changes (`org` for `orgs/[org]/_layout.tsx`) or the query changes. After
1457
1505
  an action, every loader runs. A layout that exports `gate = true` runs on every
1458
- request; a layout loader without it is not an authorization boundary. A
1506
+ request; a layout loader without it is not an authorization boundary: a client navigation can
1507
+ skip it, and an action below it runs without it. Put a check that refuses access in a gate or
1508
+ in middleware. In development, nifra warns the first time a layout loader without
1509
+ `gate` refuses a request with a redirect, a `Response`, or a 401 or 403,
1510
+ and `nifra check` reports one whose loader refuses in its own body (NF-C042). A
1459
1511
  `_layout.backend.ts` that exports `middleware` guards a directory, with
1460
1512
  or without a layout component - see [Route middleware](/docs/routing#middleware).
1461
1513
 
@@ -1561,8 +1613,9 @@ host - defence in depth behind the JSON requirement, at the cost of one comparis
1561
1613
  Serialising closed-over variables to the browser and back is a class of problem worth not
1562
1614
  having rather than encrypting.
1563
1615
 
1564
- Both content-type rules were measured rather than assumed. A body schema alone still accepts a
1565
- cross-origin urlencoded form - 200, attacker-controlled fields - and a bounded JSON read alone
1616
+ Both content-type rules were measured rather than assumed. A body schema alone still reads a
1617
+ urlencoded form that carries no `Origin` or one from a site in
1618
+ `formOrigins` - 200, attacker-controlled fields - and a bounded JSON read alone
1566
1619
  accepts the `text/plain` trick where a form's `name=value` is crafted to
1567
1620
  parse as valid JSON. Neither is sufficient by itself.
1568
1621
 
@@ -1623,7 +1676,7 @@ site.
1623
1676
  What a component usually wants around the call is state, and state is the part every framework
1624
1677
  spells differently. `useServerFn` adds exactly that.
1625
1678
 
1626
- ```ts
1679
+ ```tsx
1627
1680
  // doc-check: skip - JSX fragment, shown for the shape rather than compiled here.
1628
1681
  import { useServerFn } from "@nifrajs/web-react/fn"
1629
1682
  import { addTodo } from "./todos.fn.ts"
@@ -1688,7 +1741,7 @@ and `nifra assure` for free. The starter policy's
1688
1741
  `authenticated-write` rule matches any route declaring a domain write, so a function
1689
1742
  that writes and skips auth fails the check rather than shipping:
1690
1743
 
1691
- ```ts
1744
+ ```bash
1692
1745
  # A server function is a public POST endpoint, so the starter policy already covers it.
1693
1746
  nifra assure
1694
1747
 
@@ -2178,7 +2231,7 @@ that gap safe for you - you rarely have to think about it.
2178
2231
 
2179
2232
  ### Forms and links - nothing to do
2180
2233
 
2181
- A `` to a route, and any ``, use
2234
+ A `<form method="post">` to a route, and any `<a href>`, use
2182
2235
  progressive enhancement: native submit/navigation before hydration, a no-reload client
2183
2236
  takeover after.
2184
2237
 
@@ -2816,6 +2869,8 @@ UI idiom
2816
2869
  Build plugin
2817
2870
  Hydration bundle
2818
2871
 
2872
+ `{f.pkg}`
2873
+
2819
2874
  **Bundle** = the same minimal counter app, minified (not gzipped), for each framework -
2820
2875
  see `examples/web-*`. Indicative payload, not a benchmark.
2821
2876
 
@@ -2952,6 +3007,20 @@ Svelte resolve deferred data on the **client**, so JS-off users see the fallback
2952
3007
  deferred boundary. Put critical page data in the route `loader`; use
2953
3008
  `defer()` for slower, non-critical data.
2954
3009
 
3010
+ ### Markup outside the page
3011
+
3012
+ Svelte&apos;s `<svelte:head>` renders into the document&apos;s
3013
+ `<head>`, after the tags from the route&apos;s `meta`. The document
3014
+ always has a `<title>` of its own and a browser uses the first one, so set the
3015
+ title in `meta`.
3016
+
3017
+ A Vue `<Teleport>` is server-rendered where Vue hydrates it from, the first
3018
+ children of its target. `to="body"` content comes first in
3019
+ `<body>`. An `#id` target the app renders empty receives it, and one
3020
+ the app does not render gets a container before the app root. Any other selector, a target that
3021
+ has children of its own, and every teleport on a page that uses `defer()` render on
3022
+ the client, with a warning in development.
3023
+
2955
3024
  ### Dev HMR support
2956
3025
 
2957
3026
  Dev HMR works for all five adapters through `createViteDevServer` and the
@@ -2997,6 +3066,55 @@ app
2997
3066
  app.use((a) => a.decorate("db", db).derive((c) => ({ now: Date.now() })))
2998
3067
  ```
2999
3068
 
3069
+ ### What a parent&rsquo;s use() covers
3070
+
3071
+ A `group()` scope inherits the parent&rsquo;s chain as it stands at the call. A
3072
+ `merge()`d server was compiled on its own, so its routes keep _their_ chain. Only
3073
+ what the parent installed **before** the `group()` or `merge()` counts.
3074
+
3075
+ Installed on the parent
3076
+
3077
+ `group()` route
3078
+
3079
+ `merge()`d route
3080
+
3081
+ `derive`, `decorate`, `authenticate`,
3082
+ `beforeHandle`, `afterHandle`, `onError`,
3083
+ `around`, route-scoped assurance
3084
+
3085
+ yes
3086
+ no - wire it on the merged server
3087
+
3088
+ `onRequest`, `onResponse`, `responseHeaders`
3089
+
3090
+ yes
3091
+ yes (app-wide)
3092
+
3093
+ `responseContract()`
3094
+
3095
+ yes
3096
+ yes, when the route declares a response and its own server installed no contract
3097
+
3098
+ `effectLedger()`
3099
+
3100
+ yes
3101
+ yes, when the route declares capabilities and has no ledger of its own
3102
+
3103
+ `idempotency()`
3104
+
3105
+ yes
3106
+
3107
+ the merged server&rsquo;s own - a route declaring `idempotency` without one is
3108
+ refused at registration
3109
+
3110
+ Two checks catch the silent cases. In development and tests, `unusedScopedHooks`
3111
+ reports a hook followed only by `merge()` calls, and a `responseContract()`
3112
+ or `effectLedger()` installed after routes it would have covered.
3113
+ `nifra check` reports a `merge()` whose server authenticates none of its
3114
+ routes while this server&rsquo;s `authenticate()` or auth plugin covers its own
3115
+ (NF-C043); a module that is public on purpose takes
3116
+ `// nifra-expect NF-C043: <reason>` on the merge line.
3117
+
3000
3118
  ### Route/hook plugins: keep types with defineRouterPlugin
3001
3119
 
3002
3120
  A plugin that registers routes or hooks but adds **no context type** - e.g. mounting an auth
@@ -3010,7 +3128,7 @@ else typed).
3010
3128
 
3011
3129
  **Footgun:** reach for `definePlugin` here instead and a plain
3012
3130
  `definePlugin((app) => app.get(...))` infers `app` as
3013
- `Server`, collapsing `use()`'s result - and your whole typed
3131
+ `Server<any, any>`, collapsing `use()`'s result - and your whole typed
3014
3132
  client - to `any`, with **no type error and no runtime error**.
3015
3133
  `@nifrajs/better-auth` is built with the identity form, so
3016
3134
  `server().use(betterAuth(auth)).get(...)` keeps every route typed.
@@ -3285,7 +3403,10 @@ const app = server()
3285
3403
  `healthcheck()` adds liveness (`/health`) and readiness (`/ready`)
3286
3404
  endpoints - apply it **before** any auth guard so they stay public. `openapi()`
3287
3405
  serves an OpenAPI 3.1 document at `/openapi.json`, generated from your routes - add
3288
- `ui: true` for a Scalar API-reference page at `/reference`. Paths,
3406
+ `ui: true` for a Scalar API-reference page at `/reference`. The page
3407
+ loads an exact Scalar version from jsDelivr under a Subresource Integrity hash; serve your own
3408
+ copy with `ui: { cdn, integrity }` to keep a third-party origin out of your
3409
+ Content-Security-Policy. Paths,
3289
3410
  methods, and params are introspected; `servers`, `tags`,
3290
3411
  `security`, and `securitySchemes` are document options, and
3291
3412
  `operations` (keyed by `"GET /users/:id"`) supplies per-route bodies/security
@@ -3330,7 +3451,10 @@ app.use(idempotency({ store: new MemoryIdempotencyStore() }))
3330
3451
  enforced by default, and claims (`iss`/`aud`/`nbf`) are checked.
3331
3452
  Read the typed claims off the returned plugin - `auth.requireClaims(c.req)` (throws
3332
3453
  `401`) or `auth.claims(c.req)` (nullable). For rotating keys, pass
3333
- `key: jwks({ url })` (HTTPS-only, cached, size/time-bounded). `basicAuth`
3454
+ `key: jwks({ url })` (HTTPS-only, cached, size/time-bounded). A fetch that fails
3455
+ or returns no keys is remembered for `failureCooldownMs` (default 5 s), so while the
3456
+ identity provider is down a request fails at once instead of waiting on a fetch of its own.
3457
+ `basicAuth`
3334
3458
  compares static credentials in **constant time** (or takes a `verify` callback).
3335
3459
 
3336
3460
  ```ts
@@ -3473,7 +3597,7 @@ const PublicUser = t.object({ id: t.string(), name: t.string() })
3473
3597
 
3474
3598
  // "warn" logs and changes nothing; "enforce" makes the contract the upper bound too.
3475
3599
  // Not installing the plugin is "off" - and keeps the lane out of your bundle entirely.
3476
- export const app = server().use(responseContract("enforce")).get(
3600
+ export const app = server().use(responseContract("enforce", { extra: "strip" })).get(
3477
3601
  "/me",
3478
3602
  { response: PublicUser },
3479
3603
  async () => {
@@ -3483,8 +3607,10 @@ export const app = server().use(responseContract("enforce")).get(
3483
3607
  },
3484
3608
  )
3485
3609
 
3486
- // off -> {"id":"u1","name":"Ada","email":"a@b.c","passwordHash":"..."}
3487
- // enforce -> {"id":"u1","name":"Ada"}
3610
+ // off -> 200 {"id":"u1","name":"Ada","email":"a@b.c","passwordHash":"..."}
3611
+ // enforce -> 500 {"ok":false,"error":"internal_error"}
3612
+ // (t.object is closed; the log names email and passwordHash)
3613
+ // enforce, { extra: "strip" } -> 200 {"id":"u1","name":"Ada"}
3488
3614
  ```
3489
3615
 
3490
3616
  Not installing the plugin is &ldquo;off&rdquo;, which is exactly today&rsquo;s behaviour and
@@ -3499,12 +3625,54 @@ returns it early, or `onError` answers with it; only a hand-built
3499
3625
  should cover: like
3500
3626
  `idempotency()`, the decision is made per route at registration.
3501
3627
 
3502
- Enforcement follows your schema&rsquo;s own semantics, because Standard Schema exposes
3503
- `validate` and no way to enumerate declared keys. A _stripping_ schema (Zod,
3504
- Valibot) yields a cleaned value, so the extra fields are dropped. A _strict_ one
3628
+ By default, enforcement follows your schema&rsquo;s own semantics, because Standard Schema
3629
+ exposes `validate` and no way to enumerate declared keys. A _stripping_ schema
3630
+ (Zod, Valibot) yields a cleaned value, so the extra fields are dropped. A _strict_ one
3505
3631
  (`@nifrajs/schema`&rsquo;s `t.object`) reports them as issues, so the
3506
- response becomes a 500 and the detail goes to the logger, never to the caller. Both are what you
3507
- already declared about extra fields.
3632
+ response becomes a 500 and the detail goes to the logger, never to the caller.
3633
+ `{ extra: "strip" }` changes that for `t` schemas: they carry their
3634
+ JSON Schema, which does list the declared keys, so the payload is projected onto them - nested
3635
+ objects, arrays and records included - before it is validated. A union is projected when a
3636
+ value can meet only one of its branches: a single object branch, or object branches that all
3637
+ require one key holding literals no two of them share, such as `ok: true` and
3638
+ `ok: false`. Other unions are left to the validator. In `"warn"`
3639
+ mode the same option makes the log name the fields `"enforce"` would drop.
3640
+
3641
+ Stripping is silent by design. To see a field the contract does not declare - a new column -
3642
+ before someone asks where it went, pass `logStripped: true` with
3643
+ `"enforce"`: the log names each stripped field, nested ones as
3644
+ `user.email` and array items as `items[].cost`, once per route for each
3645
+ distinct set of names. Values are never logged.
3646
+
3647
+ For a metric or an alert, pass `onReport`. It receives every response the
3648
+ contract has something to say about: `violation` (enforce mode, a 500 went out
3649
+ instead), `warn` (warn mode, sent anyway, with the undeclared keys in
3650
+ `fields` when they are the reason) and `stripped` (enforce mode, sent
3651
+ without `fields`). Each report carries the route&rsquo;s method and pattern and
3652
+ the log line&rsquo;s message, never a value. A hook that throws or rejects is logged once and
3653
+ changes no response.
3654
+
3655
+ ```ts
3656
+ import { server } from "@nifrajs/core/server"
3657
+ import { responseContract } from "@nifrajs/core/response-contract"
3658
+
3659
+ const counts = new Map<string, number>()
3660
+
3661
+ export const app = server().use(
3662
+ responseContract("enforce", {
3663
+ extra: "strip",
3664
+ // Every report, where the log speaks once per route. `route` is the pattern, so the keys stay bounded.
3665
+ onReport: ({ kind, method, route }) => {
3666
+ const key = `${kind} ${method} ${route}`
3667
+ counts.set(key, (counts.get(key) ?? 0) + 1)
3668
+ },
3669
+ }),
3670
+ )
3671
+ ```
3672
+
3673
+ A `merge()`d server&rsquo;s routes are covered by a contract the parent installed
3674
+ before the merge, as long as the route declares a response and its own server installed none.
3675
+ See [what a parent&rsquo;s use() covers](/docs/plugins#parent-use).
3508
3676
 
3509
3677
  The check itself is essentially free: with a compiled validator it measures in the
3510
3678
  ~100ns-per-response range, and a realistic middleware-carrying route benchmarks within noise
@@ -3727,8 +3895,12 @@ one the bytes proved.
3727
3895
 
3728
3896
  -
3729
3897
  **A form post is a simple cross-origin request.** A browser sends
3730
- `multipart/form-data` with cookies and no preflight, so a cookie-authenticated upload
3731
- route needs `csrf()` like any other state change.
3898
+ `multipart/form-data`, urlencoded and `text/plain` with cookies and no
3899
+ preflight. A body-schema route refuses one whose `Origin` is another site&rsquo;s
3900
+ with `403` before reading it; list a site that must post forms to the app in the
3901
+ server&rsquo;s `formOrigins`. A request without an `Origin` passes, so
3902
+ a cookie-authenticated upload route still needs `csrf()` like any other state
3903
+ change.
3732
3904
 
3733
3905
  -
3734
3906
  **The form is held in memory.** Budget roughly twice `bodyLimit` per request in
@@ -3909,7 +4081,12 @@ accept either during a key rotation.
3909
4081
 
3910
4082
  A dropped connection or an impatient double-tap shouldn't double-charge a card. With an
3911
4083
  `Idempotency-Key` header, a retried unsafe request replays the first response instead of
3912
- re-running the side effect. It short-circuits in `onRequest`, _before_ the handler.
4084
+ re-running the side effect. The key is claimed in `onRequest`, so a concurrent retry gets
4085
+ a `409`; the stored response is replayed from `beforeHandle`, _after_ the
4086
+ route's authentication accepts the retry, so a credential revoked since the first request gets the
4087
+ route's current answer. Declare routes after `.use(idempotency())`:
4088
+ `beforeHandle` is order-scoped, and a route declared earlier replays from
4089
+ `onRequest`.
3913
4090
 
3914
4091
  ```ts
3915
4092
  // doc-check: skip - fragment: `app`, `chargeCard`, and `id` are your application's.
@@ -4242,6 +4419,10 @@ who asked" and have that be true.
4242
4419
  A route says what it does with `capabilities`, the same on a hand-written route or a
4243
4420
  server function:
4244
4421
 
4422
+ ```ts
4423
+ .post("/notes", { body: NoteInput, capabilities: ["db.write"] }, handler)
4424
+ ```
4425
+
4245
4426
  On its own that is an assertion. What makes it load-bearing is the other half:
4246
4427
  `provenance.imports` maps a module specifier to the capabilities that reaching it
4247
4428
  implies, so Nifra can compare what a route _says_ against what it _can do_.
@@ -4290,7 +4471,7 @@ the guarantee.
4290
4471
 
4291
4472
  Write to the database and declare nothing, and the check says so:
4292
4473
 
4293
- ```ts
4474
+ ```bash
4294
4475
  $ nifra check
4295
4476
 
4296
4477
  ✗ effect/capability assurance: 1
@@ -4299,7 +4480,7 @@ $ nifra check
4299
4480
 
4300
4481
  Declare it, and the policy takes over:
4301
4482
 
4302
- ```ts
4483
+ ```bash
4303
4484
  $ nifra check
4304
4485
  ✓ effect/capability assurance: none
4305
4486
 
@@ -4327,7 +4508,7 @@ is true: the handler really does have the connection in lexical scope.
4327
4508
 
4328
4509
  Which produces a specific dead end, and a specific finding for it:
4329
4510
 
4330
- ```ts
4511
+ ```bash
4331
4512
  $ nifra check
4332
4513
 
4333
4514
  ✗ effect/capability assurance: 1
@@ -4366,7 +4547,7 @@ A raw driver cannot tell a read from a write at the import, so it grants both -
4366
4547
  GET route in any module that can reach the driver is stuck. Putting your queries behind a seam
4367
4548
  split by access is what unsticks it, and it is what `create-nifra --db` scaffolds:
4368
4549
 
4369
- ```ts
4550
+ ```text
4370
4551
  db/
4371
4552
  index.ts the connection - no route module imports this
4372
4553
  read.ts reads, mapped to db.read
@@ -4385,9 +4566,13 @@ source without running it. It reads a path written as a string literal, or as a
4385
4566
  a module-level `const` string, with or without `as const`. The
4386
4567
  `const` can live in the same file or be exported from a project file it imports.
4387
4568
  The same holds for a WebSocket route's `app.ws(path, ...)`. A path built at runtime, such as a template with `${...}` in it, cannot be read
4388
- this way. `nifra check` names that expression in an NF-C036 finding, because the
4389
- route then has no module to start from. List the module in
4390
- `provenance.routeModules` to give it one.
4569
+ this way. So when `nifra.assurance.ts` loads the app, Nifra also records, in
4570
+ development, the module whose call registered each route, and the walk starts there too: a
4571
+ computed path, or a route on a server a helper builds, is still covered.
4572
+ `nifra check` still names such an expression in an NF-C036 finding, since the
4573
+ route lints read the source alone. When the registering module is not where the route&apos;s
4574
+ code lives, such as a shared helper that registers other modules&apos; handlers, list the
4575
+ right module in `provenance.routeModules`.
4391
4576
 
4392
4577
  ### Runtime beacons
4393
4578
 
@@ -4495,7 +4680,7 @@ record routes, not mounts, so review a new gap where it is listed: in the check
4495
4680
  same
4496
4681
  `opaque` field works on a `createWebApp` `mounts` entry.
4497
4682
 
4498
- ```ts
4683
+ ```bash
4499
4684
  $ nifra check
4500
4685
  • known gap, not capability-analyzed: /api/auth/* - better-auth's own handler; its effects are its own
4501
4686
  ```
@@ -4533,7 +4718,7 @@ Once assurance passes, snapshot the result. The lockfile is a review artifact: a
4533
4718
  starts touching something new shows up as a diff in the pull request rather than as nothing at
4534
4719
  all.
4535
4720
 
4536
- ```ts
4721
+ ```bash
4537
4722
  $ nifra capabilities snapshot # writes capabilities.lock.json
4538
4723
  $ nifra levels
4539
4724
  ✓ L0 typed contract
@@ -4659,6 +4844,15 @@ a `SessionStore`; in **cookie mode** (no store) the data is signed into the cook
4659
4844
  Stores mirror the ISR discipline: `MemorySessionStore` is prod-guarded;
4660
4845
  `KVSessionStore` is the durable, shared production store.
4661
4846
 
4847
+ The signature covers the cookie name, so two managers that share a secret never read each
4848
+ other's cookies; still, give sessions a secret no other signed value uses. A cookie-mode
4849
+ session lives at most `maxAge`, whatever expiry its payload names. Upgrading from
4850
+ 4.x, whose cookies were signed without the name, signs everyone out unless you pass
4851
+ `acceptLegacyCookies: true`: keep it for one `maxAge` after the upgrade
4852
+ (each such session is re-signed on its next commit), then remove it, since while it is on any
4853
+ session-shaped value the app signs with the same secret through `signValue` reads
4854
+ as a session.
4855
+
4662
4856
  ```ts
4663
4857
  // backend/auth.ts - one session manager, created on first use so the secret is read at request time.
4664
4858
  // Store mode keeps data server-side; cookie mode (no store) is stateless.
@@ -4784,6 +4978,15 @@ unauthenticated caller gets the 401 (or the refusal `run` returns), never a 413
4784
4978
  `apiKey` and `jwt` from `@nifrajs/middleware` run there. With
4785
4979
  `optional: true` they never refuse, so validation answers as usual.
4786
4980
 
4981
+ A stage that throws, or returns anything but `authenticated(principal)` or
4982
+ `rejected(...)`, fails closed with 503
4983
+ `{ ok: false, error: "auth_unavailable" }`, keeping 401 and 403 for the two
4984
+ real decisions and the cause out of the response. The cause goes where a handler's error
4985
+ goes: to `onError`, whose response replaces the 503, and when no hook answers, to
4986
+ the logger as `unhandled request error`. A database outage inside
4987
+ `authed()` is reported the same way. A thrown `Response` or
4988
+ `status(...)` is sent as thrown, as it is from a handler.
4989
+
4787
4990
  `run` receives the method, pathname, headers, path params, the raw
4788
4991
  `search` and the parsed `query` (frozen, read by the parser
4789
4992
  `c.query` uses; a repeated key is an array), the `request` (never read
@@ -4866,16 +5069,22 @@ own address (which would put all users in one bucket). Never key on a raw
4866
5069
  `X-Forwarded-For` value: a client writes whatever it likes there and gets a fresh bucket
4867
5070
  per request.
4868
5071
 
4869
- " }.
5072
+ ```ts
5073
+ import { server } from "@nifrajs/core/server"
5074
+ import { MemoryStore, rateLimit } from "@nifrajs/middleware"
5075
+
5076
+ // One reverse proxy you operate appends the caller to X-Forwarded-For. Behind a CDN that overwrites
5077
+ // a single header instead, declare { header: "<that header>" }.
4870
5078
  const app = server({ clientIp: { trustedHops: 1 } })
4871
- .use(
4872
- rateLimit({
4873
- store: new MemoryStore(), // use a shared store (Redis, etc.) in production
4874
- max: 5, // 5 attempts
4875
- windowMs: 15 * 60 * 1000, // per 15 minutes
4876
- .post("/login", …)
4877
- lang="ts"
4878
- />
5079
+ .use(
5080
+ rateLimit({
5081
+ store: new MemoryStore(), // use a shared store (Redis, etc.) in production
5082
+ max: 5, // 5 attempts
5083
+ windowMs: 15 * 60 * 1000, // per 15 minutes
5084
+ }),
5085
+ )
5086
+ .post("/login", …)
5087
+ ```
4879
5088
 
4880
5089
  Declare only hops you actually run: a directly reachable app with `trustedHops` set lets
4881
5090
  a client forge the forwarded address. Check your proxy's documentation for the header it sets
@@ -5152,9 +5361,14 @@ export const locales = defineLocales({
5152
5361
  gu: { draft: true }, // catalogs in progress: never routed, never an alternate
5153
5362
  },
5154
5363
  })
5155
- export const urls = defineI18nRouting(locales)
5364
+ export const urls = defineI18nRouting(locales, {
5365
+ // The pages that exist in some locales only, declared once; undefined = every served locale.
5366
+ pageLocales: (pathname) => (pathname.startsWith("/guides/") ? ["en", "hi"] : undefined),
5367
+ })
5156
5368
 
5157
5369
  urls.localizePathname("/kundli", "hi") // "/hi/kundli"
5370
+ urls.localizePathname("/guides/setup", "ur", { fallback: "default" }) // "/guides/setup"
5371
+ urls.localesOf("/hi/guides/setup") // ["en", "hi"]
5158
5372
  locales.chain("hi") // ["hi", "en"] - the catalog fallback order
5159
5373
  ```
5160
5374
 
@@ -5219,6 +5433,45 @@ export function meta({ params, origin }: MetaArgs): Meta {
5219
5433
  }
5220
5434
  ```
5221
5435
 
5436
+ A page that exists in some languages only is declared once, with `pageLocales`
5437
+ (given the path without its locale prefix; it must be pure). Then
5438
+ `matchSegment` answers not-found for the other locales, `alternates`
5439
+ lists only the page's own (none for a page in one locale), `localesOf(path)` names
5440
+ them for a prerender's static paths, and `localizePathname(path, locale, { fallback: "default" })`
5441
+ links a menu entry to the default locale's page where the page is missing. A
5442
+ `pageLocales` that throws, or names a locale the registry does not declare, throws
5443
+ rather than serving every locale.
5444
+
5445
+ ### Register the routing once
5446
+
5447
+ Export the router as `i18n` from `backend/framework.ts` (re-export it from
5448
+ `nifra.config.ts` when both exist), or pass it to a hand-written
5449
+ `createWebApp({ i18n })`. Every document then takes its locale from the URL:
5450
+
5451
+ - `<html lang dir>` come from `documentMeta(localeOf(path))`,
5452
+ unless the route's meta sets `lang`, on a hard load and after each client
5453
+ navigation alike.
5454
+
5455
+ - The response carries `Content-Language`.
5456
+
5457
+ - Each adapter's `useLocale()` names the page's locale key, and
5458
+ `<I18nProvider>` formats in its tag when no `locale` is passed;
5459
+ no loader has to hand either over.
5460
+
5461
+ - A route under a `[lang]` or `[[lang]]` directory runs
5462
+ `matchSegment` before any middleware: an unserved locale, or a page missing from
5463
+ it, is a 404 through your `_404`, and a non-canonical prefix (`/en/x`
5464
+ when the default is unprefixed) is a 308 to the canonical URL. The guard middleware above is
5465
+ then only needed for checks of your own.
5466
+
5467
+ ```ts
5468
+ // doc-check: skip - imports the app's own routing module.
5469
+ // backend/framework.ts - nifra dev, nifra build and the generated server entry read it from here.
5470
+ import { urls } from "../shared/i18n"
5471
+
5472
+ export const i18n = urls
5473
+ ```
5474
+
5222
5475
  ### Negotiate the locale
5223
5476
 
5224
5477
  `negotiateLocale` picks the best supported locale from a `?lang=` query
@@ -5363,6 +5616,9 @@ function Body() {
5363
5616
  }
5364
5617
  ```
5365
5618
 
5619
+ In an app that registers its routing, `locale` may be left out: the provider formats
5620
+ in the page's locale, and `useLocale()` reads the page's locale key anywhere below
5621
+ the route.
5366
5622
  `locale`, `messages` and `fallback` are serializable, so SSR
5367
5623
  renders the negotiated catalogs and the client rebuilds the same formatter on hydrate - no
5368
5624
  mismatch. Switching language re-navigates (a cookie or `?lang=`); the loader returns
@@ -5370,6 +5626,66 @@ the new catalog and the page re-renders. `localeCookie(name, locale)` builds the
5370
5626
  detector's own cookie for a switcher, so a choice made in the page and one made through
5371
5627
  `?lang=` are the same cookie.
5372
5628
 
5629
+ ### Copy tables
5630
+
5631
+ A catalog keys every message; a **copy table** keeps a page's text and its translations
5632
+ beside the code that shows it, with no key to name. `defineCopy(locales)` from
5633
+ `@nifrajs/i18n/copy` binds tables to the registry: the default locale's value is
5634
+ required, a locale the registry does not declare is a type error, and every other value has the
5635
+ default's shape - a list its length, a block its keys. Values are data (messages, lists, blocks);
5636
+ a message that takes values is ICU, read with `copy.format()`.
5637
+
5638
+ ```ts
5639
+ // shared/copy.ts - copy tables: the text and its translations beside the code that shows it.
5640
+ import { defineLocales } from "@nifrajs/i18n"
5641
+ import { defineCopy } from "@nifrajs/i18n/copy"
5642
+
5643
+ export const locales = defineLocales({ default: "en", locales: { en: {}, hi: {}, ta: {} } })
5644
+ export const copy = defineCopy(locales, {
5645
+ onMissing: ({ id, locale, fallback }) => console.warn(`${id ?? "a table"}: no ${locale}, showing ${fallback}`),
5646
+ })
5647
+
5648
+ // The default locale's value is required; every other locale is optional and shaped like it.
5649
+ export const TITLE = copy({ en: "Bicycle", hi: "साइकिल", ta: "மிதிவண்டி" })
5650
+ export const FAQ = copy.id("shop.faq", { en: ["Brakes?", "Gears?"], hi: ["ब्रेक?", "गियर?"] })
5651
+ export const PEDALS = copy({ en: "{n, plural, one {# pedal} other {# pedals}}", hi: "{n} पैडल" })
5652
+
5653
+ copy.pick(TITLE, "ta") // "மிதிவண்டி"
5654
+ copy.pick(FAQ, "ta") // ["Brakes?", "Gears?"] - the en value; onMissing fires once for ta
5655
+ copy.format(PEDALS, "en", { n: 3 }) // "3 pedals"
5656
+ ```
5657
+
5658
+ `copy.pick(table, locale)` walks `locales.chain(locale)`, and
5659
+ `onMissing` fires once per table and locale that falls back. A table's id is its
5660
+ `file:line`, or the one `copy.id()` names.
5661
+
5662
+ In a **production client build**, each table's values move out of the bundle into one chunk
5663
+ per locale, so a page's JavaScript carries the copy of the locale it renders in and none of the
5664
+ others; a chunk holds the fallback's value wherever its locale has none. The server bundle keeps
5665
+ every table whole. A page loads the chunk of its URL's locale (the first path segment when it is a
5666
+ served locale, or what `defineCopy(locales, { localeOf })` returns) and of the
5667
+ locale its `<html lang>` names, both preloaded; a client navigation loads the next
5668
+ URL's chunk with the route's code.
5669
+
5670
+ ```ts
5671
+ // doc-check: skip - continues a hand-written server.ts (adapter, manifest).
5672
+ // nifra build wires this itself; a server entry you write passes the client build's copyChunks.
5673
+ const assets = JSON.parse(await Bun.file("dist/manifest.json").text())
5674
+ export const app = createWebApp({
5675
+ adapter, manifest, clientEntry: assets.entry,
5676
+ copyChunks: assets.copyChunks, // locale -> chunk URL; each page preloads its own
5677
+ })
5678
+ ```
5679
+
5680
+ - The build reads tables statically: string literals, lists and blocks of them, and constants
5681
+ the same module declares. A table built any other way, or written in a `.svelte` or
5682
+ `.vue` file, keeps every locale in the bundle and still works;
5683
+ `nifra i18n check` says which tables those are.
5684
+
5685
+ - The build reads the source with the app's TypeScript (5.9 or 6). Without its compiler API
5686
+ (TypeScript 7 ships none) the build warns and keeps tables whole. It adds about 1 ms per
5687
+ module to a production build.
5688
+
5373
5689
  ### Rich text
5374
5690
 
5375
5691
  `rich(t, key, tags, vars)` renders a message's tags with your components, never
@@ -5398,7 +5714,7 @@ React, Preact, Solid and Vue export `rich()` from their `/i18n` entry,
5398
5714
  returning one node (each handler gets its tag's content as one node too). Svelte has
5399
5715
  `<Rich>`, which takes one snippet per tag:
5400
5716
 
5401
- ```ts
5717
+ ```svelte
5402
5718
  <!-- Svelte: each tag is a snippet that renders its content -->
5403
5719
  <script>
5404
5720
  import { Rich } from "@nifrajs/web-svelte/i18n"
@@ -5439,6 +5755,17 @@ the locale's script. Latin words (brands, units) stay allowed.
5439
5755
 
5440
5756
  - **Untranslated** messages identical to the default in another language, as a warning.
5441
5757
 
5758
+ - **Partly translated** text in a locale that does not write in Latin: a message of 6 words
5759
+ or more that is over 60% Latin-script words (`latin-share`; words split by
5760
+ `Intl.Segmenter`, so Japanese counts), with each locale's share in the coverage
5761
+ table and a warning above 10%; and a message of 80 graphemes or more translated to under 32%
5762
+ of its length (`volume`), a summary rather than a translation. Han scripts, which
5763
+ write a sentence in far fewer graphemes, are left out of `volume`. Every threshold
5764
+ is an option.
5765
+
5766
+ - **Your rules**: each of `rules` runs on every message of every locale, and
5767
+ its findings read `custom:<code>`, which `ignore` takes.
5768
+
5442
5769
  ```ts
5443
5770
  // doc-check: skip - imports the app's own catalog files.
5444
5771
  // shared/i18n.ts - the module `nifra i18n check` imports.
@@ -5456,8 +5783,22 @@ export const catalogs = {
5456
5783
  }
5457
5784
  // Keys a check skips: exact, a prefix ending in ".*", or "*".
5458
5785
  export const ignore = { script: ["languages.*"], untranslated: ["brand"] }
5786
+ // The rest of checkCatalogs()'s options: Latin words a translation keeps, and your own rules.
5787
+ export const check = {
5788
+ latinWords: ["PDF", "OK"],
5789
+ rules: [
5790
+ ({ message }: { readonly message: string }) =>
5791
+ message === message.trim() ? undefined : { code: "spacing", message: "starts or ends with a space" },
5792
+ ],
5793
+ }
5459
5794
  ```
5460
5795
 
5796
+ When the module also exports a `copy` from `defineCopy()` (or only
5797
+ that), the check finds its tables across the project's source, turns them into a catalog per
5798
+ locale and runs the same checks on them, reporting each at its `file:line`. Two tables
5799
+ with one id are an error (a production build refuses them too); a table it cannot read is a
5800
+ warning that says why.
5801
+
5461
5802
  It exits 1 on an error, and with `--strict` on a warning too; `--json`
5462
5803
  prints the result. Draft locales report missing keys as info. The checks themselves are
5463
5804
  `checkCatalogs()` from `@nifrajs/i18n/check`:
@@ -5770,7 +6111,9 @@ bridge an external fan-out (Redis pub/sub, NATS, a queue) to broadcast across al
5770
6111
  **Cloudflare Workers**, a stateless isolate can’t broadcast across connections,
5771
6112
  so Nifra ships a Durable Object hub: `createWebSocketHub(app)` holds the
5772
6113
  connections, and `toFetchHandler(app, { webSocketHub })` routes upgrades to it
5773
- - then `ws.subscribe` / `app.publish` behave exactly as on Bun.
6114
+ - then `ws.subscribe` / `app.publish` behave exactly as on Bun. An
6115
+ upgrade request for a path with no WebSocket route still gets that path's HTTP answer, as on
6116
+ every other runtime.
5774
6117
 
5775
6118
  ```ts
5776
6119
  // doc-check: skip - Workers entry: a Durable Object hub holds the connections.
@@ -5823,6 +6166,14 @@ it). Install it when you use `app.ws()`; without it a WS upgrade gets a clean
5823
6166
  npm i ws
5824
6167
  ```
5825
6168
 
6169
+ `server({ wsMaxPayloadBytes })` caps one inbound message (default
6170
+ `maxBodyBytes`, 1 MB): a socket that sends more is closed with `1009`
6171
+ and the message never reaches your handler. Bun and Node refuse it while it arrives. Deno's
6172
+ `Deno.upgradeWebSocket` takes no size limit, so Deno receives each message whole
6173
+ (up to its own limit, 64 MiB on Deno 2.9) before nifra can check it: the cap still keeps the
6174
+ message from your handler, but it does not bound the memory Deno spent receiving it. Where that
6175
+ matters, cap message size in a proxy in front of a Deno app.
6176
+
5826
6177
  ### In a composed app
5827
6178
 
5828
6179
  `mount({ path, app })` carries WebSocket upgrades as well as HTTP: when the
@@ -5834,6 +6185,11 @@ implement it too, building the outcome from `@nifrajs/core/ws`:
5834
6185
  owns its pub/sub. On Bun, install `websocket()` on the parent or on a mounted nifra
5835
6186
  child, or `listen()` refuses to start with `INVALID_WS_RUNTIME`.
5836
6187
 
6188
+ Each mounted nifra app keeps its own `wsMaxPayloadBytes`: a message over the
6189
+ child's cap closes that socket with `1009`, whether the cap is below or above the
6190
+ parent's. On Bun one listener serves them all, so its frame limit is the largest cap among the
6191
+ parent and the apps mounted on it, and a socket whose app declares less checks its own.
6192
+
5837
6193
  `mountFetch(path, handler)` and a plain fetch handler carry HTTP only. An upgrade
5838
6194
  request under such a path reaches the handler as an ordinary request and never becomes a
5839
6195
  socket. Serve that path's WebSockets from a mounted child, or keep that server beside nifra.
@@ -6051,7 +6407,7 @@ sessions, pub/sub) needs a shared store, as in any multi-instance deploy.
6051
6407
  Self-hosting (no CDN in front)? Hand `@nifrajs/node`'s `serve` a
6052
6408
  `static` mount and it serves the client bundle from disk - traversal-guarded,
6053
6409
  content-typed, with an immutable cache - before the app runs, leaving the SSR fast path
6054
- untouched: `serve(app, {'{ port, static: { dir: new URL("./assets/", import.meta.url) } }'})`.
6410
+ untouched: `serve(app, { port, static: { dir: new URL("./assets/", import.meta.url) } })`.
6055
6411
  On Cloudflare/Vercel the platform serves assets, so you don't need it there.
6056
6412
 
6057
6413
  Every file under the mount is cached as immutable by default. If the directory also holds
@@ -6219,6 +6575,12 @@ export const vitePlugins = [react()] // dev HMR (Fast Refresh)
6219
6575
  Nifra includes a conservative codemod for moving static Tailwind classes to StyleX. It is a dry
6220
6576
  run by default, so inspect the proposed edits first:
6221
6577
 
6578
+ ```sh
6579
+ nifra migrate --from tailwind --to stylex # report safe edits and manual issues
6580
+ nifra migrate --from tailwind --to stylex --write # apply only safe edits
6581
+ nifra migrate --from tailwind --to stylex --dir src
6582
+ ```
6583
+
6222
6584
  Supported static `className` attributes become `stylex.props(...)` calls
6223
6585
  backed by a local `stylex.create(...)` table. Responsive breakpoints and
6224
6586
  element-local pseudo-classes such as `hover:` are supported. Dynamic class
@@ -6229,7 +6591,7 @@ remain.
6229
6591
  StyleX compilation is native to Nifra&apos;s Bun pipeline. Install the runtime and compiler peers,
6230
6592
  then register both the browser and SSR transforms:
6231
6593
 
6232
- ```ts
6594
+ ```sh
6233
6595
  # Install the runtime and the optional compiler peers.
6234
6596
  bun add @stylexjs/stylex
6235
6597
  bun add -d @babel/core @stylexjs/babel-plugin @babel/plugin-syntax-flow \
@@ -6268,7 +6630,7 @@ target, keeping its `^` or `~` unless you pass `--exact`.
6268
6630
  The pins in `overrides`, `resolutions` and
6269
6631
  `pnpm.overrides` move with them, since an override decides what installs.
6270
6632
 
6271
- ```ts
6633
+ ```bash
6272
6634
  nifra upgrade --list # the release targets this CLI knows
6273
6635
  nifra upgrade 5.0.0 # dry-run: every planned edit, nothing written
6274
6636
  nifra upgrade 5.0.0 --write # apply, then nifra check verifies (--no-verify skips it)
@@ -6281,14 +6643,31 @@ when the rollback is intended); a target newer than the running CLI prints the c
6281
6643
  that release&apos;s CLI. It edits files under the workspace root only: a symlinked package
6282
6644
  directory or `package.json` is never followed, and a group package installed by a
6283
6645
  link from outside the root is listed under "Left alone" for you to upgrade in its
6284
- own repository. So is another version pinned outside `package.json`, with its
6285
- line: an MCP config such as `.mcp.json`, a Dockerfile or compose file, a CI
6286
- workflow, and a lockfile other than the workspace&apos;s own (an image build&apos;s frozen
6287
- lockfile, say), which you regenerate after installing. With `--write` it also
6646
+ own repository. The MCP launch pin in `.mcp.json`, `.cursor/mcp.json`,
6647
+ `CLAUDE.md` and `AGENTS.md` moves to the target, or is dropped when
6648
+ the project declares `@nifrajs/cli` so the launch runs that install from then on:
6649
+ the edit `nifra init-agents --sync-mcp` makes. Another version pinned outside
6650
+ `package.json` is listed with its line: the rest of an agent file, an MCP config
6651
+ elsewhere, a Dockerfile or compose file, a CI workflow, and a lockfile other than the
6652
+ workspace&apos;s own (an image build&apos;s frozen lockfile, say), which you regenerate after
6653
+ installing. With `--write` it also
6288
6654
  prints how hook scope changed across the
6289
6655
  upgrade (`--no-hooks` skips that). `nifra doctor` and
6290
6656
  `nifra check` (NF-D002) point here when a workspace carries more than one version;
6291
- see [mixed nifra versions](/docs/troubleshooting#mixed-versions).
6657
+ see [mixed nifra versions](/docs/troubleshooting#mixed-versions). A
6658
+ `file:` package whose dependencies this upgrade moves keeps its old ones in
6659
+ `bun.lock`, where Bun never refreshes them; the plan lists each, and
6660
+ `--write` drops those entries so the next `bun install` records them
6661
+ again (see [stale file: links](/docs/troubleshooting#stale-file-links)).
6662
+
6663
+ A `link:` or `file:` dependency outside the root that installs its own
6664
+ `@nifrajs/*` at another version stops the upgrade before anything is written: its
6665
+ imports resolve from its own `node_modules`, so after the upgrade a
6666
+ `server()` it builds cannot be merged into yours. The refusal names each one with
6667
+ the commands that move it to the target; upgrade those first, or pass
6668
+ `--allow-linked-skew` to go ahead. `nifra upgrade --list` shows the
6669
+ targets with the notes of every release after the one you declare: what an app can observe
6670
+ changing on the way up.
6292
6671
 
6293
6672
  ### Scope
6294
6673
 
@@ -6353,7 +6732,7 @@ need both). Anywhere else, add the URL.
6353
6732
 
6354
6733
  ### Setup
6355
6734
 
6356
- ```ts
6735
+ ```bash
6357
6736
  # Registers the MCP server and writes the agent files. Never clobbers what is already there.
6358
6737
  nifra init-agents
6359
6738
 
@@ -6366,9 +6745,14 @@ nifra init-agents
6366
6745
 
6367
6746
  # Then restart the agent so it picks the server up.
6368
6747
 
6369
- # The server is pinned to an exact @nifrajs/cli. After upgrading nifra, re-pin it to the version the
6370
- # project installs. Only that version string changes; every other byte of every file is kept.
6748
+ # A project that declares @nifrajs/cli launches `bunx @nifrajs/cli mcp`, unpinned: bunx runs the
6749
+ # installed CLI, so the server moves with every upgrade. Elsewhere the launch is pinned to an exact
6750
+ # version, since an unpinned bunx would fetch the latest release.
6751
+ # This moves an old pinned launch to that form: unpinned when the project declares the CLI, else the
6752
+ # version it installs. Only the version string changes; every other byte of every file is kept.
6371
6753
  # At a workspace root whose one nifra app is a member, the launch also names it: `mcp app`.
6754
+ # Run in that member, it also re-pins the root's files whose every nifra launch serves it (they stay
6755
+ # pinned: the root's own node_modules need not hold the CLI).
6372
6756
  nifra init-agents --sync-mcp
6373
6757
  ```
6374
6758
 
@@ -6377,7 +6761,7 @@ safe to re-run after a Nifra upgrade.
6377
6761
 
6378
6762
  ### The loop
6379
6763
 
6380
- ```ts
6764
+ ```bash
6381
6765
  # 1. What is here?
6382
6766
  nifra_context # routes, page routes, conventions - one call, unfiltered, as an index
6383
6767
  nifra_routes # API routes as JSON: { method, path, call, body?, query?, response? }
@@ -6414,7 +6798,7 @@ without being told a port. The server writes `.nifra/dev-server.json`, readable
6414
6798
  its owner, with its port and a token minted for that run; a tool checks that the server answers
6415
6799
  as itself before it reads anything.
6416
6800
 
6417
- ```ts
6801
+ ```bash
6418
6802
  nifra_errors # every open error, newest last
6419
6803
  nifra_errors {since: 41} # only what happened after a previous call's cursor
6420
6804
  nifra_errors {category: ["hydration"], includeStale: false}
@@ -6428,7 +6812,7 @@ nifra logs --level warn,error --grep cart
6428
6812
 
6429
6813
  Each error is a structured diagnostic, the same one the dev overlay renders:
6430
6814
 
6431
- ```ts
6815
+ ```json
6432
6816
  {
6433
6817
  "id": "e_5b6cbe9d",
6434
6818
  "category": "browser",
@@ -6507,7 +6891,7 @@ export const devDatabase = {
6507
6891
  }
6508
6892
  ```
6509
6893
 
6510
- ```ts
6894
+ ```bash
6511
6895
  nifra_db_schema # tables, row estimates, columns, keys, indexes
6512
6896
  nifra_db_schema {table: "orders"} # one table
6513
6897
  nifra_db_query {sql: "SELECT status, count(*) FROM orders GROUP BY 1"}
@@ -6623,7 +7007,7 @@ is.
6623
7007
  only by its owner: the SQL with secrets redacted, its fingerprint, the row count, the duration
6624
7008
  and the refusal code - never the rows. It rotates at 1 MB; `nifra db audit` reads it.
6625
7009
 
6626
- ```ts
7010
+ ```json
6627
7011
  {
6628
7012
  "ok": true,
6629
7013
  "tool": "query",
@@ -6732,7 +7116,7 @@ The teaching tools - `nifra_docs`, `nifra_example`,
6732
7116
  verified corpora, with no local checkout. It is read-only and needs no key. The project tools
6733
7117
  above still come from `nifra mcp` in your own repo, where they can see your routes.
6734
7118
 
6735
- ```ts
7119
+ ```bash
6736
7120
  # Claude Code
6737
7121
  claude mcp add --transport http nifra-docs https://mcp.nifra.dev
6738
7122
 
@@ -6757,7 +7141,7 @@ add Nifra docs to Cursor
6757
7141
  `nifra_check` is the one an agent should loop on. It returns structured
6758
7142
  diagnostics, each carrying its own fix, so a failure is a work item rather than a wall.
6759
7143
 
6760
- ```ts
7144
+ ```json
6761
7145
  {
6762
7146
  "ok": true,
6763
7147
  "typecheck": "pass",
@@ -6778,7 +7162,7 @@ contract (L0) to contract-derived invariant tests (L4). A scaffolded app starts
6778
7162
  rung it has not reached reports the specific thing missing - so the ladder doubles as the list
6779
7163
  of what to do next. See [the verification ladder](/docs/verification).
6780
7164
 
6781
- ```ts
7165
+ ```bash
6782
7166
  # The two an agent should gate on. Both exit non-zero on failure, so they work in CI unchanged.
6783
7167
  nifra check
6784
7168
  nifra levels --min 1
@@ -6839,7 +7223,7 @@ any Agent Client Protocol agent (Claude Code, Codex, Gemini CLI) over stdio; oth
6839
7223
  implement the same protocol port and can prove it with `checkAgentBackend` from
6840
7224
  `@nifrajs/agent-protocol/conformance`.
6841
7225
 
6842
- ```ts
7226
+ ```bash
6843
7227
  bun add @nifrajs/coding-agent @nifrajs/pi
6844
7228
 
6845
7229
  # Interactive, one-shot, JSON, and local RPC modes are available.
@@ -6854,7 +7238,7 @@ environments, and treats extensions as an explicit opt-in. Post-turn `check`,
6854
7238
  the gate until it passes or the attempt cap is reached. The local process adapter and extension
6855
7239
  worker are crash-containment helpers, not hostile-code sandboxes.
6856
7240
 
6857
- ```ts
7241
+ ```bash
6858
7242
  # Post-turn gates are opt-in. A failed gate becomes bounded repair work.
6859
7243
  bunx nifra-agent --backend pi --message "implement the change" \
6860
7244
  --verify-after-turn check,assure --max-repair-attempts 2
@@ -6869,7 +7253,10 @@ emit `approval.required` with an opaque approval id, action, capability, and bou
6869
7253
  coordinates. Resolve it through the host or RPC with `approval.resolve`; the backend
6870
7254
  emits `approval.resolved` and only then executes the tool. Denial, cancellation,
6871
7255
  timeout, and closed sessions all fail closed, and `approvalTimeoutMs` bounds how long
6872
- a pending decision can remain open.
7256
+ a pending decision can remain open: 5 minutes by default, at most 24 hours, or
7257
+ `"never"` to wait until it is answered, cancelled, its turn ends, or the session
7258
+ closes. The host's broker takes the same values as `approvals.timeoutMs` on
7259
+ `CodingAgentHost` and `CodingAgentRpcServer`.
6873
7260
 
6874
7261
  ### Expose the same agent to other clients
6875
7262
 
@@ -6967,12 +7354,13 @@ fail-open OpenTelemetry run and step spans. Providers, credentials, durable stor
6967
7354
  and tenant policy remain application-owned ports.
6968
7355
 
6969
7356
  A step that suspends for approval resumes with the decision the caller sends in
6970
- `resume.approval`. Over A2A, or on an AG-UI or `mountAgent` route that
6971
- anyone can reach, that caller may be the party asking for the tool. Return
7357
+ `resume.approval`. On an AG-UI or `mountAgent` route that anyone can
7358
+ reach, that caller may be the party asking for the tool. Return
6972
7359
  `resumeApproval: "port"` from `ports` to keep the configured approval
6973
7360
  port authoritative: it is asked again on resume, receives the caller's decision as
6974
7361
  `callerDecision`, and its verdict stands. Without a port, such a resume suspends
6975
- again.
7362
+ again. A2A does this by default, since the resuming peer is the agent that asked for the
7363
+ tool; return `resumeApproval: "caller"` there only when the peer is the approver.
6976
7364
 
6977
7365
  ### Where your code and secrets run
6978
7366
 
@@ -7000,9 +7388,11 @@ values (`nifra mcp --env-file .env.secrets`), reach all of them.
7000
7388
  -
7001
7389
  **No `.env` in the server.** When Bun loaded `.env`
7002
7390
  values into the server at startup, the server hands the session to a copy of itself that
7003
- loads none, keeping the values from the environment and `--env-file`. The process
7004
- the client started stays to forward signals and the exit code: it still holds the values
7005
- Bun loaded, but runs no project code and reads no messages.
7391
+ loads none, keeping the values from the environment and `--env-file`. A project
7392
+ that installs another release of `@nifrajs/cli` gets the session handed to that
7393
+ CLI the same way, with no `.env` loaded. The process the client started stays to
7394
+ forward signals and the exit code: it still holds the values Bun loaded, but runs no project
7395
+ code and reads no messages.
7006
7396
 
7007
7397
  -
7008
7398
  **A process per call has a cost.** A call that loads the app pays one process
@@ -7378,6 +7768,13 @@ emits the _same_ error as the Bun build (one implementation, adapted to Rollup's
7378
7768
  so a refused import - a `node:` builtin, `backend/`, a route's
7379
7769
  `.backend.ts` half - fails the build either way.
7380
7770
 
7771
+ `import.meta.glob` is not one of them. The Bun build expands a literal pattern the
7772
+ way Vite does: a string or an array of strings starting with `./`,
7773
+ `../` or `/` (the app root), `!` excluding, with the
7774
+ `eager` and `import` options, keyed as Vite keys it. Any other form
7775
+ (a computed pattern, an alias, `query`) fails the build with the file and line, and
7776
+ so does a bundle that still calls the glob because another plugin loaded that module first.
7777
+
7381
7778
  ```ts
7382
7779
  // vite.config.ts - a Vite/Rollup PRODUCTION client build (the escape hatch, not the default).
7383
7780
  // Only reach for this when an app needs a Vite-only transform with no Bun equivalent; Nifra's default
@@ -7736,7 +8133,7 @@ Declare the packages in your app's `package.json`. It is a **static**
7736
8133
  declaration on purpose - `nifra check` reads it without importing your config, so
7737
8134
  the preflight never executes app code:
7738
8135
 
7739
- ```ts
8136
+ ```json
7740
8137
  {
7741
8138
  "name": "my-app",
7742
8139
  "dependencies": {
@@ -7771,7 +8168,7 @@ not: Bun's _runtime_ resolver never offers a
7771
8168
  bare specifier to a plugin, so `bun test`, `bun run`, and preloaded
7772
8169
  scripts still load both copies unless you preload the registrar:
7773
8170
 
7774
- ```ts
8171
+ ```toml
7775
8172
  # bunfig.toml
7776
8173
  preload = ["@nifrajs/core/single-copy/register"]
7777
8174
 
@@ -7818,7 +8215,7 @@ Vue, Solid, Svelte). Nifra dedupes the active adapter's runtime in build and dev
7818
8215
  `AGENTS.md`.
7819
8216
 
7820
8217
  ###
7821
- `client` resolves to `never` (or `data: never`)
8218
+ `client<typeof app>` resolves to `never` (or `data: never`)
7822
8219
 
7823
8220
  The typed client is derived from your backend's type. Two things collapse it:
7824
8221
 
@@ -7835,7 +8232,7 @@ plain object and shape the response with `c.set` - reach for `c.json` /
7835
8232
  -
7836
8233
  **A plugin widened the app's type.** A plugin that registers routes/hooks but whose return
7837
8234
  type isn't the concrete server (e.g. an untyped `app => app.onResponse(…)`)
7838
- makes `.use()` return `Server` and the client loses your
8235
+ makes `.use()` return `Server<any, any>` and the client loses your
7839
8236
  registry. Build it with `defineRouterPlugin(name, …)` (the clearer-named
7840
8237
  `defineIdentityPlugin`) so `.use()` returns your server unchanged and
7841
8238
  routes added after it stay typed. See
@@ -7931,10 +8328,10 @@ export const app = implement(contract, {
7931
8328
  Because the budget is per-expression and global to a compilation, a type-heavy construct
7932
8329
  _elsewhere_ in the program can push an otherwise-fine `.merge()` chain over the
7933
8330
  edge. It surfaces not as `TS2589` but as a `TS2345` assignability error
7934
- naming an **uninstantiated** `Server` - the shape
8331
+ naming an **uninstantiated** `Server<Registry, unknown>` - the shape
7935
8332
  the server type collapses to when the compiler gives up mid-inference. The usual trigger is a
7936
8333
  **generic higher-order function that wraps the builder** (a
7937
- `withX(app)` that threads the `Server` type through its own type
8334
+ `withX<T>(app)` that threads the `Server` type through its own type
7938
8335
  parameters); merely having that file in the program can be enough. Treat these as real
7939
8336
  constraints of an inference-first framework:
7940
8337
 
@@ -7945,10 +8342,10 @@ inference-heavy generics thread the `Server` / registry type through your own co
7945
8342
  -
7946
8343
  **Avoid generic HOF wrappers around the builder.** Wrap with a
7947
8344
  `defineRouterPlugin` (identity plugin) or compose with `.merge()` instead
7948
- of a `withX(app)` that re-infers the whole server type.
8345
+ of a `withX<T>(app)` that re-infers the whole server type.
7949
8346
 
7950
8347
  -
7951
- Put an explicit `Promise` return annotation on async callbacks that thread
8348
+ Put an explicit `Promise<T>` return annotation on async callbacks that thread
7952
8349
  framework types, so the compiler stops re-deriving the awaited type at each use.
7953
8350
 
7954
8351
  [!TIP]
@@ -7987,6 +8384,21 @@ workspace root only. A symlinked package directory or `package.json` is never
7987
8384
  followed, and a group package installed by a link from outside the root is listed under
7988
8385
  "Left alone" - upgrade that repository on its own.
7989
8386
 
8387
+ ### "records dependencies its file: packages no longer declare"
8388
+
8389
+ A `file:` dependency's own dependencies are recorded in `bun.lock` when
8390
+ Bun first installs it, and Bun does not read that package's `package.json` again:
8391
+ after the linked package moves to a new version of a dependency, `bun install`
8392
+ (even with `--force`) keeps installing the recorded one beside it, so the app can
8393
+ load two copies of the same package. `nifra doctor` (and `nifra check`,
8394
+ as the `NF-D003` warning) compares each recorded entry with the linked
8395
+ `package.json` and names every dependency that moved.
8396
+
8397
+ Run `bun update <package>` for each named package. `nifra upgrade`
8398
+ reads the lock against the manifests it is about to write, and with `--write` drops
8399
+ those entries so the next `bun install` records them again; run that install
8400
+ before committing `bun.lock`, or `bun install --frozen-lockfile` fails.
8401
+
7990
8402
  ### Still stuck?
7991
8403
 
7992
8404
  Run `nifra check --json` as the done-gate - it surfaces the import-chain leaks,
@@ -8091,6 +8503,17 @@ written down: `nifra fix --code NF-C035` adds
8091
8503
  `export const apiPrefix = "/api"`, which is what 4.x mounted by default, and
8092
8504
  `""` keeps the backend loader-only.
8093
8505
 
8506
+ With both files, `nifra dev` and `nifra build` take
8507
+ `apiPrefix`, `apiStrip`, `mounts`, `csp`,
8508
+ `nonce`, `serverComponents`, `i18n`, `use` and
8509
+ `publicEnvPrefix` from `backend/framework.ts` when
8510
+ `nifra.config.ts` does not set them, so the
8511
+ server entry and the dev server read one value without a re-export. A hand-written
8512
+ `createWebApp` call passes `apiPrefix` itself; import it from
8513
+ `backend/framework.ts` so production serves the backend where
8514
+ `nifra dev` does. `nifra check` reports `NF-C035` at a call
8515
+ that mounts a backend with no `apiPrefix`, or with a different one.
8516
+
8094
8517
  Because the backend answers first and its 404 is final, a page file under the prefix (
8095
8518
  `routes/api/report.tsx`) could never render. Nifra refuses it instead of serving a
8096
8519
  silent 404: `createWebApp` throws at startup naming the file, `nifra build`
@@ -8099,7 +8522,7 @@ mount in front of the page router.
8099
8522
 
8100
8523
  An app run by `nifra dev` and `nifra build` sets these options from
8101
8524
  `backend/framework.ts`: `apiPrefix`, `apiStrip`, `mounts`,
8102
- `csp` and `nonce`. The generated server entry imports them from there, so
8525
+ `csp`, `nonce` and `i18n`. The generated server entry imports them from there, so
8103
8526
  export them from `framework.ts` (and re-export from `nifra.config.ts` when
8104
8527
  both exist). A `mounts` entry hands a path to another app; a single extra URL
8105
8528
  outside the prefix, such as a sitemap, is a plain route registered in `use`:
@@ -8182,7 +8605,7 @@ each other. Each domain therefore owns its full absolute paths (`/api/listings`,
8182
8605
  `.group(prefix, build)`
8183
8606
  **
8184
8607
  - declare routes under a static prefix. `app.group("/admin", (a) => a.get("/users",
8185
- list))` serves `/admin/users`, and the prefix is part of the typed client,
8608
+ list))` serves `/admin/users`, and the prefix is part of the typed client,
8186
8609
  `routes()`, OpenAPI, capability events and the effect ledger. The builder
8187
8610
  inherits this server's middleware chain as it stands at the call; what it adds stays in the
8188
8611
  group, and its `onRequest`/`onResponse` hooks run only for requests at
@@ -8263,7 +8686,7 @@ Two valid ways to mutate; pick by where the call originates.
8263
8686
 
8264
8687
  -
8265
8688
  **Route `action`** - the form/SSR path. A
8266
- `` (or the client submit) runs the route's
8689
+ `<form method="post">` (or the client submit) runs the route's
8267
8690
  `action(ctx)`, which typically calls `ctx.api` in-process and returns
8268
8691
  `actionData` (or a `redirect`). Progressive-enhancement: works with JS
8269
8692
  off, and the loader revalidates after. Reach for this for page-driven mutations tied to a
@@ -8474,7 +8897,7 @@ than something we vouch for.
8474
8897
 
8475
8898
  ### The report is the evidence
8476
8899
 
8477
- ```ts
8900
+ ```json
8478
8901
  {
8479
8902
  "schemaVersion": 1,
8480
8903
  "ok": true,
@@ -8807,7 +9230,9 @@ pass through, and every `<link>` attribute with a normal name -
8807
9230
 
8808
9231
  A route's `meta` emits the full social / structured-data head with three public
8809
9232
  helpers - `canonical()`, `openGraph()`, and `jsonLd()` - and
8810
- builds **absolute** URLs from the `origin` argument. Because
9233
+ builds **absolute** URLs from the `origin` argument. Import them from
9234
+ `@nifrajs/web/seo`: the entry imports nothing at runtime, so a page's browser bundle
9235
+ gets the three helpers and none of the server modules the package root also exports. Because
8811
9236
  `meta()` runs in **both** SSR and client navigation it has
8812
9237
  **no server env**: never read `process.env` or the request inside it.
8813
9238
  The framework injects `origin` (the site's scheme + host, e.g.
@@ -8819,9 +9244,11 @@ base, a CDN host) belongs in the `loader`, not `meta()`.
8819
9244
 
8820
9245
  ```ts
8821
9246
  // routes/articles/[slug].tsx - a complete SEO head: canonical + Open Graph + Twitter + JSON-LD,
8822
- // with ABSOLUTE URLs built from `origin`. The three helpers (canonical/openGraph/jsonLd) are public
8823
- // exports of @nifrajs/web; `origin` is a MetaArgs field beside data, pageData and params.
8824
- import { canonical, jsonLd, openGraph, type MetaArgs } from "@nifrajs/web"
9247
+ // with ABSOLUTE URLs built from `origin`. The three helpers (canonical/openGraph/jsonLd) come from
9248
+ // @nifrajs/web/seo, which imports nothing at runtime, so the page's browser bundle takes only them;
9249
+ // `origin` is a MetaArgs field beside data, pageData and params.
9250
+ import type { MetaArgs } from "@nifrajs/web"
9251
+ import { canonical, jsonLd, openGraph } from "@nifrajs/web/seo"
8825
9252
 
8826
9253
  // CAVEAT: meta() runs in BOTH SSR and client navigation, so it has NO server env - never read
8827
9254
  // `process.env` or the request here. The framework injects `origin` (the site's scheme+host, e.g.
@@ -8982,7 +9409,7 @@ router and await auth-scope invalidation on identity, tenant or permission chang
8982
9409
  The programmatic `buildClient()` API emits a content-hashed directory plus a
8983
9410
  `manifest.json` you can hand to `createWebApp` (`entry`,
8984
9411
  `routes` for per-route preload, `css` + `routeStyles` for
8985
- `<link>` injection).
9412
+ `<link>` injection, `copyChunks` when the app has copy tables).
8986
9413
 
8987
9414
  ```ts
8988
9415
  // buildClient() writes a browser bundle + manifest.json for custom build pipelines:
@@ -8991,7 +9418,8 @@ The programmatic `buildClient()` API emits a content-hashed directory plus a
8991
9418
  "assets": ["/assets/…"], // every emitted chunk URL
8992
9419
  "routes": { "users/[id]": ["/assets/_layout-H.js", "/assets/_slug_-H.js"] },
8993
9420
  "css": ["/assets/app-H.css"], // aggregate stylesheets (fallback)
8994
- "routeStyles": { "users/[id]": ["/assets/_layout-H.css"] } // per-route CSS (chain only)
9421
+ "routeStyles": { "users/[id]": ["/assets/_layout-H.css"] }, // per-route CSS (chain only)
9422
+ "copyChunks": { "hi": "/assets/copy-hi-H.js" } // copy tables by locale (@nifrajs/i18n/copy)
8995
9423
  }
8996
9424
 
8997
9425
  // Invariants worth knowing:
@@ -9503,8 +9931,8 @@ says that the app kept it open.
9503
9931
  **Routes nifra cannot see.** A mounted handler such as better-auth answers paths that are
9504
9932
  not in your backend, and no typed client covers them. Declare the mount opaque,
9505
9933
  `
9506
- mounts: [{ path: "/api/auth", app: auth, opaque: "better-auth" }]
9507
- `
9934
+ mounts: [{ path: "/api/auth", app: auth, opaque: "better-auth" }]
9935
+ `
9508
9936
  , and when `nifra.assurance.ts` names this app as its `source`, the
9509
9937
  check skips a `fetch` into that prefix by itself. Without that, list the prefixes
9510
9938
  in `nifra.check.json` next to `package.json`:
@@ -9517,7 +9945,7 @@ in `nifra.check.json` next to `package.json`:
9517
9945
 
9518
9946
  -
9519
9947
  **One call nifra cannot type.** For a single call rather than a whole prefix, such as a
9520
- static file, put `// nifra-expect NF-C002: ` on the line or in the
9948
+ static file, put `// nifra-expect NF-C002: <reason>` on the line or in the
9521
9949
  comment block above it. The finding stays in the report as info, with your reason. A comment
9522
9950
  with no reason silences nothing.
9523
9951
 
@@ -9821,7 +10249,7 @@ do. The dev overlay shows it, `nifra_explain` returns it, and every entry
9821
10249
  recognise is `NIFRA_UNHANDLED`, still with its frames and a codeframe around the line
9822
10250
  in your source.
9823
10251
 
9824
- ```ts
10252
+ ```json
9825
10253
  {
9826
10254
  "code": "NIFRA_OUTPUT_SENSITIVE_FIELD",
9827
10255
  "name": "OutputGuardError",
@@ -9916,7 +10344,8 @@ Schema that describes exactly the fields the page needs. `nifra check` flags rou
9916
10344
  without one (NF-C030): an error when the loader's own body returns a literal (an object,
9917
10345
  array, string, number or boolean), since every request that reaches that return fails, and a
9918
10346
  warning when only running it shows what it returns. `nifra schemas --write` drafts
9919
- a schema from the loader's return type for review.
10347
+ a schema from the loader's return type for review, and
10348
+ `nifra fix --code NF-C030` writes that draft for each flagged route.
9920
10349
 
9921
10350
  ### Rendering and data
9922
10351
 
@@ -9981,9 +10410,16 @@ its own.
9981
10410
 
9982
10411
  ### Silencing a nifra check finding
9983
10412
 
9984
- `nifra check` names each finding with an `NF-` code. Where a finding is
9985
- reviewed and intended, a comment on the flagged line, or anywhere in the comment block directly
9986
- above it, says so and why:
10413
+ `nifra check` names each finding with an `NF-` code;
10414
+ `nifra explain NF-C007` (or `nifra_explain` with the code as its
10415
+ `error`) says what the rule reports, why it matters, how to fix it and where it is
10416
+ documented. Where a finding is reviewed and intended, a comment on the flagged line, or anywhere
10417
+ in the comment block directly above it, says so and why:
10418
+
10419
+ ```ts
10420
+ // nifra-expect NF-S002: compares the challenge the sender echoes back, not a secret
10421
+ if (echoToken === challenge) return accept()
10422
+ ```
9987
10423
 
9988
10424
  The comment answers only the code it names. A finding that fails the check, and every security
9989
10425
  finding, is silenced only with a reason after the colon; an advisory also accepts the comment
@@ -9995,6 +10431,10 @@ as information, with the comment and its reason as evidence. Some codes also ans
9995
10431
  `@nifra-gate-reviewed` silences nothing; a finding under it names the comment to
9996
10432
  write instead.
9997
10433
 
10434
+ A fail-open gate (NF-S001) or a non-constant-time comparison (NF-S002) in code that only
10435
+ ever runs in a browser is a warning rather than an error: the server's own gate decides
10436
+ there.
10437
+
9998
10438
  ## Nifra - Failure laboratory
9999
10439
 
10000
10440
  > Replayable durable-failure schedules on virtual time: crash after commit, duplicate delivery, reordering, budget expiry, and checkpoint contention.
@@ -10295,8 +10735,12 @@ and import edits; this guide covers the structural changes it deliberately canno
10295
10735
 
10296
10736
  ### 1. Run the executable upgrade
10297
10737
 
10298
- ```ts
10299
-
10738
+ ```sh
10739
+ nifra upgrade 2.0.0 # dry-run: inspect every planned edit
10740
+ nifra upgrade 2.0.0 --write # apply edits, then run nifra check
10741
+ bun install
10742
+ bun run test
10743
+ bun run build
10300
10744
  ```
10301
10745
 
10302
10746
  The command updates existing `@nifrajs/*`, `Nifra`, and
@@ -10314,7 +10758,26 @@ only the systems an app uses with `.use()`; registration fails loudly if a requi
10314
10758
  plugin is missing.
10315
10759
 
10316
10760
  ```ts
10761
+ // doc-check: skip - migration fragment uses the application's existing stores and handlers
10762
+ // 1.x
10763
+ import "@nifrajs/core/ws"
10764
+ const app = server({ idempotencyStore, effectLedger: { sink } })
10765
+ .ws("/chat", socketHandler)
10317
10766
 
10767
+ // 2.0
10768
+ import { effectLedger } from "@nifrajs/core/effect-ledger"
10769
+ import { idempotency } from "@nifrajs/core/idempotency-plugin"
10770
+ import { mcp } from "@nifrajs/core/mcp"
10771
+ import { streaming } from "@nifrajs/core/sse"
10772
+ import { websocket } from "@nifrajs/core/ws"
10773
+
10774
+ const app = server()
10775
+ .use(idempotency({ store: idempotencyStore }))
10776
+ .use(effectLedger({ sink }))
10777
+ .use(mcp()) // only when the app declares tools/resources/prompts
10778
+ .use(streaming()) // only when the app declares SSE routes
10779
+ .use(websocket())
10780
+ .ws("/chat", socketHandler)
10318
10781
  ```
10319
10782
 
10320
10783
  The `@nifrajs/node` adapter installs `nodeDirect()` automatically.
@@ -10328,7 +10791,12 @@ contracts, assurance, capabilities, budgets, manifests, reflection, SSE, WebSock
10328
10791
  other optional systems from their documented subpaths.
10329
10792
 
10330
10793
  ```ts
10794
+ // doc-check: skip - before/after migration block includes the removed 1.x package
10795
+ // 1.x
10796
+ import { createRequestBudget } from "@nifrajs/budget"
10331
10797
 
10798
+ // 2.0
10799
+ import { createRequestBudget } from "@nifrajs/core/budget"
10332
10800
  ```
10333
10801
 
10334
10802
  Contract-generated adversarial testing lives in `@nifrajs/testing`; the deprecated
@@ -10343,7 +10811,17 @@ result of `inProcessClient(backend)` or `testClient(backend)`; both
10343
10811
  already implement the interface and forward `env` and `waitUntil`.
10344
10812
 
10345
10813
  ```ts
10814
+ // doc-check: skip - fragment uses the application adapter, manifest, and client entry
10815
+ import { inProcessClient } from "@nifrajs/client"
10816
+ import { createWebApp } from "@nifrajs/web"
10817
+ import { backend } from "./backend"
10346
10818
 
10819
+ const app = createWebApp({
10820
+ adapter,
10821
+ manifest,
10822
+ clientEntry,
10823
+ api: inProcessClient(backend),
10824
+ })
10347
10825
  ```
10348
10826
 
10349
10827
  ### 5. Declare external library mounts
@@ -10353,8 +10831,10 @@ Nifra typed contract. A relative fetch to that library is intentional, but other
10353
10831
  a hand-rolled own-API call. Declare only the exact mounted prefix in
10354
10832
  `nifra.check.json` so `nifra check` does not keep CI red:
10355
10833
 
10356
- ```ts
10357
-
10834
+ ```json
10835
+ {
10836
+ "externalMounts": ["/auth"]
10837
+ }
10358
10838
  ```
10359
10839
 
10360
10840
  Prefixes are segment-anchored: `/auth` covers `/auth` and its children,
@@ -10369,7 +10849,14 @@ After checking `!result.ok`, also narrow `result.status` before reading
10369
10849
  typed failure data. Undeclared statuses and transport status `0` remain unknown.
10370
10850
 
10371
10851
  ```ts
10372
-
10852
+ const result = await api.users({ id }).get()
10853
+ if (!result.ok) {
10854
+ if (result.status === 404) {
10855
+ result.data.message // typed from errors[404]
10856
+ } else {
10857
+ // Undeclared status or transport status 0: result.data is unknown.
10858
+ }
10859
+ }
10373
10860
  ```
10374
10861
 
10375
10862
  ### 7. Apply the remaining web and protocol changes
@@ -10378,7 +10865,11 @@ typed failure data. Undeclared statuses and transport status `0` remain unknown.
10378
10865
  Redirects accept an options object as their second argument.
10379
10866
 
10380
10867
  ```ts
10868
+ // 1.x
10869
+ redirect("/done", 307)
10381
10870
 
10871
+ // 2.0
10872
+ redirect("/done", { status: 307 })
10382
10873
  ```
10383
10874
 
10384
10875
  -
@@ -10430,8 +10921,12 @@ cannot guess, plus the Node proxy transport default.
10430
10921
 
10431
10922
  ### 1. Run the executable upgrade
10432
10923
 
10433
- ```ts
10434
-
10924
+ ```sh
10925
+ nifra upgrade 3.0.0 # dry-run: inspect every planned edit
10926
+ nifra upgrade 3.0.0 --write # apply edits, then run nifra check
10927
+ bun install
10928
+ bun run test
10929
+ bun run build
10435
10930
  ```
10436
10931
 
10437
10932
  The command pins every matching `@nifrajs/*`, `Nifra`, and
@@ -10464,7 +10959,19 @@ through the second argument, and assert on `.plain` in tests. A hand-rolled
10464
10959
  itself returns changed.
10465
10960
 
10466
10961
  ```ts
10962
+ // 2.x - a redirect was a Web Response
10963
+ const r = redirect("/done")
10964
+ r.status // 302
10965
+ r.headers.get("location")
10966
+ r instanceof Response // true
10967
+
10968
+ // 3.0 - a redirect is plain render data
10969
+ const r = redirect("/done")
10970
+ r.plain // { status, headers, body }
10971
+ r.toResponse() // build a Response only when something genuinely needs one
10467
10972
 
10973
+ // Add headers through the second argument; cookies still ride c.set as before.
10974
+ redirect("/done", { status: 307, headers: { "cache-control": "no-store" } })
10468
10975
  ```
10469
10976
 
10470
10977
  ### 3. Fix reserved typed-client segments
@@ -10476,7 +10983,13 @@ because the proxy resolves the reserved key before a path segment. The types now
10476
10983
  access at compile time instead of silently reaching the wrong node.
10477
10984
 
10478
10985
  ```ts
10986
+ // A route whose path segment spells a reserved client key
10987
+ // (get/post/put/patch/delete/head/options, subscribe/ws/index/then)
10988
+ // is no longer reachable by property access:
10989
+ api.posts.delete.get() // 3.0: type error - `delete` is a reserved verb key
10479
10990
 
10991
+ // The typed spelling is a call on the parent node with the segment:
10992
+ api.posts("delete").get() // reaches /posts/delete
10480
10993
  ```
10481
10994
 
10482
10995
  Run `nifra fix --code NF-C018` to rewrite the affected call sites. It reads them
@@ -10487,7 +11000,11 @@ from the compiler rather than a text search, so it finds every one and never mis
10487
11000
  both the table and `--json`. The set is exported as the one place it is written down.
10488
11001
 
10489
11002
  ```ts
11003
+ // doc-check: skip - fragment reads the exported reserved-key contract
11004
+ import { RESERVED_VERB_KEYS, RESERVED_EXACT_KEYS, reservedKeyFor } from '@nifrajs/client'
10490
11005
 
11006
+ reservedKeyFor('delete') // 'delete'
11007
+ reservedKeyFor('posts') // undefined
10491
11008
  ```
10492
11009
 
10493
11010
  ### 4. Review the Node proxy transport (only if you use it)
@@ -10497,7 +11014,15 @@ On Node, `@nifrajs/proxy` now defaults to the undici transport, shipped from the
10497
11014
  `createProxy` to override it.
10498
11015
 
10499
11016
  ```ts
11017
+ // doc-check: skip - fragment shows the Node transport default and its override
11018
+ import { createProxy } from '@nifrajs/proxy'
11019
+ import { undiciTransport } from '@nifrajs/proxy/undici'
10500
11020
 
11021
+ // 3.0 on Node: undici is the default transport.
11022
+ const proxy = createProxy({ target })
11023
+
11024
+ // Override it explicitly when a different transport is wanted:
11025
+ const custom = createProxy({ target, transport: undiciTransport() })
10501
11026
  ```
10502
11027
 
10503
11028
  ### 5. Run the release gates
@@ -10514,6 +11039,208 @@ If the project has `nifra.assurance.ts`, run `nifra assure --json`.
10514
11039
  Exercise every redirect path - loader, action, and layout gate - and, if the app proxies,
10515
11040
  each deploy adapter it uses.
10516
11041
 
11042
+ ## Nifra 5.0 migration guide - upgrade from 3.x or 4.x
11043
+
11044
+ > Upgrade a Nifra 3.x or 4.x application to 5.0: the chained upgrade command, the frontend/backend layout move and its follow-ups, drafted output schemas, the backend's HTTP mount, the 5.0 defaults that changed, and the release gates.
11045
+
11046
+ Nifra 4.0 split every app into a frontend and a backend half, and 5.0 enforces the split and
11047
+ changes a handful of defaults. The upgrade command pins the packages and moves imports; the
11048
+ layout migration moves files; this guide covers what each leaves to you and how to tell a
11049
+ finished migration from one that needs a decision.
11050
+
11051
+ ### 1. Run the executable upgrade
11052
+
11053
+ ```sh
11054
+ bunx @nifrajs/cli@5.0.0 upgrade 5.0.0 # dry run: every release step from the installed version
11055
+ bunx @nifrajs/cli@5.0.0 upgrade 5.0.0 --write # apply the pins and import moves
11056
+ bun install
11057
+ ```
11058
+
11059
+ Run the command from the release you are moving to. It chains every release recipe between
11060
+ the installed version and 5.0, so a 3.x app takes the 4.0 steps (the retired
11061
+ `@nifrajs/web/server-only` import moves to `@nifrajs/web/backend-only`)
11062
+ and the 5.0 ones in one pass, and prints each release's notes. It lists every
11063
+ `@nifra-gate-reviewed` comment, which silences nothing in 5.0: after review, write
11064
+ `// nifra-expect <code>: <reason>` with the code `nifra check`
11065
+ reports there. The upgrade never writes a reason for you.
11066
+
11067
+ ### 2. Move onto the frontend/backend layout (from 3.x)
11068
+
11069
+ ```sh
11070
+ nifra migrate layout # dry run: splits, moves, rewritten imports, issues
11071
+ nifra migrate layout --write # apply it
11072
+ nifra schemas --write # draft the output schemas it lists as follow-ups
11073
+ nifra check
11074
+ ```
11075
+
11076
+ Each route file splits into `x.tsx`, the page, and `x.backend.ts`, which
11077
+ holds `loader`, `action`, `middleware` and the other server
11078
+ exports. The root `backend.ts` and `framework.ts` move to
11079
+ `backend/app.ts` and `backend/framework.ts`, and every other module goes
11080
+ to `frontend/`, `backend/` or `shared/` by who imports it at
11081
+ runtime. A folder whose imported files all land in one zone moves whole, so a component nothing
11082
+ imports yet travels with its folder; a folder split between zones is reported instead.
11083
+
11084
+ ```tsx
11085
+ // doc-check: skip - a route split into its two halves
11086
+ // routes/notes.tsx - the page, shipped to the browser whole
11087
+ import type { loader } from "./notes.backend.ts"
11088
+ export default function Notes({ data }: { data: Awaited<ReturnType<typeof loader>> }) {
11089
+ return <ul>{data.notes.map((note) => <li key={note.id}>{note.title}</li>)}</ul>
11090
+ }
11091
+
11092
+ // routes/notes.backend.ts - loader, action, middleware and the other server exports
11093
+ import { t } from "@nifrajs/schema"
11094
+ export const loaderOutput = t.object({
11095
+ notes: t.array(t.object({ id: t.string(), title: t.string() })),
11096
+ })
11097
+ export async function loader() {
11098
+ return { notes: await listNotes() }
11099
+ }
11100
+ ```
11101
+
11102
+ To keep a folder where it is, declare it a zone before migrating. The migration leaves zoned
11103
+ folders in place, and builds, `nifra dev` and `nifra check` enforce them
11104
+ like the default folders.
11105
+
11106
+ ```json
11107
+ {
11108
+ "nifra": {
11109
+ "zones": {
11110
+ "frontend": ["src/ui"],
11111
+ "backend": ["server"]
11112
+ }
11113
+ }
11114
+ }
11115
+ ```
11116
+
11117
+ `nifra migrate layout --zones` writes those entries for you: every module the
11118
+ layout would move stays where it is, and `package.json` lists the widest folder
11119
+ whose files all belong to one side, or the file itself where its folder holds both. Route
11120
+ files are still split and the root entries still move. A path nested in another's folder
11121
+ overrides it, so a backend file can sit in a frontend folder without moving.
11122
+
11123
+ The command exits `0` when nothing needs a decision. A step with a known command,
11124
+ such as drafting an output schema for a backend half it did not write, is listed under
11125
+ `next` and in `followUps` with `--json`, and does not fail it;
11126
+ so is a moved path a module names only in comments, which is worth updating but changes
11127
+ nothing that runs. An issue (an import it could not place, a frontend that still uses a moved
11128
+ name at runtime, a moved path written in code or a string) exits `1`.
11129
+
11130
+ 5.0 refuses a route file that still exports a server name: `nifra build` and the
11131
+ server stop on it, and `nifra check` reports it as NF-C041.
11132
+ `nifra fix --code NF-C041` moves the export and the code only it uses into the
11133
+ route's backend half.
11134
+
11135
+ ### 3. Draft and review output schemas
11136
+
11137
+ A loader or action that returns data needs `loaderOutput` or
11138
+ `actionOutput`; the data is projected through it, so undeclared keys never reach
11139
+ the page. `nifra schemas --write` drafts each missing one from the function's return
11140
+ type, leaves out credential-like fields and marks it `nifra:generated` so later runs
11141
+ keep it current. A value typed `any` or `unknown` drafts as
11142
+ `t.json()`, which admits anything: `nifra schemas` lists those paths and
11143
+ `nifra check` warns on them (NF-C030). Give the value a type and draft again.
11144
+ `nifra schemas --check` fails on a missing, stale or open schema, for CI.
11145
+
11146
+ ### 4. Choose where the backend is served
11147
+
11148
+ 3.x and 4.x served `backend/app.ts` at `/api` by default. In 5.0
11149
+ `createWebApp` serves it over HTTP only at an `apiPrefix` the app sets;
11150
+ without one the backend is loader-only, reached in-process through `ctx.api`, and a
11151
+ browser call to `/api` reaches page routing. `nifra migrate layout` adds
11152
+ `apiPrefix = "/api"` when it moves a root `backend.ts`, and
11153
+ `nifra check` reports a framework config that sets none (NF-C035).
11154
+
11155
+ ```ts
11156
+ // doc-check: skip - backend/framework.ts
11157
+ export { reactAdapter as adapter } from "@nifrajs/web-react"
11158
+
11159
+ // Serve backend/app.ts at /api, as 3.x and 4.x did by default. "" keeps it loader-only.
11160
+ export const apiPrefix = "/api"
11161
+ ```
11162
+
11163
+ With both `nifra.config.ts` and `backend/framework.ts`, every command
11164
+ takes `apiPrefix`, `apiStrip`, `mounts`, `csp`,
11165
+ `nonce`, `serverComponents`, `use` and
11166
+ `publicEnvPrefix` from `backend/framework.ts` when
11167
+ `nifra.config.ts` leaves them unset. The
11168
+ backend sees each request's full path unless `apiStrip` is on, so its routes are
11169
+ registered under the prefix; `nifra routes` marks one outside it as in-process
11170
+ only, and `nifra dev` and `nifra build` warn about it.
11171
+
11172
+ An app that strips the prefix itself, with a `Proxy` or a wrapper around the
11173
+ backend's `fetch` that cuts `/api` before routing, gets that warning
11174
+ for every route: the check reads the registered paths, and a rewrite at run time is invisible
11175
+ to it. Delete the wrapper and export `apiStrip = true` beside
11176
+ `apiPrefix`, which does the same cut where the framework can see it. A second
11177
+ prefix the wrapper served (a `/v1` alias, a webhook path) becomes an entry in
11178
+ `mounts`.
11179
+
11180
+ ### 5. Review the 5.0 defaults that changed
11181
+
11182
+ -
11183
+ Root status pages (`_404.tsx`, `_<status>.tsx`) and
11184
+ `_error.tsx` render inside the layouts above them. One that imports the root
11185
+ layout to wrap itself renders it twice (NF-C034); remove the wrap, or export
11186
+ `inLayouts = false`.
11187
+
11188
+ -
11189
+ A layout's `meta` receives its own loader data as `data` and the page's
11190
+ as `pageData` (NF-C040).
11191
+
11192
+ -
11193
+ A WebSocket handshake runs the route chain an HTTP `GET` at the same point runs, so
11194
+ guards added before `app.ws()` apply to it.
11195
+
11196
+ -
11197
+ A `Response` returned to more than one request is no longer shared; build one per
11198
+ request.
11199
+
11200
+ -
11201
+ `nifra check` fails a secret comparison (NF-S002) outside browser code of a web
11202
+ app.
11203
+
11204
+ From 3.x, two 4.0 changes also show up in tests and tooling rather than in pages:
11205
+
11206
+ -
11207
+ Page data is handed over in one
11208
+ `<script type="application/json" id="__nifra-handover">`, not a script that
11209
+ assigns `window.__NIFRA_DATA__`. A test that read the data out of the HTML
11210
+ parses that element (`HANDOVER_ID` from `@nifrajs/web`).
11211
+
11212
+ -
11213
+ `x-nifra-isr-revalidate` and `x-nifra-isr-tags` are set only under a
11214
+ cache wrapper such as `withISR`, which removes them before responding. A test
11215
+ that read a page's TTL from them on an unwrapped app reads nothing.
11216
+
11217
+ `nifra upgrade` prints the full list with the finding or the one-line change that
11218
+ keeps the 4.x behavior for each.
11219
+
11220
+ Past 5.0, 5.1 adds one change a frontend on another origin sees. A route with a
11221
+ `body` schema answers a urlencoded, multipart or `text/plain` body whose
11222
+ `Origin` names another site with `403 forbidden_origin`, before reading
11223
+ it. List that frontend&rsquo;s origin, or an identity provider&rsquo;s for a
11224
+ `form_post` callback, in the `formOrigins` server option (an array of
11225
+ exact origins or a function; `@nifrajs/edge` takes it too). JSON bodies are
11226
+ unchanged. [Security](/docs/security) covers what the check leaves to
11227
+ `csrf()`.
11228
+
11229
+ ### 6. Run the release gates
11230
+
11231
+ -
11232
+ Run `nifra check --json` and fix every error. `nifra doctor` lists any
11233
+ package still on another release.
11234
+
11235
+ -
11236
+ If the project has `nifra.assurance.ts`, run `nifra assure --json`.
11237
+
11238
+ - Run the application test suite and a production build.
11239
+
11240
+ -
11241
+ Exercise the pages that load or post data, and every browser call to the backend, under
11242
+ `nifra dev` and against the production build.
11243
+
10517
11244
  ## Nifra - Migrating from Express, Hono, Fastify & Elysia
10518
11245
 
10519
11246
  > Move a backend to Nifra: routing, middleware, validation, and body parsing map directly from Express, Hono, Fastify, and Elysia - and you gain a typed client, multi-runtime deploy, and optional SSR.
@@ -10662,7 +11389,7 @@ Nifra's client router - `Link` + hover/focus prefetch, scroll restoration
10662
11389
  The biggest change: data fetching becomes a typed `loader` that calls your backend
10663
11390
  in-process during SSR - no `fetch` to your own API, no untyped JSON.
10664
11391
 
10665
- ```ts
11392
+ ```tsx
10666
11393
  // Next.js - app/users/[id]/page.tsx
10667
11394
  export default async function Page({ params }) {
10668
11395
  const res = await fetch(`https://api/users/${params.id}`)
@@ -10736,6 +11463,11 @@ mount small and temporary, and use typed routes for every migrated endpoint.
10736
11463
  `stripPrefix: true` when the legacy app declares paths relative to its mount point.
10737
11464
  The platform object is forwarded as the second argument when the runtime supplies one.
10738
11465
 
11466
+ A mounted fetch handler carries HTTP only. A WebSocket upgrade under the mount reaches it as
11467
+ an ordinary request and never becomes a socket, so keep the legacy app&apos;s sockets on its own
11468
+ server until they move to `app.ws()` routes (see
11469
+ [WebSockets in a composed app](/docs/websockets#composed)).
11470
+
10739
11471
  ```ts
10740
11472
  import { Hono } from "hono"
10741
11473
  import { server } from "@nifrajs/core/server"
@@ -10925,7 +11657,7 @@ only on Node, where `fetch` is undici.
10925
11657
  `GET /orders` reads through the cache, enqueues a job into a Postgres-backed store,
10926
11658
  and a separate worker process runs it. In Jaeger it is one trace:
10927
11659
 
10928
- ```ts
11660
+ ```text
10929
11661
  GET /orders orders-api server
10930
11662
  pg.query SELECT orders orders-api client (the cache loader)
10931
11663
  cache wrap orders-api internal outcome=miss
@@ -11431,19 +12163,48 @@ yes
11431
12163
  A file outside those folders joins a side with a suffix: `x.frontend.ts`,
11432
12164
  `x.backend.ts` or `x.shared.ts`. A workspace package declares its side
11433
12165
  in its `package.json`:
11434
- `{'"nifra": { "environment": "frontend" | "backend" | "shared" | "library" }'}`.
12166
+ `"nifra": { "environment": "frontend" | "backend" | "shared" | "library" }`.
11435
12167
  A file in no zone is a build error, so nothing is ever classified by accident.
11436
12168
 
12169
+ A package whose entries run on different sides gives each export subpath its own:
12170
+
12171
+ ```json
12172
+ {
12173
+ "name": "@shop/payments",
12174
+ "exports": {
12175
+ ".": "./src/index.ts",
12176
+ "./react": "./src/react.tsx",
12177
+ "./schema": "./src/schema.ts"
12178
+ },
12179
+ "nifra": {
12180
+ "environment": {
12181
+ ".": "backend",
12182
+ "./react": "frontend",
12183
+ "./schema": "library"
12184
+ }
12185
+ }
12186
+ }
12187
+ ```
12188
+
12189
+ An import is judged by the entry it names: the exact subpath first, then the most specific
12190
+ `*` pattern. Here a page may import `@shop/payments/react` but not
12191
+ `@shop/payments`, and backend code may not import the React entry, even when two
12192
+ entries are backed by one file. Importing an entry the map leaves out is an error. A file
12193
+ reached by path rather than by entry, through a relative or aliased deep import, takes the
12194
+ side of every mapped entry whose own imports reach it, and a file no mapped entry reaches is
12195
+ an error.
12196
+
11437
12197
  The app's own `package.json` can set sides too, so a folder that has to stay
11438
12198
  where it is, or a family of workspace packages, needs no edit of its own:
11439
12199
 
11440
- ```ts
12200
+ ```json
11441
12201
  {
11442
12202
  "name": "my-app",
11443
12203
  "nifra": {
11444
12204
  "zones": {
11445
12205
  "packages": { "@shop/*": "library", "@shop/db": "backend" },
11446
- "backend": ["migrations"]
12206
+ "backend": ["migrations", "src/ui/mailer.ts"],
12207
+ "frontend": ["src/ui"]
11447
12208
  }
11448
12209
  }
11449
12210
  }
@@ -11451,12 +12212,14 @@ where it is, or a family of workspace packages, needs no edit of its own:
11451
12212
 
11452
12213
  `packages` gives a side to a package that does not declare one, by exact name or
11453
12214
  by a prefix ending in `*`; a package's own declaration always wins.
11454
- `backend`, `frontend` and `shared` list app folders that
11455
- count as that zone folder. Builds, dev servers, `nifra check` and the editor
11456
- plugin all read this setting.
12215
+ `backend`, `frontend` and `shared` list app folders, or
12216
+ single files, that count as that zone. A path inside another's folder overrides it, so the
12217
+ most specific entry decides: above, `src/ui/mailer.ts` is backend code in a
12218
+ frontend folder. One path listed under two sides is refused. Builds, dev servers,
12219
+ `nifra check` and the editor plugin all read this setting.
11457
12220
 
11458
12221
  A project that serves no pages has no browser, so the zones do not apply to it. Declare that
11459
- in its `package.json` with `{'"nifra": { "kind": "api" }'}`:
12222
+ in its `package.json` with `"nifra": { "kind": "api" }`:
11460
12223
  `nifra check` then skips the zone checks and the server-only import check there,
11461
12224
  and treats every file as server code. It is read from the nearest `package.json`
11462
12225
  and only takes values `"api"` and `"web"`. A directory with web config
@@ -11524,7 +12287,7 @@ and `Route.ComponentProps` types `data` as exactly what
11524
12287
  `loaderOutput` lets through. `nifra dev`, `nifra build`,
11525
12288
  `nifra check` and `nifra types` write these files under
11526
12289
  `.nifra/types`; the app's `tsconfig.json` resolves them with
11527
- `{'"rootDirs": [".", "./.nifra/types"]'}`.
12290
+ `"rootDirs": [".", "./.nifra/types"]`.
11528
12291
 
11529
12292
  ### What may import what
11530
12293
 
@@ -11569,26 +12332,39 @@ import fails the build with the chain that led to it:
11569
12332
  -
11570
12333
  **Browser code reads only public environment variables** - `NODE_ENV` and
11571
12334
  names with the `PUBLIC_` prefix. Any other `process.env` read in a
11572
- page, `frontend/` or `shared/` fails the build.
12335
+ page, `frontend/` or `shared/` fails the build, optional access (
12336
+ `process.env?.["SECRET"]`) included.
11573
12337
 
11574
12338
  -
11575
12339
  **The build scans what it emits.** A client bundle, a public file or a prerendered page
11576
- that contains what looks like a credential fails the build.
12340
+ that contains what looks like a credential fails the build. A label in a message catalog (
12341
+ `{ password: "Password" }`) and a documented placeholder (
12342
+ `your-api-key`) are text, not credentials.
11577
12343
 
11578
12344
  The same rules run in `nifra dev` (a refused module is answered with a 403 before
11579
12345
  its source is sent), in both bundlers, for every framework, and in `nifra check`,
11580
12346
  which follows the imports the bundler follows: relative paths, tsconfig `paths`
11581
12347
  and `baseUrl`, `package.json` `imports`, and the
11582
- `clientModule` the browser entry loads. An app on the older layout moves with `nifra migrate layout`: a dry run that
11583
- reports every move, then `--write`. It follows the same imports, rewrites them
11584
- and test-runner mocks (an alias through the same alias), moves the config's
11585
- `clientModule` and component pipeline entries with their modules, adds the zone
11586
- folders to tsconfig `include` and `.nifra/` to
11587
- `.gitignore`, and leaves data files and folders zoned in
11588
- `package.json` where they are. It reports what still needs a hand, such as an
11589
- alias with no target that covers a moved file, or a specifier that names nothing installed.
11590
-
11591
- An API-only app, one that declares `{'"nifra": { "kind": "api" }'}` or has no web
12348
+ `clientModule` the browser entry loads. An app on the older layout moves with
12349
+ `nifra migrate layout`: a dry run that reports every move, then
12350
+ `--write`. It follows the same imports, rewrites them and test-runner mocks (an
12351
+ alias through the same alias), and moves the config's `clientModule`, any module
12352
+ path the config builds from its own folder, and component pipeline entries with their
12353
+ modules. A test moves with the file beside it, snapshots included. Each
12354
+ `tsconfig*.json` keeps every file in, or out of, its program as before. It adds
12355
+ `.nifra/` to `.gitignore` and leaves data files and folders zoned in
12356
+ `package.json` where they are.
12357
+
12358
+ A route file that holds server code splits into the page and its
12359
+ `x.backend.ts`. Data both halves read moves to `x.shared.ts` beside
12360
+ them; a value that cannot move is copied into each half and reported. A loader or action
12361
+ that returns data without an output schema gets a draft one, typed from what it returns:
12362
+ review that the browser may see every field it declares. The migration reports what still
12363
+ needs a hand, such as an alias with no target that covers a moved file, a specifier that
12364
+ names nothing installed, or a sibling workspace package that names a moved file. It never
12365
+ edits files outside the app.
12366
+
12367
+ An API-only app, one that declares `"nifra": { "kind": "api" }` or has no web
11592
12368
  config, no `routes/` and a `backend.ts` that exports
11593
12369
  `backend`, migrates as one: only
11594
12370
  `backend.ts` moves, to `backend/app.ts`, with the imports from it and
@@ -11939,8 +12715,10 @@ The tooling reads the backend `backend/app.ts` exports. An app that
11939
12715
  `implement`s a contract somewhere else, such as a `createApp(deps)`
11940
12716
  factory, is invisible to the contract lock and the route lints until that file serves it.
11941
12717
  `nifra check` names each implemented operation the backend does not serve
11942
- (NF-C039), and counts them when there is no `backend/app.ts` at all. Export the
11943
- same app built with stand-in dependencies:
12718
+ (NF-C039), and counts them when there is no `backend/app.ts` at all. It reads a
12719
+ contract imported from a workspace package through that package&apos;s
12720
+ `exports`; a package installed from a registry is never read, and the check says
12721
+ so rather than passing it. Export the same app built with stand-in dependencies:
11944
12722
 
11945
12723
  ```ts
11946
12724
  // backend/app.ts - the backend nifra's tooling reads
@@ -11978,7 +12756,7 @@ The same routes and schemas feed coding agents. `nifra context` prints the live
11978
12756
  API surface as compact text, and `nifra mcp` serves it over the Model Context
11979
12757
  Protocol so Claude Code or Cursor read the real contract instead of guessing.
11980
12758
 
11981
- ```ts
12759
+ ```sh
11982
12760
  $ nifra context # the same contract as compact text - pipe into any agent prompt
11983
12761
  GET /users/:id → params { id: string } response { id, name, role }
11984
12762
 
@@ -12037,7 +12815,7 @@ executor with nothing skipped.
12037
12815
 
12038
12816
  ### Run it
12039
12817
 
12040
- ```ts
12818
+ ```sh
12041
12819
  # What does this project prove right now?
12042
12820
  nifra levels
12043
12821
 
@@ -12048,7 +12826,7 @@ nifra levels --min 2
12048
12826
  nifra levels --json
12049
12827
  ```
12050
12828
 
12051
- ```ts
12829
+ ```text
12052
12830
  L0 typed contract ok
12053
12831
  L1 route assurance ok
12054
12832
  L2 capability lockfile ok
@@ -12132,6 +12910,46 @@ export default defineAssuranceConfig({
12132
12910
  })
12133
12911
  ```
12134
12912
 
12913
+ ### Response contracts
12914
+
12915
+ Next to the ladder, `nifra levels` counts the routes that declare a
12916
+ `response` or `errors` schema and how each is held at runtime:
12917
+ _enforced_, _warn-only_ (checked, original payload still sent) or _typed-only_
12918
+ (no `responseContract()` covers it). A typed-only route is usually registered on a
12919
+ server other than the one the plugin is installed on, or before it; the report names the routes
12920
+ and says which.
12921
+
12922
+ The count does not fail a level on its own. To make L1 require enforcement, add a
12923
+ `baseline` rule selecting `hasResponse: true`: unlike
12924
+ `rules`, where the first match owns a route, a baseline rule is checked on every
12925
+ route it matches, so one entry covers every class. A new app from `create-nifra`
12926
+ ships this baseline in its `nifra.assurance.ts`, beside the
12927
+ `responseContract("enforce")` its backend installs.
12928
+ `nifra assure --strict` also fails while any declared route is typed-only or
12929
+ warn-only.
12930
+
12931
+ ```ts
12932
+ // nifra.assurance.ts
12933
+ // doc-check: skip - the backend is app-specific
12934
+ import { defineAssuranceConfig, NIFRA_ASSURANCE } from "@nifrajs/core/assurance"
12935
+ import { backend } from "./backend"
12936
+
12937
+ export default defineAssuranceConfig({
12938
+ source: backend,
12939
+ policy: {
12940
+ rules: [/* first match owns each route: classify by path, method, capability ... */],
12941
+ // Checked on every route it matches, whichever rule owns the route.
12942
+ baseline: [
12943
+ {
12944
+ name: "response-contract",
12945
+ match: { hasResponse: true },
12946
+ require: [NIFRA_ASSURANCE.RESPONSE_CONTRACT],
12947
+ },
12948
+ ],
12949
+ },
12950
+ })
12951
+ ```
12952
+
12135
12953
  ### For coding agents
12136
12954
 
12137
12955
  The `nifra_levels` MCP tool returns the same
@@ -12303,9 +13121,11 @@ A suspended task's status message carries the pending continuation in `metadata`
12303
13121
  }
12304
13122
  ```
12305
13123
 
13124
+ The resuming peer is usually the agent that asked for the tool, so it does not approve its own call: the run asks `ports.approval` again and hands it the peer's `approval` as `callerDecision`. With no approval port the task stays `TASK_STATE_INPUT_REQUIRED`. Return `resumeApproval: "caller"` from `ports` only when the peer is the approver, such as a human operator's client.
13125
+
12306
13126
  Cross-request registries (cancellation, subscription fan-out, push notifications) are deliberately out of scope for the stateless seam; those spec methods answer `UnsupportedOperationError` (-32004).
12307
13127
 
12308
- A reply larger than `maxOutputBytes` answers the request with a JSON-RPC internal error (-32603, `output_limit`), the same error a stream sends when it runs out of budget. A request whose ports or store fail answers with -32603 `internal_error`, keeping the request's `id`.
13128
+ A reply larger than `maxOutputBytes` answers the request with a JSON-RPC internal error (-32603, `output_limit`), the same error a stream sends when it runs out of budget. A stream that runs out also aborts the run's signal, as a client disconnect does, so the run stops calling the model. A request whose ports or store fail answers with -32603 `internal_error`, keeping the request's `id`.
12309
13129
 
12310
13130
  The seam performs no authentication or authorization - wrap it with your app's route guards and scope every port in `ports(c)` to the caller.
12311
13131
 
@@ -12509,7 +13329,8 @@ adapter implementing the same `AgentEvidenceLog` interface.
12509
13329
  When more than one caller shares the route, also pass `evidenceOwner: (c) => <the caller's user or
12510
13330
  tenant id>`: turns are recorded and replayed under that owner, so another caller's reconnect or
12511
13331
  reused `runId` finds none of them. Without it a turn id (by default the client's `runId`) works as a
12512
- bearer capability. The owner function runs before any replay; throwing from it refuses the request.
13332
+ bearer capability. The owner function runs before any replay; throwing from it refuses the request with `403`, and a
13333
+ thrown `Response` answers the request as built, as one thrown from `ports` does.
12513
13334
 
12514
13335
  The seam performs no authentication or authorization - wrap it with your app's route guards and scope every port in `ports(c)` to the caller.
12515
13336
 
@@ -12603,7 +13424,9 @@ on from where the response stopped; without one the run is cancelled.
12603
13424
  When more than one caller shares the route, also pass `evidenceOwner: (c) => <the caller's user or
12604
13425
  tenant id>`: turns are recorded and replayed under that owner, so another caller's reconnect or
12605
13426
  reused `turnId` finds none of them. Without it a turn id works as a bearer capability. The owner
12606
- function runs before any replay; throwing from it refuses the request.
13427
+ function runs before any replay; throwing from it refuses the request with `403`, and a thrown
13428
+ `Response` answers the request as built, as one thrown from `ports` does. A JSON-mode run that
13429
+ throws answers `500 run_failed`, or `409 resume_unavailable` when the POST resumed a turn.
12607
13430
 
12608
13431
  Execution policies can be required by a tool contract. `createLocalProcessAdapter` applies cwd and
12609
13432
  environment filtering, timeouts, and cancellation to child processes. On POSIX each run leads its
@@ -12975,6 +13798,7 @@ How it holds the line:
12975
13798
 
12976
13799
  - **Post-decode body limits.** The body is decoded (base64 or UTF-8) and its real `byteLength` checked against `maxBodyBytes` (default 1,000,000 - match your app's setting if you changed it) *before* a `Request` is constructed. The event's own length claims are never trusted; over the limit answers a flat `413`.
12977
13800
  - **One header merge site.** Request headers come from the v2 `headers` map plus the separate `cookies` array in exactly one function; the array is canonical, so a `cookie` key smuggled into `headers` never reaches the app. Response `Set-Cookie` values travel in the result's `cookies` array, one entry each - never comma-joined.
13801
+ - **Body-less HEAD.** A `HEAD` answer keeps the GET route's status and headers but carries no body, on both handlers. A streaming body is cancelled rather than read, so its producer stops.
12978
13802
  - **Base64 honesty.** Response `isBase64Encoded` is decided by a strict UTF-8 decode of the actual bytes, never by content-type guessing. Binary round-trips exactly; text ships as text.
12979
13803
  - **Client IP.** `event.requestContext.http.sourceIp` feeds core's client-IP seam; `X-Forwarded-For` trust stays where it belongs, in the app's `clientIp` server option.
12980
13804
  - **Flat errors.** Uncaught failures collapse to the same `{"ok":false,"error":"internal_error"}` 500 as every other nifra runtime - the event is never echoed.
@@ -13226,6 +14050,9 @@ nifra sdk --lang <python|go> [--strict]
13226
14050
  nifra doctor [--json] [--auto-fix] Catch undeclared imports and duplicate Nifra/React installs.
13227
14051
  ```
13228
14052
 
14053
+ `nifra dev`, `build` and `start` take a flag's value as `--target vercel` or `--target=vercel`, and refuse
14054
+ a flag or argument they do not know instead of ignoring it.
14055
+
13229
14056
  ## `nifra doctor` - dependency health
13230
14057
 
13231
14058
  Doctor diffs source imports against declared dependencies, then resolves identity-sensitive
@@ -13266,7 +14093,8 @@ is the feedback plan and reports which release gates it omits. CI and release au
13266
14093
  `nifra verify --release` (or `bun run check:release`), which includes build, coverage, corpus,
13267
14094
  consumer, publish, and cross-runtime gates. Each gate runs a `package.json` script (`bun run lint`,
13268
14095
  `bun run check:docs`, ...); a gate whose script the project does not declare is reported as
13269
- `undeclared` and does not fail the run. Run `nifra port --ci --target <target>` for an app's
14096
+ `undeclared` and does not fail the run. The nifra repository's own `bun run verify` and
14097
+ `bun run check:release` fail that gate instead, so a renamed script cannot drop it. Run `nifra port --ci --target <target>` for an app's
13270
14098
  resolved deployment target; CI never guesses a target when none is configured.
13271
14099
 
13272
14100
  ## `nifra check` - the drift gate (run as "done")
@@ -13277,7 +14105,11 @@ remember them. It does three things and exits non-zero if any fails:
13277
14105
  1. **Typecheck** (`tsc --noEmit`, using the project's own TypeScript) - the frontend↔backend contract is
13278
14106
  compiler-enforced. `client<typeof app>` derives request inputs **and** `res.data` from your routes, so
13279
14107
  a screen that expects the wrong shape is a type error. Running the typecheck is what turns that latent
13280
- guarantee into an enforced one.
14108
+ guarantee into an enforced one. TypeScript sources with no `tsconfig.json` beside them fail this step,
14109
+ as a missing `typescript` install does: nothing typechecked them. A JavaScript-only project skips it.
14110
+ Every project `tsconfig.json` references is typechecked too, each as its own program; a project that
14111
+ splits its code across sibling configs lists them in `nifra.check.json`:
14112
+ `{ "tsconfigs": ["tsconfig.json", "tsconfig.server.json"] }`. A zoned file no program reads fails it.
13281
14113
  2. **Typed-client lint** - flags any hand-rolled `fetch()` to your own API (a relative URL like
13282
14114
  `fetch("/users")`), which bypasses the typed client so the compiler can't see the drift. External
13283
14115
  absolute-URL fetches are not flagged.
@@ -13511,6 +14343,14 @@ default 8 MiB) answers `409 resync_required`, so read `session.events` instead;
13511
14343
  `turn.send` while one runs answers `409 turn_running`; and a turn no client has followed for
13512
14344
  `detachedTimeoutMs` (default 2 minutes) is cancelled.
13513
14345
 
14346
+ An approval, or a coding tool's question to the person, is denied once it has waited 5 minutes.
14347
+ Pass `approvals: { timeoutMs }` to `CodingAgentHost` or `CodingAgentRpcServer` for up to 24 h, or
14348
+ `timeoutMs: "never"` to keep it until it is answered, cancelled, its turn ends, or the session
14349
+ closes; `maxPending` (default 32) still bounds how many can wait. `NifraBackend` has its own
14350
+ `approvalTimeoutMs`, taking the same values, and the host denies in the backend whatever its broker
14351
+ denies, so the shorter of the two applies. A never-expiring approval reports `expiresAt` as
14352
+ `APPROVAL_NEVER_EXPIRES_AT`, which survives JSON and stays later than any `Date.now()`.
14353
+
13514
14354
  `nifra-agent` loads `.nifra/extensions/**` from `--cwd` only when started with
13515
14355
  `--extensions`. An extension module's top-level code runs as soon as it is
13516
14356
  imported, before its declared `capabilities` are checked, so pass the flag only
@@ -13819,8 +14659,11 @@ cron.stop() // graceful - in-flight handlers finish
13819
14659
 
13820
14660
  Macros: `@hourly` `@daily` (`@midnight`) `@weekly` `@monthly` `@yearly` (`@annually`).
13821
14661
 
14662
+ Day-of-week runs 0-6 from Sunday, and 7 is Sunday too.
14663
+
13822
14664
  Day-of-month + day-of-week follow the **standard OR rule**: when both are restricted, a match on
13823
- either fires the job.
14665
+ either fires the job. A field that starts with `*` is not restricted, a step like `*/2` included,
14666
+ so `0 0 */2 * 1` fires on an odd day that is also a Monday, as in Vixie cron.
13824
14667
 
13825
14668
  ## Guarantees
13826
14669
 
@@ -13890,6 +14733,14 @@ cap live inside `app.fetch`, so they apply through this adapter automatically.
13890
14733
 
13891
14734
  Works with any `{ fetch(req): Promise<Response> }` handler, not just nifra. ESM/TS. MIT.
13892
14735
 
14736
+ ## WebSocket message size
14737
+
14738
+ `app.ws()` routes upgrade through `Deno.upgradeWebSocket`, which takes no size limit: Deno receives
14739
+ each inbound message whole (up to its own limit, 64 MiB on Deno 2.9) before the app sees it.
14740
+ `server({ wsMaxPayloadBytes })` then closes the socket with `1009` and keeps the message from your
14741
+ handler, but it cannot bound the memory Deno spent receiving it. Where that matters, cap message
14742
+ size in a proxy in front of the app. On Bun and Node the cap is enforced while the message arrives.
14743
+
13893
14744
  ## For AI agents
13894
14745
 
13895
14746
  Start with [`LLM.md`](./LLM.md) - this package's contract card (the exports you call + its footguns),
@@ -14109,8 +14960,11 @@ pass the request's bindings: `defineEnv(shape, { source: env })`.
14109
14960
  ## Secret safety
14110
14961
 
14111
14962
  Error messages name the offending variable and the reason - **never its value** (it may be a
14112
- secret). A BYO validator such as valibot may quote the value in its message; `defineEnv` replaces
14113
- it with `<redacted>`. `defineEnv` returns a frozen object, so a validated config can't be mutated downstream.
14963
+ secret). A BYO validator such as valibot or zod may quote the value in its message, escaped or
14964
+ cut short, so when it refuses a set value `defineEnv` reports the variable as invalid without the
14965
+ validator's message. For an unset variable the message is shown, since there is no value to quote.
14966
+ Use the `env.*` helpers when you want the reason as well. `defineEnv` returns a frozen object, so a
14967
+ validated config can't be mutated downstream.
14114
14968
 
14115
14969
  ## For AI agents
14116
14970
 
@@ -14250,6 +15104,7 @@ With `subscriptions: true`, a socket is admitted only when `authorize` accepts i
14250
15104
  | `allowedOrigins` | reflect `*` | CORS origin allowlist. |
14251
15105
  | `authorize` | - | Per-request guard; return `false` for 401. |
14252
15106
  | `enableGet` | `true` | Serve `GET /graphql` (queries only). |
15107
+ | `introspection` | `true` | `false` refuses `__schema` and `__type` as a validation error (400 over HTTP, an `error` frame over WS); `__typename` still resolves. Subscriptions inherit it unless their own options set it. |
14253
15108
  | `subscriptions` | `false` | `true` (reuse schema, context, `authorize` and limits) or explicit WS options. |
14254
15109
  | `legacyJsonResponse` | `false` | Old always-200 `application/json` shape. |
14255
15110
 
@@ -14306,6 +15161,17 @@ locales.documentMeta("ur") // { lang: "ur-PK", dir: "rtl" }
14306
15161
  Guard a `[lang]` route segment with `matchSegment()` in `routes/[lang]/_middleware.ts`: an unknown or
14307
15162
  draft value answers 404, and the default's prefix (`/en/...`) or a wrong case redirects.
14308
15163
 
15164
+ A page that exists in some locales only is declared once, with
15165
+ `defineI18nRouting(locales, { pageLocales: (pathname) => K[] | undefined })`: `matchSegment` answers
15166
+ 404 for the other locales, `alternates` lists only the page's own, `localesOf(path)` names them, and
15167
+ `localizePathname(path, locale, { fallback: "default" })` links to the default locale's page where the
15168
+ page is missing.
15169
+
15170
+ Register the router once, as `export const i18n = urls` in `backend/framework.ts`, and `@nifrajs/web`
15171
+ sets every document's `<html lang dir>` and `Content-Language` from it, guards `[lang]` and `[[lang]]`
15172
+ routes with `matchSegment`, and each adapter's `useLocale()` and `<I18nProvider>` read the page's
15173
+ locale.
15174
+
14309
15175
  ## Messages
14310
15176
 
14311
15177
  `createFormatter(locale, messages, options)` formats ICU messages: interpolation, `plural`,
@@ -14336,13 +15202,44 @@ entry exports a `rich()` that returns framework nodes (Svelte: `<Rich>` with one
14336
15202
  `localeCookie(name, locale)` is the browser half of the detector's `persist` cookie: assign it to
14337
15203
  `document.cookie` in a language switcher and it is byte-identical to the detector's `Set-Cookie`.
14338
15204
 
15205
+ ## Copy tables
15206
+
15207
+ `defineCopy(locales)` from `@nifrajs/i18n/copy` keeps a page's text and its translations beside the
15208
+ code that shows it, with no key to name. The default locale's value is required, an undeclared locale
15209
+ is a type error, and every other value has the default's shape. `copy.pick(table, locale)` falls back
15210
+ along `locales.chain()` and fires `onMissing` once per table and locale; `copy.format()` reads an ICU
15211
+ message.
15212
+
15213
+ ```ts
15214
+ import { defineCopy } from "@nifrajs/i18n/copy"
15215
+
15216
+ export const copy = defineCopy(locales, { onMissing: reportMissingCopy })
15217
+ export const TITLE = copy({ en: "Bicycle", hi: "साइकिल", ta: "மிதிவண்டி" })
15218
+ export const FAQ = copy.id("shop.faq", { en: ["Brakes?", "Gears?"], hi: ["ब्रेक?", "गियर?"] })
15219
+
15220
+ copy.pick(FAQ, "ta") // ["Brakes?", "Gears?"], from en
15221
+ ```
15222
+
15223
+ A production `@nifrajs/web` client build moves each table's values into one chunk per locale, so a
15224
+ page's JavaScript carries only the copy of the locale it renders in; the server keeps every table. It
15225
+ reads tables statically (literals, lists and blocks of them, same-module constants) with the app's
15226
+ TypeScript; a table written any other way keeps every locale in the bundle. `nifra i18n check` checks
15227
+ the tables of a `copy` export like catalogs, at each table's `file:line`; `tablesToCatalogs()` from
15228
+ `@nifrajs/i18n/check` is the pure transpose.
15229
+
14339
15230
  ## Checking catalogs
14340
15231
 
14341
15232
  `checkCatalogs({ locales, catalogs, ignore })` from `@nifrajs/i18n/check` reports coverage, missing
14342
15233
  and unused keys, ICU syntax errors, placeholder and rich-tag parity with the default message, plural
14343
15234
  cases the locale's grammar needs, script purity (`Intl.Locale(tag).maximize().script` against Unicode
14344
15235
  script properties - a Telugu sign in Gujarati, a Cyrillic `е` in English), and untranslated messages.
14345
- It is pure; `nifra i18n check [entry]` runs it over the module exporting `locales` and `catalogs`.
15236
+ It also catches partly translated text in a locale that does not write in Latin: `latin-share` reports
15237
+ a message of 6 words or more that is mostly Latin-script words (`latinWords` lists the brands a
15238
+ translation keeps), and each locale's coverage carries its `latinShare`; `volume` reports a long
15239
+ message translated to under a third of its length. `rules` adds the app's own checks, reported as
15240
+ `custom:<code>`.
15241
+ It is pure; `nifra i18n check [entry]` runs it over the module exporting `locales` and `catalogs`,
15242
+ and passes the rest of the options from its `check` export.
14346
15243
 
14347
15244
  ## Locale detection
14348
15245
 
@@ -14569,6 +15466,8 @@ fails at the call site, not three retries later.
14569
15466
 
14570
15467
  Per-job: `retries: number` (attempts) or `{ attempts, backoff }`. A handler that throws is routed to
14571
15468
  `onError`, then retried with the backoff delay; after the last attempt it's **dead-lettered**, not lost.
15469
+ An attempt count (and `createQueue({ defaultAttempts })`) must be a whole number; `NaN`, `Infinity` or
15470
+ a fraction throws a `RangeError`, and a count below 1 means one attempt.
14572
15471
 
14573
15472
  ```ts
14574
15473
  import { exponentialBackoff, fixedBackoff } from "@nifrajs/jobs"
@@ -14590,10 +15489,18 @@ const q = createQueue({ store: new RedisJobStore(redis) })
14590
15489
  Leasing is at-least-once: a leased job is hidden for `leaseMs`; a worker that dies mid-job releases it
14591
15490
  back automatically. Make handlers **idempotent**.
14592
15491
 
15492
+ While a handler runs, the worker renews its lease about three times per `leaseMs` through the store's
15493
+ optional `renew(id, until, lease)`, so a job that runs longer than `leaseMs` is not handed to another
15494
+ worker. A store without `renew` cannot do that: such a job may then run twice, on two workers, though
15495
+ never twice on the same queue. Each `lease` may also return a `lease` token on the job; the queue
15496
+ passes it back to `complete` / `retry` / `deadLetter` / `renew`, so a store can ignore a worker whose
15497
+ lease another worker has since taken. `MemoryJobStore` does both.
15498
+
14593
15499
  A job's `timeoutMs` bounds each attempt: one still running after that many ms fails with a
14594
15500
  `JobTimeoutError` (then retries or dead-letters), frees its worker slot, and aborts `ctx.signal`. Pass the
14595
- signal on to `fetch` or your driver, since a handler that ignores it keeps running unobserved. Keep
14596
- `timeoutMs` below `leaseMs`, after which the job can be leased again.
15501
+ signal on to `fetch` or your driver, since a handler that ignores it keeps running unobserved.
15502
+ `timeoutMs` must be below the worker's `leaseMs`: `start()` (and a later `define()`) throws a
15503
+ `RangeError` otherwise.
14597
15504
 
14598
15505
  ```ts
14599
15506
  q.define("render", { timeoutMs: 10_000, async handler(id, ctx) { await fetch(url(id), { signal: ctx.signal }) } })
@@ -16054,6 +16961,14 @@ Framework-agnostic SSR core for nifra - the render seam + HTML document orchestr
16054
16961
 
16055
16962
  Part of the **[nifra](https://nifra.dev)** full-stack TypeScript framework - one core, five UI libraries, every runtime. Scaffold a new app with `bun create nifra`.
16056
16963
 
16964
+ ## Guarding pages
16965
+
16966
+ A `_layout.backend.ts` loader is data, not a guard: a client navigation can skip it while the browser
16967
+ keeps the layout's data, and an action below it runs without it. Refuse access in that file's
16968
+ `middleware`, or export `gate = true` so its loader runs on every request and before every action,
16969
+ ahead of the page loader. In development, nifra warns when a layout loader without `gate` refuses a
16970
+ request, and `nifra check` reports one whose refusal it can read (NF-C042). See [Layout loaders on navigation](https://nifra.dev/docs/data).
16971
+
16057
16972
  ## Install
16058
16973
 
16059
16974
  ```sh
@@ -16545,7 +17460,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
16545
17460
 
16546
17461
  ## @nifrajs/coding-agent
16547
17462
 
16548
- `AGENT_CAPABILITY_MANIFEST_VERSION`, `AGENT_PRESETS`, `AgentCapability`, `AgentCapabilityManifest`, `AgentPlan`, `AgentPreset`, `AgentPresetName`, `ApprovalDecision`, `ApprovalManager`, `ApprovalManagerOptions`, `ApprovalMatchRejection`, `ApprovalMatchResult`, `ApprovalRequest`, `BoundedSubagentRunner`, `BoundedText`, `CapabilityDescriptor`, `CiDeploymentAdapter`, `CodingAgentExtension`, `CodingAgentHost`, `CodingAgentHostOptions`, `CodingAgentRpcServer`, `CodingAgentRpcServerHandle`, `CodingAgentRpcServerOptions`, `CompactionReport`, `ContextRecord`, `ContextWindow`, `ContextWindowOptions`, `DEPLOYMENT_REFERENCE_PROFILES`, `ExtensionCommand`, `ExtensionContext`, `ExtensionDescriptorOptions`, `ExtensionDescriptorSource`, `ExtensionEventHandler`, `ExtensionHost`, `ExtensionHostOptions`, `ExtensionProvider`, `ExtensionReloadResult`, `ExtensionSubagent`, `ExtensionTool`, `FileSessionStore`, `FileSessionStoreOptions`, `HandoffCoordinator`, `HandoffCoordinatorOptions`, `HandoffDecision`, `HandoffError`, `HandoffRejection`, `HandoffView`, `HealingEvent`, `HealingOptions`, `HealingResult`, `IsolatedExtensionSnapshot`, `IsolatedExtensionTool`, `IsolatedExtensionWorker`, `IsolatedExtensionWorkerOptions`, `LocalProcessDeploymentAdapter`, `MigrateLegacySessionOptions`, `NIFRA_AGENT_INSTRUCTIONS`, `NativeApprovalPort`, `NativeGatewayModelPortOptions`, `NativeMessage`, `NativeModelChunk`, `NativeModelPort`, `NativeModelRequest`, `NativeModelResponse`, `NativeTool`, `NifraAgentTool`, `NifraBackend`, `NifraBackendOptions`, `NifraContextOptions`, `NifraContextResult`, `OpenHandoffInput`, `PiBackend`, `PiBackendOptions`, `PlanEvent`, `PlanPhase`, `PlanResult`, `PlanRunner`, `PlanRunnerOptions`, `ProjectDiffOptions`, `ProjectDiffResult`, `RepairProposal`, `ReplayBackend`, `ReplayBackendOptions`, `ReplayDeploymentAdapter`, `ReviewExecutionErrorCode`, `ReviewExecutionResult`, `ReviewOptions`, `SESSION_EVIDENCE_VERSION`, `SelfHealingController`, `SessionEvidenceRecord`, `SessionLogEntry`, `SessionMigrationError`, `SessionMigrationReport`, `SessionStore`, `SubagentAbandonment`, `SubagentAbandonmentLedger`, `SubagentExecutor`, `SubagentResult`, `SubagentRunnerOptions`, `SubagentSpec`, `UiExtensionHost`, `UiExtensionHostOptions`, `UiExtensionManifest`, `UiExtensionSlot`, `UiReloadResult`, `UiStatusWidget`, `UiThemeDescriptor`, `VerificationOptions`, `VerificationRepairTask`, `VerificationResult`, `WorkflowContext`, `WorkflowEvent`, `WorkflowResult`, `WorkflowRunner`, `WorkflowRunnerOptions`, `WorkflowStep`, `approvalRequestFromEvent`, `approvalResolvedEvent`, `createCapabilityManifest`, `createCiDeploymentAdapter`, `createLocalProcessDeploymentAdapter`, `createNativeGatewayModelPort`, `createNifraTools`, `createPresetSpec`, `createReplayDeploymentAdapter`, `createVerificationRepairTask`, `deniedCapabilities`, `discoverExtensions`, `extensionDescriptor`, `extensionDescriptors`, `getAgentPreset`, `isSafeReviewDiff`, `isVerificationAvailable`, `migrateLegacySession`, `parseCapabilityManifest`, `parseSessionEvidenceRecord`, `readBoundedText`, `readProjectDiff`, `readReplayEvents`, `runNifraContext`, `runNifraReview`, `runNifraVerification`, `stableSessionEventCode`, `validateExtensionModule`
17463
+ `AGENT_CAPABILITY_MANIFEST_VERSION`, `AGENT_PRESETS`, `APPROVAL_NEVER_EXPIRES_AT`, `AgentCapability`, `AgentCapabilityManifest`, `AgentPlan`, `AgentPreset`, `AgentPresetName`, `ApprovalDecision`, `ApprovalManager`, `ApprovalManagerOptions`, `ApprovalMatchRejection`, `ApprovalMatchResult`, `ApprovalRequest`, `ApprovalTimeout`, `BoundedSubagentRunner`, `BoundedText`, `CapabilityDescriptor`, `CiDeploymentAdapter`, `CodingAgentExtension`, `CodingAgentHost`, `CodingAgentHostOptions`, `CodingAgentRpcServer`, `CodingAgentRpcServerHandle`, `CodingAgentRpcServerOptions`, `CompactionReport`, `ContextRecord`, `ContextWindow`, `ContextWindowOptions`, `DEPLOYMENT_REFERENCE_PROFILES`, `ExtensionCommand`, `ExtensionContext`, `ExtensionDescriptorOptions`, `ExtensionDescriptorSource`, `ExtensionEventHandler`, `ExtensionHost`, `ExtensionHostOptions`, `ExtensionProvider`, `ExtensionReloadResult`, `ExtensionSubagent`, `ExtensionTool`, `FileSessionStore`, `FileSessionStoreOptions`, `HandoffCoordinator`, `HandoffCoordinatorOptions`, `HandoffDecision`, `HandoffError`, `HandoffRejection`, `HandoffView`, `HealingEvent`, `HealingOptions`, `HealingResult`, `IsolatedExtensionSnapshot`, `IsolatedExtensionTool`, `IsolatedExtensionWorker`, `IsolatedExtensionWorkerOptions`, `LocalProcessDeploymentAdapter`, `MigrateLegacySessionOptions`, `NIFRA_AGENT_INSTRUCTIONS`, `NativeApprovalPort`, `NativeGatewayModelPortOptions`, `NativeMessage`, `NativeModelChunk`, `NativeModelPort`, `NativeModelRequest`, `NativeModelResponse`, `NativeTool`, `NifraAgentTool`, `NifraBackend`, `NifraBackendOptions`, `NifraContextOptions`, `NifraContextResult`, `OpenHandoffInput`, `PiBackend`, `PiBackendOptions`, `PlanEvent`, `PlanPhase`, `PlanResult`, `PlanRunner`, `PlanRunnerOptions`, `ProjectDiffOptions`, `ProjectDiffResult`, `RepairProposal`, `ReplayBackend`, `ReplayBackendOptions`, `ReplayDeploymentAdapter`, `ReviewExecutionErrorCode`, `ReviewExecutionResult`, `ReviewOptions`, `SESSION_EVIDENCE_VERSION`, `SelfHealingController`, `SessionEvidenceRecord`, `SessionLogEntry`, `SessionMigrationError`, `SessionMigrationReport`, `SessionStore`, `SubagentAbandonment`, `SubagentAbandonmentLedger`, `SubagentExecutor`, `SubagentResult`, `SubagentRunnerOptions`, `SubagentSpec`, `UiExtensionHost`, `UiExtensionHostOptions`, `UiExtensionManifest`, `UiExtensionSlot`, `UiReloadResult`, `UiStatusWidget`, `UiThemeDescriptor`, `VerificationOptions`, `VerificationRepairTask`, `VerificationResult`, `WorkflowContext`, `WorkflowEvent`, `WorkflowResult`, `WorkflowRunner`, `WorkflowRunnerOptions`, `WorkflowStep`, `approvalRequestFromEvent`, `approvalResolvedEvent`, `createCapabilityManifest`, `createCiDeploymentAdapter`, `createLocalProcessDeploymentAdapter`, `createNativeGatewayModelPort`, `createNifraTools`, `createPresetSpec`, `createReplayDeploymentAdapter`, `createVerificationRepairTask`, `deniedCapabilities`, `discoverExtensions`, `extensionDescriptor`, `extensionDescriptors`, `getAgentPreset`, `isSafeReviewDiff`, `isVerificationAvailable`, `migrateLegacySession`, `parseCapabilityManifest`, `parseSessionEvidenceRecord`, `readBoundedText`, `readProjectDiff`, `readReplayEvents`, `runNifraContext`, `runNifraReview`, `runNifraVerification`, `stableSessionEventCode`, `validateExtensionModule`
16549
17464
 
16550
17465
  ## @nifrajs/content
16551
17466
 
@@ -16553,7 +17468,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
16553
17468
 
16554
17469
  ## @nifrajs/core
16555
17470
 
16556
- `AdmissionController`, `AdmissionDecision`, `AnyServer`, `AuthHeaders`, `AuthMaybePromise`, `AuthenticationFailure`, `AuthenticationFailureReason`, `AuthenticationInput`, `AuthenticationResult`, `AuthenticationStage`, `AuthenticationSuccess`, `Context`, `ContextPlugin`, `CookieOptions`, `CookieSecret`, `DeclaredMountRoute`, `DefinePluginResult`, `DurableObjectNamespaceLike`, `ExecutionContext`, `FRAMEWORK_NAME`, `FetchApp`, `FrameworkError`, `FrameworkName`, `Handler`, `IdentityPlugin`, `InferInput`, `InferOutput`, `JoinRoutePath`, `LambdaEvent`, `LambdaHandler`, `LambdaResponse`, `LambdaV1Event`, `LambdaV2Event`, `ListenTlsOptions`, `LogFields`, `Logger`, `METHODS`, `McpPromptDescriptor`, `McpResourceDescriptor`, `Method`, `Middleware`, `MountFetchOptions`, `MountOptions`, `MountableApp`, `NetlifyEvent`, `NetlifyHandler`, `NifraFeatureVersion`, `NifraPlugin`, `NifraWebSocket`, `NodeRequestContext`, `NodeRequestHook`, `NodeResponseBodyHook`, `NodeResponseContext`, `NodeResponseHook`, `NodeServeOutcome`, `OnRequestResult`, `OpaqueMountDeclaration`, `Params`, `PlainRender`, `Platform`, `PlatformResponse`, `PluginTypeCollapsed`, `PrefixRegistry`, `Prettify`, `PromptArgument`, `PromptMessage`, `ROUTE_PATTERN_OVERLAP_MAX_STATES`, `RedactOptions`, `Registry`, `RequestPath`, `ResponseBodyHook`, `ResponseBodyReplacement`, `ResponseControls`, `ResponseFinalization`, `ResponseHeadersHook`, `ResponseHeadersView`, `ResponseMapFor`, `ResponseResult`, `RouteConfigError`, `RouteConfigErrorCode`, `RouteDescriptor`, `RouteInfo`, `RouteInfoFor`, `RouteMethod`, `RoutePatternOverlapLimitError`, `RouteSchema`, `Router`, `RouterMatch`, `RunningServer`, `SSEContext`, `SSEInit`, `SSEMessage`, `SSEStream`, `ScheduledController`, `ScheduledHandler`, `Server`, `ServerOptions`, `StandardIssue`, `StandardResult`, `StandardSchemaV1`, `StandardTypes`, `StandardWebSocket`, `StatusResponse`, `ToolAnnotations`, `TypedSSEStream`, `UrlParts`, `VERSION`, `ValidationOutcome`, `VercelHandler`, `Version`, `WebSocketContext`, `WebSocketData`, `WebSocketHandler`, `WebSocketUpgradeOutcome`, `authenticated`, `commonSecretPatterns`, `cookieNamePrefix`, `defineContextPlugin`, `defineIdentityPlugin`, `definePlugin`, `defineRouterPlugin`, `hasDuplicateCookie`, `isAuthenticatedRequest`, `isSameOriginPath`, `isSameOriginRequest`, `jsonLogger`, `markAuthenticatedRequest`, `parseCookies`, `pathnameOf`, `redactLogFields`, `rejected`, `replacedRequestOf`, `routePatternOverlap`, `serializeCookie`, `server`, `signValue`, `silentLogger`, `status`, `toFetchHandler`, `toLambdaHandler`, `toNetlifyHandler`, `toVercelHandler`, `unsignValue`, `urlPartsOf`, `writableResponse`
17471
+ `AdmissionController`, `AdmissionDecision`, `AnyServer`, `AuthHeaders`, `AuthMaybePromise`, `AuthenticationFailure`, `AuthenticationFailureReason`, `AuthenticationInput`, `AuthenticationResult`, `AuthenticationStage`, `AuthenticationSuccess`, `Context`, `ContextPlugin`, `CookieOptions`, `CookieSecret`, `DeclaredMountRoute`, `DefinePluginResult`, `DurableObjectNamespaceLike`, `ExecutionContext`, `FRAMEWORK_NAME`, `FetchApp`, `FrameworkError`, `FrameworkName`, `Handler`, `IdentityPlugin`, `InferInput`, `InferOutput`, `JoinRoutePath`, `LambdaEvent`, `LambdaHandler`, `LambdaResponse`, `LambdaV1Event`, `LambdaV2Event`, `ListenTlsOptions`, `LogFields`, `Logger`, `METHODS`, `McpPromptDescriptor`, `McpResourceDescriptor`, `Method`, `Middleware`, `MountFetchOptions`, `MountOptions`, `MountableApp`, `NetlifyEvent`, `NetlifyHandler`, `NifraFeatureVersion`, `NifraPlugin`, `NifraWebSocket`, `NodeRequestContext`, `NodeRequestHook`, `NodeResponseBodyHook`, `NodeResponseContext`, `NodeResponseHook`, `NodeServeOutcome`, `OnRequestResult`, `OpaqueMountDeclaration`, `Params`, `PlainRender`, `Platform`, `PlatformResponse`, `PluginTypeCollapsed`, `PrefixRegistry`, `Prettify`, `PromptArgument`, `PromptMessage`, `ROUTE_PATTERN_OVERLAP_MAX_STATES`, `RedactOptions`, `Registry`, `RequestPath`, `ResponseBodyHook`, `ResponseBodyReplacement`, `ResponseControls`, `ResponseFinalization`, `ResponseHeadersHook`, `ResponseHeadersView`, `ResponseMapFor`, `ResponseResult`, `RouteConfigError`, `RouteConfigErrorCode`, `RouteDescriptor`, `RouteInfo`, `RouteInfoFor`, `RouteMethod`, `RoutePatternOverlapLimitError`, `RouteSchema`, `Router`, `RouterMatch`, `RunningServer`, `SSEContext`, `SSEInit`, `SSEMessage`, `SSEStream`, `ScheduledController`, `ScheduledHandler`, `Server`, `ServerOptions`, `StandardIssue`, `StandardResult`, `StandardSchemaV1`, `StandardTypes`, `StandardWebSocket`, `StatusResponse`, `ToolAnnotations`, `TypedSSEStream`, `UrlParts`, `VERSION`, `ValidationOutcome`, `VercelHandler`, `Version`, `WebSocketContext`, `WebSocketData`, `WebSocketHandler`, `WebSocketUpgradeOutcome`, `authenticated`, `commonSecretPatterns`, `cookieNamePrefix`, `defineContextPlugin`, `defineIdentityPlugin`, `definePlugin`, `defineRouterPlugin`, `hasDuplicateCookie`, `isAuthenticatedRequest`, `isSameOriginForm`, `isSameOriginPath`, `isSameOriginRequest`, `jsonLogger`, `markAuthenticatedRequest`, `parseCookies`, `pathnameOf`, `redactLogFields`, `rejected`, `replacedRequestOf`, `routePatternOverlap`, `serializeCookie`, `server`, `signValue`, `silentLogger`, `status`, `toFetchHandler`, `toLambdaHandler`, `toNetlifyHandler`, `toVercelHandler`, `unsignValue`, `urlPartsOf`, `writableResponse`
16557
17472
 
16558
17473
  ## @nifrajs/cron
16559
17474
 
@@ -16665,7 +17580,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
16665
17580
 
16666
17581
  ## @nifrajs/web
16667
17582
 
16668
- `ACTION_GLOBAL`, `Action`, `BOUNDARY_GLOBAL`, `BackendOnly`, `Blocker`, `BlockerController`, `BlockerFunction`, `BlockerLocation`, `BlockerState`, `Boundary`, `BoundaryDescriptor`, `BoundaryError`, `BoundaryMode`, `BoundaryRegistration`, `BoundaryRequestCtx`, `BoundaryState`, `BoundaryStates`, `BoundaryStatus`, `BrowserNavigate`, `CacheStore`, `CachedResponse`, `CdnPurgeOutcome`, `CdnPurgeTarget`, `ClientAction`, `ClientActionArgs`, `ClientActionResult`, `ClientLoader`, `ClientLoaderArgs`, `ClientRequestBody`, `ClientRouteHooks`, `ClientRouter`, `ClientRouterOptions`, `CreateCspPolicyOptions`, `CreateNonceResolverOptions`, `CreateWebAppOptions`, `CspHeaderContext`, `CspPolicy`, `CssLoadingMode`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_CSS_LOADING`, `DEFAULT_DEV_PORT`, `DRAFT_COOKIE`, `Deferred`, `DehydratedState`, `DraftCookieControls`, `DynamicBoundary`, `DynamicBoundaryBatch`, `EnableDraftOptions`, `FetchRouteData`, `Fetcher`, `FetcherState`, `FontDisplay`, `FontFace`, `FontPreloadInput`, `FontSource`, `GenerateClientEntryOptions`, `GenerateRouteSearchTypesOptions`, `GenerateServerManifestOptions`, `GetStaticPaths`, `HANDOVER_ID`, `HtmlSanitizer`, `IDLE_BLOCKER`, `ISRApp`, `ISROptions`, `ISRPlatform`, `ISRQuery`, `ISRStoreOp`, `ISR_REVALIDATE_HEADER`, `ISR_REVALIDATE_TAGS_HEADER`, `ISR_STATUS_HEADER`, `InertScriptType`, `InfiniteData`, `InfiniteQueryHandle`, `InfiniteQueryOptions`, `InterceptBoundary`, `KVCacheStore`, `KVCacheStoreOptions`, `KVNamespaceLike`, `LAYOUT_DATA_GLOBAL`, `LayoutEntry`, `LinkDescriptor`, `Loader`, `LoaderContext`, `LoaderResponseControls`, `LoadingEntry`, `Manifest`, `MatchChain`, `MemoryCacheStore`, `MemoryCacheStoreOptions`, `MemoryStaticBoundaryCache`, `Meta`, `MetaArgs`, `MetaDescriptor`, `MetaInput`, `MiddlewareOutcome`, `MountRouterOptions`, `MutationCallbacks`, `MutationHandle`, `MutationState`, `MutationStatus`, `NAV_FROM_HEADER`, `NavigateFunction`, `NavigateOptions`, `NavigateSearchOf`, `NavigateTargetInput`, `NonceContext`, `NonceGenerator`, `NonceHeader`, `NonceHeaderContext`, `NonceResolver`, `NotFoundEntry`, `NotFoundScope`, `OpenGraphInput`, `PRE_HYDRATION_GUARD`, `PendingBoundary`, `PrefetchMode`, `PreviewEndpointOptions`, `PublicDirCache`, `QueryClient`, `QueryClientOptions`, `QueryHandle`, `QueryOptions`, `QueryState`, `QueryStatus`, `REDIRECT_HEADER`, `RETAIN_HEADER`, `REVALIDATE_HEADER`, `ROOT_ATTRIBUTE`, `ROUTE_GLOBAL`, `RedirectOptions`, `RenderAdapter`, `RenderAdapterConformanceError`, `RenderAdapterConformanceFixture`, `RenderAssemblyCache`, `RenderPageInput`, `RenderPageOptions`, `RenderProps`, `RenderStreamOptions`, `RenderedPage`, `RevalidateEndpointOptions`, `RevalidateResult`, `RevalidateTags`, `RevalidateTagsInput`, `RouteEntry`, `RouteMatch`, `RouteMiddleware`, `RouteModule`, `RoutePattern`, `RouteSearch`, `RouterState`, `SERVER_FN_MODULE`, `STATUS_HEADER`, `SanitizedHtml`, `ScriptDescriptor`, `SearchOf`, `ServePublicDirOptions`, `ShouldRevalidate`, `ShouldRevalidateArgs`, `SsrModuleLoader`, `StaticBoundary`, `StaticBoundaryCache`, `StaticBoundaryImportEdge`, `StaticBoundaryRoot`, `StaticCtx`, `StaticPath`, `StaticPaths`, `StaticRoutes`, `StatusPageOptions`, `Submission`, `SubmitOptions`, `TrustedHtml`, `UIMatch`, `UnsafeScriptDescriptor`, `assertCssLoadingCompatible`, `assertRenderAdapterConformance`, `assertStaticBoundaryImports`, `boundaryDescriptors`, `boundaryModeKey`, `buildManifest`, `canonical`, `createClientRouter`, `createCspPolicy`, `createMatcher`, `createMutation`, `createNonceResolver`, `createQueryClient`, `createWebApp`, `defer`, `disableDraft`, `enableDraft`, `enumerateStaticRoutes`, `filePathToPattern`, `filePathToPatterns`, `fontFace`, `fontPreload`, `generateClientEntry`, `generateRouteSearchTypes`, `generateServerManifest`, `getBrowserNavigate`, `gone`, `hashQueryKey`, `isCacheablePage`, `isDraftEnabled`, `jsonLd`, `mergeHeads`, `nifraScriptHashes`, `normalizeCssLoading`, `notFound`, `openGraph`, `previewEndpoint`, `redirect`, `registerBlocker`, `renderPage`, `renderPageResult`, `resolveChainMeta`, `resolveDynamicBoundaries`, `resolveMeta`, `resolveNavigate`, `resolvePublicPath`, `resolveStaticBoundaries`, `revalidate`, `revalidateEndpoint`, `sanitizeHtml`, `sanitizedHtml`, `searchOf`, `searchOfChain`, `serializeData`, `serializeSearch`, `servePublicDir`, `setBlockerController`, `setBrowserNavigate`, `setSsrModuleLoader`, `ssrModuleLoader`, `startDynamicBoundaries`, `statusPage`, `trustHtml`, `unsafeInlineScript`, `webProjectEvidence`, `withISR`
17583
+ `ACTION_GLOBAL`, `Action`, `BOUNDARY_GLOBAL`, `BackendOnly`, `Blocker`, `BlockerController`, `BlockerFunction`, `BlockerLocation`, `BlockerState`, `Boundary`, `BoundaryDescriptor`, `BoundaryError`, `BoundaryMode`, `BoundaryRegistration`, `BoundaryRequestCtx`, `BoundaryState`, `BoundaryStates`, `BoundaryStatus`, `BrowserNavigate`, `CacheStore`, `CachedResponse`, `CdnPurgeOutcome`, `CdnPurgeTarget`, `ClientAction`, `ClientActionArgs`, `ClientActionResult`, `ClientLoader`, `ClientLoaderArgs`, `ClientRequestBody`, `ClientRouteHooks`, `ClientRouter`, `ClientRouterOptions`, `CreateCspPolicyOptions`, `CreateNonceResolverOptions`, `CreateWebAppOptions`, `CspHeaderContext`, `CspPolicy`, `CssLoadingMode`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_CSS_LOADING`, `DEFAULT_DEV_PORT`, `DRAFT_COOKIE`, `Deferred`, `DehydratedState`, `DocumentParts`, `DraftCookieControls`, `DynamicBoundary`, `DynamicBoundaryBatch`, `EnableDraftOptions`, `FetchRouteData`, `Fetcher`, `FetcherState`, `FontDisplay`, `FontFace`, `FontPreloadInput`, `FontSource`, `GenerateClientEntryOptions`, `GenerateRouteSearchTypesOptions`, `GenerateServerManifestOptions`, `GetStaticPaths`, `HANDOVER_ID`, `HtmlSanitizer`, `IDLE_BLOCKER`, `ISRApp`, `ISROptions`, `ISRPlatform`, `ISRQuery`, `ISRStoreOp`, `ISR_REVALIDATE_HEADER`, `ISR_REVALIDATE_TAGS_HEADER`, `ISR_STATUS_HEADER`, `InertScriptType`, `InfiniteData`, `InfiniteQueryHandle`, `InfiniteQueryOptions`, `InterceptBoundary`, `KVCacheStore`, `KVCacheStoreOptions`, `KVNamespaceLike`, `LAYOUT_DATA_GLOBAL`, `LOCALES_GLOBAL`, `LayoutEntry`, `LinkDescriptor`, `Loader`, `LoaderContext`, `LoaderResponseControls`, `LoadingEntry`, `Manifest`, `MatchChain`, `MemoryCacheStore`, `MemoryCacheStoreOptions`, `MemoryStaticBoundaryCache`, `Meta`, `MetaArgs`, `MetaDescriptor`, `MetaInput`, `MiddlewareOutcome`, `MountRouterOptions`, `MutationCallbacks`, `MutationHandle`, `MutationState`, `MutationStatus`, `NAV_FROM_HEADER`, `NavigateFunction`, `NavigateOptions`, `NavigateSearchOf`, `NavigateTargetInput`, `NonceContext`, `NonceGenerator`, `NonceHeader`, `NonceHeaderContext`, `NonceResolver`, `NotFoundEntry`, `NotFoundScope`, `OpenGraphInput`, `PRE_HYDRATION_GUARD`, `PageLocale`, `PageLocales`, `PendingBoundary`, `PrefetchMode`, `PreviewEndpointOptions`, `PublicDirCache`, `QueryClient`, `QueryClientOptions`, `QueryHandle`, `QueryOptions`, `QueryState`, `QueryStatus`, `REDIRECT_HEADER`, `RETAIN_HEADER`, `REVALIDATE_HEADER`, `ROOT_ATTRIBUTE`, `ROUTE_GLOBAL`, `RedirectOptions`, `RenderAdapter`, `RenderAdapterConformanceError`, `RenderAdapterConformanceFixture`, `RenderAssemblyCache`, `RenderPageInput`, `RenderPageOptions`, `RenderProps`, `RenderStreamOptions`, `RenderedPage`, `RevalidateEndpointOptions`, `RevalidateResult`, `RevalidateTags`, `RevalidateTagsInput`, `RouteEntry`, `RouteMatch`, `RouteMiddleware`, `RouteModule`, `RoutePattern`, `RouteSearch`, `RouterState`, `SERVER_FN_MODULE`, `STATUS_HEADER`, `SanitizedHtml`, `ScriptDescriptor`, `SearchOf`, `ServePublicDirOptions`, `ShouldRevalidate`, `ShouldRevalidateArgs`, `SsrModuleLoader`, `StaticBoundary`, `StaticBoundaryCache`, `StaticBoundaryImportEdge`, `StaticBoundaryRoot`, `StaticCtx`, `StaticPath`, `StaticPaths`, `StaticRoutes`, `StatusPageOptions`, `Submission`, `SubmitOptions`, `TrustedHtml`, `UIMatch`, `UnsafeScriptDescriptor`, `WebAppI18n`, `assertCssLoadingCompatible`, `assertRenderAdapterConformance`, `assertStaticBoundaryImports`, `boundaryDescriptors`, `boundaryModeKey`, `buildManifest`, `canonical`, `createClientRouter`, `createCspPolicy`, `createMatcher`, `createMutation`, `createNonceResolver`, `createQueryClient`, `createWebApp`, `defer`, `disableDraft`, `enableDraft`, `enumerateStaticRoutes`, `filePathToPattern`, `filePathToPatterns`, `fontFace`, `fontPreload`, `generateClientEntry`, `generateRouteSearchTypes`, `generateServerManifest`, `getBrowserNavigate`, `gone`, `hashQueryKey`, `isCacheablePage`, `isDraftEnabled`, `jsonLd`, `localeOfProps`, `mergeHeads`, `nifraScriptHashes`, `normalizeCssLoading`, `notFound`, `openGraph`, `pageLocaleIn`, `previewEndpoint`, `redirect`, `registerBlocker`, `renderPage`, `renderPageResult`, `resolveChainMeta`, `resolveDynamicBoundaries`, `resolveMeta`, `resolveNavigate`, `resolvePublicPath`, `resolveStaticBoundaries`, `revalidate`, `revalidateEndpoint`, `sanitizeHtml`, `sanitizedHtml`, `searchOf`, `searchOfChain`, `serializeData`, `serializeSearch`, `servePublicDir`, `setBlockerController`, `setBrowserNavigate`, `setSsrModuleLoader`, `ssrModuleLoader`, `startDynamicBoundaries`, `statusPage`, `trustHtml`, `unsafeInlineScript`, `webProjectEvidence`, `withISR`
16669
17584
 
16670
17585
  ## @nifrajs/web-preact
16671
17586