@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.
- package/package/corpus/harnesses/copilot/instructions/ai-distribution.instructions.md +2 -1
- package/package/corpus/harnesses/copilot/instructions/exit-codes-and-wrappers.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +5 -3
- package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -1
- package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -1
- package/package/corpus/harnesses/copilot/instructions/scripting.instructions.md +2 -1
- package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +6 -3
- package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
- package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +131 -9
- package/package/corpus/rules/ai-distribution.md +2 -1
- package/package/corpus/rules/exit-codes-and-wrappers.md +1 -1
- package/package/corpus/rules/glossary.md +5 -3
- package/package/corpus/rules/react.md +3 -1
- package/package/corpus/rules/reactors.md +3 -1
- package/package/corpus/rules/scripting.md +2 -1
- package/package/corpus/rules/specs.csharp.md +6 -3
- package/package/corpus/rules/vertical-slices.md +5 -2
- package/package/corpus/skills/cratis-application-growth/SKILL.md +1 -2
- package/package/corpus/skills/cratis-application-growth/references/csharp.md +1 -3
- package/package/corpus/skills/cratis-application-growth/references/move-and-untangle.md +1 -2
- package/package/corpus/skills/cratis-application-growth/references/rename-window.md +1 -3
- package/package/corpus/skills/cratis-application-growth/references/service-and-delivery.md +3 -2
- package/package/corpus/skills/cratis-application-growth/references/stages.md +2 -2
- package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +3 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +47 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +18 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/typescript.md +2 -0
- package/package/corpus/skills/cratis-arc-connect-storage/references/csharp.md +1 -0
- package/package/corpus/skills/cratis-arc-connect-storage/references/elixir.md +9 -2
- package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +47 -8
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-controller.md +3 -1
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +6 -3
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +38 -11
- package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-abilities.md +2 -2
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-recovery.md +6 -4
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-arc-diagnose-live-query/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +29 -7
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/java.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/kotlin.md +1 -1
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp-diagnose-tool-call.md +9 -7
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +52 -1
- package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +4 -2
- package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +36 -10
- package/package/corpus/skills/cratis-arc-expose-query/references/go.md +2 -2
- package/package/corpus/skills/cratis-arc-expose-query/references/typescript.md +6 -3
- package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
- package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +55 -6
- package/package/corpus/skills/cratis-arc-generate-proxies/references/typescript.md +9 -0
- package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-configuration.md +54 -0
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-deployment.md +98 -0
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-http.md +9 -1
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +87 -4
- package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +9 -0
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp-extensions.md +4 -0
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +19 -2
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/csharp.md +4 -2
- package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +33 -36
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +18 -3
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +94 -19
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +29 -5
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-instant-feedback.md +81 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +80 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-navigation.md +103 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +41 -2
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-structure.md +117 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +8 -4
- package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +3 -3
- package/package/corpus/skills/cratis-arc-react-separate-view-model/references/typescript.md +27 -6
- package/package/corpus/skills/cratis-arc-testing-typescript/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-arc-validate-command/references/csharp-rules.md +23 -2
- package/package/corpus/skills/cratis-arc-validate-command/references/csharp.md +28 -2
- package/package/corpus/skills/cratis-arc-validation-typescript/SKILL.md +1 -0
- package/package/corpus/skills/cratis-authproxy-configure/SKILL.md +136 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/admission.md +125 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/aspire.md +154 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/operations.md +122 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/services-and-routing.md +114 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/sessions-and-logout.md +126 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/sign-in-providers.md +116 -0
- package/package/corpus/skills/cratis-authproxy-configure/references/tenant-resolution.md +135 -0
- package/package/corpus/skills/cratis-choreography-run-workflow/SKILL.md +117 -0
- package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp-chronicle.md +164 -0
- package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp.md +354 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +6 -6
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/inspection.md +11 -3
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +50 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/recovery-and-comparison.md +17 -3
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/setup-and-target.md +8 -2
- package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp-services.md +13 -2
- package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp.md +12 -0
- package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin.md +2 -0
- package/package/corpus/skills/cratis-chronicle-connect-application/references/python.md +2 -2
- package/package/corpus/skills/cratis-chronicle-connect-application/references/typescript.md +10 -1
- package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +9 -2
- package/package/corpus/skills/cratis-chronicle-constrain-append/references/csharp.md +35 -3
- package/package/corpus/skills/cratis-chronicle-constrain-append/references/go.md +1 -1
- package/package/corpus/skills/cratis-chronicle-constrain-append/references/operations.md +70 -0
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +6 -3
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +113 -16
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/container-and-kubernetes.md +293 -0
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +16 -9
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +60 -7
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +124 -2
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +36 -1
- package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
- package/package/corpus/skills/cratis-chronicle-evolve-event/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +15 -5
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +9 -8
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/go.md +2 -2
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/references/deployment.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +2 -2
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +15 -4
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +4 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +5 -2
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp.md +23 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/elixir.md +1 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/go.md +2 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +3 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +4 -3
- package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +3 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +3 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +41 -4
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +22 -4
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/elixir.md +7 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/go.md +9 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/java.md +8 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/kotlin.md +9 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/typescript.md +7 -0
- package/package/corpus/skills/cratis-chronicle-protect-personal-data/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-personal-data/references/csharp.md +28 -3
- package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +7 -6
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/elixir-integrations.md +3 -3
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/webhook-signature-wire-format.md +82 -0
- package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +19 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-outputs.md +3 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-pages.md +1 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +37 -4
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/elixir.md +11 -0
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +2 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
- package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +3 -3
- package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-coordination.md +31 -2
- package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-history.md +21 -4
- package/package/corpus/skills/cratis-chronicle-record-event/references/csharp.md +20 -2
- package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/references/java.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/references/kotlin.md +3 -0
- package/package/corpus/skills/cratis-chronicle-reduce-state/SKILL.md +2 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/csharp.md +3 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/java.md +10 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/kotlin.md +10 -1
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +27 -5
- package/package/corpus/skills/cratis-chronicle-select-client/SKILL.md +18 -0
- package/package/corpus/skills/cratis-chronicle-select-client/references/elixir.md +21 -1
- package/package/corpus/skills/cratis-chronicle-select-client/references/go.md +13 -0
- package/package/corpus/skills/cratis-chronicle-select-client/references/java.md +15 -0
- package/package/corpus/skills/cratis-chronicle-select-client/references/kotlin.md +15 -0
- package/package/corpus/skills/cratis-chronicle-select-client/references/typescript.md +16 -0
- package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +1 -1
- package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +4 -3
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/publish-pipelines.md +19 -4
- package/package/corpus/skills/cratis-code-review/SKILL.md +6 -2
- package/package/corpus/skills/cratis-code-review/references/csharp-diagnostics.md +28 -2
- package/package/corpus/skills/cratis-code-review/references/csharp.md +4 -4
- package/package/corpus/skills/cratis-commits-and-pull-requests/SKILL.md +6 -38
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-description.md +2 -0
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-labels-and-release.md +5 -4
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/workflow-inputs.md +39 -0
- package/package/corpus/skills/cratis-components-accessibility/SKILL.md +6 -8
- package/package/corpus/skills/cratis-components-accessibility/references/typescript.md +32 -14
- package/package/corpus/skills/cratis-components-build-canvas/SKILL.md +4 -3
- package/package/corpus/skills/cratis-components-build-canvas/references/typescript-props.md +1 -1
- package/package/corpus/skills/cratis-components-build-canvas/references/typescript.md +4 -2
- package/package/corpus/skills/cratis-components-choose-control/SKILL.md +13 -7
- package/package/corpus/skills/cratis-components-choose-control/references/from-primereact.md +116 -0
- package/package/corpus/skills/cratis-components-choose-control/references/menu.md +90 -0
- package/package/corpus/skills/cratis-components-choose-control/references/typescript-composition.md +48 -0
- package/package/corpus/skills/cratis-components-choose-control/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-components-compose-toolbar/SKILL.md +2 -1
- package/package/corpus/skills/cratis-components-compose-toolbar/references/floating-toolbar.md +146 -0
- package/package/corpus/skills/cratis-components-diagnose-screen/SKILL.md +102 -0
- package/package/corpus/skills/cratis-components-display-list/SKILL.md +10 -10
- package/package/corpus/skills/cratis-components-display-list/references/typescript-custom-panel.md +74 -0
- package/package/corpus/skills/cratis-components-display-list/references/typescript-datatables.md +2 -7
- package/package/corpus/skills/cratis-components-display-list/references/typescript.md +3 -2
- package/package/corpus/skills/cratis-components-submit-form/SKILL.md +6 -6
- package/package/corpus/skills/cratis-components-submit-form/references/typescript-commanddialog.md +21 -1
- package/package/corpus/skills/cratis-components-submit-form/references/typescript-commandform.md +72 -2
- package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +7 -5
- package/package/corpus/skills/cratis-components-theme-application/SKILL.md +17 -15
- package/package/corpus/skills/cratis-components-theme-application/references/localization.md +166 -0
- package/package/corpus/skills/cratis-components-theme-application/references/typescript.md +18 -14
- package/package/corpus/skills/cratis-components-theme-application/references/upgrade-from-previous-major.md +141 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +2 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-domain-philosophy.md +31 -3
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-fundamentals-helpers.md +119 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp.md +4 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +72 -1
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +9 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +2 -1
- package/package/corpus/skills/cratis-fundamentals-concept/references/java-json.md +3 -2
- package/package/corpus/skills/cratis-fundamentals-concept/references/kotlin-json.md +3 -2
- package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +41 -2
- package/package/corpus/skills/cratis-fundamentals-name-value/SKILL.md +8 -7
- package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
- package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +3 -3
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +8 -0
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/go-dependency-injection.md +3 -0
- package/package/corpus/skills/cratis-modeling-design-event-model/SKILL.md +6 -4
- package/package/corpus/skills/cratis-modeling-design-event-model/references/command-inventory.md +7 -1
- package/package/corpus/skills/cratis-modeling-design-event-model/references/model-first.md +13 -1
- package/package/corpus/skills/cratis-modeling-design-event-model/references/review-one-slice.md +6 -0
- package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +6 -6
- package/package/corpus/skills/cratis-multi-service-local-orchestration/references/csharp-aspire.md +116 -28
- package/package/corpus/skills/cratis-multi-service-local-orchestration/references/docker-compose.md +2 -2
- package/package/corpus/skills/cratis-observability/references/chronicle-kernel-export.md +46 -0
- package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +4 -2
- package/package/corpus/skills/cratis-platform-build-application/SKILL.md +8 -0
- package/package/corpus/skills/cratis-platform-build-application/references/cratis-identity.md +71 -0
- package/package/corpus/skills/cratis-platform-build-application/references/studio-repository.md +96 -0
- package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +14 -8
- package/package/corpus/skills/cratis-platform-deliver-slice/references/csharp.md +167 -3
- package/package/corpus/skills/cratis-platform-deliver-slice/references/eventual-consistency.md +150 -0
- package/package/corpus/skills/cratis-platform-deliver-slice/references/typescript.md +14 -1
- package/package/corpus/skills/cratis-platform-diagnose-slice/SKILL.md +1 -1
- package/package/corpus/skills/cratis-platform-prepare-release-pr/SKILL.md +8 -8
- package/package/corpus/skills/cratis-platform-prepare-release-pr/references/product-release-checks.md +16 -2
- package/package/corpus/skills/cratis-platform-start-application/SKILL.md +21 -0
- package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +77 -3
- package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +118 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/references/csharp.md +117 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/references/java.md +53 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/references/kotlin.md +53 -0
- package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +71 -0
- package/package/corpus/skills/cratis-release-notes/SKILL.md +1 -1
- package/package/corpus/skills/cratis-release-notes/references/publish-repair.md +6 -3
- package/package/corpus/skills/cratis-screenplay-accept-model/references/csharp.md +34 -3
- package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +84 -3
- package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +7 -11
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/commands.md +8 -4
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/projections.md +2 -0
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +29 -1
- package/package/corpus/skills/cratis-screenplay-edit-workspace/SKILL.md +2 -1
- package/package/corpus/skills/cratis-screenplay-edit-workspace/references/mcp-tools.md +1 -1
- package/package/corpus/skills/cratis-screenplay-handoff-slice/references/csharp.md +13 -1
- package/package/corpus/skills/cratis-screenplay-model-translation/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-model-translation/references/boundary-diagnostics.md +1 -1
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +30 -51
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/cli.md +19 -2
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/smallest-model.md +87 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/studio.md +5 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/typescript.md +13 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
- package/package/corpus/skills/cratis-screenplay-specify-outcome/SKILL.md +8 -12
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/running-mcp.md +12 -0
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/scenarios.md +2 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +2 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-colocated.md +101 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +4 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-decision-reads.md +1 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +7 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +7 -4
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +18 -5
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-read-models.md +4 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +35 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/typescript.md +4 -2
- package/package/corpus/skills/cratis-specifications-isolate-behavior/SKILL.md +1 -1
- package/package/corpus/skills/cratis-specifications-isolate-behavior/references/csharp-running.md +10 -3
- package/package/corpus/skills/cratis-specifications-test-application-ui/references/typescript.md +22 -4
- package/package/corpus/skills/cratis-specifications-test-typescript-behavior/SKILL.md +2 -1
- package/package/corpus/skills/cratis-specifications-test-typescript-behavior/references/typescript.md +40 -0
- package/package/corpus/skills/cratis-stage-render-slice/SKILL.md +6 -0
- package/package/corpus/skills/cratis-stage-render-slice/references/semantic-conformance.md +64 -0
- package/package/profile-catalog.json +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Webhook signature wire format
|
|
2
|
+
|
|
3
|
+
Use this when the receiver of a signed webhook is not a .NET process, so it must verify deliveries itself. A .NET receiver uses the client's `WebhookSignatureVerifier` instead (C# integrations, `references/csharp-integrations.md`), which covers the signed message and the steps under [Verify a delivery](#verify-a-delivery). A .NET receiver still loads and refreshes the keys, answers the request and handles repeats itself. The verifier keeps the keys it was created with, so create a new one from every refreshed key set.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- [What a signed request carries](#what-a-signed-request-carries)
|
|
8
|
+
- [The signed message](#the-signed-message)
|
|
9
|
+
- [Get the public keys](#get-the-public-keys)
|
|
10
|
+
- [Verify a delivery](#verify-a-delivery)
|
|
11
|
+
- [Key rotation](#key-rotation)
|
|
12
|
+
- [Repeats and replays](#repeats-and-replays)
|
|
13
|
+
- [Anti-patterns](#anti-patterns)
|
|
14
|
+
|
|
15
|
+
## What a signed request carries
|
|
16
|
+
|
|
17
|
+
The kernel generates these headers only for a webhook registered with Ed25519 signing, and there it replaces any custom header of the same name. An unsigned webhook gets none from the kernel, but its custom headers may use these names, so their presence alone proves nothing.
|
|
18
|
+
|
|
19
|
+
| Header | Contents |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `webhook-id` | Identifier of the delivery. It stays the same when the kernel retries the same delivery. Treat it as opaque. |
|
|
22
|
+
| `webhook-timestamp` | Time of signing in Unix seconds, as decimal digits. |
|
|
23
|
+
| `webhook-signature` | One or more signatures separated by a space, each written `v1a,<base64>`. |
|
|
24
|
+
| `Cratis-Key-Id` | Id of a signing key. A hint for noticing an unknown key; never base the accept or reject decision on it. |
|
|
25
|
+
|
|
26
|
+
The framing follows Standard Webhooks with its asymmetric `v1a` signature version.
|
|
27
|
+
|
|
28
|
+
## The signed message
|
|
29
|
+
|
|
30
|
+
- Message bytes: the UTF-8 bytes of `<webhook-id>.<webhook-timestamp>.` followed by the request body exactly as received. The header values are used as sent, joined by dots.
|
|
31
|
+
- Algorithm: Ed25519 (RFC 8032). Each signature is 64 bytes, Base64-encoded after the `v1a,` prefix.
|
|
32
|
+
- The body is JSON, but the signature covers its bytes. Read the raw body before any JSON parser touches it; a body that was parsed and serialized again fails verification as soon as one byte differs.
|
|
33
|
+
|
|
34
|
+
## Get the public keys
|
|
35
|
+
|
|
36
|
+
The keys belong to the **event store**, not to one webhook: every signed webhook of a store is verified with the same keys.
|
|
37
|
+
|
|
38
|
+
- Each public key is the text `whpk_` followed by the Base64 of the 32-byte Ed25519 public key. Remove the prefix and Base64-decode to get the key.
|
|
39
|
+
- Read them from the kernel with the `GetWebhookSigningKeys` operation of the `Webhooks` gRPC service, passing the event store name. Each entry has `KeyId`, `Algorithm`, `PublicKey`, `Status` (`Active` or `Overlap`), `CreatedAt` and `OverlapEndsAt`. Private keys are never returned.
|
|
40
|
+
- A receiver that cannot reach the kernel gets the keys as configuration from an operator who can: each `whpk_...` string with its status and `OverlapEndsAt`. A bare key string carries no expiry, so the receiver would trust it indefinitely. The operator supplies the complete updated set at every rotation, before the overlap ends.
|
|
41
|
+
- Load the keys when the receiver starts and keep them in memory. The kernel does not push keys to receivers, so the receiver replaces its set on its own schedule, as described under [Key rotation](#key-rotation).
|
|
42
|
+
|
|
43
|
+
## Verify a delivery
|
|
44
|
+
|
|
45
|
+
1. Reject the request when `webhook-id`, `webhook-timestamp` or `webhook-signature` is missing or empty, when `webhook-id` contains a dot, or when `webhook-id` is not well-formed text that encodes to UTF-8 without loss. Never substitute a replacement character for a malformed sequence or an unpaired surrogate; reject instead.
|
|
46
|
+
2. Reject it when `webhook-timestamp` is not canonical decimal seconds: ASCII digits `0`-`9` only, with no sign, no spaces and no leading zeros, and a value within the signed 64-bit range (at most `9223372036854775807`). Parse it so that a longer run of digits is rejected, not wrapped or truncated. Reject it also when it is more than five minutes from the receiver's clock in either direction. Keep the clock synchronized.
|
|
47
|
+
3. Build the message from the two header values and the raw body, as above, encoding strictly as UTF-8.
|
|
48
|
+
4. Reject the request when `webhook-signature` is longer than 4096 characters. Otherwise split it on spaces and keep the entries that start with `v1a,`; ignore entries of any other version. Reject the request when no `v1a` entry is left. Base64-decode the rest of each entry and skip an entry that is not valid Base64 of exactly 64 bytes. Reject the request when no signature remains.
|
|
49
|
+
5. Accept the request when **any** of those signatures verifies under **any** usable key: an active key, or an overlap key whose `OverlapEndsAt` is still in the future. Otherwise reject it and do not process the body.
|
|
50
|
+
|
|
51
|
+
The kernel takes only a `2xx` answer as an acknowledgement. Choose the answer by cause:
|
|
52
|
+
|
|
53
|
+
| Situation | Answer | What the kernel does |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| The request fails any of steps 1 to 5 with the receiver's keys current | `401` | Treats a final `401` as a configuration problem and pauses the whole webhook |
|
|
56
|
+
| The receiver cannot decide yet: it has no keys loaded, or the refresh a failed verification calls for cannot reach the key source | `503` with `Retry-After` | Defers the partition until the time given and sends again, without spending a retry or pausing the webhook |
|
|
57
|
+
| The request verifies and is handled, or verifies and its `webhook-id` was already handled | `2xx` | Moves on to the next batch |
|
|
58
|
+
|
|
59
|
+
When the webhook authenticates with OAuth or a managed identity, the kernel answers a `401` by refreshing its token and sending the batch once more; the answer to that second request decides, so a resend the receiver accepts does not pause the webhook. Do the failure-triggered refresh described under [Key rotation](#key-rotation) before answering `401`, not after.
|
|
60
|
+
|
|
61
|
+
## Key rotation
|
|
62
|
+
|
|
63
|
+
- The kernel signs every delivery once per usable key: the active key and every overlap key whose overlap has not ended. `webhook-signature` carries one signature for each. An earlier overlap stays open through a later rotation, so there can be more than two. A receiver holding any of those keys accepts the delivery, provided the header passes step 4; that is why step 5 tries every signature against every key. Each entry is 92 characters, so 44 signatures fit in the 4096-character limit and a header carrying more is rejected whole. Let overlaps end before rotating again, so the count stays far below that.
|
|
64
|
+
- A replaced key is listed with status `Overlap` and its own `OverlapEndsAt`. Stop trusting each overlap key once its own time has passed; after that it is no longer listed.
|
|
65
|
+
- Replace the key set proactively; do not wait for a failure. A key the receiver loaded as `Active` keeps verifying all through its overlap, so a receiver that refreshes only on failure never learns that the key was replaced or when it expires, and goes on trusting it. Read the keys again on a fixed interval well shorter than the overlap the operator allows at rotation. A receiver that cannot reach the kernel gets the same from its operator: the complete new set at every rotation, before the overlap ends.
|
|
66
|
+
- Replace the whole set each time, never merge into the old one: keep exactly the keys listed, with the status and `OverlapEndsAt` now listed, and drop every key that is no longer listed.
|
|
67
|
+
- As a fallback, when verification fails and `Cratis-Key-Id` names a key the receiver does not hold, read the keys again at once and verify once more. If it still fails, reject. Never accept a delivery because its key id is unknown.
|
|
68
|
+
|
|
69
|
+
## Repeats and replays
|
|
70
|
+
|
|
71
|
+
- The timestamp tolerance limits how long a captured request stays usable; it does not make a request single use. Record the `webhook-id` of every delivery that verified and was handled. Verify a repeat like any other request; when it verifies and its `webhook-id` is recorded, answer `2xx` without applying its effect again. Any other answer makes the kernel send it again or pause the webhook. Never answer `2xx` to, or record the id of, a request that failed verification.
|
|
72
|
+
- A replay of the webhook from Chronicle is a new delivery with a new `webhook-id` carrying the same events under the same sequence numbers. So `webhook-id` stops a re-sent request, while the effect itself stays keyed on the event, as described under **Webhook** in `SKILL.md`.
|
|
73
|
+
|
|
74
|
+
## Anti-patterns
|
|
75
|
+
|
|
76
|
+
- Verifying a re-serialized body, or a body a framework already decoded and re-encoded.
|
|
77
|
+
- Picking the key by `Cratis-Key-Id` and verifying only against it, or skipping verification when the id is unknown.
|
|
78
|
+
- Failing the request on a signature entry of an unknown version instead of ignoring that entry.
|
|
79
|
+
- Refreshing keys only when verification fails: a replaced key stays trusted after its overlap has ended.
|
|
80
|
+
- Answering `401` while the keys cannot be loaded, or anything but `2xx` to a verified repeat.
|
|
81
|
+
- Hard-coding one public key with no way to add a second: the next rotation rejects every delivery once the overlap ends.
|
|
82
|
+
- Treating a valid signature as authorization. Signing proves origin and integrity; keep the receiver's authentication as well.
|
|
@@ -46,7 +46,9 @@ Use the project's reference for the supported form of each operation.
|
|
|
46
46
|
- Start at tail — skip existing facts only on first registration in a namespace. It never moves an observer that already has a saved position and does not suppress explicit replay. Both kernel and client must support it; a kernel that predates it ignores the request and the new subscription catches up from the beginning, so upgrade the kernel first, then the client. Changing the subscription's identity makes a new observer that starts at the tail again, skipping anything the old one had not handled.
|
|
47
47
|
- Replay exclusion — disable replay for the whole observer or skip selected handlers when replay must not repeat their effects.
|
|
48
48
|
- Replay override — substitute a replay handler for the ordinary handler of that type, or bind a replay-only event type; ordinary handlers otherwise run unless excluded.
|
|
49
|
+
- Handler changes — deploying changed handler code does not reprocess history: the reactor continues from its saved position. Adding or removing a handled event type does not replay either on a kernel with default settings; the kernel recommends a replay instead of starting one. The development kernel image is the exception: it requests a replay when the reactor's set of handled event types changes, never for a code-only change, and a reactor with replay disabled is still not replayed. Request an explicit replay when earlier events must be handled again, and only when the handlers are replay-safe.
|
|
49
50
|
- Replay lifecycle — receive begin/end notifications for the replay or a partition when rebuilding auxiliary state.
|
|
51
|
+
- Retry schedule — a failed partition is retried automatically with exponentially growing delays, and recovery is requested again when the reactor subscribes again, for example after a deployment. After deploying the fix, check whether the partition recovered before requesting anything; an accepted retry is not proof of recovery. Retries are bounded by default; a maximum of zero retry attempts means unlimited retries. A partition that used up its attempts is quarantined and automatic retries stop. Once the cause is fixed, an operator retry of a connected reactor's exhausted partition is still accepted, but it keeps the spent budget, so one more failure quarantines the partition again; clearing its quarantine starts a fresh budget. For the retry budget and quarantine see `cratis-chronicle-inspect-observer`.
|
|
50
52
|
- Delivery identity — use the stable delivery identity plus a distinct label per external operation; a delivery attempt number is not a receipt key.
|
|
51
53
|
- Derived fact — return a registered event when success should append a fact, or complete without a result for no append.
|
|
52
54
|
- Targeted output — explicitly route an output to another source instead of inheriting the trigger's source.
|
|
@@ -66,7 +68,23 @@ Use the project's reference for the supported form of each operation.
|
|
|
66
68
|
- Partition concurrency — cap independent partitions processed concurrently for downstream capacity; preserve order within each partition, not across them.
|
|
67
69
|
- Subscription readiness — wait before appending in a live-only test; handle timeout or cancellation rather than assuming registration means ready.
|
|
68
70
|
- State and failures — inspect progress and failed partitions before retrying; clear quarantine only after fixing the cause.
|
|
69
|
-
- Replay or fast-forward — replay to process history again; fast-forward
|
|
71
|
+
- Replay or fast-forward — replay to process history again. Fast-forward is the opposite: it moves the observer to the tail, skips every unhandled event without invoking the handler and discards its failed partitions (no separate deletion needed). On an empty event sequence it does nothing and keeps the failed partitions; an observer already past the tail is left alone only when no partitions are catching up or failed. State already built is kept. Events appended after the tail was read are handled once the observer routes again; fast-forward does not lift an observer quarantine. Use it only to abandon a backlog deliberately, never as a repair.
|
|
70
72
|
- Operational diagnosis and repair — diagnose with `cratis-chronicle-inspect-observer`, which stops before changing state; perform an authorized retry, quarantine clear, replay, fast-forward, observer removal or job stop, resume or delete through `cratis-chronicle-cli-operations`, or through the SDK calls in your language reference. Each returns an outcome to match: an accepted call is not a completed repair.
|
|
71
73
|
- Retired reactor — a reactor whose code is deleted, renamed or moved without a pinned identity stays registered as a disconnected observer with its position. Remove it only when no service needs it; removal covers every namespace, and registering it again starts from the beginning.
|
|
74
|
+
- Two versions connected at once — when instances of two application versions register the same observer with different event types, the last registration wins and the other version stops receiving. Only when the last connected instance of the winner leaves does a superseded version take over: connected standbys are tried newest first, and one that cannot take over is skipped. This automatic hand-over neither lifts a quarantine nor reactivates a retired observer (a redeploy or restart that subscribes the reactor again does end its observer quarantine), and events of types only the departed version handled are not replayed to the new one. Serving both type sets at once is not supported: keep the overlap short or put new handling in a separate reactor with its own ID. The hand-over is not exactly-once, so keep effects keyed on delivery identity.
|
|
72
75
|
- Read-model reactor — observe additions, modifications or removals when the change to a view is the trigger. Use materialized change detection for stored snapshots when needed. Delivery is best-effort, not a durable event subscription: a failing handler is logged or reported and never retried, with no failed partition to recover and no exactly-once delivery. Changes made while disconnected are not guaranteed to arrive, a change can arrive again after reconnecting, and snapshot comparison can merge intermediate states. Never trigger once-only external effects (payments, messages) from a view change; react to the domain event with an event reactor and make the external call idempotent.
|
|
76
|
+
|
|
77
|
+
## Multi-step processes (sagas and process managers)
|
|
78
|
+
|
|
79
|
+
Cratis has no saga or process-manager building block. Build a multi-step process from facts, reactors and read models, chosen by its shape:
|
|
80
|
+
|
|
81
|
+
| Shape of the process | Use |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| Short and linear, no waiting (default) | A chain of reactors: each reactor handles one fact and returns the next event, or the next command where your language reference shows a command integration; without one a returned command is not executed. Add a work-list read model (`cratis-chronicle-project-view`): the opening fact adds the item, and only a completion or cancellation fact removes it. |
|
|
84
|
+
| Steps that also need guarded ordering and an explicit closure | Still facts, reactors and a work-list read model. Add a process stream: one stream per run, a stream decision guards the step order against competing appends (`cratis-chronicle-protect-decision`) and completing the stream refuses later appends (`cratis-arc-declare-command`, `references/csharp-chronicle.md`). It gives only those two guarantees; it does not drive the steps. |
|
|
85
|
+
| Waits for a person, another fact or a deadline | The same chain with a work-list item that stays open while the process waits. The wait is not code: the next step is a reactor for the fact that ends the wait, such as the approval, the answer or the recorded expiry. A reactor never waits itself. |
|
|
86
|
+
| One entity's lifecycle | A status on the entity's read model, built from its facts (`cratis-chronicle-project-view`). Commands decide from the entity's facts, not from that status. |
|
|
87
|
+
|
|
88
|
+
**No rollback across steps.** Each step commits on its own, and nothing spans a reactor's returned events and commands, several returned commands, or several steps. A failed step is redelivered, so first make each step safe to repeat and let a transient failure retry. Compensate only when the domain decides to reverse completed work: record that decision as a fact and issue a compensating command for each completed step it reverses. Chronicle does not prevent a duplicate compensation, so make each one safe to repeat. Keep the item on the work list until a completion or cancellation fact removes it. Never delete or redact events to undo a step.
|
|
89
|
+
|
|
90
|
+
**Order.** Each handler method sees its events in order within one event source. Two methods of the same reactor are not ordered relative to each other, even for the same event source: a batch method and a per-event method each keep only their own order. When two effects must happen in a set order, handle them in one method. Order does not hold across event sources or between observers: a reactor can handle a fact before a projection has stored it, and the reverse. When logic needs the facts of two entities in order, put them on one event source or carry the needed data on the later event. Limiting partition concurrency protects a downstream system; it does not create a global order. With several instances of a service connected, keep the kernel's default fan-out, which keeps each event source on one instance while the set of connected instances is unchanged. Scaling or a reconnect can move an event source to another instance, so do not hold per-source state in instance memory.
|
|
@@ -12,6 +12,8 @@ public IEnumerable<object> Dispatched(ParcelDispatched fact) =>
|
|
|
12
12
|
|
|
13
13
|
For bare results implement on the reactor `ICanProvideEventSourceId`, `ICanProvideSubject` or `ICanProvideEventStreamId` with `GetEventSourceId()`, `GetSubject()` or `GetEventStreamId()` respectively; use reactor `[EventStreamId]`, `[EventStreamType]`, `[EventSourceType]` metadata where appropriate. An explicit wrapper takes precedence; set its `Subject`, `EventSourceType`, `EventStreamType`, `EventStreamId` and tags deliberately. Keep order stable: Chronicle derives automatic append keys by delivery and output position. `[Reactor("dispatch-log", effectEpoch: 1)]` (also available with an event sequence) deliberately changes automatic output identity (and named keys from `IdempotencyKeyFor`, but not `delivery.Id`); inspect `delivery.EffectEpoch`. Do not bump it to retry a failed delivery.
|
|
14
14
|
|
|
15
|
+
The derived keys are what stop a repeated delivery from appending a returned event again, and they need a kernel that supports idempotent appends. A kernel without that support appends returned events **without** derived keys and the client logs one warning per reactor, so a redelivery can append a copy: upgrade the kernel; do not replace returned events with manual appends. An `IdempotencyKey` you set yourself on an `EventForEventSourceId` is kept and never silently dropped: on such a kernel the return fails with `IdempotentAppendsNotSupported` and nothing is appended.
|
|
16
|
+
|
|
15
17
|
When several outputs depend on independently observed state, return `EventsWithConcurrencyScopes` with the ordered targeted events and the observed concurrency conditions. For example, given `depotOutput`, `parcelOutput` and scopes obtained at decision time:
|
|
16
18
|
|
|
17
19
|
```csharp
|
|
@@ -34,6 +36,6 @@ public CommandInvocation Dispatched(ParcelDispatched fact) =>
|
|
|
34
36
|
|
|
35
37
|
Use `Cratis.Arc.Chronicle.Reactors`. Match the exact constraint name. Selectors include `ByValidation`, `ByConstraint(name)`, `ByAnyConstraint`, `ByAuthorization` and `Any` (validation and constraints, not authorization). First match wins. A handled refusal stops later commands; earlier appends remain committed. Only acknowledge when no outcome fact is required. Concurrency and infrastructure failures aren't refusals. Preserve the actor for consequential commands.
|
|
36
38
|
|
|
37
|
-
The integration also executes a bare returned command (e.g. `public ReserveLoadingBay Dispatched(ParcelDispatched fact) => new(fact.DepotId);`), an enumerable of commands and/or invocations in order, and an enumerable mixing registered events with commands:
|
|
39
|
+
The integration also executes a bare returned command (e.g. `public ReserveLoadingBay Dispatched(ParcelDispatched fact) => new(fact.DepotId);`), an enumerable of commands and/or invocations in order, and an enumerable mixing registered events with commands: all events are appended first as one batch, then the commands run in order; interleaving them in the collection does not interleave execution. If the append fails, no command runs. Without a matching refusal branch an unsuccessful command fails the delivery and stops later commands. Nothing spans the two groups: the event batch and the commands that already succeeded stay committed, and recovery redelivers the triggering event and runs the returned commands again from the first one, including those that already succeeded, stopping again at the first unsuccessful command. `[OnceOnly]` does not prevent that, so keep each returned command safe to repeat. To run a reactor's returned commands as the system with declared roles, see `[ExecuteCommandsAsSystem]` in `cratis-arc-authorize-request`. That attribute covers **returned** commands only. Prefer returning the command: a handler that calls `ICommandPipeline.Execute` itself runs with no principal unless it opens its own system scope, and must state what replay does (`ARCCHR0006`): `[OnceOnly]` when skipping the handler on replay is right, otherwise a `[Replay]` handler for the same event type.
|
|
38
40
|
|
|
39
41
|
A returned value that no side-effect handler claims (for example a custom type without a registered `IReactorSideEffectHandler`) fails the delivery with `UnhandledReactorReturnValue`. Return a supported type or register the handler.
|
|
@@ -34,7 +34,7 @@ await handler.WaitTillReachesEventSequenceNumber(position, TimeSpan.FromSeconds(
|
|
|
34
34
|
|
|
35
35
|
`GetHandlerFor<CarrierNotice>()`, `GetHandlerFor(type)` and `GetHandlerById(id)` require a known registration. On its handler use `WaitForState` / `WaitForStateAndGetState` for a specified running state, `WaitTillActive` / `WaitTillActiveAndGetState` for active processing and `WaitForThereToBeFailedPartitions` when testing failure. Supply bounded timeouts. `IReactors` also offers generic waits for state, active, subscribed, position and failures.
|
|
36
36
|
|
|
37
|
-
Use `GetStateFor<CarrierNotice>()` and `GetFailedPartitionsFor<CarrierNotice>()` (or pass `Type`) on the owning store and namespace. Fix the cause, then `await reactors.RetryFailedPartitionFor<CarrierNotice>(partition)`
|
|
37
|
+
Use `GetStateFor<CarrierNotice>()` and `GetFailedPartitionsFor<CarrierNotice>()` (or pass `Type`) on the owning store and namespace. Fix the cause, then `await reactors.RetryFailedPartitionFor<CarrierNotice>(partition)`. Its `Accepted` outcome means the request was queued, not that the partition recovered. Every returned failure record is open: recovery deletes the partition's record, so confirm it by the partition's absence from `GetFailedPartitionsFor` and by the effect, not by `IsResolved`. For quarantined work `ClearFailedPartitionQuarantineFor<CarrierNotice>(partition, retryImmediately: false)` requests clearing without an immediate retry; the default also requests an immediate retry. Its result is likewise `Accepted` only. Once the quarantine is actually cleared, the partition returns to the normal retry schedule, but a quarantined observer still blocks its recovery; check `GetFailedPartitionsFor` afterwards. `Replay<CarrierNotice>()`, `Replay(type)` or `Replay(id)` returns the `JobId` of a command job: it asks the observer to replay, then waits until the replay job is no longer outstanding. `JobId.NotSet` means the reactor is not replayable or the command job could not be started; check for it before waiting. Wait with `var job = await eventStore.Jobs.WaitTillJobCompletesOrIsDeleted(jobId, timeout);` (`Cratis.Chronicle.Jobs`). A successful command job is removed, so `null` is the usual result, but it only means the job record is gone, not that the replay succeeded. A returned job whose `Status` is not `CompletedSuccessfully` means the command failed, for example because the observer is quarantined or has no connected client; the replay may still have started, so inspect the state rather than assume nothing ran. `WaitTillJobProgressCompleted` needs the job record, so it can time out with `TaskCanceledException` if the job is removed before a poll sees it complete. Whatever the wait returns, confirm the outcome: `GetStateFor<CarrierNotice>()` no longer reports `RunningState` `Replaying`, the effects are present and `GetFailedPartitionsFor` shows no new failures. `FastForward<CarrierNotice>()` or `FastForward(id)` returns a `FastForwardResult` whose `Outcome` is `Accepted` when the call succeeds: the request was queued and the reactor has not moved yet. No job ID is returned and both position fields are unavailable. Jobs in `eventStore.Jobs.GetJobs()` labelled `FastForward <reactor ID>` can belong to earlier or later requests, so a matching job does not report this request's outcome; verify the observer instead. When the queued work runs, it reads the tail at that moment, skips every unhandled event up to it without invoking the handler and discards the failed partitions; it abandons that work and is not failure repair. It changes nothing for a replaying, retired or removed observer (fast-forward a replaying one after the replay completes), on an empty sequence (the cursor and failed partitions stay as they were) or when the observer is already past the tail with no partitions catching up or failed. When it did run, `GetStateFor` shows `NextEventSequenceNumber` advanced past the skipped range and the failures that existed before are gone; events appended later are delivered normally and can fail again.
|
|
38
38
|
|
|
39
39
|
## When the input is a view change
|
|
40
40
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Handle a committed event in C#
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- One handler per event type
|
|
6
|
+
- Configure the subscription
|
|
7
|
+
- Event context
|
|
8
|
+
- Register without discovery
|
|
9
|
+
- Replay and returned work
|
|
10
|
+
- Common mistakes
|
|
11
|
+
|
|
3
12
|
Reference `Cratis.Chronicle` in the connected backend. Write handlers as public instance methods on a concrete `IReactor` in a discovered assembly, with a registered event type as the first parameter. Names below are illustrative. Register application dependencies such as `services.AddScoped<ICarrier, Carrier>();` in the host; Chronicle discovers the reactor, not the carrier's receipt protocol.
|
|
4
13
|
|
|
5
14
|
```csharp
|
|
@@ -44,12 +53,36 @@ The client binds one handler per event type, and separately one `[Replay]` handl
|
|
|
44
53
|
- Never combine `[EventStore]`/`FromEventStore` with an explicit sequence; registration refuses it.
|
|
45
54
|
- `options.EventGenerationDelivery = EventGenerationDelivery.Pinned` requests the declared generation rather than compatibility delivery; this is a client option, not a handler attribute.
|
|
46
55
|
- `[Tag("shipping", "operations")]` or `[Tags("shipping", "operations")]` labels the reactor for inspection. Repeat `[FilterEventsByTag("urgent")]` with different values for an any-tag input filter. `[EventSourceType("parcel")]` and `[EventStreamType("dispatch")]` further restrict delivery by append metadata; these restrictions intersect. To filter by a declared route instead, `[FromEventSource<Parcel>("Dispatch")]` (`Cratis.Chronicle.EventSources`) sets both from an `IEventSource` definition and one stream it declares; explicit `[EventSourceType]`/`[EventStreamType]` may only repeat those values. An unregistered source or undeclared stream fails registration. `[EventStreamId("notifications")]` routes outputs, not inputs.
|
|
47
|
-
- Prefer constructor injection for infrastructure. Handler parameters can also receive services, `EventContext` (e.g. `context.EventSourceId`, `context.SequenceNumber
|
|
56
|
+
- Prefer constructor injection for infrastructure. Handler parameters can also receive services, `EventContext` (e.g. `context.EventSourceId`, `context.SequenceNumber`; all members under Event context below), `ReactorDelivery`, or related read models. By default every read-model parameter is loaded with the event's `EventSourceId` as its key, so `Task Notify(ParcelDispatched fact, Depot depot)` looks `Depot` up by the parcel's source ID. The lookup uses only that key value: for a model keyed by something else you get whatever is stored under that value; a materialized model returns null when its sink has no row for it. A stream-scoped model (`[EventStream<TSource>("stream")]`) refuses key-only lookup, so read it with `IReadModels.GetInstanceById<T>(eventSourceId, eventStreamId)` instead of a parameter. To use another key implement `ICanResolveReadModelKey` on the reactor. `Resolve` runs for each read-model parameter and receives the fact and context but not the parameter type, so handle every event the reactor observes: `public ReadModelKey Resolve(object fact, EventContext context) => fact switch { ParcelDispatched dispatched => dispatched.DepotId, _ => (ReadModelKey)context.EventSourceId };`. All read-model parameters of one handler get the same key; read a differently keyed model with `IReadModels.GetInstanceById<T>(key)`. A materialized read model is read from its sink and may not yet include the event being handled; don't treat it as part of the triggering fact. Avoid mutable fields across events.
|
|
48
57
|
- For tracing, implement `IReactorMiddleware.BeforeInvoke(EventContext, object)` and `AfterInvoke(EventContext, object)` returning `Task`; override the overloads with leading `ReactorId` when tagging spans by observer. Middleware surrounds individual invocations, not a cross-partition transaction.
|
|
49
58
|
|
|
59
|
+
## Event context
|
|
60
|
+
|
|
61
|
+
`EventContext` (`Cratis.Chronicle.Events`) describes the delivered event. Take it as a handler parameter and read these values from it; do not copy them into the event payload.
|
|
62
|
+
|
|
63
|
+
| Member | Carries |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `EventType` | The event type: its `Id` and the `Generation` of the payload the handler receives. Under compatibility delivery this is the generation the handler declares, which can differ from the one the event was appended in. |
|
|
66
|
+
| `AppendedGeneration` | The generation the event was appended in, whichever generation is delivered; `null` when unknown. |
|
|
67
|
+
| `EventSourceType`, `EventSourceId` | The type and identity of the event source. |
|
|
68
|
+
| `EventSource` | The name of the event source definition the event was appended through; `EventSourceName.NotSet` when it was appended without one. |
|
|
69
|
+
| `EventStreamType`, `EventStreamId` | The stream within the event source. |
|
|
70
|
+
| `SequenceNumber` | The event's position in its event sequence. |
|
|
71
|
+
| `Occurred` | When the event occurred (`DateTimeOffset`). |
|
|
72
|
+
| `EventStore`, `Namespace` | The event store and namespace the event belongs to. |
|
|
73
|
+
| `CorrelationId` | The correlation the event was appended under. Not a delivery receipt: use `ReactorDelivery`. |
|
|
74
|
+
| `Causation` | The chain of causes that led to the event. |
|
|
75
|
+
| `CausedBy` | The identity that caused the event. |
|
|
76
|
+
| `Tags`, `NamedTags` | The plain tags and the named tags on the event. |
|
|
77
|
+
| `Subject`, `SubjectIsEventSourceId` | The compliance subject, which defaults to the event source ID when the event was appended without an explicit subject. `SubjectIsEventSourceId` is `true` when the two are equal. |
|
|
78
|
+
| `CompensationFor` | The sequence number of the event this one compensates for; `null` when it is not a compensation. |
|
|
79
|
+
| `Hash` | A hash Chronicle stored for the event. It does not change with the delivered generation, so do not compare it with a hash of the payload the handler receives. |
|
|
80
|
+
| `ErasedProperties` | Always empty in a reactor delivery: only an explicit erased-path read of an event sequence fills it. Do not use it in a handler to decide whether content was erased. |
|
|
81
|
+
| `ObservationState` | Delivery state set by Chronicle. Do not branch on it; use `[Replay]` and `[OnceOnly]` (see Replay and returned work). |
|
|
82
|
+
|
|
50
83
|
## Register without discovery
|
|
51
84
|
|
|
52
|
-
For explicitly selected artifacts use `options.ExplicitArtifacts.RegisterReactor<CarrierNotice>()` (or the `Type` overload). In manual startup `await reactors.Discover(); await reactors.Register();` discovers then registers all; `Register<CarrierNotice>()` or `Register(typeof(CarrierNotice))` registers one. Do not repeat the host's automatic registration.
|
|
85
|
+
For explicitly selected artifacts use `options.ExplicitArtifacts.RegisterReactor<CarrierNotice>()` (or the `Type` overload). Discovery never finds a class that does not implement `IReactor` by its method signatures; nominate it this way or register it in manual startup with `Register(typeof(CarrierNotice))` below. In manual startup `await reactors.Discover(); await reactors.Register();` discovers then registers all; `Register<CarrierNotice>()` or `Register(typeof(CarrierNotice))` registers one. Do not repeat the host's automatic registration.
|
|
53
86
|
|
|
54
87
|
```csharp
|
|
55
88
|
var reactors = eventStore.Reactors;
|
|
@@ -64,9 +97,9 @@ For runtime schemas use `await reactors.Register(id, b => b.WithEventType(eventT
|
|
|
64
97
|
|
|
65
98
|
## Replay and returned work
|
|
66
99
|
|
|
67
|
-
`[OnceOnly]` on the reactor excludes the whole observer from replay; on a method it skips that method during replay. Neither prevents retry. To substitute replay behavior, add e.g. `[Replay] public Task Rebuild(ParcelDispatched fact) => cache.Restore(fact);`. A replay method may also bind a type without a live handler. Otherwise ordinary replayable handlers run. For lifecycle callbacks implement `ICanBeNotifiedWhenReplay` (`Task BeginReplay()`, `Task EndReplay()`) or `ICanBeNotifiedWhenPartitionReplayed` (`Task BeginReplayPartition(Partition partition)`, `Task EndReplayPartition(Partition partition)`).
|
|
100
|
+
`[OnceOnly]` on the reactor excludes the whole observer from replay; on a method it skips that method during replay. Neither prevents retry. To substitute replay behavior, add e.g. `[Replay] public Task Rebuild(ParcelDispatched fact) => cache.Restore(fact);`. A replay method may also bind a type without a live handler. Otherwise ordinary replayable handlers run. For lifecycle callbacks implement `ICanBeNotifiedWhenReplay` (`Task BeginReplay()`, `Task EndReplay()`) or `ICanBeNotifiedWhenPartitionReplayed` (`Task BeginReplayPartition(Partition partition)`, `Task EndReplayPartition(Partition partition)`). Only reactor classes receive these: a reactor defined with the builder or registered with a delegate gets none. Each notification runs in its own dependency scope. By default it also gets a new reactor instance, so a field set in `BeginReplay` is visible neither to the handlers nor to `EndReplay`; a reactor registered in the container as a singleton is the same instance each time. Do not rely on reactor fields either way: keep such state in a singleton service, or in storage outside the process when it must survive a restart or span instances.
|
|
68
101
|
|
|
69
|
-
See [Returned events and command outcomes](csharp-outputs.md) for derived facts, routing, guarded appends and custom return values. If the activation is not domain history, [record an occurrence](csharp-occurrences.md) instead. See [Pages and recovery](csharp-pages.md) for batch processing, capacity, waits, repair and view-change reactions.
|
|
102
|
+
See [Returned events and command outcomes](csharp-outputs.md) for derived facts, routing, guarded appends and custom return values. If the activation is not domain history, [record an occurrence](csharp-occurrences.md) instead. See [Pages and recovery](csharp-pages.md) for batch processing, capacity, waits, repair, starting and awaiting a replay, and view-change reactions.
|
|
70
103
|
|
|
71
104
|
## Common mistakes
|
|
72
105
|
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# React to a committed fact in Elixir
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Register a typed handler
|
|
6
|
+
- Select delivery and replay behavior
|
|
7
|
+
- Return derived events
|
|
8
|
+
- Work in pages
|
|
9
|
+
- Inspect and recover
|
|
10
|
+
- React to a change in a view instead
|
|
11
|
+
- Not supported in this SDK
|
|
12
|
+
|
|
3
13
|
## Register a typed handler
|
|
4
14
|
|
|
5
15
|
Names are illustrative. In the Mix service using `:cratis_chronicle`, define the input contract and a reactor module:
|
|
@@ -31,6 +41,7 @@ Add `{Cratis.Chronicle.Client, connection_string: endpoint, event_store: "shippi
|
|
|
31
41
|
- Compatibility delivery upgrades to the handled generation. Set `generation_delivery: :pinned` to bind to the declared generation; do not handle multiple generations of the same type ID in that reactor. Overrides client `event_generation_delivery:`. `ctx.appended_generation` is zero when unknown.
|
|
32
42
|
- Read routing and provenance from context: e.g. `ctx.event_source_id`, `ctx.sequence_number`, `ctx.event_stream_id`, `ctx.event_store`, `ctx.namespace`, `ctx.subject`, `ctx.tags`, `ctx.correlation_id`, `ctx.caused_by` and `ctx.causation`. Do not use correlation ID as a delivery receipt.
|
|
33
43
|
- `middleware: [Shipping.Trace]` wraps per-event handlers, not batch functions. Implement `@behaviour Cratis.Chronicle.Middleware` and `def call(event, ctx, next), do: next.(event, ctx)` around the tracing work; return the downstream result. Global `config :cratis_chronicle, middleware: [Service.Trace]` wraps reactor-local middleware.
|
|
44
|
+
- A handler must answer each delivered batch within the kernel's subscriber timeout, `observers.subscriberTimeout`: configured as 30 seconds unless the kernel sets another value, and 5 seconds on the development kernel image. That is not a guaranteed window: live delivery is also capped at five seconds below the kernel's cluster response timeout, so a live batch can time out sooner than the configured value. When the wait elapses the batch is recorded as a failed partition and retried with backoff, while the handler may still finish its work, so the effect can repeat. Keep handlers fast, keep effects idempotent, and move slow work out of the handler. The option is described in `cratis-chronicle-deploy-kernel`, `references/kernel-options.md`.
|
|
34
45
|
|
|
35
46
|
## Return derived events
|
|
36
47
|
|
|
@@ -100,7 +100,7 @@ For best-effort notifications rather than durable event processing, implement `i
|
|
|
100
100
|
|
|
101
101
|
## Inspect and recover
|
|
102
102
|
|
|
103
|
-
With `store` a `BlockingEventStore`, `FailedPartitionsJavaBridge.getFor(store.unwrap().getFailedPartitions(), DispatchNotices.class)` (`io.cratis.chronicle.java`) lists the reactor's failed partitions. Fix the cause, then `FailedPartitionsJavaBridge.retry(store.unwrap().getFailedPartitions(), DispatchNotices.class, partition)`. Only to deliberately abandon the backlog, `ObserversJavaBridge.fastForward(store.unwrap().getObservers(), DispatchNotices.class)`
|
|
103
|
+
With `store` a `BlockingEventStore`, `FailedPartitionsJavaBridge.getFor(store.unwrap().getFailedPartitions(), DispatchNotices.class)` (`io.cratis.chronicle.java`) lists the reactor's failed partitions. Fix the cause, then `FailedPartitionsJavaBridge.retry(store.unwrap().getFailedPartitions(), DispatchNotices.class, partition)`. Only to deliberately abandon the backlog, `ObserversJavaBridge.fastForward(store.unwrap().getObservers(), DispatchNotices.class)` asks the kernel to move the reactor to the tail. An `Accepted` `FastForwardResult` means the request was queued and the reactor has not moved yet; check the failed partitions and effects afterwards. This skips work rather than retrying it. The class overloads resolve the declared ID and sequence; each call also accepts the observer ID as a string, with an event sequence ID as an extra last argument for `retry` and `fastForward`.
|
|
104
104
|
|
|
105
105
|
## Definition errors
|
|
106
106
|
|
|
@@ -118,6 +118,7 @@ Registration rejects a mis-shaped reactor; fix the class instead of catching.
|
|
|
118
118
|
|
|
119
119
|
## Not supported in this SDK
|
|
120
120
|
|
|
121
|
+
- No `@EventLog` or `@EventStore` annotation: a reactor without an explicit sequence already reads the event log, and a source store is never inferred. `@ContextKey` can be applied but nothing reads it, so it changes no key.
|
|
121
122
|
- No reactor generation pin, automatic source-store inbox selection, output-stream annotation, dynamic typed builder or raw delegate subscription. Register compatible typed handlers, select the local sequence explicitly, and wrap routed outputs.
|
|
122
123
|
- No per-event activation option or dedicated model-key annotation. Keep services stateless; resolve a different key explicitly.
|
|
123
124
|
- No built-in receiver delivery key, effect epoch, guarded multi-target reactor return, general custom result interpreter or occurrence/receipt reactor contract. Use receiver-owned receipts; send decisions requiring concurrency checks to the owning write path instead of returning commands or unguarded facts.
|
|
@@ -110,6 +110,7 @@ Registration rejects a mis-shaped reactor; fix the class instead of catching.
|
|
|
110
110
|
|
|
111
111
|
## Not supported in this SDK
|
|
112
112
|
|
|
113
|
+
- No `@EventLog` or `@EventStore` annotation: a reactor without an explicit sequence already reads the event log, and a source store is never inferred. `@ContextKey` can be applied but nothing reads it, so it changes no key.
|
|
113
114
|
- No generation-pinning reactor option, automatic external-store selection, dynamic callback builder or raw delegate registration: register compatible typed methods on the intended sequence; cancel the registration job to stop listening.
|
|
114
115
|
- No per-event activation switch, per-reactor page limits or partition parallelism setting: keep instances stateless and bound downstream work. No dedicated readiness await: inspect observer state with a timeout.
|
|
115
116
|
- No built-in receiver delivery key, automatic output epoch, guarded multi-target reactor return or custom return interpreter: deduplicate at the receiver, version effects deliberately, and move guarded decisions into an explicit write workflow. For operational work without a fact use an application-owned durable queue with receipts rather than returning an arbitrary object.
|
|
@@ -18,7 +18,7 @@ Python has no usable Chronicle client: a Python program sends the intent through
|
|
|
18
18
|
1. Declare one immutable, past-tense fact with just the data it carries; model an optional fact as its own event type rather than an optional member. Register its type in the writer's store. Start at the first generation; keep the type ID stable across renames.
|
|
19
19
|
2. Select the intended namespace and its event log. Append the fact with the stable, non-personal source ID of the affected instance, not a newly generated ID for each write.
|
|
20
20
|
3. Inspect the outcome. On acceptance, retain the assigned position. On refusal, distinguish schema or constraint violations, concurrency conflicts and other errors; do not report success. The kernel validates content against the type's registered schema and reports a mismatch as a schema constraint violation naming the failing path, not as an error; nothing is appended. If the decision depended on state that changed, decide again rather than resubmitting the stale fact.
|
|
21
|
-
4. A lost response is **not a refusal**. Reconcile the original attempt in the same history
|
|
21
|
+
4. A lost response is **not a refusal**. Reconcile the original attempt in the same history. Retry directly only if every entry of the original append was keyed, reusing its keys; an unkeyed entry is not deduplicated and is appended again if the first attempt committed. Correlation alone does not deduplicate. Observer timeout does not undo storage.
|
|
22
22
|
|
|
23
23
|
## Capability catalog
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ Not every SDK exposes every entry; your language reference states what is not su
|
|
|
27
27
|
**Declaration and routing**
|
|
28
28
|
|
|
29
29
|
- **Event identity:** register a schema under its type ID; pin the ID explicitly for shared contracts, collisions or renames.
|
|
30
|
-
- **Payload shapes:** each SDK defines which field types an event may hold and how identifiers, dates, enums, geospatial and polymorphic values are stored. Use the SDK's typed values rather than strings or hand-written equivalents; an unsupported shape fails at registration, not at append. Treat an existing enum's member order and values as part of the contract: add new members at the end. The registered schema is generated from a type's members, not from its serializer: a type whose own serializer writes a different shape (such as a single string) must declare the shape it writes (C#, Kotlin and Java; Go refuses a type with its own JSON or text marshaler at registration, and TypeScript and Elixir have no declaration; see your language reference). The declaration changes only the schema, not serialization, and keeps personal-data marking and nullability; keep the serializer.
|
|
30
|
+
- **Payload shapes:** each SDK defines which field types an event may hold and how identifiers, dates, enums, geospatial and polymorphic values are stored. Use the SDK's typed values rather than strings or hand-written equivalents; an unsupported shape fails at registration, not at append. Treat an existing enum's member order and values as part of the contract: add new members at the end. Never hold money or other exact amounts in floating point. Where the SDK has a decimal type (C# `decimal`, Kotlin and Java `BigDecimal`), use it: the kernel keeps a decimal a decimal through storage, projections and read models and never converts it to binary floating point, but the storage provider limits the range and scale a read-model column holds. Where it has none (TypeScript `number` and Go fractional types are floating point), hold exact integer minor units within the SDK's supported integer range. The registered schema is generated from a type's members, not from its serializer: a type whose own serializer writes a different shape (such as a single string) must declare the shape it writes (C#, Kotlin and Java; Go refuses a type with its own JSON or text marshaler at registration, and TypeScript and Elixir have no declaration; see your language reference). The declaration changes only the schema, not serialization, and keeps personal-data marking and nullability; keep the serializer.
|
|
31
31
|
- **Generation:** retain compatible changes within a generation; pair incompatible shapes with migrations (`cratis-chronicle-evolve-event`).
|
|
32
32
|
- **Source ID:** use a typed identifier where available to keep instance keys distinct from stream IDs, subjects and type names.
|
|
33
33
|
- **Declared source:** register a named source definition with optional description and concurrency dimensions; inspect definitions when resolving a route dynamically.
|
|
@@ -53,7 +53,7 @@ Not every SDK exposes every entry; your language reference states what is not su
|
|
|
53
53
|
- **Tag enrichment (C# only):** use ambient scopes or registered enrichers for additive cross-cutting named tags, not payload mutation. Applied on every append path (including batches and units of work, resolved when staged) and merged without duplicates; enrichers are pure, synchronous and additive.
|
|
54
54
|
- **Audience (C# only):** mark the event type to make an audience mandatory (a missing audience fails the append); mark a member to supply the value; an ambient audience reaches only outbox appends and types that require an audience; an audience filter is not authorization.
|
|
55
55
|
- **Concurrency guards:** supply the expected history scope (per source for a batch) when an append depends on an earlier read; do not assume plain append protects that read (`cratis-chronicle-protect-decision`).
|
|
56
|
-
- **Keyed append (C# only):** supply a stable operation key
|
|
56
|
+
- **Keyed append (C# only):** supply a stable operation key and, on retry, reuse the same key, route and content. For one event, key the append. For a single-source batch, one batch key is expanded into a key per position, so also keep the batch's order. For a mixed-source batch, give every entry its own stable key. A per-entry key identifies its entry regardless of position, but still keep the original order on retry: if the first attempt did not commit, the retry decides the stored order. If any entry is unkeyed, reconcile before retrying, because unkeyed entries are not deduplicated. Distinguish already accepted from an idempotency conflict, including unverifiable content.
|
|
57
57
|
- **Prepare:** capture serialization once for subsequent append; use a prepared batch when the exact enrolled entries must be preserved.
|
|
58
58
|
- **Verify stored content:** compare a prepared payload at the suspected position; unavailable evidence after revision or erasure is neither equality nor proof of absence.
|
|
59
59
|
- **Unit of work:** stage through the transactional sequence, then have one owner commit and check the final outcome or roll back before completion. Staging is not persistence; an immediate append is not rolled back with the unit.
|
package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-coordination.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Coordinate C# writes
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Scope causation, correlation and authorship around a direct append
|
|
6
|
+
- Classify or enrich
|
|
7
|
+
- Build, retry or verify
|
|
8
|
+
- Stage and complete
|
|
9
|
+
- Observe the outcome
|
|
10
|
+
|
|
11
|
+
## Scope causation, correlation and authorship around a direct append
|
|
4
12
|
|
|
5
13
|
In a configured ASP.NET Core host inject `ICausationManager` (`Cratis.Chronicle.Auditing`). The ordinary append uses its ambient chain; dispose the scope to restore the previous chain.
|
|
6
14
|
|
|
@@ -12,6 +20,10 @@ using (causationManager.BeginScope("packing", new System.Collections.Generic.Dic
|
|
|
12
20
|
}
|
|
13
21
|
```
|
|
14
22
|
|
|
23
|
+
**Correlation.** An append without `correlationId:` takes the ambient correlation ID, which flows with the async execution context of the request or job. It does not cross a queue message, another process, or a thread started without that context: carry the value in the message and pass it as `correlationId:` on the append. To set the ambient value at a custom entry point, inject `ICorrelationIdModifier` (`Cratis.Execution`) and call `Modify(correlationId)` before the first append.
|
|
24
|
+
|
|
25
|
+
**Authorship.** Who caused an event is derived from the caller, not chosen by it. When the connection is authenticated as a signed-in Chronicle user, the kernel records that user as `CausedBy` for append, batch append, keyed append, revision and redaction, and ignores a supplied identity together with its on-behalf-of chain. An application connecting with client credentials may supply the end user and an on-behalf-of chain, and the kernel records the application itself only when the append carries no identity at all. The .NET client always sends one: its identity provider's current identity. Which identity that is depends on the provider. The base provider (`BaseIdentityProvider`) returns what `SetCurrentIdentity` set and `Identity.System` when nothing was set: outside a web request, set the end user on it before appending, otherwise the event is recorded as caused by the system identity, not by the application. The ASP.NET Core provider reads the request's `sub`, `name` and `preferred_username` claims instead, returns `Identity.NotSet` when all of them are missing, and does not use an identity set on it for an ordinary request: authenticate the request so the claims are present. Never rely on a supplied identity to attribute a write made under a user's own sign-in.
|
|
26
|
+
|
|
15
27
|
## Classify or enrich
|
|
16
28
|
|
|
17
29
|
```csharp
|
|
@@ -23,7 +35,7 @@ var result = await eventLog.AppendWithNamedTags(parcelId, assigned,
|
|
|
23
35
|
[new NamedTag("service", "express")], tags: ["priority"]);
|
|
24
36
|
```
|
|
25
37
|
|
|
26
|
-
Named tags are additive exact pairs, not replacements for plain `tags`. Use `AppendManyWithNamedTags` for a common batch label or `EventForEventSourceId.NamedTags` / `Tags` per entry. `[Audience]` has two roles. On the event type it makes an audience mandatory: appending that type without an `audience` tag, by any path (`Append`, `AppendMany`, outbox, unit of work), throws `MissingAudience` (`Cratis.Chronicle`); in a unit of work it throws when the event is added, not at commit. On a member (`[property: Audience]`) it only supplies the value from the payload and does not make an audience required. Use both when every event of the type must carry the value it holds. `using var audience = EventTags.Audience(region);` supplies the audience for appends inside the scope. Do not use audience selection as authorization.
|
|
38
|
+
Named tags are additive exact pairs, not replacements for plain `tags`. They need a kernel that supports them: an older kernel rejects the call with an `RpcException` whose status code is `Unimplemented` (a keyed append throws `IdempotentAppendsNotSupported` instead), and never drops the tags silently, so upgrade the kernel before the first named-tag append. Appends without named tags are unaffected. With SQL storage the table name `__cratis_named_tags` is reserved in each namespace database; the table Chronicle creates there is expected, but a conflicting table of that name that is not Chronicle's is detected when an event sequence is first migrated, and event-sequence operations in the namespace then fail with `NamedTagsTableCollision` until it is renamed. Use `AppendManyWithNamedTags` for a common batch label or `EventForEventSourceId.NamedTags` / `Tags` per entry. `[Audience]` has two roles. On the event type it makes an audience mandatory: appending that type without an `audience` tag, by any path (`Append`, `AppendMany`, outbox, unit of work), throws `MissingAudience` (`Cratis.Chronicle`); in a unit of work it throws when the event is added, not at commit. On a member (`[property: Audience]`) it only supplies the value from the payload and does not make an audience required. Use both when every event of the type must carry the value it holds. `using var audience = EventTags.Audience(region);` supplies the audience for appends inside the scope. Do not use audience selection as authorization.
|
|
27
39
|
|
|
28
40
|
Chronicle resolves each event's named tags in one step used by every append path (`Append`, `AppendMany`, unit-of-work staging), in this order: named tags already on the event (including call-site named tags), the ambient `EventTags.Scope` and an `[Audience]` property, then your `IEventTagEnricher`s; merged without duplicate name/value pairs. An ambient audience (`EventTags.Audience`, which is an `EventTags.Scope` for the audience tag) is stamped only on outbox appends and `[Audience]` types; other ambient pairs reach every event. Static `[Tag]` strings are plain tags: they are joined with call-site plain `tags` and de-duplicated separately, and enrichers neither see nor produce them. In a unit of work tags resolve when the event is added, not at commit. Enrichers are discovered automatically, resolved through dependency injection, all run for every event, and must be pure, synchronous and additive: they add tags and never remove or change existing ones. `EventTags.Scope(name, value)` flows with the async execution context until disposed, and nested scopes add up; open it with `using` where a request or background job starts. To change serialized content instead, provide additional event information:
|
|
29
41
|
|
|
@@ -79,6 +91,23 @@ if (!unit.IsSuccess) return; // inspect GetConstraintViolations(), GetConcurrenc
|
|
|
79
91
|
|
|
80
92
|
Staging is not storage. `Transactional.AppendWithNamedTags` and `AppendManyWithNamedTags` retain batch labels. Ordinary `eventLog.Append` is not rolled back. Do not start or commit a second unit when the host owns one.
|
|
81
93
|
|
|
94
|
+
- **Boundary:** a unit belongs to the event store and namespace it was begun on, and `Commit()` sends everything staged as one atomic append to one event sequence. Stage through a single sequence per unit; once an ordered batch (below) or a decision read takes part, staging for another sequence throws `UnitOfWorkCannotSpanEventSequences`. Calls to other services, other databases and immediate appends are outside the unit: rollback does not undo them.
|
|
95
|
+
- **Completion:** a constraint or concurrency rejection does not throw. `Commit()` completes the unit without appending anything and `IsSuccess` is false, so always check it. `Commit()` throws in two ways. A commit that is not admitted (the unit is already completed, or a protected unit is committed by something other than its owner) throws and leaves the unit as it was: nothing was appended and no completion ran. Any failure after the commit was admitted throws as well and completes the unit, whether or not an append was sent: a local failure such as a serialization error sends nothing, while after a transport error it is unknown whether the events were stored. Do not retry on the same unit; when the failure may have reached the kernel, reconcile before retrying. A completed unit cannot be committed or rolled back again (`UnitOfWorkIsAlreadyCommitted`, `UnitOfWorkIsAlreadyRolledBack`): in cleanup code check `unit.IsCompleted` before calling `Rollback()`, or rely on `using`, which rolls back an ordinary unit that was never completed and does nothing for a completed one. An open protected unit is different: disposing it throws `ProtectedUnitOfWorkRequiresOwner`, because only its owner may complete it. Disposing while a commit is in flight also does nothing; the commit finishes the unit.
|
|
96
|
+
- **After completion:** continue after `await unit.Commit()`. `unit.TryGetLastCommittedEventSequenceNumber(out var last)` returns true and the highest position the commit appended, false when nothing was appended. Do not call `unit.OnCompleted(callback)` on a unit begun through `UnitOfWorkManager`: a unit holds one completion callback and the manager uses it to stop tracking the unit, so setting your own replaces it.
|
|
97
|
+
|
|
98
|
+
When one decision spans several event sources and its events must be stored in an exact cross-source order under an explicit guard, stage an ordered batch. Prefer a decision read (`cratis-chronicle-protect-decision`), which derives the guard from what was read; use this alternative only when the code already holds the exact position it decided on:
|
|
99
|
+
|
|
100
|
+
```csharp
|
|
101
|
+
var guard = new ConcurrencyScope(observedTail, EventStreamType: "authorization");
|
|
102
|
+
unit.AddEvents(EventSequenceId.Log,
|
|
103
|
+
[new EventForEventSourceId(fromAccountId, debited), new EventForEventSourceId(toAccountId, credited)],
|
|
104
|
+
[new(new EventSourceId("authorization-history"), guard)]);
|
|
105
|
+
await unit.Commit();
|
|
106
|
+
if (!unit.IsSuccess) return;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`AddEvents` copies the events and scopes when it is called, so changing the collections afterwards has no effect, and nothing is sent before `Commit()`, which appends them in the given order together with everything else staged in the unit. A scope that narrows by event source ID is keyed by that source ID; a scope that does not (as above) may use any non-blank label. On conflict, read again and decide again.
|
|
110
|
+
|
|
82
111
|
With Chronicle ASP.NET Core unit-of-work middleware enabled, use `app.MapPost("/parcels", handler).WithUnitOfWork()` to commit before the minimal API result is returned. For MVC/Razor Pages set `ChronicleAspNetCoreOptions.UnitOfWork.ReportFailuresBeforeResponseStarts` to true (default false). For custom result handling, obtain `IUnitOfWorkCompletionFeature` from `HttpContext.Features`, await `CommitAsync()` before starting the response and inspect the returned unit. Require the feature if persistence is promised.
|
|
83
112
|
|
|
84
113
|
## Observe the outcome
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Inspect, correct and bootstrap C# history
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Read without mutating
|
|
6
|
+
- Correct, close or copy
|
|
7
|
+
- Import historical entries
|
|
8
|
+
- Seed repeatable startup history
|
|
9
|
+
|
|
3
10
|
## Read without mutating
|
|
4
11
|
|
|
5
12
|
```csharp
|
|
@@ -18,7 +25,7 @@ var page = await eventLog.GetPage(EventSequencePageRequest.Forward(null, 50, fil
|
|
|
18
25
|
var latest = await eventLog.GetLatest(20, filter);
|
|
19
26
|
```
|
|
20
27
|
|
|
21
|
-
Source/type history accepts stream type, stream ID and source type. Tail reads also accept those dimensions and event types; `GetTailSequenceNumberWithCancellation(cancellationToken, shipmentId)` supports cancellation. On a paged read consume `page.Events`; while `page.HasMore`, use `page.Next` with the same direction and filter. The request's count is the page size and must be 1–1000: a larger value throws `ArgumentOutOfRangeException` and is not clamped. To read more, including a full export, loop on `page.Next` while `page.HasMore`, keeping the same direction, filter and `Until` bound. Use `Backward` for reverse navigation, `Until` on the request for an end bound. Filter by source ID/type, stream ID/type, event types and plain tags. For a missing event check the sequence and namespace as well as every filter before writing again.
|
|
28
|
+
Sequence numbers follow append order, not business time: an event appended with an earlier `occurred:` still gets the next number, so sort by `Occurred` when business time matters. Source/type history accepts stream type, stream ID and source type. The multi-position `GetMetadataAt(positions)` accepts at most 500 positions per call, duplicates included; more throws `TooManyEventLocators`, so read a longer list in chunks. Positions without an event are left out of the result. Tail reads also accept those dimensions and event types; `GetTailSequenceNumberWithCancellation(cancellationToken, shipmentId)` supports cancellation. On a paged read consume `page.Events`; while `page.HasMore`, use `page.Next` with the same direction and filter. The request's count is the page size and must be 1–1000: a larger value throws `ArgumentOutOfRangeException` and is not clamped. To read more, including a full export, loop on `page.Next` while `page.HasMore`, keeping the same direction, filter and `Until` bound. Use `Backward` for reverse navigation, `Until` on the request for an end bound. Filter by source ID/type, stream ID/type, event types and plain tags. For a missing event check the sequence and namespace as well as every filter before writing again.
|
|
22
29
|
|
|
23
30
|
## Correct, close or copy
|
|
24
31
|
|
|
@@ -28,7 +35,7 @@ Normally append a new business fact. To link a reversal to an original without r
|
|
|
28
35
|
var reversal = await eventLog.Compensate(position, new PackingCancelled("Shipment cancelled"));
|
|
29
36
|
```
|
|
30
37
|
|
|
31
|
-
Pass no event source: the compensation takes the original's source, stream and subject, and the original is never changed. Check `reversal.IsSuccess`; a rejected compensation reports `AppendError.CompensatedEventNotFound` (no event at that position) or `AppendError.EventTypeDoesNotCompensateEventType` (the type is not declared for the original's type) in `reversal.Errors`. `correlationId`, `tags` and `occurred` can describe the correction. Observers and reducers receive the compensation as an ordinary event and read the original's position from `context.CompensationFor` (`EventSequenceNumber?`, null for other events); never copy the sequence number into the payload. Appending a compensation changes no read model and reverses no external action by itself: handle the compensating type in every projection, reducer or reactor that must apply the reversal. For mistaken recorded content rather than a later decision use `await eventLog.Revise(position, new ShipmentPacked(correctCount));`.
|
|
38
|
+
Pass no event source: the compensation takes the original's source, stream and subject, and the original is never changed. Check `reversal.IsSuccess`; a rejected compensation reports `AppendError.CompensatedEventNotFound` (no event at that position) or `AppendError.EventTypeDoesNotCompensateEventType` (the type is not declared for the original's type) in `reversal.Errors`. `correlationId`, `tags` and `occurred` can describe the correction. Observers and reducers receive the compensation as an ordinary event and read the original's position from `context.CompensationFor` (`EventSequenceNumber?`, null for other events); never copy the sequence number into the payload. Chronicle does not prevent a second compensation of the same original, and `Compensate` requests no concurrency check: when a fact may be reversed only once, enforce that yourself. A protected decision read cannot guard this call: `Compensate` is an immediate append, and inside a protected decision it is refused with `ImmediateAppendWhileReadsAreProtected`. Serialize the check and the append together per original position: one caller at a time looks for an existing compensation of that position and appends only when there is none. Serializing the appends alone still admits two compensations in turn. The compensating event does pass append constraints, but a constraint sees its payload and routing, not the position it compensates: use one only when the payload or the source already expresses the once-only rule, for example a unique value carried by the compensating type. Appending a compensation changes no read model and reverses no external action by itself: handle the compensating type in every projection, reducer or reactor that must apply the reversal. For mistaken recorded content rather than a later decision use `await eventLog.Revise(position, new ShipmentPacked(correctCount));`.
|
|
32
39
|
|
|
33
40
|
```csharp
|
|
34
41
|
var scope = ClosedStreamScope.ForEventSource(shipmentId);
|
|
@@ -45,7 +52,17 @@ await eventLog.Redact(shipmentId, new RedactionReason(reason), typeof(ShipmentPa
|
|
|
45
52
|
Guid copyJob = await eventLog.Copy(shipmentId, targetId, typeof(ShipmentPacked));
|
|
46
53
|
```
|
|
47
54
|
|
|
48
|
-
Redact by position **or** source; omit the type list for the entire source. Redaction keeps the position and replaces the content with an `EventRedacted` marker (`Cratis.Chronicle.Events`: `Reason`, `OriginalEventType`, `Occurred`, `CorrelationId`, `Causation`, `CausedBy`). Routing identifiers, tags and subject values remain on the event; the marker keeps the causation types, not their property values. Redaction does not reach earlier copies (backups, exports, events forwarded through an outbox) or derived read models by itself, and receiving the marker does not prove downstream cleanup succeeded, so confirm it before reporting an erasure complete. A reactor or reducer that already handles the original event type may add an `EventRedacted` handler to clean up what it derived: a reducer returns the sanitized model or `null` to remove it, a reactor asks the downstream system to delete its copy. Such an observer receives the marker only when the redacted event was of a type it handles, when it reads that position. That filter needs at least one ordinary event type: an observer handling nothing but `EventRedacted` receives the marker for every redaction in the sequence, whatever the original type, so check `OriginalEventType` there. Replayable observers of the affected events are also asked to replay, so review their external effects first.
|
|
55
|
+
Redact by position **or** source; omit the type list for the entire source. Redaction keeps the position and replaces the content with an `EventRedacted` marker (`Cratis.Chronicle.Events`: `Reason`, `OriginalEventType`, `Occurred`, `CorrelationId`, `Causation`, `CausedBy`). Routing identifiers, tags and subject values remain on the event; the marker keeps the causation types, not their property values. Redaction does not reach earlier copies (backups, exports, events forwarded through an outbox) or derived read models by itself, and receiving the marker does not prove downstream cleanup succeeded, so confirm it before reporting an erasure complete. A reactor or reducer that already handles the original event type may add an `EventRedacted` handler to clean up what it derived: a reducer returns the sanitized model or `null` to remove it, a reactor asks the downstream system to delete its copy. Such an observer receives the marker only when the redacted event was of a type it handles, when it reads that position. That filter needs at least one ordinary event type: an observer handling nothing but `EventRedacted` receives the marker for every redaction in the sequence, whatever the original type, so check `OriginalEventType` there. Replayable observers of the affected events are also asked to replay, so review their external effects first.
|
|
56
|
+
|
|
57
|
+
`Copy` starts a durable job that re-appends the source's events, in sequence order, under the target ID in the same sequence; pass event types to copy only those. Source and target must differ.
|
|
58
|
+
|
|
59
|
+
- Each copy is a new event with a new sequence number. It keeps the event type and generation, tags, stream and original occurred time; its audit context identifies the copy operation.
|
|
60
|
+
- Observers handle every copied event as an ordinary append, so review reactor side effects before starting.
|
|
61
|
+
- Personal data is protected again for the target. When the subject was the source ID, whether by default or assigned explicitly with that same value, the target ID becomes the subject; only a subject that differs from the source ID is kept.
|
|
62
|
+
- The job is not atomic: when a target append fails (for example on a unique constraint) the job reports the failure and the events already copied stay. Inspect the job and the target history before recovering.
|
|
63
|
+
- A resumed job does not duplicate what it already copied. A second `Copy` call is a new job and copies everything again.
|
|
64
|
+
|
|
65
|
+
Track the returned job, not just its submission.
|
|
49
66
|
|
|
50
67
|
## Import historical entries
|
|
51
68
|
|
|
@@ -83,4 +100,4 @@ public class PackingSeed : ICanSeedEvents
|
|
|
83
100
|
}
|
|
84
101
|
```
|
|
85
102
|
|
|
86
|
-
Discovered seeders declare globals or namespace-specific entries. `For<TEvent>` groups homogeneous events; `ForEventSource` accepts mixed types. Both accept `(id, streamType, streamId, events, eventSourceType?)`. `ForEvents(entries)` takes individual routes. Preserve membership, multiplicity and routing for idempotent reconciliation. For explicit bootstrap use `var seeds = store.CreateEventSeeding(); seeds.ForEvents(entries); await seeds.Register();`. Unscoped `For`/`ForEventSource`/`ForEvents` entries are global: the kernel applies them to every existing namespace and every namespace created later. Chronicle does not distinguish development from production seeds, so gate sample data by build or runtime configuration and scope it with `ForNamespace(...)`. The globals from discovered seeders are the program's declaration, owned by `ChronicleOptions.ProgramIdentifier` (the entry assembly name when unset). Each startup replaces the stored declaration, even with an empty set, so removing or scoping a global seeder stops it reaching namespaces created afterwards; if a discovered seeder fails to activate or seed, the previous declaration stays and the next registration retries. Give each program sharing a store a distinct, stable `ProgramIdentifier`. Globals added explicitly through `eventStore.Seeding` or a `CreateEventSeeding()` buffer are append-only and stay stored. Neither path retracts events already appended to existing namespaces; those need separate, deliberate remediation. Verify the history even on successful registration: check server logs for a rejected seed batch and re-register corrected entries with a fresh buffer.
|
|
103
|
+
Discovered seeders declare globals or namespace-specific entries. `For<TEvent>` groups homogeneous events; `ForEventSource` accepts mixed types. Both accept `(id, streamType, streamId, events, eventSourceType?)`. `ForEvents(entries)` takes individual routes. Preserve membership, multiplicity and routing for idempotent reconciliation. For explicit bootstrap use `var seeds = store.CreateEventSeeding(); seeds.ForEvents(entries); await seeds.Register();`. Unscoped `For`/`ForEventSource`/`ForEvents` entries are global: the kernel applies them to every existing namespace and every namespace created later. Chronicle does not distinguish development from production seeds, so gate sample data by build or runtime configuration and scope it with `ForNamespace(...)`. The globals from discovered seeders are the program's declaration, owned by `ChronicleOptions.ProgramIdentifier` (the entry assembly name when unset). Each startup replaces the stored declaration, even with an empty set, so removing or scoping a global seeder stops it reaching namespaces created afterwards; if a discovered seeder fails to activate or seed, the previous declaration stays and the next registration retries. Give each program sharing a store a distinct, stable `ProgramIdentifier`. Globals added explicitly through `eventStore.Seeding` or a `CreateEventSeeding()` buffer are append-only and stay stored. Neither path retracts events already appended to existing namespaces; those need separate, deliberate remediation. Seeds are appended in batches of 100 and a batch is validated as a whole: one constraint violation leaves every entry of that batch unseeded, registration still succeeds, and the client is not told. Verify the history even on successful registration: check server logs for a rejected seed batch and re-register corrected entries with a fresh buffer. Global seeds reach a newly created namespace asynchronously, with no guarantee that they arrive before the application's first write, so never let startup logic depend on seeded events being present. A buffer holding an entry with non-default routing needs a kernel that supports routed seeds: against an older kernel `Register()` throws `EventSeedingRoutingNotSupported` before sending anything, including the buffer's unrouted entries; upgrade the kernel, then register again.
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Record events with the C# client
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Record one fact
|
|
6
|
+
- Common mistakes
|
|
7
|
+
- Property types in events
|
|
8
|
+
- Route one decision
|
|
9
|
+
- Choose a conditional path
|
|
10
|
+
|
|
11
|
+
## Record one fact
|
|
12
|
+
|
|
3
13
|
Add `Cratis.Chronicle` to the writer project and connect to a running kernel. Names are illustrative. For local development:
|
|
4
14
|
|
|
5
15
|
```csharp
|
|
@@ -31,7 +41,7 @@ public record ShipmentPacked(int Cartons);
|
|
|
31
41
|
- Await the append and inspect `IsSuccess`; returning a result does not mean the fact was accepted.
|
|
32
42
|
- For related facts reuse the source ID, not a new GUID per append.
|
|
33
43
|
|
|
34
|
-
In a configured host inject `IEventLog` for the intended store/namespace; select a different sequence only deliberately (`store.GetEventSequence(id)`). The client discovers event types in its configured assemblies. The parameterless `[EventType]` is the default: the ID is the type name, at the first generation. Pin an explicit ID such as `[EventType("shipment-packed")]` only to keep a stored ID stable across a type rename, to resolve a name collision, or to match an ID another system publishes. For an incompatible shape pin the same ID with `generation: 2` and supply the migration (`cratis-chronicle-evolve-event`). `[Tombstone]` marks terminal meaning; it does not enforce closure. The Chronicle analyzer warns on a nullable property of an event type: record an optional fact as a separate event type instead.
|
|
44
|
+
In a configured host inject `IEventLog` for the intended store/namespace; select a different sequence only deliberately (`store.GetEventSequence(id)`). The client discovers event types in its configured assemblies. The parameterless `[EventType]` is the default: the ID is the type name, at the first generation. Pin an explicit ID such as `[EventType("shipment-packed")]` only to keep a stored ID stable across a type rename, to resolve a name collision, or to match an ID another system publishes. For an incompatible shape pin the same ID with `generation: 2` and supply the migration (`cratis-chronicle-evolve-event`). Each generation of a type ID is represented by exactly one type: two types that resolve to the same ID and generation make event type discovery fail at startup with `MultipleEventTypesWithSameIdFound`, before any append. Keep a superseded shape only as an earlier generation of the current type, with `[EventTypeGenerationFor<ShipmentPacked>(1)]` in place of `[EventType]`; never as a second `[EventType]` under the same ID. `[Tombstone]` marks terminal meaning; it does not enforce closure. The Chronicle analyzer warns on a nullable property of an event type: record an optional fact as a separate event type instead.
|
|
35
45
|
|
|
36
46
|
`IsSuccess` is true only when none of these holds. Branch on the cause rather than reporting one generic failure:
|
|
37
47
|
|
|
@@ -48,11 +58,19 @@ A refused append records nothing; use `SequenceNumber` only after success. `WasA
|
|
|
48
58
|
Chronicle describes each event type with a schema derived from the record, and uses it to read stored content back. Read models follow the same rules.
|
|
49
59
|
|
|
50
60
|
- **Default:** primitives, enums, nested records, collections, and `ConceptAs<T>` value types (`using Cratis.Concepts;`) (stored as their underlying primitive).
|
|
61
|
+
- **Money and other exact amounts:** `decimal`, or a concept wrapping one. Chronicle keeps the value a decimal through event storage, projections and read-model sinks and never converts it to binary floating point; `double` and `float` stay floating point. The storage provider still limits the range and scale a read-model column holds.
|
|
62
|
+
- **Never encode a fact as an absent member:** a nullable member holding `null` and a member missing from the stored content read back the same, as `null`, and a missing non-nullable member can read back as the type's default. Record "this did not happen" or "not yet known" as its own event type.
|
|
51
63
|
- **Location, route or area:** `Point` (longitude first, then latitude), `LineString` and `Polygon` from `Cratis.Geospatial`, e.g. `new Point(10.456, 42.123)` or `new Polygon(Shell: new LinearRing(points), Holes: [])`. A ring's first and last point are the same. Projections copy them with auto-mapping; never split a geometry into coordinate properties.
|
|
52
64
|
- **A type with its own JSON converter (edge case):** when the converter writes a different shape than the type's members, declare that shape with `[JsonSchemaType(typeof(string))]` (`Cratis.Chronicle.Schemas`) beside `[JsonConverter]`. It changes only the schema, not serialization, and keeps `[PII]` and nullability.
|
|
53
65
|
|
|
54
66
|
## Route one decision
|
|
55
67
|
|
|
68
|
+
Every event carries four routing values: event source type, event source ID, stream type and stream ID.
|
|
69
|
+
|
|
70
|
+
- **Default:** supply only the source ID; the other three take their defaults. This is right while every event of an entity shares one history and one guard.
|
|
71
|
+
- **Event source definition:** declare one when the same kind of entity is written from several places and the routing names must agree, or when the entity has parts with their own lifecycle or concurrency (a stream per month or process step, a stream that closes on its own, an observer for one stream). The definition supplies the source type and the stream type; the caller supplies the source ID and may supply a stream ID, which takes its default when omitted.
|
|
72
|
+
- **Free-form route (edge case):** pass the routing values directly only when the writer already owns a routing convention and no definition is wanted.
|
|
73
|
+
|
|
56
74
|
Use `Cratis.Chronicle.EventSources` to declare a route shared by writers:
|
|
57
75
|
|
|
58
76
|
```csharp
|
|
@@ -73,7 +91,7 @@ var mixed = await eventLog.AppendMany([
|
|
|
73
91
|
]);
|
|
74
92
|
```
|
|
75
93
|
|
|
76
|
-
These are alternatives. `
|
|
94
|
+
These are alternatives. `eventLog.Append<Shipment>(shipmentId, packed, eventStream: "Packing", eventStreamId: packingRunId)` is the generic form of `AppendThroughEventSource`, and `AppendMany<Shipment>(...)` of `AppendManyThroughEventSource`, which routes one source's batch through a definition. Append through the definition rather than repeating its source type or stream name as free-form strings at call sites. The definition's name and its stream names are stored on every event, so renaming one is a data change, not a refactoring: stored events keep the old name and observers that filter on the new name do not see them. A definition route is checked before anything is sent: `UnknownEventSource` (the definition is not registered in this store), `EventStreamDoesNotBelongToEventSource` (the named stream is not declared on it) and `EventRoutingContradictsEventSource` (an explicit `eventSourceType` or `eventStreamType` differs from the definition) are thrown, not returned in the result. Fix the route; do not drop the definition to make the append pass. Check `IsSuccess` before consuming `SequenceNumbers`. For a free-form route use `eventSourceType`, `eventStreamType`, `eventStreamId`; absent overrides use the default source type, all-stream type and default stream ID. Use `occurred:` for historical time (otherwise approximately append time), `correlationId:` for the operation, `subject:` to override the subject derived from a `[property: Subject]` member. Ordinary append records the current identity, not an import entry's `CausedBy`.
|
|
77
95
|
|
|
78
96
|
The default optimistic strategy isn't a guard for an earlier decision read (first append into an empty scope isn't checked by default). Pass `concurrencyScope: new ConcurrencyScope(observedTail, EventSourceId: shipmentId)` from `Cratis.Chronicle.EventSequences.Concurrency`, or `concurrencyScopes:` keyed by source for mixed entries. Re-decide after a conflict; see `cratis-chronicle-protect-decision`.
|
|
79
97
|
|
|
@@ -59,7 +59,7 @@ Prefer `seq.Append(ctx, source, correction)` for a later decision. `seq.Compensa
|
|
|
59
59
|
|
|
60
60
|
Erase with `seq.Redact(ctx, position, reason)` or `seq.RedactForEventSource(ctx, source, reason, assigned.Ref().ID)` (omit type IDs for the whole source). `seq.Copy(ctx, source, target, assigned.Ref().ID)` submits a job, not a completed copy; omit type IDs for all types.
|
|
61
61
|
|
|
62
|
-
`ReadSource` also accepts `SourceType`, `StreamType`, `StreamID`; empty or default route sentinels don't narrow. `seq.ReadFrom(ctx, position, eventsequences.FromFilter{SourceID: &source})` starts inclusively; optional `EventTypes` matches IDs across generations. Rows expose context, JSON, original and generational content and revisions when available. `seq.HasEvents(ctx, source)` tests existence. `seq.Next(ctx)` doesn't reserve a position. `seq.Tail(ctx, eventsequences.TailFilter{})` and `seq.TailForObserver(ctx, []events.TypeRef{assigned.Ref()})` return position, presence and error; absence isn't position zero.
|
|
62
|
+
`ReadSource` also accepts `SourceType`, `StreamType`, `StreamID`; empty or default route sentinels don't narrow. `seq.ReadFrom(ctx, position, eventsequences.FromFilter{SourceID: &source})` starts inclusively; optional `EventTypes` matches IDs across generations. Rows expose context, JSON, original and generational content and revisions when available. `seq.HasEvents(ctx, source)` tests existence. `seq.Next(ctx)` doesn't reserve a position. `seq.Tail(ctx, eventsequences.TailFilter{})` and `seq.TailForObserver(ctx, []events.TypeRef{assigned.Ref()})` return position, presence and error; absence isn't position zero. `events.First` is zero and a real position. `events.Unavailable`, `events.Max` and `events.BeforeFirst` are reserved values, not positions (the largest real position is `BeforeFirst - 1`, not `Max`); test with `IsActualValue()` before storing, comparing or passing a number on, and never use a reserved value as an exact expected position. For arithmetic use `Next()`, `Add(n)` and `Subtract(n)` and check the returned error: leaving the valid range returns `Unavailable` with `events.ErrSequenceNumberRange`, and a reserved value is returned unchanged, so `BeforeFirst.Next()` is not `First`.
|
|
63
63
|
|
|
64
64
|
## Import and seed
|
|
65
65
|
|
|
@@ -90,7 +90,7 @@ try (var unit = store.beginUnitOfWork()) {
|
|
|
90
90
|
}
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
Closing an unfinished unit rolls back; `rollback()` explicitly discards. Ordinary `log.append` is immediate. For local instrumentation `var job = EventLogJavaBridge.watchAppendOperations(store.unwrap().getEventLog(), this::recordMetrics);` receives lists of events with results; cancel with `job.cancel(null)`. Not a durable subscription.
|
|
93
|
+
Closing an unfinished unit rolls back; `rollback()` explicitly discards. The current unit is tracked per thread: begin, stage, commit and close on the same thread, because `getTransactional()` called on another thread uses that thread's current unit, if it has one, and appends immediately when it has none. `commit()` appends in staging order, one atomic batch per run of consecutive events with the same sequence, source ID and options, one batch after another; a unit that stages for several sources (as above) is not atomic across them, and an earlier batch stays appended when a later one is rejected. One source alone is not enough: staging for it again after another source, or with different options, starts a new batch. When all-or-nothing matters, stage one unbroken run with the same sequence, source ID and options. Ordinary `log.append` is immediate. For local instrumentation `var job = EventLogJavaBridge.watchAppendOperations(store.unwrap().getEventLog(), this::recordMetrics);` receives lists of events with results; cancel with `job.cancel(null)`. Not a durable subscription.
|
|
94
94
|
|
|
95
95
|
See [history, import and seeding](java-history.md) for inspection, administration and bootstrap.
|
|
96
96
|
|