@cratis/pi 8.4.1 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/package/corpus/harnesses/copilot/instructions/ai-distribution.instructions.md +2 -1
  2. package/package/corpus/harnesses/copilot/instructions/exit-codes-and-wrappers.instructions.md +1 -1
  3. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +5 -3
  4. package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -1
  5. package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -1
  6. package/package/corpus/harnesses/copilot/instructions/scripting.instructions.md +2 -1
  7. package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +6 -3
  8. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
  9. package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +131 -9
  10. package/package/corpus/rules/ai-distribution.md +2 -1
  11. package/package/corpus/rules/exit-codes-and-wrappers.md +1 -1
  12. package/package/corpus/rules/glossary.md +5 -3
  13. package/package/corpus/rules/react.md +3 -1
  14. package/package/corpus/rules/reactors.md +3 -1
  15. package/package/corpus/rules/scripting.md +2 -1
  16. package/package/corpus/rules/specs.csharp.md +6 -3
  17. package/package/corpus/rules/vertical-slices.md +5 -2
  18. package/package/corpus/skills/cratis-application-growth/SKILL.md +1 -2
  19. package/package/corpus/skills/cratis-application-growth/references/csharp.md +1 -3
  20. package/package/corpus/skills/cratis-application-growth/references/move-and-untangle.md +1 -2
  21. package/package/corpus/skills/cratis-application-growth/references/rename-window.md +1 -3
  22. package/package/corpus/skills/cratis-application-growth/references/service-and-delivery.md +3 -2
  23. package/package/corpus/skills/cratis-application-growth/references/stages.md +2 -2
  24. package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +3 -3
  25. package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +47 -3
  26. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +18 -3
  27. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
  28. package/package/corpus/skills/cratis-arc-authorize-request/references/typescript.md +2 -0
  29. package/package/corpus/skills/cratis-arc-connect-storage/references/csharp.md +1 -0
  30. package/package/corpus/skills/cratis-arc-connect-storage/references/elixir.md +9 -2
  31. package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
  32. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +47 -8
  33. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-controller.md +3 -1
  34. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +6 -3
  35. package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +38 -11
  36. package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
  37. package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-abilities.md +2 -2
  38. package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-recovery.md +6 -4
  39. package/package/corpus/skills/cratis-arc-declare-operation/references/csharp.md +2 -2
  40. package/package/corpus/skills/cratis-arc-diagnose-live-query/SKILL.md +1 -1
  41. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +29 -7
  42. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/java.md +1 -1
  43. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/kotlin.md +1 -1
  44. package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp-diagnose-tool-call.md +9 -7
  45. package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +52 -1
  46. package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +4 -2
  47. package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +36 -10
  48. package/package/corpus/skills/cratis-arc-expose-query/references/go.md +2 -2
  49. package/package/corpus/skills/cratis-arc-expose-query/references/typescript.md +6 -3
  50. package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
  51. package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +55 -6
  52. package/package/corpus/skills/cratis-arc-generate-proxies/references/typescript.md +9 -0
  53. package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
  54. package/package/corpus/skills/cratis-arc-host-application/references/csharp-configuration.md +54 -0
  55. package/package/corpus/skills/cratis-arc-host-application/references/csharp-deployment.md +98 -0
  56. package/package/corpus/skills/cratis-arc-host-application/references/csharp-http.md +9 -1
  57. package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +87 -4
  58. package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +9 -0
  59. package/package/corpus/skills/cratis-arc-invoke-command/references/csharp-extensions.md +4 -0
  60. package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
  61. package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +19 -2
  62. package/package/corpus/skills/cratis-arc-isolate-tenant/references/csharp.md +4 -2
  63. package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
  64. package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +33 -36
  65. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +18 -3
  66. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +94 -19
  67. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +29 -5
  68. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-instant-feedback.md +81 -0
  69. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +80 -0
  70. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-navigation.md +103 -0
  71. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +41 -2
  72. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-structure.md +117 -0
  73. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +8 -4
  74. package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +3 -3
  75. package/package/corpus/skills/cratis-arc-react-separate-view-model/references/typescript.md +27 -6
  76. package/package/corpus/skills/cratis-arc-testing-typescript/references/typescript.md +2 -2
  77. package/package/corpus/skills/cratis-arc-validate-command/references/csharp-rules.md +23 -2
  78. package/package/corpus/skills/cratis-arc-validate-command/references/csharp.md +28 -2
  79. package/package/corpus/skills/cratis-arc-validation-typescript/SKILL.md +1 -0
  80. package/package/corpus/skills/cratis-authproxy-configure/SKILL.md +136 -0
  81. package/package/corpus/skills/cratis-authproxy-configure/references/admission.md +125 -0
  82. package/package/corpus/skills/cratis-authproxy-configure/references/aspire.md +154 -0
  83. package/package/corpus/skills/cratis-authproxy-configure/references/operations.md +122 -0
  84. package/package/corpus/skills/cratis-authproxy-configure/references/services-and-routing.md +114 -0
  85. package/package/corpus/skills/cratis-authproxy-configure/references/sessions-and-logout.md +126 -0
  86. package/package/corpus/skills/cratis-authproxy-configure/references/sign-in-providers.md +116 -0
  87. package/package/corpus/skills/cratis-authproxy-configure/references/tenant-resolution.md +135 -0
  88. package/package/corpus/skills/cratis-choreography-run-workflow/SKILL.md +117 -0
  89. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp-chronicle.md +164 -0
  90. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp.md +354 -0
  91. package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +6 -6
  92. package/package/corpus/skills/cratis-chronicle-cli-operations/references/inspection.md +11 -3
  93. package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +50 -0
  94. package/package/corpus/skills/cratis-chronicle-cli-operations/references/recovery-and-comparison.md +17 -3
  95. package/package/corpus/skills/cratis-chronicle-cli-operations/references/setup-and-target.md +8 -2
  96. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp-services.md +13 -2
  97. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp.md +12 -0
  98. package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin.md +2 -0
  99. package/package/corpus/skills/cratis-chronicle-connect-application/references/python.md +2 -2
  100. package/package/corpus/skills/cratis-chronicle-connect-application/references/typescript.md +10 -1
  101. package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +9 -2
  102. package/package/corpus/skills/cratis-chronicle-constrain-append/references/csharp.md +35 -3
  103. package/package/corpus/skills/cratis-chronicle-constrain-append/references/go.md +1 -1
  104. package/package/corpus/skills/cratis-chronicle-constrain-append/references/operations.md +70 -0
  105. package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +6 -3
  106. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +113 -16
  107. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/container-and-kubernetes.md +293 -0
  108. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +16 -9
  109. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +60 -7
  110. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +124 -2
  111. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +36 -1
  112. package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
  113. package/package/corpus/skills/cratis-chronicle-evolve-event/references/csharp.md +2 -2
  114. package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +15 -5
  115. package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +9 -8
  116. package/package/corpus/skills/cratis-chronicle-inspect-observer/references/go.md +2 -2
  117. package/package/corpus/skills/cratis-chronicle-mcp-inspection/SKILL.md +1 -1
  118. package/package/corpus/skills/cratis-chronicle-mcp-inspection/references/deployment.md +1 -1
  119. package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +2 -2
  120. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +15 -4
  121. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +4 -1
  122. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +5 -2
  123. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp.md +23 -0
  124. package/package/corpus/skills/cratis-chronicle-project-view/references/elixir.md +1 -0
  125. package/package/corpus/skills/cratis-chronicle-project-view/references/go.md +2 -1
  126. package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +3 -1
  127. package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +4 -3
  128. package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +3 -1
  129. package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +3 -1
  130. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +41 -4
  131. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +22 -4
  132. package/package/corpus/skills/cratis-chronicle-protect-decision/references/elixir.md +7 -0
  133. package/package/corpus/skills/cratis-chronicle-protect-decision/references/go.md +9 -1
  134. package/package/corpus/skills/cratis-chronicle-protect-decision/references/java.md +8 -0
  135. package/package/corpus/skills/cratis-chronicle-protect-decision/references/kotlin.md +9 -0
  136. package/package/corpus/skills/cratis-chronicle-protect-decision/references/typescript.md +7 -0
  137. package/package/corpus/skills/cratis-chronicle-protect-personal-data/SKILL.md +1 -1
  138. package/package/corpus/skills/cratis-chronicle-protect-personal-data/references/csharp.md +28 -3
  139. package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +7 -6
  140. package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
  141. package/package/corpus/skills/cratis-chronicle-publish-contract/references/elixir-integrations.md +3 -3
  142. package/package/corpus/skills/cratis-chronicle-publish-contract/references/webhook-signature-wire-format.md +82 -0
  143. package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +19 -1
  144. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-outputs.md +3 -1
  145. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-pages.md +1 -1
  146. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +37 -4
  147. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/elixir.md +11 -0
  148. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +2 -1
  149. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
  150. package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +3 -3
  151. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-coordination.md +31 -2
  152. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-history.md +21 -4
  153. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp.md +20 -2
  154. package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +1 -1
  155. package/package/corpus/skills/cratis-chronicle-record-event/references/java.md +1 -1
  156. package/package/corpus/skills/cratis-chronicle-record-event/references/kotlin.md +3 -0
  157. package/package/corpus/skills/cratis-chronicle-reduce-state/SKILL.md +2 -1
  158. package/package/corpus/skills/cratis-chronicle-reduce-state/references/csharp.md +3 -1
  159. package/package/corpus/skills/cratis-chronicle-reduce-state/references/java.md +10 -1
  160. package/package/corpus/skills/cratis-chronicle-reduce-state/references/kotlin.md +10 -1
  161. package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +27 -5
  162. package/package/corpus/skills/cratis-chronicle-select-client/SKILL.md +18 -0
  163. package/package/corpus/skills/cratis-chronicle-select-client/references/elixir.md +21 -1
  164. package/package/corpus/skills/cratis-chronicle-select-client/references/go.md +13 -0
  165. package/package/corpus/skills/cratis-chronicle-select-client/references/java.md +15 -0
  166. package/package/corpus/skills/cratis-chronicle-select-client/references/kotlin.md +15 -0
  167. package/package/corpus/skills/cratis-chronicle-select-client/references/typescript.md +16 -0
  168. package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +1 -1
  169. package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +4 -3
  170. package/package/corpus/skills/cratis-ci-pipeline-performance/references/publish-pipelines.md +19 -4
  171. package/package/corpus/skills/cratis-code-review/SKILL.md +6 -2
  172. package/package/corpus/skills/cratis-code-review/references/csharp-diagnostics.md +28 -2
  173. package/package/corpus/skills/cratis-code-review/references/csharp.md +4 -4
  174. package/package/corpus/skills/cratis-commits-and-pull-requests/SKILL.md +6 -38
  175. package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-description.md +2 -0
  176. package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-labels-and-release.md +5 -4
  177. package/package/corpus/skills/cratis-commits-and-pull-requests/references/workflow-inputs.md +39 -0
  178. package/package/corpus/skills/cratis-components-accessibility/SKILL.md +6 -8
  179. package/package/corpus/skills/cratis-components-accessibility/references/typescript.md +32 -14
  180. package/package/corpus/skills/cratis-components-build-canvas/SKILL.md +4 -3
  181. package/package/corpus/skills/cratis-components-build-canvas/references/typescript-props.md +1 -1
  182. package/package/corpus/skills/cratis-components-build-canvas/references/typescript.md +4 -2
  183. package/package/corpus/skills/cratis-components-choose-control/SKILL.md +13 -7
  184. package/package/corpus/skills/cratis-components-choose-control/references/from-primereact.md +116 -0
  185. package/package/corpus/skills/cratis-components-choose-control/references/menu.md +90 -0
  186. package/package/corpus/skills/cratis-components-choose-control/references/typescript-composition.md +48 -0
  187. package/package/corpus/skills/cratis-components-choose-control/references/typescript.md +2 -2
  188. package/package/corpus/skills/cratis-components-compose-toolbar/SKILL.md +2 -1
  189. package/package/corpus/skills/cratis-components-compose-toolbar/references/floating-toolbar.md +146 -0
  190. package/package/corpus/skills/cratis-components-diagnose-screen/SKILL.md +102 -0
  191. package/package/corpus/skills/cratis-components-display-list/SKILL.md +10 -10
  192. package/package/corpus/skills/cratis-components-display-list/references/typescript-custom-panel.md +74 -0
  193. package/package/corpus/skills/cratis-components-display-list/references/typescript-datatables.md +2 -7
  194. package/package/corpus/skills/cratis-components-display-list/references/typescript.md +3 -2
  195. package/package/corpus/skills/cratis-components-submit-form/SKILL.md +6 -6
  196. package/package/corpus/skills/cratis-components-submit-form/references/typescript-commanddialog.md +21 -1
  197. package/package/corpus/skills/cratis-components-submit-form/references/typescript-commandform.md +72 -2
  198. package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +7 -5
  199. package/package/corpus/skills/cratis-components-theme-application/SKILL.md +17 -15
  200. package/package/corpus/skills/cratis-components-theme-application/references/localization.md +166 -0
  201. package/package/corpus/skills/cratis-components-theme-application/references/typescript.md +18 -14
  202. package/package/corpus/skills/cratis-components-theme-application/references/upgrade-from-previous-major.md +141 -0
  203. package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +2 -0
  204. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-domain-philosophy.md +31 -3
  205. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-fundamentals-helpers.md +119 -0
  206. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp.md +4 -0
  207. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +72 -1
  208. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +9 -0
  209. package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +2 -1
  210. package/package/corpus/skills/cratis-fundamentals-concept/references/java-json.md +3 -2
  211. package/package/corpus/skills/cratis-fundamentals-concept/references/kotlin-json.md +3 -2
  212. package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +41 -2
  213. package/package/corpus/skills/cratis-fundamentals-name-value/SKILL.md +8 -7
  214. package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
  215. package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +3 -3
  216. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +8 -0
  217. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp.md +2 -2
  218. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/go-dependency-injection.md +3 -0
  219. package/package/corpus/skills/cratis-modeling-design-event-model/SKILL.md +6 -4
  220. package/package/corpus/skills/cratis-modeling-design-event-model/references/command-inventory.md +7 -1
  221. package/package/corpus/skills/cratis-modeling-design-event-model/references/model-first.md +13 -1
  222. package/package/corpus/skills/cratis-modeling-design-event-model/references/review-one-slice.md +6 -0
  223. package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +6 -6
  224. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/csharp-aspire.md +116 -28
  225. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/docker-compose.md +2 -2
  226. package/package/corpus/skills/cratis-observability/references/chronicle-kernel-export.md +46 -0
  227. package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +4 -2
  228. package/package/corpus/skills/cratis-platform-build-application/SKILL.md +8 -0
  229. package/package/corpus/skills/cratis-platform-build-application/references/cratis-identity.md +71 -0
  230. package/package/corpus/skills/cratis-platform-build-application/references/studio-repository.md +96 -0
  231. package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +14 -8
  232. package/package/corpus/skills/cratis-platform-deliver-slice/references/csharp.md +167 -3
  233. package/package/corpus/skills/cratis-platform-deliver-slice/references/eventual-consistency.md +150 -0
  234. package/package/corpus/skills/cratis-platform-deliver-slice/references/typescript.md +14 -1
  235. package/package/corpus/skills/cratis-platform-diagnose-slice/SKILL.md +1 -1
  236. package/package/corpus/skills/cratis-platform-prepare-release-pr/SKILL.md +8 -8
  237. package/package/corpus/skills/cratis-platform-prepare-release-pr/references/product-release-checks.md +16 -2
  238. package/package/corpus/skills/cratis-platform-start-application/SKILL.md +21 -0
  239. package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +77 -3
  240. package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +118 -0
  241. package/package/corpus/skills/cratis-platform-upgrade-application/references/csharp.md +117 -0
  242. package/package/corpus/skills/cratis-platform-upgrade-application/references/java.md +53 -0
  243. package/package/corpus/skills/cratis-platform-upgrade-application/references/kotlin.md +53 -0
  244. package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +71 -0
  245. package/package/corpus/skills/cratis-release-notes/SKILL.md +1 -1
  246. package/package/corpus/skills/cratis-release-notes/references/publish-repair.md +6 -3
  247. package/package/corpus/skills/cratis-screenplay-accept-model/references/csharp.md +34 -3
  248. package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +84 -3
  249. package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +7 -11
  250. package/package/corpus/skills/cratis-screenplay-declare-slice/references/commands.md +8 -4
  251. package/package/corpus/skills/cratis-screenplay-declare-slice/references/projections.md +2 -0
  252. package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +29 -1
  253. package/package/corpus/skills/cratis-screenplay-edit-workspace/SKILL.md +2 -1
  254. package/package/corpus/skills/cratis-screenplay-edit-workspace/references/mcp-tools.md +1 -1
  255. package/package/corpus/skills/cratis-screenplay-handoff-slice/references/csharp.md +13 -1
  256. package/package/corpus/skills/cratis-screenplay-model-translation/SKILL.md +1 -1
  257. package/package/corpus/skills/cratis-screenplay-model-translation/references/boundary-diagnostics.md +1 -1
  258. package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +30 -51
  259. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/cli.md +19 -2
  260. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/smallest-model.md +87 -0
  261. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/studio.md +5 -0
  262. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/typescript.md +13 -0
  263. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
  264. package/package/corpus/skills/cratis-screenplay-specify-outcome/SKILL.md +8 -12
  265. package/package/corpus/skills/cratis-screenplay-specify-outcome/references/running-mcp.md +12 -0
  266. package/package/corpus/skills/cratis-screenplay-specify-outcome/references/scenarios.md +2 -2
  267. package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +2 -0
  268. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-colocated.md +101 -0
  269. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +4 -2
  270. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-decision-reads.md +1 -0
  271. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +7 -0
  272. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +7 -4
  273. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +18 -5
  274. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-read-models.md +4 -2
  275. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +35 -2
  276. package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
  277. package/package/corpus/skills/cratis-specifications-exercise-backend/references/typescript.md +4 -2
  278. package/package/corpus/skills/cratis-specifications-isolate-behavior/SKILL.md +1 -1
  279. package/package/corpus/skills/cratis-specifications-isolate-behavior/references/csharp-running.md +10 -3
  280. package/package/corpus/skills/cratis-specifications-test-application-ui/references/typescript.md +22 -4
  281. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/SKILL.md +2 -1
  282. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/references/typescript.md +40 -0
  283. package/package/corpus/skills/cratis-stage-render-slice/SKILL.md +6 -0
  284. package/package/corpus/skills/cratis-stage-render-slice/references/semantic-conformance.md +64 -0
  285. package/package/profile-catalog.json +15 -0
  286. package/package.json +1 -1
