@cratis/pi 8.4.1 → 8.5.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/scripting.instructions.md +2 -1
- 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/scripting.md +2 -1
- package/package/corpus/skills/cratis-application-growth/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +3 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +28 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +3 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +1 -1
- 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/references/csharp-chronicle.md +1 -1
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +2 -2
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +7 -7
- 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 +6 -6
- 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 +3 -1
- package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +10 -7
- 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/references/csharp.md +7 -5
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +3 -2
- package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +7 -0
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp-extensions.md +4 -0
- package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/csharp.md +4 -2
- package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +17 -22
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +11 -1
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +10 -3
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +7 -3
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +1 -1
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-arc-testing-typescript/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-arc-validation-typescript/SKILL.md +1 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +5 -5
- 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 +22 -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/python.md +2 -2
- package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +4 -3
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +86 -16
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +3 -3
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +14 -6
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +33 -1
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +27 -1
- package/package/corpus/skills/cratis-chronicle-evolve-event/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +4 -4
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +8 -7
- 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 +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +2 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +3 -3
- package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +2 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +2 -2
- 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 +4 -2
- package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +6 -5
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/elixir-integrations.md +3 -3
- package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +2 -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 +3 -3
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +2 -2
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +1 -1
- 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.md +3 -3
- 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-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.md +2 -2
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +2 -1
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +1 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +1 -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 +8 -2
- package/package/corpus/skills/cratis-fundamentals-name-value/SKILL.md +8 -7
- package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +3 -3
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +3 -0
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-platform-deliver-slice/references/typescript.md +14 -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-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 +5 -3
- package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +2 -2
- package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +6 -10
- 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 +19 -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 +26 -48
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/studio.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/references/csharp-command-results.md +1 -1
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +6 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +3 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +15 -2
- 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 +1 -1
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/typescript.md +4 -2
- 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.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cratis-arc-react-bind-slice
|
|
3
|
-
description: Use when a developer mounts the Arc React host, binds a generated query or command proxy in a React component, coordinates several command editors with one Save/Discard (CommandScope), or reads identity, availability or slice context in React. Not for a standard table (use cratis-components-display-list), a form that collects command input (use cratis-components-submit-form), view-model classes (use cratis-arc-react-separate-view-model) or producing the proxies (use cratis-arc-generate-proxies).
|
|
3
|
+
description: Use when a developer mounts the Arc React host, binds a generated query or command proxy in a React component, coordinates several command editors with one Save/Discard (CommandScope), or reads identity, availability or slice context in React, including folder-derived slice locations from the Arc Vite SliceLocationPlugin. Not for a standard table (use cratis-components-display-list), a form that collects command input (use cratis-components-submit-form), view-model classes (use cratis-arc-react-separate-view-model) or producing the proxies (use cratis-arc-generate-proxies).
|
|
4
4
|
compatibility: Requires react, react-dom, reflect-metadata, @cratis/arc, @cratis/arc.react and @cratis/fundamentals, plus proxies generated for React.
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ compatibility: Requires react, react-dom, reflect-metadata, @cratis/arc, @cratis
|
|
|
20
20
|
|
|
21
21
|
Arc React binds a React screen to backend slices through **generated proxies**: one class per query and per command, emitted by the proxy generator (`cratis-arc-generate-proxies`) for any backend language. A proxy carries the route, argument and result types, client validation rules and typed React hooks; whether it also carries a server part and slice location depends on the backend SDK (see Generated metadata in your language reference). A screen never writes `fetch`, a URL or a hand-made proxy.
|
|
22
22
|
|
|
23
|
-
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. React screens use the typescript reference whatever the backend; the sections named below are there.
|
|
23
|
+
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. React screens use the typescript reference whatever the backend; the sections named below are there.
|
|
24
24
|
|
|
25
25
|
## When to use it
|
|
26
26
|
|
|
@@ -31,11 +31,11 @@ Read `references/<language>.md` for the project's SDK (`.csproj` → csharp, Nod
|
|
|
31
31
|
## How it behaves at runtime
|
|
32
32
|
|
|
33
33
|
- **One host**, mounted once, supplies request settings, the query cache, identity, the root messenger, a default command scope and slice context.
|
|
34
|
-
- **Two kinds of query.** A *snapshot* query is request/response and can be re-run; an *observable* query is a live subscription the server pushes to. The backend return type decides
|
|
35
|
-
- **Shared, cached entries.** Hooks with the same query, arguments, page, page size and sort order share one cache entry. Observable hooks on it share one subscription. Snapshot hooks share only the last result: each mount sends its own request and `perform()` refreshes its own hook, so give shared snapshot data one owner and pass it down, or use an observable query (see Snapshot query in your language reference). A released entry is kept for the retention window (30 seconds unless configured); returning within it shows cached data at once while a snapshot query fetches again. Other arguments, page or sort
|
|
36
|
-
- **Delta transfer.** By default
|
|
37
|
-
- **Arguments are checked before sending.**
|
|
38
|
-
- **Commands are independent instances**, stable across renders, with the host's settings, change tracking against initial values, and registration in the nearest command scope.
|
|
34
|
+
- **Two kinds of query.** A *snapshot* query is request/response and can be re-run; an *observable* query is a live subscription the server pushes to. The backend return type decides; collection queries add sorting and paging.
|
|
35
|
+
- **Shared, cached entries.** Hooks with the same query, arguments, page, page size and sort order share one cache entry. Observable hooks on it share one subscription. Snapshot hooks share only the last result: each mount sends its own request and `perform()` refreshes its own hook, so give shared snapshot data one owner and pass it down, or use an observable query (see Snapshot query in your language reference). A released entry is kept for the retention window (30 seconds unless configured); returning within it shows cached data at once while a snapshot query fetches again. Other arguments, page or sort use another entry, never the previous key's data.
|
|
36
|
+
- **Delta transfer.** By default a shared-hub subscription asks for an initial snapshot, then only changes, applied by the ordinary hook; direct mode and Polling are outside this. Changes need items with an `Id` property: the .NET backend sends a full snapshot on every change for a collection whose items have none, and for a sorted or paged collection when a change would reorder it.
|
|
37
|
+
- **Arguments are checked before sending.** If the query's client validator reports a finding, Arc returns a ready, invalid result without sending the query; any finding blocks, even one with `withSeverity` Warning or Information (only commands filter by allowed severity). A missing required argument is a separate skip: nothing is sent and an observable hook never subscribes, so gate it with `when`.
|
|
38
|
+
- **Commands are independent instances**, stable across renders, with the host's settings, change tracking against initial values, and registration in the nearest command scope. Expected failures come back as a failed result rather than an exception: a refusal, an unknown route, a network failure and an unreadable response. The last three have `hasExceptions` true and `isRetryable` false. Execution can still reject on an unexpected error (such as a throwing headers callback), so branch on the result and also keep a `catch`.
|
|
39
39
|
- **Reads catch up after writes.** Success means the write was accepted; the read model updates shortly after and an observable query pushes it. Nothing refreshes a snapshot query (neither the command nor a command scope): call its `perform()` after success, and expect it may lag. Prefer an observable query for data the screen's own commands change.
|
|
40
40
|
- **Headers are read per request; caches keep the old caller.** Cached results, open live connections and the identity stay the previous caller's until you update the identity and reconnect (see Identity).
|
|
41
41
|
|
|
@@ -66,12 +66,12 @@ For a screen specified in an accepted model (`cratis-screenplay-accept-model`),
|
|
|
66
66
|
| `observableQueryTransferMode` | Delta (default) or Full; global across nested hosts. Set before any subscription. |
|
|
67
67
|
| `queryCacheRetentionMs` | How long a released query entry and its subscription stay cached. Zero evicts immediately. |
|
|
68
68
|
| `eventSourceFactory` | Custom server-sent-events client where the global one is missing or needs credentials. |
|
|
69
|
-
| `sliceMarkers` | Marks slice
|
|
70
|
-
| `applicationContext` |
|
|
69
|
+
| `sliceMarkers` | Off by default. Marks slice scopes and open `useDialog` content with `data-cratis-*` attributes for tooling. |
|
|
70
|
+
| `applicationContext` | A `new ApplicationContext()` created outside React; non-React code reads it with `subscribe` and `getSnapshot`. |
|
|
71
71
|
|
|
72
72
|
From the Arc context, `reconnectQueries()` drops every cached result (ordinary and Suspense), closes the shared live connections and re-runs mounted queries with current credentials; `observableQueryDiagnostics` serves tooling (`cratis-arc-diagnose-live-query`). Nested hosts do not isolate transport, headers or identity. The live transport must reach the backend through any proxy or gateway, under the API prefix.
|
|
73
73
|
|
|
74
|
-
**Startup globals** (before rendering): Polling timing
|
|
74
|
+
**Startup globals** (before rendering): Polling timing and the snapshot-query HTTP method; `Auto` can retry as GET, so use it only for URL-safe arguments. See Startup globals in your language reference.
|
|
75
75
|
|
|
76
76
|
### Query hooks (on each generated query)
|
|
77
77
|
|
|
@@ -92,7 +92,7 @@ From the Arc context, `reconnectQueries()` drops every cached result (ordinary a
|
|
|
92
92
|
- **Disabled (`when(false)`)**: the hook returns the empty default, ready, though nothing ran; a single-item default is an empty object, so check the condition before `hasData`. A called `perform` still runs. `when` is not authorization.
|
|
93
93
|
- **Suspense:** a failure throws `QueryFailed` (exceptions) or `QueryUnauthorized`; an invalid or unsuccessful result is returned, so check `isValid` and `isSuccess` first. A boundary reset replays a cached failure, so screens needing retry use the ordinary hooks. Suspense keeps its own caches (see Suspense in your language reference).
|
|
94
94
|
- **Suspense with observable collections** replaces `data` per emission without applying deltas, so in Delta mode an update can empty the list. Suspend only snapshot queries, single items, or a Full-mode host.
|
|
95
|
-
- **Change streams** hold the latest change set as state: the server's
|
|
95
|
+
- **Change streams** hold the latest change set as state: the server's when it sends one (even first), otherwise a diff of successive results, where the first and every Full-mode result list all items as added. Diffs ignore order. `getKey` (stable primitive) lets a diff report replaced instead of removed plus added. Sync an external collection's membership with it, never announce domain events (see Change stream in your language reference).
|
|
96
96
|
|
|
97
97
|
### Query boundaries and scope
|
|
98
98
|
|
|
@@ -122,9 +122,7 @@ The result has `data` and flags. Check in this order; stop at the first that app
|
|
|
122
122
|
|
|
123
123
|
### Command result
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
Findings carry `severity` (information, warning, error), `message`, `members` (property names, for matching fields), `reason` and `reasonDetail`. Choose copy by `reason` (`rule`, `validatorFailed`, `dependencyUnavailable`, `malformedRequest`, `frameworkFailure`, and with Chronicle `concurrencyViolation` or `constraintViolation`), never by message text; treat an unknown reason as `rule`.
|
|
125
|
+
The result has flags, `validationResults`, a typed `response` (only on success) and chainable callbacks (full list: Commands in your language reference). Findings carry `severity`, `members` (property names), `reason` and `reasonDetail`. Choose copy by `reason`, never by message text; treat an unknown reason as `rule`.
|
|
128
126
|
|
|
129
127
|
Classify a refusal in this order: suspended, not available, unauthorized, missing handler, concurrency violation, retryable, validation by field, anything else. A `concurrencyViolation` with `reasonDetail` `ReadChanged` or `ReadIncomplete` is a guarded read that changed or could not be completed, whatever `isRetryable` says: nothing was written, so re-read, keep the draft and let the user resubmit explicitly. Always keep the user's input and clear any busy state.
|
|
130
128
|
|
|
@@ -138,7 +136,7 @@ Classify a refusal in this order: suspended, not available, unauthorized, missin
|
|
|
138
136
|
|
|
139
137
|
`useIdentity()`: `id`, `name`, `roles`, `details` (typed through `detailsType` or a type argument; may be absent), `isSet`, `isLoading`, `isInRole(role)`, `refresh()`, `clearIdentity()`.
|
|
140
138
|
|
|
141
|
-
When credentials change, change them first, then `refresh()` the identity (sign-in, new roles) or `clearIdentity()` (sign-out; it only resets the local identity), then `reconnectQueries()` before caller-scoped data renders.
|
|
139
|
+
When credentials change, change them first, then `refresh()` the identity (sign-in, new roles) or `clearIdentity()` (sign-out; it only resets the local identity), then `reconnectQueries()` before caller-scoped data renders. Arc resets no state in components that stay mounted, but `RequireRole` unmounts its children and their state for `whileLoading` during `refresh()` and for `forbidden` after `clearIdentity()`, and `refresh()` reloads the page when a signed-in identity resolves to unset. A full page load is the conservative default for an account switch. See Sign-in, sign-out and account switch in your language reference.
|
|
142
140
|
|
|
143
141
|
`RequireRole` renders children for `roles` (any one) and/or an `allow(details, identity)` predicate (both must pass when given), with `whileLoading` and `forbidden` slots. It forbids anonymous callers, denies when details are missing or the predicate throws, and with no rule denies everyone. It only hides; the server still authorizes every request.
|
|
144
142
|
|
|
@@ -147,18 +145,15 @@ When credentials change, change them first, then `refresh()` the identity (sign-
|
|
|
147
145
|
Availability says, live, whether a part is offered to this tenant or user at all. Use it only when the backend serves it (see Generated metadata and Availability in your language reference).
|
|
148
146
|
|
|
149
147
|
- `AvailabilityProvider` goes below the host; without it everything is available, with it nothing is until the first decision.
|
|
150
|
-
- `RequireAvailable
|
|
151
|
-
- `useIsAvailable(part, args?)`: `isAvailable`, `isNotAvailable`, `isSuspended`, `reason`, `isKnown` (not known is pending).
|
|
152
|
-
- `useAvailableItems(items, partOf)`: the default for navigation and menus; keeps entries without a part and drops those unavailable, suspended or not yet known. Keep items and selector stable.
|
|
153
|
-
- `useAvailability()`: the decision object, with `isAvailable(part)`, `availabilityOf(part)` and `filter`.
|
|
148
|
+
- Gate a screen with `RequireAvailable` (`part`, optional `args`, slots `whileLoading`, `unavailable`, `suspended`), a control with `useIsAvailable(part, args?)` (not `isKnown` is pending), and navigation or menus with `useAvailableItems(items, partOf)` (keep both stable). `useAvailability()` gives the decision object.
|
|
154
149
|
|
|
155
150
|
A part is a generated proxy (class or instance) carrying its part, or a full server name. Arguments scope the question and grant nothing. Nest `RequireAvailable` outside `RequireRole`. It only hides; the server still refuses an unavailable or suspended part.
|
|
156
151
|
|
|
157
152
|
### Messaging, slice, application context and dialogs
|
|
158
153
|
|
|
159
|
-
- **Messaging:** `MessengerScope`, `useOnMessage`, `useSendMessage` and `useMessenger` pass typed notifications
|
|
160
|
-
- **Slice context:** `useSliceContext()` gives the module, feature and slice a component renders in. Generated hooks register their proxy's slice location when it has one; `Slice
|
|
161
|
-
- **Application context:** `useApplicationContext()`
|
|
154
|
+
- **Messaging:** `MessengerScope`, `useOnMessage`, `useSendMessage` and `useMessenger` pass typed notifications (scoping: `cratis-arc-react-separate-view-model`).
|
|
155
|
+
- **Slice context:** `useSliceContext()` gives the module, feature and slice a component renders in. Generated hooks register their proxy's slice location when it has one; `Slice`, `withSliceLocation`, the Arc Vite slice-location plugin (from folders) and `useRegisterSliceLocation` declare it otherwise.
|
|
156
|
+
- **Application context:** `useApplicationContext()` tells shared chrome what the user is viewing; contribute the screen and values with `useContributeApplicationContext` or `ApplicationContextContributor`, since Arc does not track routes. See Slice and application context in your language reference.
|
|
162
157
|
- **Dialogs**, confirmations and busy indicators: `cratis-components-coordinate-feedback`.
|
|
163
158
|
|
|
164
159
|
## Avoid
|
|
@@ -71,7 +71,9 @@ export function describeRefusal(result: CommandResult<unknown>): string {
|
|
|
71
71
|
}
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
A result has `isSuccess`, `isAuthorized`, `isValid`, `hasExceptions`, `validationResults`, `exceptionMessages`, `exceptionStackTrace`, `authorizationFailureReason`, `isRetryable`, `errorCode`, `isMissingHandler`, `isNotAvailable`, `isSuspended`, `response` (typed, only on success) and `correlationId`. Each finding has `severity`, `message`, `members` (property names, for matching fields), `reason` and `reasonDetail`.
|
|
75
|
+
|
|
76
|
+
The `reason` of a finding is one of `rule`, `concurrencyViolation`, `constraintViolation`, `validatorFailed`, `dependencyUnavailable`, `malformedRequest` or `frameworkFailure` (`concurrencyViolation` and `constraintViolation` come with Chronicle); `reasonDetail` narrows it. Treat an unknown reason as `rule`. Use them to select application-approved copy. Exception messages and stack traces are diagnostics.
|
|
75
77
|
|
|
76
78
|
The result also chains callbacks for simple cases:
|
|
77
79
|
|
|
@@ -126,6 +128,12 @@ const full = await command.validate(); // client rules, then the server's
|
|
|
126
128
|
|
|
127
129
|
Both return a command result; neither performs the command. Server validation is early feedback, not a permission check or a guarantee that execution will succeed.
|
|
128
130
|
|
|
131
|
+
A result describes the draft it was sent for. When you show validation yourself:
|
|
132
|
+
|
|
133
|
+
- Keep a revision counter. Bump it on every edit and when saving starts, and apply a `validate()` result only while its revision is still current.
|
|
134
|
+
- On blur, replace that field's messages with `result.validationResults.filter(r => r.members.includes(field))`, even when the list is empty, so a fixed field clears. `CommandResult` has no `hasErrors` or `getErrorsFor`.
|
|
135
|
+
- To save, always call `execute()`, even after a passing `validate()`: it checks the client rules again and the server decides. Take the status and messages from its result (`isSuccess`, `validationResults`), and disable the inputs and the button while it runs so the result matches the draft on screen.
|
|
136
|
+
|
|
129
137
|
## Aggregate a section with CommandScope
|
|
130
138
|
|
|
131
139
|
```tsx
|
|
@@ -186,5 +194,7 @@ const result = await command.execute();
|
|
|
186
194
|
|
|
187
195
|
A constructed command uses the global configuration only; it does not receive the provider's `httpHeadersCallback` or register with a scope. Prefer the hook inside components.
|
|
188
196
|
|
|
197
|
+
`execute()` does not throw on a network failure or an unreadable response: it returns a result with `hasExceptions` true and `isRetryable` false, so handle those by branching on the result flags. The server may already have run the command in that case; resend only a command that is safe to repeat. The call can still reject on an unexpected error, such as a headers callback that throws, so keep a `catch` for that, as in the React example above.
|
|
198
|
+
|
|
189
199
|
- `command.onPropertyChanged(property => ..., this)` notifies when a command property is assigned, for code that must react to edits without React state.
|
|
190
200
|
- `IdentityProvider` from `@cratis/arc/identity` is the non-React identity access: `await IdentityProvider.getCurrent()` (cached), `IdentityProvider.refresh()` and, at sign-out, `IdentityProvider.clearCache()`.
|
|
@@ -153,8 +153,15 @@ import { useSliceContext } from '@cratis/arc.react/slices';
|
|
|
153
153
|
import { useApplicationContext } from '@cratis/arc.react/applicationContext';
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
`useSliceContext()` tells a component which module, feature and slice it renders in. `useApplicationContext()` lets shared chrome (a feedback button, a help link) read what the user is currently viewing.
|
|
156
|
+
`useSliceContext()` tells a component which module, feature and slice it renders in. `useApplicationContext()` lets shared chrome (a feedback button, a help link) read what the user is currently viewing.
|
|
157
157
|
|
|
158
|
-
- **Explicit slice scope**, when proxies carry no slice location (see Generated metadata) or a hand-written component needs one: `<Slice module="Fleet" feature="Vehicles" slice="Registration"
|
|
159
|
-
- **Folder-derived slice scope**: `SliceLocationPlugin()` from `@cratis/arc.vite/slices` wraps exported `.tsx` and `.jsx`
|
|
158
|
+
- **Explicit slice scope**, when proxies carry no slice location (see Generated metadata) or a hand-written component needs one: `<Slice module="Fleet" feature="Vehicles" slice="Registration">` gives that location to everything inside it; the nearest explicit `<Slice>` wins. `withSliceLocation(Component, location)` gives a component a folder scope instead: the common location of the command and query hooks registered directly in that scope (with no nearer scope of their own) refines it only when it lies on or below the folder path, and any enclosing explicit `<Slice>` overrides it. Descendants can have their own scopes. `useRegisterSliceLocation(location)` registers a location from a custom hook.
|
|
159
|
+
- **Folder-derived slice scope**: `SliceLocationPlugin()` from `@cratis/arc.vite/slices` wraps exported components in slice folders at build time (in `.tsx` and `.jsx` files unless `include` is set; never in `node_modules`), as `withSliceLocation(Component, new SliceLocation(...))`. For example `SliceLocationPlugin({ roots: ['Features'], exclude: /[\\/]Shared[\\/]/ })`: `roots` lists folders whose subfolders are module, feature and slice, and `segmentsToSkip` maps files under no root. `include` and `exclude` are each one `RegExp` tested against the file path, not a glob or an array.
|
|
160
|
+
- It wraps only a component declared in the same file and exported as default or under a name that starts with an uppercase letter. A component here is a function, not async or a generator, whose every return is JSX, a `React.createElement(...)` call, `null` or `undefined` (at least one element), or a call such as `memo(...)`, `forwardRef(...)` or `withViewModel(...)` given one. Imported components exported again (`export default Imported`, `export { Screen } from './Screen'`), lowercase named exports, classes and unexported components are left alone; wrap such a screen in `<Slice>`.
|
|
161
|
+
- A wrapped `export function` becomes a constant and is no longer hoisted: top-level code in the same module that uses it before its declaration throws. Use it after the declaration or from another module.
|
|
162
|
+
- A folder scope follows the rendered tree, so a shared component in a mapped folder (such as a panel that renders `children`) gives its folder location to children with no nearer scope of their own, unless an explicit `<Slice>` encloses it. Match shared folders with `exclude`, or keep them outside the whole mapping: with `segmentsToSkip` set, a file under no root is still wrapped when it lies inside the Vite project root and at least one folder segment remains after skipping.
|
|
160
163
|
- **Store access**: `useApplicationContextStore()` returns the store `<Arc>` provides (undefined outside it), for code that subscribes to it directly. `useRegisterScope(scope)` registers a hand-built slice scope in the current page or dialog layer; `Slice` and `withSliceLocation` already do this.
|
|
164
|
+
- **Snapshot**: `useApplicationContext()` returns `location` (the `SliceLocation` of the user's focus: the page, or the top-most tracked dialog), `activeSlices`, `screen` (`{ id, name, path }`), `dialogs` (tracked dialogs, bottom first, each `{ id, title?, location }`) and `contributions`. Opening a tracked dialog moves `location` to it; closing it restores the dialog below or the page. `useSliceContext()` gives the calling component's own location, not the user's focus.
|
|
165
|
+
- **Screen and values**: Arc does not track routes, so `screen` stays empty strings until something contributes it. Contribute it from the router for each route with `<ApplicationContextContributor screen={{ id: 'vehicles', name: 'Vehicles', path: '/vehicles' }} values={...}>` or `useContributeApplicationContext({ screen: { ... }, values: { ... } })`. A contribution is removed on unmount; later contributions win for each screen field and value key.
|
|
166
|
+
- **Outside React**: create `new ApplicationContext()` from `@cratis/arc.react/applicationContext`, pass it as `<Arc applicationContext={...}>`, and read it with `subscribe(listener)` (returns an unsubscribe function) and `getSnapshot()`. Without the prop, `<Arc>` creates its own store.
|
|
167
|
+
- **DOM markers**: `<Arc sliceMarkers>` is off by default. When on, `<Slice>`, `withSliceLocation`, folder-derived slice scopes and `useDialog` content render a `display: contents` element carrying `data-cratis-module`, `data-cratis-feature` and `data-cratis-slice`; unknown parts are empty strings. The root scope and scopes registered with `useRegisterScope` get no element; wrap those in `<SliceMarker scope={...}>` yourself. Tooling resolves an element with `element.closest('[data-cratis-module]')` and reads those three attributes; no marked ancestor means no location. Content a renderer portals elsewhere is outside that element: either spread `sliceMarkerAttributes(useDialogSliceLocation())` on the portal container, or read `const scope = useContext(SliceScopeContext)` (`SliceScopeContext` from `@cratis/arc.react/slices`; its value may be `undefined`) and, when `scope` is set, wrap the portal content in `<SliceMarker scope={scope}>` (from `@cratis/arc.react/applicationContext`). In an untracked dialog (`trackInApplicationContext: false`), `useDialogSliceLocation()` is empty, so only the first option carries no location; `SliceMarker` still marks the dialog's scope.
|
|
@@ -86,9 +86,13 @@ const afterSignOut = () => { // the session is already ended
|
|
|
86
86
|
1. Change the credentials first: complete sign-in, end the session, or install the new token where `httpHeadersCallback` reads it.
|
|
87
87
|
2. Update the identity: `refresh()` after a sign-in or a backend change to roles or details (`isLoading` is true until it completes); `clearIdentity()` after a sign-out. `clearIdentity()` only resets the local identity to anonymous; it neither ends the session nor touches queries.
|
|
88
88
|
3. Call `reconnectQueries()` before caller-scoped data renders. It drops every cached result, closes the shared live connections and re-runs mounted queries with the current credentials. It does not keep cached results.
|
|
89
|
-
4.
|
|
89
|
+
4. Arc resets no state in components that stay mounted: view models, drafts and command values stay. Two things do discard state: `RequireRole` replaces its children, unmounting them and their local state, with `whileLoading` while `refresh()` runs and with `forbidden` after `clearIdentity()`; and `refresh()` can reload the page (below). For an account switch, or when state may hold the previous caller's data, a full page load is the conservative default; it also suits a sign-out that redirects to a sign-in page.
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
While `refresh()` runs, the current identity stays in place and `isLoading` is true. Then:
|
|
92
|
+
|
|
93
|
+
- **Resolved:** the result, set or unset, replaces the identity and every `useIdentity` consumer re-renders. A 401, 403, 500 or other unsuccessful answer resolves to an unset identity. A 404 (no identity endpoint) falls back to a readable legacy identity cookie, so it can still resolve to a set identity.
|
|
94
|
+
- **Reloaded:** when the result is unset and the identity whose `refresh` you called was set, the provider also reloads the page so the host can redirect to sign-in. The promise still resolves, with the unset identity. Call `refresh()` on the current `useIdentity()` value.
|
|
95
|
+
- **Rejected:** a network error, or a response that could not be read even though the request succeeded: no reload, the provider's current identity stays, `isLoading` returns to false and the promise rejects. Catch it and decide what to show.
|
|
92
96
|
|
|
93
97
|
## Availability
|
|
94
98
|
|
|
@@ -126,6 +130,6 @@ export const Navigation = () => {
|
|
|
126
130
|
- Without the provider, everything is available. With it, nothing is reported available until the first decision arrives.
|
|
127
131
|
- `useIsAvailable` returns `isAvailable`, `isKnown`, `isNotAvailable`, `isSuspended` and `reason`. Treat `!isKnown` as pending, not as available. Pass the same argument values the execution will use.
|
|
128
132
|
- `suspended` means an operator paused the part; it lifts without a reload. Report it differently from "not offered" and from "not permitted". On a screen, show it through `RequireAvailable`'s `suspended` slot, which falls back to `unavailable` when omitted.
|
|
129
|
-
- `RequireAvailable` takes `args` for a part whose availability depends on argument values. `useAvailability()` returns the
|
|
133
|
+
- `RequireAvailable` takes `args` for a part whose availability depends on argument values. `useAvailability()` returns the decision object for custom checks, with `isAvailable(part)`, `availabilityOf(part)` and `filter(items, partOf)`.
|
|
130
134
|
- `useAvailableItems` is the default for navigation and menus. It keeps entries without a part (return `undefined` from the selector) and drops entries whose part is not available, suspended or not yet known, so a gated link never flashes. Declare the entries and the selector outside the component, or memoize them; inline values recompute the filtered list on every render.
|
|
131
135
|
- A command result reports the same refusals as `isNotAvailable` and `isSuspended`.
|
|
@@ -132,7 +132,7 @@ export function VisitMarkers({ layer }: { layer: MarkerLayer }) {
|
|
|
132
132
|
}
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
For a query with parameters the arguments come first: `VisitsForSite`-style observable queries use `useChangeStream({ siteId }, visit => visit.id.toString())`.
|
|
135
|
+
For a query with parameters the arguments come first: `VisitsForSite`-style observable queries use `useChangeStream({ siteId }, visit => visit.id.toString())`. A change set the server provides wins, even for the hook's first result and on a Full-mode host. Without one, the first result (which an already-warm cache can supply) and every Full-mode result list all current items under `added`; later Delta results are diffed against the previous one. A diff compares membership and content, not order, so a reorder alone reports nothing, and new arguments or a new sort can list items under `removed` that merely left the result, with no domain deletion. Use the stream to keep an external collection's members in sync (`MarkerLayer` stands for any external view), never to announce domain events; when order or Arc paging matters, use the ordinary observable result. The key selector is used only when the hook diffs two results itself. In Delta mode the .NET backend sends change sets only for items with an `Id` property; the hook takes such a change set as is (without re-diffing) and rebuilds its collection by matching items on `id`. A collection whose items have no `Id`, and a sorted or paged one whose order a change set cannot keep, gets full snapshots instead, which the hook diffs with the key selector.
|
|
136
136
|
|
|
137
137
|
## One busy flag for several queries
|
|
138
138
|
|
|
@@ -39,7 +39,7 @@ Where proxies carry `part`, pass the proxy (class or instance) to an availabilit
|
|
|
39
39
|
| `@cratis/arc.react/availability` | `AvailabilityProvider`, `RequireAvailable`, `useIsAvailable`, `useAvailableItems`, `useAvailability`. |
|
|
40
40
|
| `@cratis/arc.react/messaging` | `MessengerScope`, `useMessenger`, `useOnMessage`, `useSendMessage`. |
|
|
41
41
|
| `@cratis/arc.react/slices` | `useSliceContext`, `Slice`, `withSliceLocation`, `useRegisterSliceLocation`, `SliceLocation`. |
|
|
42
|
-
| `@cratis/arc.react/applicationContext` | `useApplicationContext`, `useContributeApplicationContext`, `ApplicationContextContributor`, `useApplicationContextStore`, `useRegisterScope`. |
|
|
42
|
+
| `@cratis/arc.react/applicationContext` | `useApplicationContext`, `useContributeApplicationContext`, `ApplicationContextContributor`, `useApplicationContextStore`, `useRegisterScope`, `ApplicationContext` (store for use outside React), `sliceMarkerAttributes`, `SliceMarker`. |
|
|
43
43
|
| `@cratis/arc.vite/slices` | `SliceLocationPlugin` (build time). |
|
|
44
44
|
| `@cratis/arc` | `Globals`, `ObservableQueryTransferMode`. |
|
|
45
45
|
| `@cratis/arc/queries` | `QueryTransportMethod`, `QueryHttpMethod`, `lengthBasedQueryHttpMethod`, `resetQueryHttpMethodResolution`, `PollingOptions`. |
|
|
@@ -215,7 +215,7 @@ Register the event types, registered event sources, and the observers relevant t
|
|
|
215
215
|
|
|
216
216
|
`given.events` has no batch append-options argument. `correlationId`, `causedBy`, `generation` and `sourceSequenceNumber` on entry objects are import metadata, not seed-append overrides. Seed routing uses Chronicle's batch append rules; distinct declared concurrency guards for one source key may require separate batches.
|
|
217
217
|
|
|
218
|
-
The helper waits through the sequence number of the last append result, not through new events appended later by downstream reactors. Register the observers whose state you intend to assert: a wait can succeed without any matching observer.
|
|
218
|
+
The helper waits through the sequence number of the last append result, not through new events appended later by downstream reactors. Register the observers whose state you intend to assert: a wait can succeed without any matching observer. When Chronicle rejects every append with only constraint or concurrency violations, nothing is appended and the command fails with validation results. A concurrency violation has `reason` `'concurrencyViolation'`, and its `state` holds `eventSourceId`, `expectedEventSequenceNumber` and `actualEventSequenceNumber`. A constraint violation has `reason` `'constraintViolation'`, and the constraint ID is in `reasonDetail`. Assert the reason you expect, for example `result.shouldNotBeSuccessful().shouldHaveValidationErrorBecauseOf('constraintViolation')`. Any append error, such as an unavailable constraint index, makes the command report an exception instead of a validation result. A failed observer wait is different: it can fail the command after the events were committed, so also assert what was appended. Caller cancellation can stop the command wait without undoing the append. Setup, log reads and disposal can reject separately from a returned command result.
|
|
219
219
|
|
|
220
220
|
```typescript
|
|
221
221
|
import { ChronicleKernelScenario } from '@cratis/arc.chronicle/testing';
|
|
@@ -233,7 +233,7 @@ try {
|
|
|
233
233
|
|
|
234
234
|
## Kernel-backed queries
|
|
235
235
|
|
|
236
|
-
Use `withChronicle({ eventStore, connectionString })` for an Arc-owned connection, or supply `client` instead of `connectionString` for a caller-owned client you initialize and dispose. Set `completionTimeoutMs` to wait for observers after successful appends; without it, a successful command is not a barrier for read-model assertions. Match the application's `readModelNamingPolicy` if it customizes storage names (configure it on a caller-owned client). Use `activateArtifactsInScopes` only when testing that integration: it scopes reactor and reducer delivery; prefer the Arc-owned connection so Arc installs its activator and reactor result handler.
|
|
236
|
+
Use `withChronicle({ eventStore, connectionString })` for an Arc-owned connection, or supply `client` instead of `connectionString` for a caller-owned client you initialize and dispose. Set `completionTimeoutMs` to wait for observers after successful appends; without it, a successful command is not a barrier for read-model assertions. The TypeScript SDK does not send per-event-type tails, so an observer that does not handle the appended types can still block completion while it is behind the append's tail. Chronicle leaves out some observers, such as internal kernel reactors not subscribed in the namespace. If an awaited observer is still behind when the timeout elapses, the command reports an exception although its events are stored. Keep the real observers the test needs, and set `completionTimeoutMs` only where every observer included in the wait can reach each tested append's tail. Match the application's `readModelNamingPolicy` if it customizes storage names (configure it on a caller-owned client). Use `activateArtifactsInScopes` only when testing that integration: it scopes reactor and reducer delivery; prefer the Arc-owned connection so Arc installs its activator and reactor result handler.
|
|
237
237
|
|
|
238
238
|
Not supported by `ChronicleKernelScenario`: query or subscription entry points. Build an Arc application attached to a fresh kernel store with the real query and Chronicle artifacts. Act through the built server, not a second in-memory query scenario. Import `@cratis/arc.chronicle` for the builder integration; register the slice's generated metadata if it binds parameters that way. For example, with a decorated `CreateDispatchSlot` using explicit bindings, its registered `SlotCreated` event, the `DispatchSlot` read model with snapshot query `available`, and its observer `DispatchSlotProjection`:
|
|
239
239
|
|
|
@@ -105,6 +105,7 @@ Options and conditions need a preceding rule on the chain.
|
|
|
105
105
|
- `withState` — attach JSON-serializable data, fixed or derived from the model, to the last rule's finding.
|
|
106
106
|
- Generated proxies — a statement is copied only when it selects one declared member (a concept validator's rule is copied onto each command or arguments-model field of that concept) and uses only `notNull`, `notEmpty`, `minLength`, `maxLength`, `length`, `emailAddress`, `phone`, `url`, `matches` (flagless pattern, no message argument), `greaterThan`, `greaterThanOrEqual`, `lessThan` or `lessThanOrEqual` with literal finite arguments, plus a literal `withMessage`. Any other call in the statement (`when`, `unless`, `withSeverity`, `withState`, `must`, `mustAsync`, a computed message or argument) keeps the whole statement server-only and produces a generator diagnostic. Commands and queries with an explicit arguments model are covered.
|
|
107
107
|
- `treatWarningsAsErrors` — operation option that only sets the same-named flag on the generated proxy; it changes no server filtering.
|
|
108
|
+
- Browser-side checks — the allowed-severity rules in this skill are the server's. In the browser, any finding from a query's client validator blocks the query, whatever its severity; only a command's client checks are filtered by allowed severity. See `cratis-arc-react-bind-slice` for client behaviour.
|
|
108
109
|
|
|
109
110
|
## State, rejection and severity
|
|
110
111
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cratis-chronicle-cli-operations
|
|
3
|
-
description: Use when inspecting a
|
|
3
|
+
description: Use when inspecting a live Chronicle store, gating a release or deploy, running an authorized store operation or installing/updating AI guidance (`cratis ai`) via the cratis CLI; lists every `cratis chronicle` command. Not for picking MCP tools (use cratis-chronicle-mcp-inspection) or kernel configuration (use cratis-chronicle-deploy-kernel).
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ license: MIT
|
|
|
26
26
|
## How it behaves
|
|
27
27
|
|
|
28
28
|
- **Target.** The server is `--server`, then `CHRONICLE_CONNECTION_STRING`, then the active context, then `chronicle://localhost:35000`. The store and namespace are `-e`/`-n`, then the active context, then `default` and `Default`. `--debug` prints the resolved, redacted target on stderr. In an interactive terminal without `-e` or `--yes`, a store-scoped command whose context has no store, or names one the server no longer has, prompts for a store and saves the choice as the context default before it runs, even for a read. Pass `-e` and `-n` explicitly.
|
|
29
|
-
- **Output.** `-o auto` gives `json-compact` to a detected AI agent, `plain`
|
|
29
|
+
- **Output.** `-o auto` gives, in order: `json-compact` to a detected AI agent, `plain` when `NO_COLOR` is nonempty, `json` when stdout is redirected, and `table` otherwise. `-q` overrides any `-o` value except `json` and `json-compact`, which it turns into a JSON list of identifiers. In scripts and CI pass `-o` explicitly and pin the CLI version the parser was written against; output formats can change between CLI versions.
|
|
30
30
|
- **Confirmation.** A command with `requiresConfirmation` prompts in a terminal and fails with exit 5 in a non-interactive session unless `--yes` is given. `--yes` confirms; it never authorizes.
|
|
31
31
|
- **Exit codes.** 0 success, 1 not found, 2 unreachable, 3 server error or unhealthy, 4 authentication, 5 invalid input, refusal or missing confirmation, 10 internal failure. Branch on the code, not the text.
|
|
32
32
|
- **Accepted is not done.** Recovery commands often return once the server accepts the request and finish in the background. Re-read the state to learn the outcome.
|
|
@@ -35,7 +35,7 @@ license: MIT
|
|
|
35
35
|
|
|
36
36
|
Start with an installed CLI, a trusted server endpoint, read access and the exact event store and namespace.
|
|
37
37
|
|
|
38
|
-
1. Establish the intended server, store and namespace. If the target or credentials are unclear, read [setup and target](references/setup-and-target.md#reach-the-right-server). Do not run `cratis context list
|
|
38
|
+
1. Establish the intended server, store and namespace. If the target or credentials are unclear, read [setup and target](references/setup-and-target.md#reach-the-right-server). Do not run `cratis context list` or `context show` while a saved context might contain embedded credentials: they print saved servers verbatim. `chronicle auth status` redacts the saved server to scheme, hosts, ports and TLS state, and the login binding to host and port (or, for a binding saved as a URL, the same as the server); it can still show the saved username and client ID, never the token or client secret. None of them shows the effective target.
|
|
39
39
|
2. Pick the command from the catalog below. Run `cratis llm-context` to confirm the command, flags, `effect` and `requiresConfirmation` before relying on them. Use only `read-only` commands for diagnosis, never `report-error`; treat unknown effects as changes. Use `cratis llm-context --schema` for the catalog schema or `cratis <group> --help` for one group.
|
|
40
40
|
3. Read the smallest relevant scope and verify the effective target from the redacted `--debug` output on stderr. For example, inspect one observer:
|
|
41
41
|
|
|
@@ -91,7 +91,7 @@ Every command starts with `cratis chronicle`. Effect is the strongest change the
|
|
|
91
91
|
| `users list`, `users add <name> <email> <password>`, `users remove <user-id>` | read, mutating, destructive | Manage the users who sign in to the Workbench and the CLI |
|
|
92
92
|
| `applications list`, `applications add <client-id> <client-secret>`, `applications remove <app-id>` | read, mutating, destructive | Manage the client-credential applications that SDK clients connect as |
|
|
93
93
|
| `login <user>`, `logout` | local | Cache or clear a user session for the target server. `--secret <password>` signs in without a prompt |
|
|
94
|
-
| `auth status` | read | Show the active context's saved login
|
|
94
|
+
| `auth status` | read | Show the active context's saved login and client credentials: username, client ID and whether a secret is set, never the token or secret. JSON includes both identifiers; the readable view shows the username when a login is saved, otherwise the client ID. `loginMatchesServer` says whether the saved login's token is usable for the selected connection. Reads local configuration only. Redacts the saved server to scheme, host, port and TLS state, and the login binding to host and port (a binding saved as a URL keeps its scheme and TLS state) |
|
|
95
95
|
| `workbench` | destructive, interactive | Open the terminal dashboard (`--interval <seconds>` sets the refresh). See the `cratis-cli-terminal-workbench` skill |
|
|
96
96
|
| `report-error` | external | Open a prefilled public issue form in the browser (`--title`, `--body`; it prompts for both unless `-q`). The catalog calls it read-only, but the text leaves this machine: never use it for diagnosis, and keep identifiers, payloads and credentials out of it |
|
|
97
97
|
|
|
@@ -122,6 +122,6 @@ These commands outside `cratis chronicle` set the target, set up the tool and co
|
|
|
122
122
|
- **Reading results:** [Inspection results](references/inspection.md) covers output formats, every exit code, which command answers which question, and the `diagnose` readiness gate.
|
|
123
123
|
- **Release gate or model comparison:** [Recovery outcomes and comparison](references/recovery-and-comparison.md) covers `check-release` before a deploy and the read-only Screenplay namespace comparison after one.
|
|
124
124
|
- **Authorized recovery:** Check [command effects and write preflight](references/command-effects.md#preflight-for-a-write), then [recovery outcomes](references/recovery-and-comparison.md) for the exact operation. A diagnosis request does not authorize changes. Re-read after an accepted request and verify the actual outcome.
|
|
125
|
-
- **CLI upgrades, templates and managed AI installation:** [Project tooling](references/project-tooling.md).
|
|
125
|
+
- **CLI upgrades, templates and managed AI installation:** [Project tooling](references/project-tooling.md) covers `cratis ai install`/`update` in unattended setups and pinning a reviewed corpus revision.
|
|
126
126
|
|
|
127
127
|
Leave mutating interactive keys in the terminal Workbench to an operator.
|
|
@@ -15,9 +15,17 @@
|
|
|
15
15
|
There is one output flag, `-o` / `--output`, with values `table`, `plain`,
|
|
16
16
|
`json`, `json-compact`, and `auto`. **There is no `--json` flag.**
|
|
17
17
|
|
|
18
|
-
- `auto` (the default) resolves to `json-compact` when an AI-agent
|
|
19
|
-
is detected, `plain` when `NO_COLOR` is
|
|
20
|
-
and `table` otherwise.
|
|
18
|
+
- `auto` (the default) resolves, in order, to `json-compact` when an AI-agent
|
|
19
|
+
environment is detected, `plain` when `NO_COLOR` is nonempty, `json` when
|
|
20
|
+
stdout is redirected, and `table` otherwise. `-q` overrides the format: it
|
|
21
|
+
prints identifiers, as a JSON list with `-o json` or `-o json-compact`.
|
|
22
|
+
- Never rely on `auto` in a script: the same command changes format with the
|
|
23
|
+
environment. Pass `-o` explicitly and pin the CLI version (for example
|
|
24
|
+
`dotnet tool install -g Cratis.Cli --version <version>`); output formats are
|
|
25
|
+
not a stable contract across CLI versions.
|
|
26
|
+
- For list output (without `-q`), `plain` prints tab-separated rows with the
|
|
27
|
+
column headers on the first row. Some commands print their own plain layout
|
|
28
|
+
instead; `diagnose -o plain` prints `key=value` lines such as `healthy=True`.
|
|
21
29
|
- `-q` / `--quiet` prints identifiers only, one per line — what you want when
|
|
22
30
|
piping one command into another. Combined with a JSON format it yields a JSON
|
|
23
31
|
array of identifiers.
|
|
@@ -39,6 +39,28 @@ edit generated output to force a match.
|
|
|
39
39
|
|
|
40
40
|
## Managed AI installation and MCP
|
|
41
41
|
|
|
42
|
+
`cratis ai install` records the selected profiles, harnesses and languages in
|
|
43
|
+
`.cratis/ai.json`. `cratis ai update` re-applies that selection; its own options
|
|
44
|
+
are only `--source`, `--force` and `--dry-run` (global options such as `--output`
|
|
45
|
+
still apply). Run `install` again to change the selection.
|
|
46
|
+
When stdin is redirected, install cannot prompt: pass `--profiles` and
|
|
47
|
+
`--harnesses` (`--languages` is optional), or it exits 5 and downloads nothing.
|
|
48
|
+
A CI job or agent session whose stdin is still a terminal can reach a prompt, so
|
|
49
|
+
redirect stdin for unattended runs.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cratis ai install --profiles <profile> --harnesses claude,copilot </dev/null
|
|
53
|
+
cratis ai update --dry-run
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Both commands take whatever the corpus source currently holds; the installed
|
|
57
|
+
revision does not pin later runs. To reproduce a reviewed revision, pass
|
|
58
|
+
`--source <local Cratis/AI checkout>` or set `CRATIS_AI_SOURCE`, and use a fresh
|
|
59
|
+
checkout of the reviewed revision on every run. The CLI reads the corpus files
|
|
60
|
+
that match its layout and your selection from the working tree, not from a
|
|
61
|
+
recorded commit, so eligible untracked or ignored files are included and a clean
|
|
62
|
+
`git status` is not enough.
|
|
63
|
+
|
|
42
64
|
`.pi/agents` links to Pi-native corpus adapters when available. Do not
|
|
43
65
|
hand-edit generated adapters to restore missing tools; update the CLI/corpus.
|
|
44
66
|
|
package/package/corpus/skills/cratis-chronicle-cli-operations/references/recovery-and-comparison.md
CHANGED
|
@@ -66,9 +66,23 @@ never in the script text.
|
|
|
66
66
|
Run the [write preflight](command-effects.md#preflight-for-a-write) before any command below that
|
|
67
67
|
changes the store. A prompt or `--yes` is not authority to mutate a live store.
|
|
68
68
|
|
|
69
|
-
`chronicle jobs stop` and `resume`
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
`chronicle jobs stop` and `resume` exit nonzero when the kernel refuses (5, or
|
|
70
|
+
3 when a stop could not be made durable); they never report success for a
|
|
71
|
+
refused request. The terminal Workbench also reports refusals. A job that does
|
|
72
|
+
not exist when the request is validated, including a completed job whose record
|
|
73
|
+
was removed, fails both commands with exit 3 and "Job does not exist." Stop
|
|
74
|
+
names its refusal reason: a job not found (it vanished after validation), a
|
|
75
|
+
concluded job (a `Failed` one is reported as not found) or a job that is not
|
|
76
|
+
running. Resume has one generic refusal, "nothing took the job forward" (exit
|
|
77
|
+
5), and it is not a diagnosis: a never-prepared or `Failed` job, or one that
|
|
78
|
+
vanished after validation, causes it, and so can a pending drain, a refused or
|
|
79
|
+
failed admission check, or a failed state write. Resuming a completed job whose
|
|
80
|
+
record is still retained is accepted and exits 0.
|
|
81
|
+
|
|
82
|
+
In a script, let these exit codes fail the step; an earlier status read does not
|
|
83
|
+
replace the command's answer. After exit 0, read the status with
|
|
84
|
+
`jobs get <id> -o json` before relying on it. Do not repeat a refused command
|
|
85
|
+
without understanding the reason.
|
|
72
86
|
|
|
73
87
|
`cratis chronicle jobs delete <JOB_ID>` is destructive
|
|
74
88
|
and irreversible: retained job state is removed. Before confirmation it names
|
package/package/corpus/skills/cratis-chronicle-cli-operations/references/setup-and-target.md
CHANGED
|
@@ -14,7 +14,13 @@ Check the command catalog (`cratis llm-context`) before using a flag.
|
|
|
14
14
|
|
|
15
15
|
`cratis` is a .NET tool published as `Cratis.Cli` with the command name
|
|
16
16
|
`cratis`. Install it with `dotnet tool install -g Cratis.Cli`, or through
|
|
17
|
-
Homebrew, or from a release binary.
|
|
17
|
+
Homebrew, or from a release binary. Native release binaries are self-contained;
|
|
18
|
+
the .NET tool needs the runtimes its package targets, currently the .NET 11
|
|
19
|
+
runtime and the ASP.NET Core 11 shared runtime (the base runtime alone is not
|
|
20
|
+
enough). In CI,
|
|
21
|
+
pin the CLI version and set up a matching SDK (for example `actions/setup-dotnet`
|
|
22
|
+
with `dotnet-version: 11.0.x`) before `dotnet tool install`, or use a pinned
|
|
23
|
+
native release binary. Follow with `cratis completions install`;
|
|
18
24
|
it detects the shell from `$SHELL` (`--shell bash`, `zsh` or `fish` overrides
|
|
19
25
|
it) and `--force` re-adds the line. To manage the shell configuration yourself,
|
|
20
26
|
`cratis completions bash`, `zsh`, `fish` or `powershell` prints the script to
|
|
@@ -63,7 +69,7 @@ Use `cratis chronicle login <user>` (`--secret` or prompt), `chronicle logout`
|
|
|
63
69
|
and `chronicle auth status -o json` (`tokenServer`, `loginMatchesServer`). Login
|
|
64
70
|
refuses multi-host and `chronicle+srv://` targets. If the intended server requires login and no matching token is saved, sign in again. Context values can be changed
|
|
65
71
|
with `context set-value server|event-store|namespace|client-id|client-secret`.
|
|
66
|
-
Keep saved server strings free of credentials: `context list
|
|
72
|
+
Keep saved server strings free of credentials: `context list` and `context show` print saved servers verbatim, so do not run them while a saved context may embed credentials. `chronicle auth status` is safe then: it redacts the saved server to scheme, hosts, ports and TLS state and the login binding to host and port (a binding saved as a URL keeps its scheme and TLS state), and replaces a string it cannot parse with a placeholder. `loginMatchesServer` is `true` only when the saved login's token is usable for the selected connection. JSON still shows the saved username and client ID (the readable view shows the username when a login is saved), and only whether a client secret is set; it never shows the token or the secret. Keep secrets out of logs and committed configuration.
|
|
67
73
|
Default development-client credentials are registered only in development builds.
|
|
68
74
|
|
|
69
75
|
Prefer a named context over repeating a connection string:
|
|
@@ -35,8 +35,8 @@ A successful parse does not show that a kernel is reachable or that the identity
|
|
|
35
35
|
|
|
36
36
|
| Field of the frozen `ChronicleConnectionOptions` | Value |
|
|
37
37
|
|---|---|
|
|
38
|
-
| `host` | Host name, IPv4 address, or IPv6 address without its brackets |
|
|
39
|
-
| `port` |
|
|
38
|
+
| `host` | Host name, IPv4 address, or IPv6 address without its brackets. The parser preserves case, a trailing dot, and Unicode or punycode spelling. Comparing `host` strings checks spelling, not DNS equivalence |
|
|
39
|
+
| `port` | An `int`, defaulting to `DEFAULT_PORT` (`35000`). Leading zeros are accepted and dropped: `:035000` gives `35000` |
|
|
40
40
|
| `client_id`, `client_secret` | Percent-decoded. Absent credentials yield `DEVELOPMENT_CLIENT_ID` and `DEVELOPMENT_CLIENT_SECRET` |
|
|
41
41
|
| `tls` | Always `True` |
|
|
42
42
|
| `skip_tls_validation` | `True` unless `skipTlsValidation=false`; the certificate is then accepted unverified |
|
|
@@ -31,7 +31,7 @@ Names here are illustrative. Suppose a locker claims a pickup code until the loc
|
|
|
31
31
|
- **Retain per value:** when a source owns multiple identifiers, keep each until released. The owner can reclaim its own identifiers.
|
|
32
32
|
- **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
33
|
- **Value-specific removal:** map removal fields in tuple order when a retained identifier, rather than all the owner's identifiers, becomes free.
|
|
34
|
-
- **Unique event type:** when a fact may occur only once per source and scope, constrain its type instead of a field. A removal opens the next cycle.
|
|
34
|
+
- **Unique event type:** when a fact may occur only once per source and scope, constrain its type instead of a field. A removal opens the next cycle. If the removal type is itself constrained, it must pass the rule first, so a stored claim can reject it before it releases anything. A removal that passes ends the current cycle for that source and scope, including one opened earlier in the same batch or just started by a competing writer, so two racing release-and-reclaim batches can both succeed. When a release must end only the cycle the caller saw, also guard that append with a concurrency scope for that source and scope, filtered to the constrained and removal event types. Its expected position must be the revision the caller saw or the tail captured before reading those events; a materialized read model can lag that tail and hide a reclaim. On the event log, a decision read whose model covers that source, scope and every claim and removal type can supply the guard instead (`cratis-chronicle-protect-decision`). A tail sampled at append time misses a reclaim that it already includes.
|
|
35
35
|
- **Mutually exclusive event types:** group alternatives under one occurrence rule when any one of them must exclude the others until release.
|
|
36
36
|
- **Source type:** partition by the appending source's type when different types may reuse a value or start independent cycles.
|
|
37
37
|
- **Stream type:** partition by stream type when the same claim may coexist in distinct kinds of stream.
|
|
@@ -45,7 +45,7 @@ Settings come from the file `/app/chronicle.json` and from `Cratis__Chronicle__
|
|
|
45
45
|
| Capability | What it gives; when to use it | Reference |
|
|
46
46
|
| --- | --- | --- |
|
|
47
47
|
| Images | `latest-development` (with MongoDB), `latest-development-slim` (bring a database), `latest` (production). The image, not an environment name, decides development behaviour | [Images](references/development-and-production.md) |
|
|
48
|
-
| Storage engines | `MongoDB`, `PostgreSql`, `MsSql`, `Sqlite`, `InMemory`; database naming; PostgreSQL pools | [Storage](references/storage.md) |
|
|
48
|
+
| Storage engines | `MongoDB`, `PostgreSql`, `MsSql`, `Sqlite`, `InMemory`; database naming and MongoDB grants; PostgreSQL pools | [Storage](references/storage.md) |
|
|
49
49
|
| Schema jobs | Run with `--migrate-only` or `--verify-schema` (or `storage.schemaAction`) to migrate or check the schema and exit, when serving nodes must not change it | [Storage](references/storage.md) |
|
|
50
50
|
| Platform-managed databases | `storage.connectionResolution` resolves server, database, schema and identity per store and namespace, when a platform places each tenant's database | [Storage](references/storage.md) |
|
|
51
51
|
| Compliance key store | Keep encryption keys for personal data in HashiCorp Vault or Azure Key Vault instead of the main storage | [Storage](references/storage.md) |
|
|
@@ -69,11 +69,12 @@ Settings come from the file `/app/chronicle.json` and from `Cratis__Chronicle__
|
|
|
69
69
|
| Back-pressure | `registration` queues client registrations and answers busy; `overload` reports a degraded node | [Configuration](references/configuration.md) |
|
|
70
70
|
| Occurrences, imports, patterns | Occurrence delivery retry, bulk-import limits, pattern capture per store | [Configuration](references/configuration.md) |
|
|
71
71
|
| Federation | Exchange public events between separate kernels on a dedicated port (35100); off by default | [Configuration](references/configuration.md) |
|
|
72
|
-
| Clustering | Single node (default) or a multi-node cluster through MongoDB or SQL membership | [Configuration](references/configuration.md) |
|
|
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
|
+
| Constraint index repair | Retries and time budgets for keeping constraint indexes in step with the log; startup ranges | [Configuration](references/configuration.md) |
|
|
73
74
|
| Shutdown | Drain time on stop | [Configuration](references/configuration.md) |
|
|
74
75
|
| Alerts | Incidents for observer failure conditions | [Configuration](references/configuration.md) |
|
|
75
76
|
| Webhooks and external services | Where the kernel may call out, delivery retry, quarantine probes, managed identity | [Webhooks](references/webhooks.md) |
|
|
76
|
-
| Upgrade, backup, restore | Single-node, rolling or stop-all upgrades, restore order, System event store | [Upgrade](references/upgrade-and-recovery.md) |
|
|
77
|
+
| Upgrade, backup, restore | Single-node, rolling or stop-all upgrades, crossing major versions, restore order, System event store | [Upgrade](references/upgrade-and-recovery.md) |
|
|
77
78
|
| Troubleshooting | Symptom to setting | [Troubleshooting](references/troubleshooting.md) |
|
|
78
79
|
|
|
79
80
|
Kernel telemetry export is taught by the `cratis-observability` skill, and the Workbench by the `cratis-chronicle-web-workbench` skill.
|