@cratis/pi 8.5.0 → 8.6.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 (217) hide show
  1. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +5 -3
  2. package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -1
  3. package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -1
  4. package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +6 -3
  5. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
  6. package/package/corpus/rules/glossary.md +5 -3
  7. package/package/corpus/rules/react.md +3 -1
  8. package/package/corpus/rules/reactors.md +3 -1
  9. package/package/corpus/rules/specs.csharp.md +6 -3
  10. package/package/corpus/rules/vertical-slices.md +5 -2
  11. package/package/corpus/skills/cratis-application-growth/SKILL.md +1 -2
  12. package/package/corpus/skills/cratis-application-growth/references/csharp.md +0 -2
  13. package/package/corpus/skills/cratis-application-growth/references/move-and-untangle.md +1 -2
  14. package/package/corpus/skills/cratis-application-growth/references/rename-window.md +1 -3
  15. package/package/corpus/skills/cratis-application-growth/references/service-and-delivery.md +3 -2
  16. package/package/corpus/skills/cratis-application-growth/references/stages.md +2 -2
  17. package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +2 -2
  18. package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +19 -0
  19. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +15 -0
  20. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
  21. package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
  22. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +46 -7
  23. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-controller.md +3 -1
  24. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +4 -1
  25. package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +31 -4
  26. package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
  27. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +24 -2
  28. package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +49 -0
  29. package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +3 -1
  30. package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +27 -4
  31. package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
  32. package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +49 -2
  33. package/package/corpus/skills/cratis-arc-generate-proxies/references/typescript.md +9 -0
  34. package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
  35. package/package/corpus/skills/cratis-arc-host-application/references/csharp-configuration.md +54 -0
  36. package/package/corpus/skills/cratis-arc-host-application/references/csharp-deployment.md +98 -0
  37. package/package/corpus/skills/cratis-arc-host-application/references/csharp-http.md +9 -1
  38. package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +84 -2
  39. package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +2 -0
  40. package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
  41. package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +18 -1
  42. package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
  43. package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +18 -16
  44. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +8 -3
  45. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +84 -16
  46. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +22 -2
  47. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-instant-feedback.md +81 -0
  48. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +80 -0
  49. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-navigation.md +103 -0
  50. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +40 -1
  51. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-structure.md +117 -0
  52. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +7 -3
  53. package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +3 -3
  54. package/package/corpus/skills/cratis-arc-react-separate-view-model/references/typescript.md +27 -6
  55. package/package/corpus/skills/cratis-arc-validate-command/references/csharp-rules.md +23 -2
  56. package/package/corpus/skills/cratis-arc-validate-command/references/csharp.md +28 -2
  57. package/package/corpus/skills/cratis-authproxy-configure/SKILL.md +136 -0
  58. package/package/corpus/skills/cratis-authproxy-configure/references/admission.md +125 -0
  59. package/package/corpus/skills/cratis-authproxy-configure/references/aspire.md +154 -0
  60. package/package/corpus/skills/cratis-authproxy-configure/references/operations.md +122 -0
  61. package/package/corpus/skills/cratis-authproxy-configure/references/services-and-routing.md +114 -0
  62. package/package/corpus/skills/cratis-authproxy-configure/references/sessions-and-logout.md +126 -0
  63. package/package/corpus/skills/cratis-authproxy-configure/references/sign-in-providers.md +116 -0
  64. package/package/corpus/skills/cratis-authproxy-configure/references/tenant-resolution.md +135 -0
  65. package/package/corpus/skills/cratis-choreography-run-workflow/SKILL.md +117 -0
  66. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp-chronicle.md +164 -0
  67. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp.md +354 -0
  68. package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +2 -2
  69. package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +28 -0
  70. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp-services.md +13 -2
  71. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp.md +12 -0
  72. package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin.md +2 -0
  73. package/package/corpus/skills/cratis-chronicle-connect-application/references/typescript.md +10 -1
  74. package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +8 -1
  75. package/package/corpus/skills/cratis-chronicle-constrain-append/references/csharp.md +35 -3
  76. package/package/corpus/skills/cratis-chronicle-constrain-append/references/go.md +1 -1
  77. package/package/corpus/skills/cratis-chronicle-constrain-append/references/operations.md +70 -0
  78. package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +2 -0
  79. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +27 -0
  80. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/container-and-kubernetes.md +293 -0
  81. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +13 -6
  82. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +45 -0
  83. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +91 -1
  84. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +9 -0
  85. package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
  86. package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +11 -1
  87. package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +1 -1
  88. package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +1 -1
  89. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +14 -3
  90. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +3 -0
  91. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +3 -2
  92. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp.md +23 -0
  93. package/package/corpus/skills/cratis-chronicle-project-view/references/elixir.md +1 -0
  94. package/package/corpus/skills/cratis-chronicle-project-view/references/go.md +2 -1
  95. package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +2 -0
  96. package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +1 -0
  97. package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +1 -1
  98. package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +2 -0
  99. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +40 -3
  100. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +20 -2
  101. package/package/corpus/skills/cratis-chronicle-protect-decision/references/elixir.md +7 -0
  102. package/package/corpus/skills/cratis-chronicle-protect-decision/references/go.md +9 -1
  103. package/package/corpus/skills/cratis-chronicle-protect-decision/references/java.md +8 -0
  104. package/package/corpus/skills/cratis-chronicle-protect-decision/references/kotlin.md +9 -0
  105. package/package/corpus/skills/cratis-chronicle-protect-decision/references/typescript.md +7 -0
  106. package/package/corpus/skills/cratis-chronicle-protect-personal-data/references/csharp.md +24 -1
  107. package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +1 -1
  108. package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
  109. package/package/corpus/skills/cratis-chronicle-publish-contract/references/webhook-signature-wire-format.md +82 -0
  110. package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +17 -0
  111. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-outputs.md +3 -1
  112. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +35 -2
  113. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/elixir.md +11 -0
  114. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +1 -0
  115. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
  116. package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +1 -1
  117. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-coordination.md +31 -2
  118. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-history.md +21 -4
  119. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp.md +20 -2
  120. package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +1 -1
  121. package/package/corpus/skills/cratis-chronicle-record-event/references/java.md +1 -1
  122. package/package/corpus/skills/cratis-chronicle-record-event/references/kotlin.md +3 -0
  123. package/package/corpus/skills/cratis-chronicle-reduce-state/SKILL.md +2 -1
  124. package/package/corpus/skills/cratis-chronicle-reduce-state/references/csharp.md +3 -1
  125. package/package/corpus/skills/cratis-chronicle-reduce-state/references/java.md +10 -1
  126. package/package/corpus/skills/cratis-chronicle-reduce-state/references/kotlin.md +10 -1
  127. package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +27 -5
  128. package/package/corpus/skills/cratis-chronicle-select-client/SKILL.md +18 -0
  129. package/package/corpus/skills/cratis-chronicle-select-client/references/elixir.md +21 -1
  130. package/package/corpus/skills/cratis-chronicle-select-client/references/go.md +13 -0
  131. package/package/corpus/skills/cratis-chronicle-select-client/references/java.md +15 -0
  132. package/package/corpus/skills/cratis-chronicle-select-client/references/kotlin.md +15 -0
  133. package/package/corpus/skills/cratis-chronicle-select-client/references/typescript.md +16 -0
  134. package/package/corpus/skills/cratis-code-review/references/csharp-diagnostics.md +28 -2
  135. package/package/corpus/skills/cratis-code-review/references/csharp.md +1 -1
  136. package/package/corpus/skills/cratis-components-accessibility/SKILL.md +6 -8
  137. package/package/corpus/skills/cratis-components-accessibility/references/typescript.md +32 -14
  138. package/package/corpus/skills/cratis-components-build-canvas/SKILL.md +4 -3
  139. package/package/corpus/skills/cratis-components-build-canvas/references/typescript-props.md +1 -1
  140. package/package/corpus/skills/cratis-components-build-canvas/references/typescript.md +4 -2
  141. package/package/corpus/skills/cratis-components-choose-control/SKILL.md +13 -7
  142. package/package/corpus/skills/cratis-components-choose-control/references/from-primereact.md +116 -0
  143. package/package/corpus/skills/cratis-components-choose-control/references/menu.md +90 -0
  144. package/package/corpus/skills/cratis-components-choose-control/references/typescript-composition.md +48 -0
  145. package/package/corpus/skills/cratis-components-choose-control/references/typescript.md +2 -2
  146. package/package/corpus/skills/cratis-components-compose-toolbar/SKILL.md +2 -1
  147. package/package/corpus/skills/cratis-components-compose-toolbar/references/floating-toolbar.md +146 -0
  148. package/package/corpus/skills/cratis-components-diagnose-screen/SKILL.md +102 -0
  149. package/package/corpus/skills/cratis-components-display-list/SKILL.md +10 -10
  150. package/package/corpus/skills/cratis-components-display-list/references/typescript-custom-panel.md +74 -0
  151. package/package/corpus/skills/cratis-components-display-list/references/typescript-datatables.md +2 -7
  152. package/package/corpus/skills/cratis-components-display-list/references/typescript.md +3 -2
  153. package/package/corpus/skills/cratis-components-submit-form/references/typescript-commandform.md +72 -2
  154. package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +5 -3
  155. package/package/corpus/skills/cratis-components-theme-application/SKILL.md +17 -15
  156. package/package/corpus/skills/cratis-components-theme-application/references/localization.md +166 -0
  157. package/package/corpus/skills/cratis-components-theme-application/references/typescript.md +18 -14
  158. package/package/corpus/skills/cratis-components-theme-application/references/upgrade-from-previous-major.md +141 -0
  159. package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +2 -0
  160. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-domain-philosophy.md +31 -3
  161. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-fundamentals-helpers.md +119 -0
  162. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp.md +4 -0
  163. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +70 -0
  164. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +8 -0
  165. package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +1 -0
  166. package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +33 -0
  167. package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
  168. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +5 -0
  169. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/go-dependency-injection.md +3 -0
  170. package/package/corpus/skills/cratis-modeling-design-event-model/SKILL.md +6 -4
  171. package/package/corpus/skills/cratis-modeling-design-event-model/references/command-inventory.md +7 -1
  172. package/package/corpus/skills/cratis-modeling-design-event-model/references/model-first.md +13 -1
  173. package/package/corpus/skills/cratis-modeling-design-event-model/references/review-one-slice.md +6 -0
  174. package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +6 -6
  175. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/csharp-aspire.md +116 -28
  176. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/docker-compose.md +2 -2
  177. package/package/corpus/skills/cratis-observability/references/chronicle-kernel-export.md +46 -0
  178. package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +4 -2
  179. package/package/corpus/skills/cratis-platform-build-application/SKILL.md +8 -0
  180. package/package/corpus/skills/cratis-platform-build-application/references/cratis-identity.md +71 -0
  181. package/package/corpus/skills/cratis-platform-build-application/references/studio-repository.md +96 -0
  182. package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +14 -8
  183. package/package/corpus/skills/cratis-platform-deliver-slice/references/csharp.md +167 -3
  184. package/package/corpus/skills/cratis-platform-deliver-slice/references/eventual-consistency.md +150 -0
  185. package/package/corpus/skills/cratis-platform-diagnose-slice/SKILL.md +1 -1
  186. package/package/corpus/skills/cratis-platform-start-application/SKILL.md +21 -0
  187. package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +77 -3
  188. package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +118 -0
  189. package/package/corpus/skills/cratis-platform-upgrade-application/references/csharp.md +117 -0
  190. package/package/corpus/skills/cratis-platform-upgrade-application/references/java.md +53 -0
  191. package/package/corpus/skills/cratis-platform-upgrade-application/references/kotlin.md +53 -0
  192. package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +71 -0
  193. package/package/corpus/skills/cratis-screenplay-accept-model/references/csharp.md +29 -0
  194. package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +82 -1
  195. package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +1 -1
  196. package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +10 -0
  197. package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +5 -4
  198. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/cli.md +19 -2
  199. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/smallest-model.md +87 -0
  200. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/typescript.md +13 -0
  201. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
  202. package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +2 -0
  203. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-colocated.md +101 -0
  204. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +3 -1
  205. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-decision-reads.md +1 -0
  206. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +1 -0
  207. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +4 -2
  208. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +3 -3
  209. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +34 -1
  210. package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
  211. package/package/corpus/skills/cratis-specifications-isolate-behavior/SKILL.md +1 -1
  212. package/package/corpus/skills/cratis-specifications-isolate-behavior/references/csharp-running.md +10 -3
  213. package/package/corpus/skills/cratis-specifications-test-application-ui/references/typescript.md +22 -4
  214. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/SKILL.md +2 -1
  215. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/references/typescript.md +40 -0
  216. package/package/profile-catalog.json +15 -0
  217. package/package.json +1 -1