@@ -5,6 +5,8 @@
5
5
  - Packages and compiler settings
6
6
  - Entry point
7
7
  - Provider order
8
+ - Development proxy
9
+ - Build and lint
8
10
  - Request configuration
9
11
  - Observable query transport
10
12
  - Startup globals
@@ -14,7 +16,7 @@ Names such as `App`, `fleet` and the header values are illustrative; use the app
14
16
 
15
17
  ## Packages and compiler settings
16
18
 
17
- Install `@cratis/arc`, `@cratis/arc.react`, `@cratis/fundamentals`, `reflect-metadata`, `react` and `react-dom`. Keep `@cratis/arc` and `@cratis/arc.react` on the same release so one runtime is shared.
19
+ Install `@cratis/arc`, `@cratis/arc.react`, `@cratis/fundamentals`, `reflect-metadata`, `react` and `react-dom`. Keep `@cratis/arc` and `@cratis/arc.react` on the same release so one runtime is shared. Declare every package a screen imports directly, such as an icon package, in the application's own dependencies.
18
20
 
19
21
  Generated proxies and models use decorators. In `tsconfig.json`:
20
22
 
@@ -27,6 +29,8 @@ Generated proxies and models use decorators. In `tsconfig.json`:
27
29
  }
28
30
  ```
29
31
 
32
+ In an application created from the Cratis template these options live in `.frontend/tsconfig.json`, which includes every `.ts` and `.tsx` file of the project, and the root `tsconfig.json` only extends it. Keep that file's `useDefineForClassFields: false`, bundler module resolution and `noEmit`.
33
+
30
34
  Vite's default transform does not emit decorator metadata. Add `@cratis/arc.vite` as a development dependency when classes rely on constructor injection or typed parameters (view models):
31
35
 
32
36
  ```ts
