@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
@@ -35,7 +35,7 @@ Grow in stages and move only when a stage's pain is real (see [growth stages](re
35
35
  1. Feature/slice folders in one backend project and frontend package — start here for one capability.
36
36
  2. Module folders with clear ownership; keep peer implementations private.
37
37
  3. Separate module projects/packages in one host when build, ownership or access boundaries justify it.
38
- 4. Publish owner contracts at the first cross-module dependency, even if projects are not split yet: service/grain interfaces for same-host requests and public events for notifications. Never read another module's read models or internal sequences.
38
+ 4. Publish owner contracts at the first cross-module dependency, even if projects are not split yet: an owner-defined in-process service interface, bound through the host's dependency injection, for same-host requests and public events for notifications. Never read another module's read models or internal sequences.
39
39
 
40
40
  Extract a separate service and event store only when independent deployment, scaling or ownership pays for the boundary. Replace in-process dependencies with explicit service APIs for requests and outbox → inbox publication for notifications. Read [service extraction and delivery handoffs](references/service-and-delivery.md) before splitting a service or moving modeled/generated work.
41
41
 
@@ -77,7 +77,6 @@ Python has no application SDK: call the owning service through its HTTP API.
77
77
  - Declare the producer store for contracts consumed across stores; check local versus remote sequence selection in your SDK.
78
78
  - Declare private facts for the log and public contracts for the outbox; the kernel refuses the opposite declared visibility at those destinations.
79
79
  - Choose a custom publication sequence only when the outbox is not the intended destination. The event log is not a publish target; registration or origin metadata alone does not publish anything.
80
- - Pin the persisted job type name when renaming a job class; inventory job-step and request types separately (C#).
81
80
 
82
81
  ### Naming policy (see Naming policy)
83
82
 
@@ -31,10 +31,9 @@
31
31
  | Read-model container | pluralized type name (policy) | only with a namespace-sensitive policy | yes | `[ReadModelName("name")]` or fluent projection `.ContainerName("name")` |
32
32
  | Arc route | namespace segments + type/method name | yes | yes | `[Path("/api/...")]` |
33
33
  | Proxy file folder | namespace segments | yes | file name only | `NamespaceRoot`, `CratisProxiesSegmentsToSkip` |
34
- | Job type | simple type name | no | yes | `[JobType("name")]` |
35
34
  | Convention DI binding | `IName`→`Name` in the same namespace | breaks if the pair splits | breaks | keep the pair together or register explicitly |
36
35
 
37
- The observer ID, read-model identifier and container are independent. When the full model type name must change, plan the new definition and verify the successor against historical events and the chosen sink. Full-set registration can retire the old projection across namespaces without deleting its data. A successor projection sharing the container can get a replay recommendation; apply and verify the replay as needed. Do not expect this to rebuild a successor reducer. For an intentional container-only change, coordinate readers/writers and explicitly update the definition (`UpdateDefinition` in Workbench when saving an existing model); deploy matching declarations. This changes routing metadata, not rows or table names. Ordinary registration refuses a different container for the same identifier (even a case-only change or new generation), and clients declaring the old container after the update are refused too. Migrate/rebuild separately before cutting readers over.
36
+ The observer ID, read-model identifier and container are independent. When the full model type name must change, plan the new definition and verify the successor against historical events and the chosen sink. Full-set registration can retire the old projection across namespaces without deleting its data. A successor projection sharing the container can get a replay recommendation; apply and verify the replay as needed. Do not expect this to rebuild a successor reducer. For an intentional container-only change, coordinate readers/writers and explicitly update the definition (`UpdateDefinition` in Workbench when saving an existing model); deploy matching declarations. This changes routing metadata, not rows or table names. Ordinary registration refuses a different container for the same identifier with `FailedPrecondition`, even when the names differ only in case (such as after switching naming policy). If any container conflicts, Chronicle rejects the entire read-model registration batch before applying any of its definitions, so none of them is registered or updated. Dropping or renaming collections does not help: the check compares against the stored definition. Clients declaring the old container after the update are refused too. Migrate/rebuild separately before cutting readers over.
38
37
 
39
38
  ## Identity pinning
40
39
 
@@ -69,7 +68,6 @@ public record InvoiceListItem(InvoiceId Id, decimal Amount);
69
68
  - `[EventStore("billing")]` on a contract or assembly declares public origin (type wins). With event-type-based inference, a single remote origin routes reactors, reducers and model-bound projections to that inbox; a local origin or no origin selects the log. Fluent projections infer an inbox even for a named local origin. On the producer, explicitly select the outbox when observing local publications. Split observers that require multiple source sequences; origin alone does not publish.
70
69
  - `[Public]` declares a public contract without naming an origin. Neither declaration means private when there is no explicit registration. The kernel rejects public appends to the log and private appends to the outbox, including batches; inspect failed append results.
71
70
  - `[PublishTo(sequence)]` chooses a nondefault sequence for a projection/reducer event target; publication otherwise targets the outbox. It cannot target the log, redirect arbitrary appends or emit anything by itself.
72
- - Job type (Cratis Choreography): `[JobType("SendReminders")]` from `Cratis.Choreography.Jobs` before renaming a job class with persisted jobs.
73
71
 
74
72
  Explicit registration can supply the same ids instead of attributes, in `ChronicleOptions.ExplicitArtifacts` (before the client connects):
75
73
 
@@ -23,7 +23,7 @@ For each dependency that points up or sideways, pick one fix:
23
23
 
24
24
  | The dependency is | Fix |
25
25
  | --- | --- |
26
- | A same-host question or request to another module | Grain or service interface in the owner's `.Contracts`; only the owner accesses its read model |
26
+ | A same-host question or request to another module | Owner-defined in-process service interface in the owner's `.Contracts`, bound through the host's dependency injection; after extraction, an explicit service API; only the owner accesses its read model |
27
27
  | A request across a service boundary | Explicit service API; no dependency on the other host's implementation or read model |
28
28
  | "Tell me when" | Owner-published public event in `.Contracts`; use the outbox → inbox path for cross-store delivery |
29
29
  | A module needing an external provider | Port in the module's `.Contracts`; each `Integration.<Provider>` project implements it |
@@ -45,6 +45,5 @@ with contracts); everything else moves into the module that owns it. Delete the
45
45
  | 404 from the frontend or a script after a rename | Convention-based Arc routes can follow the namespace | Regenerate proxies; replace hard-coded routes; update reverse-proxy rewrites |
46
46
  | A generated proxy lost members after a split | A project that only references a type emitted a copy over the owner’s proxy | Generate each project into its own package; map referenced assemblies with `AssemblyToPackageMapping`. See the `cratis-arc-generate-proxies` skill (in `cratis/arc/csharp`). |
47
47
  | API docs, authorization or Release stripping silently stopped applying | Code keyed on a namespace or path | Replace name keys with explicit declarations or one shared pattern |
48
- | Stored jobs fail to resume after a namespace or type rename | A persisted job type or state identity no longer resolves | Keep `AssemblyName` where possible. If the type moved to another assembly, the stored job step type is an assembly-qualified name resolved at load, so either add a type forwarder in the old assembly or rewrite the stored names in a verified repair (see the rename window). Choose the forwarder when the old assembly can stay deployed; choose the rewrite when it will be retired. This is separate from the job IDs, which Chronicle keeps |
49
48
  | Module B does not compile without module A's internals | Hidden coupling | Contract or lower project; never `InternalsVisibleTo` |
50
49
  | Gate baseline keeps growing | Moving and refactoring in one step | Split the commit; fix the dependency, not the baseline |
@@ -32,8 +32,6 @@ First check for a supported migration for the affected artifact. If one is unava
32
32
  | --- | --- |
33
33
  | Reactor, reducer and projection ids, observer state, failed partitions, replay state | the event store's system and per-namespace collections |
34
34
  | Read model identifiers and definitions | read-model definitions and materialized storage; verify effective collection names |
35
- | Grain state type names | the Orleans storage |
36
- | Job, job step and request type names | job storage |
37
35
 
38
36
  This repair is for stored names only. If events, event type IDs or stored read-model shapes must change, plan that migration separately.
39
37
 
@@ -51,6 +49,6 @@ The repair is a script with:
51
49
  2. Scale the application to zero, back up the affected collections, run the dry runs and compare their
52
50
  counts with the expected ones.
53
51
  3. Have the authorized operator apply the reviewed repair and refresh any cached registrations as required by the deployment plan. The event-store kernel, not only the application, can retain pre-repair registrations: identify which kernel nodes cache the affected ones and document the supported refresh. If the approved plan requires a kernel restart, do it and verify registration before starting the new application. Then start the new application.
