@cratis/pi 8.5.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/specs.csharp.instructions.md +6 -3
- package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
- 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/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 +0 -2
- 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 +2 -2
- package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +19 -0
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +15 -0
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
- package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +46 -7
- 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 +4 -1
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +31 -4
- package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +24 -2
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +49 -0
- package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +3 -1
- package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +27 -4
- package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
- package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +49 -2
- 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 +84 -2
- package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +2 -0
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +18 -1
- package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
- package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +18 -16
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +8 -3
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +84 -16
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +22 -2
- 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 +40 -1
- 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 +7 -3
- 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-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-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 +2 -2
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +28 -0
- 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/typescript.md +10 -1
- package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +8 -1
- 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 +2 -0
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +27 -0
- 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 +13 -6
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +45 -0
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +91 -1
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +9 -0
- package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
- package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +11 -1
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +14 -3
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +3 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +3 -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 +2 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +1 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +2 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +40 -3
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +20 -2
- 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/references/csharp.md +24 -1
- package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
- 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 +17 -0
- 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.md +35 -2
- 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 +1 -0
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
- package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +1 -1
- 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-code-review/references/csharp-diagnostics.md +28 -2
- package/package/corpus/skills/cratis-code-review/references/csharp.md +1 -1
- 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/references/typescript-commandform.md +72 -2
- package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +5 -3
- 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 +70 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +8 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +1 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +33 -0
- package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +5 -0
- 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-diagnose-slice/SKILL.md +1 -1
- 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-screenplay-accept-model/references/csharp.md +29 -0
- package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +82 -1
- package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +10 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +5 -4
- 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/typescript.md +13 -0
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
- 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 +3 -1
- 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 +1 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +4 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +3 -3
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +34 -1
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
- 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/profile-catalog.json +15 -0
- package/package.json +1 -1
|
@@ -99,6 +99,8 @@ Outside the filters the SDK exposes `identityProvider.setCurrentIdentity(identit
|
|
|
99
99
|
| `ProjectionRegistrationNotApplied` | The kernel accepted a projection but could not apply it; read `failure` and fix the definition |
|
|
100
100
|
| `ObserverHasNoHandlers`, `InvalidHandlerSignature` | A reactor or reducer has no handler, or a handler with parameters the client cannot supply; fix the method |
|
|
101
101
|
|
|
102
|
+
**Refused credentials.** With the defaults (automatic registration and the keep-alive session on), when the kernel refuses the connection, `awaitRegistration()` and an append that is still waiting for the first registration pass throw `io.cratis.chronicle.connection.ChronicleConnectionFailed` instead of waiting; the message names the gRPC status: `UNAUTHENTICATED` for a wrong client ID or secret, `PERMISSION_DENIED` for a client that is not permitted. Treat it as a configuration fault: report the process as not ready and correct the secret or the client's permissions. Do not add a retry loop: the client keeps reconnecting in the background and later calls succeed once the kernel accepts it. With `withoutAutoRegistration()` there is no such gate: `awaitRegistration()` returns immediately and a refused call fails with the gRPC `StatusException` of that call. A kernel that is unreachable when the client is constructed makes the constructor throw `io.grpc.StatusException: UNAVAILABLE`. If it stops answering before the first registration pass has started, nothing is thrown and `awaitRegistration()` and the first append wait, which is why the startup wait above is bounded with `withTimeout`. A pass that starts and then fails, for example because the kernel drops mid-registration, still lets the waiting callers through: the failure is written to standard error and registration is retried on the next connection, so `awaitRegistration()` returning does not prove that every artifact registered. After the first pass an append no longer waits for registration, but it still throws `ChronicleConnectionFailed` without calling the kernel while the connection stands refused; otherwise the call goes to the kernel, and an outage makes it fail with a gRPC `StatusException` or wait: handle all three. Connection problems are written to standard error as `[Chronicle] Connection lost: <status>`, not to a logging framework.
|
|
103
|
+
|
|
102
104
|
The client emits OpenTelemetry spans under the `io.cratis.chronicle` scope with no client setup when the application runs the OpenTelemetry SDK: `Chronicle append <EventType>`, `Chronicle appendMany`, `Chronicle observe <EventType>`, `Chronicle reduce <EventType>` and the `observe batch` / `reduce batch` variants. A refused append or throwing handler ends its span with an error. An observation span is **not** a child of the append span; correlate them by the `chronicle.event_source_id` attribute or the correlation ID.
|
|
103
105
|
|
|
104
106
|
## Not supported in this SDK
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Connect a Node server
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Setup (below)
|
|
6
|
+
- Open the store and verify registration
|
|
7
|
+
- Transport and credentials
|
|
8
|
+
- Application options
|
|
9
|
+
- Behavior patterns
|
|
10
|
+
- Not supported in this SDK
|
|
11
|
+
|
|
3
12
|
Install `@cratis/chronicle`, its `@cratis/fundamentals` peer and `reflect-metadata`. Load `reflect-metadata` before decorated modules. Use standard decorators and an ES2022 target; only enable `experimentalDecorators` and `emitDecoratorMetadata` together for a legacy decorator build. Declare field types explicitly rather than relying on the transpiler to emit runtime metadata. Names below are illustrative.
|
|
4
13
|
|
|
5
14
|
## Open the store and verify registration
|
|
@@ -64,7 +73,7 @@ Pass these as the second argument of `ChronicleOptions.fromConnectionString(uri,
|
|
|
64
73
|
- **Concurrency:** `concurrencyScopeStrategy: ConcurrencyScopeStrategies.none` (enum from `@cratis/chronicle`) disables the default optimistic scope. Alternatively supply a sync/async callback returning a scope or `undefined` for no check. Explicit scopes bypass it; callback failure prevents the append.
|
|
65
74
|
- **Enrichment:** `eventEnrichmentProviders: [(content, ctx) => { content.partition = ctx.namespace; }]` sets a declared cross-cutting field on serialized content, not on `ctx.event`. Providers may be async; the default list is empty.
|
|
66
75
|
- **Reactor results:** `reactorResultHandler: (result, ctx, type, storeName, ns) => handleEffect(result, ctx, type, storeName, ns)` returns true only for a fully handled result; throw on failure. `readModelReactorResultHandler` receives `(result, changeset, type, store, ns)` instead. Set `readModelReactorOnError: (error, changeset, type) => reportFailure(error, changeset, type)` for non-terminal activation, handler or effect failures; reporting does not retry.
|
|
67
|
-
- **Diagnostics:** `logger: { log: entry => applicationLog(entry) }`
|
|
76
|
+
- **Diagnostics:** `logger: { log: entry => applicationLog(entry) }` routes the client's own diagnostics to the application logger; each client has its own sink and `log` is called synchronously. An entry has `category`, `level` (`Verbose`, `Debug`, `Info`, `Warn`, `Error`), `message` and `attributes`. Entries are sanitized: a failure appears as its error type (attribute `error.type`) and, for gRPC, `rpc.grpc.status_code`; exception messages, stacks and event payloads are left out, so the text is only on the errors your own code catches. Do not log those verbatim: a caught error can contain the authorization server's raw response body, because a token request answered with an error status puts that body in its message and a call the kernel then rejects as unauthenticated can repeat it. Inspect them privately and log only the type, the status code and a redacted message. The sink should not throw; a failing sink does not change call results or acknowledgements. Without `logger` the entries go to OpenTelemetry `diag`, which discards them until the application calls `diag.setLogger(...)`; use one of the two paths, not both. Built-in telemetry uses convention span names; `telemetry.spanNames` accepts `legacy`/`convention` but neither changes naming. Source IDs are omitted by default; `telemetry: { eventSourceId: { mode: 'hmac', key: deploymentKey } }` uses SHA-256 with a nonempty `Uint8Array`. Select `raw` only if exposing identifiers is intended.
|
|
68
77
|
|
|
69
78
|
## Behavior patterns
|
|
70
79
|
|
|
@@ -10,6 +10,8 @@ A lookup can tell a writer that a value is free; it cannot reserve it. A registe
|
|
|
10
10
|
|
|
11
11
|
Read `references/<language>.md` for the project's SDK (`.csproj` → csharp, Node server `package.json` → typescript, `*.kt` → kotlin, `*.java` → java, `go.mod` → go, `mix.exs` → elixir); only the project's languages are installed.
|
|
12
12
|
|
|
13
|
+
Read [operations](references/operations.md) when upgrading a kernel that holds unique claims, when a rule is added to or changed on a store that already holds events, when reading a reindex job's skipped-duplicates report, or when a rebuild keeps refusing appends.
|
|
14
|
+
|
|
13
15
|
## Default: reserve one property for one source
|
|
14
16
|
|
|
15
17
|
Names here are illustrative. Suppose a locker claims a pickup code until the locker is emptied.
|
|
@@ -23,11 +25,14 @@ Names here are illustrative. Suppose a locker claims a pickup code until the loc
|
|
|
23
25
|
|
|
24
26
|
- **Model-bound declaration:** keep a single field claim, once-only event or close marker with the event it governs when the model expresses the whole rule.
|
|
25
27
|
- **Dedicated definition:** use the builder when multiple event types participate or comparison, scope or message logic does not belong on the model.
|
|
28
|
+
- **Declaration only:** a definition describes the rule and does nothing else. It must not append events or run commands, its body has no branches, loops, variables or assignments, and each selector is a plain property access. The .NET analyzers catch the common breaches (an injected event log or command pipeline, those statement forms, a selector that is not a property chain), not every side effect, so a clean build is not proof.
|
|
26
29
|
- **Constraint name:** give related declarations one stable identity for grouping, release and diagnostics; keep unrelated rules separately named. Claims are indexed under this name, so renaming a rule starts a new, empty index until it is rebuilt.
|
|
27
30
|
- **Ordered composite key:** select multiple properties together when only the tuple must be unique; map other claiming events to the same tuple in the same order.
|
|
28
31
|
- **Multiple claiming events:** include every event that introduces or changes the value, even when its field has a different name. An event with no constrained properties present does not replace a claim.
|
|
29
32
|
- **Case comparison:** opt into ignoring case when differently cased strings denote one value; use the same comparison for release.
|
|
30
33
|
- **One value per source:** by default reclaiming one's current value succeeds; replacing it frees the previous value.
|
|
34
|
+
- **Once per source is a type rule:** a unique property that carries the source's own identifier never rejects a second event on that source, because the owner re-claims its own value. To allow a fact once per source, use a unique event type.
|
|
35
|
+
- **Hashed claims:** the index stores a hash of the constrained value, not the value, so a rule may cover personal data. A hash is not encryption or anonymisation: predictable values can be guessed. Protect the event property separately and keep custom messages free of the value.
|
|
31
36
|
- **Retain per value:** when a source owns multiple identifiers, keep each until released. The owner can reclaim its own identifiers.
|
|
32
37
|
- **Source-wide removal:** declare each lifecycle event that should release the owner's claims in the matching scope. One removal event can release multiple named rules.
|
|
33
38
|
- **Value-specific removal:** map removal fields in tuple order when a retained identifier, rather than all the owner's identifiers, becomes free.
|
|
@@ -39,7 +44,7 @@ Names here are illustrative. Suppose a locker claims a pickup code until the loc
|
|
|
39
44
|
- **Sequence selection:** limit enforcement to named sequences, or just the event log, when other sequences must not check the rule. Unrestricted means every sequence, not one shared index. Merged selections form a union; an unrestricted declaration wins.
|
|
40
45
|
- **Static violation message:** use a template when callers need a domain-specific explanation; substitute violation detail keys rather than parsing the kernel's prose.
|
|
41
46
|
- **Message provider:** use a callback when the message must be computed. Check the SDK's callback timing and arguments before relying on violation details.
|
|
42
|
-
- **Closing event:** when *all* subsequent writes in a scope should stop, close it by event. Reads and replay remain available. Registration alone does not apply historical closures.
|
|
47
|
+
- **Closing event:** when *all* subsequent writes in a scope should stop, close it by event. Reads and replay remain available. Registration alone does not apply historical closures. Marking an event type as a tombstone closes nothing and rejects no later append.
|
|
43
48
|
- **Closure dimensions:** default to source ID, stream type and stream ID together; select source ID, source type, stream type or stream ID in combination to match the intended write boundary. Every closing and reopening append must supply each selected dimension, and a scope that resolves only to the default stream is refused.
|
|
44
49
|
- **Payload stream ID:** when the closing event names a different stream, take its ID from a required nonempty property; reopening events must carry the same property.
|
|
45
50
|
- **Reopening events:** allow named event types to lift this rule's closure for the exact scope; they cannot clear a manual closure or another rule's closure. To reopen, append a configured reopening event addressing the same scope. A manual scope reopen refuses a closure owned by a closing event (closed by event). Without reopening events, no append or manual reopen lifts it.
|
|
@@ -47,4 +52,6 @@ Names here are illustrative. Suppose a locker claims a pickup code until the loc
|
|
|
47
52
|
- **Registration and inspection:** discover or explicitly register definitions at store setup. Inspect the registered identity where available; prove enforcement with an append, not just a successful startup.
|
|
48
53
|
- **Violation result:** branch on constraint kind and name; use event type, sequence number and structured details for diagnosis. Property values may be sensitive. In a batch, occurrence and release follow call order; failed constraint validation rejects the whole append.
|
|
49
54
|
- **Unavailable index:** this refusal is not a business collision: none of the attempted new events were written. Back off and retry the unchanged request, preserving idempotency keys. The event and claim-index update are not crash-atomic, and renumbering after a duplicate sequence number does not revalidate the constraint.
|
|
55
|
+
- **Rule added or changed on stored events:** registering a new property rule, or one whose claiming or removal mapping, comparison, retention mode or scope changed or whose sequence selection grew, makes the kernel rebuild that index from history in each sequence that holds events and that the rule newly covers or whose index the change affects. Registering an unchanged rule rebuilds nothing, and a selection that only grew rebuilds only the newly covered sequences. Until the rebuild finishes, appends the rule governs get the unavailable-index refusal. History is not rejected: where sources already share a value, the earliest claimant keeps it; a later colliding claim that storage rejects is not written, and the reindex step's progress message counts those rejected writes per constraint. Read that message on the job's step and settle every duplicate in the domain with events (`references/operations.md`). An occurrence rule keeps no index; it judges the next append against the source's stored events as soon as it is registered. A closing rule ignores history until rebuilt.
|
|
56
|
+
- **Revised events:** revising a constrained event schedules a refold of its index from the revised position; revision is not validated against the rule, so it does not guarantee the source the revised value when another source already holds it. A retained per-value claim is released only when the revising source owns it and that event made it; one made by another event stays. If constrained events were revised on a kernel from before that behaviour, rebuild that rule's index once to release the stale claims (`references/operations.md`).
|
|
50
57
|
- **Operator rebuild:** when an index needs repair, request reindexing for the intended store, namespace, sequence and constraint names; an empty selection means all applicable indexed rules. Follow the job to completion. Rebuilding closure rules, unlike registering them, applies closing and reopening history. Verify contention afterward; duplicate values already in the index make storage fall back to a non-unique index, with only a logged warning, despite successful startup.
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Append constraints in C#
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Reserve and release a property
|
|
6
|
+
- Map tuples and alternative claims
|
|
7
|
+
- Occurrence rather than property
|
|
8
|
+
- Close and reopen a write scope
|
|
9
|
+
- Registration, failures and repair
|
|
10
|
+
- In an Arc command
|
|
11
|
+
|
|
3
12
|
## Reserve and release a property
|
|
4
13
|
|
|
5
14
|
Reference `Cratis.Chronicle`. Names are illustrative. With a connected `IEventStore store`, include both event types in the store's registered artifacts. For a positional record, target the **property**, not the constructor parameter:
|
|
@@ -17,7 +26,7 @@ public record LockerEmptied;
|
|
|
17
26
|
|
|
18
27
|
In a disposable namespace, append `await store.EventLog.Append("locker-1", new PickupCodeAssigned("A7"))`, then the same event to `"locker-2"`. Only the first result should have `IsSuccess`. Append `new LockerEmptied()` to `"locker-1"`; the second assignment should now succeed. If both initial appends succeed, check store registration, event sequence and namespace before relying on the rule. `store.Constraints.HasFor("PickupCode")` checks local discovery, not kernel enforcement.
|
|
19
28
|
|
|
20
|
-
By default the comparison is case-sensitive and `PerEventSource` replaces the owner's previous claim. Assigning the current value again succeeds for that owner. For multiple simultaneous codes, declare `[property: Unique("PickupCode", Mode = UniqueConstraintMode.PerValue)]`. To drop just one, put `[RemoveConstraint("PickupCode", Properties = new[] { nameof(CodeReleased.Code) })]` on a `CodeReleased(string Code)` event. No properties means release all for that owner in scope. Repeat the attribute for different rules, or use it on several ending events. Use a stable explicit name for shared declarations and removers; otherwise the attribute derives identity from the annotated member. Shared property declarations must agree on retention mode.
|
|
29
|
+
By default the comparison is case-sensitive and `PerEventSource` replaces the owner's previous claim. Assigning the current value again succeeds for that owner. `[Unique]` also works on a property typed as a `ConceptAs<T>`: the underlying value is compared, so keep the concept type on the event. For multiple simultaneous codes, declare `[property: Unique("PickupCode", Mode = UniqueConstraintMode.PerValue)]`. To drop just one, put `[RemoveConstraint("PickupCode", Properties = new[] { nameof(CodeReleased.Code) })]` on a `CodeReleased(string Code)` event. No properties means release all for that owner in scope. Repeat the attribute for different rules, or use it on several ending events. Use a stable explicit name for shared declarations and removers; otherwise the attribute derives identity from the annotated member. Shared property declarations must agree on retention mode.
|
|
21
30
|
|
|
22
31
|
## Map tuples and alternative claims
|
|
23
32
|
|
|
@@ -42,6 +51,8 @@ public class DepotCodeRule : IConstraint
|
|
|
42
51
|
|
|
43
52
|
Specify each claiming type once, selecting property paths (not computed expressions) in tuple order. Map the same order on a value-specific remover. No constrained properties present means no replacement. Runtime type mappings can use `u.On(eventType, new[] { "Depot", "Code" })`, `u.RemovedWith(removalType, new[] { "Site", "ExternalCode" })` or `u.RemovedWith(removalType)` with registered `EventType` values. Missing paths fail definition. A dedicated property definition without `WithName` uses its owner identity; without an owner supply the name.
|
|
44
53
|
|
|
54
|
+
A definition class only declares. The analyzers report a violation as a build error: `CHR0017`, `CHR0018` and `CHR0020`; their meanings are in the `cratis-code-review` skill, `references/csharp-diagnostics.md`.
|
|
55
|
+
|
|
45
56
|
Select `.PerEventSourceType()`, `.PerEventStreamType()` or `.PerEventStreamId()` **before** declaring a unique rule; each partitions by one more dimension. Otherwise all sources compete for the tuple in that namespace and sequence. `.ForEventLog()` is `.ForEventSequences(EventSequenceId.Log)` (`Cratis.Chronicle.EventSequences`); e.g. `.ForEventSequences(new EventSequenceId("dispatch"))` selects another sequence. Sequence selection applies to the builder's built definitions. Attribute equivalent on `Unique` or `ClosesStream`: `EventSequences = new[] { "event-log" }`. Empty means all sequences independently; merged selections union, with unrestricted winning.
|
|
46
57
|
|
|
47
58
|
## Occurrence rather than property
|
|
@@ -81,9 +92,30 @@ A declaration that cannot be built throws while constraints are discovered, befo
|
|
|
81
92
|
| `NoEventTypesAddedToUniqueConstraint` | A unique rule was built without any `On<TEvent>(...)` |
|
|
82
93
|
| `MissingNameForUniqueConstraint` | A unique rule has no explicit name and no owning constraint type to derive one from |
|
|
83
94
|
| `NoUniqueEventTypeConstraintToRemove` | `RemovedWith<T>()` on the outer builder has no preceding occurrence rule (`Unique<TEvent>()`) to attach to |
|
|
95
|
+
| `EventTypeAlreadyAddedToUniqueConstraint` | One unique rule maps the same event type twice with `On` |
|
|
96
|
+
| `ConflictingUniqueConstraintModes` | `[Unique]` properties that share a name declare different `Mode` values |
|
|
97
|
+
| `DuplicateConstraintNames` | Two rules built in one `Define` resolve to the same name. Occurrence rules that share a name are grouped instead, and so are closing declarations |
|
|
98
|
+
| `MissingNameForClosesStreamConstraint` | A closing declaration has an empty name; the empty name is reserved for manual closures |
|
|
99
|
+
| `ConflictingClosesStreamDeclarations` | Closing declarations that share a name differ in dimensions or stream-ID property, or a closing declaration shares its name with another kind of rule |
|
|
84
100
|
|
|
85
|
-
|
|
101
|
+
One failure comes later, when the definitions are registered with the kernel: `ClosesStreamConstraintsNotSupported` means the connected kernel has no closing-event constraints. Upgrade the kernel before registering closing declarations.
|
|
86
102
|
|
|
87
|
-
For
|
|
103
|
+
For an unsuccessful append, distinguish `result.IsRetryable` (transient refusal, no new events written; honor `result.RetryAfter` or back off and retry unchanged, preserving idempotency keys) from `result.ConstraintViolations`. For example, `result.ConstraintViolations.Any(v => v.ConstraintType == ConstraintType.Unique && v.ConstraintName.Value == "PickupCode")` identifies the domain conflict. Do not convert other failures into “code taken.” `UniqueEventType` is an occurrence violation; `Schema` means the event content does not match its registered schema and `Unknown` is a refusal the kernel could not classify, so treat neither as a business collision; `StreamClosed` is a closed-scope refusal: every one is the violation named `closed-stream`, whatever `Name` the closing declaration has. That `Name` identifies the closure owner, reported in `Details[WellKnownConstraintDetailKeys.ClosedBy]` and as `ClosedBy` from `GetClosedStreams()` (empty or null for a manual closure); match the refusal on `closed-stream` and use `ClosedBy` only to tell owners apart. Inspect `EventTypeId`, `SequenceNumber`, `Message` and `Details`; `WellKnownConstraintDetailKeys` includes `PropertyName`, `PropertyValue`, `ClosedBy` and `ClosedAtSequenceNumber`. Avoid logging sensitive values. `store.Constraints.ResolveMessageFor(v)` resolves a known local rule's callback/template, leaving unknown rules alone. Ordered batch validation includes earlier claims/releases in the batch; rejection writes none of the batch.
|
|
104
|
+
|
|
105
|
+
For repair, on an authorized operator connection use `await services.ConstraintIndexes.ReindexConstraints(new ReindexConstraintsRequest { EventStore = "dispatch", Namespace = "default", EventSequenceId = "event-log", ConstraintNames = new[] { "PickupCode" } })` (`Cratis.Chronicle.Contracts.Events.Constraints.Operator`). An empty list selects all applicable indexed rules. Check command success before using `Response` as a job ID; follow that ID in Jobs until `CompletedSuccessfully`, then verify contention. Reindexing closures, unlike registration, applies history; redacted payload IDs may prevent reconstruction without a matching snapshot. Index updates and event writes are not crash-atomic. Do not treat startup or job acceptance as proof the storage index enforces uniqueness. Kernel upgrades that touch stored claims, the skipped-duplicates report and a rebuild that does not finish are in `references/operations.md`.
|
|
88
106
|
|
|
89
107
|
**Not supported in this SDK:** no append constraint for cross-namespace/sequence uniqueness, arbitrary counts or balance predicates. Route competing claims to one authoritative scope; for decisions over previously read events use `cratis-chronicle-protect-decision`, not a preflight lookup.
|
|
108
|
+
|
|
109
|
+
## In an Arc command
|
|
110
|
+
|
|
111
|
+
When a constraint refuses the events an Arc command produces, the command fails as invalid and none of the events in that rejected batch are stored. Events an earlier immediate append or explicit commit already persisted stay persisted. Every violation, whatever its kind, becomes one entry in the result's `ValidationResults`:
|
|
112
|
+
|
|
113
|
+
| Member | Value |
|
|
114
|
+
| --- | --- |
|
|
115
|
+
| `Severity` | `Error` |
|
|
116
|
+
| `Reason` | `ValidationResultReason.ConstraintViolation`, serialized as `constraintViolation` |
|
|
117
|
+
| `ReasonDetail` | The constraint name |
|
|
118
|
+
| `Message` | The constraint's message |
|
|
119
|
+
| `Members` | The violating property in camel case when the violation's details carry `PropertyName`; otherwise empty |
|
|
120
|
+
|
|
121
|
+
Branch on `Reason` and `ReasonDetail`, never on the message. Clients select their text by constraint name, so give every rule a stable explicit name and treat renaming it as a breaking change for them. A lookup in a validator or the handler does not reserve the value; it never replaces the constraint.
|
|
@@ -82,4 +82,4 @@ Check `result.Errors` separately: when `result.Disposition == eventsequences.Rej
|
|
|
82
82
|
|
|
83
83
|
- Value-specific removal: `RemovedWith` accepts event descriptors, not paths. If releasing all the owner's tuples is incorrect, have a supporting SDK own the definition.
|
|
84
84
|
- Event-driven closure (including closure dimensions, payload-derived stream ID, shared close owner and reopening events): register the rule through a supporting SDK. Go writers can receive `constraints.StreamClosed`; a unique event type is not a stream closure.
|
|
85
|
-
- Application-level constraint reindex operation: have an operator request and monitor the rebuild for the correct store, namespace, sequence and rules. Re-registering
|
|
85
|
+
- Application-level constraint reindex operation: have an operator request and monitor the rebuild for the correct store, namespace, sequence and rules. Re-registering an unchanged registry is not a rebuild; the kernel starts one itself only for a new property rule or one whose index-affecting definition changed (`references/operations.md`).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Operating constraint indexes
|
|
2
|
+
|
|
3
|
+
Language-neutral. How to request a rebuild from an application is in `references/<language>.md`.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- [A rule added or changed on stored events](#a-rule-added-or-changed-on-stored-events)
|
|
8
|
+
- [The skipped-duplicates report](#the-skipped-duplicates-report)
|
|
9
|
+
- [A rebuild that does not finish](#a-rebuild-that-does-not-finish)
|
|
10
|
+
- [Revised events](#revised-events)
|
|
11
|
+
- [Upgrading a kernel that holds unique claims](#upgrading-a-kernel-that-holds-unique-claims)
|
|
12
|
+
|
|
13
|
+
## A rule added or changed on stored events
|
|
14
|
+
|
|
15
|
+
What registration does with history depends on the kind of rule:
|
|
16
|
+
|
|
17
|
+
| Rule | On registration |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| Unique property rule, new or changed | The kernel starts a reindex job for each sequence that holds events and that the rule newly covers or whose index the change affects, and rebuilds the index from the events in log order |
|
|
20
|
+
| Unique property rule, unchanged | Nothing. Registering the same definitions again is not a rebuild |
|
|
21
|
+
| Unique event type rule | Nothing to rebuild: it keeps no index and judges the next append against the source's stored events |
|
|
22
|
+
| Closing rule | History is ignored. Request a rebuild to apply past closing and reopening events |
|
|
23
|
+
|
|
24
|
+
A property rule counts as changed when its claiming or removal events or properties, case comparison, retention mode or scope differ, or when its sequence selection now covers a sequence it did not cover before. A selection that only grew rebuilds the newly covered sequences and leaves the ones it already covered alone. Narrowing the selection rebuilds nothing.
|
|
25
|
+
|
|
26
|
+
While a unique property index rebuilds, appends governed by that index are refused with the unavailable-index error and store nothing; retry the unchanged append after a delay. Appends the index does not govern continue, and a rebuild of closure rules alone refuses no append.
|
|
27
|
+
|
|
28
|
+
Default procedure after deploying a new or changed property rule to a store that holds events:
|
|
29
|
+
|
|
30
|
+
1. Find the reindex job for each namespace and affected sequence and follow it to `CompletedSuccessfully`. Registration does not wait for it and does not fail when the job cannot start. If no job appears for a sequence that holds governed events, request the rebuild explicitly.
|
|
31
|
+
2. Read the progress message of the job's reindex step for skipped duplicates (next section).
|
|
32
|
+
3. Prove contention with an append in each namespace.
|
|
33
|
+
|
|
34
|
+
## The skipped-duplicates report
|
|
35
|
+
|
|
36
|
+
A rebuild does not fail on history that already breaks the rule. When storage rejects a claim because it collides with one already rebuilt, the kernel logs a warning, does not write that claim and continues. The first historical claimant keeps the value until an event releases or replaces it.
|
|
37
|
+
|
|
38
|
+
The progress message of the job's reindex step, not of the job itself, reports the skips per constraint, for example `Skipped 3 duplicate claims: UniqueEmail=2, UniqueName=1`. It holds constraint names and counts only: no values, hashes or claimant identities. The counts are rejected claim writes, not sources or values. A rebuild without collisions leaves the message unchanged, so a clean message on a step of a job that reached `CompletedSuccessfully` means storage rejected no claim; it does not describe values that history claimed twice and later released. Only rejected writes are skipped and counted: storage that has fallen back to a non-unique index can accept a colliding claim without reporting it, so prove contention as well.
|
|
39
|
+
|
|
40
|
+
For each reported constraint, find the sources that share a value from the events or a read model, decide in the domain which one keeps it, and record that with events: the others take another value or release theirs. A source whose colliding claim was not written does not hold that value. When that claim was a change of value, the source's previous claim can still stand, so do not assume it holds nothing. If the domain gives the value to such a source, first release the current owner's claim with an event, then append a fresh claim for the chosen source.
|
|
41
|
+
|
|
42
|
+
## A rebuild that does not finish
|
|
43
|
+
|
|
44
|
+
Symptoms: governed appends keep returning the unavailable-index error, the gauge `chronicle-event-sequences-constraint-indexes-rebuilding` stays above zero, and every 5 minutes the kernel logs a line that starts with `Constraint rebuild` and contains `is still holding`.
|
|
45
|
+
|
|
46
|
+
The kernel refuses governed appends on purpose: accepting them against an incomplete index would let duplicates in. About every 30 seconds it checks the reindex job step. Once the step has ended (failed, stopped, completed or removed) it releases the rebuild and catches the index up from the event sequence before governed appends resume. A warning that starts with `Constraint index rebuild terminal handoff failed` or `Constraint index rebuild cancellation handoff failed` means the step could not hand over; the same check recovers it.
|
|
47
|
+
|
|
48
|
+
- Default: wait and follow the job. Do not restart the kernel to hurry a running rebuild.
|
|
49
|
+
- Restart the kernel only when the `still holding` line ends with `restart the Kernel to recover`. The kernel adds that when it cannot tell whether the step is alive: the step is `unreadable`, the rebuild has `no job` (for example a step started by an earlier kernel version), or a finished step has `missing or inconsistent status history`. The restart is safe: the index is caught up from the event sequence before governed appends resume.
|
|
50
|
+
- A job that ended as `Failed` or `CompletedWithFailures` did not confirm successful completion; do not rely on the index or on its skipped-duplicates report. Read its steps for the cause, fix it, then request the rebuild again. A missing schema for a claiming or removal event type fails the rebuild.
|
|
51
|
+
|
|
52
|
+
## Revised events
|
|
53
|
+
|
|
54
|
+
Revising a constrained event schedules a refold: the index is refolded from the revised position before the next governed append. A revision is not validated against the rule, so the refold does not guarantee the source the revised value: when another source already holds it, that source keeps it. Check the outcome with an append or a read model rather than assuming the claim transferred. For a rule that retains each value, the value the old content held is released only when the revising source owns it and the claim was made by that same event; a claim on that value made by another event is kept. Kernels from before this behaviour left the old claim in place. If constrained events were revised on such a kernel, rebuild that constraint's index once after upgrading; the stale claims are then released.
|
|
55
|
+
|
|
56
|
+
## Upgrading a kernel that holds unique claims
|
|
57
|
+
|
|
58
|
+
Edge case: upgrading from a kernel that may have persisted unhashed claims. General upgrade order and rollback are in the `cratis-chronicle-deploy-kernel` skill, `references/upgrade-and-recovery.md`.
|
|
59
|
+
|
|
60
|
+
1. Back up every namespace database before starting the new kernel.
|
|
61
|
+
2. Start the new kernel. Its startup patch permanently deletes every unique claim whose stored value is not a 64-character lowercase hexadecimal hash, for all sequences and scopes and for both retention modes. The match is case-sensitive, so an uppercase value is deleted too. In-memory storage has nothing to clean.
|
|
62
|
+
3. Unless every stored claim is known to have been a hash already, request a rebuild for each namespace and sequence and follow each job to `CompletedSuccessfully`. The rebuild recreates the claims from the events with current hashes; governed appends are refused while it runs.
|
|
63
|
+
4. Read each job's skipped-duplicates report and prove contention.
|
|
64
|
+
|
|
65
|
+
Facts to plan around:
|
|
66
|
+
|
|
67
|
+
- Between the upgrade and the rebuild, a deleted claim does not stop another source from taking the value. Rebuild before reopening the store to writers when that matters.
|
|
68
|
+
- A downgrade does not bring the deleted claims back, and neither does a rebuild: it derives new claims from history. To roll back, stop the kernels and restore the backup.
|
|
69
|
+
- A patch that fails during cleanup or schema update is not recorded as done; starting the kernel again retries it safely.
|
|
70
|
+
- Duplicate claims that already have the hash shape are kept. Storage then falls back to a non-unique index and logs a warning, so verify contention after the upgrade.
|
|
@@ -72,6 +72,7 @@ Settings come from the file `/app/chronicle.json` and from `Cratis__Chronicle__
|
|
|
72
72
|
| Clustering | Single node (default) or a multi-node cluster through MongoDB or SQL membership; lease standby for platforms that start the replacement first; best-effort node roles | [Configuration](references/configuration.md) |
|
|
73
73
|
| Constraint index repair | Retries and time budgets for keeping constraint indexes in step with the log; startup ranges | [Configuration](references/configuration.md) |
|
|
74
74
|
| Shutdown | Drain time on stop | [Configuration](references/configuration.md) |
|
|
75
|
+
| Containers and Kubernetes | Memory and CPU sizing, StatefulSet shape with probes and disruption budget, crash dumps. Read when sizing a kernel container, running it on Kubernetes or capturing a crash | [Container and Kubernetes](references/container-and-kubernetes.md) |
|
|
75
76
|
| Alerts | Incidents for observer failure conditions | [Configuration](references/configuration.md) |
|
|
76
77
|
| Webhooks and external services | Where the kernel may call out, delivery retry, quarantine probes, managed identity | [Webhooks](references/webhooks.md) |
|
|
77
78
|
| Upgrade, backup, restore | Single-node, rolling or stop-all upgrades, crossing major versions, restore order, System event store | [Upgrade](references/upgrade-and-recovery.md) |
|
|
@@ -125,6 +126,7 @@ Every bindable setting, grouped by JSON object. Consult the [option index](refer
|
|
|
125
126
|
- `events`: `queues`, `queueBoundedCapacity`, `queueBoundedEvents`, `statePersistenceInterval`, `constraintsVersionCheckInterval`, `causationPropertyRetention`, `queueDepletionWaitTimeoutMilliseconds`.
|
|
126
127
|
- `shutdown`: `drainTimeout`, `hostShutdownReserve`.
|
|
127
128
|
- `startup`: `busySiloWaitLimit`.
|
|
129
|
+
- `crashDumps`: `retain`.
|
|
128
130
|
- `features`: `api`, `workbench`, `changesetStorage`, `oAuthAuthority`, `projectionGenerations`, `isolatedPartitionReplay`.
|
|
129
131
|
- `storage`: `type`, `connectionDetails`, `connectionDetailsFile`, `databaseNamePrefix`, `systemDatabaseName`, `schema`, `createIfMissing`, `schemaMode`, `schemaAction`.
|
|
130
132
|
- `storage.postgreSqlEntra`: `enabled`, `managedIdentityClientId`.
|
|
@@ -43,6 +43,33 @@ Put structure in the file and secrets (connection strings, passwords, tokens)
|
|
|
43
43
|
in environment variables fed from a secret store. Every node of a cluster must
|
|
44
44
|
resolve the same values.
|
|
45
45
|
|
|
46
|
+
Write settings at the top level of `chronicle.json`:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"storage": { "type": "MongoDB" },
|
|
51
|
+
"observers": { "subscriberTimeout": 60 }
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Never wrap them in `Cratis` and `Chronicle` objects. The kernel places the
|
|
56
|
+
file under that path itself, so a wrapped setting binds to nothing and is
|
|
57
|
+
ignored without an error or a warning. Each such setting keeps its default or
|
|
58
|
+
the value from an environment variable; when a wrapped setting is one the
|
|
59
|
+
kernel requires, such as the TLS certificate, startup stops as if it were
|
|
60
|
+
missing. The `Cratis__Chronicle__` prefix belongs to environment variables
|
|
61
|
+
only.
|
|
62
|
+
|
|
63
|
+
### Ignored legacy settings
|
|
64
|
+
|
|
65
|
+
The kernel still accepts two settings from earlier releases and ignores them.
|
|
66
|
+
Remove them when you find them.
|
|
67
|
+
|
|
68
|
+
| Legacy setting | What applies now |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `additiveEventTypeSchemaEvolutionEventStores` | Every event store accepts compatible additions to its event types. The list no longer limits that to the stores it names, and a populated list logs a startup warning. List the stores that must keep strict validation under `strictEventTypeSchemaEventStores`, with the same value on every node |
|
|
71
|
+
| `identityProvider.certificate` | The top-level `tls` certificate serves the kernel's token endpoint; see [Network and TLS](network-and-tls.md). The setting logs a startup warning whenever it is present. Remove it and any `Cratis__Chronicle__IdentityProvider__Certificate__*` variables |
|
|
72
|
+
|
|
46
73
|
## Features
|
|
47
74
|
|
|
48
75
|
| Setting | Default | Turn it off or on when |
|
package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/container-and-kubernetes.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# Container sizing, Kubernetes and crash dumps
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Size the container
|
|
6
|
+
- Garbage collection settings
|
|
7
|
+
- Kubernetes workload
|
|
8
|
+
- Probes and stopping
|
|
9
|
+
- Disruptions, placement and network
|
|
10
|
+
- Replace kernels in Kubernetes
|
|
11
|
+
- Crash dumps
|
|
12
|
+
|
|
13
|
+
Setting names are written as they appear in `chronicle.json`. The environment
|
|
14
|
+
form is `Cratis__Chronicle__` plus the path with `__` between segments.
|
|
15
|
+
|
|
16
|
+
## Size the container
|
|
17
|
+
|
|
18
|
+
Size from the peak of your own workload, not from a table.
|
|
19
|
+
|
|
20
|
+
1. Run the real workload with a generous memory limit and no heap setting.
|
|
21
|
+
2. Read the container's peak memory, including a cold start against the full
|
|
22
|
+
backlog. Memory follows the number of resident observers, reactors and
|
|
23
|
+
reducers, not the event rate; the `cratis.chronicle.observer.resident`
|
|
24
|
+
gauge reports that number per kernel.
|
|
25
|
+
3. Set the memory limit above that peak, with headroom for the next cold
|
|
26
|
+
start. A limit below what the kernel needs gets the container killed.
|
|
27
|
+
4. Measure again after a kernel upgrade or when the application adds
|
|
28
|
+
namespaces or observers.
|
|
29
|
+
|
|
30
|
+
| Kernel | CPU | Memory limit |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| Development, test, a kernel per tenant, low event rates | One CPU works, at a clearly lower append rate and slower catch-up | Above the observed peak. As an order of magnitude from a synthetic workload, 512 MiB ran out of memory and 1 GiB left moderate headroom |
|
|
33
|
+
| Shared by many namespaces and observers | Two or more. The step from one CPU to two gives the largest gain in append rate and catch-up time | Above the observed peak, with cold-start headroom |
|
|
34
|
+
|
|
35
|
+
CPU is a cold-start concern. A starting kernel reactivates observers and
|
|
36
|
+
catches up, and needs far more CPU than it does at steady state.
|
|
37
|
+
|
|
38
|
+
- Size the CPU request from the cold-start peak, not from the average.
|
|
39
|
+
- Prefer no CPU limit, so a starting kernel can use idle CPU on its node.
|
|
40
|
+
- When the platform enforces a CPU limit, set it from the cold-start peak. A
|
|
41
|
+
lower limit starves the thread pool; a kernel that cannot complete a startup
|
|
42
|
+
step stops itself and is restarted, and no probe budget fixes that.
|
|
43
|
+
|
|
44
|
+
## Garbage collection settings
|
|
45
|
+
|
|
46
|
+
The production image runs Server GC with dynamic adaptation and a
|
|
47
|
+
conserve-memory setting. Keep those defaults; they suit both a small and a
|
|
48
|
+
large container. With a container memory limit and no heap setting, the
|
|
49
|
+
runtime caps the heap at 75 % of the limit, or at 20 MB when that is larger.
|
|
50
|
+
|
|
51
|
+
Change a setting only for a measured reason, as an environment variable on the
|
|
52
|
+
container. `DOTNET_GC*` values that take a number are **hexadecimal**:
|
|
53
|
+
`DOTNET_GCHeapHardLimitPercent=0x4B` is 75 %.
|
|
54
|
+
|
|
55
|
+
| Variable | Change it when |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `DOTNET_GCHeapHardLimitPercent` | Other processes share the container, so the heap must stay below the default 75 % |
|
|
58
|
+
| `DOTNET_gcServer=0` (Workstation GC) | Memory, not CPU, limits a kernel with several CPUs. It lowers peak memory and costs a large share of the append throughput |
|
|
59
|
+
|
|
60
|
+
Anti-patterns:
|
|
61
|
+
|
|
62
|
+
- Do not turn dynamic adaptation off (`DOTNET_GCDynamicAdaptationMode=0`): it
|
|
63
|
+
raises memory without raising throughput.
|
|
64
|
+
- Do not switch the GC mode on a one-CPU container; in the measured workload
|
|
65
|
+
the mode made no measurable difference with one CPU.
|
|
66
|
+
- Do not write a decimal number into a `DOTNET_GC*` variable; `75` is read as
|
|
67
|
+
hexadecimal, not as 75.
|
|
68
|
+
|
|
69
|
+
## Kubernetes workload
|
|
70
|
+
|
|
71
|
+
Run the kernel as a **StatefulSet**, although it keeps all state in the
|
|
72
|
+
storage backend and needs no persistent volume. A StatefulSet stops a pod
|
|
73
|
+
before it creates the replacement, replaces one pod at a time and waits for
|
|
74
|
+
readiness, and gives each kernel a stable name in logs and cluster membership.
|
|
75
|
+
A single `Localhost` kernel depends on stop-before-start: the replacement
|
|
76
|
+
waits for the single-writer lease, which the old kernel releases when it
|
|
77
|
+
stops.
|
|
78
|
+
|
|
79
|
+
| Alternative | When it works |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| Deployment, several kernels with `MongoDB` or `Sql` clustering | With the default rolling update |
|
|
82
|
+
| Deployment, one `Localhost` kernel | Only with `strategy: Recreate`, or `RollingUpdate` with `maxSurge: 0` and `maxUnavailable: 1`. The default rollout never completes: the new pod waits for the lease while Kubernetes waits for it to become ready. Prefer `Recreate`. Lease standby is the exception that makes the default start-before-stop rollout complete, but it gives up readiness as a rollout gate: validate the image first and keep the previous one ready to roll back to. See [Clustering](configuration.md#clustering) |
|
|
83
|
+
|
|
84
|
+
The parts of the pod that are specific to the kernel:
|
|
85
|
+
|
|
86
|
+
```yaml
|
|
87
|
+
spec:
|
|
88
|
+
automountServiceAccountToken: false # the kernel does not call the Kubernetes API
|
|
89
|
+
terminationGracePeriodSeconds: 30
|
|
90
|
+
securityContext:
|
|
91
|
+
runAsNonRoot: true
|
|
92
|
+
runAsUser: 1654 # the image's user
|
|
93
|
+
runAsGroup: 1654
|
|
94
|
+
fsGroup: 1654
|
|
95
|
+
seccompProfile:
|
|
96
|
+
type: RuntimeDefault
|
|
97
|
+
containers:
|
|
98
|
+
- name: chronicle
|
|
99
|
+
image: cratis/chronicle:<pinned release>
|
|
100
|
+
ports:
|
|
101
|
+
- { name: chronicle, containerPort: 35000 }
|
|
102
|
+
- { name: silo, containerPort: 11111 }
|
|
103
|
+
- { name: health, containerPort: 8080 }
|
|
104
|
+
env:
|
|
105
|
+
- name: POD_IP
|
|
106
|
+
valueFrom: { fieldRef: { fieldPath: status.podIP } }
|
|
107
|
+
- name: Cratis__Chronicle__Clustering__AdvertisedIP
|
|
108
|
+
value: $(POD_IP)
|
|
109
|
+
- name: Cratis__Chronicle__Clustering__GatewayEnabled
|
|
110
|
+
value: "false"
|
|
111
|
+
- name: Cratis__Chronicle__Health__Port
|
|
112
|
+
value: "8080"
|
|
113
|
+
- name: Cratis__Chronicle__Health__Tls
|
|
114
|
+
value: "false"
|
|
115
|
+
- name: Cratis__Chronicle__Health__Exclusive
|
|
116
|
+
value: "true"
|
|
117
|
+
# plus storage, clustering type, TLS and encryption certificate settings
|
|
118
|
+
startupProbe:
|
|
119
|
+
tcpSocket: { port: 35000 }
|
|
120
|
+
periodSeconds: 10
|
|
121
|
+
failureThreshold: 30
|
|
122
|
+
livenessProbe:
|
|
123
|
+
httpGet: { path: /health/live, port: health }
|
|
124
|
+
periodSeconds: 10
|
|
125
|
+
timeoutSeconds: 5
|
|
126
|
+
failureThreshold: 6
|
|
127
|
+
readinessProbe:
|
|
128
|
+
httpGet: { path: /health, port: health }
|
|
129
|
+
periodSeconds: 5
|
|
130
|
+
timeoutSeconds: 5
|
|
131
|
+
failureThreshold: 3
|
|
132
|
+
lifecycle:
|
|
133
|
+
preStop:
|
|
134
|
+
sleep: { seconds: 5 }
|
|
135
|
+
securityContext:
|
|
136
|
+
allowPrivilegeEscalation: false
|
|
137
|
+
readOnlyRootFilesystem: true
|
|
138
|
+
capabilities: { drop: ["ALL"] }
|
|
139
|
+
volumeMounts:
|
|
140
|
+
- { name: tmp, mountPath: /tmp }
|
|
141
|
+
volumes:
|
|
142
|
+
- name: tmp
|
|
143
|
+
emptyDir: { sizeLimit: 256Mi }
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- **Health port.** Serve probes from a dedicated plaintext health port and
|
|
147
|
+
make it exclusive, so it answers nothing but the health paths. Do not open
|
|
148
|
+
it to other namespaces. See [Health probes](network-and-tls.md#health-probes).
|
|
149
|
+
- **Cluster gateway.** Turn it off. Applications connect to Chronicle on port
|
|
150
|
+
35000 only; the gateway is outside Chronicle's authentication and is never
|
|
151
|
+
an application entry point. Allow nothing to reach port 30000.
|
|
152
|
+
- **Advertised address.** Take it from the pod IP, so each kernel advertises
|
|
153
|
+
an address its peers can reach.
|
|
154
|
+
- **Cluster identity.** `clustering.clusterId` and `clustering.serviceId` are
|
|
155
|
+
identical on every kernel of one cluster, and different for every cluster
|
|
156
|
+
that shares a database.
|
|
157
|
+
- **Read-only root filesystem.** Nothing under `/app` is writable. The
|
|
158
|
+
`emptyDir` on `/tmp` holds the runtime's diagnostics socket and pipes; it is
|
|
159
|
+
not a place for dumps.
|
|
160
|
+
- **Secrets.** Mount the certificates and the storage connection string from
|
|
161
|
+
Secrets, without `subPath`, so a renewed TLS certificate reaches the kernel.
|
|
162
|
+
See [Certificate renewal](network-and-tls.md#certificate-renewal).
|
|
163
|
+
- **Resources.** Set requests and limits as in Size the container above.
|
|
164
|
+
|
|
165
|
+
## Probes and stopping
|
|
166
|
+
|
|
167
|
+
The kernel binds its listeners before it starts, so each probe checks a
|
|
168
|
+
different thing.
|
|
169
|
+
|
|
170
|
+
| Probe | Target | Checks |
|
|
171
|
+
| --- | --- | --- |
|
|
172
|
+
| Startup | TCP on 35000 | The process is up and has bound its listeners |
|
|
173
|
+
| Liveness | `GET /health/live` on the health port | The process answers HTTP; it runs no health checks |
|
|
174
|
+
| Readiness | `GET /health` on the health port | Startup has completed, the readiness checks pass and shutdown has not begun |
|
|
175
|
+
|
|
176
|
+
- Never use the readiness path as the liveness probe: a kernel that is still
|
|
177
|
+
starting or has storage trouble would be killed and start over.
|
|
178
|
+
- Never use a TCP check as the liveness probe: an open socket passes even when
|
|
179
|
+
the kernel no longer answers HTTP. Use `/health/live`.
|
|
180
|
+
- Never use a TCP check as the readiness probe; the port is open long before
|
|
181
|
+
the kernel is ready.
|
|
182
|
+
- Readiness keeps a starting kernel out of the Service for as long as it
|
|
183
|
+
needs and never restarts it. Do not tighten the liveness budget: a restart
|
|
184
|
+
throws away the cold-start work done so far.
|
|
185
|
+
- Raising the startup `failureThreshold` does not fix a kernel that restarts
|
|
186
|
+
during a cold start. The startup probe passes within seconds; the cause is
|
|
187
|
+
starved CPU or a failing startup step.
|
|
188
|
+
- The production image has no shell, so the `preStop` hook must be the
|
|
189
|
+
kubelet's `sleep` action, which needs Kubernetes 1.30 or later. It keeps the
|
|
190
|
+
kernel serving while load balancers stop sending traffic.
|
|
191
|
+
- `terminationGracePeriodSeconds` covers the `preStop` sleep plus the kernel's
|
|
192
|
+
own shutdown: `shutdown.drainTimeout` plus `shutdown.hostShutdownReserve`,
|
|
193
|
+
13 seconds by default. Keep it at 30 or more, and raise it when you raise
|
|
194
|
+
either setting.
|
|
195
|
+
|
|
196
|
+
## Disruptions, placement and network
|
|
197
|
+
|
|
198
|
+
- Add a PodDisruptionBudget with `maxUnavailable: 1`, so a drain or a cluster
|
|
199
|
+
upgrade evicts one kernel at a time. With one kernel keep `maxUnavailable:
|
|
200
|
+
1` and accept a short outage; never use `minAvailable: 1` with one replica,
|
|
201
|
+
because no drain could then evict the pod.
|
|
202
|
+
- Keep kernels on separate nodes with required pod anti-affinity on
|
|
203
|
+
`kubernetes.io/hostname`. An evicted kernel then needs a free node: have one
|
|
204
|
+
node more than kernels, or use the preferred form of anti-affinity.
|
|
205
|
+
- Restrict traffic with a NetworkPolicy that your network plugin enforces:
|
|
206
|
+
|
|
207
|
+
| Port | Allow from |
|
|
208
|
+
| --- | --- |
|
|
209
|
+
| 35000 | Application namespaces and the ingress |
|
|
210
|
+
| 11111 | Other kernel pods only |
|
|
211
|
+
| 30000 | Nothing |
|
|
212
|
+
| Health port | The node's probes only |
|
|
213
|
+
|
|
214
|
+
- Allow the kernel's outbound traffic to DNS, the other kernels and storage,
|
|
215
|
+
plus whatever the configuration uses: an external authority, a telemetry
|
|
216
|
+
collector, webhook and sink targets, federation peers, a compliance key
|
|
217
|
+
store. A kernel that cannot resolve its storage host never becomes ready.
|
|
218
|
+
- With TLS and authentication both off behind an ingress, the NetworkPolicy
|
|
219
|
+
is the only access control: every pod it lets in has full access. See
|
|
220
|
+
[Run behind an HTTPS proxy](network-and-tls.md#run-behind-an-https-proxy).
|
|
221
|
+
|
|
222
|
+
## Replace kernels in Kubernetes
|
|
223
|
+
|
|
224
|
+
| Situation | How |
|
|
225
|
+
| --- | --- |
|
|
226
|
+
| One `Localhost` kernel | StatefulSet with one replica and `RollingUpdate`. For a Deployment prefer `Recreate`; `RollingUpdate` with `maxSurge: 0` and `maxUnavailable: 1` also stops the old pod first. Never the default rolling update without lease standby |
|
|
227
|
+
| Several kernels whose releases can share a cluster, or a configuration change | Rolling update, one kernel at a time |
|
|
228
|
+
| A stop-all upgrade | Scale the StatefulSet to zero, wait until the pods are gone, change the image, scale back up. Changing the image while kernels still run starts the rolling update you are avoiding |
|
|
229
|
+
|
|
230
|
+
[Upgrade, backup and recovery](upgrade-and-recovery.md) decides which row
|
|
231
|
+
applies. Reverting the image does not unstick a stalled StatefulSet rollout:
|
|
232
|
+
revert the template, then delete the pod that never became ready.
|
|
233
|
+
|
|
234
|
+
## Crash dumps
|
|
235
|
+
|
|
236
|
+
Dumps are off by default. Turn them on only to capture a crash, with the .NET
|
|
237
|
+
runtime's variables and a dedicated writable volume:
|
|
238
|
+
|
|
239
|
+
| Variable | Value | Effect |
|
|
240
|
+
| --- | --- | --- |
|
|
241
|
+
| `DOTNET_DbgEnableMiniDump` | `1` | Write a dump when the kernel crashes |
|
|
242
|
+
| `DOTNET_DbgMiniDumpType` | `2` | Include the managed heap, which heap analysis needs |
|
|
243
|
+
| `DOTNET_DbgMiniDumpName` | `/dumps/core.%h.%t` | Where to write it; host name and time keep a later crash from overwriting an earlier dump |
|
|
244
|
+
|
|
245
|
+
- Always set `DOTNET_DbgMiniDumpName` to a path on the dumps volume. Without
|
|
246
|
+
it the runtime writes to `/tmp`.
|
|
247
|
+
- Never write dumps to the size-limited `/tmp` volume. A heap dump is about as
|
|
248
|
+
large as the kernel's memory, and the kubelet evicts a pod whose `emptyDir`
|
|
249
|
+
grows past its `sizeLimit`: the dump would kill the kernel you are
|
|
250
|
+
diagnosing.
|
|
251
|
+
- Size the dumps volume for more than one dump of the memory limit. An
|
|
252
|
+
`emptyDir` survives a container restart but not the pod being deleted,
|
|
253
|
+
evicted or rescheduled; copy the dump out first, or use a
|
|
254
|
+
PersistentVolumeClaim when dumps must survive the pod.
|
|
255
|
+
- In Docker, mount a host directory owned by user 1654 at `/dumps`.
|
|
256
|
+
- The production image has no `tar`, so `kubectl cp` does not work against the
|
|
257
|
+
kernel container. Copy through an ephemeral debug container that mounts the
|
|
258
|
+
dumps volume.
|
|
259
|
+
- Turn dumps off again once you have the one you need.
|
|
260
|
+
|
|
261
|
+
A kernel in a crash loop can write a dump on every crash. `crashDumps.retain`
|
|
262
|
+
(`Cratis__Chronicle__CrashDumps__Retain`) limits that on a best-effort basis:
|
|
263
|
+
|
|
264
|
+
| Value | Behaviour |
|
|
265
|
+
| --- | --- |
|
|
266
|
+
| `0` (default) | Nothing is deleted; dumps accumulate |
|
|
267
|
+
| `N` above zero | At every kernel start, the kernel tries to delete the oldest matching dumps and keep the newest `N` |
|
|
268
|
+
|
|
269
|
+
- Opt in only for a directory dedicated to dumps with one kernel writing to
|
|
270
|
+
it, and copy out dumps you need before you enable it: the first start with
|
|
271
|
+
retention on already deletes.
|
|
272
|
+
- Give the file name a fixed part, as in `/dumps/core.%h.%t`. Placeholders
|
|
273
|
+
(`%h`, `%t`, `%p`, `%%`) belong in the file name only, never in the
|
|
274
|
+
directory path.
|
|
275
|
+
- Leave room for `N + 1` dumps of the memory limit: the retained ones plus the
|
|
276
|
+
next write before the kernel restarts. Retention does not cap bytes and does
|
|
277
|
+
not prevent an eviction between starts.
|
|
278
|
+
- Pruning runs only when dumps are enabled and `DOTNET_DbgMiniDumpName` is
|
|
279
|
+
set. A negative value is invalid.
|
|
280
|
+
- Pruning is not a guarantee. It considers only regular files whose names
|
|
281
|
+
match the configured name, skips names ending in `.partial`, and does not
|
|
282
|
+
check that a dump is complete. It gives up for that start after a few
|
|
283
|
+
seconds or when the directory holds more than 1000 entries, and never fails
|
|
284
|
+
startup; the kernel log says when it gave up. The directory can therefore
|
|
285
|
+
hold more than `N` dumps: watch the volume's free space rather than rely on
|
|
286
|
+
the count.
|
|
287
|
+
|
|
288
|
+
**A dump is a copy of the kernel's memory.** It contains storage connection
|
|
289
|
+
strings, certificate and signing keys, and event data, including personal data
|
|
290
|
+
that is encrypted at rest. Treat every dump as a secret that holds personal
|
|
291
|
+
data: restrict who can take and copy it, never attach it to an issue, and
|
|
292
|
+
delete every copy when the analysis is done. Erasing a person's data does not
|
|
293
|
+
remove it from an earlier dump.
|