@cratis/pi 7.153.5 → 7.153.6
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-screenplay-automations-and-translations/SKILL.md +3 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/statemachines-and-workflows.md +9 -9
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/systems-and-abilities.md +90 -0
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.json +26079 -16706
- package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.version +1 -1
- package/package.json +1 -1
|
@@ -32,6 +32,9 @@ pending-work contracts when changing each reaction/capture, not at final review.
|
|
|
32
32
|
a refused construct. Run `screenplay test` or MCP `run-specifications` for V4.
|
|
33
33
|
- Read [realization and gap-fill](references/realization-and-gap-fill.md) before
|
|
34
34
|
promising Automation/Translate delivery (STAGE-ESM-024).
|
|
35
|
+
- Read [systems and abilities](references/systems-and-abilities.md) before
|
|
36
|
+
declaring an external `system` or `ability`, choosing its effect class, or
|
|
37
|
+
writing `invokes`/`starts` (never the deprecated `sends`, `send`, `start`).
|
|
35
38
|
- Invokes have no caller without `runs as`. Read captures-and-reactions
|
|
36
39
|
[invocation identity](../cratis-screenplay-captures-and-reactions/references/invocation-identity.md)
|
|
37
40
|
for the ESM v10 actor and role/authenticated versus claim/opaque admission.
|
|
@@ -89,7 +89,7 @@ statemachine InvoiceLifecycle
|
|
|
89
89
|
on InvoiceMarkedOverdue -> Overdue
|
|
90
90
|
on InvoicePaid -> Paid
|
|
91
91
|
state Overdue
|
|
92
|
-
entering
|
|
92
|
+
entering starts CollectOverdue
|
|
93
93
|
on InvoicePaid -> Paid
|
|
94
94
|
on InvoiceWrittenOff -> WrittenOff
|
|
95
95
|
state Paid final
|
|
@@ -108,13 +108,13 @@ workflow CollectOverdue
|
|
|
108
108
|
for Invoice
|
|
109
109
|
trigger when InvoiceLifecycle enters Overdue
|
|
110
110
|
-> Remind
|
|
111
|
-
action Remind
|
|
111
|
+
action Remind invokes SendReminder
|
|
112
112
|
next -> AwaitPayment
|
|
113
113
|
wait AwaitPayment for InvoicePaid expires after 14 days
|
|
114
114
|
expired -> ApproveWriteOff
|
|
115
115
|
approval ApproveWriteOff by FinanceController expires after 7 days
|
|
116
116
|
approved -> WriteOff
|
|
117
|
-
action WriteOff
|
|
117
|
+
action WriteOff invokes WriteOffInvoice
|
|
118
118
|
|
|
119
119
|
specification AnUnpaidInvoiceIsWrittenOff
|
|
120
120
|
given InvoiceSent
|
|
@@ -123,8 +123,8 @@ workflow CollectOverdue
|
|
|
123
123
|
for "9c858901-8a57-4791-81fe-4c455b099bc9"
|
|
124
124
|
outcome AwaitPayment expired
|
|
125
125
|
outcome ApproveWriteOff approved
|
|
126
|
-
then
|
|
127
|
-
then
|
|
126
|
+
then invokes SendReminder
|
|
127
|
+
then invokes WriteOffInvoice
|
|
128
128
|
then completes
|
|
129
129
|
|
|
130
130
|
specification TheRunWaitsForPayment
|
|
@@ -132,7 +132,7 @@ workflow CollectOverdue
|
|
|
132
132
|
for "9c858901-8a57-4791-81fe-4c455b099bc9"
|
|
133
133
|
when append InvoiceMarkedOverdue
|
|
134
134
|
for "9c858901-8a57-4791-81fe-4c455b099bc9"
|
|
135
|
-
then
|
|
135
|
+
then invokes SendReminder
|
|
136
136
|
then waits at AwaitPayment
|
|
137
137
|
```
|
|
138
138
|
|
|
@@ -143,7 +143,7 @@ workflow CollectOverdue
|
|
|
143
143
|
transition on it, in declaration order across the whole machine, whose condition holds and
|
|
144
144
|
whose target the current state allows. Anything else is ignored, not an error.
|
|
145
145
|
- Workflow nodes: `trigger` (`on <Event>`, `when <StateMachine> enters <State>`, `every`,
|
|
146
|
-
`at`, `manual`), `action <Name>
|
|
146
|
+
`at`, `manual`), `action <Name> invokes <Command> [attempts n] [timeout] [retry after]`,
|
|
147
147
|
`decide <Name> when <condition>` with exactly two outlets, `wait` for an event or a
|
|
148
148
|
duration, `approval <Name> by <Persona or Policy>`, `foreach <Name> over <collection>` and
|
|
149
149
|
`join all|any|at least n`. Edges are `<outlet> -> <Node>` under their node; a workflow
|
|
@@ -156,8 +156,8 @@ workflow CollectOverdue
|
|
|
156
156
|
|
|
157
157
|
| Construct | Lines |
|
|
158
158
|
| --- | --- |
|
|
159
|
-
| `statemachine` | `given <Event>`, `when append <Event>`, `then is <State>`, `then
|
|
160
|
-
| `workflow` | `given <Event>`, `when append <Event>` or `when start <key>`, `outcome <Node> <outlet>`, `then
|
|
159
|
+
| `statemachine` | `given <Event>`, `when append <Event>`, `then is <State>`, `then invokes <Command>`, `then starts <Workflow>` (every command and workflow, in order) |
|
|
160
|
+
| `workflow` | `given <Event>`, `when append <Event>` or `when start <key>`, `outcome <Node> <outlet>`, `then invokes <Command>` (every one, in order), `then completes`, `then fails at <Node>`, `then waits at <Node>` |
|
|
161
161
|
|
|
162
162
|
The reference evaluator steps the run deterministically. A wait or approval with no stated
|
|
163
163
|
`outcome` suspends the run (`then waits at`); an action defaults to `next`; a wait for a
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Systems and abilities
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Code computes, abilities touch the world
|
|
6
|
+
- Declare a system
|
|
7
|
+
- Effect classes
|
|
8
|
+
- Inputs, returns and outcomes
|
|
9
|
+
- Answers that arrive later
|
|
10
|
+
- Implementation
|
|
11
|
+
- The one `invokes` verb
|
|
12
|
+
- What is merged and what is not
|
|
13
|
+
|
|
14
|
+
## Code computes, abilities touch the world
|
|
15
|
+
|
|
16
|
+
A model reaches something outside itself (a carrier, a ledger, a chat tool) through a `system` with `ability` declarations, not through an invented command or a free-text effect. Pure computation stays in code; anything with an external effect is an ability whose retry behavior, returned values and refusals are declared and therefore checkable. Record what an ability returned as a fact only through an event the model `produces`; an ability's result is never a fact by itself.
|
|
17
|
+
|
|
18
|
+
## Declare a system
|
|
19
|
+
|
|
20
|
+
```screenplay
|
|
21
|
+
concept ParcelId : Uuid
|
|
22
|
+
concept TrackingNumber : String
|
|
23
|
+
|
|
24
|
+
type Address
|
|
25
|
+
street String
|
|
26
|
+
postalCode String
|
|
27
|
+
|
|
28
|
+
system Carrier
|
|
29
|
+
description "The parcel carrier's booking service"
|
|
30
|
+
ability BookPickup idempotent
|
|
31
|
+
description "Books a pickup for one parcel"
|
|
32
|
+
parcelId ParcelId
|
|
33
|
+
address Address
|
|
34
|
+
returns
|
|
35
|
+
trackingNumber TrackingNumber
|
|
36
|
+
pickupAt DateTime
|
|
37
|
+
outcome NoCapacity
|
|
38
|
+
description "No pickup slot on the requested day"
|
|
39
|
+
ability Quote safe
|
|
40
|
+
address Address
|
|
41
|
+
returns
|
|
42
|
+
price Decimal
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- A `system` belongs to the application, also when its file is imported into a module or feature. It names the business system, not a provider interface; an extension or implementation owns how.
|
|
46
|
+
- Everything under `ability` is optional and in any order: `description`, typed inputs, `returns`, `outcome`, `answers later`, `implementation`. Ability names are unique within a system, ignoring case (`PLAY0983`).
|
|
47
|
+
- Declaring an ability selects ESM v50; models without one keep their bytes and version.
|
|
48
|
+
|
|
49
|
+
## Effect classes
|
|
50
|
+
|
|
51
|
+
Write the class after the ability name. It says what a retry may do when an attempt's outcome is unknown.
|
|
52
|
+
|
|
53
|
+
| Class | Meaning | Unknown outcome |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `safe` | No external effect, such as a lookup | Retry freely |
|
|
56
|
+
| `idempotent` | Same idempotency key has the effect once | Retry with the same key |
|
|
57
|
+
| `once` | A repeat may repeat the effect | Never retry; stop for reconciliation |
|
|
58
|
+
|
|
59
|
+
`once` is the default because it is never wrong. Do not mark an ability `idempotent` unless the system really deduplicates. Any other class is `PLAY0984`.
|
|
60
|
+
|
|
61
|
+
## Inputs, returns and outcomes
|
|
62
|
+
|
|
63
|
+
- Inputs use the operation-input grammar: concepts, enums, composite types, collections, `optional`. Not `identifier` or `generated`, no subject modifier. A keyword-named input is written with `@` (`@outcome String`).
|
|
64
|
+
- `returns` holds at least one typed field; an ability without it returns nothing. Every type must be declared (`PLAY0986`).
|
|
65
|
+
- An `outcome <Name>` is a business result other than success, the external counterpart of a command refusal. It has a name and description, no payload. It cannot be named `next`, `refused`, `failed`, `returned` or `expired` (`PLAY0985`); those are invocation outlets.
|
|
66
|
+
|
|
67
|
+
## Answers that arrive later
|
|
68
|
+
|
|
69
|
+
`answers later` marks an ability whose answer arrives after the invocation returns (a person approves in chat, a partner confirms by webhook). Workflows and `approval ... via` use these.
|
|
70
|
+
|
|
71
|
+
## Implementation
|
|
72
|
+
|
|
73
|
+
An ability owns at most one `file` or tagged fence, directly or in an `implementation` wrapper (`PLAY0494` when combined). Its result is exactly one of: values matching `returns`, a declared outcome, or a failure. A hints-only block is intent and leaves the ability unrealized.
|
|
74
|
+
|
|
75
|
+
## The one `invokes` verb
|
|
76
|
+
|
|
77
|
+
`invokes` is the single verb for asking a command to run. The old forms still compile with deprecation `PLAY0397` and a repair; never author them.
|
|
78
|
+
|
|
79
|
+
| Before | After |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `entering send <Command>` | `entering invokes <Command>` |
|
|
82
|
+
| `entering start <Workflow>` | `entering starts <Workflow>` |
|
|
83
|
+
| `then sends <Command>` | `then invokes <Command>` |
|
|
84
|
+
| `action <Name> sends <Command>` | `action <Name> invokes <Command>` |
|
|
85
|
+
|
|
86
|
+
## What is merged and what is not
|
|
87
|
+
|
|
88
|
+
Merged in Screenplay (decision 0159, published in 6.19.0 and 6.20.0): the abilities declaration and the `invokes` verb for workflows, state machines and specifications. Not yet taught here because the Screenplay docs had not landed when this was written: invoking an ability from reactions, workflows and state machines, `compute` nodes and `entering` bodies, and the `given`/`then invokes` specification lines for abilities; extension contracts, settings, secrets and activation; extension components on screens; and authoring extension packages with `cratis extension new` and `verify`. Until they land, an ability is a checked, typed contract that nothing runs; do not author invocation syntax from memory.
|
|
89
|
+
|
|
90
|
+
Read Screenplay's [systems and abilities](https://github.com/Cratis/Screenplay/blob/main/Documentation/screenplay/systems.md) page and [decision 0159](https://github.com/Cratis/Screenplay/blob/main/decisions/0159-systems-with-abilities-extensions-and-durable-invocations.md) for the contract.
|
|
@@ -194,7 +194,7 @@ Read [references/actions-beyond-commands.md](references/actions-beyond-commands.
|
|
|
194
194
|
From ESM v6 every action sets reactions off. A specification runs only the slice that declares it: only that slice's reactions, captures and publications run, and `then` events compare the new facts of that slice. A specification whose action is a command goes in the slice that declares the command and states the command's own events. Another slice's event is `PLAY0285` (unreachable): state it in the slice that produces it. An automation states a command it invokes in another slice with `then invokes <Command>` (ESM v34).
|
|
195
195
|
Read [references/reactions-and-cascades.md](references/reactions-and-cascades.md) when a specification's expected events include what a reaction appends, when a cascade, clock tick or invoked command is involved, or when a compiler reports `PLAY0285` (it holds the "Version skew and `PLAY0285`" section).
|
|
196
196
|
|
|
197
|
-
A `statemachine` or `workflow` (ESM v36) carries its own specifications with `then is`, `then
|
|
197
|
+
A `statemachine` or `workflow` (ESM v36) carries its own specifications with `then is`, `then invokes`, `then starts`, `outcome`, `then completes`, `then fails at` and `then waits at`. Read automations-and-translations [state machines and workflows](../cratis-screenplay-automations-and-translations/references/statemachines-and-workflows.md) when specifying either.
|
|
198
198
|
|
|
199
199
|
## Published-event specifications (released ESM v9)
|
|
200
200
|
|