@cratis/pi 7.165.1 → 7.165.3
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/agents/frontend-developer.md +1 -6
- package/package/corpus/harnesses/copilot/instructions/framework.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/github-actions.instructions.md +5 -2
- package/package/corpus/harnesses/copilot/instructions/new-repository-intake.instructions.md +4 -3
- package/package/corpus/harnesses/copilot/instructions/orleans.instructions.md +19 -19
- package/package/corpus/harnesses/copilot/instructions/verification-discipline.instructions.md +1 -1
- package/package/corpus/harnesses/pi/agents/frontend-developer.md +1 -6
- package/package/corpus/hooks/scripts/cratis-nuget-pins.txt +4 -4
- package/package/corpus/rules/framework.md +1 -1
- package/package/corpus/rules/github-actions.md +5 -2
- package/package/corpus/rules/new-repository-intake.md +4 -3
- package/package/corpus/rules/orleans.md +19 -19
- package/package/corpus/rules/verification-discipline.md +1 -1
- package/package/corpus/skills/cratis-chronicle-event-modeling/references/event-log-hygiene.md +1 -1
- package/package/corpus/skills/cratis-engineering-decision-record/SKILL.md +12 -6
- package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +17 -11
- package/package/corpus/skills/cratis-orleans-jobs/references/lifecycle-and-placement.md +2 -2
- package/package/corpus/skills/cratis-orleans-jobs/references/state-machines.md +6 -6
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/statemachines-and-workflows.md +1 -1
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/sandbox-and-specrunner.md +3 -3
- package/package/corpus/skills/orleans/SKILL.md +2 -2
- package/package.json +1 -1
|
@@ -231,12 +231,7 @@ export const Projects = () => {
|
|
|
231
231
|
|
|
232
232
|
## Browser verification (optional)
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
1. Open the app page in the integrated browser.
|
|
236
|
-
2. Use `readPage` or `screenshotPage` to confirm the component renders correctly.
|
|
237
|
-
3. Use `clickElement` or `typeInPage` to test interactive elements.
|
|
238
|
-
|
|
239
|
-
This closes the development loop — build, render, verify — without leaving the editor.
|
|
234
|
+
Browser tools are a capability, not authority, and only the `browser-operator` agent receives them (`browser.md`). Do not drive a browser yourself, even when the workspace enables editor browser tools. To verify the UI after implementation, hand `browser-operator` the URL, the scope, the permit and the artifact directory, and use its evidence record. Production stays read-only and sign-in stops for a human. If no `browser-operator` is available, report the UI as unverified rather than using browser tools directly.
|
|
240
235
|
|
|
241
236
|
---
|
|
242
237
|
|
|
@@ -37,7 +37,7 @@ Each framework repo is organized by what it builds, not by feature slices:
|
|
|
37
37
|
|
|
38
38
|
- **Fundamentals** — the base library. `ConceptAs<T>`, type discovery (`IInstancesOf<T>` / `IImplementationsOf<T>`), serialization, common primitives. `Source/DotNET` includes `Fundamentals.TypeDiscovery.Generator`, `Metrics.Roslyn` (`Cratis.Metrics.Roslyn`) and `OpenTelemetry` (`Cratis.OpenTelemetry`); `Source/JavaScript` publishes `@cratis/fundamentals`, and `Source/ESLintConfig` publishes `@cratis/eslint-config` (verified at v7.23.0).
|
|
39
39
|
- **Specifications** — BDD lifecycle, assertions and analyzers. `Source/Specifications` supplies common helpers, `Source/XUnit` and `Source/NUnit` supply runner-specific bases/assertions, and `Source/CodeAnalysis` supplies the bundled analyzers (v4.1.1).
|
|
40
|
-
- **
|
|
40
|
+
- **Choreography** — shared silo hosting, grain serializers, jobs and jobs storage (MongoDB/SQL/in-memory), in `Cratis.Choreography*` packages (2.0.0 or newer). The core does not require Chronicle; the optional `.Chronicle` adapter does.
|
|
41
41
|
- **Arc** — the CQRS + model-binding + proxy-generation engine. `Source/DotNET` (the command/query pipeline, validation, authorization, identity, the Roslyn **proxy generator**) + `Source/JavaScript` (`@cratis/arc`, `@cratis/arc.react`, `@cratis/arc.react.mvvm`). Arc.Core does **not** depend on Chronicle.
|
|
42
42
|
- **Chronicle** — the event-sourcing engine. `Source/Kernel` (the engine: **Orleans grains**, event sequences, observers/projections/reducers, storage providers — MongoDB and others), `Source/Clients` (the client SDKs incl. `DotNET` and `Testing`), `Infrastructure`, `Tools`, `Workbench`. The kernel is the deep, performance- and consistency-critical core. Its shared job engine, jobs storage, serializers and reusable silo hosting now come from the separate **Orleans** repo, not Chronicle-owned jobs code (Chronicle v19.50.0).
|
|
43
43
|
- **Components** — the React component library (Components-owned markup and styling contract; React Aria internally; optional PrimeReact/MUI presentation adapters under `Adapters/`). `Source/<Component>/` folder per component (`CommandDialog`, `DataPage`, `DataTables`, …) with Storybook stories; published as `@cratis/components`. (Application rules *consume* these components; here you *build* them.)
|
|
@@ -112,8 +112,11 @@ capacity numbers into workflows or guidance.
|
|
|
112
112
|
|
|
113
113
|
## Automation that writes back
|
|
114
114
|
|
|
115
|
-
- A bot that pushes to a branch must **retry
|
|
116
|
-
|
|
115
|
+
- A bot that pushes to a branch must **retry by merging** — the branch moves while the
|
|
116
|
+
job runs, and a plain push loses the whole run to a non-fast-forward. Fetch, merge the
|
|
117
|
+
remote branch into the bot's commit (`git pull --no-rebase`), and push again. Never
|
|
118
|
+
rebase, amend, reset or force-push: `git-commits` forbids rewriting history, with no
|
|
119
|
+
automation exception.
|
|
117
120
|
- A bot's pre-push verification build must match the strictest configuration any CI in
|
|
118
121
|
the organization applies to the same commit (build `Release` when consumers enforce
|
|
119
122
|
analyzers there). Do not add `[skip ci]` to bot commits as a load optimization: the
|
|
@@ -11,9 +11,10 @@ Cratis organization. It does not apply to applications built on Cratis.
|
|
|
11
11
|
|
|
12
12
|
When a repository is created in the Cratis organization, prepare one transient,
|
|
13
13
|
no-effect Strategy intake proposal. Do not create, comment on, assign, mention,
|
|
14
|
-
link, or otherwise mutate a GitHub issue unless
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
link, or otherwise mutate a GitHub issue unless the user directly names that
|
|
15
|
+
issue operation or an accepted policy scopes it. Do not require another profile
|
|
16
|
+
or confirmation once either is present. Tool access and a request to create the
|
|
17
|
+
repository do not supply that issue-effect authority.
|
|
17
18
|
|
|
18
19
|
The proposal should include only the bounded facts needed for Strategy triage:
|
|
19
20
|
|
|
@@ -11,7 +11,7 @@ paths:
|
|
|
11
11
|
> **⚠️ APPLIES ONLY TO PROJECTS USING MICROSOFT ORLEANS**
|
|
12
12
|
> If your project does not reference `Microsoft.Orleans` or any Orleans packages, **ignore this entire file**. These rules are irrelevant outside of Orleans contexts.
|
|
13
13
|
|
|
14
|
-
In the Cratis organization, Orleans is the Chronicle kernel's actor runtime (`Source/Kernel/`). The kernel conventions below are verified against `Cratis/Chronicle` **v19.50.0**. Shared hosting and jobs come from `Cratis/
|
|
14
|
+
In the Cratis organization, Orleans is the Chronicle kernel's actor runtime (`Source/Kernel/`). The kernel conventions below are verified against `Cratis/Chronicle` **v19.50.0**. Shared hosting and jobs come from `Cratis/Choreography`; use `Cratis.Choreography` 2.0.0 or newer (renamed from `Cratis.Orleans`); use its setup for other services that co-host a silo.
|
|
15
15
|
|
|
16
16
|
## General
|
|
17
17
|
|
|
@@ -37,35 +37,35 @@ services.AddKeyedSingleton(WellKnownGrainStorageProviders.EventSequences, Create
|
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
Jobs are the exception to the kernel's `IStorage` shape: `JobGrainStorageProvider`
|
|
40
|
-
and `JobStepGrainStorageProvider` live in `Cratis.
|
|
41
|
-
`Cratis.
|
|
42
|
-
`Cratis.
|
|
40
|
+
and `JobStepGrainStorageProvider` live in `Cratis.Choreography.Jobs` and take
|
|
41
|
+
`Cratis.Choreography.Storage.IJobsStorage`. Chronicle registers them under
|
|
42
|
+
`Cratis.Choreography.WellKnownGrainStorageProviders.Jobs` and `.JobSteps`, still wrapped
|
|
43
43
|
in its resilient storage pipeline.
|
|
44
44
|
|
|
45
|
-
## Co-host a silo with Cratis.
|
|
45
|
+
## Co-host a silo with Cratis.Choreography
|
|
46
46
|
|
|
47
47
|
For job/step authoring, stage barriers, recovery, storage scopes and state-machine
|
|
48
48
|
APIs, load **cratis-orleans-jobs** from `cratis/engineering/csharp`. These APIs are
|
|
49
49
|
framework/service guidance; they do not impose application slice architecture.
|
|
50
50
|
|
|
51
|
-
For service authors, `Cratis.
|
|
52
|
-
shared job system without requiring Chronicle. With `Cratis.
|
|
53
|
-
`Cratis.
|
|
51
|
+
For service authors, `Cratis.Choreography` supplies hosting, grain serializers, and the
|
|
52
|
+
shared job system without requiring Chronicle. With `Cratis.Choreography` and
|
|
53
|
+
`Cratis.Choreography.Storage.MongoDB` 2.0.0 or newer, this host uses durable MongoDB membership
|
|
54
54
|
and jobs storage (a local MongoDB server is required):
|
|
55
55
|
|
|
56
56
|
```csharp
|
|
57
57
|
// Copyright (c) Cratis. All rights reserved.
|
|
58
58
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
59
59
|
|
|
60
|
-
using Cratis.
|
|
61
|
-
using Cratis.
|
|
60
|
+
using Cratis.Choreography.Hosting;
|
|
61
|
+
using Cratis.Choreography.Setup;
|
|
62
62
|
using Microsoft.AspNetCore.Builder;
|
|
63
63
|
using MongoDB.Driver;
|
|
64
64
|
|
|
65
65
|
var builder = WebApplication.CreateBuilder(args);
|
|
66
66
|
var connectionString = builder.Configuration.GetConnectionString("Mongo")
|
|
67
67
|
?? throw new InvalidOperationException("Configure the Mongo connection string.");
|
|
68
|
-
builder.
|
|
68
|
+
builder.AddCratisChoreography(new CratisChoreographyOptions
|
|
69
69
|
{
|
|
70
70
|
ClusterId = "my-service",
|
|
71
71
|
ServiceId = "my-service",
|
|
@@ -73,15 +73,15 @@ builder.AddCratisOrleans(new CratisOrleansOptions
|
|
|
73
73
|
DatabaseName = "my-service-orleans",
|
|
74
74
|
ConnectionString = connectionString
|
|
75
75
|
});
|
|
76
|
-
builder.Services.
|
|
76
|
+
builder.Services.AddCratisChoreographyMongoDBJobsStorage(new MongoClient(connectionString));
|
|
77
77
|
|
|
78
78
|
var app = builder.Build();
|
|
79
79
|
app.Run();
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
- Register jobs storage separately: `
|
|
83
|
-
`
|
|
84
|
-
`
|
|
82
|
+
- Register jobs storage separately: `AddCratisChoreographyMongoDBJobsStorage`,
|
|
83
|
+
`AddCratisChoreographySqlJobsStorage` (`Cratis.Choreography.Setup`), or
|
|
84
|
+
`AddCratisChoreographyInMemoryJobsStorage` (`Cratis.Choreography.Storage`).
|
|
85
85
|
- Use the local `IJobs` service to start/stop/delete typed jobs during rolling
|
|
86
86
|
upgrades; generic manager calls can land on a release that does not know the
|
|
87
87
|
type. Provide singleton `IJobsManagerKeys` on every silo for all host-owned
|
|
@@ -93,7 +93,7 @@ app.Run();
|
|
|
93
93
|
- Give grain implementations a unique `[GrainType("unique-name")]`. Orleans'
|
|
94
94
|
default type name derives from the class name alone; a collision across
|
|
95
95
|
assemblies prevents silo startup.
|
|
96
|
-
- Silos configured by `
|
|
96
|
+
- Silos configured by `AddCratisChoreography` deliberately use Orleans' in-memory
|
|
97
97
|
reminder service in both clustering modes; their reminders do not survive a
|
|
98
98
|
full restart. Jobs rehydrate from durable jobs storage and do not use
|
|
99
99
|
reminders. Do not point such a silo at the MongoDB reminder table merely
|
|
@@ -101,10 +101,10 @@ app.Run();
|
|
|
101
101
|
10.x runtime it made the reminder service stop responding in these hosts. Hosts that build their own silo choose separately; the
|
|
102
102
|
Chronicle kernel uses MongoDB reminders with MongoDB storage and in-memory
|
|
103
103
|
reminders with in-memory storage.
|
|
104
|
-
- `
|
|
104
|
+
- `AddCratisChoreography` enables activity propagation itself. If a host keeps an
|
|
105
105
|
explicit `AddActivityPropagation()` call, it must be **before**, never after,
|
|
106
|
-
`
|
|
106
|
+
`AddCratisChoreography`, to avoid duplicate Orleans propagation filters/spans.
|
|
107
107
|
- Keep Orleans package versions aligned: the Release-build guard rejects a
|
|
108
108
|
`Microsoft.Orleans.Reminders`/`Microsoft.Orleans.Server` version mismatch.
|
|
109
|
-
- `Enabled = false` makes `
|
|
109
|
+
- `Enabled = false` makes `AddCratisChoreography` a no-op for specification hosts;
|
|
110
110
|
it does not register the silo or its collaborators.
|
package/package/corpus/harnesses/copilot/instructions/verification-discipline.instructions.md
CHANGED
|
@@ -12,7 +12,7 @@ authored a file or preserve a chain of evidence about how it arrived.
|
|
|
12
12
|
|
|
13
13
|
- Run the narrowest relevant build, type check, lint, and specifications while iterating; explain when a wider gate is required before completion or push/PR.
|
|
14
14
|
- Run one phase per command with its real exit status. Budget targeted checks around 120 seconds and build/test phases around 300 seconds; explain any longer budget first, and obtain explicit approval before a phase exceeds 600 seconds. Stop on a failure; do not blindly retry or repeat passing tests on unchanged inputs without a flaky-test hypothesis or required matrix.
|
|
15
|
-
- CI is not a feedback loop: run
|
|
15
|
+
- CI is not a feedback loop: run the Tier 1 gate locally before pushing, and run integration (Tier 2) locally when the repository's policy requires it. Integration may wait for CI only when the repository allows it, CI demonstrably runs that coverage and it passes before merge; say it was deferred to CI, never call it a local pass. If integration is required but has neither local proof nor enforced CI coverage, treat it as unverified and stop. A stricter repository policy, such as local-only integration, wins. On a shared machine cap parallelism, one heavy phase at once (`cratis-engineering-ci-gates`).
|
|
16
16
|
- Separate status/fetch from builds, Debug from Release, each test project, and frontend lint/compile/test/build. Do not combine these into an opaque command with a large outer timeout. Expose progress and cancellation; report the precise failed or timed-out phase and do not continue dependent phases after failure.
|
|
17
17
|
- Never use `build/test | grep | sort/head/tail` as gate evidence. Capture the producer's exit status before summarising output; `pipefail` alone is insufficient with early-closing consumers such as `head`. Printed zero-error counts are not proof of success. Preserve needed full diagnostics in task-scoped `.ai-work/` logs rather than hiding them in `/tmp`.
|
|
18
18
|
- Fast feedback is a product requirement: a spec takes milliseconds, the suite seconds; specs share setup and run in parallel; analyzers must not halt builds. CI builds the spec path without analyzers and enforces them, warnings as errors, in a parallel required job; the pre-push gate runs them. A slowdown is a defect.
|
|
@@ -226,12 +226,7 @@ export const Projects = () => {
|
|
|
226
226
|
|
|
227
227
|
## Browser verification (optional)
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
1. Open the app page in the integrated browser.
|
|
231
|
-
2. Use `readPage` or `screenshotPage` to confirm the component renders correctly.
|
|
232
|
-
3. Use `clickElement` or `typeInPage` to test interactive elements.
|
|
233
|
-
|
|
234
|
-
This closes the development loop — build, render, verify — without leaving the editor.
|
|
229
|
+
Browser tools are a capability, not authority, and only the `browser-operator` agent receives them (`browser.md`). Do not drive a browser yourself, even when the workspace enables editor browser tools. To verify the UI after implementation, hand `browser-operator` the URL, the scope, the permit and the artifact directory, and use its evidence record. Production stays read-only and sign-in stops for a human. If no `browser-operator` is available, report the UI as unverified rather than using browser tools directly.
|
|
235
230
|
|
|
236
231
|
---
|
|
237
232
|
|
|
@@ -10,9 +10,9 @@ Cratis.Chronicle.CodeAnalysis 19.50.1
|
|
|
10
10
|
Cratis.Fundamentals 7.23.0
|
|
11
11
|
Cratis.Metrics.Roslyn 7.23.0
|
|
12
12
|
Cratis.OpenTelemetry 7.23.0
|
|
13
|
-
Cratis.
|
|
14
|
-
Cratis.
|
|
15
|
-
Cratis.
|
|
16
|
-
Cratis.
|
|
13
|
+
Cratis.Choreography 2.0.0
|
|
14
|
+
Cratis.Choreography.Chronicle 2.0.0
|
|
15
|
+
Cratis.Choreography.Storage.MongoDB 2.0.0
|
|
16
|
+
Cratis.Choreography.Storage.Sql 2.0.0
|
|
17
17
|
Cratis.Specifications 4.1.1
|
|
18
18
|
Cratis.Specifications.XUnit 4.1.1
|
|
@@ -36,7 +36,7 @@ Each framework repo is organized by what it builds, not by feature slices:
|
|
|
36
36
|
|
|
37
37
|
- **Fundamentals** — the base library. `ConceptAs<T>`, type discovery (`IInstancesOf<T>` / `IImplementationsOf<T>`), serialization, common primitives. `Source/DotNET` includes `Fundamentals.TypeDiscovery.Generator`, `Metrics.Roslyn` (`Cratis.Metrics.Roslyn`) and `OpenTelemetry` (`Cratis.OpenTelemetry`); `Source/JavaScript` publishes `@cratis/fundamentals`, and `Source/ESLintConfig` publishes `@cratis/eslint-config` (verified at v7.23.0).
|
|
38
38
|
- **Specifications** — BDD lifecycle, assertions and analyzers. `Source/Specifications` supplies common helpers, `Source/XUnit` and `Source/NUnit` supply runner-specific bases/assertions, and `Source/CodeAnalysis` supplies the bundled analyzers (v4.1.1).
|
|
39
|
-
- **
|
|
39
|
+
- **Choreography** — shared silo hosting, grain serializers, jobs and jobs storage (MongoDB/SQL/in-memory), in `Cratis.Choreography*` packages (2.0.0 or newer). The core does not require Chronicle; the optional `.Chronicle` adapter does.
|
|
40
40
|
- **Arc** — the CQRS + model-binding + proxy-generation engine. `Source/DotNET` (the command/query pipeline, validation, authorization, identity, the Roslyn **proxy generator**) + `Source/JavaScript` (`@cratis/arc`, `@cratis/arc.react`, `@cratis/arc.react.mvvm`). Arc.Core does **not** depend on Chronicle.
|
|
41
41
|
- **Chronicle** — the event-sourcing engine. `Source/Kernel` (the engine: **Orleans grains**, event sequences, observers/projections/reducers, storage providers — MongoDB and others), `Source/Clients` (the client SDKs incl. `DotNET` and `Testing`), `Infrastructure`, `Tools`, `Workbench`. The kernel is the deep, performance- and consistency-critical core. Its shared job engine, jobs storage, serializers and reusable silo hosting now come from the separate **Orleans** repo, not Chronicle-owned jobs code (Chronicle v19.50.0).
|
|
42
42
|
- **Components** — the React component library (Components-owned markup and styling contract; React Aria internally; optional PrimeReact/MUI presentation adapters under `Adapters/`). `Source/<Component>/` folder per component (`CommandDialog`, `DataPage`, `DataTables`, …) with Storybook stories; published as `@cratis/components`. (Application rules *consume* these components; here you *build* them.)
|
|
@@ -111,8 +111,11 @@ capacity numbers into workflows or guidance.
|
|
|
111
111
|
|
|
112
112
|
## Automation that writes back
|
|
113
113
|
|
|
114
|
-
- A bot that pushes to a branch must **retry
|
|
115
|
-
|
|
114
|
+
- A bot that pushes to a branch must **retry by merging** — the branch moves while the
|
|
115
|
+
job runs, and a plain push loses the whole run to a non-fast-forward. Fetch, merge the
|
|
116
|
+
remote branch into the bot's commit (`git pull --no-rebase`), and push again. Never
|
|
117
|
+
rebase, amend, reset or force-push: `git-commits` forbids rewriting history, with no
|
|
118
|
+
automation exception.
|
|
116
119
|
- A bot's pre-push verification build must match the strictest configuration any CI in
|
|
117
120
|
the organization applies to the same commit (build `Release` when consumers enforce
|
|
118
121
|
analyzers there). Do not add `[skip ci]` to bot commits as a load optimization: the
|
|
@@ -10,9 +10,10 @@ Cratis organization. It does not apply to applications built on Cratis.
|
|
|
10
10
|
|
|
11
11
|
When a repository is created in the Cratis organization, prepare one transient,
|
|
12
12
|
no-effect Strategy intake proposal. Do not create, comment on, assign, mention,
|
|
13
|
-
link, or otherwise mutate a GitHub issue unless
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
link, or otherwise mutate a GitHub issue unless the user directly names that
|
|
14
|
+
issue operation or an accepted policy scopes it. Do not require another profile
|
|
15
|
+
or confirmation once either is present. Tool access and a request to create the
|
|
16
|
+
repository do not supply that issue-effect authority.
|
|
16
17
|
|
|
17
18
|
The proposal should include only the bounded facts needed for Strategy triage:
|
|
18
19
|
|
|
@@ -10,7 +10,7 @@ paths:
|
|
|
10
10
|
> **⚠️ APPLIES ONLY TO PROJECTS USING MICROSOFT ORLEANS**
|
|
11
11
|
> If your project does not reference `Microsoft.Orleans` or any Orleans packages, **ignore this entire file**. These rules are irrelevant outside of Orleans contexts.
|
|
12
12
|
|
|
13
|
-
In the Cratis organization, Orleans is the Chronicle kernel's actor runtime (`Source/Kernel/`). The kernel conventions below are verified against `Cratis/Chronicle` **v19.50.0**. Shared hosting and jobs come from `Cratis/
|
|
13
|
+
In the Cratis organization, Orleans is the Chronicle kernel's actor runtime (`Source/Kernel/`). The kernel conventions below are verified against `Cratis/Chronicle` **v19.50.0**. Shared hosting and jobs come from `Cratis/Choreography`; use `Cratis.Choreography` 2.0.0 or newer (renamed from `Cratis.Orleans`); use its setup for other services that co-host a silo.
|
|
14
14
|
|
|
15
15
|
## General
|
|
16
16
|
|
|
@@ -36,35 +36,35 @@ services.AddKeyedSingleton(WellKnownGrainStorageProviders.EventSequences, Create
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Jobs are the exception to the kernel's `IStorage` shape: `JobGrainStorageProvider`
|
|
39
|
-
and `JobStepGrainStorageProvider` live in `Cratis.
|
|
40
|
-
`Cratis.
|
|
41
|
-
`Cratis.
|
|
39
|
+
and `JobStepGrainStorageProvider` live in `Cratis.Choreography.Jobs` and take
|
|
40
|
+
`Cratis.Choreography.Storage.IJobsStorage`. Chronicle registers them under
|
|
41
|
+
`Cratis.Choreography.WellKnownGrainStorageProviders.Jobs` and `.JobSteps`, still wrapped
|
|
42
42
|
in its resilient storage pipeline.
|
|
43
43
|
|
|
44
|
-
## Co-host a silo with Cratis.
|
|
44
|
+
## Co-host a silo with Cratis.Choreography
|
|
45
45
|
|
|
46
46
|
For job/step authoring, stage barriers, recovery, storage scopes and state-machine
|
|
47
47
|
APIs, load **cratis-orleans-jobs** from `cratis/engineering/csharp`. These APIs are
|
|
48
48
|
framework/service guidance; they do not impose application slice architecture.
|
|
49
49
|
|
|
50
|
-
For service authors, `Cratis.
|
|
51
|
-
shared job system without requiring Chronicle. With `Cratis.
|
|
52
|
-
`Cratis.
|
|
50
|
+
For service authors, `Cratis.Choreography` supplies hosting, grain serializers, and the
|
|
51
|
+
shared job system without requiring Chronicle. With `Cratis.Choreography` and
|
|
52
|
+
`Cratis.Choreography.Storage.MongoDB` 2.0.0 or newer, this host uses durable MongoDB membership
|
|
53
53
|
and jobs storage (a local MongoDB server is required):
|
|
54
54
|
|
|
55
55
|
```csharp
|
|
56
56
|
// Copyright (c) Cratis. All rights reserved.
|
|
57
57
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
58
58
|
|
|
59
|
-
using Cratis.
|
|
60
|
-
using Cratis.
|
|
59
|
+
using Cratis.Choreography.Hosting;
|
|
60
|
+
using Cratis.Choreography.Setup;
|
|
61
61
|
using Microsoft.AspNetCore.Builder;
|
|
62
62
|
using MongoDB.Driver;
|
|
63
63
|
|
|
64
64
|
var builder = WebApplication.CreateBuilder(args);
|
|
65
65
|
var connectionString = builder.Configuration.GetConnectionString("Mongo")
|
|
66
66
|
?? throw new InvalidOperationException("Configure the Mongo connection string.");
|
|
67
|
-
builder.
|
|
67
|
+
builder.AddCratisChoreography(new CratisChoreographyOptions
|
|
68
68
|
{
|
|
69
69
|
ClusterId = "my-service",
|
|
70
70
|
ServiceId = "my-service",
|
|
@@ -72,15 +72,15 @@ builder.AddCratisOrleans(new CratisOrleansOptions
|
|
|
72
72
|
DatabaseName = "my-service-orleans",
|
|
73
73
|
ConnectionString = connectionString
|
|
74
74
|
});
|
|
75
|
-
builder.Services.
|
|
75
|
+
builder.Services.AddCratisChoreographyMongoDBJobsStorage(new MongoClient(connectionString));
|
|
76
76
|
|
|
77
77
|
var app = builder.Build();
|
|
78
78
|
app.Run();
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
- Register jobs storage separately: `
|
|
82
|
-
`
|
|
83
|
-
`
|
|
81
|
+
- Register jobs storage separately: `AddCratisChoreographyMongoDBJobsStorage`,
|
|
82
|
+
`AddCratisChoreographySqlJobsStorage` (`Cratis.Choreography.Setup`), or
|
|
83
|
+
`AddCratisChoreographyInMemoryJobsStorage` (`Cratis.Choreography.Storage`).
|
|
84
84
|
- Use the local `IJobs` service to start/stop/delete typed jobs during rolling
|
|
85
85
|
upgrades; generic manager calls can land on a release that does not know the
|
|
86
86
|
type. Provide singleton `IJobsManagerKeys` on every silo for all host-owned
|
|
@@ -92,7 +92,7 @@ app.Run();
|
|
|
92
92
|
- Give grain implementations a unique `[GrainType("unique-name")]`. Orleans'
|
|
93
93
|
default type name derives from the class name alone; a collision across
|
|
94
94
|
assemblies prevents silo startup.
|
|
95
|
-
- Silos configured by `
|
|
95
|
+
- Silos configured by `AddCratisChoreography` deliberately use Orleans' in-memory
|
|
96
96
|
reminder service in both clustering modes; their reminders do not survive a
|
|
97
97
|
full restart. Jobs rehydrate from durable jobs storage and do not use
|
|
98
98
|
reminders. Do not point such a silo at the MongoDB reminder table merely
|
|
@@ -100,10 +100,10 @@ app.Run();
|
|
|
100
100
|
10.x runtime it made the reminder service stop responding in these hosts. Hosts that build their own silo choose separately; the
|
|
101
101
|
Chronicle kernel uses MongoDB reminders with MongoDB storage and in-memory
|
|
102
102
|
reminders with in-memory storage.
|
|
103
|
-
- `
|
|
103
|
+
- `AddCratisChoreography` enables activity propagation itself. If a host keeps an
|
|
104
104
|
explicit `AddActivityPropagation()` call, it must be **before**, never after,
|
|
105
|
-
`
|
|
105
|
+
`AddCratisChoreography`, to avoid duplicate Orleans propagation filters/spans.
|
|
106
106
|
- Keep Orleans package versions aligned: the Release-build guard rejects a
|
|
107
107
|
`Microsoft.Orleans.Reminders`/`Microsoft.Orleans.Server` version mismatch.
|
|
108
|
-
- `Enabled = false` makes `
|
|
108
|
+
- `Enabled = false` makes `AddCratisChoreography` a no-op for specification hosts;
|
|
109
109
|
it does not register the silo or its collaborators.
|
|
@@ -11,7 +11,7 @@ authored a file or preserve a chain of evidence about how it arrived.
|
|
|
11
11
|
|
|
12
12
|
- Run the narrowest relevant build, type check, lint, and specifications while iterating; explain when a wider gate is required before completion or push/PR.
|
|
13
13
|
- Run one phase per command with its real exit status. Budget targeted checks around 120 seconds and build/test phases around 300 seconds; explain any longer budget first, and obtain explicit approval before a phase exceeds 600 seconds. Stop on a failure; do not blindly retry or repeat passing tests on unchanged inputs without a flaky-test hypothesis or required matrix.
|
|
14
|
-
- CI is not a feedback loop: run
|
|
14
|
+
- CI is not a feedback loop: run the Tier 1 gate locally before pushing, and run integration (Tier 2) locally when the repository's policy requires it. Integration may wait for CI only when the repository allows it, CI demonstrably runs that coverage and it passes before merge; say it was deferred to CI, never call it a local pass. If integration is required but has neither local proof nor enforced CI coverage, treat it as unverified and stop. A stricter repository policy, such as local-only integration, wins. On a shared machine cap parallelism, one heavy phase at once (`cratis-engineering-ci-gates`).
|
|
15
15
|
- Separate status/fetch from builds, Debug from Release, each test project, and frontend lint/compile/test/build. Do not combine these into an opaque command with a large outer timeout. Expose progress and cancellation; report the precise failed or timed-out phase and do not continue dependent phases after failure.
|
|
16
16
|
- Never use `build/test | grep | sort/head/tail` as gate evidence. Capture the producer's exit status before summarising output; `pipefail` alone is insufficient with early-closing consumers such as `head`. Printed zero-error counts are not proof of success. Preserve needed full diagnostics in task-scoped `.ai-work/` logs rather than hiding them in `/tmp`.
|
|
17
17
|
- Fast feedback is a product requirement: a spec takes milliseconds, the suite seconds; specs share setup and run in parallel; analyzers must not halt builds. CI builds the spec path without analyzers and enforces them, warnings as errors, in a parallel required job; the pre-push gate runs them. A slowdown is a defect.
|
package/package/corpus/skills/cratis-chronicle-event-modeling/references/event-log-hygiene.md
CHANGED
|
@@ -40,7 +40,7 @@ after the process that noticed it is gone. These are not facts:
|
|
|
40
40
|
|
|
41
41
|
Pick the mechanism that owns the progress, so progress is state of that mechanism, not events:
|
|
42
42
|
|
|
43
|
-
- a **durable job** (Cratis.
|
|
43
|
+
- a **durable job** (Cratis.Choreography jobs, see **cratis-orleans-jobs**) for work with steps, retries and pacing;
|
|
44
44
|
- an **event-sourced state machine** when the lifecycle is itself a domain fact sequence;
|
|
45
45
|
- an **Orleans reminder** to wake up later;
|
|
46
46
|
- a **command operation** (**cratis-arc-command-operation**) for inline work with compensation;
|
|
@@ -97,12 +97,18 @@ into an approval ceremony merely because this skill is available.
|
|
|
97
97
|
text in place — that text is what people relied on. Correct a typo or add
|
|
98
98
|
context under a dated banner that says what changed and why. Change the
|
|
99
99
|
*choice* only with a new record.
|
|
100
|
-
11. **Point both ways
|
|
101
|
-
replaces in `supersedes`; the replaced record's `status`
|
|
102
|
-
`superseded` and it gains a `superseded-by` pointer forward, with
|
|
103
|
-
original text preserved.
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
11. **Point both ways; cite the new record only on new work.** The new record
|
|
101
|
+
names the one it replaces in `supersedes`; the replaced record's `status`
|
|
102
|
+
becomes `superseded` and it gains a `superseded-by` pointer forward, with
|
|
103
|
+
its original text preserved. Keep committed trailers and existing issue and
|
|
104
|
+
pull request text as written: they record which decision governed that work,
|
|
105
|
+
and updating a committed trailer means rewriting history, which
|
|
106
|
+
`git-commits` forbids. Cite the new id on new commits and new work. For
|
|
107
|
+
open work, add a forward link only where the user or an applicable policy
|
|
108
|
+
authorizes that issue or pull request effect; authority to write a record does
|
|
109
|
+
not cover it, and never rewrite another author's text. A reader arriving at
|
|
110
|
+
either record must be able to reach the other and tell which one governed the
|
|
111
|
+
original implementation.
|
|
106
112
|
|
|
107
113
|
Read [record-format.md](references/record-format.md) when authoring or updating a record or regenerating its index; it defines the exact front-matter fields, closed value sets, and index shape.
|
|
108
114
|
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cratis-orleans-jobs
|
|
3
|
-
description: Use when authoring or recovering Cratis.
|
|
3
|
+
description: Use when authoring or recovering Cratis.Choreography jobs, configuring their storage or changing job-step lifecycle transitions. Not for operating live Chronicle jobs or validating application commands.
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
8
8
|
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
9
9
|
|
|
10
|
-
# Recoverable
|
|
10
|
+
# Recoverable Choreography jobs
|
|
11
11
|
|
|
12
12
|
For services and kernel contributors using Orleans. This is library-consumer guidance, not the application vertical-slice architecture. For live Chronicle operations use **cratis-chronicle-cli-operations** instead. Co-hosting conventions are in [orleans.md](../../rules/orleans.md).
|
|
13
13
|
|
|
14
|
+
Use `Cratis.Choreography` 2.0.0 or newer. When upgrading from `Cratis.Orleans`, replace the package/namespace prefix and `AddCratisOrleans` registration prefix with `Cratis.Choreography` and `AddCratisChoreography`, including `CratisChoreographyOptions`. The 1.x prerequisites below and in the references describe the pre-rename compatibility baseline; Choreography 2.0.0 includes them.
|
|
15
|
+
|
|
16
|
+
## Verified product sources
|
|
17
|
+
|
|
18
|
+
Packages are pinned to 2.0.0, the `Cratis.Choreography` rename baseline. Names are verified against `Cratis/Orleans` origin/main: `Source/Choreography/Hosting/CratisChoreographySiloBuilderExtensions.cs`, `CratisChoreographyOptions.cs`, and the jobs-storage extensions in `Source/Choreography.Storage.MongoDB/Setup/`, `Source/Choreography.Storage.Sql/Setup/` and `Source/Choreography.Storage/InMemory/`.
|
|
19
|
+
|
|
14
20
|
## 1. Choose a job, not a detached task
|
|
15
21
|
|
|
16
22
|
A job plans recoverable work; each step is a grain and does the work. Use it for work that must outlive a request. It is **at-least-once**, not exactly-once: a step interrupted before a durable checkpoint can perform the same work again. Protect external effects with receiver-owned idempotency/deduplication; a checkpoint does not atomically commit an external write.
|
|
@@ -22,7 +28,7 @@ A job plans recoverable work; each step is a grain and does the work. Use it for
|
|
|
22
28
|
|
|
23
29
|
`PerformStep` runs **outside the activation context** with a deep-copied state snapshot. Mutating that snapshot does not persist it; do not access/write grain `State` directly from background work. A specification host such as Orleans.TestKit must register `DeepCopier<TState>`.
|
|
24
30
|
|
|
25
|
-
Requires
|
|
31
|
+
Requires 1.19.0 for `TryInvokeOnActivation` to coordinate state/checkpoints on the current activation, including during deactivation. Call it only from the run's background work. Keep callbacks local: capture copied inputs, call remote systems outside the callback, then commit in a second callback. Never call another grain, nest and await another callback, or start unawaited work inside it. Inspect `ActivationCallbackRejected` (`NoRun`, `StaleRun`, `Closed`, `Cancelled`); exceptions propagate. The optional `queueCancellationToken` cancels waiting callbacks only; started callbacks finish. Stop/deactivation waits for started callbacks and work to settle; `JobsOptions.StepStopTimeout` defaults to 10 seconds and `JobStepError.StopTimedOut` is not proof of quiescence. Requires 1.16.2 for framework-owned stop reporting: do not report cancellation again from a `PerformWork` override.
|
|
26
32
|
|
|
27
33
|
## 2. Plan dependencies as stages
|
|
28
34
|
|
|
@@ -42,23 +48,23 @@ protected override Task<IImmutableList<JobStepDetails>> PrepareSteps(RecoveryReq
|
|
|
42
48
|
]);
|
|
43
49
|
```
|
|
44
50
|
|
|
45
|
-
Import `System.Collections.Immutable` and `Cratis.
|
|
51
|
+
Import `System.Collections.Immutable` and `Cratis.Choreography.Jobs` in that job file. `CreateStep<TStep>` takes the **grain interface**, not the implementation. Its stage overload accepts `JobStepStage`, with implicit integer conversion.
|
|
46
52
|
|
|
47
53
|
Every step in a stage reaches an outcome before later stages start; steps within a stage run in parallel. All steps are prepared up front, so later-stage preparation cannot read the effects of earlier-stage execution. Read such dependencies in `PerformStep`.
|
|
48
54
|
|
|
49
|
-
A failed stage stops the pipeline by default: later steps become `Unreachable`, and the job completes with failures. A best-effort stage may override `GetFailureBehaviorFor(JobStepStage)` to return `JobStageFailureBehavior.ContinueWithNextStage` (namespace `Cratis.
|
|
55
|
+
A failed stage stops the pipeline by default: later steps become `Unreachable`, and the job completes with failures. A best-effort stage may override `GetFailureBehaviorFor(JobStepStage)` to return `JobStageFailureBehavior.ContinueWithNextStage` (namespace `Cratis.Choreography.Jobs.Stages`). Do not silently continue when a later stage relies on the failed output.
|
|
50
56
|
|
|
51
57
|
Requires 1.25.0 for durable step plans: preparation requests must round-trip through the host's JSON options. Invalid plans return `StartJobError.InvalidStepPlan`. Recovery reuses identities and requests, prepares only unsaved steps, and never calls `PrepareSteps` again. Put retry-safe initialization needed before start **and** resume in `OnBeforeDispatchingJobSteps(JobStepDispatchContext)`, after the respective start/resume hook. `InitializationMayBeIncomplete` flags recovery from preparing/starting, not exactly-once initialization. A failed hook dispatches nothing; recovery never replays the start hook. A legacy preparing/starting job without a saved plan returns `CannotResumeJobError.MissingStepPlan` rather than inventing identities.
|
|
52
58
|
|
|
53
59
|
## 3. Start locally and recover every scope
|
|
54
60
|
|
|
55
|
-
Requires 1.18.0 for the singleton local service `Cratis.
|
|
61
|
+
Requires 1.18.0 for the singleton local service `Cratis.Choreography.Jobs.IJobs`, registered by `AddCratisChoreography`. Prefer `Start<TJob,TRequest>(new JobKey(scope, namespace), request)` (or its explicit job-id overload), `Stop(key, jobId)` and `Delete(key, jobId)` during rolling upgrades. Generic `IJobsManager.Start`/`GetJobsOfType` send types through a manager that may run an older release and cannot decode them.
|
|
56
62
|
|
|
57
63
|
Inspect `Result<JobId, StartJobError>` before telling a caller that work started. `FailedStartingSomeJobSteps` means remaining work is still running, not that nothing started; `AllJobStepsFailedStarting` means no step started. Start success is not completion. Match `StopJobResult`/`DeleteJobResult`: accepted, `NotFound`, `UnknownJobType`, or `Refused` with the job's error. Unknown types require a release that knows the type; exceptions propagate. Deletion acceptance is not completed removal. Third-party storage should override `IJobStorage.GetJobType` with a metadata-only read; its fallback reads the request too.
|
|
58
64
|
|
|
59
65
|
`IGrainFactory.GetJobsManager(scope, namespace)` remains available. `IJobsManager.Resume(JobId)` returns **`Task<bool>`**; false means nothing took the job: do not wait for a completion callback as though resumption succeeded. True may also mean already running or finalized. `IJobsManager.Stop` returns `Result<StopJobError>`; preserve a persistence refusal. `Rehydrate()` returns after loading/preparing interrupted jobs, before its bounded background drain resumes them all. `StartStepsInBackground = true` moves step preparation/start to the next turn after durability; later failures belong to the job, not Start.
|
|
60
66
|
|
|
61
|
-
Requires 1.17.0 for automatic recovery on silo activation/member death. Provide singleton `IJobsManagerKeys` implementations on **every silo**, enumerating all host-owned scope/namespace pairs through `GetKeys(CancellationToken)`. The default remembers only keys used in this process: it is not a durable catalog. Providers run outside request scope; never inject a current tenant/user or scoped database. Requires 1.23.3 (1.24.2 for provider construction failures) for automatic recovery retries of failed providers/managers, from 1 second doubling to 60 seconds until success or silo shutdown. There is no periodic sweep by default. `
|
|
67
|
+
Requires 1.17.0 for automatic recovery on silo activation/member death. Provide singleton `IJobsManagerKeys` implementations on **every silo**, enumerating all host-owned scope/namespace pairs through `GetKeys(CancellationToken)`. The default remembers only keys used in this process: it is not a durable catalog. Providers run outside request scope; never inject a current tenant/user or scoped database. Requires 1.23.3 (1.24.2 for provider construction failures) for automatic recovery retries of failed providers/managers, from 1 second doubling to 60 seconds until success or silo shutdown. There is no periodic sweep by default. `AddCratisChoreography` registers recovery; separately configured silos need `AddCratisChoreographyJobsRecovery()` (`Cratis.Choreography.Hosting`).
|
|
62
68
|
|
|
63
69
|
Read [lifecycle and placement](references/lifecycle-and-placement.md) for drain/admission, bounded attempts, placement, custom storage compatibility and step test runs.
|
|
64
70
|
|
|
@@ -70,13 +76,13 @@ Keeping a job does not keep successful step state: successful **steps delete the
|
|
|
70
76
|
|
|
71
77
|
## 5. Register storage and budget concurrency
|
|
72
78
|
|
|
73
|
-
`IJobsStorage.GetFor(scope, namespace)` returns `JobsStorage`. Scope and namespace are opaque host-owned storage coordinates, not authorization checks. Choose one storage registration alongside `
|
|
79
|
+
`IJobsStorage.GetFor(scope, namespace)` returns `JobsStorage`. Scope and namespace are opaque host-owned storage coordinates, not authorization checks. Choose one storage registration alongside `AddCratisChoreography`:
|
|
74
80
|
|
|
75
81
|
| Registration | Package / namespace | Use |
|
|
76
82
|
| --- | --- | --- |
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
83
|
+
| `AddCratisChoreographyMongoDBJobsStorage` | `.Storage.MongoDB` / `Cratis.Choreography.Setup` | Durable MongoDB; default database `{scope}+jobs[+{namespace}]`, overridable |
|
|
84
|
+
| `AddCratisChoreographySqlJobsStorage` | `.Storage.Sql` / `Cratis.Choreography.Setup` | Durable EF Core; `OptionsResolver(scope, namespace)` selects `DbContextOptions<JobsDbContext>` |
|
|
85
|
+
| `AddCratisChoreographyInMemoryJobsStorage` | `.Storage` / `Cratis.Choreography.Storage` | Specs/development; restart loses state |
|
|
80
86
|
|
|
81
87
|
The SQL provider calls `dbContext.Database.Migrate()` automatically before constructing storage. Do not substitute `EnsureCreated` or hand-create tables; grant migration permissions and choose scope-to-database mapping deliberately. `IJobsStorage.Reset()` clears the cache; the next resolution migrates again. There is no MySQL/MariaDB jobs provider.
|
|
82
88
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
## Stop, drain and admission
|
|
7
7
|
|
|
8
|
-
Requires
|
|
8
|
+
Requires 1.20.0 for `IJobs.StopAndDrain(key, jobId, timeout)` and the grain protocols `IJobDrain` / `IJobStepDrain`. Unlike ordinary stop acceptance, `Drained` means no step code can run, final outcomes/checkpoints are durable and completion/stop hooks finished. Other outcomes are `TimedOut` (call again), `Completed`, `NotFound` and `UnknownJobType`. `TimeSpan.Zero` polls. Add the method to hand-written `IJobs` implementations. Enable only after every silo supports it. A pending drain survives reactivation and refuses resume; a timeout is not proof of quiescence. Hooks can repeat or be missed after a crash, so keep them idempotent rather than collecting results only there.
|
|
9
9
|
|
|
10
10
|
Requires 1.21.0 for owner admission: implement `IJobAdmission.MayRun(JobAdmissionRequest, CancellationToken)` and register with `siloBuilder.AddJobAdmission<T>()` on every silo that hosts those job types. Every admission must allow; none means allow. It runs before start, every resume and each later stage. Refusals return `StartJobError.NotAdmitted` / `CannotResumeJobError.NotAdmitted`; manager resume returns false. A refused running job is stopped/drained, and a refused later stage stops the job. Exceptions/timeouts are failures, not refusals; a later stage retries an unanswered admission on a timer.
|
|
11
11
|
|
|
@@ -41,7 +41,7 @@ A completed stop sets `StopFinalized` after all required notifications have succ
|
|
|
41
41
|
|
|
42
42
|
## Independent controller and worker placement
|
|
43
43
|
|
|
44
|
-
Requires 1.30.0 for `Cratis.
|
|
44
|
+
Requires 1.30.0 for `Cratis.Choreography.Hosting` extensions on `ISiloBuilder`:
|
|
45
45
|
|
|
46
46
|
- `AddJobPlacement()` or `AddJobPlacement<TDirector>()` opts controllers into `JobsPlacementStrategy`.
|
|
47
47
|
- `AddJobStepPlacement()` or `AddJobStepPlacement<TDirector>()` opts workers into `JobStepsPlacementStrategy`, including recovered steps.
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
# Grain lifecycle state machines
|
|
5
5
|
|
|
6
|
-
Source: `Cratis/
|
|
6
|
+
Source: `Cratis/Choreography`. Use explicit states when entering/leaving a status has behavior; an enum is enough for a status with no behavior. Do not put long-running work on a grain turn just because `OnEnter` is available.
|
|
7
7
|
|
|
8
8
|
## Stored lifecycle
|
|
9
9
|
|
|
10
|
-
`StateMachine<TStoredState>` derives from a stateful grain. Override `InitialState` and `CreateStates()`; states derive `State<TStoredState>`. `AllowedTransitions` is an immutable list of target types, or override `CanTransitionTo<TTargetState>(storedState)` for a guard (`Source/
|
|
10
|
+
`StateMachine<TStoredState>` derives from a stateful grain. Override `InitialState` and `CreateStates()`; states derive `State<TStoredState>`. `AllowedTransitions` is an immutable list of target types, or override `CanTransitionTo<TTargetState>(storedState)` for a guard (`Source/Choreography/StateMachines/StateMachine.cs`; `State.cs`).
|
|
11
11
|
|
|
12
12
|
Declaration excerpt for an existing grain file with `ProcessState : StateMachineState`, the existing `IProcess` grain interface, and a registered `processes` grain storage provider:
|
|
13
13
|
|
|
@@ -18,7 +18,7 @@ Declaration excerpt for an existing grain file with `ProcessState : StateMachine
|
|
|
18
18
|
using System;
|
|
19
19
|
using System.Collections.Immutable;
|
|
20
20
|
using System.Threading.Tasks;
|
|
21
|
-
using Cratis.
|
|
21
|
+
using Cratis.Choreography.StateMachines;
|
|
22
22
|
using Orleans;
|
|
23
23
|
using Orleans.Providers;
|
|
24
24
|
|
|
@@ -54,13 +54,13 @@ For externally owned storage, the protected constructor accepts `Orleans.Core.IS
|
|
|
54
54
|
|
|
55
55
|
## Lifecycle following Chronicle facts
|
|
56
56
|
|
|
57
|
-
`EventSourcedStateMachine<TModel>` from `Cratis.
|
|
57
|
+
`EventSourcedStateMachine<TModel>` from `Cratis.Choreography.Chronicle.StateMachines` uses a Chronicle read model as authoritative state. Its interface derives `IEventSourcedStateMachine` (string-keyed). There is **no grain storage provider** to configure and writes are no-ops: `ReadModelStorage<TModel>` reads Chronicle; `ResolveState(TModel?)` derives activation state (`Source/Choreography.Chronicle/StateMachines/EventSourcedStateMachine.cs`; `ReadModelStorage.cs`).
|
|
58
58
|
|
|
59
59
|
- Define states with `CreateStates()` as above, over `TModel`.
|
|
60
60
|
- Define event transitions in `DefineTransitions(IStateMachineTransitions<TModel>)`, using `.On<TEvent>().When(model => predicate).TransitionTo<TState>()`. First applicable allowed transition wins. Make `ResolveState` agree with these transitions after restart (`EventSourcedStateMachine.cs`, `StateMachineTransitions.cs`).
|
|
61
61
|
- Use model-bound projection attributes, an already-discovered projection, or `DefineProjection(IProjectionBuilderFor<TModel>)`, not competing projections. `DefineProjection` and `DefineTransitions` run at startup **without a constructor**: use only the builder, never injected services or fields (`EventSourcedStateMachine.cs`).
|
|
62
|
-
- Register `AddEventSourcedStateMachines()` on `ISiloBuilder` or `IServiceCollection`, beside the application's Chronicle client registration; namespace `Cratis.
|
|
63
|
-
- Grain keys include event store, namespace and event-source ID. Use `IGrainFactory.GetEventSourcedStateMachine<TInterface>(eventStore, eventSourceId)` from `Cratis.
|
|
62
|
+
- Register `AddEventSourcedStateMachines()` on `ISiloBuilder` or `IServiceCollection`, beside the application's Chronicle client registration; namespace `Cratis.Choreography.Chronicle.Hosting` (`Hosting/EventSourcedStateMachinesServiceCollectionExtensions.cs`).
|
|
63
|
+
- Grain keys include event store, namespace and event-source ID. Use `IGrainFactory.GetEventSourcedStateMachine<TInterface>(eventStore, eventSourceId)` from `Cratis.Choreography.Chronicle.StateMachines` so tenant coordinates come from the supplied event store (`StateMachines/EventSourcedStateMachineGrainFactoryExtensions.cs`).
|
|
64
64
|
- Prefer passive models. For events consumed by a materialized projection, the reactor waits for its sequence position before refreshing; `ModelCatchUpTimeout` defaults to 30 seconds and expiry fails with `ModelDidNotCatchUp` (`EventSourcedStateMachineReactor.cs`; `EventSourcedStateMachinesOptions.cs`).
|
|
65
65
|
|
|
66
66
|
This machine **follows facts**, it does not arbitrate whether a command may append one. Keep command rejection and append-time invariants at their owning boundary. Enter/model-change effects may repeat on activation, redelivery or replay: design them idempotently (`Documentation/concepts/event-sourced-state-machines.md`). Test guards, no-op refusals, reactivation and persistence failures separately from job recovery.
|
|
@@ -171,5 +171,5 @@ duration resumes at once.
|
|
|
171
171
|
without exactly two outlets PLAY0848, an undeclared reference PLAY0851); PLAY0839 and
|
|
172
172
|
PLAY0841 are shared.
|
|
173
173
|
- Stage refuses ESM v36 models with `STAGE-ESM-016`; every other model renders as
|
|
174
|
-
before. The durable engine is Cratis.
|
|
174
|
+
before. The durable engine is Cratis.Choreography; its hosting and adapters are outside this
|
|
175
175
|
reference.
|
|
@@ -39,8 +39,8 @@ Two engines:
|
|
|
39
39
|
|
|
40
40
|
| Engine | Selected by | Behaviour |
|
|
41
41
|
| --- | --- | --- |
|
|
42
|
-
| EventModel (legacy;
|
|
43
|
-
| Semantic (`cratis run`
|
|
42
|
+
| EventModel (legacy; explicit only) | `--engine eventmodel` on `cratis run`, or `Stage__Runtime__Engine=eventmodel` | Commands evaluate their modeled `produces` mappings, append the facts to Chronicle and echo the payload. **Only part of modeled validation is enforced, and no authorization.** See [What the EventModel engine enforces](#what-the-eventmodel-engine-enforces). It registers Chronicle projections. Named event sources, streams and routes are refused with `STAGE-ESM-030` (`/stage/status` reports `state: "unsupported"` and `/api/**` answers 501), so a routed model does not run here |
|
|
43
|
+
| Semantic (the default of `cratis run` and of Stage) | nothing, `--engine semantic`, or `Stage__Runtime__Engine=semantic` | Evaluates validation, requirements, authorization, conditional production and constraints before accepting a command; appends one batch; denied is HTTP 403, validation or constraint failure HTTP 400, an unsupported command HTTP 501. `GET /stage/semantic/admission` lists what is admitted. Executes routes and event-triggered reactions (including `where`, `runs as`, `from`, productions, invocations and cascades), settling them with the initiating command in one batch. Refuses a model it cannot execute (`state: "unsupported"`, `/api/**` returns 501). Read models are in-process, not Chronicle projections in the Workbench; the history is unbounded, so use it for short sessions |
|
|
44
44
|
|
|
45
45
|
Do not read an answering sandbox as evidence of correct authorization. Callers are
|
|
46
46
|
built from unsigned `x-ms-client-principal` headers that anyone who can reach the host can
|
|
@@ -114,7 +114,7 @@ evidence about the rest.
|
|
|
114
114
|
## Protected command reads
|
|
115
115
|
|
|
116
116
|
Requires Stage 4.129.0 for semantic Host and specification-executor protected reads;
|
|
117
|
-
older engines refuse them with `STAGE-ESM-044`. The
|
|
117
|
+
older engines refuse them with `STAGE-ESM-044`. The EventModel Host and
|
|
118
118
|
structural runner still refuse the preamble with `STAGE-ESM-044`; the structural
|
|
119
119
|
runner exits `1` without a report. The Cratis renderer renders protected reads only from Stage 4.138.0 and refuses unpreservable shapes with `-044`:
|
|
120
120
|
executing a model here does not make it renderable.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: orleans
|
|
3
|
-
description: Use when an Orleans task requires choosing state ownership, communication, scheduling or hosting guarantees against failure. Not for other actor stacks, relational-only CRUD or Cratis.
|
|
3
|
+
description: Use when an Orleans task requires choosing state ownership, communication, scheduling or hosting guarantees against failure. Not for other actor stacks, relational-only CRUD or Cratis.Choreography job implementation.
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ license: MIT
|
|
|
8
8
|
|
|
9
9
|
# Microsoft Orleans
|
|
10
10
|
|
|
11
|
-
Use only within this skill's stated task; general workflow advice does not apply to unrelated tasks. Cratis rules in `.cratis/ai/rules/` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ. `.cratis/ai/rules/orleans.md` forbids `[Alias]` on grain interfaces and grain methods (it is used only on `[GenerateSerializer]` state and definition records that must survive a rename) and forbids `ConfigureAwait(false)` in grain code; **cratis-orleans-jobs** owns recoverable jobs. DurableJobs/Journaling are experimental and are not interchangeable with Cratis.
|
|
11
|
+
Use only within this skill's stated task; general workflow advice does not apply to unrelated tasks. Cratis rules in `.cratis/ai/rules/` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ. `.cratis/ai/rules/orleans.md` forbids `[Alias]` on grain interfaces and grain methods (it is used only on `[GenerateSerializer]` state and definition records that must survive a rename) and forbids `ConfigureAwait(false)` in grain code; **cratis-orleans-jobs** owns recoverable jobs. DurableJobs/Journaling are experimental and are not interchangeable with Cratis.Choreography jobs.
|
|
12
12
|
|
|
13
13
|
## Diagnostic Output Budget
|
|
14
14
|
|