54
- 4. Check registration outcomes and compare IDs and positions with the approved mapping. No unexpected observer starts from zero or repeats effects. Confirm read-model rebuild/routing if applicable, test routes and every screen, and verify stored jobs resume.
52
+ 4. Check registration outcomes and compare IDs and positions with the approved mapping. No unexpected observer starts from zero or repeats effects. Confirm read-model rebuild/routing if applicable and test routes and every screen.
55
53
 
56
54
  Rollback is the backup plus the previous release; keep both until the checks pass.
@@ -4,8 +4,9 @@
4
4
 
5
5
  1. Give each service its own event store and deployment boundary. Keep tenant namespaces within each store; namespaces are not service names. Do not split a store by renaming namespaces or granting peers direct reads of read models.
6
6
  2. For a request, replace the same-host interface with an explicit service API. For a notification, publish an owner-defined contract from the producer's outbox and consume it from the producer-specific inbox in the receiver's store. Name the actual producer event store in the subscription or origin declaration. Source and target namespaces match by name, case-insensitively; forwarding does not create a missing namespace in the source. Verify the corresponding tenant namespace IDs exist on both sides.
7
- 3. Register the same contract IDs and the generations each side understands. If generations differ deliberately, prove compatible delivery or configure the required generation and source migrations; incompatible forwarding can park a partition. Do not confuse registering a public contract, subscribing, and publishing. Preserve old local event types and their replay path; a subscription does not migrate private history.
8
- 4. Prove the system with a fresh event per representative tenant: producer outbox → correct consumer inbox → observer position and downstream result. Test an unmatched namespace and absence of cross-tenant delivery. Validate replay and external effect deduplication before retiring the old binding. For publication details use `cratis-chronicle-publish-contract`.
7
+ 3. Keep the public event types owned by the producing service and separate from its implementation. When producer and consumer are both C#, share the producer's contracts project or package (`<Service>.Contracts`) by default; both sides reference it. A consumer on another SDK declares the event type locally with the same event type ID and a compatible schema and generation; a shared package is not required. In either case a consumer never references the producing service's project or its private events. For the layout of the contracts project use `cratis-chronicle-publish-contract`.
8
+ 4. Register the same contract IDs and the generations each side understands. If generations differ deliberately, prove compatible delivery or configure the required generation and source migrations; incompatible forwarding can park a partition. Do not confuse registering a public contract, subscribing, and publishing. Preserve old local event types and their replay path; a subscription does not migrate private history.
9
+ 5. Prove the system with a fresh event per representative tenant: producer outbox → correct consumer inbox → observer position and downstream result. Test an unmatched namespace and absence of cross-tenant delivery. Validate replay and external effect deduplication before retiring the old binding. For publication details use `cratis-chronicle-publish-contract`.
9
10
 
10
11
  ## Inventory and removal
11
12
 
@@ -9,9 +9,9 @@ These are application structure conventions, not framework admission rules. Keep
9
9
  | 1 | One backend project and one frontend package; feature/slice folders. | Default for a prototype, single-purpose service or one team with one capability. |
10
10
  | 2 | Named module folders containing whole feature/slice folders in the same projects. | People recognize distinct capabilities, with different vocabulary or navigation, settings or access grouped by capability. |
11
11
  | 3 | Each module has a backend project and frontend package; the host composes modules on purpose-specific platform projects. | A module needs separate build, specs or ownership; other modules reach into its internals; or an audience or entitlement boundary needs enforceable separation. |
12
- | 4 | Publish `<Module>.Contracts` for a module others depend on. | At the first cross-module request or event dependency. Share service or grain interfaces, public events and the concepts they carry, not commands, read models or internal logic. |
12
+ | 4 | Publish `<Module>.Contracts` for a module others depend on. | At the first cross-module request or event dependency. Share owner-defined service interfaces, public events and the concepts they carry, not commands, read models or internal logic. |
13
13
 
14
- For a new application with several teams, distinct capabilities, audience gating or known product-line modules, start at stage 2 if folders suffice; start at stage 3 only when separate ownership, build or enforcement already applies. Publish contracts when the dependency first appears, regardless of folder or project stage. Use owner-published service/grain interfaces for same-host requests and public events for notifications. Do not expose read models or internal event sequences. A separate deployment is a service-boundary decision: use a separate event store, explicit service APIs for requests, and outbox → inbox publication for notifications. Tenant namespaces separate data within a store, not services.
14
+ For a new application with several teams, distinct capabilities, audience gating or known product-line modules, start at stage 2 if folders suffice; start at stage 3 only when separate ownership, build or enforcement already applies. Publish contracts when the dependency first appears, regardless of folder or project stage. Use owner-published in-process service interfaces, bound through the host's dependency injection, for same-host requests and public events for notifications. Do not expose read models or internal event sequences. A separate deployment is a service-boundary decision: use a separate event store, explicit service APIs for requests, and outbox → inbox publication for notifications. Tenant namespaces separate data within a store, not services.
15
15
 
16
16
  ## Allowed references
17
17
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cratis-arc-authorize-request
3
- description: Use when restricting who may execute an Arc command or query on the server, including writing a custom authorization policy or a command/query filter that denies a request, or a rule that depends on who acts on behalf of a user. Not for selecting a tenant (use cratis-arc-isolate-tenant).
3
+ description: "Use when restricting who may execute an Arc command or query on the server, including writing a custom authorization policy or a command/query filter that denies a request, a rule that depends on who acts on behalf of a user, or deciding which paths of a service behind Cratis AuthProxy admit anonymous or token-bearing callers and whether the service takes part in identity verification. Not for selecting a tenant (use cratis-arc-isolate-tenant) or for setting up AuthProxy itself: sign-in providers, who is admitted at the ingress, tenant resolution, sessions, routing (use cratis-authproxy-configure)."
4
4
  compatibility: Requires an Arc backend with a trusted source of caller identity.
5
5
  ---
6
6
 
@@ -10,13 +10,13 @@ Authorization decides whether the caller may invoke an operation. Authentication
10
10
 
11
11
  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.
12
12
 
13
- When the application runs behind Cratis AuthProxy, read [who authenticates what](references/authproxy.md) before opening a path to anonymous or token-bearing callers.
13
+ When the application runs behind Cratis AuthProxy, read [who authenticates what](references/authproxy.md) before opening a path to anonymous or token-bearing callers, changing how a service takes part in identity verification, deciding what the backend may trust of a session, or letting support act on behalf of a user. To set up AuthProxy itself (sign-in providers, who is admitted at the ingress, tenant resolution, sessions and the cookie domain that shares a sign-in across hosts, routing), use the `cratis-authproxy-configure` skill.
14
14
 
15
15
  ## Default path: require sign-in on the operation
16
16
 
17
17
  1. Verify that the host supplies an authenticated principal for a real credential and does not accept a caller's assertion of identity. If it cannot distinguish that credential from an anonymous request, fix authentication first.
18
18
  2. Declare sign-in on the command or query, not inside its handler. For example, a shift-swap request (names are illustrative) might be open to any signed-in employee **if** the host authenticates only employees. If other callers can sign in, declare the employee role instead. Apply the requirement to the read model only when its queries share the same rule.
19
- 3. Exercise the server pipeline with and without the credential. The denied request must not mutate state, append events or reveal protected rows. For a role or policy, also try a signed-in caller who fails it. Inspect the authorization verdict: an HTTP challenge at the host and an Arc denial need not have the same status. A direct handler test exercises neither gate.
19
+ 3. Exercise the server pipeline with and without the credential. The denied request must not mutate state, append events or reveal protected rows. For a role or policy, also try a signed-in caller who fails it. Repeat each case on every transport that reaches the operation (such as direct HTTP, WebSocket and the live-query hub), because they can pass different gates. Inspect the authorization verdict: an HTTP challenge at the host and an Arc denial need not have the same status. A direct handler test exercises neither gate.
20
20
 
21
21
  ## Capability catalog
22
22
 
@@ -1,13 +1,27 @@
1
1
  # Behind Cratis AuthProxy: who authenticates what
2
2
 
3
+ ## Contents
4
+
5
+ - The boundary
6
+ - Choose how a path is admitted
7
+ - Bearer routes
8
+ - Anonymous paths
9
+ - Sign-in providers
10
+ - Sessions across tenant hosts
11
+ - On-behalf sessions
12
+ - Verify
13
+
3
14
  Read this when the application is deployed behind Cratis AuthProxy. It is deployment configuration under `Cratis:AuthProxy:Services:<service>` and applies to every backend language. Names below are illustrative.
4
15
 
16
+ This reference covers what the application may rely on and which paths a service opens. To set up AuthProxy itself (sign-in providers, the claim gate that admits people, tenant resolution, sessions and sign-out, routing and operations), use the `cratis-authproxy-configure` skill.
17
+
5
18
  ## The boundary
6
19
 
7
20
  - AuthProxy decides who the caller is before the request reaches the application. The application trusts the principal and tenant AuthProxy forwards and authorizes that identity; it does not check passwords, session cookies or issuer tokens itself. The one exception is a personal access token, which AuthProxy passes on unverified (see Bearer routes).
