@cratis/pi 7.158.0 → 7.158.1
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/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +7 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +73 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/public-events-and-direction.md +21 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +6 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +54 -126
- package/package/corpus/skills/cratis-screenplay-command-surface/references/compliance.md +6 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/concepts-and-types.md +38 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/generated-values-and-responses.md +19 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/policy-persona-seed.md +61 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/validate-rules.md +7 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +1 -5
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +21 -8
- package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +3 -3
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/principles.md +1 -1
- package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +51 -97
- package/package/corpus/skills/cratis-screenplay-projections/references/mapping-sources.md +33 -0
- package/package/corpus/skills/cratis-screenplay-projections/references/outbound-every.md +12 -0
- package/package/corpus/skills/cratis-screenplay-projections/references/reducers.md +40 -0
- package/package/corpus/skills/cratis-screenplay-projections/references/stage-admission.md +18 -0
- package/package/corpus/skills/cratis-screenplay-projections/verification.json +2 -3
- package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +61 -134
- package/package/corpus/skills/cratis-screenplay-read-surface/references/passive.md +78 -0
- package/package/corpus/skills/cratis-screenplay-read-surface/references/performer-bodies.md +29 -0
- package/package/corpus/skills/cratis-screenplay-read-surface/references/query-execution.md +21 -0
- package/package/corpus/skills/cratis-screenplay-read-surface/references/screen-levels.md +51 -0
- package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +5 -2
- package/package/corpus/skills/cratis-screenplay-reverse-engineering/references/synthesis-rules.md +7 -4
- package/package/corpus/skills/cratis-screenplay-slice-design/references/rule-layers.md +21 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +15 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +12 -2
- package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +1 -0
- package/package.json +1 -1
|
@@ -110,6 +110,13 @@ Current behavior:
|
|
|
110
110
|
The context carries `Principal`, `Target`, `Resource` and `ReceivedAt`.
|
|
111
111
|
The old synchronous `IAuthorizationEvaluator.IsAuthorized` rejects policy-bearing
|
|
112
112
|
declarations.
|
|
113
|
+
- **Policies that decide from recorded state.** Derive from
|
|
114
|
+
`StateAwareAuthorizationPolicy<TState>` (implement `GetKey`, `Read`, `Decide`) and
|
|
115
|
+
register it like any named policy. It fails closed: a missing key, absent state, a
|
|
116
|
+
failed read and a rejecting decision all deny and none throws. It is the hand-written
|
|
117
|
+
counterpart of a Screenplay policy with `reads`. Admission only: later state changes
|
|
118
|
+
do not revoke. Requires Arc 22.181.0. Read
|
|
119
|
+
[authorization](references/authorization.md#policies-that-decide-from-recorded-state).
|
|
113
120
|
- **Schemes.** `AuthenticationSchemes` is honored on the ASP.NET Core host and
|
|
114
121
|
rejected at startup on the standalone Core host.
|
|
115
122
|
- **Composition.** Stacked attributes **AND**; only a role list is OR. A method's
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
- Attributes
|
|
7
7
|
- Composition and precedence
|
|
8
8
|
- Named policies
|
|
9
|
+
- Policies that decide from recorded state
|
|
9
10
|
- Guests and anonymous policies
|
|
10
11
|
- Evaluation order
|
|
11
12
|
- Baselines: two separate mechanisms
|
|
@@ -38,6 +39,8 @@ Requires Arc 22.51.0 for `IdentityDiscovery`, which controls the users/tenants/d
|
|
|
38
39
|
|
|
39
40
|
On an Arc older than 22.21.0 only Arc's own attributes count, and only `Roles` is evaluated: `Policy` and `AuthenticationSchemes` are read by nothing, so `[Authorize(Policy = "…")]` enforces nothing, and Microsoft's `[Authorize]`/`[AllowAnonymous]` are **not** enforced on model-bound commands and read models (a command protected only with Microsoft's attribute is open to every caller). Either upgrade, or use only Arc's attributes with roles and treat everything else as unenforced. Do not write a policy-protected endpoint on an Arc older than 22.23.0.
|
|
40
41
|
|
|
42
|
+
Requires Arc 22.181.0 for `StateAwareAuthorizationPolicy<TState>` and `StateDenialReason` (first release tag that contains them).
|
|
43
|
+
|
|
41
44
|
Requires Arc 22.31.2 for identity and declaration continuity to be rechecked around policy evaluation.
|
|
42
45
|
|
|
43
46
|
Requires Arc 22.43.0 for forwarded identity headers to need a host-wide trust opt-in; older versions trust them from any caller.
|
|
@@ -133,6 +136,76 @@ public record <Name>(...)
|
|
|
133
136
|
in a fresh execution scope. `ICurrentPrincipalAccessor` then exposes the
|
|
134
137
|
selected identity.
|
|
135
138
|
|
|
139
|
+
## Policies that decide from recorded state
|
|
140
|
+
|
|
141
|
+
Use `StateAwareAuthorizationPolicy<TState>` (`Cratis.Arc.Authorization`, `TState : class`) when
|
|
142
|
+
access depends on something the application recorded, such as the plan of the asset a command
|
|
143
|
+
acts on or the author of an article. It implements `IAuthorizationPolicy`, so it is registered,
|
|
144
|
+
referenced and evaluated exactly like any other named policy. It is the hand-written counterpart of a
|
|
145
|
+
Screenplay policy with `reads` (see `cratis-screenplay-command-surface`); a rendered model
|
|
146
|
+
generates the equivalent.
|
|
147
|
+
|
|
148
|
+
```csharp
|
|
149
|
+
public class DataQualityEnabled(IAssetPlans plans) : StateAwareAuthorizationPolicy<AssetPlan>
|
|
150
|
+
{
|
|
151
|
+
protected override object? GetKey(AuthorizationPolicyContext context) =>
|
|
152
|
+
(context.Resource as CommandContext)?.Command is RequestScopedToken command ? command.AssetId : null;
|
|
153
|
+
|
|
154
|
+
protected override async ValueTask<AssetPlan?> Read(object key, CancellationToken cancellationToken) =>
|
|
155
|
+
await plans.Find((AssetId)key, cancellationToken);
|
|
156
|
+
|
|
157
|
+
protected override bool Decide(ClaimsPrincipal principal, AssetPlan state) => state.DataQuality;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
builder.Services.AddArcAuthorizationPolicy<DataQualityEnabled>("DataQualityEnabled"); // before Build()
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```csharp
|
|
164
|
+
[Authorize(Policy = "DataQualityEnabled")]
|
|
165
|
+
[Command]
|
|
166
|
+
public record RequestScopedToken(AssetId AssetId) { /* ... */ }
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
| Member | Contract |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `GetKey(AuthorizationPolicyContext)` | `object?`. Take the key from `context.Resource` (the `CommandContext` or `QueryContext`). Return `null` to deny |
|
|
172
|
+
| `Read(object key, CancellationToken)` | `ValueTask<TState?>`. Fetch the state, typically a read model through your own lookup. Return `null` when none is recorded |
|
|
173
|
+
| `Decide(ClaimsPrincipal, TState)` | `bool`. Compare the state with the caller |
|
|
174
|
+
| `OnDenied(context, StateDenialReason, Exception?)` | virtual, default does nothing. Log or count the cause |
|
|
175
|
+
|
|
176
|
+
**Fail-closed behavior** (from `IsAuthorized` in source), in evaluation order:
|
|
177
|
+
|
|
178
|
+
| Situation | Result | `StateDenialReason` |
|
|
179
|
+
| --- | --- | --- |
|
|
180
|
+
| `GetKey` returns `null` or throws | denied | `NoKey` |
|
|
181
|
+
| `Read` returns `null` (no read model instance) | denied | `NotFound` |
|
|
182
|
+
| `Read` throws (store unavailable, any exception) | denied | `ReadFailed` |
|
|
183
|
+
| `Decide` returns `false` | denied | `Rejected` |
|
|
184
|
+
| `Decide` throws | denied | `Rejected` |
|
|
185
|
+
| Cancellation (`OperationCanceledException` while the token is cancelled) | **propagates**, not a denial | none |
|
|
186
|
+
|
|
187
|
+
Absence never allows, and none of the denials throws, so a denial stays distinguishable from a
|
|
188
|
+
server error only through `OnDenied`. A `Read` that returns a default or empty `TState` instead of
|
|
189
|
+
`null` is your decision and `Decide` then sees it; return `null` for "nothing recorded".
|
|
190
|
+
|
|
191
|
+
Limits:
|
|
192
|
+
|
|
193
|
+
- It is an admission check. The read does not enrol in decision reads and access granted when
|
|
194
|
+
the state later changes is not revoked. A read model can lag the events that produced it, so a
|
|
195
|
+
rule that must hold under concurrent writers belongs in the handler as a protected decision
|
|
196
|
+
read (`cratis-chronicle-decision-reads`), not only in a policy.
|
|
197
|
+
- The default registration is authenticated callers only; an unauthenticated caller is never
|
|
198
|
+
evaluated unless the policy opts in with `evaluatesAnonymous: true`, which a state-aware policy
|
|
199
|
+
rarely should.
|
|
200
|
+
- To end a live observable subscription when the state changes, Arc main also has
|
|
201
|
+
`StateAwareEmissionGuard<TState>` (Requires Arc 22.184.0 or later).
|
|
202
|
+
- To specify a policy, call `IsAuthorized` with a hand-built `AuthorizationPolicyContext` and seed the
|
|
203
|
+
state your `Read` override returns. Cover absent state, a failing read, a missing key and a rejecting decision.
|
|
204
|
+
|
|
205
|
+
Sources: `StateAwareAuthorizationPolicy.cs`, `StateDenialReason.cs` and
|
|
206
|
+
`AuthorizationPolicyServiceCollectionExtensions.cs` in `Cratis/Arc` `Source/DotNET/Arc.Core/Authorization`;
|
|
207
|
+
Arc documentation `backend/csharp/core/authorization.md`.
|
|
208
|
+
|
|
136
209
|
## Guests and anonymous policies
|
|
137
210
|
|
|
138
211
|
By default **a policy requires an authenticated principal**, even when the policy
|
|
@@ -49,6 +49,27 @@ The reference fold admits only root-property set/clear from literals or event
|
|
|
49
49
|
properties; other mappings block planning. Publication is unrouted and reactions
|
|
50
50
|
can observe the new public fact. A route filter therefore cannot select publication.
|
|
51
51
|
|
|
52
|
+
Events an outbound projection publishes count as producers: a routed fact, an
|
|
53
|
+
`every`/`all` scope and compile-time source-type inference all see them, and a
|
|
54
|
+
published instance keeps the event source and context of the fact that produced it.
|
|
55
|
+
An `every` scope folds every producible event type, so inference needs those facts to
|
|
56
|
+
share one source type. A projection that combines `from` and `every` over different
|
|
57
|
+
producible event types is refused as ambiguous (`InvalidSemanticContract`, no `PLAY`
|
|
58
|
+
code), because the published event would have no single source type:
|
|
59
|
+
|
|
60
|
+
```screenplay excerpt
|
|
61
|
+
// Refused: PackOrder produces OrderPacked keyed by an OrderId, while another
|
|
62
|
+
// producer's event is keyed by a different type; `every` folds both.
|
|
63
|
+
projection OrderShippedPublisher => OrderShipped
|
|
64
|
+
every
|
|
65
|
+
status = "packed"
|
|
66
|
+
from OrderPacked
|
|
67
|
+
carrier = carrier
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Fold one source type, or map each event in its own `from` and drop `every`.
|
|
71
|
+
Requires Screenplay 5.2.0 (`screenplay --version`).
|
|
72
|
+
|
|
52
73
|
This complete source uses the released publication specification form:
|
|
53
74
|
|
|
54
75
|
```screenplay
|
|
@@ -113,6 +113,12 @@ the input selection or not; nested paths and read aliases fail binding): keep th
|
|
|
113
113
|
the invoked command or the implementation. A compiler that stops before ESM v6 binds none of this
|
|
114
114
|
(`PLAY0268`).
|
|
115
115
|
|
|
116
|
+
A top-level `trigger` that fails to bind does not refuse the whole model when a host uses
|
|
117
|
+
admissible compilation (Screenplay 5.2.0): the trigger is excluded, the reactions and
|
|
118
|
+
specifications that depend on it are excluded after it, and independent slices still bind. Strict
|
|
119
|
+
binding still refuses the whole model. Read toolchain
|
|
120
|
+
[executable subset](../cratis-screenplay-toolchain/references/executable-subset.md).
|
|
121
|
+
|
|
116
122
|
## Refusals and recovery redelivery
|
|
117
123
|
|
|
118
124
|
Invocation refusal selectors, `$refusal` branch values and `acknowledge`
|
|
@@ -8,31 +8,21 @@ license: MIT
|
|
|
8
8
|
|
|
9
9
|
Read [preferred syntax](../cratis-screenplay-toolchain/references/preferred-syntax.md) when writing or reviewing `.play`.
|
|
10
10
|
|
|
11
|
-
Everything that changes the system: the `command`
|
|
12
|
-
|
|
13
|
-
they are all built from.
|
|
11
|
+
Everything that changes the system: the `command` (intent), the `event` it appends,
|
|
12
|
+
the rules that can refuse it, and the strongly-typed values they are built from.
|
|
14
13
|
|
|
15
14
|
## Locate the model
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`cratis ai install` manages `.cratis/ai/`, never model files. Keep explanatory
|
|
21
|
-
Markdown in project documentation; `.play` is the single flow model.
|
|
16
|
+
The folder of the project's existing `.play` files is the model; code-only `Source/` or `src/` does not qualify. Otherwise use repository-root `Screenplay/`
|
|
17
|
+
([discovery/version gates](../cratis-screenplay-event-modeling/references/file-layout.md#locate-the-model)).
|
|
18
|
+
Never put a model under `.cratis/` or hand-copy it.
|
|
22
19
|
|
|
23
20
|
## Product sources
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
- Generated-value and response rules (ESM v7).
|
|
30
|
-
- Identity and compliance syntax (`identity.md`, `context.md`, `concepts.md`, `purposes.md`, `events.md`, `diagnostics.md`); v13 compliance admission: `references/compliance.md`.
|
|
31
|
-
- v15 generation strategies, strict fixtures and freshness; Stage realization: `references/generated-values-and-responses.md`; shop: `references/shop-generation.md`.
|
|
32
|
-
|
|
33
|
-
"Parses" and "runs" are different claims. The executable profile, and what
|
|
34
|
-
each construct binds to, is in the `cratis-screenplay-model-authoring` language
|
|
35
|
-
reference.
|
|
22
|
+
Versions: toolchain `SKILL.md`. Binding lives in `Semantics/SemanticModelBinder*.cs` and
|
|
23
|
+
`Diagnostics/DiagnosticCodes.cs`; syntax docs are `identity.md`, `context.md`, `concepts.md`,
|
|
24
|
+
`purposes.md`, `events.md` and `diagnostics.md`. "Parses" is not "runs": see the
|
|
25
|
+
`cratis-screenplay-model-authoring` language reference.
|
|
36
26
|
|
|
37
27
|
## `concept` and `type`
|
|
38
28
|
|
|
@@ -42,37 +32,13 @@ concept DiscountPercentage : Decimal
|
|
|
42
32
|
validate
|
|
43
33
|
>= 0 message "A discount cannot be negative"
|
|
44
34
|
<= 100 message "A discount cannot exceed 100 percent"
|
|
45
|
-
concept PersonName : String pii
|
|
46
|
-
pii reason "Identifies the billing contact."
|
|
47
|
-
concept InvoiceStatus : Enum
|
|
48
|
-
draft
|
|
49
|
-
sent
|
|
50
|
-
paid
|
|
51
35
|
```
|
|
52
36
|
|
|
53
|
-
Primitives: `Uuid`, `String`, `Int`, `Decimal`, `Bool`, `Date`, `DateTime
|
|
54
|
-
`
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
[compliance
|
|
58
|
-
consumer ceilings, marker repairs, reasons, scopes and provider limits.
|
|
59
|
-
|
|
60
|
-
**Identifiers cannot be personal data or secrets.** PLAY0515 is a source error
|
|
61
|
-
for command identifiers, typed `for` destinations, event-source identities,
|
|
62
|
-
scalar/composite stream-id types and nested route mapping sources, including legacy
|
|
63
|
-
markers. Keep a surrogate identity and carry protected data in the payload.
|
|
64
|
-
Chronicle likewise rejects `[PII]`/`[Encrypted]` identifiers (CHR0034/CHR0052).
|
|
65
|
-
|
|
66
|
-
Read [enum numbers](references/enum-numbers.md) for `draft = 1`, unique int32
|
|
67
|
-
all-or-none pins, stored/public identity safety, `enum-pinning`, ESM v12 and the
|
|
68
|
-
CLI/Stage gap. Unnumbered enums keep positions; specifications use names.
|
|
69
|
-
|
|
70
|
-
⚠️ **Enum trap.** A value literally named `validate` is read as an empty validate
|
|
71
|
-
block. Write `@validate` for the value; the compiler warns when it sees the
|
|
72
|
-
ambiguity.
|
|
73
|
-
|
|
74
|
-
Use `type <Name>` for a composite shape (several properties) that events and
|
|
75
|
-
commands reference; use `concept` for a single wrapped primitive.
|
|
37
|
+
Primitives: `Uuid`, `String`, `Int`, `Decimal`, `Bool`, `Date`, `DateTime`; `Enum` is a separate kind. Use bare `pii` and `secret` on concepts (**compliance is inherited**) and
|
|
38
|
+
`type <Name>` for a composite shape. **Identifiers cannot be personal data or secrets** (PLAY0515).
|
|
39
|
+
⚠️ A value literally named `validate` in an enum is read as an empty validate block; write `@validate`.
|
|
40
|
+
Read [concepts and types](references/concepts-and-types.md) for pii/secret, enum numbers and the
|
|
41
|
+
links to [compliance](references/compliance.md) and [enum numbers](references/enum-numbers.md).
|
|
76
42
|
|
|
77
43
|
## The command block
|
|
78
44
|
|
|
@@ -108,13 +74,10 @@ Keep to it.
|
|
|
108
74
|
A file/code `handler` beside unconditional `produces`, with a resolved nonempty body,
|
|
109
75
|
binds as the v23 result contract: `produces` fixes the
|
|
110
76
|
events and the body owns their property values. Without `produces`, with `produces ... when`,
|
|
111
|
-
or with an unresolved body it fails binding with PLAY0800
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
`produces` for declarative logic. Read [described handlers](references/described-handlers.md)
|
|
116
|
-
when logic needs prose, for the result contract, PLAY0695–0698, Unsupported
|
|
117
|
-
ImplementationBody and Stage's STAGE-IMPL-002 refusal (no stubs, even in Stub mode).
|
|
77
|
+
or with an unresolved body it fails binding with PLAY0800. A pending
|
|
78
|
+
`handler implementation` beside unconditional `produces` is a described command (ESM v23).
|
|
79
|
+
Prefer plain `produces` for declarative logic. Read [described handlers](references/described-handlers.md)
|
|
80
|
+
for the result contract, version gates, PLAY0695–0698 and Stage's STAGE-IMPL-002 refusal.
|
|
118
81
|
|
|
119
82
|
## `identifier` — the stream boundary decision
|
|
120
83
|
|
|
@@ -126,28 +89,14 @@ something whose identity the caller does not supply); for a create command prefe
|
|
|
126
89
|
`generated identifier` below, which also keeps the id out of the rendered form.
|
|
127
90
|
|
|
128
91
|
**A command that creates something has no caller-supplied id.** Declare
|
|
129
|
-
`<id> <IdConcept> generated identifier` (ESM v7
|
|
130
|
-
caller needs it back
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
[
|
|
92
|
+
`<id> <IdConcept> generated identifier` (ESM v7) and `returns <id>` when the
|
|
93
|
+
caller needs it back; plain `identifier` on a create command makes the rendered form ask the user to type
|
|
94
|
+
the id. Keep plain `identifier` for commands that act on an existing stream. Specifications pin the
|
|
95
|
+
allocated value with `for "<value>"`. Read
|
|
96
|
+
[generated values](references/generated-values-and-responses.md) before writing one;
|
|
97
|
+
the shared model is [shop generation](references/shop-generation.md).
|
|
135
98
|
|
|
136
|
-
|
|
137
|
-
command RegisterOrganization
|
|
138
|
-
organizationId OrganizationId generated identifier
|
|
139
|
-
name OrganizationName
|
|
140
|
-
produces event OrganizationRegistered
|
|
141
|
-
name OrganizationName = name
|
|
142
|
-
returns organizationId
|
|
143
|
-
specification RegistersAnOrganization
|
|
144
|
-
when RegisterOrganization
|
|
145
|
-
for "11111111-1111-1111-1111-111111111111"
|
|
146
|
-
name = "Acme"
|
|
147
|
-
then OrganizationRegistered
|
|
148
|
-
for "11111111-1111-1111-1111-111111111111"
|
|
149
|
-
name = "Acme"
|
|
150
|
-
```
|
|
99
|
+
The complete create-command example with its specification is in that reference.
|
|
151
100
|
|
|
152
101
|
- A second `identifier` on the same command is an error: *only one property can be
|
|
153
102
|
the identifier*.
|
|
@@ -177,12 +126,10 @@ alias on **every** read (`PLAY0410`), aliases are unique (`PLAY0411`) and must n
|
|
|
177
126
|
match a command property (`PLAY0412`). A `require` path uses the alias, or the
|
|
178
127
|
view name when that view is read once.
|
|
179
128
|
|
|
180
|
-
Opt eligible state reads into application-root `command reads protected` (v25)
|
|
181
|
-
|
|
182
|
-
for
|
|
183
|
-
reads
|
|
184
|
-
Requires Stage 4.138.0 to render protected reads as Arc read protection (shapes it cannot preserve stay STAGE-ESM-044); `cratis render` gets it from the first CLI that bundles it, and CLI 3.75.0 refuses every protected read with STAGE-ESM-044.
|
|
185
|
-
Uniqueness still uses a constraint; reference success is not target realization.
|
|
129
|
+
Opt eligible state reads into application-root `command reads protected` (v25); legacy reads stay
|
|
130
|
+
unprotected and reads/concurrency cannot combine (PLAY0783). Read [protected reads](references/protected-reads.md)
|
|
131
|
+
for admission, paths and PLAY0780–0786.
|
|
132
|
+
Rendering needs a recent Stage (the protected-reads reference has the CLI versions). Uniqueness still uses a constraint; reference success is not target realization.
|
|
186
133
|
|
|
187
134
|
Do not use `reads` to fetch data the caller could supply. A composite-key view's `by` block in a
|
|
188
135
|
command read is `PLAY0271`, or `PLAY0781` reason `by-parts` under `command reads protected`
|
|
@@ -208,24 +155,16 @@ optional `severity`, sharing the condition grammar with `produces … when`:
|
|
|
208
155
|
`and` binds tighter than `or`, parentheses group. A conditional rule is an
|
|
209
156
|
implication: `require isExtension == false or newEndDate > endDate`.
|
|
210
157
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
`today - 7 days`, `date of occurred`; PLAY0812 to PLAY0814): do not author them into executable models.
|
|
218
|
-
|
|
219
|
-
Requires Screenplay 4.205.0 (ESM v28; `screenplay --version`) for `==`/`!=` between Uuid
|
|
220
|
-
values (properties, concepts, identities, canonical literals, and read paths in `require`);
|
|
221
|
-
older binders report PLAY0268. Read [Uuid equality](references/uuid-equality.md) for the same-concept
|
|
222
|
-
rule, PLAY0268/0273 and the refused shapes (ordering, Uuid validation rules, Uuid concept rules).
|
|
158
|
+
Date/DateTime comparisons need ESM v26 and Uuid `==`/`!=` needs
|
|
159
|
+
ESM v28; older binders report PLAY0268 (`screenplay --version`). Read
|
|
160
|
+
[date comparisons](references/date-comparisons.md) for ordering a retention window with
|
|
161
|
+
`require to >= from`, offsets and the parsed-but-not-runnable calendar and clock forms
|
|
162
|
+
(PLAY0812 to PLAY0814; do not author them into executable models), and
|
|
163
|
+
[Uuid equality](references/uuid-equality.md) for the same-concept rule and refused shapes.
|
|
223
164
|
|
|
224
|
-
**Rules whose logic is code.** A bare `rule <Name>` has no portable meaning (`PLAY0268`)
|
|
165
|
+
**Rules whose logic is code.** A bare `rule <Name>` has no portable meaning (`PLAY0268`); a bodied rule binds only as
|
|
225
166
|
opaque code. Read [references/validate-rules.md](references/validate-rules.md) when a rule's logic must live in a `file`
|
|
226
|
-
or fenced code body
|
|
227
|
-
the body is opaque and travels unchanged, and the Cratis render target refuses `java` bodies.
|
|
228
|
-
Requires Screenplay 4.244.0 (`screenplay --version`) for that refusal.
|
|
167
|
+
or fenced code body (the Cratis render target refuses `java` bodies).
|
|
229
168
|
|
|
230
169
|
**Put format rules on the `concept`, not the command** (except date comparisons,
|
|
231
170
|
which bind only on command properties, not as concept rules). A concept carries its own
|
|
@@ -246,16 +185,12 @@ authorize (IsAccountant or IsFinance) and OwnsInvoice
|
|
|
246
185
|
Policy names are PascalCase. `and` binds tighter than `or`; parentheses group.
|
|
247
186
|
A continuation line extends the clause.
|
|
248
187
|
|
|
249
|
-
⚠️
|
|
250
|
-
`A and B`. Write the operator explicitly so the reader does not have to know this.
|
|
188
|
+
⚠️ Two adjacent policies synthesize an implicit `and` (`authorize A B` means `A and B`); write the operator.
|
|
251
189
|
|
|
252
190
|
- Several `authorize` lines on one command or query combine with AND, in authored
|
|
253
|
-
order.
|
|
254
|
-
-
|
|
255
|
-
|
|
256
|
-
- Evaluation short-circuits left to right, module → feature → command. If it
|
|
257
|
-
reaches a policy implemented in code, the reference runner reports the outcome
|
|
258
|
-
unsupported; it never guesses allow or deny.
|
|
191
|
+
order; a `module` or `feature` gate is ANDed too, so an `or` never bypasses another gate.
|
|
192
|
+
- Evaluation short-circuits left to right, module → feature → command. A policy implemented
|
|
193
|
+
in code makes the reference runner report the outcome unsupported, never allow or deny.
|
|
259
194
|
|
|
260
195
|
## Inline events and destinations
|
|
261
196
|
|
|
@@ -281,19 +216,14 @@ One `concurrency` block per command; it is not bound (`PLAY0271`) and does not p
|
|
|
281
216
|
|
|
282
217
|
## Generated values and responses (ESM v7 and v15)
|
|
283
218
|
|
|
284
|
-
UUID generation
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
remain refused. Patterns are readable references, not gapless allocators or secrets;
|
|
290
|
-
check digits catch typos, not forgery. Keep uniqueness/freshness enforcement.
|
|
291
|
-
Read [references/generated-values-and-responses.md](references/generated-values-and-responses.md)
|
|
292
|
-
for `generated`, `generate`, `returns`, strict fixtures/freshness and renderer limits.
|
|
219
|
+
UUID generation and responses bind as v7; concept `generate` strategies select v15, rules v20 and pattern/checksum rules v21; older
|
|
220
|
+
compilers refuse PLAY0268 (`screenplay --version`). Secrets and sequences remain refused;
|
|
221
|
+
keep uniqueness and freshness enforcement. Read
|
|
222
|
+
[references/generated-values-and-responses.md](references/generated-values-and-responses.md)
|
|
223
|
+
for `generated`, `generate`, `returns`, strict fixtures, freshness and renderer limits.
|
|
293
224
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
Routes and realization: `cratis-screenplay-toolchain/references/sources-and-streams.md`.
|
|
225
|
+
Further gates: stored stream `All` refusal, compliance (ESM v13), enum numbers (ESM v12).
|
|
226
|
+
Example: `cratis-screenplay-toolchain/references/generated-responses-example.md`; routes: `cratis-screenplay-toolchain/references/sources-and-streams.md`.
|
|
297
227
|
|
|
298
228
|
## `constraint` — uniqueness at append time
|
|
299
229
|
|
|
@@ -303,6 +233,8 @@ Chronicle's constraints enforce **uniqueness only**; use one when two concurrent
|
|
|
303
233
|
|
|
304
234
|
A policy has **exactly one** `require` line (`PLAY0441`) **or** one implementation, never both (`PLAY0440`). Read [references/policy-persona-seed.md](references/policy-persona-seed.md) when
|
|
305
235
|
declaring a policy (including `require anonymous` for a deliberately public command or query), a persona, or a `seed` block.
|
|
236
|
+
A policy that decides from recorded state declares `reads <Model> [as alias] [by property]` and a state condition in `require`
|
|
237
|
+
(`plan.dataQuality == true`, `article.author == $identity.id`); an absent read denies. See the same reference, "Policies that decide from recorded state".
|
|
306
238
|
|
|
307
239
|
`authorize` says who may act; whether the command exists for the caller at all is `available`, with `provide` for `$context` values: `cratis-screenplay-availability`.
|
|
308
240
|
|
|
@@ -326,23 +258,19 @@ Four contexts, and **what each omits is load-bearing** — when writing a code b
|
|
|
326
258
|
## Verify
|
|
327
259
|
|
|
328
260
|
- [ ] Validate the complete model root with warnings as errors; name the tool,
|
|
329
|
-
version and result
|
|
330
|
-
bundle compatibility and execution are separate checks.
|
|
261
|
+
version and result (versions: toolchain `SKILL.md`).
|
|
331
262
|
- [ ] No unintended `PLAY0478` or `PLAY0479` information remains.
|
|
332
263
|
- [ ] At most one command property carries `identifier`, and no event property does.
|
|
333
264
|
- [ ] Format rules live on the `concept` except command-only date comparisons;
|
|
334
265
|
state-dependent rules are specifications. DateTime comparisons preserve UTC
|
|
335
266
|
ticks; specs include missing-offset Validation rejection.
|
|
336
267
|
- [ ] Every `authorize` combining policies writes `and`/`or` explicitly.
|
|
337
|
-
- [ ] Protected reads opt in
|
|
338
|
-
from target realization; legacy reads and `concurrency` imply no protection.
|
|
268
|
+
- [ ] Protected reads opt in and meet admission; legacy reads and `concurrency` imply no protection.
|
|
339
269
|
- [ ] Constraints are `unique` forms; no `file` constraint stands in for another rule.
|
|
340
270
|
- [ ] Each policy has one `require` or one implementation, not both.
|
|
341
271
|
- [ ] Personal data is `pii` on the concept; operational secrets are `secret`;
|
|
342
|
-
no identifier or subject concept carries either
|
|
343
|
-
|
|
344
|
-
- [ ] Described handlers distinguish binding from Unsupported body execution and
|
|
345
|
-
Stage refusal; attached handlers remain unbound. Name the admitting tool.
|
|
272
|
+
no identifier or subject concept carries either; run `--check purposes` separately.
|
|
273
|
+
- [ ] Described handlers distinguish binding from Unsupported body execution and Stage refusal.
|
|
346
274
|
- [ ] No event carries an optional property covering two situations.
|
|
347
275
|
|
|
348
276
|
Compiler versions and admission: `cratis-screenplay-toolchain/SKILL.md`.
|
|
@@ -198,6 +198,12 @@ Move legal declarations out of old reasons by hand; repairs never guess them.
|
|
|
198
198
|
|
|
199
199
|
## Identify the person, not the stream
|
|
200
200
|
|
|
201
|
+
**Identifiers cannot be personal data or secrets.** PLAY0515 is a source error
|
|
202
|
+
for command identifiers, typed `for` destinations, event-source identities,
|
|
203
|
+
scalar/composite stream-id types and nested route mapping sources, including legacy
|
|
204
|
+
markers. Keep a surrogate identity and carry protected data in the payload.
|
|
205
|
+
Chronicle likewise rejects `[PII]`/`[Encrypted]` identifiers (CHR0034/CHR0052).
|
|
206
|
+
|
|
201
207
|
An event property may end in `subject`, last among modifiers (before `=` on an
|
|
202
208
|
inline mapping). Each generation may choose one mark independently:
|
|
203
209
|
|
package/package/corpus/skills/cratis-screenplay-command-surface/references/concepts-and-types.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# `concept` and `type`
|
|
2
|
+
|
|
3
|
+
Read this when declaring a concept (validation, enum, protection) or a composite `type`.
|
|
4
|
+
|
|
5
|
+
```screenplay
|
|
6
|
+
concept InvoiceId : Uuid
|
|
7
|
+
concept DiscountPercentage : Decimal
|
|
8
|
+
validate
|
|
9
|
+
>= 0 message "A discount cannot be negative"
|
|
10
|
+
<= 100 message "A discount cannot exceed 100 percent"
|
|
11
|
+
concept PersonName : String pii
|
|
12
|
+
pii reason "Identifies the billing contact."
|
|
13
|
+
concept InvoiceStatus : Enum
|
|
14
|
+
draft
|
|
15
|
+
sent
|
|
16
|
+
paid
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Primitives: `Uuid`, `String`, `Int`, `Decimal`, `Bool`, `Date`, `DateTime`.
|
|
20
|
+
`Enum` is a separate concept kind; details: [enum numbers](enum-numbers.md).
|
|
21
|
+
Use bare `pii` (`personal` alias) and `secret` on concepts; **Compliance is inherited**.
|
|
22
|
+
Keep protection even when a compiler or renderer refuses it. Read
|
|
23
|
+
[compliance and purposes](compliance.md) for ESM v13, binder-only refusals,
|
|
24
|
+
consumer ceilings, marker repairs, reasons, scopes and provider limits.
|
|
25
|
+
|
|
26
|
+
**Identifiers cannot be personal data or secrets** (PLAY0515): see
|
|
27
|
+
[compliance](compliance.md#identify-the-person-not-the-stream).
|
|
28
|
+
|
|
29
|
+
Read [enum numbers](enum-numbers.md) for `draft = 1`, unique int32
|
|
30
|
+
all-or-none pins, stored/public identity safety, `enum-pinning`, ESM v12 and the
|
|
31
|
+
CLI/Stage gap. Unnumbered enums keep positions; specifications use names.
|
|
32
|
+
|
|
33
|
+
⚠️ **Enum trap.** A value literally named `validate` is read as an empty validate
|
|
34
|
+
block. Write `@validate` for the value; the compiler warns when it sees the
|
|
35
|
+
ambiguity.
|
|
36
|
+
|
|
37
|
+
Use `type <Name>` for a composite shape (several properties) that events and
|
|
38
|
+
commands reference; use `concept` for a single wrapped primitive.
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
- Version and freshness
|
|
12
12
|
- Responses and pre-generation boundaries
|
|
13
13
|
- What the CLI and Stage realize
|
|
14
|
+
- Create command with a generated identifier
|
|
14
15
|
|
|
15
16
|
`generated` properties and `returns` bind/reference-execute (ESM v7).
|
|
16
17
|
Concept generation strategies and whole-source freshness bind as ESM v15. The CLI and Stage
|
|
@@ -308,3 +309,21 @@ assertions against captured values; v15 captures also check strategy shape.
|
|
|
308
309
|
The in-memory Stage executor instead requires deterministic fixtures and returns
|
|
309
310
|
Unsupported(IdentityAllocation) when missing. Build and run generated Debug
|
|
310
311
|
specifications separately; source reading is not a render or runtime result.
|
|
312
|
+
|
|
313
|
+
## Create command with a generated identifier
|
|
314
|
+
|
|
315
|
+
```screenplay excerpt
|
|
316
|
+
command RegisterOrganization
|
|
317
|
+
organizationId OrganizationId generated identifier
|
|
318
|
+
name OrganizationName
|
|
319
|
+
produces event OrganizationRegistered
|
|
320
|
+
name OrganizationName = name
|
|
321
|
+
returns organizationId
|
|
322
|
+
specification RegistersAnOrganization
|
|
323
|
+
when RegisterOrganization
|
|
324
|
+
for "11111111-1111-1111-1111-111111111111"
|
|
325
|
+
name = "Acme"
|
|
326
|
+
then OrganizationRegistered
|
|
327
|
+
for "11111111-1111-1111-1111-111111111111"
|
|
328
|
+
name = "Acme"
|
|
329
|
+
```
|
package/package/corpus/skills/cratis-screenplay-command-surface/references/policy-persona-seed.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
- `policy` and `persona`
|
|
6
6
|
- Anonymous policy
|
|
7
7
|
- Policy negation
|
|
8
|
+
- Policies that decide from recorded state
|
|
8
9
|
- `seed`
|
|
9
10
|
|
|
10
11
|
## `policy` and `persona`
|
|
@@ -106,6 +107,66 @@ negated claim's target is optional, non-string, or a subject without a command
|
|
|
106
107
|
identifier. This C# semantic check does not come from ordinary editor validation.
|
|
107
108
|
Source: `Documentation/screenplay/policies.md`.
|
|
108
109
|
|
|
110
|
+
## Policies that decide from recorded state
|
|
111
|
+
|
|
112
|
+
A policy can decide from state the application has recorded (the plan of the asset a command
|
|
113
|
+
acts on, the author of an article) instead of only from the caller. It declares the read models
|
|
114
|
+
it consults with `reads` and compares what they hold in `require`.
|
|
115
|
+
|
|
116
|
+
Excerpt: the read models `AssetPlan` and `Article`, their projections and the commands are declared elsewhere.
|
|
117
|
+
|
|
118
|
+
```screenplay excerpt
|
|
119
|
+
policy DataQualityEnabled
|
|
120
|
+
reads AssetPlan as plan by assetId
|
|
121
|
+
require authenticated and plan.dataQuality == true
|
|
122
|
+
|
|
123
|
+
policy IsAuthor
|
|
124
|
+
reads Article as article by slug
|
|
125
|
+
require authenticated and article.author == $identity.id
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- `reads <Model> [as <alias>] [by <property>]`. `by` names a property of the command or query being
|
|
129
|
+
authorized (resolved like `claim "x" matches invoice.department`); it is the key of the read.
|
|
130
|
+
Without `as`, the model name is the alias.
|
|
131
|
+
- A state condition is the shared condition operand (`<path> <operator> <value>`) used by
|
|
132
|
+
`produces when` and `validate require`. The path starts at a read alias, a property of the artifact
|
|
133
|
+
being authorized or `$identity`. It combines with `authenticated`, `role`, `claim`, `not`, `and` and `or`.
|
|
134
|
+
- A policy has `reads` **and** one `require`; it never also has an implementation (`PLAY0440`), and one `require` line
|
|
135
|
+
(`PLAY0441`).
|
|
136
|
+
- The caller's identifier is `$identity.id`: the property must be required text and the operator `==` or `!=`;
|
|
137
|
+
other caller details and artifact operands are refused. A specification names the caller's identifier with
|
|
138
|
+
`id "alice"` under `given caller`.
|
|
139
|
+
- `contains` (a required text collection holds an element, or a required text property holds a substring) and
|
|
140
|
+
`starts with` compare against a text constant, ordinal and case-sensitive. An absent value never matches.
|
|
141
|
+
- A policy can declare typed inputs that a command or query maps (`asset AssetId`, then under
|
|
142
|
+
`authorize PlanGrants` a line `asset = vesselId`), so it does not depend on how an artifact spells its key.
|
|
143
|
+
An unmapped input is filled from the artifact property of the same name. The mapping block belongs to one
|
|
144
|
+
`authorize <Policy>` line.
|
|
145
|
+
- `narrow <Policy>` on a collection query drops, per row, the rows the policy denies (a row without recorded state is
|
|
146
|
+
dropped too); `authorize` still refuses the whole call and composes with it. Not an `authorize` form.
|
|
147
|
+
|
|
148
|
+
**Fail-closed.** A read that finds nothing denies; a policy never allows because state is missing. In the generated
|
|
149
|
+
Arc policy, a missing key, a missing instance, a failing read and an unauthenticated caller (when `$identity.id` is
|
|
150
|
+
used and the principal carries none) all make the policy *unavailable*, and unavailable denies. A negated condition does
|
|
151
|
+
not turn absence into allow: `!=` against `$identity.id` still denies a caller that cannot say who it is. A specification
|
|
152
|
+
states the denial with a `given` read model (or none) and a `then` rejection of kind `Unauthorized`.
|
|
153
|
+
|
|
154
|
+
**Admission and rendering.** Screenplay admits these policies to the executable semantic model, so
|
|
155
|
+
they bind and the reference evaluator runs them from `given` read-model state. ESM versions: `reads` and state
|
|
156
|
+
conditions v44, `contains`/`starts with` v45, policy inputs v46, `narrow` v47, `$identity.id` v49. A model that uses none
|
|
157
|
+
of them is unchanged. Rendering is a separate step: Stage renders v44 to v47 policies as fail-closed
|
|
158
|
+
Arc authorization policies, and `$identity.id` reads the caller from the principal Arc authorized (Stage
|
|
159
|
+
`reference/authentication-rendering.md`). An unsupported shape is refused for that artifact with the construct named;
|
|
160
|
+
never weaken or drop the policy to render. The executable model admits a read property compared with a constant of its
|
|
161
|
+
scalar type (text, enumeration, number, boolean). Check the compiler version (`cratis-screenplay-toolchain`) before
|
|
162
|
+
relying on a version-specific form. Not verified end to end in this corpus: a generated application built in CI.
|
|
163
|
+
|
|
164
|
+
The hand-written counterpart in Arc is `StateAwareAuthorizationPolicy<TState>` (`cratis-arc-authentication-authorization-and-identity`).
|
|
165
|
+
Admission only: like every policy, the check runs when the call is admitted and revokes nothing later. A rule that must
|
|
166
|
+
hold under concurrent writers belongs in a protected command read (`protected-reads.md`).
|
|
167
|
+
|
|
168
|
+
Sources: Screenplay `Documentation/screenplay/policies.md`, decisions 0151, 0152, 0153, 0154, 0157.
|
|
169
|
+
|
|
109
170
|
## `seed`
|
|
110
171
|
|
|
111
172
|
Excerpt: `CustomerRegistered` is declared in a slice.
|
package/package/corpus/skills/cratis-screenplay-command-surface/references/validate-rules.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
- Rule vocabulary
|
|
6
6
|
- `require` message
|
|
7
|
+
- Code bodies
|
|
7
8
|
- Date and DateTime comparisons
|
|
8
9
|
- `not empty` means non-blank text
|
|
9
10
|
- Rules whose logic is code
|
|
@@ -42,6 +43,12 @@ validate
|
|
|
42
43
|
message "The end must not be before the start"
|
|
43
44
|
```
|
|
44
45
|
|
|
46
|
+
## Code bodies
|
|
47
|
+
|
|
48
|
+
Built-in inline languages are `csharp`, `typescript`, `react`, `html`, `sql` and `java`;
|
|
49
|
+
the body is opaque and travels unchanged, and the Cratis render target refuses `java` bodies
|
|
50
|
+
(Requires Screenplay 4.244.0, `screenplay --version`).
|
|
51
|
+
|
|
45
52
|
## Date and DateTime comparisons
|
|
46
53
|
|
|
47
54
|
Requires Screenplay 4.199.0 (ESM v26; `screenplay --version`); older binders refuse
|
|
@@ -40,11 +40,7 @@
|
|
|
40
40
|
{ "kind": "skill-contains", "value": "`reads X optional` is not supported yet" },
|
|
41
41
|
{
|
|
42
42
|
"kind": "skill-contains",
|
|
43
|
-
"value": "
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"kind": "skill-contains",
|
|
47
|
-
"value": "`cratis ai install` manages `.cratis/ai/`, never model files"
|
|
43
|
+
"value": "The folder of the project's existing `.play` files"
|
|
48
44
|
},
|
|
49
45
|
{
|
|
50
46
|
"kind": "skill-contains",
|