@@ -39,7 +43,9 @@ export default defineConfig({
39
43
  });
40
44
  ```
41
45
 
42
- The plugin processes `.ts` files; keep decorated classes out of `.tsx`, or pass `EmitMetadataPlugin({ fileRegEx: /\.tsx?$/ })`.
46
+ - The plugin processes `.ts` files; keep decorated classes out of `.tsx`, or pass `EmitMetadataPlugin({ fileRegEx: /\.tsx?$/ })`.
47
+ - It reads the compiler options from `tsconfig.json` in the folder the dev server or build is started from, and does not follow `extends`. When the options live in another file, pass `EmitMetadataPlugin({ tsconfigPath })` with that file's path.
48
+ - **Edge case:** `AddQueryStringToReferences('v=42')`, also from `@cratis/arc.vite`, appends that query string to the module paths of `import ... from` and `export ... from` statements in the built chunks, and to root-relative `url(/...)` references in the built CSS. It rewrites nothing else, such as dynamic imports or relative CSS URLs. Use it only for a host that cannot serve content-hashed file names.
43
49
 
44
50
  ## Entry point
45
51
 
@@ -64,31 +70,93 @@ createRoot(document.getElementById('root')!).render(
64
70
 
65
71
  ```tsx
66
72
  <Arc>
67
- <CratisComponentsProvider> {/* @cratis/components */}
68
- <MVVM> {/* @cratis/arc.react.mvvm */}
69
- <BrowserRouter> {/* react-router-dom */}
70
- <App />
71
- </BrowserRouter>
72
- </MVVM>
73
+ <CratisComponentsProvider toaster> {/* @cratis/components */}
74
+ <DialogComponents confirmation={ConfirmationDialog} busyIndicator={BusyIndicatorDialog}>
75
+ <MVVM> {/* @cratis/arc.react.mvvm */}
76
+ <BrowserRouter> {/* react-router-dom */}
77
+ <Routes>
78
+ <Route path="/vehicles" element={<Vehicles />} />
79
+ </Routes>
80
+ </BrowserRouter>
81
+ </MVVM>
82
+ </DialogComponents>
73
83
  </CratisComponentsProvider>
74
84
  </Arc>
75
85
  ```
76
86
 
87
+ - **Where it lives.** The entry module renders `<Arc>` and the Components provider around `<App />`; `App.tsx` renders the rest, with one route per feature composition page (see [Routes, layout and menu](typescript-navigation.md)).
88
+ - **`DialogComponents`** (`@cratis/arc.react/dialogs`) supplies the confirmation and busy-indicator dialogs that `useConfirmationDialog()` and `useBusyIndicator()` open; `ConfirmationDialog` and `BusyIndicatorDialog` come from `@cratis/components/Dialogs`. Without it a confirmation resolves as cancelled at once and nothing is shown. See `cratis-components-coordinate-feedback`.
89
+ - **Components provider and the router.** The provider sits directly inside `<Arc>` and outside the router, as shown. The one exception: when you pass it `value.router` so that Components links navigate client-side, render it inside the router, because that value is built from router hooks. See `cratis-components-theme-application`.
90
+ - For a multilingual application, `ArcComponentsProvider` takes the place of `CratisComponentsProvider`; see [UI language](typescript-localization.md).
91
+
92
+ ## Development proxy
93
+
94
+ The browser talks to the Vite dev server, so every backend path it calls needs a proxy entry. Arc needs two: `/.cratis` (identity and the live-query hub) and `/api` (generated command and query routes).
95
+
96
+ ```ts
97
+ export default defineConfig({
98
+ server: {
99
+ proxy: {
100
+ '/.cratis': { target: 'http://localhost:5000', ws: true },
101
+ '/api': { target: 'http://localhost:5000', ws: true }
102
+ }
103
+ }
104
+ });
105
+ ```
106
+
107
+ - The target is the backend's own address; change it when the backend port changes.
108
+ - `ws: true` forwards WebSocket upgrades. Set it on every path that can carry a live query.
109
+ - Proxying only `/api` breaks the identity request and every live query through the hub.
110
+ - Add an entry for every other backend path the browser calls, such as an API description page.
111
+
112
+ ## Build and lint
113
+
114
+ - **Build.** The template's `build` script type-checks the whole frontend before it bundles. It is the check that catches a renamed or removed backend property after proxies are regenerated: run it after every backend contract change. The bundle goes to the folder the backend serves as static files; that folder is build output, never edited by hand.
115
+ - **Lint.** One flat configuration at the project root:
116
+
117
+ ```js
118
+ import cratis from '@cratis/eslint-config';
119
+ import arc from '@cratis/eslint-plugin-arc';
120
+ import components from '@cratis/eslint-plugin-components';
121
+
122
+ export default [
123
+ { ignores: ['.cratis/**'] },
124
+ ...cratis.configs.consumer,
125
+ ...arc.configs.recommended,
126
+ ...components.configs.recommended,
127
+ ];
128
+ ```
129
+
130
+ The Arc configuration skips generated proxies, recognizing them by their content, so proxies beside hand-written files need no path list. Never add a suppression to a generated file. For what the rules check, see `cratis-code-review`.
131
+
77
132
  ## Request configuration
78
133
 
79
134
  ```tsx
80
135
  <Arc
81
136
  microservice="fleet"