@@ -1,5 +1,16 @@
1
1
  # Generate TypeScript clients from a C# project
2
2
 
3
+ ## Contents
4
+
5
+ - Generate and verify
6
+ - Match the running endpoints
7
+ - Choose outputs only when needed
8
+ - What the build owns in the output tree
9
+ - Map namespaces and types
10
+ - Compare output or inspect validation without publishing
11
+ - Not supported in this SDK
12
+ - Common mistakes
13
+
3
14
  Build the project that owns the Arc endpoints. `Cratis` brings in `Cratis.Arc.ProxyGenerator.Build`; when using `Cratis.Arc` alone, reference the build package explicitly. Use the matching `@cratis/arc` client in the frontend. Names below are illustrative.
4
15
 
5
16
  ## Generate and verify
@@ -12,6 +23,8 @@ For an existing `ReserveRoom` command in `Venue.Rooms`, add this to `Venue.cspro
12
23
  </PropertyGroup>
13
24
  ```
14
25
 
26
+ Set every `CratisProxies*` property in the project file, or in `Directory.Build.targets` to share it between projects. Never use `Directory.Build.props`: the build package assigns its defaults after that file is read, so the output path, segments to skip, API prefix, library mode, incremental reuse, output deletion and the two name-in-route switches set there are overwritten.
27
+
15
28
  Run `dotnet build Venue.csproj`. The after-build target passes the compiled assembly to the generator; make its project dependencies available alongside the assembly. Normal discovery starts with commands, queries and typed identity details and follows referenced models. Under default conventions, import `ReserveRoom` from `./generated/Venue/Rooms/ReserveRoom` in a module beside `generated`. Inspect the payload, result and `/api/venue/rooms/reserve-room` route, then type-check the frontend. Snapshot and observable query methods generate different clients; generated React helpers follow the query kind and cardinality, not the read model's name.
16
29
 
17
30
  ## Match the running endpoints
