@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
@@ -0,0 +1,126 @@
1
+ # Sessions and sign-out
2
+
3
+ ## Contents
4
+
5
+ - What a caller without a session gets
6
+ - Session lifetime
7
+ - The identity cookie
8
+ - Sign out
9
+ - Require a recent sign-in for sensitive paths
10
+ - Tell the backend when someone signs in
11
+ - Anti-patterns
12
+
13
+ ## What a caller without a session gets
14
+
15
+ The proxy serves a sign-in or selection page only to a browser that is navigating. Every other caller gets a status code. A refusal of a signed-in caller carries its status for every caller, with the refusal page as the body.
16
+
17
+ | Situation | Browser navigation | Any other caller (`fetch`, webhook, API client) |
18
+ |---|---|---|
19
+ | Not signed in, one provider | Redirect to the provider | `401` |
20
+ | Not signed in, several providers | The provider-selection page | `401` |
21
+ | Signed in, must choose a tenant | The tenant-selection page | `403` |
22
+ | Signed in, belongs to no tenant | The no-organization page with `403` | The same `403` response, page included |
23
+ | Signed in, lacks a required claim | The not-authorized page with `403` | The same `403` response, page included |
24
+ | Signed in, a `Required` service could not be asked | The service-unavailable page with `503` and `Retry-After` | The same `503` response, page included |
25
+
26
+ - A `503` is an outage, not a refusal: the session is kept and the person is let back in when the service answers again. Do not treat it as signed out.
27
+ - A client must read the status, not the body: a `403` or `503` can carry HTML.
28
+ - The frontend never receives a login page as the response to a command or query. A `401` there means the session has ended: navigate or reload the page so the browser starts sign-in. See `cratis-arc-react-bind-slice` (identity reference) for the React side.
29
+ - An endpoint that must answer callers without a session, such as a webhook receiver, is declared in the service's `AnonymousPaths`. See [services-and-routing.md](services-and-routing.md).
30
+ - An HTTP probe is not a navigation: on a protected application path it gets `401`, not a redirect. Probe the management listener instead: see [operations.md](operations.md).
31
+
32
+ ## Session lifetime
33
+
34
+ Settings under `Cratis:AuthProxy:Session`:
35
+
36
+ | Setting | Default | Meaning |
37
+ |---|---|---|
38
+ | `Lifetime` | `12:00:00` | Absolute lifetime. When it elapses the person signs in again at the provider. |
39
+ | `SlidingExpiration` | `false` | Whether activity extends the lifetime. Off, so `Lifetime` is a hard bound. |
40
+ | `IdentityRevalidationInterval` | `00:10:00` | How long a positive `/.cratis/me` verdict stored with the session is honored before the proxy asks the services again. |
41
+ | `IdentityResultCacheDuration` | `00:00:30` | How long the proxy reuses a `/.cratis/me` answer in memory, per person and tenant. Zero turns off this in-memory reuse only; the verdict stored with the session is still honored for `IdentityRevalidationInterval`. |
42
+ | `TenantRevalidationInterval` | `00:10:00` | How long a selected tenant is trusted before it is confirmed against the tenants endpoint again. |
43
+ | `CookieDomain` | host-only | A parent domain such as `.example.com`, so one sign-in holds on every host under it. Cannot be combined with `SubHost` tenant resolution. |
44
+
45
+ - Removing a person's access in the application does not take effect on the next request. Both `IdentityRevalidationInterval` and `IdentityResultCacheDuration` let a positive verdict be reused, and neither is an exact deadline. Lower both when the delay is too long; each lapse costs one `/.cratis/me` call per service. To have a `Required` service asked on every request, set both to zero.
46
+ - The session cookie is `HttpOnly` and has no persistent expiry: the browser drops it when the browser session ends.
47
+ - A provider entry can carry its own `Session` block with `Lifetime` and `SlidingExpiration`. It can only shorten the global policy. Use it for a provider that proves less, such as an e-mail code.
48
+
49
+ ## The identity cookie
50
+
51
+ By default the proxy writes a readable `.cratis-identity` cookie with the details from `/.cratis/me`.
52
+
53
+ - It is display data, never a credential. The backend ignores it and the Arc frontend reads identity from `/.cratis/me`.
54
+ - Set `Session:EmitIdentityDetailsCookie` to `false` once every frontend reads identity from `/.cratis/me`. The proxy then stops writing it and expires copies that browsers still send.
55
+ - The roles of a session come from the sign-in provider's claims. A `roles` field in a service's `/.cratis/me` answer is not added to the session.
56
+
57
+ ## Sign out
58
+
59
+ Sign-out is a full-page navigation, not a `fetch`:
60
+
61
+ ```html
62
+ <a href="/.cratis/logout?redirect=https://www.example.com">Sign out</a>
63
+ ```
64
+
65
+ | Session established through | What sign-out ends |
66
+ |---|---|
67
+ | An OIDC provider that advertises an end-session endpoint | The proxy session and the provider's session. The browser goes through the provider's end-session endpoint and back to `/.cratis/logout/callback`. |
68
+ | An OIDC provider without an end-session endpoint, or a session that holds no ID token | The proxy session only. |
69
+ | An OAuth provider such as GitHub | The proxy session only. The person stays signed in at the provider, so the next sign-in may complete without asking for credentials. |
70
+
71
+ - Register `https://<proxy-host>/.cratis/logout/callback` as a post-logout redirect URI at every OIDC provider that supports sign-out through an end-session endpoint.
72
+ - `redirect` is an absolute URL or a same-site relative path. An absolute target is accepted when its origin is the proxy's own public origin, a configured service frontend, or listed in `Logout:AllowedRedirectOrigins`. Each entry there is an origin with no path, such as `https://www.example.com`.
73
+ - A missing or refused `redirect` falls back to `/`.
74
+ - The endpoint is anonymous. It works when the session is already invalid.
75
+ - Sign-out deletes the proxy's own cookies. A cookie the application or an earlier ingress set survives unless it is listed under `Logout:AdditionalCookies` with its exact `Name` and, for a cookie scoped to a parent domain, its `Domain`.
76
+
77
+ ## Require a recent sign-in for sensitive paths
78
+
79
+ A valid session does not prove the person signed in recently. Declare how old the sign-in may be per path on a service:
80
+
81
+ ```json
82
+ "Services": {
83
+ "main": {
84
+ "FreshAuthentication": [
85
+ { "Path": "/admin", "Prefix": true, "MaxAge": "00:15:00" }
86
+ ]
87
+ }
88
+ }
89
+ ```
90
+
91
+ | Caller whose sign-in is older than `MaxAge` | Response |
92
+ |---|---|
93
+ | A browser navigation | Redirect to sign in again with the same provider, then back to the page. |
94
+ | Any other request | `401` with a `WWW-Authenticate` challenge carrying `insufficient_user_authentication`. The request is not replayed; the client decides whether to retry after the person has signed in again. |
95
+
96
+ - `Path` is matched against the path the backend receives. With `StripPathPrefix` on a service routed by `/reporting`, write `/admin`; with the prefix kept, write `/reporting/admin`. A rule written the other way never matches and the path goes unprotected.
97
+ - `Prefix: true` also covers every path below it.
98
+ - A rule that lists `Methods` also requires `FreshAuthenticationMethodOverrideUnsupported: true` on the service, or the proxy refuses to start. Set it only when the backend honors no HTTP method override. Otherwise leave `Methods` out so the rule covers every method.
99
+ - It works for sessions from an OIDC provider or an e-mail code (`Type: Code`). A session from an OAuth provider such as GitHub cannot prove when the person signed in, so a path with a rule answers `403` for it. Do not put a rule on a service whose users sign in through an OAuth provider.
100
+ - Use it instead of shortening the whole session.
101
+
102
+ ## Tell the backend when someone signs in
103
+
104
+ `Services:<name>:SignInCallback` has the proxy call the service's backend, in the background, without delaying the browser:
105
+
106
+ ```json
107
+ "SignInCallback": { "Path": "/internal/sign-in", "Interval": "12:00:00" }
108
+ ```
109
+
110
+ | Kind | When |
111
+ |---|---|
112
+ | `SignedIn` | A sign-in at a provider completes. |
113
+ | `Returned` | An existing browser session makes a request to the service and no callback was sent for that person and service within `Interval`. A `SignedIn` starts the interval, so the request that follows a sign-in is not a `Returned`. |
114
+
115
+ - Delivery is best-effort: a callback can be dropped, and each proxy instance tracks `Interval` on its own, so several instances can each send one. Make the receiver tolerate both a missing and a repeated callback.
116
+ - `Path` is a path on the service's `Backend`. A service without a backend cannot receive the callback.
117
+ - Set `Secret` from a secret store so the service can tell the proxy from any other caller on its network.
118
+ - Use it to record activity or start per-person work. It is a notification, not a gate: admission stays with [required claims and `/.cratis/me`](admission.md).
119
+
120
+ ## Anti-patterns
121
+
122
+ - Calling `/.cratis/logout` with `fetch`. The redirects to the provider need a navigation.
123
+ - Following a `401` from a command or query as if it were a redirect, or expecting a login page in the response.
124
+ - Reading `.cratis-identity` to make an authorization decision.
125
+ - A very short `Session:Lifetime` to protect one sensitive operation. Use `FreshAuthentication` on that path.
126
+ - Expecting a removed person to be locked out on the next request while `IdentityRevalidationInterval` or `IdentityResultCacheDuration` still lets the earlier verdict be reused.
@@ -0,0 +1,116 @@
1
+ # Sign-in providers
2
+
3
+ ## Contents
4
+
5
+ - OpenID Connect providers
6
+ - OAuth providers such as GitHub
7
+ - One provider or several
8
+ - Register the callbacks at the provider
9
+ - Providers that let anyone register
10
+ - Sign in with a one-time code
11
+ - Anti-patterns
12
+
13
+ ## OpenID Connect providers
14
+
15
+ Declare a provider that publishes an OpenID Connect discovery document under `Cratis:AuthProxy:Authentication:OidcProviders`:
16
+
17
+ ```json
18
+ {
19
+ "Cratis": {
20
+ "AuthProxy": {
21
+ "Authentication": {
22
+ "OidcProviders": [
23
+ {
24
+ "Name": "Microsoft",
25
+ "Type": "Microsoft",
26
+ "Authority": "https://login.microsoftonline.com/<tenant-id>/v2.0",
27
+ "ClientId": "<client-id>",
28
+ "ClientSecret": "<client-secret>"
29
+ }
30
+ ]
31
+ }
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ | Property | Meaning |
38
+ |---|---|
39
+ | `Name` | The name shown on the provider-selection page. It also gives the scheme name. |
40
+ | `Type` | `Microsoft`, `Google` or `Custom`. Use `Custom` for any other OpenID Connect provider, such as Keycloak. |
41
+ | `Authority` | The provider's authority URL. |
42
+ | `ClientId`, `ClientSecret` | The application registered at the provider. |
43
+ | `Scopes` | Scopes in addition to `openid`, `profile` and `email`. |
44
+
45
+ Supply `ClientSecret` from a secret store or an environment variable (`Cratis__AuthProxy__Authentication__OidcProviders__0__ClientSecret`), never from a committed file.
46
+
47
+ ## OAuth providers such as GitHub
48
+
49
+ GitHub publishes no discovery document. Declare it under `Authentication:OAuthProviders` with its endpoints named:
50
+
51
+ ```json
52
+ {
53
+ "Name": "GitHub",
54
+ "Type": "GitHub",
55
+ "AuthorizationEndpoint": "https://github.com/login/oauth/authorize",
56
+ "TokenEndpoint": "https://github.com/login/oauth/access_token",
57
+ "UserInformationEndpoint": "https://api.github.com/user",
58
+ "ClientId": "<client-id>",
59
+ "ClientSecret": "<client-secret>",
60
+ "Scopes": [ "read:user", "user:email" ],
61
+ "ClaimMappings": {
62
+ "sub": "id",
63
+ "name": "name",
64
+ "preferred_username": "login",
65
+ "email": "email"
66
+ }
67
+ }
68
+ ```
69
+
70
+ - `ClaimMappings` turns the provider's user-information JSON into claims: the key is the claim to create, the value is the JSON field to read.
71
+ - Add the `read:org` scope to a GitHub provider when admission depends on organization or team. See [admission.md](admission.md).
72
+ - An OAuth provider has no end-session endpoint, so sign-out clears the proxy session only. It also cannot prove when the person signed in, so fresh-authentication rules cannot be satisfied. See [sessions-and-logout.md](sessions-and-logout.md).
73
+
74
+ ## One provider or several
75
+
76
+ OIDC and OAuth providers count together.
77
+
78
+ | Configured | An unauthenticated browser navigation |
79
+ |---|---|
80
+ | One provider | Is redirected straight to that provider. |
81
+ | Several providers | Gets the provider-selection page. |
82
+
83
+ Each provider has a login endpoint at `/.cratis/login/{scheme}`. The scheme is the provider `Name` in lowercase with spaces replaced by hyphens: `My Provider` becomes `my-provider`. Link to that endpoint to start sign-in with one specific provider.
84
+
85
+ ## Register the callbacks at the provider
86
+
87
+ Register these addresses on the proxy's public host at the provider:
88
+
89
+ | Address | Purpose |
90
+ |---|---|
91
+ | `https://<proxy-host>/signin-{scheme}` | The sign-in callback (redirect URI). |
92
+ | `https://<proxy-host>/.cratis/logout/callback` | The post-logout redirect URI. Only for an OIDC provider that advertises an end-session endpoint; without one, sign-out ends the proxy session only. |
93
+
94
+ A proxy that serves several hosts needs the callbacks registered for each host, or one host set aside for the handshake with `SignIn:CallbackHost`.
95
+
96
+ ## Providers that let anyone register
97
+
98
+ A social provider signs in every account it has. Two settings limit who gets through:
99
+
100
+ - `RequireVerifiedEmail: true` on an OIDC provider refuses the sign-in unless the person carries exactly one e-mail address and the provider reports it as verified. It defaults to `false`.
101
+ - A required claim decides who is admitted after sign-in. See [admission.md](admission.md).
102
+
103
+ ## Sign in with a one-time code
104
+
105
+ An OIDC provider entry with `Type: Code` signs a person in with an e-mail address and a short code. It needs no `Authority` or `ClientId`.
106
+
107
+ - The proxy issues and verifies the code. The application decides who may sign in, writes the mail and delivers it.
108
+ - Required settings on the provider's `Code` block: `RequestUrl` (the application endpoint the proxy posts a signed request to) and `Attestation` (how that request is signed).
109
+ - Use it when the people who sign in are already known to the application and a separate identity service only to send codes is not wanted.
110
+
111
+ ## Anti-patterns
112
+
113
+ - A login page, password handling or token validation in the application. The proxy owns sign-in.
114
+ - Declaring GitHub under `OidcProviders`. It has no discovery document.
115
+ - A public social provider with no admission requirement on a public host. Everyone with an account gets in.
116
+ - A client secret in a committed configuration file.
@@ -0,0 +1,135 @@
1
+ # Tenant resolution
2
+
3
+ ## Contents
4
+
5
+ - How resolution works
6
+ - Choose a strategy
7
+ - Tenant registry
8
+ - Verify that the tenant exists
9
+ - When no tenant resolves
10
+ - Let a person choose among several tenants
11
+ - Anti-patterns
12
+
13
+ ## How resolution works
14
+
15
+ `Cratis:AuthProxy:TenantResolutions` is an ordered list. The strategies run in order until one resolves a tenant.
16
+
17
+ ```json
18
+ {
19
+ "Cratis": {
20
+ "AuthProxy": {
21
+ "TenantResolutions": [
22
+ { "Strategy": "Specified", "Options": { "TenantId": "acme" } }
23
+ ]
24
+ }
25
+ }
26
+ }
27
+ ```
28
+
29
+ - The proxy removes any `x-cratis-tenant-id` the caller sent and writes the tenant it resolved itself. A caller cannot choose the tenant through a header.
30
+ - Arc reads `x-cratis-tenant-id` by default, so an Arc backend behind the proxy needs no tenant selector configuration. See `cratis-arc-isolate-tenant` for what the backend does with the tenant.
31
+ - The proxy also writes the same value to `Tenant-ID`. That copy is deprecated; read `x-cratis-tenant-id`.
32
+ - A tenant id may contain ASCII letters, ASCII digits and `-`, `.`, `_`, `~`, at most 256 characters. `.` and `..` on their own are not tenant ids. A value outside that rule does not resolve.
33
+ - In Cratis products the tenant is what people see as a workspace.
34
+
35
+ ## Choose a strategy
36
+
37
+ | Situation | Strategy | Options and notes |
38
+ |---|---|---|
39
+ | One tenant per deployment | `Specified` | `TenantId`. The default for a single-tenant application. |
40
+ | A fixed list of customer domains | `Host` | Matches the request host against the tenant registry. |
41
+ | A subdomain per tenant, provisioned dynamically | `SubHost` | `ParentHost`. `acme.example.com` resolves to `acme`. No registry lookup, so add verification. |
42
+ | The identity provider knows the tenant | `Claim` | `ClaimType`. Matches the claim value against `SourceIdentifiers` in the registry. |
43
+ | The tenant is in the path | `Route` | `Pattern`, a regular expression with a named group `sourceIdentifier`, for example `^/tenant/(?<sourceIdentifier>[^/]+)`. Matches against `SourceIdentifiers`. |
44
+ | A person belongs to several tenants and picks one | `Selection` | `TenantsEndpoint`. See [below](#let-a-person-choose-among-several-tenants). |
45
+ | A fallback when nothing else resolves | `Default` | `TenantId`. Put it last. |
46
+
47
+ - `Claim` without `ClaimType` reads `http://schemas.microsoft.com/identity/claims/tenantid`, the Microsoft Entra tenant id. Set `ClaimType` for any other provider. The claim is read from the identity the proxy itself authenticated, never from a header the caller sent.
48
+ - `SubHost` resolves only a single label directly under `ParentHost`: `foo.bar.example.com` and `example.com` itself do not resolve.
49
+ - `SubHost` cannot be combined with `Session:CookieDomain`. The proxy refuses to start, because a session cookie shared across the domain would reach every tenant's host.
50
+
51
+ ## Tenant registry
52
+
53
+ `Host`, `Claim` and `Route` map what they read to a tenant id through `Cratis:AuthProxy:Tenants`, keyed by tenant id:
54
+
55
+ ```json
56
+ {
57
+ "Cratis": {
58
+ "AuthProxy": {
59
+ "Tenants": {
60
+ "acme": {
61
+ "Domains": ["acme.example.com"],
62
+ "SourceIdentifiers": ["acme", "tenant-acme"]
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ `Specified`, `Default` and `SubHost` do not use the registry.
71
+
72
+ ## Verify that the tenant exists
73
+
74
+ `SubHost` accepts any single-label subdomain as a tenant id. Have the proxy ask the application whether the tenant exists before it forwards anything:
75
+
76
+ ```json
77
+ {
78
+ "Cratis": {
79
+ "AuthProxy": {
80
+ "TenantVerification": {
81
+ "UrlTemplate": "https://platform.example.com/api/tenants/{tenantId}"
82
+ }
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ - Any `2xx` status means the tenant exists and the request proceeds. Any other status or a network error serves the tenant-not-found page.
89
+ - `SubHost` can set its own `VerificationUrlTemplate` option, which replaces the global template for that strategy.
90
+ - Verification answers "does this tenant exist". It does not answer "may this person enter it". That decision is the application's: its identity details answer (`/.cratis/me`) is resolved per person and tenant, and with the default `Required` verification a refusal keeps the person out.
91
+
92
+ ## When no tenant resolves
93
+
94
+ The table applies to a request that needs a tenant. The proxy's sign-in pages, invitation and registration paths and a service's `AnonymousPaths` proceed without one, and a deployment that redirects unresolved callers to an invitation lobby sends them there instead.
95
+
96
+ | Configuration | Signed-in person | Anonymous caller |
97
+ |---|---|---|
98
+ | `TenantResolutions` has entries, none resolves | The no-organization page with `403` | `401` |
99
+ | `TenantResolutions` is empty | The request proceeds without a tenant | The request proceeds without a tenant |
100
+
101
+ An empty `TenantResolutions` is only possible when no service uses `Required` identity verification. `Required` is the default, and the proxy refuses to start with a `Required` service and no tenant resolution. A single-tenant application satisfies this with `Specified`.
102
+
103
+ ## Let a person choose among several tenants
104
+
105
+ Use `Selection` when one account can belong to several tenants:
106
+
107
+ ```json
108
+ { "Strategy": "Selection", "Options": { "TenantsEndpoint": "https://platform.example.com/api/tenants/selectable" } }
109
+ ```
110
+
111
+ `TenantsEndpoint` is an absolute URL the application serves. It returns the tenants of the signed-in person as a JSON array of `{ "id": "...", "name": "..." }`.
112
+
113
+ | The endpoint answers | Result |
114
+ |---|---|
115
+ | Exactly one tenant | The tenant is selected automatically. No page is shown. |
116
+ | Several tenants | A browser navigation gets the tenant-selection page. Any other caller gets `403`. |
117
+ | An empty list, `401` or `403` | The person has no tenant: see [When no tenant resolves](#when-no-tenant-resolves). |
118
+ | Unreachable, a timeout, another error or unparseable JSON | `503`. The person is not reported as having no tenant. |
119
+
120
+ The selection page links to `/.cratis/select-tenant?tenantId=<id>&returnUrl=<path>`. The proxy validates the chosen tenant against the endpoint before it stores the selection.
121
+
122
+ **In-app tenant switcher.** For a person with more than one tenant the proxy keeps a `.cratis-tenants` cookie: a URL-encoded JSON array of `{ id, name }` that script on the page can read.
123
+
124
+ 1. Show the switcher only when the cookie lists more than one tenant. A person with one tenant never gets the cookie.
125
+ 2. Switch by navigating the browser to `/.cratis/select-tenant?tenantId=<id>&returnUrl=<current path>`.
126
+
127
+ Every switch is validated against `TenantsEndpoint` again, so a stale cookie cannot grant a tenant the person has left. The selected tenant is also re-confirmed when `Session:TenantRevalidationInterval` (default 10 minutes) has lapsed.
128
+
129
+ ## Anti-patterns
130
+
131
+ - Sending `x-cratis-tenant-id` from the frontend to switch tenant. The proxy removes it. Navigate to `/.cratis/select-tenant`.
132
+ - `SubHost` without tenant verification. Any subdomain then becomes a tenant id.
133
+ - Treating tenant verification as a membership check.
134
+ - Putting `Default` or `Specified` before another strategy. They always resolve, so nothing after them runs.
135
+ - Configuring tenant selection in the backend as well. Keep Arc's default header selector and choose the strategy in the proxy only.
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: cratis-choreography-run-workflow
3
+ description: "Use when a service that has deliberately chosen Orleans (mainly Cratis's own services, libraries and tools) needs a durable workflow that branches, waits for a person, an event or a deadline, or fans out over items, and must survive restarts: write, host and test a Choreography workflow. Not the default for applications: they build on Arc, Chronicle and Components and model a multi-step process, including waits and deadlines, with facts, reactors and a work-list read model (`cratis-chronicle-react-to-fact`). Not for resumable background steps (`cratis-orleans-jobs`)."
4
+ ---
5
+
6
+ # Run a durable workflow
7
+
8
+ ## Contents
9
+
10
+ - What a workflow is
11
+ - Is a workflow the right shape
12
+ - Default path
13
+ - Rules that keep a run correct
14
+ - Failure and undoing completed work
15
+ - Anti-patterns
16
+ - Verify
17
+ - Reference index
18
+
19
+ Choreography is the Orleans toolkit for Cratis's own services, libraries and tools, and this skill is installed by the engineering profiles. An application builds on Arc, Chronicle and Components and models a multi-step process, including waits and deadlines, with facts, reactors and a work-list read model (`cratis-chronicle-react-to-fact`); use that unless the team has deliberately chosen Orleans.
20
+
21
+ Choreography is C#-only. Read `references/csharp.md` for the code.
22
+
23
+ Read `references/<language>.md` for the project's SDK (`.csproj` → csharp); only the languages the project uses are installed.
24
+
25
+ ## What a workflow is
26
+
27
+ A workflow is a business process written as data: a versioned graph of nodes, with edges between the named outlets of those nodes. The engine runs it. A run records the definition it was admitted with and every step it takes as a fact in its own journal, and it is rebuilt from that journal each time it is activated. That is why a run survives a restart, provided the journal is in durable storage.
28
+
29
+ | Node kind | What it does | Leaves through |
30
+ | --- | --- | --- |
31
+ | Trigger | The entry point. Exactly one per graph; its output is the trigger's payload | `next` |
32
+ | Action | Performs a named capability in your code, normally by sending a command | `next`, or `failed` |
33
+ | Decision | A capability in your code that picks one of the node's own outlets | the outlets you name, or `failed` |
34
+ | Wait | Waits for a signal or for time to pass | `resumed` or `expired` (signal), `elapsed` (timer) |
35
+ | Approval | Waits for a person to approve or reject | `approved`, `rejected`, `expired` |
36
+ | ForEach | Fans out over a list, one branch per item, with bounded parallelism | `each` |
37
+ | Join | Gathers the branches of one ForEach: all, any or at least a number | `completed`, `partial` |
38
+
39
+ The graph never contains the work. An action or decision node names a capability and a version; a performer class in the service provides it. Only action and decision nodes are performed by your code; the engine handles the other kinds itself.
40
+
41
+ Each node carries a policy: how many attempts it gets, how long one attempt may take, the delay between attempts and how many times a branch may visit it. The default policy is a single attempt.
42
+
43
+ ## Is a workflow the right shape
44
+
45
+ Use a workflow when the code is one of Cratis's own Orleans-based services and its process branches, waits for a person, an event or a deadline, or fans out over items. The table is for that engineering work only; an application always takes the facts, reactors and work-list path, whatever the shape of its process.
46
+
47
+ | The process is | Use |
48
+ | --- | --- |
49
+ | A straight chain of reactions, with no waiting | A reactor chain: `cratis-chronicle-react-to-fact` |
50
+ | A fixed set of steps that must all get done, with no decision, person or deadline in between | A job: `cratis-orleans-jobs` |
51
+ | One entity moving through its own lifecycle | A state machine: `cratis-orleans-jobs`, reference `csharp-state-machines.md` |
52
+ | A single call | The call |
53
+
54
+ A workflow costs a definition source, named capabilities and a journal. Do not pay that for a straight list of steps.
55
+
56
+ ## Default path
57
+
58
+ The default is a Cratis service connected to Chronicle that keeps the journal in Chronicle: runs become events that can be read and audited, the engine maintains a run listing and an open-waits read model, and an appended event can start a run.
59
+
60
+ 1. **Draw the graph.** Name every node, its kind and the outlets it can leave through. Give every signal wait and approval an expiry, and connect its `expired` outlet; a timer wait has a duration instead and leaves through `elapsed`. Connect `failed` wherever the process has an answer to a failure.
61
+ 2. **Write one performer per capability.** A performer does one thing, normally sends one command, and reports an outcome. Make its effect safe to repeat (see the rules).
62
+ 3. **Supply the definition.** A definition source says which workflows it owns and returns the active snapshot: workflow id, version, subject kind and graph. Performers and definition sources are discovered; you do not register them.
63
+ 4. **Host the engine.** Switch workflows on in the Choreography host and add the Chronicle journal. Workflows are off by default.
64
+ 5. **Trigger the run.** Declare the event that starts it, or start it from code. Give the trigger a deduplication key derived from the event or the business operation.
65
+ 6. **Resume the run.** A person's decision resolves the approval wait on the run. A later fact resumes a signal wait when your code raises a signal with the run's correlation key.
66
+ 7. **Follow it.** Read the run's snapshot for the authoritative status; use the run listing for screens.
67
+
68
+ Steps 1 to 3 and starting from code are in `references/csharp.md`. Step 4 with Chronicle, event triggers, schedules and signals are in `references/csharp-chronicle.md`.
69
+
70
+ **Alternative: no Chronicle.** The engine also keeps the journal in grain storage, one document per run. Use it when the service has no Chronicle, or for local work and tests with in-memory storage. Event triggers, schedules, signals and the run read models come from the Chronicle integration and are not available without it; runs are started from code and waits are resolved on the run.
71
+
72
+ ## Rules that keep a run correct
73
+
74
+ - **A trigger is deduplicated.** The run id is derived from the workflow and the trigger's deduplication key, and a run lives in one scope. A repeated trigger with the same key in the same scope finds the existing run and starts nothing new. It must still pass admission against the current definition, so check the result every time. Derive the key from the event or the business operation; never from a random value or the current time.
75
+ - **A performer can run more than once.** The engine retries a failed attempt under the node's policy, and a restart can invoke a performer twice for one attempt. Every attempt of one node execution carries the same idempotency key. Deduplicate the external effect on the run's scope together with that key: this is the service's half of the guarantee. The key does not include the scope, so the same workflow and trigger key in two tenants give the same idempotency key; a receiver that deduplicates on the key alone drops the second tenant's effect.
76
+ - **Say so when the effect is unknown.** A performer that cannot tell whether its effect happened answers ambiguous. The node is not retried. Other work in the run carries on, and once nothing is in flight the run waits for reconciliation. A person can reconcile only a node in the root branch. An ambiguous node inside a ForEach branch cannot be reconciled, so the run stays in that state: never answer ambiguous inside a fan-out; report a failure there and let the `failed` path decide.
77
+ - **Subject kinds must match.** The trigger's subject kind must equal the definition's, or the run is not admitted. An admission that fails starts nothing and reports its rejections; check the result.
78
+ - **Each arrival is a visit.** There is no implicit merge. A node reached over two edges runs once per arrival, and the second arrival fails while the node allows one visit. Gather parallel paths with a ForEach and its Join; raise the visit limit only for an intended loop.
79
+ - **A ForEach needs exactly one Join and cannot be nested.** Each item must be an object with a unique, non-empty string `key`.
80
+ - **Data is small JSON.** Payloads, node outputs and signal payloads are JSON of at most 32 KiB. Pass identifiers and let the performer read the rest. Never put a secret in node configuration.
81
+ - **A running run keeps its definition.** Changing a workflow means returning a new version of the snapshot. Runs already admitted finish on the version they started with.
82
+ - **A signal is not remembered.** Raising a signal resolves the waits that are open and visible at that moment. A signal raised before its wait is visible resolves nothing. The number it returns counts the waits it found, not the runs that resumed; read the run's snapshot to confirm.
83
+ - **Tell the engine every scope.** A scope separates one tenant's runs from another's. After a full restart the engine only looks for waiting runs in scopes it knows, and it knows none by itself. On durable storage, name the single scope the service uses, or supply every tenant's scope; otherwise a waiting run in an untouched scope is never woken.
84
+
85
+ ## Failure and undoing completed work
86
+
87
+ There is no rollback. Facts already recorded stay recorded.
88
+
89
+ - A node that fails for good leaves through `failed` when that outlet is connected, and the run continues from there. Two exceptions: an answer with an undeclared outlet or unusable output leaves through `fallback` first when that is connected, and a node reached more often than its visit limit is routed nowhere. Route `failed` to action nodes that undo the completed work, each sending one compensating command, or to an approval for a person to decide.
90
+ - A failure nothing handles fails the run when it happens in the root branch. Inside a ForEach branch it only ends that branch; the join counts it as a branch that did not succeed and leaves through `partial` when its mode is then not satisfied.
91
+ - An expired signal wait or approval leaves through `expired`. Treat it as a business outcome with its own path, not as an error.
92
+
93
+ ## Anti-patterns
94
+
95
+ - Blocking, sleeping or keeping an in-memory timer in a reactor or a performer to wait for a deadline. Use a wait node.
96
+ - Modelling a wait as a job step that blocks.
97
+ - A performer that does several unrelated things. One capability, one effect, so a retry repeats only that effect.
98
+ - A deduplication key that differs between deliveries of the same trigger. Every redelivery then starts a new run.
99
+ - A performer whose effect is not safe to repeat.
100
+ - Leaving `expired` or `failed` unconnected where the business has an answer for that case.
101
+ - Reading the run listing to decide what a run does next. It can lag; the run's snapshot is authoritative.
102
+ - A performer that runs whatever a node's configuration names. Definitions are data; whoever can edit one could then run anything.
103
+
104
+ ## Verify
105
+
106
+ 1. Start a run on an in-memory host and poll its snapshot under a deadline until it reaches the expected status. Never sleep a fixed time.
107
+ 2. Send the same trigger twice: one run, and each effect happens once.
108
+ 3. Make a performer report a failure: once its attempts are used up the run takes the `failed` path you connected, or ends failed with the nodes behind it unreachable.
109
+ 4. Let a signal wait or approval expire with a short expiry: the run takes the `expired` path. Let a timer wait run out: the run takes the `elapsed` path.
110
+ 5. Against durable storage: start a run, restart the host while it waits, deliver the awaited signal or approval, and confirm one completed run and one external effect.
111
+
112
+ ## Reference index
113
+
114
+ | Reference | Read when |
115
+ | --- | --- |
116
+ | `references/csharp.md` | Writing the graph, performers and definition source, hosting the engine, starting and following a run, resolving an approval, or testing a workflow |
117
+ | `references/csharp-chronicle.md` | Keeping the journal in Chronicle, starting a run from an event, a schedule or a state machine, resuming with a signal, or reading the run listing |