82
137
  apiBasePath="/portal"
83
- httpHeadersCallback={() => ({ 'Accept-Language': navigator.language })}>
138
+ httpHeadersCallback={accessTokenHeader}>
84
139
  <App />
85
140
  </Arc>
86
141
  ```
87
142
 
88
- - `microservice`: only when the backend consists of named services.
143
+ `accessTokenHeader` is an application function defined outside the component; the token source is illustrative:
144
+
145
+ ```ts
146
+ const accessTokenHeader = () => ({ Authorization: `Bearer ${session.accessToken}` });
147
+ ```
148
+
149
+ - `microservice`: only when the backend consists of named services. The value travels as the `x-cratis-microservice` header, and as a query argument of the same name on WebSocket URLs and on the shared server-sent-events stream. A direct server-sent-events stream carries neither.
89
150
  - `apiBasePath`: only when the deployment adds a prefix in front of the generated routes. Client-side routing has its own base in the router.
151
+ - **Served under a path prefix:** set `apiBasePath` for requests and the router's `basename` for routes, to the same prefix. The host's `basePath` configures nothing.
90
152
  - `origin`: only for a backend on a different origin.
91
- - `httpHeadersCallback`: called as each request is sent, so new credentials apply to the next request. Keep the function stable (define it outside the component or memoize it).
153
+ - `httpHeadersCallback`: for headers the application owns, such as a bearer token. Called as each request is sent, so new credentials apply to the next request. Keep the function stable (define it outside the component or memoize it). Never return `Accept-Language` from it: Arc sends the UI language itself from the host's `locale` (see [UI language](typescript-localization.md)).
154
+ - **Outside React**, `<Arc>` has written `microservice`, `apiBasePath`, `origin` and the callback to the process-wide `Globals`. An instance constructed with `new` uses the first three. Whether it sends the callback's headers depends on the request:
155
+ - **A command:** yes, on execution and validation.
156
+ - **A query's snapshot request** (`perform()`, on an observable query too): no.
157
+ - **An observable query's subscription:** yes on polling requests and on the hub's subscribe and unsubscribe calls, as in the table below.
158
+
159
+ No constructed instance gets the host's `locale` (see [UI language](typescript-localization.md)). To supply either, call `instance.setRequestDefaults({ httpHeadersCallback, locale })`. That call replaces the process-wide defaults for the instance, so pass the callback together with the locale; passing only one drops the other. For the same header, a callback set on one instance with `setHttpHeadersCallback` wins over those defaults.
92
160
 
93
161
  Which requests carry those headers depends on the observable transport:
94
162
 
@@ -103,7 +171,7 @@ So a live query behind header-based authentication needs cookie authentication,
103
171
 
104
172
  ## Observable query transport
105
173
 
106
- Server-sent events through a shared hub is the default and needs no configuration. Change it only for a reason:
174
+ Server-sent events through a shared hub is the default of `<Arc>` and needs no configuration. (Without `<Arc>`, the core default is WebSocket.) Change it only for a reason:
107
175
 
108
176
  ```tsx
109
177
  import { ObservableQueryTransferMode } from '@cratis/arc';
@@ -120,14 +188,14 @@ import { QueryTransportMethod } from '@cratis/arc/queries';
120
188
 
121
189
  | Prop | Choose a non-default value when |
122
190
  | --- | --- |
123
- | `queryTransportMethod` | `WebSocket` when the infrastructure handles it better than server-sent events; `Polling` when something cuts long-lived connections or the backend should scale to zero. Polling updates lag by the interval. |
191
+ | `queryTransportMethod` | `WebSocket` when the infrastructure handles it better than server-sent events, or when the backend runs several instances and the load balancer does not keep a browser on one instance: with server-sent events the subscribe requests are separate calls that must reach the instance holding the stream, while WebSocket sends them on the stream's own connection. `Polling` when something cuts long-lived connections or the backend should scale to zero. Polling updates lag by the interval. |
124
192
  | `queryConnectionCount` | Many concurrent live queries saturate one hub connection (server-sent events cap at four). |
125
193
  | `queryDirectMode` | Each query must use its own endpoint instead of the hub: a direct server-sent-events stream with the default transport, a direct WebSocket with `WebSocket`. Polling is always per query. |
126
194
  | `observableQueryTransferMode` | A consumer needs whole collections on every update (for example suspending observable collections). |
127
195
  | `queryCacheRetentionMs` | Cached data must be dropped immediately on unmount (`0`) or kept longer than the default. |
128
196
  | `eventSourceFactory` | The runtime has no global server-sent-events client, or the stream needs credentials the default client cannot send. |
129
197
 
130
- A development proxy must forward the hub endpoints as well as the API routes, including upgrade and streaming support.
198
+ A development proxy must forward the hub endpoints as well as the API routes, including upgrade and streaming support; see Development proxy.
131
199
 
132
200
  ## Startup globals
133
201
 
@@ -143,8 +211,8 @@ Globals.queryHttpMethod = QueryHttpMethod.Query;
143
211
  Globals.queryHttpMethodResolver = lengthBasedQueryHttpMethod({ threshold: 1500 });
144
212
  ```
145
213
 
146
- - **Polling timing** (`queryPollingOptions`): `intervalMs`, `minIntervalMs`, `maxIntervalMs`, `backoffMultiplier`, `jitterRatio`. An observable query instance used outside the hooks overrides them with `setPollingOptions({ intervalMs })` before it subscribes.
147
- - **Snapshot-query HTTP method**: a method the generator emitted on the proxy wins, then `queryHttpMethodResolver`, then `queryHttpMethod` (`Get` unless set). `Query` keeps arguments out of URLs and never falls back. `Auto` tries QUERY and retries as GET when the server refuses it, so use it only when arguments are safe in a URL. `lengthBasedQueryHttpMethod` switches above a URL length (2000 characters unless `threshold` is given) to `whenLong` (`Auto` unless given). `resetQueryHttpMethodResolution()` forgets what `Auto` learned, after a network change or between tests.
214
+ - **Polling timing** (`queryPollingOptions`), with defaults: `intervalMs` 5000, `minIntervalMs` 1000, `maxIntervalMs` 60000, `backoffMultiplier` 2, `jitterRatio` 0.2. An observable query instance used outside the hooks overrides them with `setPollingOptions({ intervalMs })` before it subscribes.
215
+ - **Snapshot-query HTTP method**: a method the generator emitted on the proxy wins, then `queryHttpMethodResolver`, then `queryHttpMethod` (`Get` unless set). `Query` sends arguments, paging and sorting in the request body and never falls back; an argument bound to a route parameter is still part of the URL path, so keep sensitive values out of the route. `Auto` tries QUERY and retries as GET when the server refuses the method or the request fails with a network or CORS error, and then stays on GET for that backend, so use it only when arguments are safe in a URL. `lengthBasedQueryHttpMethod` switches above a URL length (2000 characters unless `threshold` is given) to `whenLong` (`Auto` unless given). `resetQueryHttpMethodResolution()` forgets what `Auto` learned, after a network change or between tests.
148
216
 
149
217
  ## Slice and application context
150
218
 
@@ -153,8 +221,15 @@ import { useSliceContext } from '@cratis/arc.react/slices';
153
221
  import { useApplicationContext } from '@cratis/arc.react/applicationContext';
154
222
  ```
155
223
 
156
- `useSliceContext()` tells a component which module, feature and slice it renders in. `useApplicationContext()` lets shared chrome (a feedback button, a help link) read what the user is currently viewing. Set `sliceMarkers` on `<Arc>` to also expose slice boundaries as DOM attributes for tooling.
224
+ `useSliceContext()` tells a component which module, feature and slice it renders in. `useApplicationContext()` lets shared chrome (a feedback button, a help link) read what the user is currently viewing.
157
225
 