8
21
  - The boundary holds only when nothing reaches the application around AuthProxy. Restrict the application's listener to the proxy at the network level. AuthProxy removes caller-supplied identity and tenant headers and writes its own; a route that bypasses it does neither.
9
- - Forwarded identity is not authorization. The application still declares sign-in, roles and policies on each operation and still checks tenant membership.
22
+ - Forwarded identity is not authorization. The application still declares sign-in, roles and policies on each operation and must still check tenant membership on tenant-scoped operations.
10
23
  - Identity verification is `Required` by default for a service with a `Backend`: after sign-in AuthProxy asks the application's `/.cratis/me` and admits a browser caller only on an explicit positive verdict. A refusal, an error, a timeout or an answer without a verdict denies. The application must therefore answer that endpoint with whether this person may use it.
24
+ - To take a service out of verification, set `ResolveIdentityDetails: false` on it, for example a static-file server that cannot answer `/.cratis/me`: AuthProxy then skips only that service's `/.cratis/me`; every other participating service is still asked and can still deny. The supported `IdentityVerification` modes are `Required` (default) and `BestEffort`. A `BestEffort` service causes a denial only when it answers 403, or when AuthProxy is configured to sign the call to it and cannot sign it. A 200 that says "not authorized", an error, a timeout or an unreachable service causes no denial from that service, but another service or a later gate can still deny the request. Use it only for a service that merely adds display details, never for the service that decides who may enter.
11
25
 
12
26
  ## Choose how a path is admitted
13
27
 
@@ -83,14 +97,44 @@ Declare the identity providers in one place only. For a Screenplay deployment, l
83
97
 
84
98
  ## Sessions across tenant hosts
85
99
 
86
- `Session:CookieDomain` shares one sign-in across hosts under a parent domain. It cannot be combined with `SubHost` tenant resolution: AuthProxy refuses to start, because one session would then be valid on every tenant's host. With a tenant per sub-host, leave `CookieDomain` empty so each tenant host keeps its own session.
100
+ `Session:CookieDomain` shares one sign-in across hosts under a parent domain. With `SubHost` tenant resolution AuthProxy refuses to start, and no setting overrides that: the host-only session cookie is what keeps one tenant's session off the next tenant's host, and AuthProxy's tenant verification only confirms that the tenant exists, not that the person belongs to it. Choose one:
101
+
102
+ - Keep `SubHost` and leave `CookieDomain` empty, so each tenant host signs in separately.
103
+ - Resolve tenants another way, such as the `Claim` strategy, and then set the cookie domain.
104
+
105
+ With a cookie domain:
106
+
107
+ - Use the narrowest domain that covers every service host. AuthProxy refuses to start when a host listed in a service's `Hosts` is outside it, or when the domain is an IP address, a top-level domain, a wildcard or has a port.
108
+ - `SameSite=Lax` does not separate sibling subdomains, so treat every host under the domain as one trust boundary.
109
+
110
+ Cookie scope only decides what a browser sends. AuthProxy does not bind a session to a host, so a session cookie copied to another host of the same AuthProxy still authenticates there, with or without a cookie domain. Authenticating does not grant that host's tenant; separate gates decide that:
111
+
112
+ - **Credential binding:** a session bound to another tenant, through a bound tenant-selection cookie or a `Claim` tenant, is refused with 403 before any membership lookup, even for a member of both tenants.
113
+ - **Membership confirmation:** when `Selection` is configured, AuthProxy confirms through the tenants endpoint that the person belongs to a tenant addressed by `Host`, `SubHost` or `Route`, and trusts that confirmation until `Session:TenantRevalidationInterval` passes. A zero or negative interval remembers nothing: AuthProxy skips the check only for a request carrying a bound tenant-selection cookie for that tenant, and confirmation of a `Route` tenant does not issue one, so without it AuthProxy checks membership again. Without `Selection`, AuthProxy leaves membership to the application.
114
+ - **The application:** it must enforce tenant membership on every tenant-scoped operation; Arc's sign-in and role checks do not do that.
115
+
116
+ ## On-behalf sessions
117
+
118
+ An on-behalf session lets a support person or agent, signed in as themselves, act for one user in one tenant for one issue. It is off until `Cratis:AuthProxy:OnBehalf` is configured; without that section AuthProxy's on-behalf endpoints answer 404.
119
+
120
+ - **The application decides.** AuthProxy starts a session only after the backend of `OnBehalf:Service` confirms a live grant on `GET /.cratis/on-behalf/grants`, and asks again once its last answer is no longer fresh. An answer stays fresh until the earliest of `OnBehalf:RecheckInterval` (30 seconds by default), the grant's own `validUntil` and the session's expiry. Only an explicit live answer counts; a refusal ends the session, and an error or timeout refuses the request with 503.
121
+ - **The application authenticates each callback.** The grant check and both notifications carry a signed `Authorization: Bearer` attestation. Arc's forwarded-request settings do not cover these three calls, so the receiver verifies each one itself: signature against the pinned public keys, issuer, audience, validity period, the purpose that endpoint expects, the method, URL and body hash against the request, and a token identifier not seen before within the token's lifetime. Refuse a call whose attestation is missing or fails any of these. Only then take the represented user, tenant, issue, session identifier and actor from the verified token; the actor is its `act` claim. The actor header on these calls is advisory and may be omitted, and neither it nor the query string or body authenticates anyone.
122
+ - **The application keeps a durable record per session.** AuthProxy reports each session to `POST /.cratis/on-behalf/sessions/started` and `POST /.cratis/on-behalf/sessions/ended`. The check before a session starts and every later check are the same signed request, so the verified session identifier is the only thing that tells them apart:
123
+ - For a session identifier the application has never seen, decide on the grant alone and, when the answer is live, durably record the session as pending. AuthProxy issues the session only when the started notification is then acknowledged; record that acknowledged start.
124
+ - For a session identifier already recorded, answer live only while the grant is live and the record shows an acknowledged start that has not ended. Answer not live for one that is still pending or has ended.
125
+ - Keep each record, including an ended one, until the session's `expiresAt` has passed. A record lost earlier makes an ended session look new, and the application would reopen it.
126
+ - Record an end idempotently by session identifier. The ended notification is best-effort: one AuthProxy instance sends it once, several instances can each send it for the same session, and it may never arrive, so treat `expiresAt` from the started notification as the latest the session can last.
127
+ - **Who may act** is limited by `OnBehalf:ActorAuthorization:RequiredClaims`, on top of the deployment's own admission requirements. AuthProxy evaluates those claims when a session is started, not on each request of a running session; ending access during a session is the application's grant answer.
128
+ - **What the application receives:** the represented user as the principal and tenant, with the actor and a signed assertion beside them. A path in `AnonymousPaths` is forwarded without the actor or the assertion. Only `OnBehalf:Service`, or the services listed in `OnBehalf:Services`, are reached during a session; a request to any other service is refused with 403. So is a request to a permitted service whose route forwards the signed-in user's access token to the backend: during a session that token is the actor's, and AuthProxy refuses the request instead of forwarding it.
129
+ - **Pair forwarded requests with the application's verification.** For the requests AuthProxy forwards during a session, a C# Arc backend turns on both `TrustForwardedIdentityHeaders` and `OnBehalfOf`, the latter with the issuer, audience and public keys matching `OnBehalf:Attestation` (`cratis-arc-host-application` skill, `references/csharp-identity.md`). Until both are on, and whenever the assertion does not verify, Arc rejects the forwarded identity of a request carrying an on-behalf header instead of authenticating it. A backend without such verification must verify the assertion itself before believing either identity header. These settings verify forwarded requests only, not the three callbacks above.
130
+ - **Authorization still evaluates the represented user.** A rule about who is acting reads the actor explicitly; see Delegated sessions in this skill.
87
131
 
88
132
  ## Verify
89
133
 
90
134
  1. Without a credential, a bearer-route path answers 401 and an ordinary path does not reach the application.
91
135
  2. An issuer token for another tenant, or one missing a required scope, is refused before the application.
92
136
  3. Forged `x-cratis-tenant-id` and `x-ms-client-principal*` values never survive. On an authenticated request the application sees AuthProxy's values, not the forged ones. On an anonymous path, and on a personal-access-token request, it sees none of these headers.
93
- 4. A browser caller for whom `/.cratis/me` answers "not authorized", or does not answer, is not admitted.
137
+ 4. For a service with `Required` verification, a browser caller whose fresh `/.cratis/me` check answers "not authorized", or gets no answer, is not admitted. A remembered positive answer skips the fresh check only for the same account and tenant, while the set of `Required` services is unchanged and the answer has not expired. Every other gate still applies.
94
138
  5. On a route that accepts personal access tokens, the application refuses a well-formed but unknown or revoked token, and a valid token used for another tenant.
95
139
  6. A request that skips the proxy cannot reach the application's listener.
96
140
  7. No path that serves a credential-bearing endpoint appears in `AnonymousPaths`, and none appears in `PassCallerAuthorizationPaths` unless the application authenticates that credential itself.
@@ -1,5 +1,11 @@
1
1
  # C#: filter requests, narrow rows and guard delivery
2
2
 
3
+ ## Contents
4
+
5
+ - Gate a family of operations
6
+ - Narrow rows before counts and paging
7
+ - Recheck access on delivery
8
+
3
9
  ## Gate a family of operations
4
10
 
5
11
  Arc discovers `IAuthorizationCommandFilter` and `IAuthorizationQueryFilter` implementations; do not register them. They run before ordinary filters, and a denial stops the operation. A paged query can fail paging validation before its authorization filter runs. For example, in a staff-only service use `ICurrentPrincipalAccessor.Current` in a filter to check a host-issued clearance. Limit a feature-specific filter to the intended `context.Type` (command) or `context.Name` (query), returning success elsewhere. The optional reason becomes the result's `AuthorizationFailureReason`.
@@ -31,15 +37,15 @@ public sealed class StaffCommands(ICurrentPrincipalAccessor callers) : IAuthoriz
31
37
  Register `builder.Services.AddScoped<IQueryRowNarrowing, VisibleShifts>();` with a scoped access store. In `Cratis.Arc.Queries`, the typed base builds a membership predicate for the read model; it applies to every query of that model unless `AppliesTo(QueryContext)` is overridden.
32
38
 
33
39
  ```csharp
34
- public sealed class VisibleShifts(IShiftAccess access) : QueryRowNarrowing<Shift, Guid>
40
+ public sealed class VisibleShifts(IShiftAccess access, ICurrentPrincipalAccessor callers) : QueryRowNarrowing<Shift, Guid>
35
41
  {
36
42
  protected override Expression<Func<Shift, Guid>> Key => shift => shift.Id;
37
43
  protected override ValueTask<IEnumerable<Guid>> GetAllowedKeys(QueryContext context) =>
38
- access.VisibleIds(context.AuthorizedPrincipal, context.CancellationToken);
44
+ access.VisibleIds(callers.Current, context.CancellationToken);
39
45
  }
40
46
  ```
41
47
 
42
- Have the store return an empty set for no access and throw on lookup failure. For a different predicate implement `IQueryRowNarrowing.GetPredicate(Type, QueryContext)` returning `ValueTask<LambdaExpression?>`: null means **not applicable**, never “no access”. Test that totals as well as rows exclude another caller's shifts. Scope the underlying producer too, especially for streams; a delivery guard decides on the whole emission, not individual rows.
48
+ Read the caller from `ICurrentPrincipalAccessor.Current`. `QueryContext.AuthorizedPrincipal` is set only when scheme authentication selected a different principal and is `null` otherwise, so do not use it to read the caller. Have the store return an empty set for no access and throw on lookup failure. For a different predicate implement `IQueryRowNarrowing.GetPredicate(Type, QueryContext)` returning `ValueTask<LambdaExpression?>`: null means **not applicable**, never “no access”. Test that totals as well as rows exclude another caller's shifts. Scope the underlying producer too, especially for streams; a delivery guard decides on the whole emission, not individual rows.
43
49
 
44
50
  ## Recheck access on delivery
45
51
 
@@ -59,3 +65,12 @@ public sealed class ActiveSession(ISessions sessions) : StateAwareEmissionGuard<
59
65
  Missing key/state, read failure and rejection yield `DenyAndTerminate`; override `OnDenied(context, reason, exception)` for diagnostics. Requested read cancellation propagates. If membership rather than session validity grants access, capture the authorized organization in `QueryContext.SubscriptionScope` in the admission filter and recheck membership against that scope at delivery. Use the emission's principal, not `HttpContext`: the hub subscribe request has ended.
60
66
 
61
67
  For conditional suppression implement `Task<ObservableQueryEmissionVerdict> Guard(ObservableQueryEmissionContext context)` directly. For example, after a fresh permission check, `return !allowed ? ObservableQueryEmissionVerdict.DenyAndTerminate : paused ? ObservableQueryEmissionVerdict.Suppress : ObservableQueryEmissionVerdict.Allow;`. Suppress skips just this emission; terminate on revocation. Return `Allow` for unrelated `QueryName` values when a rule applies only to particular queries. Revoke access after first delivery without reconnecting; the next protected update must not arrive.
68
+
69
+ When the check itself cannot run, choose between the two failure outcomes deliberately. `Unavailable` needs a guard that implements `Guard` directly; a `StateAwareEmissionGuard` read failure always denies.
70
+
71
+ | Situation | Do | Result |
72
+ | --- | --- | --- |
73
+ | The permission lookup is temporarily unreachable and the caller should retry | Catch that failure and return `ObservableQueryEmissionVerdict.Unavailable` | No data is written and the operation ends. Where the transport reports it, the caller can retry, and the Arc TypeScript client does so automatically with backoff; elsewhere the caller sees an unauthorized result. |
74
+ | Anything else goes wrong in the guard | Let the exception propagate | Arc fails closed on a non-fatal exception: it logs an error and treats it as `DenyAndTerminate`. A cancellation because the subscription ended closes delivery without an error. A fatal runtime failure, such as running out of memory, is not turned into a verdict and escapes. |
75
+
76
+ Never return `Allow` because a lookup failed. With several guards the most restrictive verdict wins (`DenyAndTerminate`, then `Unavailable`, then `Suppress`, then `Allow`), so do not rely on guard order. For telling a temporary guard failure from a denial on the client, see `references/csharp.md` in the `cratis-arc-diagnose-live-query` skill.
@@ -33,7 +33,7 @@ public interface IShiftStore { void Reschedule(Guid id, DateTimeOffset start); }
33
33
 
34
34
  Choose a different declaration only when needed:
35
35
 
36
- - `[Roles("dispatcher", "supervisor")]` or `[Authorize(Roles = "dispatcher,supervisor")]`: either role suffices. Stacked attributes must **all** pass.
36
+ - `[Roles("dispatcher", "supervisor")]` or `[Authorize(Roles = "dispatcher,supervisor")]`: either role suffices. To require **both** roles, stack one `[Authorize(Roles = "dispatcher")]` and one `[Authorize(Roles = "supervisor")]` on the same target: every authorization attribute on a declaration must pass. Do not repeat `[Roles]` on one target; write the second requirement as `[Authorize(Roles = ...)]`.
37
37
  - `[Authorize(Policy = "owns-shift")]`: evaluate the registered decision below. `[Authorize(AuthenticationSchemes = "StaffBearer")]` selects a registered ASP.NET Core scheme instead of trusting the default identity; comma-separate multiple schemes.
38
38
  - `[Roles("payroll")]` on a query method **replaces** the read-model authorization declaration; repeat any restrictions that should still apply. `[AllowAnonymous]` explicitly opens a method or type; do not combine it with a restriction on the same target: that fails with `AmbiguousAuthorizationLevel`. Independent filters still run.
39
39
  - `[RequiresScope("shift:change")]` adds a ceiling, **not** sign-in: combine with ordinary authorization. For every verified caller identity, all required scopes must match exactly (ordinal); type and method scopes accumulate. An ordinary principal without a verified capability identity is not restricted by this ceiling.
@@ -107,14 +107,23 @@ This denies when there is no actor; allow `!context.Principal.IsActedOnBehalfOf(
107
107
  ## Common mistakes
108
108
 
109
109
  - Importing both `Cratis.Arc.Authorization` and `Microsoft.AspNetCore.Authorization` in one file makes `[Authorize]` and `[AllowAnonymous]` ambiguous. Import only Arc's namespace in command and query files.
110
- - Expecting stacked attributes to mean "any of": roles inside one attribute are alternatives, separate attributes must all pass.
110
+ - Expecting stacked attributes to mean "any of": roles inside one attribute are alternatives, separate attributes must all pass. Listing two roles in one attribute never means "both".
111
111
  - Assuming a query method's own declaration adds to the read model's: it replaces it.
112
112
  - Reporting a denial as a validation error or an exception. Return an unauthorized result from a filter, or `AuthorizationResult.Failure(...)` from the command.
113
113
  - Testing the handler directly. Neither attributes nor filters run outside the pipeline.
114
114
 
115
115
  ## Trusted background work
116
116
 
117
- Outside HTTP use the injected `ISystemExecution` for a bounded scope: `using (systemExecution.AsSystem("dispatcher")) { var result = await pipeline.Execute(command); /* inspect result */ }`. With no roles the actor satisfies sign-in only. Use `As(trustedPrincipal)` for an explicit server-selected identity. Await inside the scope so disposal restores the previous actor. The system actor is authenticated with `SystemPrincipal.AuthenticationType` (`"System"`) and `SystemPrincipal.Subject` (`"[System]"`), which is what audit trails show. The scoped principal is used only when there is no HTTP request, so it cannot elevate an HTTP caller. Keep the scope as narrow as the work. Do not take roles from request or event payloads. In the Chronicle integration put `[Cratis.Arc.Chronicle.Reactors.ExecuteCommandsAsSystem("dispatcher")]` on a reactor class for its **returned** commands only; separately invoked commands need their own principal.
117
+ Outside HTTP use the injected `ISystemExecution` for a bounded scope: `using (systemExecution.AsSystem("dispatcher")) { var result = await pipeline.Execute(command); /* inspect result */ }`. With no roles the actor satisfies sign-in only. Use `As(trustedPrincipal)` for an explicit server-selected identity. Await inside the scope so disposal restores the previous actor. The system actor is authenticated with `SystemPrincipal.AuthenticationType` (`"System"`) and `SystemPrincipal.Subject` (`"[System]"`), which is what audit trails show. The scoped principal is used only when there is no HTTP request, so it cannot elevate an HTTP caller. The same principal is authorized, so it must hold at least one role from each role-restricted attribute on the command. Keep the scope as narrow as the work. Do not take roles from request or event payloads. In the Chronicle integration put `[Cratis.Arc.Chronicle.Reactors.ExecuteCommandsAsSystem("dispatcher")]` on a reactor class for its **returned** commands only; separately invoked commands need their own principal.
118
+
119
+ ### Who is recorded as the cause
120
+
121
+ With the Chronicle integration, events record who caused them as `causedBy`:
122
+
123
+ - **Inside an HTTP request:** `AsSystem` and `As` change nothing; the cause is resolved as for any other request. A verified caller credential is recorded as the caller, or, when the credential carries an actor, as that actor with the verified caller as its `OnBehalfOf`. A principal with an actor is recorded as described below, and anything else as the identity Chronicle resolves for the request. A Chronicle identity that code set explicitly wins over the first two.
124
+ - **`As(principal)` outside HTTP:** the principal becomes the cause only when the identity that would otherwise be recorded has the System subject. It then takes that identity's place and keeps its `OnBehalfOf` chain after it, which is how a reactor keeps the triggering event's chain. Any other identity, such as one set explicitly, stays the cause.
125
+ - **Claim mapping:** `sub` becomes the subject, `name` the name and `preferred_username` the user name, with `Identity.Name` as the fallback for the last two. Give the principal's `ClaimsIdentity` an authentication type; an unauthenticated principal leaves the recorded identity unchanged.
126
+ - **A principal with an actor** (acting on behalf of someone): the actor is recorded as the cause with the represented user as its `OnBehalfOf`, when both carry a subject, name or user name; otherwise only the one that does is recorded. Inside an HTTP request this applies unless code has set a Chronicle identity explicitly or the caller is a verified caller credential, which follows its own rule above and still records its actor as the cause.
118
127
 
119
128
  ## Not supported in this SDK
120
129
 
@@ -77,6 +77,8 @@ builder.addAuthorizationCommandFilter(CommandGate).addAuthorizationQueryFilter(Q
77
77
 
78
78
  Alternatively use discovered classes marked `@authorizationCommandFilter()` or `@authorizationQueryFilter()`. The blanket filters above also deny anonymous operations; explicitly account for any intended exceptions.
79
79
 
80
+ To limit a gate to some operations, match `operationName` exactly. It is the declared namespace and the name joined with a dot, skipping an empty part; a model-bound query's name includes its read-model class. Query introspection shows it as `fullyQualifiedName`; command introspection shows `namespace` and `name` separately, so join them. For example, a command without a namespace is `AcknowledgeShift`, and the query `byName` on read model `Item` is `Item.byName`. Deny when `operationName` is absent, as it may be on a manually built context. Never infer the operation from the `command`/`query` input. Register a filter token in one group per operation kind: a token in both the authorization and the pipeline group for commands, or for queries, makes `build()` throw.
81
+
80
82
  ## Guard ongoing delivery
81
83
 
82
84
  Admission at subscription is not a continuing entitlement. Register a scoped service in the server options and include its token in `query.observableEmissionGuards`. For example, with an application lookup that checks the current entitlement for the indicated query and input:
@@ -63,6 +63,7 @@ For application-owned documents only: `await shipments.InsertOneAsync(item)`, `R
63
63
  - For a named sink configure `Cratis:MongoDB:Sinks:reporting:Server` or `ServerFile` (secret file). Use Chronicle's `[Sink("reporting")]` or Arc's `[ReadModelSink("reporting")]` from `Cratis.Arc.Sinks` (Arc wins). Inject the model's collection normally. Lower-level code uses `IMongoDBReadModelDatabases.GetFor(typeof(Shipment))` or `IMongoDBSinks.GetClientFor("reporting")`. Unknown named sinks fail rather than falling back.
64
64
  - Leave `DirectConnection` unset to preserve the URI setting; true pins a server, not a change-stream capability. `EnableResilience` defaults on: async collection-not-found may return empty/default or wait on a stream. Set false for native driver failure behavior. `LogCommandBodies` is off; enable only in a controlled environment without sensitive data.
65
65
  - Concepts serialize as their underlying values; use nested mapped types for actual subdocuments. Arc supplies serializers for temporal and geospatial values and polymorphic discrimination. Match stored IDs and discriminators, not just the apparent JSON shape.
66
+ - Arc's default serializer stores a `DateTimeOffset` as a BSON date holding its `ToUnixTimeMilliseconds()` value. The offset and sub-millisecond ticks are lost, and the value reads back as `+00:00`. When local time matters, store the offset or time-zone ID in its own field. For equality with a stored value, compare the `ToUnixTimeMilliseconds()` results of both values rather than trimming ticks yourself; use a stable key if distinct instants can share a millisecond. That serializer accepts only `BsonType.DateTime` (default) and `BsonType.String`; `Int64` throws. `String` is not a lossless alternative: its format does not round-trip. For a different storage contract, set an application-owned serializer on that member in a class map (`SetSerializer`).
66
67
  - Configure maps **before first use** (driver maps freeze). For example:
67
68
 
68
69
  ```csharp
@@ -86,7 +86,7 @@ A watch invalidates the collection, not just matching IDs; rerun the scoped sele
86
86
 
87
87
  ## Override placement only when necessary
88
88
 
89
- For simple overrides, `database_resolver: Dispatch.Databases` implements `Cratis.Arc.MongoDB.DatabaseNameResolver.resolve(tenant, options)` (handle nil); `server_resolver: Dispatch.Servers` implements `Cratis.Arc.MongoDB.ServerResolver.resolve(options)`. For tenant-specific servers or rotating identities, add this option inside `mongodb:`:
89
+ For simple overrides, `database_resolver: Dispatch.Databases` implements `Cratis.Arc.MongoDB.DatabaseNameResolver.resolve(tenant, options)` and returns the database name. `options` is the `Cratis.Arc.MongoDB.Options` struct, not a keyword list: read `options.database`, and return it unchanged when `Cratis.Arc.Tenancy.default?(tenant)` is true (`nil`, `""`, or `"Default"` or `"[notset]"` in any letter case); `server_resolver: Dispatch.Servers` implements `Cratis.Arc.MongoDB.ServerResolver.resolve(options)`. For tenant-specific servers or rotating identities, add this option inside `mongodb:`:
90
90
 
91
91
  ```elixir
