@cratis/pi 8.4.1 → 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 (286) hide show
  1. package/package/corpus/harnesses/copilot/instructions/ai-distribution.instructions.md +2 -1
  2. package/package/corpus/harnesses/copilot/instructions/exit-codes-and-wrappers.instructions.md +1 -1
  3. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +5 -3
  4. package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -1
  5. package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -1
  6. package/package/corpus/harnesses/copilot/instructions/scripting.instructions.md +2 -1
  7. package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +6 -3
  8. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
  9. package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +131 -9
  10. package/package/corpus/rules/ai-distribution.md +2 -1
  11. package/package/corpus/rules/exit-codes-and-wrappers.md +1 -1
  12. package/package/corpus/rules/glossary.md +5 -3
  13. package/package/corpus/rules/react.md +3 -1
  14. package/package/corpus/rules/reactors.md +3 -1
  15. package/package/corpus/rules/scripting.md +2 -1
  16. package/package/corpus/rules/specs.csharp.md +6 -3
  17. package/package/corpus/rules/vertical-slices.md +5 -2
  18. package/package/corpus/skills/cratis-application-growth/SKILL.md +1 -2
  19. package/package/corpus/skills/cratis-application-growth/references/csharp.md +1 -3
  20. package/package/corpus/skills/cratis-application-growth/references/move-and-untangle.md +1 -2
  21. package/package/corpus/skills/cratis-application-growth/references/rename-window.md +1 -3
  22. package/package/corpus/skills/cratis-application-growth/references/service-and-delivery.md +3 -2
  23. package/package/corpus/skills/cratis-application-growth/references/stages.md +2 -2
  24. package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +3 -3
  25. package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +47 -3
  26. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +18 -3
  27. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
  28. package/package/corpus/skills/cratis-arc-authorize-request/references/typescript.md +2 -0
  29. package/package/corpus/skills/cratis-arc-connect-storage/references/csharp.md +1 -0
  30. package/package/corpus/skills/cratis-arc-connect-storage/references/elixir.md +9 -2
  31. package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
  32. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +47 -8
  33. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-controller.md +3 -1
  34. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +6 -3
  35. package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +38 -11
  36. package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
  37. package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-abilities.md +2 -2
  38. package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-recovery.md +6 -4
  39. package/package/corpus/skills/cratis-arc-declare-operation/references/csharp.md +2 -2
  40. package/package/corpus/skills/cratis-arc-diagnose-live-query/SKILL.md +1 -1
  41. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +29 -7
  42. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/java.md +1 -1
  43. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/kotlin.md +1 -1
  44. package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp-diagnose-tool-call.md +9 -7
  45. package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +52 -1
  46. package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +4 -2
  47. package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +36 -10
  48. package/package/corpus/skills/cratis-arc-expose-query/references/go.md +2 -2
  49. package/package/corpus/skills/cratis-arc-expose-query/references/typescript.md +6 -3
  50. package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
  51. package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +55 -6
  52. package/package/corpus/skills/cratis-arc-generate-proxies/references/typescript.md +9 -0
  53. package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
  54. package/package/corpus/skills/cratis-arc-host-application/references/csharp-configuration.md +54 -0
  55. package/package/corpus/skills/cratis-arc-host-application/references/csharp-deployment.md +98 -0
  56. package/package/corpus/skills/cratis-arc-host-application/references/csharp-http.md +9 -1
  57. package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +87 -4
  58. package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +9 -0
  59. package/package/corpus/skills/cratis-arc-invoke-command/references/csharp-extensions.md +4 -0
  60. package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
  61. package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +19 -2
  62. package/package/corpus/skills/cratis-arc-isolate-tenant/references/csharp.md +4 -2
  63. package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
  64. package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +33 -36
  65. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +18 -3
  66. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +94 -19
  67. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +29 -5
  68. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-instant-feedback.md +81 -0
  69. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +80 -0
  70. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-navigation.md +103 -0
  71. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +41 -2
  72. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-structure.md +117 -0
  73. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +8 -4
  74. package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +3 -3
  75. package/package/corpus/skills/cratis-arc-react-separate-view-model/references/typescript.md +27 -6
  76. package/package/corpus/skills/cratis-arc-testing-typescript/references/typescript.md +2 -2
  77. package/package/corpus/skills/cratis-arc-validate-command/references/csharp-rules.md +23 -2
  78. package/package/corpus/skills/cratis-arc-validate-command/references/csharp.md +28 -2
  79. package/package/corpus/skills/cratis-arc-validation-typescript/SKILL.md +1 -0
  80. package/package/corpus/skills/cratis-authproxy-configure/SKILL.md +136 -0
  81. package/package/corpus/skills/cratis-authproxy-configure/references/admission.md +125 -0
  82. package/package/corpus/skills/cratis-authproxy-configure/references/aspire.md +154 -0
  83. package/package/corpus/skills/cratis-authproxy-configure/references/operations.md +122 -0
  84. package/package/corpus/skills/cratis-authproxy-configure/references/services-and-routing.md +114 -0
  85. package/package/corpus/skills/cratis-authproxy-configure/references/sessions-and-logout.md +126 -0
  86. package/package/corpus/skills/cratis-authproxy-configure/references/sign-in-providers.md +116 -0
  87. package/package/corpus/skills/cratis-authproxy-configure/references/tenant-resolution.md +135 -0
  88. package/package/corpus/skills/cratis-choreography-run-workflow/SKILL.md +117 -0
  89. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp-chronicle.md +164 -0
  90. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp.md +354 -0
  91. package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +6 -6
  92. package/package/corpus/skills/cratis-chronicle-cli-operations/references/inspection.md +11 -3
  93. package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +50 -0
  94. package/package/corpus/skills/cratis-chronicle-cli-operations/references/recovery-and-comparison.md +17 -3
  95. package/package/corpus/skills/cratis-chronicle-cli-operations/references/setup-and-target.md +8 -2
  96. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp-services.md +13 -2
  97. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp.md +12 -0
  98. package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin.md +2 -0
  99. package/package/corpus/skills/cratis-chronicle-connect-application/references/python.md +2 -2
  100. package/package/corpus/skills/cratis-chronicle-connect-application/references/typescript.md +10 -1
  101. package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +9 -2
  102. package/package/corpus/skills/cratis-chronicle-constrain-append/references/csharp.md +35 -3
  103. package/package/corpus/skills/cratis-chronicle-constrain-append/references/go.md +1 -1
  104. package/package/corpus/skills/cratis-chronicle-constrain-append/references/operations.md +70 -0
  105. package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +6 -3
  106. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +113 -16
  107. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/container-and-kubernetes.md +293 -0
  108. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +16 -9
  109. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +60 -7
  110. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +124 -2
  111. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +36 -1
  112. package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
  113. package/package/corpus/skills/cratis-chronicle-evolve-event/references/csharp.md +2 -2
  114. package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +15 -5
  115. package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +9 -8
  116. package/package/corpus/skills/cratis-chronicle-inspect-observer/references/go.md +2 -2
  117. package/package/corpus/skills/cratis-chronicle-mcp-inspection/SKILL.md +1 -1
  118. package/package/corpus/skills/cratis-chronicle-mcp-inspection/references/deployment.md +1 -1
  119. package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +2 -2
  120. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +15 -4
  121. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +4 -1
  122. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +5 -2
  123. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp.md +23 -0
  124. package/package/corpus/skills/cratis-chronicle-project-view/references/elixir.md +1 -0
  125. package/package/corpus/skills/cratis-chronicle-project-view/references/go.md +2 -1
  126. package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +3 -1
  127. package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +4 -3
  128. package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +3 -1
  129. package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +3 -1
  130. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +41 -4
  131. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +22 -4
  132. package/package/corpus/skills/cratis-chronicle-protect-decision/references/elixir.md +7 -0
  133. package/package/corpus/skills/cratis-chronicle-protect-decision/references/go.md +9 -1
  134. package/package/corpus/skills/cratis-chronicle-protect-decision/references/java.md +8 -0
  135. package/package/corpus/skills/cratis-chronicle-protect-decision/references/kotlin.md +9 -0
  136. package/package/corpus/skills/cratis-chronicle-protect-decision/references/typescript.md +7 -0
  137. package/package/corpus/skills/cratis-chronicle-protect-personal-data/SKILL.md +1 -1
  138. package/package/corpus/skills/cratis-chronicle-protect-personal-data/references/csharp.md +28 -3
  139. package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +7 -6
  140. package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
  141. package/package/corpus/skills/cratis-chronicle-publish-contract/references/elixir-integrations.md +3 -3
  142. package/package/corpus/skills/cratis-chronicle-publish-contract/references/webhook-signature-wire-format.md +82 -0
  143. package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +19 -1
  144. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-outputs.md +3 -1
  145. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-pages.md +1 -1
  146. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +37 -4
  147. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/elixir.md +11 -0
  148. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +2 -1
  149. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
  150. package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +3 -3
  151. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-coordination.md +31 -2
  152. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-history.md +21 -4
  153. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp.md +20 -2
  154. package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +1 -1
  155. package/package/corpus/skills/cratis-chronicle-record-event/references/java.md +1 -1
  156. package/package/corpus/skills/cratis-chronicle-record-event/references/kotlin.md +3 -0
  157. package/package/corpus/skills/cratis-chronicle-reduce-state/SKILL.md +2 -1
  158. package/package/corpus/skills/cratis-chronicle-reduce-state/references/csharp.md +3 -1
  159. package/package/corpus/skills/cratis-chronicle-reduce-state/references/java.md +10 -1
  160. package/package/corpus/skills/cratis-chronicle-reduce-state/references/kotlin.md +10 -1
  161. package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +27 -5
  162. package/package/corpus/skills/cratis-chronicle-select-client/SKILL.md +18 -0
  163. package/package/corpus/skills/cratis-chronicle-select-client/references/elixir.md +21 -1
  164. package/package/corpus/skills/cratis-chronicle-select-client/references/go.md +13 -0
  165. package/package/corpus/skills/cratis-chronicle-select-client/references/java.md +15 -0
  166. package/package/corpus/skills/cratis-chronicle-select-client/references/kotlin.md +15 -0
  167. package/package/corpus/skills/cratis-chronicle-select-client/references/typescript.md +16 -0
  168. package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +1 -1
  169. package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +4 -3
  170. package/package/corpus/skills/cratis-ci-pipeline-performance/references/publish-pipelines.md +19 -4
  171. package/package/corpus/skills/cratis-code-review/SKILL.md +6 -2
  172. package/package/corpus/skills/cratis-code-review/references/csharp-diagnostics.md +28 -2
  173. package/package/corpus/skills/cratis-code-review/references/csharp.md +4 -4
  174. package/package/corpus/skills/cratis-commits-and-pull-requests/SKILL.md +6 -38
  175. package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-description.md +2 -0
  176. package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-labels-and-release.md +5 -4
  177. package/package/corpus/skills/cratis-commits-and-pull-requests/references/workflow-inputs.md +39 -0
  178. package/package/corpus/skills/cratis-components-accessibility/SKILL.md +6 -8
  179. package/package/corpus/skills/cratis-components-accessibility/references/typescript.md +32 -14
  180. package/package/corpus/skills/cratis-components-build-canvas/SKILL.md +4 -3
  181. package/package/corpus/skills/cratis-components-build-canvas/references/typescript-props.md +1 -1
  182. package/package/corpus/skills/cratis-components-build-canvas/references/typescript.md +4 -2
  183. package/package/corpus/skills/cratis-components-choose-control/SKILL.md +13 -7
  184. package/package/corpus/skills/cratis-components-choose-control/references/from-primereact.md +116 -0
  185. package/package/corpus/skills/cratis-components-choose-control/references/menu.md +90 -0
  186. package/package/corpus/skills/cratis-components-choose-control/references/typescript-composition.md +48 -0
  187. package/package/corpus/skills/cratis-components-choose-control/references/typescript.md +2 -2
  188. package/package/corpus/skills/cratis-components-compose-toolbar/SKILL.md +2 -1
  189. package/package/corpus/skills/cratis-components-compose-toolbar/references/floating-toolbar.md +146 -0
  190. package/package/corpus/skills/cratis-components-diagnose-screen/SKILL.md +102 -0
  191. package/package/corpus/skills/cratis-components-display-list/SKILL.md +10 -10
  192. package/package/corpus/skills/cratis-components-display-list/references/typescript-custom-panel.md +74 -0
  193. package/package/corpus/skills/cratis-components-display-list/references/typescript-datatables.md +2 -7
  194. package/package/corpus/skills/cratis-components-display-list/references/typescript.md +3 -2
  195. package/package/corpus/skills/cratis-components-submit-form/SKILL.md +6 -6
  196. package/package/corpus/skills/cratis-components-submit-form/references/typescript-commanddialog.md +21 -1
  197. package/package/corpus/skills/cratis-components-submit-form/references/typescript-commandform.md +72 -2
  198. package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +7 -5
  199. package/package/corpus/skills/cratis-components-theme-application/SKILL.md +17 -15
  200. package/package/corpus/skills/cratis-components-theme-application/references/localization.md +166 -0
  201. package/package/corpus/skills/cratis-components-theme-application/references/typescript.md +18 -14
  202. package/package/corpus/skills/cratis-components-theme-application/references/upgrade-from-previous-major.md +141 -0
  203. package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +2 -0
  204. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-domain-philosophy.md +31 -3
  205. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-fundamentals-helpers.md +119 -0
  206. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp.md +4 -0
  207. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +72 -1
  208. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +9 -0
  209. package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +2 -1
  210. package/package/corpus/skills/cratis-fundamentals-concept/references/java-json.md +3 -2
  211. package/package/corpus/skills/cratis-fundamentals-concept/references/kotlin-json.md +3 -2
  212. package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +41 -2
  213. package/package/corpus/skills/cratis-fundamentals-name-value/SKILL.md +8 -7
  214. package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
  215. package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +3 -3
  216. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +8 -0
  217. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp.md +2 -2
  218. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/go-dependency-injection.md +3 -0
  219. package/package/corpus/skills/cratis-modeling-design-event-model/SKILL.md +6 -4
  220. package/package/corpus/skills/cratis-modeling-design-event-model/references/command-inventory.md +7 -1
  221. package/package/corpus/skills/cratis-modeling-design-event-model/references/model-first.md +13 -1
  222. package/package/corpus/skills/cratis-modeling-design-event-model/references/review-one-slice.md +6 -0
  223. package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +6 -6
  224. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/csharp-aspire.md +116 -28
  225. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/docker-compose.md +2 -2
  226. package/package/corpus/skills/cratis-observability/references/chronicle-kernel-export.md +46 -0
  227. package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +4 -2
  228. package/package/corpus/skills/cratis-platform-build-application/SKILL.md +8 -0
  229. package/package/corpus/skills/cratis-platform-build-application/references/cratis-identity.md +71 -0
  230. package/package/corpus/skills/cratis-platform-build-application/references/studio-repository.md +96 -0
  231. package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +14 -8
  232. package/package/corpus/skills/cratis-platform-deliver-slice/references/csharp.md +167 -3
  233. package/package/corpus/skills/cratis-platform-deliver-slice/references/eventual-consistency.md +150 -0
  234. package/package/corpus/skills/cratis-platform-deliver-slice/references/typescript.md +14 -1
  235. package/package/corpus/skills/cratis-platform-diagnose-slice/SKILL.md +1 -1
  236. package/package/corpus/skills/cratis-platform-prepare-release-pr/SKILL.md +8 -8
  237. package/package/corpus/skills/cratis-platform-prepare-release-pr/references/product-release-checks.md +16 -2
  238. package/package/corpus/skills/cratis-platform-start-application/SKILL.md +21 -0
  239. package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +77 -3
  240. package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +118 -0
  241. package/package/corpus/skills/cratis-platform-upgrade-application/references/csharp.md +117 -0
  242. package/package/corpus/skills/cratis-platform-upgrade-application/references/java.md +53 -0
  243. package/package/corpus/skills/cratis-platform-upgrade-application/references/kotlin.md +53 -0
  244. package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +71 -0
  245. package/package/corpus/skills/cratis-release-notes/SKILL.md +1 -1
  246. package/package/corpus/skills/cratis-release-notes/references/publish-repair.md +6 -3
  247. package/package/corpus/skills/cratis-screenplay-accept-model/references/csharp.md +34 -3
  248. package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +84 -3
  249. package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +7 -11
  250. package/package/corpus/skills/cratis-screenplay-declare-slice/references/commands.md +8 -4
  251. package/package/corpus/skills/cratis-screenplay-declare-slice/references/projections.md +2 -0
  252. package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +29 -1
  253. package/package/corpus/skills/cratis-screenplay-edit-workspace/SKILL.md +2 -1
  254. package/package/corpus/skills/cratis-screenplay-edit-workspace/references/mcp-tools.md +1 -1
  255. package/package/corpus/skills/cratis-screenplay-handoff-slice/references/csharp.md +13 -1
  256. package/package/corpus/skills/cratis-screenplay-model-translation/SKILL.md +1 -1
  257. package/package/corpus/skills/cratis-screenplay-model-translation/references/boundary-diagnostics.md +1 -1
  258. package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +30 -51
  259. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/cli.md +19 -2
  260. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/smallest-model.md +87 -0
  261. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/studio.md +5 -0
  262. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/typescript.md +13 -0
  263. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
  264. package/package/corpus/skills/cratis-screenplay-specify-outcome/SKILL.md +8 -12
  265. package/package/corpus/skills/cratis-screenplay-specify-outcome/references/running-mcp.md +12 -0
  266. package/package/corpus/skills/cratis-screenplay-specify-outcome/references/scenarios.md +2 -2
  267. package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +2 -0
  268. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-colocated.md +101 -0
  269. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +4 -2
  270. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-decision-reads.md +1 -0
  271. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +7 -0
  272. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +7 -4
  273. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +18 -5
  274. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-read-models.md +4 -2
  275. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +35 -2
  276. package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
  277. package/package/corpus/skills/cratis-specifications-exercise-backend/references/typescript.md +4 -2
  278. package/package/corpus/skills/cratis-specifications-isolate-behavior/SKILL.md +1 -1
  279. package/package/corpus/skills/cratis-specifications-isolate-behavior/references/csharp-running.md +10 -3
  280. package/package/corpus/skills/cratis-specifications-test-application-ui/references/typescript.md +22 -4
  281. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/SKILL.md +2 -1
  282. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/references/typescript.md +40 -0
  283. package/package/corpus/skills/cratis-stage-render-slice/SKILL.md +6 -0
  284. package/package/corpus/skills/cratis-stage-render-slice/references/semantic-conformance.md +64 -0
  285. package/package/profile-catalog.json +15 -0
  286. package/package.json +1 -1
