@cratis/pi 7.45.0 → 7.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/product-sync.json +3 -3
- package/package/corpus/skills/cratis-arc-command/SKILL.md +21 -19
- package/package/corpus/skills/cratis-arc-command/references/generated-values.md +19 -54
- package/package/corpus/skills/cratis-arc-command/references/shop-generation.md +110 -0
- package/package/corpus/skills/cratis-fundamentals-concept/SKILL.md +21 -11
- package/package/corpus/skills/cratis-fundamentals-concept/references/shop-generation.md +108 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-command-surface/references/generated-values-and-responses.md +20 -17
- package/package/corpus/skills/cratis-screenplay-command-surface/references/shop-generation.md +96 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +11 -2
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/generate-notes.md +5 -4
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/generated-recovery.md +128 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +30 -27
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/choosing-generation.md +30 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +1 -1
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-loop.md +3 -3
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +26 -15
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/property-links.md +11 -7
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/release-baseline.md +140 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +16 -3
- package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-read-surface/references/equality-filters.md +1 -1
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/delivery-protocol.md +1 -1
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +10 -2
- package/package/corpus/skills/cratis-screenplay-specifications/references/generated-fixtures.md +42 -10
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +7 -4
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution-example.md +5 -4
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution.md +50 -23
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/verification.json +7 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +2 -2
- package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +13 -11
- package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +2 -2
- package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract-exceptions.json +7 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.json +963 -7
- package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.version +1 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/verdicts.md +12 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/versions.md +51 -7
- package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +5 -1
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +22 -12
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/choosing-generation.md +30 -0
- package/package.json +1 -1
|
@@ -166,9 +166,9 @@
|
|
|
166
166
|
}
|
|
167
167
|
],
|
|
168
168
|
"synced": {
|
|
169
|
-
"version": "4.
|
|
169
|
+
"version": "4.153.0",
|
|
170
170
|
"date": "2026-10-13",
|
|
171
|
-
"by": "Cratis/AI#
|
|
171
|
+
"by": "Cratis/AI#655"
|
|
172
172
|
},
|
|
173
173
|
"covers": {
|
|
174
174
|
"skills": [
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
],
|
|
197
197
|
"rules": []
|
|
198
198
|
},
|
|
199
|
-
"notes": "Standalone 4.
|
|
199
|
+
"notes": "Standalone 4.153.0 and byte-identical published/Golden contract pinned for Cratis/AI#655; retains Cratis/AI#654, #648, #650 and #652. Text not empty rejects Unicode White_Space-only values in every ESM version without changing canonical bytes; collections and identity text remain unchanged. Stored stream All is reserved at binding (PLAY0273), including id pins; differing event pins carry storedName in ESM v16; equal-name pins are no-ops, PLAY0472 checks validity/generation agreement/uniqueness, and PLAY0686 is retired. Latest released Stage 4.92.0 / CLI 3.59.0 still admit only through v15 (CLI bundles Screenplay 4.147.1), so stored-name rendering is not released. Decision 0070 release baseline (Cratis/AI#655) ships CLI admit/check, committed sidecar, MCP list/proposal review and independent revision guards. No baseline requires an explicit event mode; unadmitted revisions default to inPlace; admitted revisions require newGeneration. Only a reviewed correction may hand-edit the baseline. The 4.153.0 from-esm route uses contract.Name rather than StoredName and can refuse pinned renames; source boundary is documented, not hidden. Child-before-parent reference deferral is executable across given/when and accepted commits; parent absence leaves children out, ambiguous parents fail, and decision 0007's creation-event routing difference remains. Adds the concept generation MCP summary, typed strategy editing guidance and PLAY0683/PLAY0684 entropy/uniqueness repairs; derived regex, matches/checksum repair and rule-proof status remain unshipped. Retains ESM v15 strategies, strict fixtures, whole-source freshness and 4.148.0 response-name resolution. Historical evidence stays qualified. CLI 3.57.0 / MCP 4.147.1 lacks the new summary and repairs; this pin does not upgrade CLI or Scene runtime."
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
"id": "scene",
|
|
@@ -172,25 +172,27 @@ public record Transfer(<AccountId> From, <AccountId> To, <Money> Amount)
|
|
|
172
172
|
|
|
173
173
|
## Generate a server-owned new identifier
|
|
174
174
|
|
|
175
|
-
**Arc 22.66.0
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
175
|
+
**Arc 22.66.0+**: replace local `New()` with a `[GeneratedValue]` Handle parameter,
|
|
176
|
+
never a request property. Use a non-nullable self-generatable concept and a unique,
|
|
177
|
+
case-sensitive generated name. Return the value explicitly if the caller needs it.
|
|
178
|
+
Read [generated values](references/generated-values.md) for Provide/DI boundaries,
|
|
179
|
+
validation/captures, ARC0022–ARC0025, migration and named pins; newer context
|
|
180
|
+
factories are version-qualified in the shop reference below.
|
|
181
|
+
|
|
182
|
+
## Choosing a strategy
|
|
183
|
+
|
|
184
|
+
Use the [threaded shop example](references/shop-generation.md): CustomerId
|
|
185
|
+
(`cus_` + ULID), context-aware TypeID OrderId, NanoID InviteCode and secret
|
|
186
|
+
`Bytes(32)` ApiKey. Arc 22.87.1 resolves Fundamentals 7.24.0 and passes captured
|
|
187
|
+
received time/tenant to context factories; released Clock/Tenant scenario setup
|
|
188
|
+
is shown there. Earlier version-qualified examples above remain unchanged.
|
|
189
|
+
|
|
190
|
+
## When not to generate
|
|
191
|
+
|
|
192
|
+
Keep client-owned IDs as inputs. Generation is not authorization, tenant
|
|
193
|
+
isolation, idempotency, freshness or gapless invoice numbering. Credentials need
|
|
194
|
+
explicit entropy, `[NotAudited]`, authorized delivery and hash storage; never
|
|
195
|
+
log captures or persist plaintext authentication keys. See [boundaries](references/shop-generation.md#when-not-to-generate).
|
|
194
196
|
|
|
195
197
|
## Where the event source id comes from
|
|
196
198
|
|
|
@@ -18,50 +18,13 @@ Generated parameters arrived in Arc **22.66.0**, scenario pinning in **22.67.0**
|
|
|
18
18
|
and analyzers in **22.68.0**. The examples and behavior here are verified at
|
|
19
19
|
**v22.68.0**, which pins Fundamentals **7.23.0**.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
using Cratis.Arc.Commands.ModelBound;
|
|
29
|
-
using Cratis.Concepts;
|
|
30
|
-
|
|
31
|
-
namespace Shopping.Carts;
|
|
32
|
-
|
|
33
|
-
/// <summary>
|
|
34
|
-
/// Represents a cart identifier.
|
|
35
|
-
/// </summary>
|
|
36
|
-
/// <param name="Value">The underlying identifier.</param>
|
|
37
|
-
public record CartId(Guid Value) : ConceptAs<Guid>(Value), IGeneratable<CartId>
|
|
38
|
-
{
|
|
39
|
-
/// <summary>
|
|
40
|
-
/// Creates a new cart identifier.
|
|
41
|
-
/// </summary>
|
|
42
|
-
/// <returns>A new cart identifier.</returns>
|
|
43
|
-
public static CartId New() => new(GenerateValue.Uuid());
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/// <summary>
|
|
47
|
-
/// Allocates a server-owned cart identifier.
|
|
48
|
-
/// </summary>
|
|
49
|
-
[Command]
|
|
50
|
-
public record AllocateCartId
|
|
51
|
-
{
|
|
52
|
-
/// <summary>
|
|
53
|
-
/// Returns the allocated identifier to the caller.
|
|
54
|
-
/// </summary>
|
|
55
|
-
/// <param name="cartId">The server-generated identifier.</param>
|
|
56
|
-
/// <returns>The allocated identifier.</returns>
|
|
57
|
-
public CartId Handle([GeneratedValue("cart")] CartId cartId) => cartId;
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
For a Chronicle stream identity, derive `CartId` from `EventSourceId<Guid>`
|
|
62
|
-
instead; see `cratis-fundamentals-concept`. Return `(id, event)` to both append
|
|
63
|
-
and give the caller the new stream id, as in SKILL.md. An identifier is not an
|
|
64
|
-
event, and generation alone does not persist anything.
|
|
21
|
+
For the current threaded example, read [shop commands](shop-generation.md) and
|
|
22
|
+
[shop concepts](../../cratis-fundamentals-concept/references/shop-generation.md).
|
|
23
|
+
Those declarations are separately verified at Arc 22.87.1 / Fundamentals 7.24.0:
|
|
24
|
+
CustomerId (`cus_` + ULID), context-aware TypeID OrderId, NanoID InviteCode and
|
|
25
|
+
secret bytes ApiKey. They allocate responses, not events or persisted entities.
|
|
26
|
+
For a real Chronicle stream identity use `EventSourceId<T>`; return `(id, event)`
|
|
27
|
+
to append and return the stream ID, or use an explicit event-source wrapper.
|
|
65
28
|
|
|
66
29
|
Keep existing/client-chosen identifiers and references on command properties.
|
|
67
30
|
Services and read models remain ordinary dependencies, not generated values.
|
|
@@ -77,7 +40,7 @@ The type must be non-nullable and implement `IGeneratable<TSelf>` for itself;
|
|
|
77
40
|
a raw `Guid`, nullable concept or by-reference parameter is invalid. Use domain
|
|
78
41
|
concepts; the runtime's type check is the self-generatable interface contract.
|
|
79
42
|
|
|
80
|
-
`[GeneratedValue]` uses the parameter name. `[GeneratedValue("
|
|
43
|
+
`[GeneratedValue]` uses the parameter name. `[GeneratedValue("customerId")]` keeps the
|
|
81
44
|
pin/capture name stable across a parameter rename. Names are case-sensitive,
|
|
82
45
|
non-whitespace and unique within the command.
|
|
83
46
|
|
|
@@ -94,7 +57,8 @@ turn the defect into a user rejection or disable validation to make it pass.
|
|
|
94
57
|
|
|
95
58
|
Validated values enter `CommandContext.GeneratedValues` in parameter-resolution
|
|
96
59
|
order. Each capture has zero-based `Order`, `Name`, declared `Type` and `Value`;
|
|
97
|
-
`Get<
|
|
60
|
+
`Get<CustomerId>("customerId")` retrieves the latest matching capture for the
|
|
61
|
+
shop's CustomerId parameter. Rejected values are
|
|
98
62
|
not captured. A Handle parameter is not a request property and is not audited
|
|
99
63
|
as command input. Do not log or trace captures or validator failure text, which
|
|
100
64
|
can contain values. Returning a value or putting it in an event still follows the
|
|
@@ -114,12 +78,11 @@ handler-construction checks remain for declarations compiled without analyzers.
|
|
|
114
78
|
|
|
115
79
|
## Migrate generation inside Handle
|
|
116
80
|
|
|
117
|
-
For `var id =
|
|
118
|
-
`Handle()`, keep the request contract unchanged:
|
|
81
|
+
For `var id = CustomerId.New();` in `Handle()`, keep the request unchanged:
|
|
119
82
|
|
|
120
|
-
1.
|
|
121
|
-
|
|
122
|
-
2. Replace
|
|
83
|
+
1. Keep CustomerId's `IGeneratable<CustomerId>` strategy (`cus_` + ULID), or
|
|
84
|
+
OrderId's context contract, as shown in [shop generation](shop-generation.md).
|
|
85
|
+
2. Replace local allocation with `[GeneratedValue("customerId")] CustomerId customerId`
|
|
123
86
|
on `Handle()`, then use that parameter in the existing return/operation shape.
|
|
124
87
|
3. Return the id if the caller needs it; a capture is not an automatic response.
|
|
125
88
|
4. Pin the concept by generated name in pipeline specifications. For a pure
|
|
@@ -161,8 +124,10 @@ the prior verification): `Source/DotNET/Arc.Core/Commands/ModelBound/GeneratedVa
|
|
|
161
124
|
`Source/DotNET/Arc.Core.CodeAnalysis/DiagnosticDescriptors.cs`; and
|
|
162
125
|
`Source/DotNET/Testing/Commands/CommandScenarioGeneratedValueExtensions.cs`.
|
|
163
126
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
127
|
+
The older 22.75.0 baseline has no contextual generation beyond Fundamentals
|
|
128
|
+
7.23.0 UUID helpers. Arc **22.87.1** separately supports received-time/tenant
|
|
129
|
+
context and Fundamentals 7.24.0's additional strategies; [sources and Clock/Tenant
|
|
130
|
+
setup](shop-generation.md). Neither tag supplies a native freshness/collision
|
|
131
|
+
allocator or a pattern contract. Screenplay 4.147.0+ separately admits concept `generate`
|
|
167
132
|
strategies and freshness; see `cratis-screenplay-command-surface/references/generated-values-and-responses.md`
|
|
168
133
|
for that language contract and Stage's explicit scopes, not native Arc freshness support.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Shop commands: generation stays out of requests
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
- Choosing a strategy
|
|
9
|
+
- When not to generate
|
|
10
|
+
- Verified released sources
|
|
11
|
+
|
|
12
|
+
## Choosing a strategy
|
|
13
|
+
|
|
14
|
+
Use the [same shop concepts](../../cratis-fundamentals-concept/references/shop-generation.md):
|
|
15
|
+
CustomerId is `cus_` + ULID; OrderId is context-aware TypeID; InviteCode is NanoID;
|
|
16
|
+
ApiKey is secret `Bytes(32)` with `[NotAudited]`. The concept owns the factory,
|
|
17
|
+
not a command property or a per-call random implementation.
|
|
18
|
+
|
|
19
|
+
The following complete command declarations depend on those Shop concepts and
|
|
20
|
+
`Cratis.Arc.Core` / `Cratis.Arc.Chronicle` **22.87.1**, resolving Fundamentals
|
|
21
|
+
**7.24.0**. They allocate response values only, not persisted entities or events;
|
|
22
|
+
they are not production authentication endpoints. Protect any credential-issuing
|
|
23
|
+
endpoint independently before hosting it.
|
|
24
|
+
|
|
25
|
+
```csharp
|
|
26
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
27
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
28
|
+
|
|
29
|
+
using Cratis.Arc.Commands.ModelBound;
|
|
30
|
+
|
|
31
|
+
namespace Shop;
|
|
32
|
+
|
|
33
|
+
[Command]
|
|
34
|
+
public record AllocateCustomerId
|
|
35
|
+
{
|
|
36
|
+
public CustomerId Handle([GeneratedValue("customerId")] CustomerId customerId) => customerId;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[Command]
|
|
40
|
+
public record AllocateOrderId
|
|
41
|
+
{
|
|
42
|
+
public OrderId Handle([GeneratedValue("orderId")] OrderId orderId) => orderId;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[Command]
|
|
46
|
+
public record AllocateInviteCode
|
|
47
|
+
{
|
|
48
|
+
public InviteCode Handle([GeneratedValue("inviteCode")] InviteCode inviteCode) => inviteCode;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[Command]
|
|
52
|
+
public record AllocateApiKey
|
|
53
|
+
{
|
|
54
|
+
public ApiKey Handle([GeneratedValue("apiKey")] ApiKey apiKey) => apiKey;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Arc **22.87.1** supports `IGeneratableInContext<TSelf>`: it maps captured
|
|
59
|
+
`CommandContext.ReceivedAt` to `Now` and `ITenantIdAccessor.Current` to `Tenant`.
|
|
60
|
+
NotSet/Default tenants become the zero-GUID default; named tenants retain their
|
|
61
|
+
identifier. TypeID uses time only; the context carries the tenant but the built-in
|
|
62
|
+
factory does not encode it. Keep tenant authorization/storage scope independent.
|
|
63
|
+
|
|
64
|
+
Arc prefers context if both generation interfaces are implemented. An unpinned
|
|
65
|
+
context factory with default ReceivedAt throws `MissingGenerationTime`, even
|
|
66
|
+
when custom code ignores time; it never reads a replacement UtcNow. Pins bypass
|
|
67
|
+
generation, not concept validation. Validate-only requests do not allocate or
|
|
68
|
+
reserve the generated value for a later command.
|
|
69
|
+
|
|
70
|
+
For a command pipeline specification, these setup calls are released at **22.87.1**:
|
|
71
|
+
|
|
72
|
+
```csharp excerpt
|
|
73
|
+
using var scenario = new CommandScenario<AllocateOrderId>();
|
|
74
|
+
scenario.Clock(DateTimeOffset.Parse("2026-10-05T08:00:00Z"));
|
|
75
|
+
scenario.Tenant(new TenantId("shop-eu"));
|
|
76
|
+
scenario.PinGeneratedValue("orderId", new OrderId("order_0000000000e008000000000000"));
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Imports: `System`, `Shop`, `Cratis.Arc.Testing.Commands`, `Cratis.Arc.Tenancy`.
|
|
80
|
+
Configure before Execute/Validate; Clock also precedes initialization. Clock fixes
|
|
81
|
+
receipt/UTC wall time, not randomness; Tenant changes the scenario's executions,
|
|
82
|
+
not its caller. A pin fixes the whole OrderId and bypasses its factory. To inspect
|
|
83
|
+
an unpinned timestamp contract, opt in with `AllowGeneration()` and assert shape
|
|
84
|
+
and captured-time semantics, never one exact random suffix.
|
|
85
|
+
|
|
86
|
+
## When not to generate
|
|
87
|
+
|
|
88
|
+
- Existing/client-owned IDs stay command inputs; services/read models remain
|
|
89
|
+
ordinary dependencies. Generation is not authorization or tenant isolation.
|
|
90
|
+
- Randomness is not idempotency, storage freshness or a gapless invoice allocator.
|
|
91
|
+
Arc#3129 freshness is not delivered by this parameter API; Stage's v15 explicit
|
|
92
|
+
scopes are a separate realization.
|
|
93
|
+
- ApiKey is a credential, never a Chronicle stream ID. `[NotAudited]` protects
|
|
94
|
+
causation only. Never log captures, return secrets on public endpoints, or
|
|
95
|
+
append plaintext authentication credentials. Retain a hash; for retained
|
|
96
|
+
operational secrets use `[Encrypted]` plus `[NotAudited]`.
|
|
97
|
+
- Screenplay's generated context and secret execution remain unavailable. A
|
|
98
|
+
compiled Arc factory does not imply that it can recover or render as `.play`.
|
|
99
|
+
|
|
100
|
+
## Verified released sources
|
|
101
|
+
|
|
102
|
+
Arc `v22.87.1:Source/DotNET/Arc.Core/Commands/GeneratedValueResolution.cs:35-79`,
|
|
103
|
+
`GeneratedValueFactories.cs:55-124`, `CommandContext.cs:63`;
|
|
104
|
+
`Source/DotNET/Testing/Commands/CommandScenarioGeneratedValueExtensions.cs:52-92`;
|
|
105
|
+
`Source/DotNET/Chronicle/Commands/NotAuditedAttribute.cs`,
|
|
106
|
+
`CommandCausationValues.cs:94-102` (command causation exclusion, not event/log protection);
|
|
107
|
+
`Documentation/backend/csharp/commands/generated-values.md`;
|
|
108
|
+
`Directory.Packages.props` resolves Fundamentals 7.24.0.
|
|
109
|
+
Factory/context signatures are source-checked at Fundamentals v7.24.0 in the
|
|
110
|
+
linked shop concept reference. This does not update the corpus's global pins.
|
|
@@ -15,7 +15,7 @@ This skill is verified against these exact public releases:
|
|
|
15
15
|
|
|
16
16
|
| Package | Version | Purpose |
|
|
17
17
|
| --- | --- | --- |
|
|
18
|
-
| `Cratis.Fundamentals` | `7.
|
|
18
|
+
| `Cratis.Fundamentals` | `7.24.0` | `ConceptAs<T>`, `IGeneratable<TSelf>`, `IGeneratableInContext<TSelf>`, `GenerationContext` and `GenerateValue` |
|
|
19
19
|
| `Cratis.Chronicle` | `18.3.0` | `Cratis.Chronicle.Events.EventSourceId` and `EventSourceId<T>` |
|
|
20
20
|
| `@cratis/fundamentals` | `7.23.0` | TypeScript `ConceptAs<T>`, `field`, `Guid`, and JSON conversion |
|
|
21
21
|
|
|
@@ -114,17 +114,26 @@ bits from `RandomNumberGenerator`:
|
|
|
114
114
|
millisecond, and clock adjustments can reorder values.
|
|
115
115
|
|
|
116
116
|
Neither helper guarantees uniqueness; a collision is extremely unlikely, not
|
|
117
|
-
impossible.
|
|
118
|
-
`
|
|
117
|
+
impossible. Fundamentals **7.24.0** also supplies ULID, TypeID, NanoID and encoded
|
|
118
|
+
bytes. `IGeneratableInContext<TSelf>` declares static `New(GenerationContext)`
|
|
119
|
+
for a captured time and portable tenant. Built-ins consume time, not tenant;
|
|
120
|
+
context is not tenant isolation. Default time is rejected, not replaced with now.
|
|
121
|
+
Sources and the complete shop example: [shop generation](references/shop-generation.md).
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
## Choosing a strategy
|
|
121
124
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
The shared shop uses CustomerId (`cus_` + ULID), context-aware OrderId (TypeID),
|
|
126
|
+
InviteCode (NanoID), and secret ApiKey (`Bytes(32)`, `[NotAudited]` in its host).
|
|
127
|
+
Read [choices, time/tenant context and protection](references/shop-generation.md).
|
|
128
|
+
Resolve Fundamentals 7.24.0 before using these newer helpers; the earlier 7.23.0
|
|
129
|
+
UUID examples remain supported.
|
|
130
|
+
|
|
131
|
+
## When not to generate
|
|
132
|
+
|
|
133
|
+
Client-supplied identities stay inputs; random generation is not idempotency or
|
|
134
|
+
gapless numbering. UUIDs are not credentials. Byte generation can create a secret
|
|
135
|
+
in 7.24.0, but audit suppression, authorized delivery and hash storage are separate
|
|
136
|
+
host responsibilities; never treat randomness as protection.
|
|
128
137
|
|
|
129
138
|
In specifications, construct the concept from a known value
|
|
130
139
|
(`new <ConceptName>(Guid.Parse("…"))`) and assert against it. Do not seed or
|
|
@@ -258,7 +267,8 @@ repository structure.
|
|
|
258
267
|
- Enums remain enums.
|
|
259
268
|
- A concept that creates its own value implements `IGeneratable<TSelf>`; a
|
|
260
269
|
Guid-backed one uses `GenerateValue`, not `Guid.NewGuid()` or `Random`.
|
|
261
|
-
Client-supplied
|
|
270
|
+
Client-supplied/idempotent values are not freshly generated; secrets use the
|
|
271
|
+
explicit entropy, audit and storage contract in [shop generation](references/shop-generation.md).
|
|
262
272
|
- Null absence uses a nullable concept reference rather than a null wrapped
|
|
263
273
|
value.
|
|
264
274
|
- Primitive-to-derived conversions and sentinels exist only when justified by
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Small-shop generation: choose the value's job
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
- Choosing a strategy
|
|
9
|
+
- When not to generate
|
|
10
|
+
- Verified released sources
|
|
11
|
+
|
|
12
|
+
## Choosing a strategy
|
|
13
|
+
|
|
14
|
+
At **Fundamentals 7.24.0**, a shop can use CustomerId (`cus_` + ULID) for
|
|
15
|
+
recognizable time-ordered customer references, OrderId (TypeID) for typed order
|
|
16
|
+
references, InviteCode (NanoID) for opaque invitation references, and ApiKey
|
|
17
|
+
(`Bytes(32)`) for a 256-bit credential. UUID remains the ordinary identity choice;
|
|
18
|
+
encoded bytes make an exact entropy budget explicit. Prefixes add no entropy.
|
|
19
|
+
UUIDv7/ULID/TypeID reveal time and are not monotonic within a millisecond.
|
|
20
|
+
An invitation reference here is not by itself permission to join the shop; if
|
|
21
|
+
possession is the authorization mechanism, treat it as a protected credential too.
|
|
22
|
+
|
|
23
|
+
This complete concept excerpt requires `Cratis.Fundamentals` **7.24.0** and,
|
|
24
|
+
for the ApiKey audit attribute, `Cratis.Arc.Chronicle` **22.87.1**. These are
|
|
25
|
+
non-stream references; use `EventSourceId<string>` instead only if a concept
|
|
26
|
+
actually identifies a Chronicle event source.
|
|
27
|
+
|
|
28
|
+
```csharp
|
|
29
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
30
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
31
|
+
|
|
32
|
+
using Cratis.Arc.Chronicle.Commands;
|
|
33
|
+
using Cratis.Concepts;
|
|
34
|
+
|
|
35
|
+
namespace Shop;
|
|
36
|
+
|
|
37
|
+
public record CustomerId(string Value) : ConceptAs<string>(Value), IGeneratable<CustomerId>
|
|
38
|
+
{
|
|
39
|
+
public static CustomerId New() => new($"cus_{GenerateValue.Ulid()}");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public record OrderId(string Value) : ConceptAs<string>(Value), IGeneratableInContext<OrderId>
|
|
43
|
+
{
|
|
44
|
+
public static OrderId New(GenerationContext context) => new(GenerateValue.TypeId("order", context));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public record InviteCode(string Value) : ConceptAs<string>(Value), IGeneratable<InviteCode>
|
|
48
|
+
{
|
|
49
|
+
public static InviteCode New() => new(GenerateValue.NanoId());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[NotAudited]
|
|
53
|
+
public record ApiKey(string Value) : ConceptAs<string>(Value), IGeneratable<ApiKey>
|
|
54
|
+
{
|
|
55
|
+
public static ApiKey New() => new(GenerateValue.Bytes(32));
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`CustomerId` has 80 random bits; the custom prefix is not a TypeID. `OrderId`
|
|
60
|
+
has 74 random bits and the TypeID `order_` prefix. Default NanoID is 21 symbols
|
|
61
|
+
with 126 bits; bytes use unpadded base64url (43 symbols for 32 bytes).
|
|
62
|
+
|
|
63
|
+
`IGeneratableInContext<TSelf>` requires `static abstract TSelf New(GenerationContext)`.
|
|
64
|
+
`GenerationContext` holds one captured `DateTimeOffset Now` and a portable String
|
|
65
|
+
`Tenant`; `DefaultTenant` is the zero-GUID string, never a display name or empty
|
|
66
|
+
string. The shop passes time and tenant together, for example:
|
|
67
|
+
|
|
68
|
+
```csharp excerpt
|
|
69
|
+
var context = new GenerationContext(
|
|
70
|
+
DateTimeOffset.Parse("2026-10-05T08:00:00Z"), "shop-eu");
|
|
71
|
+
var orderId = OrderId.New(context);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This excerpt assumes `System`, `Cratis.Concepts` and the Shop declarations above.
|
|
75
|
+
TypeID consumes `Now`, **not Tenant**. Passing a tenant does not encode it or
|
|
76
|
+
provide isolation; retain tenant scope independently in the host/storage.
|
|
77
|
+
A domain factory can read Tenant, but arbitrary tenant IDs cannot be inserted
|
|
78
|
+
into a TypeID prefix (only lowercase letters/underscores, letter endpoints).
|
|
79
|
+
Do not present a tenant-prefixed custom string as standard TypeID.
|
|
80
|
+
|
|
81
|
+
Use the context form only for time/tenant-dependent generation. If both interfaces
|
|
82
|
+
are implemented, callers choose context; the interfaces themselves do not dispatch.
|
|
83
|
+
Built-in context overloads reject default Now (`MissingGenerationTime`) and time
|
|
84
|
+
before the Unix epoch. A fixed context fixes the timestamp, not random suffixes.
|
|
85
|
+
|
|
86
|
+
## When not to generate
|
|
87
|
+
|
|
88
|
+
- Client-minted customer/order IDs stay inputs. Do not replace them on retry.
|
|
89
|
+
- Random values supply neither idempotency nor gapless invoice allocation.
|
|
90
|
+
- An ID is not an authentication token or authorization policy.
|
|
91
|
+
- ApiKey is a **secret**, not an event-source ID. `[NotAudited]` withholds command
|
|
92
|
+
causation values; it does not protect logs, responses or storage. Deliver a
|
|
93
|
+
credential only over an authorized secure channel and retain its hash, not
|
|
94
|
+
plaintext. For a retained operational integration secret instead, use
|
|
95
|
+
`[Encrypted]` plus `[NotAudited]` as described by `cratis-arc-command`.
|
|
96
|
+
- Never log generated values/captures or seed production randomness. Use known
|
|
97
|
+
values in specs; test shape/time separately when randomness is the behavior.
|
|
98
|
+
|
|
99
|
+
## Verified released sources
|
|
100
|
+
|
|
101
|
+
Fundamentals `v7.24.0:Source/DotNET/Fundamentals/Concepts/GenerationContext.cs:6-17`,
|
|
102
|
+
`IGeneratableInContext.cs:13-21`, `GenerateValue.TimeOrderedStrings.cs:15-57`,
|
|
103
|
+
`GenerateValue.RandomStrings.cs:10-64`; `Documentation/csharp/generating-values.md`.
|
|
104
|
+
Arc `v22.87.1:Source/DotNET/Chronicle/Commands/NotAuditedAttribute.cs`,
|
|
105
|
+
`CommandCausationValues.cs:94-102` (command/type/property exclusion only, never
|
|
106
|
+
payload encryption or log protection);
|
|
107
|
+
`Documentation/backend/csharp/commands/generated-values.md`.
|
|
108
|
+
The latter attribute belongs to the host integration, not Fundamentals.
|
|
@@ -29,7 +29,7 @@ Pins: toolchain `references/versions.md`; sources below. Compilation is not exec
|
|
|
29
29
|
- `4.68.0` (`79801bf`): generated-value/response rule probes (ESM v7).
|
|
30
30
|
- `4.127.0`: identity and compliance syntax (`identity.md`, `context.md`, `concepts.md`, `purposes.md`, `events.md`, `diagnostics.md`).
|
|
31
31
|
- `4.141.0`: v13 compliance admission; rechecked at `4.142.0`: `references/compliance.md`.
|
|
32
|
-
- `4.148.0`: v15 generation strategies/strict fixtures/freshness; Stage `4.89.1` realization: `references/generated-values-and-responses.md`.
|
|
32
|
+
- `4.148.0`: v15 generation strategies/strict fixtures/freshness; Stage `4.89.1` realization: `references/generated-values-and-responses.md`; shop: `references/shop-generation.md`.
|
|
33
33
|
|
|
34
34
|
"Parses" and "runs" are different claims. The executable profile, and what
|
|
35
35
|
each construct binds to, is in the `cratis-screenplay-model-authoring` language
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Contents
|
|
4
4
|
|
|
5
|
+
- Choosing a strategy
|
|
6
|
+
- When not to
|
|
5
7
|
- The concept declares how; the property declares that
|
|
6
8
|
- Inspect and edit generation through MCP
|
|
7
9
|
- Version and freshness
|
|
@@ -10,7 +12,7 @@
|
|
|
10
12
|
|
|
11
13
|
`generated` properties and `returns` bind/reference-execute since 4.68.0 (ESM v7).
|
|
12
14
|
Concept generation strategies and whole-source freshness shipped in Screenplay
|
|
13
|
-
4.147.0 (ESM v15); standalone pin **4.
|
|
15
|
+
4.147.0 (ESM v15); standalone pin **4.153.0** includes them. CLI **3.57.0** bundles
|
|
14
16
|
Screenplay **4.147.1** / Stage **4.89.1**, rendering the supported strategies,
|
|
15
17
|
scalar/named responses, fixtures and `then returns`. Binding is not rendering.
|
|
16
18
|
Historical CLI 3.41.0 STAGE-ESM-028/029 probes do not describe this bundle.
|
|
@@ -22,24 +24,25 @@ Cratis/cli `v3.57.0:Directory.Packages.props:8-10`; Cratis/Stage
|
|
|
22
24
|
`v4.89.1:Documentation/reference/generated-values-rendering.md:6-146`.
|
|
23
25
|
Decision 0054 describes later phases too; only its shipped phase 2b-1 is taught here.
|
|
24
26
|
|
|
27
|
+
## Choosing a strategy
|
|
28
|
+
|
|
29
|
+
Use the [threaded shop model](shop-generation.md): CustomerId is `cus_` + ULID,
|
|
30
|
+
OrderId is TypeID, InviteCode is NanoID. It links the same .NET concepts but does
|
|
31
|
+
not claim their received-time/tenant context or secret ApiKey Bytes(32) factory
|
|
32
|
+
is executable in Screenplay. The table below owns exact strategy shapes.
|
|
33
|
+
|
|
34
|
+
## When not to
|
|
35
|
+
|
|
36
|
+
Client-minted values remain inputs. Generation is not authorization, idempotency,
|
|
37
|
+
gapless invoice allocation or a credential contract. Preserve ApiKey's `secret`
|
|
38
|
+
classification without generated properties; context/secret execution remains
|
|
39
|
+
Screenplay#616 phases 3/4, not a reason to strip protection.
|
|
40
|
+
|
|
25
41
|
## The concept declares how; the property declares that
|
|
26
42
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
concept ReceiptCode : String
|
|
31
|
-
generate nanoid
|
|
32
|
-
command RegisterProject
|
|
33
|
-
projectId ProjectId generated identifier
|
|
34
|
-
receipt ReceiptCode generated
|
|
35
|
-
name String
|
|
36
|
-
produces event ProjectRegistered
|
|
37
|
-
name String = name
|
|
38
|
-
receipt ReceiptCode = receipt
|
|
39
|
-
returns
|
|
40
|
-
projectId = projectId
|
|
41
|
-
receipt ReceiptCode = receipt
|
|
42
|
-
```
|
|
43
|
+
The complete reference-executable [shop example](shop-generation.md) declares
|
|
44
|
+
strategies on concepts and `generated`/`generated identifier` on properties.
|
|
45
|
+
It includes whole-value fixture pins and returned IDs.
|
|
43
46
|
|
|
44
47
|
A generated property must be a required scalar **concept**, not a bare primitive,
|
|
45
48
|
optional value or collection. Only Uuid and String generation are executable.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# The shop in Screenplay: keep the release boundary
|
|
5
|
+
|
|
6
|
+
## Choosing a strategy
|
|
7
|
+
|
|
8
|
+
Use the same vocabulary as the [Fundamentals/Arc shop](../../cratis-fundamentals-concept/references/shop-generation.md),
|
|
9
|
+
but only the released language realization: CustomerId is `cus_` + uppercase
|
|
10
|
+
ULID, OrderId is `typeid "order"`, and InviteCode is NanoID. Their strategies
|
|
11
|
+
belong to concepts; command properties only say `generated`/`generated identifier`.
|
|
12
|
+
The existing [strategy reference](generated-values-and-responses.md) owns exact
|
|
13
|
+
encodings, entropy, MCP edits, fixtures and freshness.
|
|
14
|
+
|
|
15
|
+
**Context-dependent generation is not released in Screenplay.** The OrderId below
|
|
16
|
+
is time-ordered TypeID, not Arc's received-time/tenant factory contract; Stage
|
|
17
|
+
4.89.1 emits a wall-clock `New()`. Passed-through GenerationContext in Arc source
|
|
18
|
+
recovery describes that strategy shape, not equivalent clock/tenant semantics.
|
|
19
|
+
Context-member/rule recovery stays in code (Screenplay#616 phase 3).
|
|
20
|
+
|
|
21
|
+
The shop's ApiKey remains a **secret**. In .NET its factory is `Bytes(32)` and its
|
|
22
|
+
concept is `[NotAudited]`; executable secret generation is **not released in
|
|
23
|
+
Screenplay** (phase 4). The declaration below preserves classification without
|
|
24
|
+
adding `generate bytes 32` or a generated command property. No API-key issuance
|
|
25
|
+
behavior is claimed; retain it as an explicit gap/owning implementation contract.
|
|
26
|
+
|
|
27
|
+
This complete reference-executable model uses the pinned Screenplay **4.151.0**:
|
|
28
|
+
|
|
29
|
+
```screenplay
|
|
30
|
+
concept CustomerId : String
|
|
31
|
+
generate ulid prefix "cus_"
|
|
32
|
+
concept OrderId : String
|
|
33
|
+
generate typeid "order"
|
|
34
|
+
concept InviteCode : String
|
|
35
|
+
generate nanoid
|
|
36
|
+
concept ApiKey : String secret
|
|
37
|
+
module Shop
|
|
38
|
+
feature Customers
|
|
39
|
+
slice StateChange Register
|
|
40
|
+
command RegisterCustomer
|
|
41
|
+
customerId CustomerId generated identifier
|
|
42
|
+
inviteCode InviteCode generated
|
|
43
|
+
produces event CustomerRegistered
|
|
44
|
+
inviteCode InviteCode = inviteCode
|
|
45
|
+
returns
|
|
46
|
+
customerId = customerId
|
|
47
|
+
inviteCode = inviteCode
|
|
48
|
+
specification RegistersWithPinnedValues
|
|
49
|
+
when RegisterCustomer
|
|
50
|
+
for "cus_01ARZ3NDEKTSV4RRFFQ69G5FAV"
|
|
51
|
+
generated inviteCode = "abcdefghijklmnopqrstu"
|
|
52
|
+
then CustomerRegistered
|
|
53
|
+
for "cus_01ARZ3NDEKTSV4RRFFQ69G5FAV"
|
|
54
|
+
inviteCode = "abcdefghijklmnopqrstu"
|
|
55
|
+
then returns
|
|
56
|
+
customerId = "cus_01ARZ3NDEKTSV4RRFFQ69G5FAV"
|
|
57
|
+
inviteCode = "abcdefghijklmnopqrstu"
|
|
58
|
+
feature Orders
|
|
59
|
+
slice StateChange Place
|
|
60
|
+
command PlaceOrder
|
|
61
|
+
orderId OrderId generated identifier
|
|
62
|
+
produces event OrderPlaced
|
|
63
|
+
returns orderId
|
|
64
|
+
specification PlacesWithPinnedValue
|
|
65
|
+
when PlaceOrder
|
|
66
|
+
for "order_0000000000e008000000000000"
|
|
67
|
+
then OrderPlaced
|
|
68
|
+
for "order_0000000000e008000000000000"
|
|
69
|
+
then returns "order_0000000000e008000000000000"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Each property is server-owned, not a client-minted input. The ApiKey declaration
|
|
73
|
+
is not permission to replace its secret contract with an ordinary random String.
|
|
74
|
+
No `given clock` is used: pin the whole value. A seed/clock does not draw a
|
|
75
|
+
portable ULID or TypeID fixture. A v15 duplicate-source specification should
|
|
76
|
+
expect Concurrency with no new facts or response, not a regenerated ID.
|
|
77
|
+
|
|
78
|
+
## When not to generate
|
|
79
|
+
|
|
80
|
+
Client-minted customer/order IDs remain inputs. Fresh random values are not
|
|
81
|
+
idempotency keys, authorization, gapless invoice numbers or proof of projection
|
|
82
|
+
readiness. A reference InviteCode is not automatically a credential; if possession
|
|
83
|
+
confers access, protect it as a secret and do not claim this generated String
|
|
84
|
+
example realizes that credential behavior. Never drop ApiKey's secret marker to
|
|
85
|
+
make its generation bind/render. Pattern/random/rule execution, context rules,
|
|
86
|
+
sequence allocation and secret generation stay explicit upstream gaps.
|
|
87
|
+
|
|
88
|
+
## Tagged evidence
|
|
89
|
+
|
|
90
|
+
Screenplay `v4.151.0:Documentation/screenplay/generated-values/choosing.md:8-51`,
|
|
91
|
+
`Documentation/screenplay/generated-values.md:60-72`,
|
|
92
|
+
`Documentation/screenplay/concepts.md:60-86` (header secret classification),
|
|
93
|
+
`Source/DotNET/Screenplay/Semantics/SemanticModelBinder.Generation.cs:14-80`.
|
|
94
|
+
Stage `v4.89.1:Documentation/reference/generated-values-rendering.md:62-83,138-146`.
|
|
95
|
+
Arc `v22.87.1:Documentation/backend/csharp/generating-a-screenplay.md:260-284`.
|
|
96
|
+
Sources for the released .NET context/secret helpers are in the linked shop reference.
|