158
- - **Explicit slice scope**, when proxies carry no slice location (see Generated metadata) or a hand-written component needs one: `<Slice module="Fleet" feature="Vehicles" slice="Registration">`, or `withSliceLocation(Component, location)`. `useRegisterSliceLocation(location)` registers a location from a custom hook.
159
- - **Folder-derived slice scope**: `SliceLocationPlugin()` from `@cratis/arc.vite/slices` wraps exported `.tsx` and `.jsx` components in slice folders at build time. Map folders with `roots` or `segmentsToSkip`; leave shared folders out with `exclude`.
226
+ - **Explicit slice scope**, when proxies carry no slice location (see Generated metadata) or a hand-written component needs one: `<Slice module="Fleet" feature="Vehicles" slice="Registration">` gives that location to everything inside it; the nearest explicit `<Slice>` wins. `withSliceLocation(Component, location)` gives a component a folder scope instead: the common location of the command and query hooks registered directly in that scope (with no nearer scope of their own) refines it only when it lies on or below the folder path, and any enclosing explicit `<Slice>` overrides it. Descendants can have their own scopes. `useRegisterSliceLocation(location)` registers a location from a custom hook.
227
+ - **Folder-derived slice scope**: `SliceLocationPlugin()` from `@cratis/arc.vite/slices` wraps exported components in slice folders at build time (in `.tsx` and `.jsx` files unless `include` is set; never in `node_modules`), as `withSliceLocation(Component, new SliceLocation(...))`. For example `SliceLocationPlugin({ roots: ['Features'], exclude: /[\\/]Shared[\\/]/ })`: `roots` lists folders whose subfolders are module, feature and slice, and `segmentsToSkip` maps files under no root. `include` and `exclude` are each one `RegExp` tested against the file path, not a glob or an array.
228
+ - It wraps only a component declared in the same file and exported as default or under a name that starts with an uppercase letter. A component here is a function, not async or a generator, whose every return is JSX, a `React.createElement(...)` call, `null` or `undefined` (at least one element), or a call such as `memo(...)`, `forwardRef(...)` or `withViewModel(...)` given one. Imported components exported again (`export default Imported`, `export { Screen } from './Screen'`), lowercase named exports, classes and unexported components are left alone; wrap such a screen in `<Slice>`.
229
+ - A wrapped `export function` becomes a constant and is no longer hoisted: top-level code in the same module that uses it before its declaration throws. Use it after the declaration or from another module.
230
+ - A folder scope follows the rendered tree, so a shared component in a mapped folder (such as a panel that renders `children`) gives its folder location to children with no nearer scope of their own, unless an explicit `<Slice>` encloses it. Match shared folders with `exclude`, or keep them outside the whole mapping: with `segmentsToSkip` set, a file under no root is still wrapped when it lies inside the Vite project root and at least one folder segment remains after skipping.
160
231
  - **Store access**: `useApplicationContextStore()` returns the store `<Arc>` provides (undefined outside it), for code that subscribes to it directly. `useRegisterScope(scope)` registers a hand-built slice scope in the current page or dialog layer; `Slice` and `withSliceLocation` already do this.