@@ -38,16 +51,26 @@ These examples are MSBuild property assignments (e.g. `<CratisProxiesFramework>n
38
51
 
39
52
  - `CratisProxiesSkip=true` or `DisableProxyGenerator=true`: skip generation even with a destination. Leaving `CratisProxiesOutputPath` empty disables generation; `CratisProxiesSuppressOutputPathMessage=true` silences the empty-path notice.
40
53
  - `CratisProxiesIncremental=false`: force discovery instead of reusing the fingerprint and recorded outputs under `$(IntermediateOutputPath)`. It does not disable the per-file write shortcut. For a damaged file, remove that generated file and rebuild.
41
- - `CratisProxiesSkipOutputDeletion=false`: **recursively delete the entire output tree** before generating; use only on a disposable directory, with incremental reuse disabled for a forced reset. Normally the build keeps the directory but still removes stale generated-marked files. `CratisProxiesSkipFileIndexTracking` is forwarded but not parsed; it cannot retain orphans.
54
+ - `CratisProxiesSkipOutputDeletion=false`: **recursively delete the entire output tree** before generating; use only on a disposable directory, with incremental reuse disabled for a forced reset. That removes every stale file, with or without a marker or a record of the previous build. Normally the build keeps the directory and removes a stale file only when it carries the generated marker and the previous build recorded it (see "What the build owns in the output tree"). `CratisProxiesSkipFileIndexTracking` is forwarded but not parsed; it cannot retain orphans.
42
55
  - `CratisProxiesUseSourceFileAsOutputFile=true`: group by C# source filename instead of per type when method debug info in an embedded or adjacent portable PDB identifies the document. Unresolved types (often enums) keep separate files.
43
56
  - `CratisProxiesUseProxyFileSuffix=true`: write `ReserveRoom.proxy.ts`; update handwritten direct imports. Generated imports and barrels follow the suffix.
44
57
  - `CratisProxiesSkipIndexGeneration=true`: skip writing folder `index.ts` exports. Keep handwritten barrels outside the output tree: skipping writes does not prevent cleanup.
45
58
  - `CratisProxiesFileHeader=Venue contracts\n{fileName}`: emit comment lines with the generated filename substituted. Unset or empty uses `file_header_template` from `.editorconfig`, read only from `[*]`, `[*.cs]` and `[*.{…}]` lists with an exact `cs` entry such as `[*.{ts,cs}]` (`[*.{ts, cs}]`, path-specific and TypeScript-only sections are ignored); otherwise no custom header. `none` (any case) suppresses the fallback, not tracking metadata. An existing `index.ts` updated in place keeps its comments and gets no new header; only newly created ones get it. Full output deletion removes existing indexes, and orphan-directory cleanup can too. After changing the header, edit the header comment in surviving `index.ts` files by hand; deleting them to get the new header loses any handwritten lines they hold.
46
59
  - `CratisProxiesLibraryMode=true`: also collect public concrete types, interfaces and enums from project assemblies even without endpoint references. Open generic definitions are not concrete model roots.
47
60
  - `CratisProxiesEmitInterfaces=true`: render plain model shapes rather than decorated classes. Use for data-only contracts, not where query/identity deserialization needs constructors. Command/query clients themselves remain classes.
61
+ - `CratisProxiesClientValidation=server`: emit no generated client rule validators, so a request that reaches the server gets its validation messages from the server, resolved for the request (language, tenant). The mode only suppresses generated validators; it adds no server validation, and a validator Arc does not discover still does not run there. Use it when messages are localized or come from a message lambda. The default `mirrored` emits validators for the projectable rules; a blocking one stops the request in the browser and shows the wording fixed at build time (a literal message, or the client rule's default when the server message is a lambda). Before switching, remove application imports of the generated validator classes, then rebuild. Required-property and required-query-parameter checks, route argument checks and handwritten client validators still run in both modes and can still stop a request in the browser. `mirrored` and `server` are the only values.
48
62
  - `CratisProxiesFramework=none`: omit React helpers but retain executable Arc client classes; default is React.
49
63
  - `CratisAvailabilityManifest=$(MSBuildProjectDirectory)/obj/availability.json`: export discovered command/read-model parts, slice locations and availability gates for tooling. This does not enforce access.
50
64
 
65
+ ## What the build owns in the output tree
66
+
67
+ - **Generated files** carry a `// @generated by Cratis` marker line. When a command, query or type is renamed or removed, the next build deletes its stale file only when all of these hold: the file is a `.ts` file that still carries the marker, the previous successful build of the project recorded it as its output, and this build does not produce it. Files without the marker are never deleted as stale. With `CratisProxiesIncremental=false`, or after that record under `$(IntermediateOutputPath)` is lost (a cleaned `obj`, a fresh checkout), stale files stay: delete them by hand. These conditions apply while the build keeps the output tree, which is the default. With `CratisProxiesSkipOutputDeletion=false` the whole tree is deleted before generating, so stale files go with it whatever their marker or record. There is no separate tracking index in the frontend to create, commit or repair.
68
+ - **One output tree per generating build.** Give each generating project (and each endpoint group) its own output directory; a build that regenerates from scratch (`CratisProxiesSkipOutputDeletion=false`) deletes the whole tree, including another build's files.
69
+ - **`index.ts` is merged, not owned.** It carries no marker. Unless `CratisProxiesSkipIndexGeneration=true`, the build merges the `index.ts` of each folder it generates a file into, and of folders whose `index.ts` the previous build recorded; other folders are left alone. There it adds an `export * from './<file>'` line for every generated file in the folder, removes relative `export * from` lines whose target no longer exists, and keeps the rest: `export * from` lines for handwritten `.ts`/`.tsx` files, for a subfolder with its own `index.ts`/`index.tsx` and for packages, plus any other line (imports, comments, named exports). Kept lines that are not `export * from` are moved above the exports and blank lines are dropped. A relative target is checked by its name inside the index's own folder, whatever leading `./` or `../` it has: `export * from '../Shared'` is kept only if that folder itself holds `Shared.ts`, `Shared.tsx` or a `Shared` subfolder with its own index, and is removed otherwise. Re-export a parent or sibling folder from a barrel outside the output tree.
70
+ - A handwritten file is not exported automatically: add its `export * from` line yourself; the build then keeps it.
71
+ - **A handwritten barrel in a generated folder becomes recorded.** Unless `CratisProxiesSkipIndexGeneration=true`, each build records the `index.ts` of every folder it generates a file into, also one you wrote yourself before the first proxy landed there. When a stale generated file is deleted from a folder that then holds no other `.ts`/`.tsx` file and no subfolder, the build removes that folder's `index.ts` if the previous build recorded it, handwritten lines included, and then the folder when it is empty. An `index.ts` that was not recorded stays, and so does its folder. A barrel that must survive on its own belongs outside the output tree.
72
+ - **A surviving barrel can keep a stale export.** When the last generated file leaves a folder that a handwritten `.ts`/`.tsx` file or a subfolder keeps alive, the build deletes the stale file but does not rewrite that folder's `index.ts`: its `export * from` line for the removed file stays and breaks the TypeScript compile. Remove that line by hand.
73
+
51
74
  ## Map namespaces and types
52
75
 
53
76
  Add only the needed MSBuild items. `Include` identifies the item; the named metadata configures generation.
@@ -65,6 +88,19 @@ Add only the needed MSBuild items. `Include` identifies the item; the named meta
65
88
 
66
89
  The longest matching namespace root redirects its subtree; `Folder=""` strips that prefix without replacing it. A root's `Namespace` decides both the output folder and the slice location of commands and queries; its `Folder` changes only the output path. Roots never change URLs. A `TypeToTsType` mapping is checked ahead of the built-in mappings wherever a type goes through that lookup; it cannot target one property. Enums and dictionaries are resolved before the lookup, a concept is looked up by its underlying value type rather than its own name, and dictionary keys use only the built-in mappings. An item without `TypeName` or `TsType` is skipped with an "ignoring unusable --type-to-ts entry" warning in the build output. Map only to a compatible wire shape; omit `Package` for inline TypeScript types, supply it for imported names. A `ConceptAs` class hydrates itself. Any other imported class that wraps a scalar needs a `JsonConverter<T>` registered with `JsonSerializer.registerConverter` at client startup (see `cratis-fundamentals-concept`), unless one is already registered: Fundamentals ships converters for its own `Guid`, `DateOnly`, `TimeOnly` and `TimeSpan`. Without a converter, deserialization calls the class's no-argument constructor and ignores the wire value, so the result does not hold the sent value. Assembly mappings reuse exports from a client package rather than emitting copies. Exclusions remove unwanted types/subtrees; compile callers to catch missing dependencies. No special setting is needed for indirect scalar concepts: a record derived via an intermediate `ConceptAs<string>` record maps to the underlying string.
67
90
 
91
+ Built-in mappings, used unless a `TypeToTsType` item replaces them:
92
+
93
+ | C# type | TypeScript type |
94
+ | --- | --- |
95
+ | `byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, `decimal` | `number`. A `long`, `ulong` or `decimal` beyond what a JavaScript number holds exactly loses precision in the browser; send such a value as a string concept. |
96
+ | `string`, `char`, `Uri` | `string` |
97
+ | `bool` | `boolean` |
98
+ | `DateTime`, `DateTimeOffset` | `Date` |
99
+ | `Guid`, `DateOnly`, `TimeOnly`, `TimeSpan` | The type of the same name from `@cratis/fundamentals` |
100
+ | `Point`, `LineString`, `Polygon` from `Cratis.Geospatial` | The type of the same name from `@cratis/fundamentals` |
101
+ | `object`, `JsonNode`, `JsonObject`, `JsonDocument` | `Record<string, unknown>` |
102
+ | `JsonArray` | `Record<string, unknown>[]` on a generated property: it is treated as a collection of that shape |
103
+
68
104
  ## Compare output or inspect validation without publishing
69
105
 
70
106
  Use the packaged executable directly with the same compiled input and generation arguments as the build. In these shell examples `generator` is the absolute path to `Cratis.Arc.ProxyGenerator.Build.dll` from the build task directory; `assembly`, `out` and `scratch` are absolute paths, `scratch` being a disposable directory. This is not a globally installed CLI.
@@ -74,7 +110,17 @@ dotnet "$generator" "$assembly" "$out" --skip-output-deletion --check
74
110
  dotnet "$generator" "$assembly" "$scratch" --validation-report=json --validation-report-file="$PWD/validation.json"
75
111
  ```
76
112
 
77
- For a drift gate build the input with `-p:CratisProxiesSkip=true` first so the build does not repair the evidence. That build runs no generator, so take the exact arguments from the generator command in a normal-verbosity log (`dotnet build -v:n`) of an earlier generation-enabled build, or of a separate build whose `CratisProxiesOutputPath` is a disposable directory. The build runs the generator from the build task directory, so make any relative paths in the logged command absolute (or replay from that directory). Pass the options the build passes, or the check compares against output the build never writes. `CratisProxiesSegmentsToSkip` is the optional third argument, directly after the output path and before any switch: `dotnet "$generator" "$assembly" "$out" 1 --check`. Everything else is a switch: `--project-directory=<project folder>` for header resolution, plus one for each setting you use, such as `--endpoint-group=<group>` (it changes which endpoints are discovered), `--file-header-base64=<Base64 of CratisProxiesFileHeader>`, `--use-proxy-file-suffix`, `--api-prefix=<prefix>`, `--framework=none` and repeated `--namespace-root=<Namespace>=<Folder>`. The usage text the generator prints without arguments is only a summary and omits some switches. `--check` writes and deletes nothing, including the availability manifest, but it is not a sandbox: it loads the assembly and runs validator constructors, so use only trusted inputs. It prints one `missing: <path>`, `changed: <path>` or `obsolete: <path>` line per finding (relative to the output, `/` separators) and then a summary line; a clean run prints `Proxies are up to date.`. Exit `0` is clean and `2` is drift. Exit `1` is a failure: with fewer than two positional arguments the generator prints its usage text on stdout; other usage, loading and comparison failures it handles print `error: <message>` on stderr. Treat only `2` as stale proxies and any other non-zero exit, whatever its output, as a failed check. Separately use `--validation-report=text` for human inspection or `json` for tooling; a report run still writes proxies to its output tree (and deletes that tree first unless `--skip-output-deletion` is passed), so point it at `scratch`, never at `out`. It also writes the availability manifest, so omit `--availability-manifest` or point it into `scratch`. A `--validation-report-file` inside the proxy output tree is rejected with exit 1, so write it elsewhere. Combining `--check` with a report option is a usage error (exit 1); run them as two invocations. Both ignore `--state-file`. For direct **writing** calls pass `--skip-output-deletion` to avoid wiping the destination and optionally `--state-file=/absolute/path/to/state.json` outside it for incremental generation.
113
+ For a drift gate build the input with `-p:CratisProxiesSkip=true` first so the build does not repair the evidence. That build runs no generator, so take the exact arguments from the generator command in a normal-verbosity log (`dotnet build -v:n`) of an earlier generation-enabled build, or of a separate build whose `CratisProxiesOutputPath` is a disposable directory. The build runs the generator from the build task directory, so make any relative paths in the logged command absolute (or replay from that directory). Pass the options the build passes, or the check compares against output the build never writes. `CratisProxiesSegmentsToSkip` is the optional third argument, directly after the output path and before any switch: `dotnet "$generator" "$assembly" "$out" 1 --check`. Everything else is a switch: `--project-directory=<project folder>` for header resolution, plus one for each setting you use, such as `--endpoint-group=<group>` (it changes which endpoints are discovered), `--file-header-base64=<Base64 of CratisProxiesFileHeader>`, `--use-proxy-file-suffix`, `--api-prefix=<prefix>`, `--framework=none`, `--client-validation=server` and repeated `--namespace-root=<Namespace>=<Folder>`. The usage text the generator prints without arguments is only a summary and omits some switches. `--check` writes and deletes nothing, including the availability manifest, but it is not a sandbox: it loads the assembly and runs validator constructors, so use only trusted inputs. It prints one `missing: <path>`, `changed: <path>` or `obsolete: <path>` line per finding (relative to the output, `/` separators) and then a summary line; a clean run prints `Proxies are up to date.`. Exit `0` is clean and `2` is drift. Exit `1` is a failure: with fewer than two positional arguments the generator prints its usage text on stdout; other usage, loading and comparison failures it handles print `error: <message>` on stderr. Treat only `2` as stale proxies and any other non-zero exit, whatever its output, as a failed check. Separately use `--validation-report=text` for human inspection or `json` for tooling; a report run still writes proxies to its output tree (and deletes that tree first unless `--skip-output-deletion` is passed), so point it at `scratch`, never at `out`. It also writes the availability manifest, so omit `--availability-manifest` or point it into `scratch`. A `--validation-report-file` inside the proxy output tree is rejected with exit 1, so write it elsewhere. Combining `--check` with a report option is a usage error (exit 1); run them as two invocations. Both ignore `--state-file`. For direct **writing** calls pass `--skip-output-deletion` to avoid wiping the destination and optionally `--state-file=/absolute/path/to/state.json` outside it for incremental generation.
114
+
115
+ Client rules for a command property or a model-bound query parameter come from, in order:
116
+
117
+ 1. The rules of the model's validator.
118
+ 2. Plus the rules of the member's concept validator (identical rules appear once).
119
+ 3. Data annotations, only when neither of the above contributed a rule the generator can extract for that member. An annotation on a member that has such a rule is not projected; a validator rule that cannot be extracted does not displace it. For a model-bound query the annotations can sit on the property of the matching argument model or directly on the method parameter; when both yield a rule for the same member, the argument model's annotations are used and the parameter's are not.
120
+
121
+ The generator uses one validator per model, never a combination. Two validators deriving from `CommandValidator<T>`, `QueryValidator<T>` or another discoverable base for the same model fail generation with "Multiple validators for …": merge them into one. When the model has none of those, the generator falls back to a validator that is not discoverable, such as a bare FluentValidation `AbstractValidator<T>`. Arc does not discover that one on the server, so the client carries rules Arc never runs; such a rule stops the request in the browser when its severity is one the client blocks on. Derive from `CommandValidator<T>` or `QueryValidator<T>` so both sides agree (`cratis-arc-validate-command`). Edge case, controller queries: annotations placed directly on action parameters are a fallback for the whole query, not per parameter. They are projected only when everything else yields no rule at all: no rule from the matching argument model's validator, none from its annotations and none from the concept validators of the action's parameters. Concept rules are inferred only when a matching argument model exists, so without one the direct annotations are always the source.
122
+
123
+ A projection report lists what can be projected, also when `CratisProxiesClientValidation=server` suppresses the validators.
78
124
 
79
125
  Projected literal rules (e.g. required, lengths, comparisons, regex) provide client feedback. Conditional rules, arbitrary predicates and injected-data checks remain server concerns. A clean projection report is not proof the command will execute. After changing a backend contract regenerate rather than patching the client.
80
126
 
@@ -90,4 +136,5 @@ Projected literal rules (e.g. required, lengths, comparisons, regex) provide cli
90
136
 
91
137
  - Building only the frontend after changing a backend contract: rebuild the configured endpoint project first.
92
138
  - Editing generated payloads or routes: correct the contract or generator settings and regenerate.
139
+ - Adding roll-forward or runtime settings because the backend targets a newer .NET than the generator was built for: none is needed. For a compatible newer target framework the build by default runs the generator with roll-forward to the latest installed major runtime; it is not pinned to the project's target runtime.
93
140
  - Using two closed instantiations of one generic model, such as `Page<Order>` and `Page<Invoice>`: both generate as `Page` in the generic's folder. Generation fails with "Duplicate type names detected"; with `CratisProxiesUseSourceFileAsOutputFile=true` that check is skipped, but both declarations are combined into one file under the same name `Page`, so the TypeScript does not compile. Declare a non-generic type with its own properties for each shape; deriving from the closed generic still generates the generic.
@@ -1,5 +1,13 @@
1
1
  # Generate clients from a Node backend
2
2
 
3
+ ## Contents
4
+
5
+ - Generate before compiling the client
6
+ - Align routes and output
7
+ - Inspect the published contract
8
+ - Integrate with custom tooling
9
+ - Not supported in this SDK
10
+
3
11
  Use source mode for decorated commands and queries. It reads the backend TypeScript program, not a running server. Names below are illustrative.
4
12
 
5
13
  ## Generate before compiling the client
@@ -66,5 +74,6 @@ For low-level `defineCommand` / `defineQuery` registrations, describe outputs wi
66
74
  - No endpoint-group selector, namespace-root folder map, independent layout trim, source-file bundling, or custom header: select the correct artifacts and output roots; use generated imports as written.
67
75
  - No package-wide mapping, type/namespace exclusion filters or extra model roots: map shared types individually and publish other shared contracts in a separate package.
68
76
  - No response-override option or target-client compatibility profile: give the backend a statically resolvable return type and type-check against the installed client packages.
77
+ - No client validation mode: there is no switch that stops the generator emitting client validators so that only the server evaluates the rules (the C# build has one, `CratisProxiesClientValidation`). Server validation stays authoritative either way.
69
78
  - No full proxy check or validation projection report: regenerate in a clean checkout and check generated changes (including new files); inspect diagnostics and generated validators. Metadata check alone does not verify clients.
70
79
  - No availability manifest, adapter generator, endpoint-options resource, generated slice-location API, or OpenAPI/Screenplay companion output: register artifacts on the host, match routing explicitly and obtain any separate tooling contract from its owner.
@@ -33,7 +33,7 @@ Python has no Arc application SDK and cannot host operations: host them in a ser
33
33
  - **Plain endpoint:** map a hand-written route such as a health check beside the generated ones, where the SDK offers it; it bypasses the command and query pipelines, so state its authentication requirement explicitly.
34
34
  - **Endpoint groups:** bind groups to ports and optional prefixes when operators need separate listeners; decide explicitly whether ungrouped routes may share group ports.
35
35
  - **Controllers:** omit conventional controller registration on a host serving only Arc endpoints.
36
- - **Static assets and fallback:** serve the built frontend if it ships with the backend; use a fallback entry file for browser navigation, not as proof an API route exists.
36
+ - **Static assets and fallback:** serve the built frontend if it ships with the backend (C#: read `references/csharp-deployment.md` when shipping both as one deployable); use a fallback entry file for browser navigation, not as proof an API route exists.
37
37
  - **Static file policy:** choose the served directory, mount path, default documents and content types. Keep directory browsing off unless listing files is intentional; allow well-known resources explicitly when needed.
38
38
 
39
39
  ## Request context and access catalog
@@ -4,6 +4,8 @@
4
4
 
5
5
  - Where settings come from
6
6
  - Core, commands and queries
7
+ - JSON serialization
8
+ - Request localization
7
9
  - Routes
8
10
  - Identity and discovery
9
11
  - Tenancy
@@ -59,6 +61,58 @@ For example, these settings behind an HTTPS gateway keep a live-query backlog sm
59
61
 
60
62
  For a cross-assembly query, call `options.Artifacts.Include(typeof(DepotStatus).Assembly)` and inspect `IncludedAssemblies` for explicit inclusions. To bound HTTP request bodies on ASP.NET Core use `builder.WebHost.ConfigureKestrel(k => k.Limits.MaxRequestBodySize = 1_048_576)`; verify oversized requests are rejected at the intended boundary.
61
63
 
64
+ ## JSON serialization
65
+
66
+ `JsonSerializerOptions` in the options callback is the serializer for the generated command and query endpoints: add converters or change settings there. Other endpoint kinds have their own options:
67
+
68
+ | Endpoints | Configure | What Arc does to it |
69
+ | --- | --- | --- |
70
+ | Generated commands and queries | `options.JsonSerializerOptions` in `AddCratisArc` | Uses it as is. |
71
+ | Controllers | MVC's JSON options, after `AddCratisArc` returns: `builder.Services.PostConfigure<Microsoft.AspNetCore.Mvc.JsonOptions>(...)` | Still sets its own naming policy, removes the first `JsonStringEnumConverter` and appends its converters. Use it for other settings such as null omission and number handling. |
72
+ | Plain minimal APIs | ASP.NET Core's `ConfigureHttpJsonOptions` | Adds concept converters only; naming, enums and dates stay ASP.NET Core's. |
73
+
74
+ - `ConfigureHttpJsonOptions` never changes a generated command or query endpoint.
75
+ - Configure MVC after `AddCratisArc` returns, not inside its `configureBuilder` callback: settings made there run before Arc's own setup and are overridden.
76
+
77
+ ## Request localization
78
+
79
+ Arc can pick the UI language per request, so validation messages and other resources come back in the caller's language. It is opt-in: without `Localization`, Arc negotiates nothing and adds no header. The client side is in `cratis-arc-react-bind-slice`, `references/typescript-localization.md`.
80
+
81
+ ```csharp
82
+ builder.AddCratisArc(configureOptions: options =>
83
+ {
84
+ options.Localization = new()
85
+ {
86
+ SupportedUICultures = ["en", "nb-NO"],
87
+ DefaultUICulture = "en"
88
+ };
89
+ });
90
+ ```
91
+
92
+ | Key under `Localization` | Default | Meaning |
93
+ | --- | --- | --- |
94
+ | `SupportedUICultures` | required | Distinct canonical .NET culture names such as `nb-NO`. |
95
+ | `DefaultUICulture` | required | Used when no provider selects a culture. Must be one of the supported names. |
96
+ | `Providers` | `AcceptLanguage` only | Where the language comes from, in priority order: `QueryString` (`?ui-culture=nb-NO`), `Cookie` (`.AspNetCore.Culture`) and `AcceptLanguage`. An unsupported value falls through to the next provider. |
97
+ | `FormattingCulture` | invariant | One fixed culture for number and date formatting in every request. |
98
+
99
+ - Invalid options stop startup: an empty list, a duplicate, a non-canonical name or a default outside the supported list. A `Providers` list that is set must be non-empty and without duplicates.
100
+ - Default: leave `Providers` unset and let `Accept-Language` decide. Set `Providers`, for example `["QueryString", "Cookie", "AcceptLanguage"]`, only when a user must be able to choose a language that differs from the browser's.
101
+ - A language tag matches a supported culture exactly, through a supported parent, or through its only supported regional variant: `nb` selects `nb-NO` when that is the only supported `nb` culture.
102
+ - The caller's language never selects the formatting culture or a time zone. JSON formats follow the serializer.
103
+ - Responses carry `Content-Language`, and `Vary: Accept-Language` when that provider is on. With the cookie provider on, responses are marked as not to be stored by caches.
104
+ - Observable-query streams carry the language in the reserved query parameter `_cratisUiCulture`, because browser stream APIs cannot set the header. The Arc client adds it only when the frontend has a language configured. On a stream request a value that exactly names a supported culture wins over the providers; otherwise the providers decide as usual. Do not name a query argument that.
105
+ - `UseCratisArc()` installs the middleware ahead of Arc's endpoints. Call `app.UseCratisRequestLocalization()` earlier only when middleware or routes before Arc need the culture; it is not installed twice. The self-hosted listener behaves the same and needs no call.
106
+ - One policy per pipeline: do not combine this with `app.UseInvariantCulture()` or ASP.NET Core's `UseRequestLocalization`. Arc throws an `InvalidOperationException` instead of running two policies.
107
+ - The selected language is `CultureInfo.CurrentUICulture` while the request runs. Arc restores the previous cultures afterwards and never changes the host-wide defaults. Work started from inside a request can inherit the request's culture: set the culture explicitly in background work whose output language matters.
108
+ - Give validation messages as lambdas, so a shared validator resolves them per request and not once:
109
+
110
+ ```csharp
111
+ RuleFor(command => command.Name).NotEmpty().WithMessage(_ => ValidationMessages.NameRequired);
112
+ ```
113
+
114
+ `ValidationMessages` stands for the application's resource class.
115
+
62
116
  ## Routes
63
117
 
64
118
  Keys are under `GeneratedApis`. The MSBuild properties configure proxy generation and must describe the same routes; they do not configure the running host.
@@ -0,0 +1,98 @@
1
+ # Deploy an Arc application (C#)
2
+
3
+ ## Contents
4
+
5
+ - One deployable
6
+ - Build and publish
7
+ - Configure the deployed host
8
+ - Put the ingress in front
9
+ - Verify
10
+ - Alternative: a separately hosted frontend
11
+ - Anti-patterns
12
+
13
+ ## One deployable
14
+
15
+ Default: ship the application as one process. The ASP.NET Core host serves the generated command and query endpoints and the built frontend from one origin, so the browser needs no cross-origin setup and the generated proxies call the API with relative URLs.
16
+
17
+ The host created by the `cratis` template already has this shape: the frontend build writes to the backend's `wwwroot`, and the host serves it with `UseDefaultFiles()`, `UseStaticFiles()` and `MapFallbackToFile("/index.html")`. For the middleware itself see [the C# host reference](csharp.md).
18
+
19
+ ## Build and publish
20
+
21
+ 1. Install the frontend dependencies with the package manager the scaffold chose, from its lockfile. A clean build workspace has none.
22
+
23
+ | Package manager | Frozen install |
24
+ | --- | --- |
25
+ | npm | `npm ci` |
26
+ | Yarn | `yarn install --immutable` |
27
+ | pnpm | `pnpm install --frozen-lockfile` |
28
+
29
+ These commands fail without a lockfile, and a project scaffolded without the install step has none. Run the manager's plain `install` once on a development machine, commit the lockfile it writes, and use the frozen install in every build after that.
30
+ 2. Build the backend: `dotnet build --configuration Release`. This regenerates the TypeScript proxies, which the frontend build compiles against.
31
+ 3. Build the frontend. In the template this is the `build` script in the root `package.json` (`npm run build`, `yarn build` or `pnpm build`); it type-checks and writes to `wwwroot`.
32
+ 4. Publish the backend: `dotnet publish --configuration Release --output <folder>`. The publish output includes `wwwroot`.
33
+ 5. Run the published output on an ASP.NET Core runtime image, as a non-root user.
34
+
35
+ - Keep this order. Without step 2 the frontend compiles against stale or missing proxies after a backend change. `wwwroot` is not committed in the template, so a publish without step 3 produces a host that answers the API but has no frontend.
36
+ - Build the image in two stages: an SDK stage that runs steps 1 to 4 (it needs Node.js and the .NET SDK), and a runtime stage that only copies the publish output.
37
+ - Pin the base images and the Cratis packages to released versions for anything other people reach. The template references Cratis packages with a floating version; replace it before shipping.
38
+
39
+ ## Configure the deployed host
40
+
41
+ Supply environment-specific values as environment variables; `:` in a configuration key becomes `__`.
42
+
43
+ | Value | Key |
44
+ | --- | --- |
45
+ | Chronicle connection string | `Cratis__Chronicle__ConnectionString` |
46
+ | Event store name | `Cratis__Chronicle__EventStore` |
47
+ | Read models in MongoDB | `Cratis__MongoDB__Server`, `Cratis__MongoDB__Database` |
48
+ | Read models through Entity Framework Core | `ConnectionStrings__Cratis`, when the host reads its connection string from there as the template does |
49
+ | Arc options | `Cratis__Arc__...`; see [host configuration](csharp-configuration.md) |
50
+
51
+ - Take the Chronicle client credentials and database passwords from the platform's secret store. The client and passwords in the template's `appsettings.json` and `docker-compose.yml` are public development values: never deploy them.
52
+ - Give each service its own Chronicle client with access to only the event stores it uses. Registering clients on the kernel is in `cratis-chronicle-deploy-kernel`, `references/authentication.md`; connecting the application is in `cratis-chronicle-connect-application`.
53
+ - The listening address is ASP.NET Core's, not Arc's: set `ASPNETCORE_HTTP_PORTS` or `ASPNETCORE_URLS` to what the platform expects. The ASP.NET Core runtime images listen on port 8080 by default.
54
+ - Decide whether the deployed host serves the API description. The template serves Swagger for every environment; restrict it to Development or protect it. See [API description](csharp-http.md).
55
+ - Give the orchestrator separate liveness and readiness endpoints with ASP.NET Core health checks. Readiness runs the checks tagged `ready`. Liveness runs no dependency check: restarting the host does not bring Chronicle back. A `MapHealthChecks` without a predicate runs every check, so set one on both:
56
+
57
+ ```csharp
58
+ builder.Services.AddHealthChecks();
59
+
60
+ // after builder.Build()
61
+ app.MapHealthChecks("/health/live", new HealthCheckOptions { Predicate = _ => false });
62
+ app.MapHealthChecks("/health/ready", new HealthCheckOptions
63
+ {
64
+ Predicate = registration => registration.Tags.Contains("ready")
65
+ });
66
+ ```
67
+
68
+ - `AddHealthChecks()` is required before the endpoints are mapped. Call it yourself: a host that does not use Chronicle has no other registration, and calling it twice is harmless.
69
+ - Adding the Chronicle client to an ASP.NET Core host registers the Chronicle connection check and tags it `ready`, so readiness covers Chronicle without more code.
70
+ - Nothing else is tagged for you. For every other dependency the host cannot serve without, add a check with the `ready` tag (`.AddCheck<TCheck>("name", tags: ["ready"])`). A host with no `ready` check always reports ready.
71
+
72
+ ## Put the ingress in front
73
+
74
+ An application with sign-in either validates tokens in the host itself or sits behind an authenticating ingress such as Cratis AuthProxy. Both are in [authentication and identity](csharp-identity.md).
75
+
76
+ When using Cratis AuthProxy, make it the only public entry: it signs people in and forwards the identity to the host. Configure it with `cratis-authproxy-configure`.
77
+
78
+ A host that trusts forwarded identity headers must be reachable only through that ingress. Anyone who reaches it directly chooses who they are.
79
+
80
+ ## Verify
81
+
82
+ After each deployment follow `cratis-platform-verify-service-handoff`.
83
+
84
+ ## Alternative: a separately hosted frontend
85
+
86
+ Host the frontend apart from the backend only when it needs a CDN or its own release cadence. Keep one origin for the browser by routing both through the ingress: the frontend at the root, and the host's own paths to the host. Those are the API prefix and Arc's endpoints under `/.cratis/`, such as `/.cratis/commands` and `/.cratis/queries`. The observable-query connections live there too (`/.cratis/queries/ws`, `/.cratis/queries/sse` and the paths below it), so the ingress must pass WebSocket and server-sent-event traffic on those paths to the host. Remove the static-file and fallback middleware from the host then.
87
+
88
+ When Cratis AuthProxy is the ingress, keep the one-deployable shape and declare the service with a backend only. A proxy service that declares both a frontend and a backend sends `/api/...` to the backend and every other path to the frontend. Arc's endpoints under `/.cratis/` then reach the frontend, which cannot answer them: observable queries never connect.
89
+
90
+ - Do not work around this by sending the whole `/.cratis/` prefix to the host. The proxy serves sign-in, sign-out, token and other paths under that prefix itself, and it answers `/.cratis/me` by asking the host.
91
+ - Do not let the frontend's server relay Arc's paths to the host either. That is a second way into a host that trusts forwarded identity headers.
92
+ - When the frontend still has to be hosted apart behind AuthProxy, treat it as a design decision to raise, not a configuration step: every request for Arc's own paths must reach the host through the proxy, with the proxy's own paths untouched. Service declarations are in `cratis-authproxy-configure`.
93
+
94
+ ## Anti-patterns
95
+
96
+ - Do not run the frontend development server in a deployed environment.
97
+ - Do not expose the host directly next to the ingress "for debugging" while it trusts forwarded identity.
98
+ - Do not bake secrets or environment-specific settings into the image.
@@ -2,6 +2,12 @@
2
2
 
3
3
  Commands and queries are the default HTTP surface. Use this file only when the host needs something beside them.
4
4
 
5
+ ## Contents
6
+
7
+ - Describe the API
8
+ - Custom endpoints on the self-hosted listener
9
+ - Map an exception to a response
10
+
5
11
  ## Describe the API
6
12
 
7
13
  Pick the one integration that matches the host. Each only describes the surface; none protects it.
@@ -13,7 +19,9 @@ Pick the one integration that matches the host. Each only describes the surface;
13
19
  | Self-hosted listener | none (in `Cratis.Arc.Core`) | `app.MapOpenApi(pattern, title, version);` from `Cratis.Arc.OpenApi` | `/openapi.json` by default |
14
20
 
15
21
  - `AddConcepts()` describes concepts as their primitive, wraps command and query responses in their result types, and adds paging and sorting parameters. It serves nothing by itself.
16
- - `Cratis.Arc.Swagger` and `Cratis.Arc.OpenApi` cannot be installed in the same host, and `Cratis` already brings `Cratis.Arc.Swagger`.
22
+ - `Cratis.Arc.Swagger` and `Cratis.Arc.OpenApi` cannot be installed in the same host, and `Cratis` already brings `Cratis.Arc.Swagger`. A host that needs `Cratis.Arc.OpenApi` references the individual Arc packages instead of `Cratis`.
23
+ - `Cratis.Arc.Swagger` requires `Swashbuckle.AspNetCore` 11.0.1 or later. In a Swashbuckle filter of your own, a media type's schema is read-only: replace the media type in `Content` with a new `OpenApiMediaType` instead of assigning its `Schema`.
24
+ - `Cratis.Arc.OpenApi` supports hosts targeting .NET 10 only.
17
25
  - Do not generate clients from these documents: model-bound response schemas are not specific to the returned type. Use the Arc proxy generator for typed clients.
18
26
  - The self-hosted document lists routes and endpoint metadata without body schemas, is served anonymously, and always describes non-anonymous endpoints as bearer-protected.
19
27
  - Decide deliberately where a document is published; serve it only in development unless it is meant to be public.
@@ -9,6 +9,7 @@
9
9
  - Claims on a forwarded principal
10
10
  - Identity details
11
11
  - Development users and tenants
12
+ - Simulate a user locally
12
13
  - Read the caller in code
13
14
  - Avoid
14
15
 
@@ -44,6 +45,24 @@ builder.Services.AddAuthorization();
44
45
 
45
46
  The scheme is named `MicrosoftIdentityPlatform`; pass a string to use another name. `AddCratis()` registers this scheme for you, but it stays inert until the trust option is on.
46
47
 
48
+ When the host validates JWT bearer tokens itself, keep the token's own claim names and tell ASP.NET Core which of them carry the name and the roles:
49
+
50
+ ```csharp
51
+ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
52
+ .AddJwtBearer(options =>
53
+ {
54
+ options.Authority = builder.Configuration["Authentication:Authority"];
55
+ options.Audience = builder.Configuration["Authentication:Audience"];
56
+ options.MapInboundClaims = false;
57
+ options.TokenValidationParameters.NameClaimType = "preferred_username";
58
+ options.TokenValidationParameters.RoleClaimType = "roles";
59
+ });
60
+ ```
61
+
62
+ - The two claim names are examples: use the names in the tokens your issuer sends.
63
+ - Role checks ask the principal whether it is in a role, and that answer uses `RoleClaimType`. When it does not name the claim that carries the roles, every role requirement fails for every caller.
64
+ - `MapInboundClaims = false` keeps `sub` as `sub`, which is the claim Arc reads as the identity id for identity details. With the mapping on, ASP.NET Core renames `sub` and that id becomes `unknown`.
65
+
47
66
  ## Self-hosted listener
48
67
 
49
68
  `ArcApplication` hosts discover `IAuthenticationHandler` implementations and try them in turn. Do not rely on their order; make each handler's applicability unambiguous.
@@ -138,7 +157,10 @@ public class StaffDetailsProvider(IStaffDirectory directory) : IProvideIdentityD
138
157
  - `IdentityProviderContext` carries `Id` (the `sub` claim, `unknown` when absent), `Name` and `Claims`.
139
158
  - `Claims` is an `IEnumerable<KeyValuePair<string, string>>`: the key is the claim type and the value the claim value. Read `.Key` and `.Value`; these are not `System.Security.Claims.Claim` objects, so there is no `.Type`. `KeyValuePair` is a struct: `FirstOrDefault(...)` never returns null, so write `.Value`, not `?.Value`, and treat a null `Value` as "claim absent".
140
159
  - The type argument declares the shape of the details. When discovery exposes `/.cratis/identity-details/schema`, that endpoint describes the shape. Import the generated TypeScript type instead of declaring a frontend copy. The non-generic `IProvideIdentityDetails` has the same `Provide` method but gives the frontend no generated type.
141
- - `IdentityDetails(IsUserAuthorized, Details)`: `false` makes `/.cratis/me` answer 403. That gates application entry in the frontend only; it adds no claims and protects no command or query.
160
+ - `IdentityDetails(IsUserAuthorized, Details)`: `false` makes `/.cratis/me` answer 403. It adds no claims and protects no command or query. What it gates depends on what is in front of the host:
161
+ - **Arc alone:** application entry in the frontend only.
162
+ - **Behind Cratis AuthProxy:** the proxy asks `/.cratis/me` too, and with its default verification the answer is also the proxy's admission verdict. Only a positive answer admits. A `false` is a refusal: by default the person gets the proxy's forbidden page (403) instead of the application; an OIDC provider configured in the proxy to answer a denial as a failed sign-in ends the session and sends the person back to sign-in instead. A failure is not a refusal: when the proxy needs a fresh answer and the provider throws, the host answers with another error or the answer comes too late, the proxy answers 503 Service Unavailable and keeps the person's session, so they are let back in when the host recovers. People whose earlier positive answer the proxy still holds keep getting in meanwhile. Return `true` for everyone who may enter, including people who still need onboarding (say that in `Details`), and keep the provider fast and dependable: while it fails, nobody who needs a fresh answer gets in, which includes everyone signing in. The proxy settings that change this are in `cratis-authproxy-configure`.
163
+ - Roles come from the principal the host authenticated. The details provider cannot add a role: nothing it returns satisfies `[Roles]` or a policy.
142
164
  - Arc picks the provider whenever a DI scope first resolves it, not when the host builds. Arc's endpoint mapping does not resolve it. When discovery finds more than one implementation (a referenced project or package can contribute one), the host still starts, but every resolution throws `MultipleIdentityDetailsProvidersFound`, including your own startup code that resolves it from a scope. In requests that means a signed-in `/.cratis/me`, `IIdentityProvider.Get()` for a signed-in caller, and a `/.cratis/identity-details/schema` request that passes discovery access (anonymous callers included only where anonymous discovery is allowed, by default in Development). Anonymous `/.cratis/me` still answers 401 and `Get()` outside a request returns anonymous, so the conflict can go unnoticed until someone signs in or requests the schema. Pin one with `options.IdentityDetailsProvider = typeof(StaffDetailsProvider)` in `AddCratisArc`, or call `builder.Services.AddIdentityProvider<StaffDetailsProvider>()` after `AddCratisArc`; use the latter in a trimmed or NativeAOT host.
143
165
  - `/.cratis/me` returns 401 without an authenticated principal. Arc's handlers for `/.cratis/me` (including the 401 and 403 it returns), `/.cratis/users` and `/.cratis/tenants` set `Cache-Control: no-store, private` and add `Cookie` to `Vary`; an existing `Vary: *` is kept. When a response is produced before the handler runs, such as a roster request that authorization refuses, the handler does not add these headers. `/.cratis/me` is specific to the caller; the rosters may be the same for every caller but list development users and tenants. A shared cache such as a CDN or gateway must bypass these routes or honour those headers. One that overrides them risks serving one user's identity to another, or a stale 401 to someone who has just signed in.
144
166
  - Without a custom provider, authenticated callers pass with empty details.
@@ -178,6 +200,60 @@ public class DevelopmentTenants : ICanProvideTenants
178
200
 
179
201
  Both endpoints are anonymous in Development and need authentication elsewhere; `Introspection:IdentityDiscovery = false` removes them. Keep development providers out of deployed hosts.
180
202
 
203
+ ## Simulate a user locally
204
+
205
+ To try the application as a given user before sign-in exists, send the forwarded identity headers yourself. Do this only in Development, on a host bound to loopback.
206
+
207
+ 1. Register the header scheme and turn the trust on for Development only:
208
+ - A host built with `AddCratis()` already has the header scheme as its default.
209
+ - When the deployed host uses another scheme, make the two registrations mutually exclusive, so the header scheme is the only one in Development:
210
+
211
+ ```csharp
212
+ if (builder.Environment.IsDevelopment())
213
+ {
214
+ builder.Services.AddMicrosoftIdentityPlatformIdentityAuthentication();
215
+ }
216
+ else
217
+ {
218
+ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
219
+ .AddJwtBearer(options => { /* as in the ASP.NET Core host section */ });
220
+ }
221
+ ```
222
+
223
+ Registering the header scheme next to the other one is not enough. Each registration sets the default scheme and the last one wins, and an explicit `DefaultAuthenticateScheme` wins over both; the test request is then authenticated by the other scheme and stays anonymous.
224
+ - Set `Cratis:Arc:TrustForwardedIdentityHeaders` to `true` in `appsettings.Development.json`. Do not set it in the `AddCratisArc` callback as the ASP.NET Core host example does: the callback runs after configuration is bound and turns the trust on in every environment.
225
+ 2. Write the test user as JSON. `userRoles` become the role claims:
226
+
227
+ ```json
228
+ {
229
+ "identityProvider": "aad",
230
+ "userId": "e7f664ca-4ecc-45be-84cf-74b6240d049a",
231
+ "userDetails": "dana@example.test",
232
+ "userRoles": ["dispatcher"],
233
+ "claims": [{ "typ": "name", "val": "Dana Dispatcher" }]
234
+ }
235
+ ```
236
+
237
+ 3. Base64-encode it on your own machine, on one line. Never paste an identity into an online encoder.
238
+
239
+ ```bash
240
+ python3 -c 'import base64,pathlib; print(base64.b64encode(pathlib.Path("principal.json").read_bytes()).decode())'
241
+ ```
242
+
243
+ 4. Send all three headers; a request that lacks one of them is not authenticated.
244
+
245
+ | Header | Value |
246
+ | --- | --- |
247
+ | `x-ms-client-principal` | The Base64 text. |
248
+ | `x-ms-client-principal-id` | The user id. |
249
+ | `x-ms-client-principal-name` | The user name. |
250
+
251
+ In a browser, set the headers with a header extension. Add a URL filter for the local address (for example `^http://localhost:5173/.*$`) before enabling the profile, never "all requests", and disable the profile afterwards. Use one profile per test user.
252
+
253
+ Check three cases: no headers (a protected operation refuses the caller as unauthenticated), a user without the required role (refused as unauthorized) and a user with it (the operation runs).
254
+
255
+ Base64 is not a signature: whoever can send these headers chooses who they are. This loopback-only Development host is the one case where the trust is on without an ingress in front. Never turn the trust on for a host other machines can reach; a `localhost` URL in the browser does not prove the host is bound to loopback only. This checks authorization, not the sign-in the deployed host will use.
256
+
181
257
  ## Read the caller in code
182
258
 
183
259
  Inject `ICurrentPrincipalAccessor` (`Cratis.Arc.Authorization`) and read `Current`, a `ClaimsPrincipal?`. Use it, not identity details, for decisions about the caller.
@@ -193,6 +269,11 @@ if (principals.Current is { } principal && principal.GetActor() is { } actor)
193
269
 
194
270
  `audit` stands for an application service. A request carrying the on-behalf headers (`OnBehalfOfHeaders.ActorHeader`, `OnBehalfOfHeaders.AssertionHeader`) fails authentication unless `OnBehalfOf:Enabled` and `TrustForwardedIdentityHeaders` are both on and the assertion verifies.
195
271
 
272
+ Two small helpers exist for edge cases; prefer `Current` and its claims:
273
+
274
+ - `identity.GetUserIdAsGuid()` (on `IIdentity`, namespace `System.Security.Principal`) parses the `ClaimTypes.NameIdentifier` claim as a `Guid`. It returns `Guid.Empty` when the claim is absent and throws `FormatException` when the value is not a Guid. A forwarded principal has that claim; a JWT principal with `MapInboundClaims = false` has `sub` instead.
275
+ - `request.GetClientPrincipal()` (`Cratis.Arc.Identity`, on `HttpRequest`) decodes the `x-ms-client-principal` header into a `ClientPrincipal`, or returns null without the header. It only decodes: it checks neither the trust option nor a signature, and throws on text that is not Base64. Use it in custom middleware only behind the same ingress boundary, never to authenticate.
276
+
196
277
  Inject `IIdentityProvider` (`Cratis.Arc.Identity`) when backend code needs the same identity result the frontend receives.
197
278
 
198
279
  - `Get()` and `Get<TDetails>()` build it from the current principal and the details provider. With no request context or no authenticated principal the result is anonymous.
@@ -202,8 +283,9 @@ Inject `IIdentityProvider` (`Cratis.Arc.Identity`) when backend code needs the s
202
283
 
203
284
  ## Avoid
204
285
 
205
- - Do not enable `TrustForwardedIdentityHeaders` without the ingress boundary; anyone who reaches the backend could then name themselves.
286
+ - Do not enable `TrustForwardedIdentityHeaders` without the ingress boundary; anyone who reaches the backend could then name themselves. The only exception is the loopback-bound Development host in "Simulate a user locally".
206
287
  - Do not accept custom headers such as a user id or role header without the same boundary.
207
288
  - Do not authorize from `IdentityDetails`, the development rosters or a tenant header.
289
+ - Do not read or write the `.cratis-identity` cookie in application code. The Arc frontend reads identity from `/.cratis/me`; on the server use `IIdentityProvider` for presentation data and `ICurrentPrincipalAccessor` for the principal.
208
290
  - Do not normalize claim types when reading reserved claims, and do not persist the provider claim as a durable key.
209
291
  - Do not test only the valid token: cover missing, malformed, expired, wrong-issuer and wrong-audience credentials, and forged forwarded headers.
@@ -143,6 +143,8 @@ app.UseCratisArc();
143
143
 
144
144
  `UseStaticFiles(options => ...)` accepts `FileSystemPath` (default `wwwroot`), `RequestPath` (URL prefix, default root), `ServeDefaultFiles`, `DefaultFileNames` and `ContentTypeMappings`. Default documents are tried in order: index.html, index.htm, default.html, default.htm. For example, `app.UseStaticFiles(o => { o.FileSystemPath = "public"; o.RequestPath = "/ui"; o.DefaultFileNames = ["home.html"]; o.ContentTypeMappings[".geojson"] = "application/geo+json"; });` mounts that directory at `/ui`. The fallback path is relative to the first static-file root. Static files bypass command and query authorization, so put only public assets in a served directory.
145
145
 
146
+ To ship the host and its frontend as one deployable (build order, environment variables, the ingress in front), read [deployment](csharp-deployment.md).
147
+
146
148
  For Swagger or OpenAPI, extra endpoints on the self-hosted listener and mapping an exception to a status and error code, read [custom endpoints, API description and exception responses](csharp-http.md).
147
149
 
148
150
  ## Endpoint groups
@@ -30,11 +30,12 @@ if (result.IsSuccess)
30
30
 
31
31
  The argument order is fixed: command, then optional `IServiceProvider`, then optional `ValidationResultSeverity`, then the optional `CancellationToken` last. `using Cratis.Arc.Commands;` is required for the token overloads. Omit the token when the caller has none; do not invent one.
32
32
 
33
- Await each execution before recording success. Independent imports are not an atomic batch. Let `Execute` create and dispose its scope unless the command needs existing scoped dependencies. A scope is not a tenant or identity grant.
33
+ Await each execution before recording success. Let `Execute` create and dispose its scope unless the command needs existing scoped dependencies. A scope is not a tenant or identity grant.
34
34
 
35
35
  ## Invocation choices
36
36
 
37
37
  - **Preflight:** `await pipeline.Validate(command, token)` authorizes and checks without executing the handler. Recheck the result of execution; validation reserves nothing.
38
+ - **Several changes as one unit:** each `Execute` runs exactly one command, and the pipeline has no call that takes several. Separate top-level executions are not an atomic batch: a later refusal does not undo an earlier commit. With the Arc–Chronicle integration enabled, return the events that must commit together from one outer command, within one event store, namespace, and event sequence, instead of making several top-level calls; standalone Arc gives no such guarantee. Chronicle rollback does not undo a successful immediate append, an earlier explicit commit, or an external write. External work can be compensated separately.
38
39
  - **Typed response:** `var r = await pipeline.Execute<DockId>(command, token);` Read `r.Response` only on success. No payload produces `default(TResult)`; if absence must differ from zero, use an untyped execution and inspect `r.ResponsePayload` on that result. A non-null incompatible payload throws `InvalidCastException`; request the client payload, not the handler’s event or tuple.
39
40
  - **Existing dependencies:** `await pipeline.Execute<DockId>(command, scopedServices, token)`; the same provider position works with untyped `Execute` and `Validate`. Never pass the root provider; the caller owns disposal.
40
41
  - **Trusted job context:** with `ICurrentPrincipalOverride` (Arc authorization) and `ITenantScope` (Arc tenancy), enter `using var identity = principals.BeginScope(trustedPrincipal);` and `using var tenancy = tenants.Begin(authorizedTenant);` before resolving tenant-dependent services. Do not derive either grant from input. `ISystemExecution` (`Cratis.Arc.Authorization`) is the higher-level identity route: `using (system.AsSystem("dispatcher")) { … }` for a system actor with exactly those roles, or `As(trustedPrincipal)`; it applies only where there is no HTTP request. See `cratis-arc-authorize-request` for choosing the actor.
@@ -18,6 +18,23 @@ Read `references/<language>.md` for the project's SDK (`.csproj` → csharp, Nod
18
18
  3. Resolve tenant-bound services **after** admission. Use the established operation context, not a second read of the header or claim. Verify both the write target and the read target; configuring a resolver alone does not partition a database.
19
19
  4. Names are illustrative: write dispatch ticket 42 with a different destination in each of two tenants, then read 42 as a member of each. Each read must return only that tenant's destination. Stop if either the denial test or the isolation test fails.
20
20
 
21
+ ## Behind Cratis AuthProxy
22
+
23
+ When Cratis AuthProxy is the ingress, choose the tenant strategy in the proxy and keep Arc's header selector with its default name, `x-cratis-tenant-id`. In C# that selector is the default, so no selector configuration is needed; for other SDKs set it up as the language reference describes. Use tenant IDs that both sides accept and spell the same way. The proxy forwards letters, digits and `-._~` unchanged, while a backend selector can be stricter: the configured Node selector lowercases the ID and refuses anything that is not a DNS label, so `north_east` passes the proxy and gets 400 from that backend.
24
+
25
+ - The proxy always removes any `x-cratis-tenant-id` the client sent. It adds its own value only when it forwards a tenant it resolved. Without a resolved tenant the proxy may redirect or refuse the request; if it does forward it, it sends no tenant header, so tenant-only operations must still reject absence. This holds only while the backend is reachable through the proxy alone; a caller that reaches the backend directly chooses the header value.
26
+ - Do not also configure an Arc subdomain or claim selector. It would resolve the tenant a second time from a different source and can disagree with the proxy.
27
+ - For one tenant per deployment, fix the tenant in the proxy. Arc's fixed ID selector is for a host without the proxy. This covers the proxy's normal tenancy only, and what a bearer route does depends on the credential. For an access token from an external issuer the tenant comes from the token, and a tenant fixed in the proxy neither overrides nor constrains it, so constrain the tenant of those tokens independently. A personal access token is forwarded for the service to verify, with no tenant resolved by the proxy, so the service must establish and check the tenant itself. A client-credentials token issued by the proxy still goes through the proxy's normal tenancy.
28
+ - The forwarded tenant is still a selection. The proxy's tenant verification is optional and confirms only that the tenant exists, not that the caller belongs to it, so step 2 of the default path still applies. It is also no ground for the ingress verification declaration in the catalog below.
29
+
30
+ Proxy-side strategies, tenant verification and sessions belong to `cratis-authproxy-configure`.
31
+
32
+ ## Vocabulary: tenant, workspace, namespace
33
+
34
+ - **Tenant** is the product's scope for membership, roles and business data. Arc resolves its **tenant ID**, and the application checks membership against that ID.
35
+ - **Workspace** is the word for a tenant in text people read. It is the same thing with the same tenant ID, not a second concept. Keep a product's established label where it has one.
36
+ - **Chronicle namespace** is the partition of an event store that holds a tenant's data. People choose a workspace; the application resolves the namespace from the admitted tenant. Never accept a namespace from the caller, and never treat a namespace as proof of access.
37
+
21
38
  ## Capability catalog
22
39
 
23
40
  - **Header name:** change it only to match an existing ingress or client contract; handle ambiguous header values before accepting a tenant.
@@ -32,7 +49,7 @@ Read `references/<language>.md` for the project's SDK (`.csproj` → csharp, Nod
32
49
  - **Required selection:** refuse absence for tenant-only work; do not confuse a default or unset sentinel with a named tenant.
33
50
  - **Membership claim:** compare the selected tenant to authenticated grants when the identity provider lists memberships. A claim constraint that allows missing claims is not a positive membership check.
34
51
  - **Membership policy:** install a deny-by-default evaluator or pre-execution filter when grants require application policy; check both commands and queries.
35
- - **Ingress verification declaration:** suppress the C# startup warning only when ingress actually verifies tenants; this declaration adds no runtime check.
52
+ - **Ingress verification declaration:** suppress the C# startup warning only when ingress enforces caller-to-tenant membership and callers cannot reach the backend except through it. Checking that a tenant exists does not qualify. This declaration adds no runtime check.
36
53
  - **Duplicate-header preservation:** require a capable C# host when duplicate selector headers must remain distinguishable.
37
54
  - **Strict validator membership:** enable the C# option to treat membership denials from validators as authorization failures, not suppressible validation errors.
38
55
  - **Tenant identity and current context:** distinguish default from named IDs and read the resolved tenant within the operation rather than passing a caller-supplied ID to storage.
@@ -49,6 +49,8 @@ Return `QueryResult.Unauthorized(context.CorrelationId)` instead only when the f
49
49
 
50
50
  With three authorized matches and unchanged data, expect one item on page 1 and `paging: {"page":1,"size":2,"totalItems":3,"totalPages":2}`. Size is the requested limit; total pages rounds up (zero for zero size). Verify the two IDs on page 0 do not recur. A shrinking total usually means a window was counted. An empty second page can mean two layers skipped rows.
51
51
 
52
+ The response `paging` has exactly four fields: `page`, `size`, `totalItems` and `totalPages`. It has no `hasNext`, `hasPrevious` or `pageSize`: the request control is `pageSize`, the response field is `size`. For a successful paged result, derive navigation from the zero-based `page`: a next page exists when `page >= 0 && totalPages > 0 && page < totalPages - 1` (do not add one to `page`, since a very large echoed index overflows), a previous one when `page > 0 && page - 1 < totalPages`. The requested page index is echoed without clamping, so `page` can be at or above `totalPages`: with three matches and size two, page 2 is already out of range, and the page just before an out-of-range one may not exist either. Such a result has an empty window only when the source actually windows the data, as a queryable or a rendered source does; a plain list is passed through unchanged while `page` still echoes the request. An unpaged result reports `page` 0, `size` 0 and `totalPages` 0, so test `size > 0` before computing navigation. An ordinary unpaged, non-observable query reports `totalItems` 0; an unpaged observable collection can report its match count there, in a one-shot HTTP snapshot as well as in live emissions, so do not use `totalItems` to detect paging.
53
+
52
54
  ## When the repository already cut the page
53
55
 
54
56
  Use a distinct source type and implement `IQueryRendererFor<TSource>` rather than returning the items alone. The first discovered renderer whose source type accepts the result wins; ensure its concrete class is resolvable from DI and avoid overlapping source types. For example, after the repository has counted authorized matches and applied the current order and window exactly once: