@cratis/pi 8.5.0 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +5 -3
  2. package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -1
  3. package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -1
  4. package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +6 -3
  5. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
  6. package/package/corpus/rules/glossary.md +5 -3
  7. package/package/corpus/rules/react.md +3 -1
  8. package/package/corpus/rules/reactors.md +3 -1
  9. package/package/corpus/rules/specs.csharp.md +6 -3
  10. package/package/corpus/rules/vertical-slices.md +5 -2
  11. package/package/corpus/skills/cratis-application-growth/SKILL.md +1 -2
  12. package/package/corpus/skills/cratis-application-growth/references/csharp.md +0 -2
  13. package/package/corpus/skills/cratis-application-growth/references/move-and-untangle.md +1 -2
  14. package/package/corpus/skills/cratis-application-growth/references/rename-window.md +1 -3
  15. package/package/corpus/skills/cratis-application-growth/references/service-and-delivery.md +3 -2
  16. package/package/corpus/skills/cratis-application-growth/references/stages.md +2 -2
  17. package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +2 -2
  18. package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +19 -0
  19. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +15 -0
  20. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
  21. package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
  22. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +46 -7
  23. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-controller.md +3 -1
  24. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +4 -1
  25. package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +31 -4
  26. package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
  27. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +24 -2
  28. package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +49 -0
  29. package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +3 -1
  30. package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +27 -4
  31. package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
  32. package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +49 -2
  33. package/package/corpus/skills/cratis-arc-generate-proxies/references/typescript.md +9 -0
  34. package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
  35. package/package/corpus/skills/cratis-arc-host-application/references/csharp-configuration.md +54 -0
  36. package/package/corpus/skills/cratis-arc-host-application/references/csharp-deployment.md +98 -0
  37. package/package/corpus/skills/cratis-arc-host-application/references/csharp-http.md +9 -1
  38. package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +84 -2
  39. package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +2 -0
  40. package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
  41. package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +18 -1
  42. package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
  43. package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +18 -16
  44. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +8 -3
  45. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +84 -16
  46. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +22 -2
  47. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-instant-feedback.md +81 -0
  48. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +80 -0
  49. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-navigation.md +103 -0
  50. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +40 -1
  51. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-structure.md +117 -0
  52. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +7 -3
  53. package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +3 -3
  54. package/package/corpus/skills/cratis-arc-react-separate-view-model/references/typescript.md +27 -6
  55. package/package/corpus/skills/cratis-arc-validate-command/references/csharp-rules.md +23 -2
  56. package/package/corpus/skills/cratis-arc-validate-command/references/csharp.md +28 -2
  57. package/package/corpus/skills/cratis-authproxy-configure/SKILL.md +136 -0
  58. package/package/corpus/skills/cratis-authproxy-configure/references/admission.md +125 -0
  59. package/package/corpus/skills/cratis-authproxy-configure/references/aspire.md +154 -0
  60. package/package/corpus/skills/cratis-authproxy-configure/references/operations.md +122 -0
  61. package/package/corpus/skills/cratis-authproxy-configure/references/services-and-routing.md +114 -0
  62. package/package/corpus/skills/cratis-authproxy-configure/references/sessions-and-logout.md +126 -0
  63. package/package/corpus/skills/cratis-authproxy-configure/references/sign-in-providers.md +116 -0
  64. package/package/corpus/skills/cratis-authproxy-configure/references/tenant-resolution.md +135 -0
  65. package/package/corpus/skills/cratis-choreography-run-workflow/SKILL.md +117 -0
  66. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp-chronicle.md +164 -0
  67. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp.md +354 -0
  68. package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +2 -2
  69. package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +28 -0
  70. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp-services.md +13 -2
  71. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp.md +12 -0
  72. package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin.md +2 -0
  73. package/package/corpus/skills/cratis-chronicle-connect-application/references/typescript.md +10 -1
  74. package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +8 -1
  75. package/package/corpus/skills/cratis-chronicle-constrain-append/references/csharp.md +35 -3
  76. package/package/corpus/skills/cratis-chronicle-constrain-append/references/go.md +1 -1
  77. package/package/corpus/skills/cratis-chronicle-constrain-append/references/operations.md +70 -0
  78. package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +2 -0
  79. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +27 -0
  80. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/container-and-kubernetes.md +293 -0
  81. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +13 -6
  82. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +45 -0
  83. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +91 -1
  84. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +9 -0
  85. package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
  86. package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +11 -1
  87. package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +1 -1
  88. package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +1 -1
  89. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +14 -3
  90. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +3 -0
  91. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +3 -2
  92. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp.md +23 -0
  93. package/package/corpus/skills/cratis-chronicle-project-view/references/elixir.md +1 -0
  94. package/package/corpus/skills/cratis-chronicle-project-view/references/go.md +2 -1
  95. package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +2 -0
  96. package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +1 -0
  97. package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +1 -1
  98. package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +2 -0
  99. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +40 -3
  100. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +20 -2
  101. package/package/corpus/skills/cratis-chronicle-protect-decision/references/elixir.md +7 -0
  102. package/package/corpus/skills/cratis-chronicle-protect-decision/references/go.md +9 -1
  103. package/package/corpus/skills/cratis-chronicle-protect-decision/references/java.md +8 -0
  104. package/package/corpus/skills/cratis-chronicle-protect-decision/references/kotlin.md +9 -0
  105. package/package/corpus/skills/cratis-chronicle-protect-decision/references/typescript.md +7 -0
  106. package/package/corpus/skills/cratis-chronicle-protect-personal-data/references/csharp.md +24 -1
  107. package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +1 -1
  108. package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
  109. package/package/corpus/skills/cratis-chronicle-publish-contract/references/webhook-signature-wire-format.md +82 -0
  110. package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +17 -0
  111. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-outputs.md +3 -1
  112. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +35 -2
  113. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/elixir.md +11 -0
  114. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +1 -0
  115. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
  116. package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +1 -1
  117. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-coordination.md +31 -2
  118. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-history.md +21 -4
  119. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp.md +20 -2
  120. package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +1 -1
  121. package/package/corpus/skills/cratis-chronicle-record-event/references/java.md +1 -1
  122. package/package/corpus/skills/cratis-chronicle-record-event/references/kotlin.md +3 -0
  123. package/package/corpus/skills/cratis-chronicle-reduce-state/SKILL.md +2 -1
  124. package/package/corpus/skills/cratis-chronicle-reduce-state/references/csharp.md +3 -1
  125. package/package/corpus/skills/cratis-chronicle-reduce-state/references/java.md +10 -1
  126. package/package/corpus/skills/cratis-chronicle-reduce-state/references/kotlin.md +10 -1
  127. package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +27 -5
  128. package/package/corpus/skills/cratis-chronicle-select-client/SKILL.md +18 -0
  129. package/package/corpus/skills/cratis-chronicle-select-client/references/elixir.md +21 -1
  130. package/package/corpus/skills/cratis-chronicle-select-client/references/go.md +13 -0
  131. package/package/corpus/skills/cratis-chronicle-select-client/references/java.md +15 -0
  132. package/package/corpus/skills/cratis-chronicle-select-client/references/kotlin.md +15 -0
  133. package/package/corpus/skills/cratis-chronicle-select-client/references/typescript.md +16 -0
  134. package/package/corpus/skills/cratis-code-review/references/csharp-diagnostics.md +28 -2
  135. package/package/corpus/skills/cratis-code-review/references/csharp.md +1 -1
  136. package/package/corpus/skills/cratis-components-accessibility/SKILL.md +6 -8
  137. package/package/corpus/skills/cratis-components-accessibility/references/typescript.md +32 -14
  138. package/package/corpus/skills/cratis-components-build-canvas/SKILL.md +4 -3
  139. package/package/corpus/skills/cratis-components-build-canvas/references/typescript-props.md +1 -1
  140. package/package/corpus/skills/cratis-components-build-canvas/references/typescript.md +4 -2
  141. package/package/corpus/skills/cratis-components-choose-control/SKILL.md +13 -7
  142. package/package/corpus/skills/cratis-components-choose-control/references/from-primereact.md +116 -0
  143. package/package/corpus/skills/cratis-components-choose-control/references/menu.md +90 -0
  144. package/package/corpus/skills/cratis-components-choose-control/references/typescript-composition.md +48 -0
  145. package/package/corpus/skills/cratis-components-choose-control/references/typescript.md +2 -2
  146. package/package/corpus/skills/cratis-components-compose-toolbar/SKILL.md +2 -1
  147. package/package/corpus/skills/cratis-components-compose-toolbar/references/floating-toolbar.md +146 -0
  148. package/package/corpus/skills/cratis-components-diagnose-screen/SKILL.md +102 -0
  149. package/package/corpus/skills/cratis-components-display-list/SKILL.md +10 -10
  150. package/package/corpus/skills/cratis-components-display-list/references/typescript-custom-panel.md +74 -0
  151. package/package/corpus/skills/cratis-components-display-list/references/typescript-datatables.md +2 -7
  152. package/package/corpus/skills/cratis-components-display-list/references/typescript.md +3 -2
  153. package/package/corpus/skills/cratis-components-submit-form/references/typescript-commandform.md +72 -2
  154. package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +5 -3
  155. package/package/corpus/skills/cratis-components-theme-application/SKILL.md +17 -15
  156. package/package/corpus/skills/cratis-components-theme-application/references/localization.md +166 -0
  157. package/package/corpus/skills/cratis-components-theme-application/references/typescript.md +18 -14
  158. package/package/corpus/skills/cratis-components-theme-application/references/upgrade-from-previous-major.md +141 -0
  159. package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +2 -0
  160. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-domain-philosophy.md +31 -3
  161. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-fundamentals-helpers.md +119 -0
  162. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp.md +4 -0
  163. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +70 -0
  164. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +8 -0
  165. package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +1 -0
  166. package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +33 -0
  167. package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
  168. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +5 -0
  169. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/go-dependency-injection.md +3 -0
  170. package/package/corpus/skills/cratis-modeling-design-event-model/SKILL.md +6 -4
  171. package/package/corpus/skills/cratis-modeling-design-event-model/references/command-inventory.md +7 -1
  172. package/package/corpus/skills/cratis-modeling-design-event-model/references/model-first.md +13 -1
  173. package/package/corpus/skills/cratis-modeling-design-event-model/references/review-one-slice.md +6 -0
  174. package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +6 -6
  175. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/csharp-aspire.md +116 -28
  176. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/docker-compose.md +2 -2
  177. package/package/corpus/skills/cratis-observability/references/chronicle-kernel-export.md +46 -0
  178. package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +4 -2
  179. package/package/corpus/skills/cratis-platform-build-application/SKILL.md +8 -0
  180. package/package/corpus/skills/cratis-platform-build-application/references/cratis-identity.md +71 -0
  181. package/package/corpus/skills/cratis-platform-build-application/references/studio-repository.md +96 -0
  182. package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +14 -8
  183. package/package/corpus/skills/cratis-platform-deliver-slice/references/csharp.md +167 -3
  184. package/package/corpus/skills/cratis-platform-deliver-slice/references/eventual-consistency.md +150 -0
  185. package/package/corpus/skills/cratis-platform-diagnose-slice/SKILL.md +1 -1
  186. package/package/corpus/skills/cratis-platform-start-application/SKILL.md +21 -0
  187. package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +77 -3
  188. package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +118 -0
  189. package/package/corpus/skills/cratis-platform-upgrade-application/references/csharp.md +117 -0
  190. package/package/corpus/skills/cratis-platform-upgrade-application/references/java.md +53 -0
  191. package/package/corpus/skills/cratis-platform-upgrade-application/references/kotlin.md +53 -0
  192. package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +71 -0
  193. package/package/corpus/skills/cratis-screenplay-accept-model/references/csharp.md +29 -0
  194. package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +82 -1
  195. package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +1 -1
  196. package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +10 -0
  197. package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +5 -4
  198. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/cli.md +19 -2
  199. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/smallest-model.md +87 -0
  200. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/typescript.md +13 -0
  201. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
  202. package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +2 -0
  203. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-colocated.md +101 -0
  204. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +3 -1
  205. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-decision-reads.md +1 -0
  206. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +1 -0
  207. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +4 -2
  208. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +3 -3
  209. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +34 -1
  210. package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
  211. package/package/corpus/skills/cratis-specifications-isolate-behavior/SKILL.md +1 -1
  212. package/package/corpus/skills/cratis-specifications-isolate-behavior/references/csharp-running.md +10 -3
  213. package/package/corpus/skills/cratis-specifications-test-application-ui/references/typescript.md +22 -4
  214. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/SKILL.md +2 -1
  215. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/references/typescript.md +40 -0
  216. package/package/profile-catalog.json +15 -0
  217. package/package.json +1 -1
@@ -11,7 +11,7 @@ One precise line per load-bearing term, so the same word means the same thing ev
11
11
 
12
12
  ## Events & streams
13
13
 
14
- - **Event** — an immutable, past-tense **fact** that something happened; declared with `[EventType]` in .NET. Subject to the event store’s redaction policies.
14
+ - **Event** — an immutable, past-tense **fact** that something happened; declared with `[EventType]` in .NET. A stored payload is replaced with a marker only by an explicit redaction request: a redaction (of one event, or of an event source's events) replaces the stored payload in the target event sequence only, not in copies made earlier such as backups, exports or events already forwarded to an inbox; system event store events cannot be redacted. An explicit revision corrects content and keeps the original. Both keep the event's sequence number; a redacted event leaves a marker with the reason. A compensation is a new event linked to the one it offsets.
15
15
  - **Event source** — the entity or process whose changes are recorded; one event source can have multiple named streams.
16
16
  - **Event source id** — the append routing identity of an event source, carried in event context. Do not duplicate it in the payload just to identify the current source. A related source ID can be part of the fact.
17
17
  - **Event stream** — an ordered part of an event source’s history within an event sequence. A stream type names the part; a stream ID selects an instance of that part.
@@ -19,7 +19,8 @@ One precise line per load-bearing term, so the same word means the same thing ev
19
19
  - **Event log** — the default event sequence where domain events are appended.
20
20
  - **Outbox / inbox** — cross-service event sequences: a producer appends its public contract event to the outbox; a consumer observes the inbox.
21
21
  - **Public event** — an event type that is part of the contract an event store exposes to other services (`.NET`: `[Public]` or `[EventStore]` on the type, or `[EventStore]` on its assembly; otherwise private). The outbox rejects private events and the event log rejects public events.
22
- - **EventContext** — metadata traveling with an event (event source id, sequence number, occurred, causation/correlation, subject).
22
+ - **EventContext** — metadata traveling with an event: event source id, sequence number, occurred, correlation id and causation chain, caused-by identity, tags, event type with the delivered generation, stream type and id, event store and namespace, and subject. Which further members exist depends on the SDK: .NET also exposes the generation the event was appended in and, only when the event is a compensation, the sequence number it compensates for; other SDKs may omit either or report them differently, so check the SDK before relying on them. Read these from the context instead of copying them into the event; `cratis-chronicle-react-to-fact` (`references/csharp.md`) lists the .NET context members.
23
+ - **Integration event** — an event that crosses a system boundary. With Chronicle outbox/inbox subscriptions, outbound it is the public contract event a producer appends to its outbox, and a consumer's reactors, reducers and projections may observe that contract directly on the inbox; other outbound delivery, such as a webhook, need not go through an outbox. Inbound raw data from an outside system, recorded as received in that system's terms as an event type of its own, stays at the boundary: only the Translation slice observes it, and everything else consumes the facts we own that the translation records.
23
24
 
24
25
  ## Read side
25
26
 
@@ -29,6 +30,7 @@ One precise line per load-bearing term, so the same word means the same thing ev
29
30
  - **Reactor** — observes recorded events to trigger effects such as notifications, commands or follow-up events. See `cratis-chronicle-react-to-fact` for the client’s registration and delivery conventions.
30
31
  - **Observer** — a projection, reducer or reactor consuming an event sequence and maintaining subscription, replay and quarantine state. A projection's replay and catch-up are one globally ordered step, a new failure stops that catch-up, a full replay leaves the observer inactive, and completing it does not resume an observer from quarantine; do not generalize this ordering to reducers.
31
32
  - **Sink** — where Chronicle sends projection or reducer state: a store such as MongoDB (the default document store) or an EF Core-backed SQL sink, or an event-sequence sink that publishes the state as new events.
33
+ - **To-do list** — a read model of pending work that an Automation drains: an opening event adds the item, every event that closes the work removes it, and on each pass the reactor sends one command per eligible item (for example, one whose deadline has passed), not per listed item. The list can lag, so it only nominates candidates; the command rechecks current state.
32
34
  - **AutoMap** — Chronicle's on-by-default mapping of matching event→read-model property names; omit `.AutoMap()` unless explicitly re-enabling mapping after `.NoAutoMap()`.
33
35
  - **Graph** — a named property graph that events build through a graph projection: nodes, edges and their properties. Derived state like a read model; nothing writes to it directly.
34
36
  - **Node** — a graph element with a label, one unique key and primitive properties. The label is the type name.
@@ -51,7 +53,7 @@ One precise line per load-bearing term, so the same word means the same thing ev
51
53
 
52
54
  ## Structure & types
53
55
 
54
- - **Slice** — the vertical unit of one behavior (command + events + projection + read model + component + specs), created/changed/deleted together.
56
+ - **Slice** — the vertical unit of one behavior, grouping only the artifacts that behavior needs (any of command, events, projection, read model, query, component, specs; a listing slice may have a read model, query and projection but no command or new event), created/changed/deleted together. Its folder is named for the capability (`Registration`, `Listing`), not for the command type; when present, a command is named in the imperative and an event in the past tense.
55
57
  - **Slice types** — **State Change** (command → events), **State View** (events → read model), **Automation** (events → side effect, including a follow-up command or event — a Screenplay `produces` / `invokes`), **Translation** (data from *outside* the model's own facts → our own facts: an external system's or another service's data recorded as events we own, keeping the external fact distinct from the local one; a Screenplay `Translate` slice with `direction outbound` is the other direction, publishing our private facts as one public contract event). A reactor that turns our own event into a follow-up event or command is an Automation, not a Translation.
56
58
  - **Concept** — a named type wrapping exactly one scalar domain value (`ConceptAs<T>` in C#, TypeScript, Kotlin and Java; a defined type in Go; `use Cratis.Chronicle.Concept` in Elixir); the bare scalar on every wire and in every store.
57
59
  - **Event-source identity** — the concept type that addresses one Chronicle event history (`EventSourceId<T>` in C#); only such identities use it, every other identity is a plain concept.
@@ -12,8 +12,10 @@ paths:
12
12
 
13
13
  - Call the backend through generated proxies, never raw `fetch`, since copied routes and types drift. Compose slices on a page only through their exported components, never their internals, so each slice stays removable. See `cratis-arc-react-bind-slice`.
14
14
  - Call hooks unconditionally; gate a query with `Query.when(condition).use(args)`, since a skipped hook breaks React's hook order.
15
- - Render unauthorized, refused and failed results apart from pending and empty, since an empty list hides a refusal. Show a neutral failure message, never exception text or stack traces, which expose internals. Let observable queries show accepted writes; a locally patched list drifts from the read model.
15
+ - Render unauthorized, refused and failed results apart from pending and empty, since an empty list hides a refusal. Show a neutral failure message, never exception text or stack traces, which expose internals. Let observable queries show accepted writes; a locally patched list drifts from the read model. Edge case: for a gesture that must show its result in the same frame, such as a drop or a paste, see `cratis-arc-react-bind-slice` (`references/typescript-instant-feedback.md`). A command built there with `new` instead of `use()` does not get the host's locale: before executing, call `setRequestDefaults({ locale: arc.localeStore, httpHeadersCallback: arc.httpHeadersCallback })` on it with `arc` from `useContext(ArcContext)`.
16
16
  - Bind live collections with the observable query's `.use()` hook; Suspense and raw `subscribe` do not apply delta updates. Render `useSuspense()` inside a `QueryBoundary`, which supplies the fallback and catches failures.
17
17
  - On sign-in, sign-out or account switch, change the credentials first, then `refresh()` the identity (`clearIdentity()` on sign-out) and call `reconnectQueries()` before caller-scoped data renders: the identity calls touch only the identity, while reconnecting drops cached results and live connections that still belong to the old caller. Reserve a full page load for identity-provider redirects or an intentional app reset. See `cratis-arc-react-bind-slice`.
18
+ - Set the UI language with the `locale` prop on `<Arc>`, never a hand-written `Accept-Language` header: the header replaces the language Arc sends, and a native WebSocket or EventSource handshake cannot carry it, so a live stream carries its language in its URL. With a locale set, that is the active language by default; a header override replaces it only when it is one valid language tag, and a preference list is left out of the URL, so the stream stops following the UI language. See `cratis-arc-react-bind-slice` (`references/typescript-localization.md`).
19
+ - Read a command form's values through the form's own instance (`useCommandInstance()` beneath the form) and submit through the form: its own submit, or, for a plain `CommandForm` only, the form handle's `execute()` (`formRef`) for a button outside it. Submit a `CommandStepper` only through its own Submit: its `formRef` reaches the inner form and skips the stepper's before-execute step and confirmation. Calling the instance's `execute()` skips the form's custom field errors and result callbacks; calling the command's `use()` beside the form creates a second instance that can submit different values from those on screen. See `cratis-components-submit-form`.
18
20
  - Keep view models plain classes. Mark one with constructor parameters `@injectable()` and type each dependency as a class or explicit token, never a bare interface, which compiles away and cannot be resolved. Release subscriptions in `detached()`, or they outlive the view. Wrap a child that reads view-model state itself in `observer` from `@cratis/arc.react.mvvm`, or it will not re-render. Keep `@cratis/eslint-plugin-arc` recommended rules on; they reject hooks in view models and direct `mobx-react` imports. See `cratis-arc-react-separate-view-model`.
19
21
  - Ask confirmation through the shared confirmation hook or `IDialogs`, never `window.confirm`, and act only on `DialogResult.Yes` or `Ok`, since dismissal resolves to `Cancelled`. Start a busy indicator without awaiting it, since its promise settles only on close, and close it in `finally`, since users cannot dismiss it. See `cratis-components-coordinate-feedback`.
@@ -20,8 +20,10 @@ profile: application
20
20
  - Start a new effect-producing reactor at the tail, or have it ignore older facts; its first catch-up is not a replay, so replay exclusion does not stop it.
21
21
  - Exclude effect-producing handlers from replay, and still make every effect idempotent: exclusion does not stop retries or redelivery. Key each external call by the stable delivery identity plus an effect name, never an attempt number, for the receiver to deduplicate.
22
22
  - Return follow-up events or commands instead of appending to the event log yourself, so they belong to the delivery. Derive them from the event and stable state, never a fresh ID or the clock, so a redelivery produces the same output.
23
- - Never swallow a failed effect; let it fail the partition so it retries visibly. Do not throw to reject malformed or refused input: record a failure fact, because failed partitions stall and enough of them quarantine the whole observer.
23
+ - Never swallow a failed effect; let it fail the partition so it retries visibly. Do not throw to reject malformed or refused input: record a failure fact, because a failed partition stalls every later event for that event source, and once its retries are used up on the same event it is quarantined: automatic retries stop. It moves on through an authorized manual retry, which is still accepted but keeps the spent budget, by clearing that partition's quarantine, or, on a replayable reactor, by a successful replay that covers the failed event. Other event sources can keep flowing while the observer stays active. A batch handler that throws fails every partition in the batch, so report the failure for the affected partition when the rest can succeed. Failed partitions quarantine the observer as a whole only when a kernel failure threshold is enabled and reached, and both thresholds are off by default; a reactor partition whose latest failure is a timeout does not count toward them; the observer can still be quarantined for other reasons, such as a catch-up that cannot start.
24
+ - A handler may await the work of the delivery it is handling, but must not hold that delivery open for a future business fact, an approval or a deadline. Handle a later fact in its own handler; for a deadline, an approval or any process that pauses, keep a work-list item open and continue in the reactor for the fact that ends the wait (`cratis-chronicle-react-to-fact`, "Multi-step processes"). Never sleep, block or keep an in-memory timer to wait for one: a handler that does not answer in time times out. Live delivery records that as a failed partition; catch-up and replay can run the timed-out step again first, so the handler may run more than once before the failure is recorded. Once it is recorded, automatic recovery retries only while that partition has retries left, and an in-memory timer is lost on restart.
24
25
  - Keep reactors stateless and shared dependencies thread-safe; partitions can run concurrently.
26
+ - Never assume a projection or reducer has handled the event the reactor is handling: every observer advances on its own, so a stored read model may not include that event yet. Decide from the event itself or on-demand state (`cratis-platform-deliver-slice`, `references/eventual-consistency.md`).
25
27
  - Do not delete, revoke, bill or notify because a stored read model lacks something: it lags the log and reads empty while rebuilding, so decide from the events or on-demand state. Cap the subjects one unattended pass may act on and refuse an implausible count, so one bad input cannot sweep everything.
26
28
  - Guard against reacting to what the reactor itself produced, or one input loops.
27
29
  - Commands a reactor returns run without the caller's identity and run again on redelivery: make them idempotent, and when they need authorization run them as a system identity holding only the roles they need (`cratis-arc-authorize-request`).
@@ -1,14 +1,17 @@
1
1
  ---
2
- applyTo: "**/for_*/**/*.cs, **/when_*/**/*.cs"
2
+ applyTo: "**/for_*/**/*.cs, **/when_*/**/*.cs, **/when_*.cs, **/given/**/*.cs"
3
3
  paths:
4
4
  - "**/for_*/**/*.cs"
5
5
  - "**/when_*/**/*.cs"
6
+ - "**/when_*.cs"
7
+ - "**/given/**/*.cs"
6
8
  ---
7
9
  <!-- cratis-ai: generated Copilot instructions. Do not edit; rules/ is the source. -->
8
10
 
9
11
  # C# specs
10
12
 
11
- - Name spec projects `<Source>.Specs`. Start a new one on `Cratis.Specifications.XUnit.v3`; keep an existing project's runner with its matching adapter package, which wires the lifecycle into that runner.
13
+ - Name spec projects `<Source>.Specs`. In a separate spec project, mirror the slice's relative path under the project root, `<Source>.Specs/<Feature>/<Slice>/`, and put the spec folders there (for example `for_<Unit>/` or `when_<behaviour>/`). Start a new one on `Cratis.Specifications.XUnit.v3`; keep an existing project's runner with its matching adapter package, which wires the lifecycle into that runner.
14
+ - Keep an existing co-located layout: where the application project already compiles specs beside its slices, extend it and add no separate spec project, not even for running-kernel specs. Its setup is the project's own, not universal: some exclude only the spec folders from non-Debug builds and run through the application's entry point, others also exclude flat `when_*.cs` files and run with `dotnet test`. Read the project's exclusion patterns and run command, place spec files only where the exclusion reaches, and use the suite's established filter to keep infrastructure out of ordinary runs.
12
15
  - Write `Establish` for setup, `Because` for the one action and `should_*` facts marked with the runner's fact attribute (none on the native runner). `Given`/`When` are aliases: one name per phase per class. A `given/` context holds `Establish` only; `all_dependencies` creates the substitutes. Lifecycle runs base-first, so never call a base lifecycle method.
13
16
  - Keep the shared lifecycle: facts share one instance and may run concurrently, so they only read, even through a helper (no assignment, `Add`, `Returns`, `Dispose` or second action); every mutation goes in `Establish` or `Because`. Use `[PerFactSpecificationLifecycle]` only when isolation genuinely requires it.
14
17
  - Return `Task`, never `async void`, from facts and lifecycle methods, and await every `Task`-returning `Should*`: a discarded assertion can never fail.
@@ -19,4 +22,4 @@ paths:
19
22
  - Reuse `GlobalUsings.Specs.cs` without repeating its imports; alias a type a namespace shadows (CS0118) with a `using` placed last.
20
23
  - Run a built suite without rebuilding and check its exit status and teardown result, not only passing facts. After changing a widely substituted interface, build the whole spec project; after a runner migration, account for every previously discovered case and skip.
21
24
 
22
- Mechanism, packages and runner options: `cratis-specifications-isolate-behavior`; scenarios: `cratis-specifications-exercise-backend`; run commands and filters: `run-tests`.
25
+ Mechanism, packages and runner options: `cratis-specifications-isolate-behavior`; scenarios: `cratis-specifications-exercise-backend`, whose `references/csharp-colocated.md` covers specs kept beside the slice; run commands and filters: `run-tests`.
@@ -17,9 +17,9 @@ paths:
17
17
 
18
18
  Group by behavior, not by technical layer. Each slice has exactly one type:
19
19
 
20
- - **State Change**: a command is accepted or refused and appends events.
20
+ - **State Change**: a command is accepted or refused. An accepted command appends events or, in an application that is not event sourced, writes through the application's store, and may change nothing when it repeats work already done. A refused command never applies the requested change.
21
21
  - **State View**: events build a read model that queries expose.
22
- - **Automation**: reacts to a committed event with a follow-up command or an outside call.
22
+ - **Automation**: reacts to a committed event with a follow-up command or an outside call. Without events, trigger the side effect explicitly, and only after the command's write is confirmed committed: a store call that returned inside an open transaction is not yet committed. That is separate from the inline operations a command returns as part of its own write.
23
23
  - **Translation**: turns input from outside our own facts into our facts.
24
24
 
25
25
  Non-negotiables:
@@ -27,8 +27,11 @@ Non-negotiables:
27
27
  - **Layout.** `<Module>/<Feature>/<Slice>/` under one slice root: the source or package root, or the single artifact folder (such as `Features/`) an SDK's discovery and generator scan so the host stays outside it. Add no other wrapper or technical-layer folder; a single-capability application starts at `<Feature>/<Slice>/`. The namespace, package or module mirrors the path.
28
28
  - **Renaming is a migration.** A namespace or package rename can change stored observer identities and Arc routes; never treat it as a plain file move.
29
29
  - **One slice is one unit.** Its command, events, read model, reaction and screen live in its folder and ship with its specifications. Declare its backend artifacts in one `<Slice>` file unless the language needs a file per public type, so the slice reads and changes as one. Report a partly done slice as partial; never stub it.
30
+ - **One command per slice by default.** Give each command its own slice folder unless the model puts several commands in one state-change slice. On .NET, when command names are left out of Arc routes, a second HTTP-mapped command in the same namespace, counted after the skipped route segments, puts the type name back into the conventional route of each, which changes the URL of a command that had no name in it. Protocol-only commands do not count. An explicit route stays as written but still counts as a command in its namespace. Other backends route differently, so check the generated routes before adding a command.
30
31
  - **Slices do not call each other.** Read another slice's published state or react to its fact; never invoke its handler or service. Compose through the command pipeline and propagate refusal.
31
32
  - **Concepts stay home.** Keep a concept in its slice until another slice shares the meaning, then move it one level up (`cratis-fundamentals-name-value`).
33
+ - **Events have a home too.** Declare an event once, in the slice that owns the fact, which is not always the only slice that appends it. Other slices that append, project or react to it import it, never copy it. When no single slice owns the fact, move it to the feature root or another shared scope and keep its event type ID unchanged.
34
+ - **Screens connect through the feature.** A slice's screen never imports a sibling slice's screen. It takes what it needs as callback props, and the feature's composition page connects them (`cratis-arc-react-bind-slice`, `references/typescript-structure.md`).
32
35
  - **Facts.** Append observed transitions, not repeated polls, to the history the fact belongs to. Guard a decision against concurrent writers, because a plain append does not protect what was read (`cratis-chronicle-protect-decision`). Keep confidential inputs out of causation.
33
36
  - **Facts are not views.** Never append an event for a total, count or status label that existing facts and the clock already determine, such as overdue or past due: store the deadline, project the rest and compare at the query or screen. Record an expiry or status change as a fact only when the business treats it as a transition that changes rights or releases something, such as an expired invitation freeing its email address for reuse, and append it once, when the transition is decided. Record a fact once, either per item or as one event carrying the list, never both, and record the one decision that changed rather than a whole settings object. A refused command appends nothing unless the business must audit or react to the refusal. Keep the event source ID and the time it was recorded out of the payload; both travel with the event (`cratis-modeling-design-event-model`).
34
37
  - **Projections fold; reactors act.** A projection has no effects, because rebuilds replay it. A reactor reads state through read models and acts by returning commands or events or by an outside call, never by reading or appending to the event log itself.
@@ -10,7 +10,7 @@ One precise line per load-bearing term, so the same word means the same thing ev
10
10
 
11
11
  ## Events & streams
12
12
 
13
- - **Event** — an immutable, past-tense **fact** that something happened; declared with `[EventType]` in .NET. Subject to the event store’s redaction policies.
13
+ - **Event** — an immutable, past-tense **fact** that something happened; declared with `[EventType]` in .NET. A stored payload is replaced with a marker only by an explicit redaction request: a redaction (of one event, or of an event source's events) replaces the stored payload in the target event sequence only, not in copies made earlier such as backups, exports or events already forwarded to an inbox; system event store events cannot be redacted. An explicit revision corrects content and keeps the original. Both keep the event's sequence number; a redacted event leaves a marker with the reason. A compensation is a new event linked to the one it offsets.
14
14
  - **Event source** — the entity or process whose changes are recorded; one event source can have multiple named streams.
15
15
  - **Event source id** — the append routing identity of an event source, carried in event context. Do not duplicate it in the payload just to identify the current source. A related source ID can be part of the fact.
16
16
  - **Event stream** — an ordered part of an event source’s history within an event sequence. A stream type names the part; a stream ID selects an instance of that part.
@@ -18,7 +18,8 @@ One precise line per load-bearing term, so the same word means the same thing ev
18
18
  - **Event log** — the default event sequence where domain events are appended.
19
19
  - **Outbox / inbox** — cross-service event sequences: a producer appends its public contract event to the outbox; a consumer observes the inbox.
20
20
  - **Public event** — an event type that is part of the contract an event store exposes to other services (`.NET`: `[Public]` or `[EventStore]` on the type, or `[EventStore]` on its assembly; otherwise private). The outbox rejects private events and the event log rejects public events.
21
- - **EventContext** — metadata traveling with an event (event source id, sequence number, occurred, causation/correlation, subject).
21
+ - **EventContext** — metadata traveling with an event: event source id, sequence number, occurred, correlation id and causation chain, caused-by identity, tags, event type with the delivered generation, stream type and id, event store and namespace, and subject. Which further members exist depends on the SDK: .NET also exposes the generation the event was appended in and, only when the event is a compensation, the sequence number it compensates for; other SDKs may omit either or report them differently, so check the SDK before relying on them. Read these from the context instead of copying them into the event; `cratis-chronicle-react-to-fact` (`references/csharp.md`) lists the .NET context members.
22
+ - **Integration event** — an event that crosses a system boundary. With Chronicle outbox/inbox subscriptions, outbound it is the public contract event a producer appends to its outbox, and a consumer's reactors, reducers and projections may observe that contract directly on the inbox; other outbound delivery, such as a webhook, need not go through an outbox. Inbound raw data from an outside system, recorded as received in that system's terms as an event type of its own, stays at the boundary: only the Translation slice observes it, and everything else consumes the facts we own that the translation records.
22
23
 
23
24
  ## Read side
24
25
 
@@ -28,6 +29,7 @@ One precise line per load-bearing term, so the same word means the same thing ev
28
29
  - **Reactor** — observes recorded events to trigger effects such as notifications, commands or follow-up events. See `cratis-chronicle-react-to-fact` for the client’s registration and delivery conventions.
29
30
  - **Observer** — a projection, reducer or reactor consuming an event sequence and maintaining subscription, replay and quarantine state. A projection's replay and catch-up are one globally ordered step, a new failure stops that catch-up, a full replay leaves the observer inactive, and completing it does not resume an observer from quarantine; do not generalize this ordering to reducers.
30
31
  - **Sink** — where Chronicle sends projection or reducer state: a store such as MongoDB (the default document store) or an EF Core-backed SQL sink, or an event-sequence sink that publishes the state as new events.
32
+ - **To-do list** — a read model of pending work that an Automation drains: an opening event adds the item, every event that closes the work removes it, and on each pass the reactor sends one command per eligible item (for example, one whose deadline has passed), not per listed item. The list can lag, so it only nominates candidates; the command rechecks current state.
31
33
  - **AutoMap** — Chronicle's on-by-default mapping of matching event→read-model property names; omit `.AutoMap()` unless explicitly re-enabling mapping after `.NoAutoMap()`.
32
34
  - **Graph** — a named property graph that events build through a graph projection: nodes, edges and their properties. Derived state like a read model; nothing writes to it directly.
33
35
  - **Node** — a graph element with a label, one unique key and primitive properties. The label is the type name.
@@ -50,7 +52,7 @@ One precise line per load-bearing term, so the same word means the same thing ev
50
52
 
51
53
  ## Structure & types
52
54
 
53
- - **Slice** — the vertical unit of one behavior (command + events + projection + read model + component + specs), created/changed/deleted together.
55
+ - **Slice** — the vertical unit of one behavior, grouping only the artifacts that behavior needs (any of command, events, projection, read model, query, component, specs; a listing slice may have a read model, query and projection but no command or new event), created/changed/deleted together. Its folder is named for the capability (`Registration`, `Listing`), not for the command type; when present, a command is named in the imperative and an event in the past tense.
54
56
  - **Slice types** — **State Change** (command → events), **State View** (events → read model), **Automation** (events → side effect, including a follow-up command or event — a Screenplay `produces` / `invokes`), **Translation** (data from *outside* the model's own facts → our own facts: an external system's or another service's data recorded as events we own, keeping the external fact distinct from the local one; a Screenplay `Translate` slice with `direction outbound` is the other direction, publishing our private facts as one public contract event). A reactor that turns our own event into a follow-up event or command is an Automation, not a Translation.
55
57
  - **Concept** — a named type wrapping exactly one scalar domain value (`ConceptAs<T>` in C#, TypeScript, Kotlin and Java; a defined type in Go; `use Cratis.Chronicle.Concept` in Elixir); the bare scalar on every wire and in every store.
56
58
  - **Event-source identity** — the concept type that addresses one Chronicle event history (`EventSourceId<T>` in C#); only such identities use it, every other identity is a plain concept.
@@ -11,8 +11,10 @@ paths:
11
11
 
12
12
  - Call the backend through generated proxies, never raw `fetch`, since copied routes and types drift. Compose slices on a page only through their exported components, never their internals, so each slice stays removable. See `cratis-arc-react-bind-slice`.
13
13
  - Call hooks unconditionally; gate a query with `Query.when(condition).use(args)`, since a skipped hook breaks React's hook order.
14
- - Render unauthorized, refused and failed results apart from pending and empty, since an empty list hides a refusal. Show a neutral failure message, never exception text or stack traces, which expose internals. Let observable queries show accepted writes; a locally patched list drifts from the read model.
14
+ - Render unauthorized, refused and failed results apart from pending and empty, since an empty list hides a refusal. Show a neutral failure message, never exception text or stack traces, which expose internals. Let observable queries show accepted writes; a locally patched list drifts from the read model. Edge case: for a gesture that must show its result in the same frame, such as a drop or a paste, see `cratis-arc-react-bind-slice` (`references/typescript-instant-feedback.md`). A command built there with `new` instead of `use()` does not get the host's locale: before executing, call `setRequestDefaults({ locale: arc.localeStore, httpHeadersCallback: arc.httpHeadersCallback })` on it with `arc` from `useContext(ArcContext)`.
15
15
  - Bind live collections with the observable query's `.use()` hook; Suspense and raw `subscribe` do not apply delta updates. Render `useSuspense()` inside a `QueryBoundary`, which supplies the fallback and catches failures.
16
16
  - On sign-in, sign-out or account switch, change the credentials first, then `refresh()` the identity (`clearIdentity()` on sign-out) and call `reconnectQueries()` before caller-scoped data renders: the identity calls touch only the identity, while reconnecting drops cached results and live connections that still belong to the old caller. Reserve a full page load for identity-provider redirects or an intentional app reset. See `cratis-arc-react-bind-slice`.
17
+ - Set the UI language with the `locale` prop on `<Arc>`, never a hand-written `Accept-Language` header: the header replaces the language Arc sends, and a native WebSocket or EventSource handshake cannot carry it, so a live stream carries its language in its URL. With a locale set, that is the active language by default; a header override replaces it only when it is one valid language tag, and a preference list is left out of the URL, so the stream stops following the UI language. See `cratis-arc-react-bind-slice` (`references/typescript-localization.md`).
18
+ - Read a command form's values through the form's own instance (`useCommandInstance()` beneath the form) and submit through the form: its own submit, or, for a plain `CommandForm` only, the form handle's `execute()` (`formRef`) for a button outside it. Submit a `CommandStepper` only through its own Submit: its `formRef` reaches the inner form and skips the stepper's before-execute step and confirmation. Calling the instance's `execute()` skips the form's custom field errors and result callbacks; calling the command's `use()` beside the form creates a second instance that can submit different values from those on screen. See `cratis-components-submit-form`.
17
19
  - Keep view models plain classes. Mark one with constructor parameters `@injectable()` and type each dependency as a class or explicit token, never a bare interface, which compiles away and cannot be resolved. Release subscriptions in `detached()`, or they outlive the view. Wrap a child that reads view-model state itself in `observer` from `@cratis/arc.react.mvvm`, or it will not re-render. Keep `@cratis/eslint-plugin-arc` recommended rules on; they reject hooks in view models and direct `mobx-react` imports. See `cratis-arc-react-separate-view-model`.
18
20
  - Ask confirmation through the shared confirmation hook or `IDialogs`, never `window.confirm`, and act only on `DialogResult.Yes` or `Ok`, since dismissal resolves to `Cancelled`. Start a busy indicator without awaiting it, since its promise settles only on close, and close it in `finally`, since users cannot dismiss it. See `cratis-components-coordinate-feedback`.
@@ -19,8 +19,10 @@ profile: application
19
19
  - Start a new effect-producing reactor at the tail, or have it ignore older facts; its first catch-up is not a replay, so replay exclusion does not stop it.
20
20
  - Exclude effect-producing handlers from replay, and still make every effect idempotent: exclusion does not stop retries or redelivery. Key each external call by the stable delivery identity plus an effect name, never an attempt number, for the receiver to deduplicate.
21
21
  - Return follow-up events or commands instead of appending to the event log yourself, so they belong to the delivery. Derive them from the event and stable state, never a fresh ID or the clock, so a redelivery produces the same output.
22
- - Never swallow a failed effect; let it fail the partition so it retries visibly. Do not throw to reject malformed or refused input: record a failure fact, because failed partitions stall and enough of them quarantine the whole observer.
22
+ - Never swallow a failed effect; let it fail the partition so it retries visibly. Do not throw to reject malformed or refused input: record a failure fact, because a failed partition stalls every later event for that event source, and once its retries are used up on the same event it is quarantined: automatic retries stop. It moves on through an authorized manual retry, which is still accepted but keeps the spent budget, by clearing that partition's quarantine, or, on a replayable reactor, by a successful replay that covers the failed event. Other event sources can keep flowing while the observer stays active. A batch handler that throws fails every partition in the batch, so report the failure for the affected partition when the rest can succeed. Failed partitions quarantine the observer as a whole only when a kernel failure threshold is enabled and reached, and both thresholds are off by default; a reactor partition whose latest failure is a timeout does not count toward them; the observer can still be quarantined for other reasons, such as a catch-up that cannot start.
23
+ - A handler may await the work of the delivery it is handling, but must not hold that delivery open for a future business fact, an approval or a deadline. Handle a later fact in its own handler; for a deadline, an approval or any process that pauses, keep a work-list item open and continue in the reactor for the fact that ends the wait (`cratis-chronicle-react-to-fact`, "Multi-step processes"). Never sleep, block or keep an in-memory timer to wait for one: a handler that does not answer in time times out. Live delivery records that as a failed partition; catch-up and replay can run the timed-out step again first, so the handler may run more than once before the failure is recorded. Once it is recorded, automatic recovery retries only while that partition has retries left, and an in-memory timer is lost on restart.
23
24
  - Keep reactors stateless and shared dependencies thread-safe; partitions can run concurrently.
25
+ - Never assume a projection or reducer has handled the event the reactor is handling: every observer advances on its own, so a stored read model may not include that event yet. Decide from the event itself or on-demand state (`cratis-platform-deliver-slice`, `references/eventual-consistency.md`).
24
26
  - Do not delete, revoke, bill or notify because a stored read model lacks something: it lags the log and reads empty while rebuilding, so decide from the events or on-demand state. Cap the subjects one unattended pass may act on and refuse an implausible count, so one bad input cannot sweep everything.
25
27
  - Guard against reacting to what the reactor itself produced, or one input loops.
26
28
  - Commands a reactor returns run without the caller's identity and run again on redelivery: make them idempotent, and when they need authorization run them as a system identity holding only the roles they need (`cratis-arc-authorize-request`).
@@ -1,13 +1,16 @@
1
1
  ---
2
- applyTo: "**/for_*/**/*.cs, **/when_*/**/*.cs"
2
+ applyTo: "**/for_*/**/*.cs, **/when_*/**/*.cs, **/when_*.cs, **/given/**/*.cs"
3
3
  paths:
4
4
  - "**/for_*/**/*.cs"
5
5
  - "**/when_*/**/*.cs"
6
+ - "**/when_*.cs"
7
+ - "**/given/**/*.cs"
6
8
  ---
7
9
 
8
10
  # C# specs
9
11
 
10
- - Name spec projects `<Source>.Specs`. Start a new one on `Cratis.Specifications.XUnit.v3`; keep an existing project's runner with its matching adapter package, which wires the lifecycle into that runner.
12
+ - Name spec projects `<Source>.Specs`. In a separate spec project, mirror the slice's relative path under the project root, `<Source>.Specs/<Feature>/<Slice>/`, and put the spec folders there (for example `for_<Unit>/` or `when_<behaviour>/`). Start a new one on `Cratis.Specifications.XUnit.v3`; keep an existing project's runner with its matching adapter package, which wires the lifecycle into that runner.
13
+ - Keep an existing co-located layout: where the application project already compiles specs beside its slices, extend it and add no separate spec project, not even for running-kernel specs. Its setup is the project's own, not universal: some exclude only the spec folders from non-Debug builds and run through the application's entry point, others also exclude flat `when_*.cs` files and run with `dotnet test`. Read the project's exclusion patterns and run command, place spec files only where the exclusion reaches, and use the suite's established filter to keep infrastructure out of ordinary runs.
11
14
  - Write `Establish` for setup, `Because` for the one action and `should_*` facts marked with the runner's fact attribute (none on the native runner). `Given`/`When` are aliases: one name per phase per class. A `given/` context holds `Establish` only; `all_dependencies` creates the substitutes. Lifecycle runs base-first, so never call a base lifecycle method.
12
15
  - Keep the shared lifecycle: facts share one instance and may run concurrently, so they only read, even through a helper (no assignment, `Add`, `Returns`, `Dispose` or second action); every mutation goes in `Establish` or `Because`. Use `[PerFactSpecificationLifecycle]` only when isolation genuinely requires it.
13
16
  - Return `Task`, never `async void`, from facts and lifecycle methods, and await every `Task`-returning `Should*`: a discarded assertion can never fail.
@@ -18,4 +21,4 @@ paths:
18
21
  - Reuse `GlobalUsings.Specs.cs` without repeating its imports; alias a type a namespace shadows (CS0118) with a `using` placed last.
19
22
  - Run a built suite without rebuilding and check its exit status and teardown result, not only passing facts. After changing a widely substituted interface, build the whole spec project; after a runner migration, account for every previously discovered case and skip.
20
23
 
21
- Mechanism, packages and runner options: `cratis-specifications-isolate-behavior`; scenarios: `cratis-specifications-exercise-backend`; run commands and filters: `run-tests`.
24
+ Mechanism, packages and runner options: `cratis-specifications-isolate-behavior`; scenarios: `cratis-specifications-exercise-backend`, whose `references/csharp-colocated.md` covers specs kept beside the slice; run commands and filters: `run-tests`.
@@ -16,9 +16,9 @@ paths:
16
16
 
17
17
  Group by behavior, not by technical layer. Each slice has exactly one type:
18
18
 
19
- - **State Change**: a command is accepted or refused and appends events.
19
+ - **State Change**: a command is accepted or refused. An accepted command appends events or, in an application that is not event sourced, writes through the application's store, and may change nothing when it repeats work already done. A refused command never applies the requested change.
20
20
  - **State View**: events build a read model that queries expose.
21
- - **Automation**: reacts to a committed event with a follow-up command or an outside call.
21
+ - **Automation**: reacts to a committed event with a follow-up command or an outside call. Without events, trigger the side effect explicitly, and only after the command's write is confirmed committed: a store call that returned inside an open transaction is not yet committed. That is separate from the inline operations a command returns as part of its own write.
22
22
  - **Translation**: turns input from outside our own facts into our facts.
23
23
 
24
24
  Non-negotiables:
@@ -26,8 +26,11 @@ Non-negotiables:
26
26
  - **Layout.** `<Module>/<Feature>/<Slice>/` under one slice root: the source or package root, or the single artifact folder (such as `Features/`) an SDK's discovery and generator scan so the host stays outside it. Add no other wrapper or technical-layer folder; a single-capability application starts at `<Feature>/<Slice>/`. The namespace, package or module mirrors the path.
27
27
  - **Renaming is a migration.** A namespace or package rename can change stored observer identities and Arc routes; never treat it as a plain file move.
28
28
  - **One slice is one unit.** Its command, events, read model, reaction and screen live in its folder and ship with its specifications. Declare its backend artifacts in one `<Slice>` file unless the language needs a file per public type, so the slice reads and changes as one. Report a partly done slice as partial; never stub it.
29
+ - **One command per slice by default.** Give each command its own slice folder unless the model puts several commands in one state-change slice. On .NET, when command names are left out of Arc routes, a second HTTP-mapped command in the same namespace, counted after the skipped route segments, puts the type name back into the conventional route of each, which changes the URL of a command that had no name in it. Protocol-only commands do not count. An explicit route stays as written but still counts as a command in its namespace. Other backends route differently, so check the generated routes before adding a command.
29
30
  - **Slices do not call each other.** Read another slice's published state or react to its fact; never invoke its handler or service. Compose through the command pipeline and propagate refusal.
30
31
  - **Concepts stay home.** Keep a concept in its slice until another slice shares the meaning, then move it one level up (`cratis-fundamentals-name-value`).
32
+ - **Events have a home too.** Declare an event once, in the slice that owns the fact, which is not always the only slice that appends it. Other slices that append, project or react to it import it, never copy it. When no single slice owns the fact, move it to the feature root or another shared scope and keep its event type ID unchanged.
33
+ - **Screens connect through the feature.** A slice's screen never imports a sibling slice's screen. It takes what it needs as callback props, and the feature's composition page connects them (`cratis-arc-react-bind-slice`, `references/typescript-structure.md`).
31
34
  - **Facts.** Append observed transitions, not repeated polls, to the history the fact belongs to. Guard a decision against concurrent writers, because a plain append does not protect what was read (`cratis-chronicle-protect-decision`). Keep confidential inputs out of causation.
32
35
  - **Facts are not views.** Never append an event for a total, count or status label that existing facts and the clock already determine, such as overdue or past due: store the deadline, project the rest and compare at the query or screen. Record an expiry or status change as a fact only when the business treats it as a transition that changes rights or releases something, such as an expired invitation freeing its email address for reuse, and append it once, when the transition is decided. Record a fact once, either per item or as one event carrying the list, never both, and record the one decision that changed rather than a whole settings object. A refused command appends nothing unless the business must audit or react to the refusal. Keep the event source ID and the time it was recorded out of the payload; both travel with the event (`cratis-modeling-design-event-model`).
33
36
  - **Projections fold; reactors act.** A projection has no effects, because rebuilds replay it. A reactor reads state through read models and acts by returning commands or events or by an outside call, never by reading or appending to the event log itself.
@@ -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,7 +31,6 @@
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
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.
@@ -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, a rule that depends on who acts on behalf of a user, or configuring what Cratis AuthProxy admits (identity verification, bearer routes, anonymous paths, a sign-in shared across hosts). 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,7 +10,7 @@ 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, changing how a service takes part in identity verification, or sharing a sign-in across hosts.
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
 
@@ -8,10 +8,13 @@
8
8
  - Anonymous paths
9
9
  - Sign-in providers
10
10
  - Sessions across tenant hosts
11
+ - On-behalf sessions
11
12
  - Verify
12
13
 
13
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.
14
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
+
15
18
  ## The boundary
16
19
 
17
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).
@@ -110,6 +113,22 @@ Cookie scope only decides what a browser sends. AuthProxy does not bind a sessio
110
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.
111
114
  - **The application:** it must enforce tenant membership on every tenant-scoped operation; Arc's sign-in and role checks do not do that.
112
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.
131
+
113
132
  ## Verify
114
133
 
115
134
  1. Without a credential, a bearer-route path answers 401 and an ordinary path does not reach the application.
@@ -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`.
@@ -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. With the Chronicle integration, events a command appends inside `As(principal)` record that principal as their `causedBy`, unless the current Chronicle identity's subject is not System, in which case that identity wins. A System identity is replaced, and its `OnBehalfOf` chain is kept after the principal. Claim `sub` becomes the subject, `name` the name and `preferred_username` the user name, with `Identity.Name` as the fallback for the last two. A principal acting on behalf of someone records the actor with the represented user as `OnBehalfOf` when both carry a subject, name or user name; otherwise it records only the one that does. Give its `ClaimsIdentity` an authentication type; an unauthenticated principal leaves the recorded identity unchanged. 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.
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
 
@@ -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`.