@@ -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.
@@ -117,7 +136,7 @@ var provider = principal.FindFirst(MicrosoftIdentityPlatformClaims.IdentityProvi
117
136
 
118
137
  ## Identity details
119
138
 
120
- Implement `IProvideIdentityDetails<TDetails>` when the frontend needs more than the principal carries. Arc discovers it; when several exist, select one with `options.IdentityDetailsProvider`.
139
+ Implement `IProvideIdentityDetails<TDetails>` when the frontend needs more than the principal carries. Arc discovers it; Arc's own default provider does not count.
121
140
 
122
141
  ```csharp
123
142
  using Cratis.Arc.Identity;
@@ -138,8 +157,12 @@ 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.
142
- - `/.cratis/me` returns 401 without an authenticated principal. Responses are per user and sent with `Cache-Control: no-store, private`; do not let a shared cache override that.
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.
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.
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.
143
166
  - Without a custom provider, authenticated callers pass with empty details.
144
167
 
145
168
  ## Development users and tenants
@@ -177,6 +200,60 @@ public class DevelopmentTenants : ICanProvideTenants
177
200
 
178
201
  Both endpoints are anonymous in Development and need authentication elsewhere; `Introspection:IdentityDiscovery = false` removes them. Keep development providers out of deployed hosts.
179
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
+
180
257
  ## Read the caller in code
181
258
 
182
259
  Inject `ICurrentPrincipalAccessor` (`Cratis.Arc.Authorization`) and read `Current`, a `ClaimsPrincipal?`. Use it, not identity details, for decisions about the caller.
@@ -192,6 +269,11 @@ if (principals.Current is { } principal && principal.GetActor() is { } actor)
192
269
 
193
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.
194
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
+
195
277
  Inject `IIdentityProvider` (`Cratis.Arc.Identity`) when backend code needs the same identity result the frontend receives.
196
278
 
197
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.
@@ -201,8 +283,9 @@ Inject `IIdentityProvider` (`Cratis.Arc.Identity`) when backend code needs the s
201
283
 
202
284
  ## Avoid
203
285
 
204
- - 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".
205
287
  - Do not accept custom headers such as a user id or role header without the same boundary.
206
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.
207
290
  - Do not normalize claim types when reading reserved claims, and do not persist the provider claim as a durable key.
208
291
  - Do not test only the valid token: cover missing, malformed, expired, wrong-issuer and wrong-audience credentials, and forged forwarded headers.
@@ -105,6 +105,13 @@ Call these on the `IArcBuilder` passed to `configureBuilder` (`configureArcBuild
105
105
 
106
106
  ## Compose request services
107
107
 
108
+ `AddCratisArc` (and `AddCratis`) and `ArcApplication.CreateBuilder` turn on `ValidateScopes` only when the environment name matches `Development` (case-insensitively), and keep `ValidateOnBuild` off. Under any other name (`Staging`, `Production`, `Local`), a singleton that takes a scoped service (tenant storage, the event log) in its constructor is not rejected and keeps the first instance forever. With `ValidateScopes = true`, Microsoft DI rejects that singleton when it is resolved. It does not detect a reference you capture by hand from a child scope. To turn the check on in every environment, set `ValidateScopes = true` and keep `ValidateOnBuild = false`; turning `ValidateOnBuild` on fails `Build()`. Where you set it depends on the host:
109
+
110
+ - `WebApplicationBuilder`: call `builder.Host.UseDefaultServiceProvider(o => { o.ValidateScopes = true; o.ValidateOnBuild = false; })` after `AddCratisArc` or `AddCratis`. The last call wins, so a call before them is discarded.
111
+ - `IHostBuilder` with `AddCratisArc`: call `UseDefaultServiceProvider` with the same options on the host builder itself, after `AddCratisArc`.
112
+ - `ArcApplication.CreateBuilder`: call `ConfigureContainer` with a `DefaultServiceProviderFactory` carrying those options. It replaces Arc's defaults whether it comes before or after `AddCratisArc`.
113
+ - `AddCratisArcCore()` on the generic host: Arc does not change the provider options, so the host's own settings apply.
114
+
108
115
  Register dependencies on the host (`builder.Services.AddScoped<IDepotDirectory, DepotDirectory>()`), not in a static handler. Use an Arc policy for shared authorization across host types:
109
116
 
110
117
  ```csharp
@@ -136,6 +143,8 @@ app.UseCratisArc();
136
143
 
137
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.
138
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
+
139
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).
140
149
 
141
150
  ## Endpoint groups
@@ -8,6 +8,10 @@ Normal callers need only the pipeline. For shared behavior, implement the approp
8
8
 
9
9
  Filters implement `Task<CommandResult> OnExecution(CommandContext context)`. For an `IAuthorizationCommandFilter` return `CommandResult.Unauthorized(context.CorrelationId)` on denial, otherwise `CommandResult.Success(context.CorrelationId)`. An `IAvailabilityCommandFilter` runs before other authorization filters: for temporary unavailability return `CommandResult.Retryable(context.CorrelationId, "Station offline")`. Ordinary `ICommandFilter` implementations run after authorization; for a domain rule return a result with `CorrelationId = context.CorrelationId` and `ValidationResults = [ValidationResult.Error("Station closed")]`, not an authorization denial.
10
10
 
11
+ Filters run after context values are built and before the command's own `Provide()` and `Handle()`. Model-bound execute and validate-only requests run them only if the request gets that far: a missing handler, a principal that cannot be attached, or (on execute) a failing execution scope `Begin` or `BeginAsync` ends the request before any filter runs. Controller actions go through ASP.NET Core MVC filters instead of this chain. So a filter only checks: do not charge quota, count uses or record a successful execution in it. Logging the check itself is fine. An execution scope's `Complete` (below) sees the result so far, and a scope completed after it can still fail the command, so record the outcome no earlier than when `Execute` returns. A successful result is the final verdict, not proof that `Handle()` ran: a command that requires approval can return the approval flow's success without reaching the handler. Nor does it prove durable Chronicle work. A nested pipeline command shares the outer pipeline command's transaction, so a later outer failure discards its pending events (events appended immediately or committed explicitly stay); see the nested Chronicle command note in [the C# reference](csharp.md). A pipeline command executed from a controller action owns its own transaction and commits before `Execute` returns; a later failure of the action does not undo it.
12
+
13
+ Within each group Arc orders filters by the filter type's full name (ordinal comparison), not by registration or a priority setting. Arc merges each filter's result, including a thrown exception, into a running result and stops the chain once that result blocks: an authorization denial, an exception message, or validation findings that block under the effective severity policy. A thrown `IValidationFailure` becomes a finding rather than an exception message, unless it is or wraps an authorization denial, which becomes a denial instead. A nonblocking finding (for example a warning) lets later filters run. A severity policy can also make `Unknown` findings block. So a refusal may not include every filter's findings. Arc's built-in validation runs as two ordinary filters in `Cratis.Arc.Commands.Filters`: `DataAnnotationValidationFilter` and `FluentValidationFilter`. A custom ordinary filter runs before each of them whose full name sorts after its own, which need not be both. Validators for `[GeneratedValue]` handler arguments run only when an execution passes all filters and reaches argument resolution; a validate-only request never runs them.
14
+
11
15
  ## Execution scopes and returned values
12
16
 
13
17
  Arc discovers execution scopes (`Cratis.Arc.Commands`) and resolves them from the command's service scope. Per invocation it calls `Begin` on every scope, then `BeginAsync` in the same order, runs filters, validation and the handler, then `Complete` in reverse order (also when validation fails or execution throws), and finally `End` in reverse order. A validate-only request runs none of these callbacks.
@@ -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,12 +18,29 @@ 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.
24
41
  - **Query parameter:** select by a named query parameter (normally `tenantId`) when the client contract uses a URL selector; authorize it like a header.
25
42
  - **Claim type:** select from a verified principal claim (normally `tenant_id`) when the identity provider assigns the active tenant.
26
- - **Subdomain and base domain:** select the single label immediately before the configured base domain when tenants have dedicated hosts. Protect the fallback header too: a nonmatching host can select through it.
43
+ - **Subdomain and base domain:** select the single label immediately before the configured base domain when tenants have dedicated hosts. Protect the fallback header too: a nonmatching host can select through it. This Arc resolver is separate from Cratis AuthProxy's own tenant resolution: AuthProxy refuses to start when its own tenant resolutions include the `SubHost` strategy and its session cookie domain is set. Read the AuthProxy reference in `cratis-arc-authorize-request` before sharing a sign-in across hosts.
27
44
  - **Fixed ID:** select one configured tenant for a single-tenant deployment, independently of the caller; this is not membership evidence.
28
45
  - **Development selector:** use a stable local tenant for development without requiring a caller selection.
29
46
  - **Custom resolver:** supply trusted selection logic for an application-specific source; validate its result before use.
@@ -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.
@@ -34,8 +34,8 @@ public class DispatchMembership : ITenantMembership
34
34
  Use only identities from trusted authentication schemes. In a combined host configure the existing `AddCratis(configureArcOptions: ...)` registration instead of adding Arc twice. All registered membership checks must return true; a thrown check or failed membership-service resolution also denies access. The `AddScoped<ITenantMembership, …>()` registration is required: convention-based registration does not supply the hook, and with no checks registered, selection alone succeeds and nothing is checked. `IsMember` is synchronous: load external grants during authentication rather than blocking here.
35
35
 
36
36
  - `StrictValidatorMembership` defaults to false. Enable it to propagate membership denials arising in validation as authorization failures. In custom exception handling, `TenantMembershipDenied.IsCauseOf(exception)` recognizes direct, inner and aggregate denials; never turn one into a successful validation.
37
- - `RequireDuplicateHeaderPreservation` defaults to false. With the header or subdomain resolver, HttpListener warns by default and refuses startup when preservation is required. Use ASP.NET Core; otherwise require a trusted ingress that removes all incoming selector headers, injects exactly one, and prevents direct backend access.
38
- - `options.Tenancy.IngressValidatesTenant = true` suppresses the missing-membership startup warning for header, query and subdomain selection. Default false. Set it only for actual ingress enforcement; it neither authorizes the request nor changes resolver behavior.
37
+ - `RequireDuplicateHeaderPreservation` defaults to false. It covers only the built-in header resolver and the subdomain resolver, whose header fallback reads the header (a matching subdomain ignores the header). A custom resolver that reads headers is not covered. ASP.NET Core keeps repeated tenant-header lines, so Arc evaluates all of them: after splitting on commas, trimming and discarding empty entries, a tenant is selected only if exactly one distinct value remains. HttpListener cannot guarantee that. On non-Windows platforms it keeps only the last line, so earlier lines never reach Arc and only the last line is evaluated; a blank last line selects nothing. On Windows the lines are combined. With the header or subdomain resolver, HttpListener starts with a warning by default and refuses to start when this option is true. Use ASP.NET Core; otherwise require a trusted ingress that removes all incoming selector headers, injects exactly one, and prevents direct backend access.
38
+ - `options.Tenancy.IngressValidatesTenant = true` suppresses only the missing-membership startup warning for header, query and subdomain selection. Default false. It does not suppress HttpListener's duplicate-header warning or bypass `RequireDuplicateHeaderPreservation`. Set it only when a trusted ingress enforces caller-to-tenant membership and direct backend access is prevented; header sanitization or tenant-existence checks alone do not qualify. It neither authorizes the request nor changes resolver behavior.
39
39
 
40
40
  ## Select one source
41
41
 
@@ -50,6 +50,8 @@ Use only identities from trusted authentication schemes. In a combined host conf
50
50
  | Fixed | `options.UseFixedTenancy("east")` | Single deployment tenant, independent of caller. `FixedTenantId` defaults to `development`. |
51
51
  | Development | `options.UseDevelopmentTenancy("sandbox")` | Same fixed ID setting; `DevelopmentTenantId` is an obsolete alias. Not restricted to Development environments. |
52
52
 
53
+ Read the tenant only once its source is available. Middleware added through an `IStartupFilter` can run before `UseAuthentication()`, so a claim-based read there sees only a principal already present. A filter registered before Arc's also runs before Arc publishes the request context: there the read returns `TenantId.NotSet` and no membership check runs, even with `DispatchMembership` registered. After that, a read that finds no tenant returns `NotSet` when no check applies, but throws `TenantMembershipDenied` with a check such as `DispatchMembership`, which rejects `NotSet`. Arc does not cache `NotSet`, so a later read after authentication can still resolve the tenant. Work already done is not redone. The scoped event store selects its namespace when it is first resolved (resolving `IEventStore` or a service taken from it, such as `IEventLog`, counts even before any append; `IChronicleClient` alone does not) and keeps it for that DI scope; `NotSet` maps to the default namespace. ASP.NET Core's default request unit of work defers that resolution until its first event-store operation; an explicitly registered `IUnitOfWorkManager` owns its own binding. Do not resolve or use tenant-scoped services (`IEventLog`, `IEventStore`, tenant collections or contexts) before authentication. Use them in the admitted operation, or in middleware placed after `UseAuthentication()` only once it has required a named tenant and verified the caller's membership for it; authentication alone admits no tenant.
54
+
53
55
  `TenancyOptionsValidator` checks `BaseDomain` for Subdomain selection (the fluent helper also checks immediately). Provide the deployment's domain, not an empty value or bare top-level label. The validator does not check every selector name: validate your configuration for nonblank names and a usable fixed ID as applicable.
54
56
 
55
57
  For a trusted application-specific source, implement `ITenantIdResolver` (`public string Resolve()`), returning an empty string for absence. For example, in a deployment using a validated installation record: `public string Resolve() => installation.TenantCode;`. Register the implementation **after** Arc, e.g. `builder.Services.AddSingleton<ITenantIdResolver, InstallationTenantResolver>();`. Do not capture request-scoped services in the singleton or cache a request's tenant on it. Keep the membership check.
@@ -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:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cratis-arc-react-bind-slice
3
- description: Use when a developer mounts the Arc React host, binds a generated query or command proxy in a React component, coordinates several command editors with one Save/Discard (CommandScope), or reads identity, availability or slice context in React. Not for a standard table (use cratis-components-display-list), a form that collects command input (use cratis-components-submit-form), view-model classes (use cratis-arc-react-separate-view-model) or producing the proxies (use cratis-arc-generate-proxies).
3
+ description: Use when a developer mounts the Arc React host, binds a generated query or command proxy in a React component, sets the UI language (locale, translations) of a React application, coordinates several command editors with one Save/Discard (CommandScope), or reads identity, availability or slice context in React, including folder-derived slice locations from the Arc Vite SliceLocationPlugin. Not for a standard table (use cratis-components-display-list), a form that collects command input (use cratis-components-submit-form), view-model classes (use cratis-arc-react-separate-view-model) or producing the proxies (use cratis-arc-generate-proxies).
4
4
  compatibility: Requires react, react-dom, reflect-metadata, @cratis/arc, @cratis/arc.react and @cratis/fundamentals, plus proxies generated for React.
5
5
  ---
6
6
 
@@ -20,33 +20,34 @@ compatibility: Requires react, react-dom, reflect-metadata, @cratis/arc, @cratis
20
20
 
21
21
  Arc React binds a React screen to backend slices through **generated proxies**: one class per query and per command, emitted by the proxy generator (`cratis-arc-generate-proxies`) for any backend language. A proxy carries the route, argument and result types, client validation rules and typed React hooks; whether it also carries a server part and slice location depends on the backend SDK (see Generated metadata in your language reference). A screen never writes `fetch`, a URL or a hand-made proxy.
22
22
 
23
- Read `references/<language>.md` for the project's SDK (`.csproj` → csharp, Node server `package.json` → typescript, `*.kt` → kotlin, `*.java` → java, `go.mod` → go, `mix.exs` → elixir); only the project's languages are installed. React screens use the typescript reference whatever the backend; the sections named below are there. Names in examples are illustrative.
23
+ Read `references/<language>.md` for the project's SDK (`.csproj` → csharp, Node server `package.json` → typescript, `*.kt` → kotlin, `*.java` → java, `go.mod` → go, `mix.exs` → elixir); only the project's languages are installed. React screens use the typescript reference whatever the backend; the sections named below are there.
24
24
 
25
25
  ## When to use it
26
26
 
27
- - Hand-written binding: a custom view, a live dashboard, a command fired from a button whose inputs are already known, a page-level save bar.
27
+ - Hand-written binding: a custom view, a live dashboard, a button command with known inputs, a page-level save bar.
28
28
  - Prefer a Components surface when one fits: `cratis-components-display-list` for a query-backed table, `cratis-components-submit-form` for a form or dialog collecting command input. Never also call the hook for a query such a surface binds.
29
29
  - Move presentation logic or collaborators into a class with `cratis-arc-react-separate-view-model`.
30
30
 
31
31
  ## How it behaves at runtime
32
32
 
33
33
  - **One host**, mounted once, supplies request settings, the query cache, identity, the root messenger, a default command scope and slice context.
34
- - **Two kinds of query.** A *snapshot* query is request/response and can be re-run; an *observable* query is a live subscription the server pushes to. The backend return type decides the kind. Collection queries add sorting and paging.
35
- - **Shared, cached entries.** Hooks with the same query, arguments, page, page size and sort order share one cache entry. Observable hooks on it share one subscription. Snapshot hooks share only the last result: each mount sends its own request and `perform()` refreshes its own hook, so give shared snapshot data one owner and pass it down, or use an observable query (see Snapshot query in your language reference). A released entry is kept for the retention window (30 seconds unless configured); returning within it shows cached data at once while a snapshot query fetches again. Other arguments, page or sort select another entry, never the previous key's data.
36
- - **Delta transfer.** By default an observable collection gets an initial snapshot, then only changes, which the ordinary hook applies.
37
- - **Arguments are checked before sending.** An invalid query returns a ready, invalid result and sends nothing. A missing required argument sends nothing, and an observable hook never subscribes, so gate it with `when`.
38
- - **Commands are independent instances**, stable across renders, with the host's settings, change tracking against initial values, and registration in the nearest command scope. Executing returns a result; it never throws for a refusal.
39
- - **Reads catch up after writes.** Success means the write was accepted; the read model updates shortly after and an observable query pushes it. Nothing refreshes a snapshot query (neither the command nor a command scope): call its `perform()` after success, and expect it may lag. Prefer an observable query for data the screen's own commands change.
34
+ - **Two kinds of query.** A *snapshot* query is request/response and can be re-run; an *observable* query is a live subscription the server pushes to. The backend return type decides; collection queries add sorting and paging.
35
+ - **Shared, cached entries.** Hooks with the same query, arguments, page, page size and sort order share one cache entry. Observable hooks on it share one subscription. Snapshot hooks share only the last result: each mount sends its own request and `perform()` refreshes its own hook, so give shared snapshot data one owner and pass it down, or use an observable query (see Snapshot query in your language reference). A released entry is kept for the retention window (30 seconds unless configured); returning within it shows cached data at once while a snapshot query fetches again. Other arguments, page or sort use another entry, never the previous key's data.
36
+ - **Delta transfer.** By default a shared-hub subscription asks for an initial snapshot, then only changes, applied by the ordinary hook; direct mode and Polling are outside this. Changes need items with an `Id` property: the .NET backend sends a full snapshot on every change for a collection whose items have none, and for a sorted or paged collection when a change would reorder it.
37
+ - **Arguments are checked before sending.** If the query's client validator reports a finding, Arc returns a ready, invalid result without sending the query; any finding blocks, even one with `withSeverity` Warning or Information (only commands filter by allowed severity). A missing required argument is a separate skip: nothing is sent and an observable hook never subscribes, so gate it with `when`.
38
+ - **Commands are independent instances**, stable across renders, with the host's settings, change tracking against initial values, and registration in the nearest command scope. Expected failures come back as a failed result rather than an exception: a refusal, an unknown route, a network failure and an unreadable response. The last three have `hasExceptions` true and `isRetryable` false. Execution can still reject on an unexpected error (such as a throwing headers callback), so branch on the result and also keep a `catch`.
39
+ - **Reads catch up after writes.** Success means the write was accepted; the read model updates once the event is processed (no upper bound: never wait a fixed time) and an observable query pushes it. After a create, a record screen's ready result without data is pending, not missing (`cratis-platform-deliver-slice`). Nothing refreshes a snapshot query (neither the command nor a command scope): call its `perform()` after success; it may lag. Prefer an observable query for data the screen's own commands change.
40
40
  - **Headers are read per request; caches keep the old caller.** Cached results, open live connections and the identity stay the previous caller's until you update the identity and reconnect (see Identity).
41
41
 
42
42
  ## Default path
43
43
 
44
- 1. Import the decorator-metadata polyfill first in the entry module, then mount the Arc host once around the application; a Components provider goes directly inside it, with the MVVM provider and the router inside that.
44
+ 0. Place the screen and mount it from the feature's composition page: structure (`references/typescript-structure.md`), routes (`references/typescript-navigation.md`).
45
+ 1. Import the decorator-metadata polyfill first in the entry module, then mount the Arc host once; inside it, in order: Components provider, `DialogComponents`, MVVM provider, router.
45
46
  2. In the component that shows data, call the generated query's ordinary hook on every render, with `when(condition)` while a required argument is unknown. Branch on the result in Result state order (see Query hooks in your language reference).
46
47
  3. For an action whose inputs are known, call the generated command's hook, set values through its setter, execute, and classify the result in Command result order (see Commands in your language reference).
47
48
  4. Let the query, not the command, update what is shown.
48
49
 
49
- For a screen specified in an accepted model (`cratis-screenplay-accept-model`), follow [Implementing a screen from an accepted model](references/react-screen-from-model.md).
50
+ For a screen specified in an accepted model (`cratis-screenplay-accept-model`), follow [this guide](references/react-screen-from-model.md).
50
51
 
51
52
  ## Capability catalog
52
53
 
@@ -57,7 +58,8 @@ For a screen specified in an accepted model (`cratis-screenplay-accept-model`),
57
58
  | `microservice` | Backend service the requests address, when an ingress routes by service. |
58
59
  | `apiBasePath` | Prefix before every Arc request when served under a sub-path; never repeat the route's `/api`. |
59
60
  | `origin` | Backend on another origin. |
60
- | `httpHeadersCallback` | Extra headers (tenant, locale, bearer), read per request. Event streams and WebSockets carry none, so authenticate live queries with cookies, an `eventSourceFactory` or Polling (see Request configuration in your language reference). Keep the function stable. |
61
+ | `locale` | UI language, sent as `Accept-Language` (details: `references/typescript-localization.md`). |
62
+ | `httpHeadersCallback` | Extra headers (tenant, bearer), read per request; never `Accept-Language`. Event streams and WebSockets carry none, so authenticate live queries with cookies, an `eventSourceFactory` or Polling (see Request configuration in your language reference). Keep the function stable. |
61
63
  | `development` | Defers view-model disposal so StrictMode remounts keep their instance. |
62
64
  | `detailsType` | Prefer the generated class whose decorated fields type the identity's application details. |
63
65
  | `queryTransportMethod` | Server-sent events through a shared hub (default), WebSocket, or Polling (only when long-lived connections are cut or the backend scales to zero; it lags by the interval). |
@@ -66,12 +68,12 @@ For a screen specified in an accepted model (`cratis-screenplay-accept-model`),
66
68
  | `observableQueryTransferMode` | Delta (default) or Full; global across nested hosts. Set before any subscription. |
67
69
  | `queryCacheRetentionMs` | How long a released query entry and its subscription stay cached. Zero evicts immediately. |
68
70
  | `eventSourceFactory` | Custom server-sent-events client where the global one is missing or needs credentials. |
69
- | `sliceMarkers` | Marks slice boundaries in the DOM with `data-cratis-*` attributes for tooling. |
70
- | `applicationContext` | An application-context store created outside React, for non-React subscribers. |
71
+ | `sliceMarkers` | Off by default. Marks slice scopes and open `useDialog` content with `data-cratis-*` attributes for tooling. |
72
+ | `applicationContext` | A `new ApplicationContext()` created outside React; non-React code reads it with `subscribe` and `getSnapshot`. |
71
73
 
72
74
  From the Arc context, `reconnectQueries()` drops every cached result (ordinary and Suspense), closes the shared live connections and re-runs mounted queries with current credentials; `observableQueryDiagnostics` serves tooling (`cratis-arc-diagnose-live-query`). Nested hosts do not isolate transport, headers or identity. The live transport must reach the backend through any proxy or gateway, under the API prefix.
73
75
 
74
- **Startup globals** (before rendering): Polling timing, and the snapshot-query HTTP method (a generated per-query method wins, then a global resolver, then GET); `Auto` can retry as GET, so use it only for URL-safe arguments. See Startup globals in your language reference.
76
+ **Startup globals** (before rendering): Polling timing and the snapshot-query HTTP method; `Auto` can retry as GET, so use it only for URL-safe arguments. See Startup globals in your language reference.
75
77
 
76
78
  ### Query hooks (on each generated query)
77
79
 
@@ -81,18 +83,18 @@ From the Arc context, `reconnectQueries()` drops every cached result (ordinary a
81
83
  | `useWithPaging(pageSize, args?, sorting?)` | collection queries | the `use` tuple plus setPage, setPageSize | The server pages the collection; never slice on the client. |
82
84
  | `useSuspense(...)` | every query | same tuple as `use` | Suspend while loading and throw on failure, under a query boundary. |
83
85
  | `useSuspenseWithPaging(pageSize, ...)` | collection queries | same tuple as `useWithPaging` | Paged and suspending. |
84
- | `useChangeStream(args?, getKey?, sorting?)` | observable collection queries | a change set: added, replaced, removed | Sync an external collection (canvas, map layer) instead of re-rendering a list. |
85
- | `when(condition)` then any hook above except the change stream | every query | same tuples | Hold the query until a condition holds; hooks cannot be conditional. |
86
+ | `useChangeStream(args?, getKey?, sorting?)` | observable collection queries | a change set: added, replaced, removed | Sync an external collection (canvas, map layer). |
87
+ | `when(condition)` then any hook above except the change stream | every query | same tuples | Hold the query until a condition holds. |
86
88
 
87
89
  - A query without parameters takes no `args` on its own hooks; through `when`, arguments always come first.
88
90
  - **Proxy members:** `sortBy` (collection queries) has ascending and descending per model property, for initial sorting or `setSorting`. `part` and `sliceLocation`, where emitted, identify it for availability and slice context. `route`, `roles` and `defaultValue` describe it.
89
- - **Paging:** `setPage` is zero-based. `result.paging` reports `page`, `size`, `totalItems` and `totalPages`. Each page or sort order is its own cache entry and subscription.
91
+ - **Paging:** `setPage` is zero-based. `result.paging` reports `page`, `size`, `totalItems` and `totalPages`.
90
92
  - **`perform(args?, options?)`** re-runs a snapshot query (the hook's arguments when none are passed); `options.timeoutMs` is a deadline for that run, after which the result is ready, unsuccessful and has exceptions.
91
93
  - **Raw hooks** (`useQuery`, `useObservableQuery`, their paging and suspense variants, `useChangeStream`) take the query class first; `useQuery` and `useQueryWithPaging` also accept `{ isEnabled, timeoutMs }`, for a hook-level deadline. There is no paged change stream.
92
94
  - **Disabled (`when(false)`)**: the hook returns the empty default, ready, though nothing ran; a single-item default is an empty object, so check the condition before `hasData`. A called `perform` still runs. `when` is not authorization.
93
95
  - **Suspense:** a failure throws `QueryFailed` (exceptions) or `QueryUnauthorized`; an invalid or unsuccessful result is returned, so check `isValid` and `isSuccess` first. A boundary reset replays a cached failure, so screens needing retry use the ordinary hooks. Suspense keeps its own caches (see Suspense in your language reference).
94
96
  - **Suspense with observable collections** replaces `data` per emission without applying deltas, so in Delta mode an update can empty the list. Suspend only snapshot queries, single items, or a Full-mode host.
95
- - **Change streams** hold the latest change set as state: the server's delta, or a diff of successive results. The first lists every item as added (what later sets list: Change stream in your language reference). `getKey` (stable primitive) lets a diff report replaced instead of removed plus added. Synchronize a collection with it; never announce domain events from it.
97
+ - **Change streams** hold the latest change set as state: the server's when it sends one (even first), otherwise a diff of successive results, where the first and every Full-mode result list all items as added. Diffs ignore order. `getKey` (stable primitive) lets a diff report replaced instead of removed plus added. Sync an external collection's membership with it, never announce domain events (see Change stream in your language reference).
96
98
 
97
99
  ### Query boundaries and scope
98
100
 
@@ -117,20 +119,18 @@ The result has `data` and flags. Check in this order; stop at the first that app
117
119
  - **`use(initialValues?)`** returns the command, a values setter and a values clearer. Initial values become the draft and baseline once (key the editor by record identity). Use the setter in input handlers: it re-renders, while direct assignment re-renders only when `hasChanges` flips. The clearer unsets every property.
118
120
  - **Instance:** `execute()` sends it; success makes the submitted values the baseline, so edits made during the request stay changes. `validate()` runs server authorization and validation without executing; `validateClientSide()` runs local rules only. `hasChanges`, `setInitialValues(values)`, `revertChanges()` and `clear()` manage the draft; `setInitialValuesFromCurrentValues()` deliberately accepts the current draft, never as a post-save step. `route`, `roles`, `part`, `sliceLocation` (where emitted) and `propertyDescriptors` describe it.
119
121
  - **Severity override:** `execute(allowedSeverity, ignoreWarnings)` for "save anyway": execute allowing Information; when only warnings fail, confirm and execute allowing Warning. Generated and server blocking-severity policies cannot be relaxed this way.
120
- - Construct a command directly only outside React; it gets neither the host's settings nor headers.
122
+ - Use the hook. `new` a command only outside React or per overlapping gesture (instant feedback): process-wide settings, no host `locale`, no scope.
121
123
  - **Required inputs:** an unset non-optional property fails client validation (reason `rule`, detail `Required`) and nothing is sent. The hook creates no identifiers.
122
124
 
123
125
  ### Command result
124
126
 
125
- Fields: `isSuccess`, `isAuthorized`, `isValid`, `hasExceptions`, `validationResults`, `exceptionMessages`, `exceptionStackTrace`, `authorizationFailureReason`, `isRetryable`, `errorCode`, `isMissingHandler`, `isNotAvailable`, `isSuspended`, `response` (typed, only on success), `correlationId`. Chainable callbacks: `onSuccess`, `onFailed`, `onException`, `onUnauthorized`, `onValidationFailure`, `onNotAvailable`, `onSuspended`.
126
-
127
- Findings carry `severity` (information, warning, error), `message`, `members` (property names, for matching fields), `reason` and `reasonDetail`. Choose copy by `reason` (`rule`, `validatorFailed`, `dependencyUnavailable`, `malformedRequest`, `frameworkFailure`, and with Chronicle `concurrencyViolation` or `constraintViolation`), never by message text; treat an unknown reason as `rule`.
127
+ The result has flags, `validationResults`, a typed `response` (only on success) and chainable callbacks (full list: Commands in your language reference). Findings carry `severity`, `members` (property names), `reason` and `reasonDetail`. Choose copy by `reason`, never by message text; treat an unknown reason as `rule`.
128
128
 
129
129
  Classify a refusal in this order: suspended, not available, unauthorized, missing handler, concurrency violation, retryable, validation by field, anything else. A `concurrencyViolation` with `reasonDetail` `ReadChanged` or `ReadIncomplete` is a guarded read that changed or could not be completed, whatever `isRetryable` says: nothing was written, so re-read, keep the draft and let the user resubmit explicitly. Always keep the user's input and clear any busy state.
130
130
 
131
131
  ### Command scope
132
132
 
133
- `CommandScope` gathers the commands created below it into one save bar (the host supplies a default). Props: `setHasChanges`, `setIsPerforming`, and per-command callbacks for executions the scope runs: `onBeforeExecute`, `onSuccess`, `onFailed`, `onException`, `onUnauthorized`, `onValidationFailure`. `useCommandScope()` gives `hasChanges`, `isPerforming`, `hasValidationFailures`, `hasExceptions`, `validationFailures`, `exceptions`, `aggregatedValidationFailures`, `aggregatedExceptions`, `execute()` and `revertChanges()`.
133
+ `CommandScope` gathers the commands created below it into one save bar. Props: `setHasChanges`, `setIsPerforming`, and per-command callbacks for executions the scope runs: `onBeforeExecute`, `onSuccess`, `onFailed`, `onException`, `onUnauthorized`, `onValidationFailure`. `useCommandScope()` gives `hasChanges`, `isPerforming`, `hasValidationFailures`, `hasExceptions`, `validationFailures`, `exceptions`, `aggregatedValidationFailures`, `aggregatedExceptions`, `execute()` and `revertChanges()`.
134
134
 
135
135
  `execute()` runs the scope's own changed commands in sequence; child scopes add only failures and exceptions to the aggregates. It is not a transaction (a failure neither stops nor rolls back the others; report partial saves) and refreshes no query. `revertChanges()` does not re-render inputs; reset each editor through its setter.
136
136
 
@@ -138,7 +138,7 @@ Classify a refusal in this order: suspended, not available, unauthorized, missin
138
138
 
139
139
  `useIdentity()`: `id`, `name`, `roles`, `details` (typed through `detailsType` or a type argument; may be absent), `isSet`, `isLoading`, `isInRole(role)`, `refresh()`, `clearIdentity()`.
140
140
 
141
- When credentials change, change them first, then `refresh()` the identity (sign-in, new roles) or `clearIdentity()` (sign-out; it only resets the local identity), then `reconnectQueries()` before caller-scoped data renders. None of these resets application state (component state, view models, drafts), so a full page load is the conservative default for an account switch. See Sign-in, sign-out and account switch in your language reference.
141
+ When credentials change, change them first, then `refresh()` the identity (sign-in, new roles) or `clearIdentity()` (sign-out; it only resets the local identity), then `reconnectQueries()` before caller-scoped data renders. Arc resets no state in components that stay mounted, but `RequireRole` unmounts its children and their state for `whileLoading` during `refresh()` and for `forbidden` after `clearIdentity()`, and `refresh()` reloads the page when a signed-in identity resolves to unset. See Sign-in, sign-out and account switch in your language reference.
142
142
 
143
143
  `RequireRole` renders children for `roles` (any one) and/or an `allow(details, identity)` predicate (both must pass when given), with `whileLoading` and `forbidden` slots. It forbids anonymous callers, denies when details are missing or the predicate throws, and with no rule denies everyone. It only hides; the server still authorizes every request.
144
144
 
@@ -147,27 +147,24 @@ When credentials change, change them first, then `refresh()` the identity (sign-
147
147
  Availability says, live, whether a part is offered to this tenant or user at all. Use it only when the backend serves it (see Generated metadata and Availability in your language reference).
148
148
 
149
149
  - `AvailabilityProvider` goes below the host; without it everything is available, with it nothing is until the first decision.
150
- - `RequireAvailable`: `part`, optional `args`, slots `whileLoading`, `unavailable`, `suspended` (falls back to `unavailable`).
151
- - `useIsAvailable(part, args?)`: `isAvailable`, `isNotAvailable`, `isSuspended`, `reason`, `isKnown` (not known is pending).
152
- - `useAvailableItems(items, partOf)`: the default for navigation and menus; keeps entries without a part and drops those unavailable, suspended or not yet known. Keep items and selector stable.
153
- - `useAvailability()`: the decision object, with `isAvailable(part)`, `availabilityOf(part)` and `filter`.
150
+ - Gate a screen with `RequireAvailable` (`part`, optional `args`, slots `whileLoading`, `unavailable`, `suspended`), a control with `useIsAvailable(part, args?)` (not `isKnown` is pending), and navigation or menus with `useAvailableItems(items, partOf)` (keep both stable). `useAvailability()` gives the decision object.
154
151
 
155
152
  A part is a generated proxy (class or instance) carrying its part, or a full server name. Arguments scope the question and grant nothing. Nest `RequireAvailable` outside `RequireRole`. It only hides; the server still refuses an unavailable or suspended part.
156
153
 
157
154
  ### Messaging, slice, application context and dialogs
158
155
 
159
- - **Messaging:** `MessengerScope`, `useOnMessage`, `useSendMessage` and `useMessenger` pass typed notifications between unrelated components (scoping: `cratis-arc-react-separate-view-model`).
160
- - **Slice context:** `useSliceContext()` gives the module, feature and slice a component renders in. Generated hooks register their proxy's slice location when it has one; `Slice` and `withSliceLocation` declare it for hand-written components, the Arc Vite slice-location plugin derives it from folders at build time, and `useRegisterSliceLocation(location)` registers it from a custom hook.
161
- - **Application context:** `useApplicationContext()` snapshots location, active slices, screen, dialogs and contributions; `useContributeApplicationContext(contribution)` or `ApplicationContextContributor` adds a screen description or values (help links, feedback). `useApplicationContextStore()` returns the store; `useRegisterScope(scope)` registers a hand-built slice scope in the current page or dialog layer.
156
+ - **Messaging:** `MessengerScope`, `useOnMessage`, `useSendMessage` and `useMessenger` pass typed notifications (scoping: `cratis-arc-react-separate-view-model`).
157
+ - **Slice context:** `useSliceContext()` gives the module, feature and slice a component renders in. Generated hooks register their proxy's slice location when it has one; `Slice`, `withSliceLocation`, the Arc Vite slice-location plugin (from folders) and `useRegisterSliceLocation` declare it otherwise.
158
+ - **Application context:** `useApplicationContext()` tells shared chrome what the user is viewing; contribute the screen and values with `useContributeApplicationContext` or `ApplicationContextContributor`, since Arc does not track routes. See Slice and application context in your language reference.
162
159
  - **Dialogs**, confirmations and busy indicators: `cratis-components-coordinate-feedback`.
163
160
 
164
161
  ## Avoid
165
162
 
166
163
  - Calling a hook inside a condition or loop, or reading a disabled query's default as data.
167
- - Closing a dialog by waiting for a list to grow, or inserting the new row by hand.
168
- - Sending a caller identifier from a form. The server takes the caller from the real identity.
169
- - Setting the host's `basePath`: it configures nothing. Use `apiBasePath` for requests and the router's basename for routes.
170
- - Editing generated proxies: change the backend contract, regenerate, then type-check the client.
164
+ - Closing a dialog by waiting for a list to grow, or inserting the new row by hand (edge case: instant feedback, `references/typescript-instant-feedback.md`).
165
+ - Sending a caller identifier from a form: the server takes the caller from the real identity.
166
+ - Setting the host's `basePath`: it configures nothing. Use `apiBasePath` and the router's basename.
167
+ - Editing generated proxies: change the backend, regenerate, type-check the client.
171
168
 
172
169
  ## Related skills
173
170
 
@@ -43,6 +43,8 @@ export function ScheduleButton({ siteId, date }: { siteId: string; date: Date })
43
43
  }
44
44
  ```
45
45
 
46
+ **Busy state without your own flag:** `const { isExecuting } = useCommandExecutionState(command)` (from `@cratis/arc.react/commands`) is true from the first `execute()` in flight until the last one settles, whether it succeeds or fails; `validate()` does not set it. It reports pending work only, so take success or failure from the result. Outside a `CommandForm`, use it instead of the `busy` state above when the button only needs disabling.
47
+
46
48
  `ScheduleVisit.use({ siteId })` seeds initial values; the returned `setCommandValues(values)` assigns several properties at once and `clearCommandValues()` empties them.
47
49
 
48
50
  ## Classify a refusal
@@ -71,7 +73,9 @@ export function describeRefusal(result: CommandResult<unknown>): string {
71
73
  }
72
74
  ```
73
75
 
74
- The `reason` of a finding is one of `rule`, `concurrencyViolation`, `constraintViolation`, `validatorFailed`, `dependencyUnavailable`, `malformedRequest` or `frameworkFailure`; `reasonDetail` narrows it. Use them to select application-approved copy. Exception messages and stack traces are diagnostics.
76
+ A result has `isSuccess`, `isAuthorized`, `isValid`, `hasExceptions`, `validationResults`, `exceptionMessages`, `exceptionStackTrace`, `authorizationFailureReason`, `isRetryable`, `errorCode`, `isMissingHandler`, `isNotAvailable`, `isSuspended`, `response` (typed, only on success) and `correlationId`. Each finding has `severity`, `message`, `members` (property names, for matching fields), `reason` and `reasonDetail`.
77
+
78
+ The `reason` of a finding is one of `rule`, `concurrencyViolation`, `constraintViolation`, `validatorFailed`, `dependencyUnavailable`, `malformedRequest` or `frameworkFailure` (`concurrencyViolation` and `constraintViolation` come with Chronicle); `reasonDetail` narrows it. Treat an unknown reason as `rule`. Use them to select application-approved copy: branch on `reason` and `reasonDetail` (the client's own check for an unset required property gives `rule` with `reasonDetail` `Required`; a rule authored on the server that rejects a missing value need not carry that detail, so match it by `members`), never on the message text, which changes with wording and language. Exception messages and stack traces are diagnostics.
75
79
 
76
80
  The result also chains callbacks for simple cases:
77
81
 
@@ -126,6 +130,12 @@ const full = await command.validate(); // client rules, then the server's
126
130
 
127
131
  Both return a command result; neither performs the command. Server validation is early feedback, not a permission check or a guarantee that execution will succeed.
128
132
 
133
+ A result describes the draft it was sent for. When you show validation yourself:
134
+
135
+ - Keep a revision counter. Bump it on every edit and when saving starts, and apply a `validate()` result only while its revision is still current.
136
+ - On blur, replace that field's messages with `result.validationResults.filter(r => r.members.includes(field))`, even when the list is empty, so a fixed field clears. `CommandResult` has no `hasErrors` or `getErrorsFor`.
137
+ - To save, always call `execute()`, even after a passing `validate()`: it checks the client rules again and the server decides. Take the status and messages from its result (`isSuccess`, `validationResults`), and disable the inputs and the button while it runs so the result matches the draft on screen.
138
+
129
139
  ## Aggregate a section with CommandScope
130
140
 
131
141
  ```tsx
@@ -173,6 +183,8 @@ export function VisitEditor({ initial }: { initial: Draft }) {
173
183
 
174
184
  For one Save/Discard bar, register all editors in the same nearest scope. Dirty tracking, sequential execution and discard cover only its directly registered commands. Only aggregated failures and exceptions include child scopes; coordinate separate scopes explicitly if they must save together. After reverting, pass each editor’s restored values through its setter to refresh its inputs.
175
185
 
186
+ `scope.execute()` runs only the commands that have changes and returns their combined result: `isSuccess`, `isValid` and `isAuthorized` are true only when they are true for every executed command, and `validationResults` and `exceptionMessages` hold the findings of all of them. For a summary that stays on screen after the call, read the scope instead: `hasValidationFailures` with `aggregatedValidationFailures`, and `hasExceptions` with `aggregatedExceptions`.
187
+
176
188
  Use `setHasChanges` and `setIsPerforming` on the scope if its parent needs dirty and busy indicators. `onSuccess` signals one command’s success, not a successful batch. A later failure does not undo earlier saves.
177
189
 
178
190
  ## Outside React
@@ -184,7 +196,10 @@ command.scheduledFor = date;
184
196
  const result = await command.execute();
185
197
  ```
186
198
 
187
- A constructed command uses the global configuration only; it does not receive the provider's `httpHeadersCallback` or register with a scope. Prefer the hook inside components.
199
+ A constructed command uses the process-wide configuration, which the host writes when it mounts (service, API prefix, origin and headers callback); it does not register with a scope and does not get the host's `locale`. Prefer the hook inside components; the exception is one instance per gesture when gestures can overlap (see [instant feedback](typescript-instant-feedback.md)).
200
+
201
+ `execute()` does not throw on a network failure or an unreadable response: it returns a result with `hasExceptions` true and `isRetryable` false, so handle those by branching on the result flags. The server may already have run the command in that case; resend only a command that is safe to repeat. The call can still reject on an unexpected error, such as a headers callback that throws, so keep a `catch` for that, as in the React example above.
188
202
 
203
+ - Busy state without React: `getCommandExecutionState(command).isExecuting` reads it, and `subscribeToCommandExecutionState(command, onChange)` calls `onChange` when the first execution starts and when the last one settles; it returns the function that unsubscribes. Both come from `@cratis/arc/commands`.
189
204
  - `command.onPropertyChanged(property => ..., this)` notifies when a command property is assigned, for code that must react to edits without React state.
190
- - `IdentityProvider` from `@cratis/arc/identity` is the non-React identity access: `await IdentityProvider.getCurrent()` (cached), `IdentityProvider.refresh()` and, at sign-out, `IdentityProvider.clearCache()`.
205
+ - `IdentityProvider` from `@cratis/arc/identity` is the non-React identity access; see Outside React in [Identity and availability](typescript-identity.md).