92
92
  connection_resolution: [
@@ -97,7 +97,14 @@ connection_resolution: [
97
97
  ]
98
98
  ```
99
99
 
100
- Both slots default to `:default`; connection applies first, then identity. A resolved database replaces tenant suffixing. Templates accept `:database` and `:connection_string` with `{tenant}` (`Default` if unset), `{storage}` and `{purpose}`; missing substitutions fail. HTTP POST sends storage `MongoDB`, purpose `Runtime` or `Schema`, and `scope.tenant`; `timeout:` defaults to 10000 ms. Return 200 with the chosen `connectionString`, `database`, `identity` or `expiresAt` fields, or 204 for unchanged. Keep endpoint credentials separate from database credentials. Alternatively implement `Cratis.Arc.MongoDB.ConnectionResolver.resolve/1`, e.g. `def resolve(%{scope: %{"tenant" => t}}), do: {:ok, %Cratis.Arc.MongoDB.ResolvedConnection{database: "dispatch-" <> t}}`. Cache duration defaults to 300 seconds; answers are keyed by purpose and tenant, refreshed ahead of expiry and invalidated on authentication rejection. Schema purpose selects permissions, not a migration.
100
+ Both slots default to `:default`; connection applies first, then identity. A resolved database replaces tenant suffixing. Templates accept `:database` and `:connection_string` with `{tenant}` (`Default` for the default tenant), `{storage}` and `{purpose}`; missing substitutions fail. HTTP POST sends storage `MongoDB`, purpose `Runtime` or `Schema`, and `scope.tenant`; `timeout:` defaults to 10000 ms. Return 200 with the chosen `connectionString`, `database`, `identity` or `expiresAt` fields, or 204 to leave this slot unchanged. Keep endpoint credentials separate from database credentials. For rules a template cannot express, set `connection: Dispatch.Connections` to a module implementing `Cratis.Arc.MongoDB.ConnectionResolver.resolve/1`. It receives `%{storage: "MongoDB", purpose: :runtime | :schema, scope: %{"tenant" => t}}` (`t` is `"Default"` for every default tenant: unset, empty, `Default` or `[NotSet]` in any case) and returns `{:ok, %Cratis.Arc.MongoDB.ResolvedConnection{...}}`, `:unchanged` (this slot changes nothing; the identity slot still runs) or `{:error, reason}`. A resolved database applies to the default tenant too, and a database from the identity slot wins over one from the connection slot. Only when neither slot returns a database does the database-name resolver choose it. So the `:unchanged` clause below keeps the bare `database:` name for the default tenant only if the identity slot returns no database for it and the database-name resolver returns the base name:
101
+
102
+ ```elixir
103
+ def resolve(%{scope: %{"tenant" => "Default"}}), do: :unchanged
104
+ def resolve(%{scope: %{"tenant" => t}}), do: {:ok, %Cratis.Arc.MongoDB.ResolvedConnection{database: "dispatch-" <> t}}
105
+ ```
106
+
107
+ Cache duration defaults to 300 seconds; answers are cached per purpose and tenant. Nothing refreshes in the background. Without a returned expiry, the next lookup resolves again once the cache duration passes. With `expiresAt`, the expiry replaces the cache duration: the next lookup from one minute before the earliest returned expiry resolves again. A MongoDB authorization or authentication error (code 13 or 18) from an Arc write or index call (`insert`, `insert_many`, `save`, `update`, `update_many`, `delete`, `delete_many`, `create_index`) drops the cached answer. Read failures, for example from `find` or `count`, do not drop it, and neither does an unreachable server. Pass `purpose: :schema` to `collection/3` (for example before creating indexes) so a configured resolver can return a more privileged identity; the flag itself grants no permissions and runs no migration.
101
108
 
102
109
  ## Test against a real server
103
110
 
@@ -38,6 +38,8 @@ Use the project's reference for the supported forms. Use optional mechanisms onl
38
38
  - **Event history:** when a rule is easier to state over the events of one source than over a read model, or several commands share rules over that history, decide from the stream's events or an aggregate root where the SDK reference offers one. The read model stays the default. The decision is guarded only against changes to the history it read; a competing write there rejects the command.
39
39
  - **Generated argument:** Allocate a server-owned input per invocation; name a capture for reuse and opt out of guarded freshness only deliberately (C# only).
40
40
  - **Response declaration:** Expose only the value the caller needs; use the SDK’s success form for work without a useful payload.
41
+ - **Updated view:** Do not return the read model the command affects. Return an identity or a value the decision produced; the caller reads the view through a query.
42
+ - **Return type:** For C#, "What `Handle` may return" in `references/csharp.md` is the guide to which return type fits and what refuses a command.
41
43
  - **Composite outcome:** Combine effects and at most one response; use an explicit alternatives wrapper for mutually exclusive outcomes rather than returning an error-shaped success object.
42
44
  - **Declaration faults:** an unresolvable dependency, a requested state lookup without a command key, or more than one unconsumed return value is a programming error. It surfaces as an execution fault, not as validation feedback; fix the declaration rather than catching it.
43
45
  - **Refusal:** Return recognized validation feedback when the decision cannot proceed; put rules that should run on preflight in `cratis-arc-validate-command`.
@@ -6,6 +6,7 @@
6
6
  - Which event source receives the events
7
7
  - Refuse without recording
8
8
  - Events for another event source
9
+ - Transaction boundary
9
10
  - Stream routing and completion
10
11
  - Server-allocated identity
11
12
  - Subject and tags
@@ -60,8 +61,8 @@ public record OpenAccount(OwnerName Owner)
60
61
  | `Handle` returns | What Chronicle does |
61
62
  | --- | --- |
62
63
  | An `[EventType]` event | Appended to the command's event source. |
63
- | `IEnumerable<object>` of events | Each appended in order, atomically. |
64
- | `EventForEventSourceId`, or a collection of them | Appended to the ID each value carries. |
64
+ | `IEnumerable<object>` of events | Appended atomically. Order is kept per event source, not across sources ("Events for another event source" below). |
65
+ | `EventForEventSourceId`, or a collection of them | Appended atomically to the ID each value carries, in order per event source. |
65
66
  | `EventsWithConcurrencyScopes` | Ordered cross-source events with exact, labelled concurrency scopes. |
66
67
  | Tuple `(event, value)` | The event is appended; the value becomes the response. |
67
68
  | Tuple containing an `EventSourceId` and an event | The ID selects the event source and becomes the response. |
@@ -70,12 +71,14 @@ public record OpenAccount(OwnerName Owner)
70
71
  | `CompleteStream` | Closes a non-default stream after the events commit. |
71
72
  | `Result<TEvent, ValidationResult>` | The event is appended, or the blocking validation result refuses the command and rolls back the pending events. |
72
73
 
73
- Returned events commit together and roll back together. An immediate event-log append, an explicit early commit and an external service call are outside that boundary.
74
+ Which of these to pick, next to the returns that record nothing, is in "What `Handle` may return" in `references/csharp.md`.
75
+
76
+ Returned events commit together and roll back together. An immediate event-log append, an explicit early commit and an external service call are outside that boundary; see "Transaction boundary" below.
74
77
 
75
78
  ## Which event source receives the events
76
79
 
77
80
  1. `ICanProvideEventSourceId.GetEventSourceId()` wins.
78
- 2. Otherwise the first public property that is an `EventSourceId`, derives from `EventSourceId<T>`, or carries Chronicle's `[Key]` (`Cratis.Chronicle.Keys`). The typed and attributed forms have equal priority and never form a composite: declare exactly one candidate.
81
+ 2. Otherwise the first public property that is an `EventSourceId`, derives from `EventSourceId<T>`, or carries Chronicle's `[Key]` (`Cratis.Chronicle.Keys`). The typed and attributed forms have equal priority and never form a composite: declare exactly one candidate. On a positional record, Chronicle's `[Key]` may sit on the parameter.
79
82
  3. With no candidate Arc generates a new identity, which suits creation only.
80
83
 
81
84
  The default is an identity concept deriving from `EventSourceId<T>`, shared by the command, the events and the read models. A property named `Id` alone selects nothing. Chronicle's `[Key]` selects the event source; `[Key]` from `System.ComponentModel.DataAnnotations` selects only the Arc command key.
@@ -94,10 +97,16 @@ public record TransferFunds(AccountId From, AccountId To, Amount Amount) : ICanP
94
97
 
95
98
  A returned `EventSourceId` addresses the returned events and becomes the response, but it arrives after dependencies were loaded: it never reloads a read model or retargets an aggregate. A returned raw `Guid` is only a response.
96
99
 
100
+ An identity created inside `Handle`, such as `new AccountId(Guid.NewGuid())`, is not a generated value and is not guarded: when the source already holds events, the returned events extend that history. When creation must refuse an occupied source, take the identity as a `[GeneratedValue]` parameter ("Server-allocated identity" below).
101
+
102
+ Queries never use this resolution. A query argument is bound by name, and Chronicle's `[Key]` on it selects nothing: filter by the argument explicitly.
103
+
97
104
  ## Refuse without recording
98
105
 
99
106
  A business rule decided in `Handle` returns `Result<TEvent, ValidationResult>` (`Cratis.Monads`, `Cratis.Arc.Validation`): the event, or a failure. Never return a nullable event or an empty collection, since returning no events does not fail the command, and do not move a decision that needs loaded state into a validator class.
100
107
 
108
+ A single `ValidationResult` is the business refusal; give it error severity when the return also carries an operation, where a result below the command's blocking severity does not refuse (an unauthorized `AuthorizationResult` refuses as unauthorized). An error DTO as the other `Result` alternative is response data: the command succeeds, and events already pending in its transaction commit.
109
+
101
110
  ```csharp
102
111
  [Command]
103
112
  public record WithdrawFunds(AccountId AccountId, Amount Amount)
@@ -123,6 +132,29 @@ public IEnumerable<EventForEventSourceId> Handle() =>
123
132
 
124
133
  `EventForEventSourceId` is in `Cratis.Chronicle.EventSequences`. Use it only when an event belongs to a different source than the command's own.
125
134
 
135
+ - **Order.** The values commit atomically, grouped by event source: returned as `A1, B1, A2`, they can commit as `A1, A2, B1`. When the order across sources matters, return `EventsWithConcurrencyScopes`.
136
+ - **Occurrence time.** Set `Occurred` on the value to record when a fact happened, for an import or a backfill: `new(AccountId, new FundsDeposited(From, Amount)) { Occurred = creditedAt }`. Left unset, the event carries the append time.
137
+
138
+ ## Transaction boundary
139
+
140
+ One top-level command is one transaction: Arc starts it before `Handle` runs, enrolls the returned events, and commits or rolls back on the command's result. This holds for a model-bound command over HTTP, one executed through `ICommandPipeline`, one returned by a reactor and one run in a `CommandScenario`. Keep one transaction within one event store, namespace and event sequence. Return events and let Arc commit; that is the default.
141
+
142
+ | Situation | What happens |
143
+ | --- | --- |
144
+ | A command executed from inside another command's `Handle` | It joins the outer transaction, and its returned events commit only when the outer command does. An aggregate the nested command commits explicitly is different: it can commit the shared transaction at once, and a later failure of the outer command cannot then undo it. Do not commit an aggregate inside a nested command. Its successful result means "enrolled", not "committed". Inspect the nested result and propagate a failure, or the outer command commits despite it. Not when either command's `Handle` can return an operation: the nested command is then rejected with `InvalidCommandOperation` before it runs. |
145
+ | Several commands returned by one reactor | Separate transactions: earlier ones stay committed when a later one fails. Return one command when the events must commit together. |
146
+ | A command executed through `ICommandPipeline` from a controller action | Its own transaction, committed when `Execute` returns. A later failure of the action does not undo it. The action's own transactional appends commit when the action ends. |
147
+ | A POST controller action as the command | It has a transaction (not with `[AspNetResult]`), but no read protection and no `[GeneratedValue]` parameters. |
148
+ | Chronicle's request-level unit-of-work middleware | A different boundary. A command starts its own transaction and never joins it. |
149
+
150
+ Appending by hand inside `Handle`, when returning the event is not possible:
151
+
152
+ - `eventLog.Transactional.Append(...)` stages the event in the command's transaction. Awaiting it reports no append outcome, and it throws when no transaction is active.
153
+ - A plain `eventLog.Append(...)` persists at once and is never rolled back; a failed one also fails the command when the append went to the command's own event log and belongs to that command. A failed append to another event store, namespace or event sequence is not observed, so check its result yourself. Under read protection `On` it is refused with `ImmediateAppendWhileReadsAreProtected`.
154
+ - A read of the event log inside `Handle` sees persisted events only, never the ones still staged.
155
+
156
+ Anti-pattern: starting work in `Handle` that outlives the command (fire-and-forget, an unawaited continuation). Events it stages after the command completed can be discarded. Await the work, or move it to a reactor.
157
+
126
158
  ## Stream routing and completion
127
159
 
128
160
  Source identity, stream selection and concurrency are separate decisions. Add stream metadata only when one source needs separate routes.
@@ -147,7 +179,7 @@ Template parts format strings unchanged, enums by name, `DateOnly` as `yyyy-MM-d
147
179
 
148
180
  To compute the same ID outside the pipeline (a read endpoint, a seed, a spec), call `EventStreamIdTemplate.ResolveFor(command)` (`Cratis.Arc.Chronicle.Commands`) instead of repeating the join. It resolves the attribute or the provider interface exactly as the pipeline does and returns null when neither declares an ID; `EventStreamIdTemplate.Resolve(template, command)` resolves a given template.
149
181
 
150
- `concurrency: true` on `[EventSourceType]`, `[EventStreamType]` or `[EventStreamId]` adds that dimension to the concurrency scope Arc declares, always together with the target event source ID. On a command routed with `[EventSource<TSource>]`, any such flag replaces the definition's declared dimensions for that command. Without any flag, the default optimistic check still narrows by the routing metadata, and flagging only some attributes can widen the check compared with that default. Neither guards a decision that read state; for that use a stream decision (below) or `cratis-chronicle-protect-decision`.
182
+ `concurrency: true` on `[EventSourceType]`, `[EventStreamType]` or `[EventStreamId]` adds that dimension to the concurrency scope Arc declares, always together with the target event source ID. On a command routed with `[EventSource<TSource>]`, any such flag replaces the definition's declared dimensions for that command. Without any flag, the default optimistic check still narrows by the routing metadata, and flagging only some attributes can widen the check compared with that default. Without read protection `On`, Arc captures a flagged scope after `Handle` returns, while it processes the response; the unflagged default is captured at commit for an event written through an event source definition. When a returned event's own routing replaces the command's definition with string routing, Arc captures that event's default scope while it processes the response as well. Under read protection `On`, Arc only stages the declared dimensions with the events, and Chronicle resolves the scope at commit. Neither reflects what the handler read, so neither guards a decision that read state; for that use a stream decision (below) or `cratis-chronicle-protect-decision`.
151
183
 
152
184
  Per-event routing overrides the command for one event: `new EventForEventSourceId(id, fact) { EventStream = "Archive" }` selects another stream on the command's definition; setting `EventSource = typeof(OtherDefinition)` selects another definition and its own stream. Neither changes the route used to load command dependencies.
153
185
 
@@ -178,13 +210,20 @@ The generated identity is guarded: the whole event source has to be empty when r
178
210
 
179
211
  Use `ICanProvideSubject.GetSubject()` on the command for a compliance identity known before handling, or return `(fact, new Subject(customerId.ToString()))` when the decision supplies it. The subject need not own the event source.
180
212
 
181
- - `[EventTag("account", nameof(AccountId))]` tags from an input; `[EventTag("origin", Value = "import")]` adds a constant.
182
- - For computed tags implement `ICanProvideEventTags.GetEventTags()` on the command, e.g. `=> [new NamedTag("channel", Channel)]`. For a convention shared across commands implement `ICanProvideCommandEventTags.GetEventTags(object command)` on a discovered service; return an empty sequence when not applicable.
213
+ - A command property typed `Subject`, or one marked `[Subject]` (`Cratis.Chronicle`, converted with `ToString()`), also declares the subject without code. A typed and a marked property have equal priority, so declare exactly one; `ICanProvideSubject` wins over both.
214
+ - A returned `Subject` overrides the command's subject for the returned events only. It arrives after validators, `Provide` and the `Handle` dependencies were resolved, so set the subject on the command when they need it.
215
+ - Aggregate `Apply` does not forward the command's subject, declared or returned. Events applied by an aggregate take their subject from the event's own subject metadata, falling back to the event source ID.
216
+
217
+ - `[EventTag("account", nameof(AccountId))]` tags from an input; `[EventTag("origin", Value = "import")]` adds a constant. Give each attribute a property name or `Value`, never both and never neither (`AmbiguousEventTagValue`). A property that does not exist or is not public and readable fails with `UnknownEventTagProperty`, a null value with `EventTagValueMissing`; an empty string is a valid tag value. A concept contributes the value it wraps.
218
+ - For computed tags implement `ICanProvideEventTags.GetEventTags()` on the command, e.g. `=> [new NamedTag("channel", Channel)]`. For a convention shared across commands implement `ICanProvideCommandEventTags.GetEventTags(object command)` on a discovered service; return an empty sequence when not applicable. `[EventTag]`, `ICanProvideEventTags`, `ICanProvideCommandEventTags` and `EventTags` live in `Cratis.Arc.Chronicle.Commands`; `NamedTag` lives in `Cratis.Chronicle`.
183
219
  - Arc discovers command tag providers by convention and resolves them from the command's service scope, so they may inject scoped tenant or user services. Keep them transient or scoped; a singleton must not capture request values. They run once per command at the first returned-event append, after authorization and validation, and never for validation-only calls or commands that return no events.
184
220
  - Every command tag source (attributes, `ICanProvideEventTags`, providers, returned `EventTags`) applies only to events the handler returns. Aggregate-root commits and events appended directly to an event log or sequence get none of them; a direct append must pass its own named tags.
185
221
  - Return `(fact, new EventTags(new NamedTag("batch", batchId)))` to tag all returned events after handling. Set `NamedTags = [new NamedTag("leg", "credit")]` on an `EventForEventSourceId` to tag only that event. Arc merges by name/value pair at append, not during preflight.
222
+ - In pipeline extension code, `commandContext.GetEventTags()` reads only the tags the handler returned; `commandContext.ResolveEventTags()` resolves the combined set. A replacement event sequence or unit of work has to support named tags: one that does not fails the tagged append instead of dropping the tags.
186
223
  - For explicit guards, return `new EventsWithConcurrencyScopes(events, [new(label, new ConcurrencyScope(expected, EventSourceId: accountId))])`: use the expected revision for the exact history read, and a meaningful nonempty scope label. A label identifies a guard; it does not select the history.
187
224
 
188
225
  ## What the audit record keeps
189
226
 
190
- Arc copies public command values into each event's causation, separately from the event itself. `[NotAudited]` (`Cratis.Arc.Chronicle.Commands`) on a command, property or parameter and Chronicle's `[PII]` on a top-level command property keep the value out. Exclusion is not recursive: mark the containing property or the whole command when nested data is sensitive. Encrypting the event property does not remove the command value from causation. Never store a password or token as a reversible event value.
227
+ Arc copies public command values into causation, separately from the event itself: `commandType`, `commandTypeFullName`, then every readable public command property under its camel-cased name. This applies to an event the command returns, which also gets `eventSequenceId`, and to any other event appended while the command runs, which does not. An indexer is skipped, and so is a property whose name collides with one of those reserved names. A concept records the value it wraps, numbers and dates are written culture-invariantly, a nested object or collection becomes compact JSON, a null is omitted, and a long value keeps its first 1024 characters followed by `…`.
228
+
229
+ `[NotAudited]` (`Cratis.Arc.Chronicle.Commands`) and Chronicle's `[PII]` keep a value out. Either may sit on the property, on the positional parameter, on the property's type (a shared concept is then excluded from every command that uses it) or on the command. `[NotAudited]` on the command excludes all of its values; `[PII]` on the command covers only the properties that command type declares, so a property inherited from a base type is still recorded unless it, its type or its declaring type is marked. Exclusion is not recursive: a marking on a member of a nested object does not remove it from that JSON, so mark the containing property, its type, or the whole command with `[NotAudited]`, when nested data is sensitive. Encrypting the event property does not remove the command value from causation. Never store a password or token as a reversible event value.
@@ -21,7 +21,9 @@ public class CartsController(ICartService carts) : ControllerBase
21
21
  - A `[HttpPost]` action's return value is wrapped in the same command result envelope a model-bound command produces. The request type is a plain body type, not a `[Command]`.
22
22
  - The generated frontend proxy is named after the action method.
23
23
  - **Validate route.** Arc adds `POST <route>/validate` for the action. It runs MVC binding and filters and skips the action body, so a precondition checked only inside the action or its service is not a pre-flight rule.
24
- - **Validation.** Discovered FluentValidation validators and data annotations run during MVC model binding. `[TreatWarningsAsErrors]` (`Cratis.Arc`) on an action or controller makes warning-level results block; the caller-severity header does not apply to controllers.
24
+ - **Validation.** Discovered FluentValidation validators and data annotations run during MVC model binding. Every failure they add blocks the action and reaches the result as an `Error`, whatever severity the rule declares.
25
+ - **Severity.** Do not build a warning or confirmation flow on a controller. `[TreatWarningsAsErrors]` (`Cratis.Arc`) on an action or controller is not a floor: a caller that sends `X-Ignore-Warnings: true` receives only `Error` results even where the attribute is declared. `X-Allowed-Severity` has no effect on controllers. Use a model-bound command instead (`cratis-arc-validate-command`). For a warning the caller confirms, put the rule in a validator and declare no floor: the caller first requests with allowed severity `Information`, then resends with `Warning` after confirming. Declare `[BlockOnValidationSeverity(ValidationResultSeverity.Warning)]` only when a warning must never be waived; that floor makes confirmation impossible.
26
+ - **State rules.** A validator for a controller body type cannot take a read model as a constructor parameter and cannot call `GetTenant()`, `GetCausedBy()` or `IsSystem()` on the validation context: it runs during model binding, outside the command pipeline. The first fails the request with `ReadModelValidatorRequiresCommandPipeline`; the second throws `OperationSnapshotUnavailable`, so the request fails instead of reporting a finding. When a rule depends on state, tenant or caller, convert the action to a model-bound command.
25
27
  - **Authorization.** Use ASP.NET Core's own `[Authorize]` and `[AllowAnonymous]`; MVC authorization runs before body binding.
26
28
  - **Native response.** `[AspNetResult]` (`Cratis.Arc`) on an action or controller returns the ASP.NET result as written, with no envelope, no validate route and no execution scopes. Use it to keep an existing response contract.
27
29
  - **Binding.** `[FromRequest]` (`Cratis.Arc.ModelBinding`) binds one parameter from several request sources; see below. `[property: ExplicitOffset]` works on body properties. `[ApiController]` automatic problem responses can short-circuit before Arc and keep ASP.NET's shape.
@@ -55,7 +55,7 @@ public record ApproveReport(ReportId ReportId, string Owner, string Month)
55
55
 
56
56
  ## Aggregate root
57
57
 
58
- Use it when an entity's rules read best as methods over its own history. Derive from `AggregateRoot` (`Cratis.Arc.Chronicle.Aggregates`), keep state in `On` methods, and take the aggregate as a `Handle` parameter. Arc loads it for the command's event source and replays its handled events first.
58
+ Use it when an entity's rules read best as methods over its own history. Derive from `AggregateRoot` (`Cratis.Arc.Chronicle.Aggregates`), keep state in `On` methods, and take the aggregate as a `Handle` parameter. Arc loads it for the command's event source and replays its handled events first. Every injected aggregate parameter uses the command's event source: a second parameter of the same type is the same instance, with the same state and `Failed` results, not another identity. Load any other identity with `IAggregateRootFactory.Get<T>(…)`.
59
59
 
60
60
  ```csharp
61
61
  using Cratis.Arc.Chronicle.Aggregates;
@@ -98,6 +98,8 @@ public record AddItemToOrder(OrderId OrderId, ProductId Product, Quantity Quanti
98
98
  - `Commit()` commits the whole command transaction. Return straight after it; a later failure cannot undo it.
99
99
  - Never call `Commit()` in a command whose `Handle` can return a command operation: it throws `InvalidCommandOperation`. The pipeline commits there after the operation ran, and that deferred commit does not see `Failed` results, so make the refusal in the handler before returning the operation (`cratis-arc-declare-operation`).
100
100
  - The aggregate guards its own history: a concurrent append to it rejects the commit. It does not guard read models or other aggregates the command uses.
101
+ - Without `[EventSource<TSource>]`, an existing aggregate guards only the event types it handles. A new aggregate, or one with no handler methods, guards every event type on its event source ID, so two competing creations cannot both commit.
102
+ - A subject declared on or returned by the command does not reach events the aggregate applies. Those events take their subject from the event's own subject metadata; see "Subject and tags" in `references/csharp-chronicle.md`.
101
103
  - There are no snapshots: every command replays the handled history, so keep it bounded.
102
104
 
103
105
  ## Aggregate root catalog
@@ -113,7 +115,7 @@ public record AddItemToOrder(OrderId OrderId, ProductId Product, Quantity Quanti
113
115
  | `[EventSource<TSource>]`, optionally with a stream name | Binds the aggregate to one event source definition and stream: only that stream's events are replayed and guarded. Without it, every handled event for the event source ID in any stream is replayed. |
114
116
  | `IAggregateRootFactory.Get<T>(id, streamId, eventSourceType)` | Load an aggregate for another identity, or outside a command. Loading two aggregates does not make one decision over both: collect every `Commit()` result. |
115
117
 
116
- A constructor may take registered services. A read model injected there is a dependency, not replayed state, and is not updated by `Apply`.
118
+ A constructor may take registered services. A read model injected there is a dependency, not replayed state, and is not updated by `Apply`. It is resolved from the command's context: loading the aggregate through `IAggregateRootFactory` with another ID does not rekey it.
117
119
 
118
120
  ## Failures
119
121
 
@@ -122,4 +124,5 @@ A constructor may take registered services. A read model injected there is a dep
122
124
  | `StreamDecisionRequiresSpecificRoute` | The read has an unspecified event source ID, every stream type, or the default stream ID | Declare the stream type and stream ID on the command or route. |
123
125
  | `EventRoutingContradictsEventSource` | A stream name the event source definition does not declare, or metadata contradicting it | Use a declared stream. |
124
126
  | `UnableToResolveAggregateRootFromCommandContext` | The command's event source ID is declared but unusable, for example unspecified | Supply a usable identity before the aggregate is resolved. |
125
- | `ReadAndAggregateOnSameSource` | Under read protection, a protected read model and an aggregate guard the same source | Decide from the aggregate, or mark an advisory read `[Unprotected("reason")]`. |
127
+ | `AggregateRootContradictsEventSource` | An aggregate with `[EventSource<TSource>]` names a stream the definition does not declare, is loaded through `Get<T>` with another event source type, or carries an `[EventStreamType]` that differs from the declared stream's | Make the declaration, the `Get<T>` arguments and the attribute agree with the event source definition. |
128
+ | `ReadAndAggregateOnSameSource` (analyzer `ARCCHR0033`) | Under read protection `On`, a protected read model and an aggregate guard the same source | Decide from the aggregate, or mark an advisory read `[Unprotected("reason")]`. A protected read of a different source is allowed beside the aggregate and adds its own guard. |