232
+ - **Snapshot**: `useApplicationContext()` returns `location` (the `SliceLocation` of the user's focus: the page, or the top-most tracked dialog), `activeSlices`, `screen` (`{ id, name, path }`), `dialogs` (tracked dialogs, bottom first, each `{ id, title?, location }`) and `contributions`. Opening a tracked dialog moves `location` to it; closing it restores the dialog below or the page. `useSliceContext()` gives the calling component's own location, not the user's focus.
233
+ - **Screen and values**: Arc does not track routes, so `screen` stays empty strings until something contributes it. Contribute it from the router for each route with `<ApplicationContextContributor screen={{ id: 'vehicles', name: 'Vehicles', path: '/vehicles' }} values={...}>` or `useContributeApplicationContext({ screen: { ... }, values: { ... } })`. A contribution is removed on unmount; later contributions win for each screen field and value key.
234
+ - **Outside React**: create `new ApplicationContext()` from `@cratis/arc.react/applicationContext`, pass it as `<Arc applicationContext={...}>`, and read it with `subscribe(listener)` (returns an unsubscribe function) and `getSnapshot()`. Without the prop, `<Arc>` creates its own store.
235
+ - **DOM markers**: `<Arc sliceMarkers>` is off by default. When on, `<Slice>`, `withSliceLocation`, folder-derived slice scopes and `useDialog` content render a `display: contents` element carrying `data-cratis-module`, `data-cratis-feature` and `data-cratis-slice`; unknown parts are empty strings. The root scope and scopes registered with `useRegisterScope` get no element; wrap those in `<SliceMarker scope={...}>` yourself. Tooling resolves an element with `element.closest('[data-cratis-module]')` and reads those three attributes; no marked ancestor means no location. Content a renderer portals elsewhere is outside that element: either spread `sliceMarkerAttributes(useDialogSliceLocation())` on the portal container, or read `const scope = useContext(SliceScopeContext)` (`SliceScopeContext` from `@cratis/arc.react/slices`; its value may be `undefined`) and, when `scope` is set, wrap the portal content in `<SliceMarker scope={scope}>` (from `@cratis/arc.react/applicationContext`). In an untracked dialog (`trackInApplicationContext: false`), `useDialogSliceLocation()` is empty, so only the first option carries no location; `SliceMarker` still marks the dialog's scope.
@@ -6,6 +6,8 @@
6
6
  - Typed identity details
7
7
  - Gate by role
8
8
  - Sign-in, sign-out and account switch
9
+ - Behind Cratis AuthProxy
10
+ - Outside React
9
11
  - Availability
10
12
 
11
13
  Role names, detail properties and proxies are illustrative. Client-side checks only hide what the server would refuse; the server authorizes every query and command.
@@ -18,12 +20,12 @@ import { useIdentity } from '@cratis/arc.react/identity';
18
20
  export function UserBadge() {
19
21
  const identity = useIdentity();
20
22
  if (identity.isLoading) return <span>…</span>;
21
- if (!identity.isSet) return <a href="/login">Sign in</a>;
23
+ if (!identity.isSet) return <span>Not signed in</span>;
22
24
  return <span>{identity.name}{identity.isInRole('Planner') && ' (planner)'}</span>;
23
25
  }
24
26
  ```
25
27
 
26
- The identity exposes `id`, `name`, `roles`, `details`, `isSet`, `isLoading`, `isInRole(role)`, `refresh()` and `clearIdentity()`. Keep the loading branch: deciding access from a not-yet-loaded identity flashes the wrong UI.
28
+ The identity exposes `id`, `name`, `roles`, `details`, `isSet`, `isLoading`, `isInRole(role)`, `refresh()` and `clearIdentity()`. Keep the loading branch: deciding access from a not-yet-loaded identity flashes the wrong UI. What the not-signed-in branch offers depends on what signs the user in: the application's own sign-in screen, or nothing at all behind Cratis AuthProxy (below).
27
29
 
28
30
  ## Typed identity details
29
31
 
@@ -86,9 +88,31 @@ const afterSignOut = () => { // the session is already ended
86
88
  1. Change the credentials first: complete sign-in, end the session, or install the new token where `httpHeadersCallback` reads it.
87
89
  2. Update the identity: `refresh()` after a sign-in or a backend change to roles or details (`isLoading` is true until it completes); `clearIdentity()` after a sign-out. `clearIdentity()` only resets the local identity to anonymous; it neither ends the session nor touches queries.
88
90
  3. Call `reconnectQueries()` before caller-scoped data renders. It drops every cached result, closes the shared live connections and re-runs mounted queries with the current credentials. It does not keep cached results.
89
- 4. Neither step resets application state: component state, view models, drafts and command values stay. For an account switch, or when that state may hold the previous caller's data, a full page load is the conservative default; it also suits a sign-out that redirects to a sign-in page.
91
+ 4. Arc resets no state in components that stay mounted: view models, drafts and command values stay. Two things do discard state: `RequireRole` replaces its children, unmounting them and their local state, with `whileLoading` while `refresh()` runs and with `forbidden` after `clearIdentity()`; and `refresh()` can reload the page (below). For an account switch, or when state may hold the previous caller's data, a full page load is the conservative default; it also suits a sign-out that redirects to a sign-in page.
90
92
 
91
- If `refresh()` finds that a signed-in session has ended, the provider reloads the page itself so the host can redirect to sign-in.
93
+ While `refresh()` runs, the current identity stays in place and `isLoading` is true. Then:
94
+
95
+ - **Resolved:** the result, set or unset, replaces the identity and every `useIdentity` consumer re-renders. A 401, 403, 500 or other unsuccessful answer resolves to an unset identity. A 404 (no identity endpoint) falls back to a readable legacy identity cookie, so it can still resolve to a set identity.
96
+ - **Reloaded:** when the result is unset and the identity whose `refresh` you called was set, the provider also reloads the page so the host can redirect to sign-in. The promise still resolves, with the unset identity. Call `refresh()` on the current `useIdentity()` value.
97
+ - **Rejected:** a network error, or a response that could not be read even though the request succeeded: no reload, the provider's current identity stays, `isLoading` returns to false and the promise rejects. Catch it and decide what to show.
98
+
99
+ ## Behind Cratis AuthProxy
100
+
101
+ When Cratis AuthProxy fronts the application (`cratis-authproxy-configure`), the proxy owns sign-in, sign-out and tenant selection; the application has no login route and no login screen.
102
+
103
+ - **Sign-in.** An unset identity is not proof that the proxy refused the caller: any unsuccessful identity request resolves to unset as well (see Resolved above). Show the not-signed-in element and let the proxy decide on the next page navigation. A page navigation to a protected path starts sign-in; a background request such as `fetch` is refused with a status code instead and never shows a sign-in page. Never link to an application `/login`.
104
+ - **Sign-out.** Navigate the whole page: `window.location.href = '/.cratis/logout'`. The proxy ends the session and returns the browser to the application root. Never call the endpoint with `fetch`, and no `clearIdentity()` or `reconnectQueries()` is needed, because the page is replaced. To land elsewhere, add `?redirect=` with either a path on the same site (starting with a single `/`) or an absolute `http` or `https` URL whose origin the proxy allows (the site the user is on always is). A missing or disallowed target falls back to the root.
105
+ - **Tenant switcher.** Offer one only when the `.cratis-tenants` cookie lists more than one tenant. Its value is a URL-encoded JSON array of `{ id, name }`; a user with a single tenant has no such cookie. Switch with a page navigation to `/.cratis/select-tenant?tenantId=<id>&returnUrl=<current path>`.
106
+
107
+ ## Outside React
108
+
109
+ `IdentityProvider` from `@cratis/arc/identity` serves code with no component, such as a route guard or a startup module:
110
+
111
+ - `await IdentityProvider.getCurrent(StaffDetails)` returns the identity. A set identity is kept in memory and returned without another request. An unset identity or a failed request is not kept, so the next call asks the server again. The details class is optional.
112
+ - `await IdentityProvider.refresh(StaffDetails)` asks the server again.
113
+ - `IdentityProvider.clearCache()` forgets the cached identity after a sign-out. `clearIdentityCookie()` is deprecated and does the same; use `clearCache()`.
114
+
115
+ Inside a component, use `useIdentity()`.
92
116
 
93
117
  ## Availability
94
118
 
@@ -126,6 +150,6 @@ export const Navigation = () => {
126
150
  - Without the provider, everything is available. With it, nothing is reported available until the first decision arrives.
127
151
  - `useIsAvailable` returns `isAvailable`, `isKnown`, `isNotAvailable`, `isSuspended` and `reason`. Treat `!isKnown` as pending, not as available. Pass the same argument values the execution will use.
128
152
  - `suspended` means an operator paused the part; it lifts without a reload. Report it differently from "not offered" and from "not permitted". On a screen, show it through `RequireAvailable`'s `suspended` slot, which falls back to `unavailable` when omitted.
129
- - `RequireAvailable` takes `args` for a part whose availability depends on argument values. `useAvailability()` returns the provider's context for custom checks.
153
+ - `RequireAvailable` takes `args` for a part whose availability depends on argument values. `useAvailability()` returns the decision object for custom checks, with `isAvailable(part)`, `availabilityOf(part)` and `filter(items, partOf)`.
130
154
  - `useAvailableItems` is the default for navigation and menus. It keeps entries without a part (return `undefined` from the selector) and drops entries whose part is not available, suspended or not yet known, so a gated link never flashes. Declare the entries and the selector outside the component, or memoize them; inline values recompute the filtered list on every render.
131
155
  - A command result reports the same refusals as `isNotAvailable` and `isSuspended`.
@@ -0,0 +1,81 @@
1
+ # Showing a change before the read model has it (edge case)
2
+
3
+ ## Contents
4
+
5
+ - When this applies
6
+ - Created items
7
+ - Removed items
8
+ - Rules
9
+ - Avoid
10
+
11
+ The default is to show nothing extra: the command succeeds, the read model catches up and the observable query pushes the change (see `cratis-platform-deliver-slice`, `references/eventual-consistency.md`). This reference is the exception to "never insert the new row by hand", for the few gestures where that wait is visible. `AllNotes` (observable query), `AddNote` (command), `Note` and their properties are illustrative.
12
+
13
+ ## When this applies
14
+
15
+ Only when a gesture must show its result in the same frame: dropping a dragged item, pasting, drawing or moving things on a canvas. A dialog that creates a record does not qualify: it closes on success and the list updates on its own.
16
+
17
+ ## Created items
18
+
19
+ Keep the items the user just created in a separate local list, and render the query's items plus the local ones the query does not contain yet.
20
+
21
+ ```tsx
22
+ const [notes] = AllNotes.use();
23
+ const [justAdded, setJustAdded] = useState<Note[]>([]);
24
+
25
+ const shown = useMemo(() => {
26
+ const known = new Set(notes.data.map(note => note.id.toString()));
27
+ return [...notes.data, ...justAdded.filter(note => !known.has(note.id.toString()))];
28
+ }, [notes.data, justAdded]);
29
+
30
+ useEffect(() => {
31
+ const known = new Set(notes.data.map(note => note.id.toString()));
32
+ setJustAdded(previous => previous.some(note => known.has(note.id.toString()))
33
+ ? previous.filter(note => !known.has(note.id.toString()))
34
+ : previous);
35
+ }, [notes.data]);
36
+
37
+ const forget = (id: Guid) =>
38
+ setJustAdded(previous => previous.filter(note => note.id.toString() !== id.toString()));
39
+
40
+ const add = async (text: string) => {
41
+ const id = Guid.create();
42
+ setJustAdded(previous => [...previous, { id, text }]);
43
+
44
+ const command = new AddNote(); // one instance per gesture: gestures can overlap
45
+ command.id = id;
46
+ command.text = text;
47
+ try {
48
+ const result = await command.execute();
49
+ if (!result.isSuccess) forget(id); // and tell the user why
50
+ } catch {
51
+ forget(id); // outcome unknown: the query shows the note if it was accepted
52
+ }
53
+ };
54
+ ```
55
+
56
+ - The command carries an identity made on the client (`Guid.create()` from `@cratis/fundamentals`), so the local item and the query's item can be matched.
57
+ - A local item leaves the list when the query contains it, and when the command is refused or fails. Classify the refusal as for any command (see [Commands](typescript-commands.md)).
58
+ - The command is constructed per gesture so that two quick gestures never share one instance's values; see Outside React in the same reference for what a constructed command does not get.
59
+
60
+ ## Removed items
61
+
62
+ Keep the identities the user just removed and filter them from what is shown. Only filter: the item stays in the query's result, so forgetting its identity brings it back.
63
+
64
+ - **Command refused or failed:** forget the identity, so the item comes back, and tell the user why. This holds for an item from the query and for one still in the local created list.
65
+ - **Command accepted:** keep filtering. A result that lacks the item is not proof that the removal was processed: the query can be loading, filtered, or on another page. Forget the identity only when the item was present in a ready, successful result of that query and is absent from a later one that would contain it (same arguments, not paged past it). When the screen cannot tell, keep the identity; it is dropped with the component.
66
+ - **Item still only in the local created list:** leave it in that list and filter it by identity like any other item; apply the filter to the local items as well as the query's. Deleting the local entry instead would leave nothing to show again when the removal is refused. Keep the identity filtered after the removal is accepted: the create can reach the read model after the user removed the item, and without the filter the item would reappear until the removal is processed too.
67
+
68
+ ## Rules
69
+
70
+ - The query stays the source of truth. The local lists only bridge the gap. Nothing guarantees they empty: a read model can stay behind indefinitely, so a local entry may live until the component unmounts. Never show a local created item as confirmed; mark it as pending when the difference matters.
71
+ - Never modify the query result or its array; build the shown list from it.
72
+ - Match by identity, compared as a string or other primitive.
73
+ - Do not guess the time the read model needs: there is no upper bound. Remove a local entry on evidence (the query has the created item, the item was seen and is now gone, or the command failed), never on a timer.
74
+
75
+ ## Avoid
76
+
77
+ - Using this for ordinary create dialogs, lists or forms.
78
+ - Replacing the query data with local state.
79
+ - Local entries with no rule that removes them.
80
+ - Treating an item's absence from one result as proof that it was removed.
81
+ - Showing server-computed values (totals, generated numbers, status) in the local item: show only what the user entered.
@@ -0,0 +1,80 @@
1
+ # UI language in Arc React
2
+
3
+ ## Contents
4
+
5
+ - Default path
6
+ - What Arc does with the language
7
+ - Validation text
8
+ - Outside React
9
+ - Avoid
10
+
11
+ This is the home for the client side of the UI language: the texts of the application's own screens and the language Arc sends to the backend. Texts and formats of Cratis Components controls follow it through `ArcComponentsProvider`; see `cratis-components-theme-application` (`references/localization.md`). The backend decides which cultures it honours; see Request localization in `cratis-arc-host-application`. Language tags, text keys and the storage key below are illustrative.
12
+
13
+ ## Default path
14
+
15
+ 1. **Define the texts** in one catalogue. The first pack is the fallback and defines the shape; every other pack provides the same keys and value kinds.
16
+ 2. **Create one locale store** at module level, outside every component.
17
+ 3. **Pass the store to the Arc host.** Providers that need the language go inside `<Arc>`.
18
+ 4. **Read texts** with `useTranslation(catalogue)` and **switch** with `useLocale()`.
19
+
20
+ ```tsx
21
+ import { createLocale, defineTranslations } from '@cratis/arc/localization';
22
+ import { Arc, useLocale, useTranslation } from '@cratis/arc.react';
23
+
24
+ const translations = defineTranslations('en', { name: 'Name' }, {
25
+ nb: { name: 'Navn' },
26
+ });
27
+ const locale = createLocale({ catalogue: translations, storageKey: 'ui-language' });
28
+
29
+ function Profile() {
30
+ const selection = useLocale();
31
+ const text = useTranslation(translations);
32
+ return (
33
+ <>
34
+ <select aria-label="Language" value={selection?.locale} onChange={event => selection?.setLocale(event.target.value)}>
35
+ <option value="en" lang="en">English</option>
36
+ <option value="nb" lang="nb">Norsk bokmål</option>
37
+ </select>
38
+ <label>{text.name}<input name="name" /></label>
39
+ </>
40
+ );
41
+ }
42
+
43
+ export const App = () => <Arc locale={locale}><Profile /></Arc>;
44
+ ```
45
+
46
+ - **Lookup:** a text is taken from the pack for the exact tag, then its parent (`nb-NO` → `nb`), then the fallback pack.
47
+ - **Supported languages** are the catalogue's packs unless `supported` lists them. Without a catalogue the store defaults to `en`.
48
+ - **Initial language:** a valid saved choice wins, then the browser language when `detectBrowserLanguage: true` is set (off by default), then `defaultLocale`.
49
+ - **`storageKey`** remembers the choice and follows a change made in another tab. Leave it out for a language that lasts only for the page.
50
+ - **`formatLocale`** follows the UI language; set it only to pin `Intl` formatting to another tag.
51
+ - **`useLocale()`** returns `locale`, `supported`, `formatLocale` and `setLocale(tag)`. `setLocale` accepts a supported tag. When the host has no `locale`, `useLocale()` returns `undefined` and `useTranslation` returns the fallback pack, so keep the optional chaining.
52
+ - `<Arc locale>` also accepts the options object directly. Keep the store or options reference stable across renders.
53
+
54
+ For a ready-made selector and Components controls in the same language, mount `ArcComponentsProvider` inside `<Arc locale={locale}>` instead of `CratisComponentsProvider`, as described in `cratis-components-theme-application`.
55
+
56
+ ## What Arc does with the language
57
+
58
+ - **Requests.** Commands, query requests, polling and the server-sent-events hub's subscribe and unsubscribe requests send the active language as `Accept-Language`. Do not add the header yourself.
59
+ - **Live streams.** A WebSocket or server-sent-events stream cannot carry the header. When the host has a locale, Arc puts one language tag in the stream URL instead: the value the `Accept-Language` header would have had, when that is a single valid tag. The backend uses it only when it has localization configured and supports that culture.
60
+ - **Switching.** A change refreshes query results and reopens live subscriptions. Nothing is remounted, so inputs and component state keep their values.
61
+ - **Document.** The localized host sets `<html lang>`. Use one localized `<Arc>` per page.
62
+
63
+ ## Validation text
64
+
65
+ - With a locale on the host, `CommandForm` shows Arc-owned failures (such as a missing required field) in English or Norwegian Bokmål. Messages authored in a rule pass through unchanged; without a locale the original messages are shown.
66
+ - To change the wording, supply `formatValidationResult` on the form or in `CommandFormDefaults`. Decide by `reason` and `reasonDetail`, never by message text. For your own display, `formatValidationResult(result, locale, { fieldTitle, fieldName })` from `@cratis/arc/localization` returns the platform text for those failures and the original message for every other.
67
+ - **Rule messages translated by the server** only reach the screen when the rule runs on the server. By default the generated proxy carries a copy of the rule, which rejects first with the wording from build time. Generate proxies with client validation set to `server` (see `cratis-arc-generate-proxies`); required-property and route checks still run in the browser.
68
+
69
+ ## Outside React
70
+
71
+ - A command or query instance used without the host: `instance.setRequestDefaults({ locale })`. The call replaces the process-wide defaults for that instance, so include `httpHeadersCallback` when the application has one.
72
+ - A browser application without React: set `Globals.locale = locale` (from `@cratis/arc`) once at startup.
73
+ - **Edge case: server rendering.** Create one store per request with the same default language on server and client. Never put a per-user store in `Globals` on a server.
74
+
75
+ ## Avoid
76
+
77
+ - Returning `Accept-Language` from `httpHeadersCallback`: an explicit header replaces the automatic one, and a live stream gets it only when it is a single valid language tag. A preference list (`nb, en;q=0.8`) is dropped, so the stream has no language.
78
+ - Creating the store or the options object inside a component.
79
+ - A second localized `<Arc>` on the same page: a document has one language.
80
+ - Matching on message text to translate a validation failure.
@@ -0,0 +1,103 @@
1
+ # Routes, layout and menu in an Arc React application
2
+
3
+ ## Contents
4
+
5
+ - Routes
6
+ - Layout route
7
+ - Menu
8
+ - Routes outside the shell
9
+ - Unknown URL
10
+ - Record screens
11
+ - Shell-wide values
12
+ - Avoid
13
+
14
+ Arc does not route; the application uses React Router (`react-router-dom`), mounted inside the Arc host as shown in Provider order in [Host setup](typescript-host.md). Paths, features and component names below are illustrative.
15
+
16
+ ## Routes
17
+
18
+ Declare the routes in `App.tsx`, one per feature composition page (see [Where frontend files go](typescript-structure.md)). A page reaches its dialogs and sub-screens itself; they get no route.
19
+
20
+ ## Layout route
21
+
22
+ A parent route without a path renders the shell (top bar, menu) and an `<Outlet />`; the feature routes are its children, so the shell is written once.
23
+
24
+ ```tsx
25
+ <Routes>
26
+ <Route element={<DefaultLayout menu={menu} />}>
27
+ <Route path="/" element={<Home />} />
28
+ <Route path="/vehicles" element={<Vehicles />} />
29
+ <Route path="*" element={<PageNotFound />} />
30
+ </Route>
31
+ <Route path="/signed-out" element={<SignedOut />} />
32
+ </Routes>
33
+ ```
34
+
35
+ Inside the layout, wrap the outlet in an error boundary so a page that fails to render leaves the shell and the menu on screen:
36
+
37
+ ```tsx
38
+ import { ErrorBoundary } from '@cratis/components/Common';
39
+ import { Outlet, useLocation } from 'react-router-dom';
40
+
41
+ const location = useLocation();
42
+
43
+ <main>
44
+ <ErrorBoundary key={location.pathname}>
45
+ <Outlet />
46
+ </ErrorBoundary>
47
+ </main>
48
+ ```
49
+
50
+ - **Key the boundary by the path.** A boundary that has caught an error keeps showing its fallback until it is reset. Without the key, choosing another menu entry would still show the fallback; with it, a new path mounts a fresh boundary.
51
+ - `ErrorBoundary` catches errors thrown while rendering, not errors in event handlers or asynchronous work. Expected command and query failures arrive as results, but a call can still reject, so keep a `catch` in the handler and show the failure there (see [Commands](typescript-commands.md)).
52
+
53
+ ## Menu
54
+
55
+ Keep the menu as data (label, target path, icon) declared beside the routes, outside the component, and pass it to the layout. One entry per feature route.
56
+
57
+ To hide entries the user cannot use, filter the same data: by availability with `useAvailableItems`, or by role with the identity's `isInRole` (see Availability and Gate by role in [Identity and availability](typescript-identity.md)). Hiding an entry is presentation only; the server still authorizes every request.
58
+
59
+ ## Routes outside the shell
60
+
61
+ A screen without the shell (a sign-in callback, a print view, a signed-out page) is a sibling of the layout route, not a child, as `/signed-out` is above.
62
+
63
+ ## Unknown URL
64
+
65
+ Add a catch-all child route (`path="*"`) that renders a recovery page with a way back. Without it an unknown URL matches no route and nothing is rendered.
66
+
67
+ ## Record screens
68
+
69
+ Put the record's identity in the path (`/vehicles/:vehicleId`), so the screen survives a reload and can be linked to.
70
+
71
+ ```tsx
72
+ import { Guid } from '@cratis/fundamentals';
73
+ import { useParams } from 'react-router-dom';
74
+ import { VehicleDetails } from './Details';
75
+
76
+ export const VehiclePage = () => {
77
+ const params = useParams();
78
+ const vehicleId = params.vehicleId && Guid.isGuid(params.vehicleId) ? Guid.parse(params.vehicleId) : undefined;
79
+ const [vehicle] = VehicleDetails.when(vehicleId !== undefined).use({ vehicleId: vehicleId! });
80
+
81
+ if (vehicleId === undefined) return <PageNotFound />;
82
+ // then branch on the result in the result-state order
83
+ };
84
+ ```
85
+
86
+ - Route parameters are strings typed by the user as much as by links. Check and convert them to the type the query argument declares; `Guid.parse` throws on a malformed value, hence the `Guid.isGuid` check. `VehicleDetails` is an illustrative query taking a `Guid`.
87
+ - Gate with `when` while the parameter is absent or invalid, and keep the hook call unconditional (see Conditional query in [Query hooks](typescript-queries.md)).
88
+ - Straight after a create, the record's first result can be empty because the read model has not caught up: show it as pending, not as "not found". See `cratis-platform-deliver-slice` (`references/eventual-consistency.md`).
89
+ - With a view model, take the parameter through the `params` decorator instead; see `cratis-arc-react-separate-view-model`.
90
+ - Never pass the record itself through navigation state: it is absent when the user enters the URL directly or follows a shared link, and it goes stale. Query by the identity in the URL.
91
+
92
+ **Edge case: a heavy, rarely visited page.** Load it on demand with React's `lazy` and a `<Suspense>` fallback around the route element. Not for ordinary pages.
93
+
94
+ ## Shell-wide values
95
+
96
+ For a value many features read and the shell owns (whether the menu is collapsed, the current workspace selection), use one React context provided by the layout. The signed-in user already has one: `useIdentity()`. Never copy query data into a context to share it; each screen calls the query hook. For an observable query, Arc shares the cache entry and the subscription. A snapshot query sends one request per mounted hook, so give that data one owner and pass the result down (see [Query hooks](typescript-queries.md)).
97
+
98
+ ## Avoid
99
+
100
+ - Repeating the top bar or menu in every page.
101
+ - A route per dialog.
102
+ - Menu entries built inline in the layout's render, apart from the route list.
103
+ - A context that mirrors a read model.
@@ -5,11 +5,13 @@
5
5
  - Live list with the full state order
6
6
  - Snapshot query with arguments and refresh
7
7
  - Conditional query
8
+ - Changing arguments, page or sort
8
9
  - Sorting
9
10
  - Paging
10
11
  - Suspense
11
12
  - Change stream
12
13
  - One busy flag for several queries
14
+ - When the live connection drops
13
15
 
14
16
  The examples use an illustrative visit-scheduling slice: `AllVisits` (observable collection), `VisitsForSite` (snapshot collection taking `{ siteId }`), `VisitDetails` (observable single item). Replace them with the application's own proxies and import each from the module the generator emitted (`./proxies` below stands for that module).
15
17
 
@@ -57,6 +59,33 @@ if (!hasSite) return <p>Choose a site.</p>;
57
59
 
58
60
  The hook is still called on every render; the request and subscription start only while the condition is true. `when` offers `use`, `useWithPaging`, `useSuspense` and `useSuspenseWithPaging`. `useChangeStream` has no conditional form.
59
61
 
62
+ The condition only stops the hook from running the query by itself. The `perform` the hook returns still sends a request when it is called, so guard manual execution with the same condition (disable the refresh button, or return early).
63
+
64
+ ## Changing arguments, page or sort
65
+
66
+ Every distinct combination of arguments, page, page size and sort order is its own cache entry, and for an observable query its own subscription, shared by every hook on that entry. When one of them changes, the hook switches entry in the same render:
67
+
68
+ - A hook disabled with `when` returns the default value as an empty, ready result and starts nothing by itself (a manual `perform()` still sends a request): branch on the condition before the result (see Conditional query).
69
+ - A query with a required argument missing sends no request and opens no subscription until the argument is set.
70
+ - An entry still in the cache shows its result at once, and an observable hook joins the subscription the entry already has.
71
+ - Otherwise the result is the query's default value with `isReady` false and `isPerforming` true. The previous rows are never carried over, so the state order above shows the loading branch; do not keep the old rows in component state to hide it.
72
+
73
+ **Filter typed by the user:** hold the input value in component state, debounce it, and pass the debounced value as the query argument. Each new value passed straight through is another entry with its own request or subscription; only a value whose entry is still cached is reused.
74
+
75
+ ```tsx
76
+ const [text, setText] = useState('');
77
+ const [filter, setFilter] = useState('');
78
+
79
+ useEffect(() => {
80
+ const timer = setTimeout(() => setFilter(text), 300);
81
+ return () => clearTimeout(timer);
82
+ }, [text]);
83
+
84
+ const [visits] = VisitsMatching.use({ filter });
85
+ ```
86
+
87
+ `VisitsMatching` is an illustrative observable query whose `filter` argument is optional; the delay is the application's choice. An empty string counts as missing for a required argument, and a query with a missing required argument is not sent, so an empty filter only lists everything when the backend declares the argument optional.
88
+
60
89
  ## Sorting
61
90
 
62
91
  ```tsx
@@ -120,7 +149,7 @@ import { useEffect } from 'react';
120
149
  import { AllVisits } from './proxies';
121
150
 
122
151
  export function VisitMarkers({ layer }: { layer: MarkerLayer }) {
123
- const changes = AllVisits.useChangeStream(visit => visit.id.toString());
152
+ const changes = AllVisits.useChangeStream(visit => visit.id.toString()); // a ChangeSet: added, replaced, removed
124
153
 
125
154
  useEffect(() => {
126
155
  changes.added.forEach(visit => layer.add(visit.id.toString(), visit.location));
@@ -132,7 +161,7 @@ export function VisitMarkers({ layer }: { layer: MarkerLayer }) {
132
161
  }
133
162
  ```
134
163
 
135
- For a query with parameters the arguments come first: `VisitsForSite`-style observable queries use `useChangeStream({ siteId }, visit => visit.id.toString())`. The first change set lists every current item under `added`, a new filter, page or sort can list rows that merely left the result under `removed`, and on a Full-mode host every change set lists everything under `added`; the stream synchronizes a collection (`MarkerLayer` stands for any external view) and never says a domain event happened.
164
+ For a query with parameters the arguments come first: `VisitsForSite`-style observable queries use `useChangeStream({ siteId }, visit => visit.id.toString())`. A change set the server provides wins, even for the hook's first result and on a Full-mode host. Without one, the first result (which an already-warm cache can supply) and every Full-mode result list all current items under `added`; later Delta results are diffed against the previous one. A diff compares membership and content, not order, so a reorder alone reports nothing, and new arguments or a new sort can list items under `removed` that merely left the result, with no domain deletion. Use the stream to keep an external collection's members in sync (`MarkerLayer` stands for any external view), never to announce domain events; when order or Arc paging matters, use the ordinary observable result. The key selector is used only when the hook diffs two results itself. In Delta mode the .NET backend sends change sets only for items with an `Id` property; the hook takes such a change set as is (without re-diffing) and rebuilds its collection by matching items on `id`. A collection whose items have no `Id`, and a sorted or paged one whose order a change set cannot keep, gets full snapshots instead, which the hook diffs with the key selector.
136
165
 
137
166
  ## One busy flag for several queries
138
167
 
@@ -155,3 +184,13 @@ export function VisitsScreen() {
155
184
  ```
156
185
 
157
186
  Inside the scope, `useQueryScope()` returns the same aggregated `isPerforming`.
187
+
188
+ ## When the live connection drops
189
+
190
+ Arc reconnects on its own and re-subscribes the mounted queries; a screen needs no code for it. The schedule depends on the transport:
191
+
192
+ - **WebSocket connections and the shared server-sent-events stream:** the first retry comes after one second and each further retry waits half a second longer, up to ten seconds. A successful connection resets the count. After 100 failed attempts in a row Arc stops retrying that connection. Open it again with `reconnectQueries()` from the Arc context or a page reload. A query that subscribes on a shared connection afterwards also reopens it; do not rely on that.
193
+ - **A direct server-sent-events stream:** the browser's `EventSource` reconnects by its own rules; Arc applies no schedule and no attempt limit.
194
+ - **Polling:** there is no connection to restore; failed polls back off within the configured polling options and continue.
195
+
196
+ When updates stop arriving, diagnose with `cratis-arc-diagnose-live-query`.