@cratis/pi 7.7.1 → 7.9.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/agents/screenplay-modeler.md +10 -2
- package/package/corpus/agents/screenplay-renderer.md +13 -0
- package/package/corpus/agents/screenplay-reviewer.md +10 -0
- package/package/corpus/agents/slice-implementer.md +16 -2
- package/package/corpus/skills/cratis-application-slice-conformance/LICENSE +7 -0
- package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +9 -3
- package/package/corpus/skills/cratis-application-slice-conformance/references/build-prompts.md +151 -0
- package/package/corpus/skills/cratis-application-slice-conformance/references/checklists.md +37 -2
- package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +4 -1
- package/package/corpus/skills/cratis-application-slice-conformance/references/provenance.md +15 -14
- package/package/corpus/skills/cratis-application-slice-conformance/verification.json +36 -7
- package/package/corpus/skills/cratis-application-slice-specifications/LICENSE +7 -0
- package/package/corpus/skills/cratis-application-slice-specifications/references/provenance.md +11 -13
- package/package/corpus/skills/cratis-arc-react-page/LICENSE +7 -0
- package/package/corpus/skills/cratis-arc-react-page/references/provenance.md +13 -6
- package/package/corpus/skills/cratis-chronicle-reactor/LICENSE +7 -0
- package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-reactor/references/provenance.md +7 -3
- package/package/corpus/skills/cratis-chronicle-read-model-specifications/LICENSE +7 -0
- package/package/corpus/skills/cratis-chronicle-read-model-specifications/references/provenance.md +13 -9
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +4 -1
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/audit-format.md +17 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/automation-patterns.md +14 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/integration-contracts.md +30 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/provenance.md +17 -10
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/translation-patterns.md +2 -2
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/verification.json +3 -1
- package/package/corpus/skills/cratis-screenplay-discovery/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +10 -7
- package/package/corpus/skills/cratis-screenplay-discovery/references/plotting-and-handoff.md +37 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/provenance.md +18 -9
- package/package/corpus/skills/cratis-screenplay-discovery/references/storming-loop.md +1 -1
- package/package/corpus/skills/cratis-screenplay-discovery/verification.json +5 -1
- package/package/corpus/skills/cratis-screenplay-event-modeling/LICENSE +7 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +18 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/provenance.md +19 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/verification.json +8 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +19 -20
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/candidate-inventory.md +101 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/provenance.md +17 -1
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/ui-observation.md +65 -23
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/verification.json +56 -10
- package/package/corpus/skills/cratis-screenplay-model-review/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +22 -10
- package/package/corpus/skills/cratis-screenplay-model-review/references/business-questions.md +54 -3
- package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +17 -3
- package/package/corpus/skills/cratis-screenplay-model-review/references/provenance.md +12 -7
- package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +10 -1
- package/package/corpus/skills/cratis-screenplay-model-review/references/review-questions.md +11 -1
- package/package/corpus/skills/cratis-screenplay-model-review/verification.json +4 -1
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +21 -21
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/completeness-self-check.md +37 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/per-turn-protocol.md +50 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +12 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/provenance.md +22 -16
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/reasoning-notes.md +15 -1
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/stop-or-assume.md +16 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/verification.json +5 -1
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/LICENSE +7 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +7 -4
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/drift-and-ledger.md +1 -1
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/gap-fill-handoff.md +19 -4
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/provenance.md +11 -13
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/verification.json +32 -7
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/LICENSE +7 -2
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +14 -1
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/invoicing-dues-design.md +259 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/invoicing-dues-example.md +414 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/provenance.md +19 -10
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +6 -2
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-examples.md +200 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/view-and-story-specs.md +54 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/verification.json +4 -1
- package/package/corpus/skills/cratis-screenplay-slice-design/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/SKILL.md +45 -43
- package/package/corpus/skills/cratis-screenplay-slice-design/references/command-inventory.md +13 -1
- package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +4 -2
- package/package/corpus/skills/cratis-screenplay-slice-design/references/provenance.md +28 -7
- package/package/corpus/skills/cratis-screenplay-slice-design/references/read-model-design.md +69 -3
- package/package/corpus/skills/cratis-screenplay-slice-design/references/slicing.md +31 -3
- package/package/corpus/skills/cratis-screenplay-slice-design/verification.json +24 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +6 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/boundaries.md +20 -1
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/provenance.md +15 -1
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-patterns.md +69 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/verification.json +3 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/LICENSE +7 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +3 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/provenance.md +12 -3
- package/package/corpus/skills/cratis-screenplay-ui-composition/LICENSE +7 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/provenance.md +14 -7
- package/package.json +1 -1
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
# Invoicing and dues: worked example for the scenario-examples excerpts
|
|
2
|
+
|
|
3
|
+
Complete executable model (harbor club dues) holding every declaration the excerpts in
|
|
4
|
+
`scenario-examples.md` and `view-and-story-specs.md` rely on, except the stored-state rules. Each
|
|
5
|
+
of those excerpts is copied verbatim from the fence below (names are the specification names),
|
|
6
|
+
except `ReversingAReceivedPayment` and `RequestingARefundAfterAReversal`, which come from
|
|
7
|
+
`invoicing-dues-design.md` (`RefundRequester` stays with `ReversePayment` there to keep that example's source declaration and
|
|
8
|
+
destination-type information; a reaction can also consume events from a capture or another reaction).
|
|
9
|
+
|
|
10
|
+
**Scope.** This document is the runnable demonstration only. It deliberately holds no rule that
|
|
11
|
+
depends on stored state (the invoice must exist, only an open invoice may be voided, a reversal
|
|
12
|
+
needs a received payment, `reads` + `require`): those rules cannot bind or run at Screenplay
|
|
13
|
+
4.64.0 (PLAY0271, PLAY0268) and are stated in the design-mode document `invoicing-dues-design.md`,
|
|
14
|
+
never in prose here. It shows the category shapes; for a coverage example see `berth-reservations.md`.
|
|
15
|
+
|
|
16
|
+
```screenplay
|
|
17
|
+
// Needs the standalone screenplay compiler (ESM v6)
|
|
18
|
+
// Scenario coverage worked example: invoicing club dues (complete document).
|
|
19
|
+
// Backs the excerpts in scenario-examples.md and view-and-story-specs.md: issue an invoice,
|
|
20
|
+
// request payment, an external gateway result captured and translated, an open-invoices todo list family and an accumulating credit balance.
|
|
21
|
+
// Scope: executable demonstration only. No stored-state rule is declared or pretended here; those
|
|
22
|
+
// (invoice exists, void only if open, reversal needs a received payment) live in the design-mode
|
|
23
|
+
// document invoicing-dues-design.md.
|
|
24
|
+
// The external payment outcome is a fact (PaymentGatewayResultReceived); a refund request is a
|
|
25
|
+
// fact of intent, never proof that money moved.
|
|
26
|
+
|
|
27
|
+
concept InvoiceId : Uuid
|
|
28
|
+
concept MemberId : Uuid
|
|
29
|
+
concept GatewayOutcome : Enum
|
|
30
|
+
captured
|
|
31
|
+
declined
|
|
32
|
+
|
|
33
|
+
policy IsAccounts
|
|
34
|
+
require role "Accounts"
|
|
35
|
+
|
|
36
|
+
module Invoicing
|
|
37
|
+
feature Dues
|
|
38
|
+
authorize IsAccounts
|
|
39
|
+
|
|
40
|
+
slice StateChange IssueInvoice
|
|
41
|
+
description "Issues one invoice per invoice id. IssueOnce refuses a retried issue with the same id. Why an amount above zero: a zero invoice cannot be collected or voided meaningfully."
|
|
42
|
+
command IssueInvoice
|
|
43
|
+
invoiceId InvoiceId identifier
|
|
44
|
+
member MemberId
|
|
45
|
+
amount Decimal
|
|
46
|
+
validate
|
|
47
|
+
amount > 0 message "An invoice needs an amount above zero"
|
|
48
|
+
produces InvoiceIssued
|
|
49
|
+
for invoiceId
|
|
50
|
+
member = member
|
|
51
|
+
amount = amount
|
|
52
|
+
event InvoiceIssued
|
|
53
|
+
member MemberId
|
|
54
|
+
amount Decimal
|
|
55
|
+
constraint IssueOnce
|
|
56
|
+
unique event InvoiceIssued
|
|
57
|
+
|
|
58
|
+
specification IssuingAnInvoice
|
|
59
|
+
given caller
|
|
60
|
+
authenticated
|
|
61
|
+
role "Accounts"
|
|
62
|
+
when IssueInvoice
|
|
63
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
64
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
65
|
+
amount = 130
|
|
66
|
+
then InvoiceIssued
|
|
67
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
68
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
69
|
+
amount = 130
|
|
70
|
+
|
|
71
|
+
specification RejectingAnInvoiceWithoutAnAmount
|
|
72
|
+
given caller
|
|
73
|
+
authenticated
|
|
74
|
+
role "Accounts"
|
|
75
|
+
when IssueInvoice
|
|
76
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
77
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
78
|
+
amount = 0
|
|
79
|
+
then error "An invoice needs an amount above zero"
|
|
80
|
+
|
|
81
|
+
specification RefusingACallerWithoutTheAccountsRole
|
|
82
|
+
given caller
|
|
83
|
+
authenticated
|
|
84
|
+
when IssueInvoice
|
|
85
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
86
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
87
|
+
amount = 130
|
|
88
|
+
then denied
|
|
89
|
+
|
|
90
|
+
slice StateChange SettleOrVoidInvoice
|
|
91
|
+
description "An invoice ends either settled or voided, never both: SettleOrVoid declares the exclusivity per invoice, enforced at append. Rules about the invoice's stored state are in invoicing-dues-design.md."
|
|
92
|
+
command SettleInvoice
|
|
93
|
+
invoiceId InvoiceId identifier
|
|
94
|
+
produces InvoiceSettled
|
|
95
|
+
for invoiceId
|
|
96
|
+
command VoidInvoice
|
|
97
|
+
invoiceId InvoiceId identifier
|
|
98
|
+
reason String
|
|
99
|
+
produces InvoiceVoided
|
|
100
|
+
for invoiceId
|
|
101
|
+
reason = reason
|
|
102
|
+
event InvoiceSettled
|
|
103
|
+
event InvoiceVoided
|
|
104
|
+
reason String
|
|
105
|
+
constraint SettleOrVoid
|
|
106
|
+
unique event InvoiceSettled
|
|
107
|
+
unique event InvoiceVoided
|
|
108
|
+
|
|
109
|
+
specification SettlingAnInvoice
|
|
110
|
+
given caller
|
|
111
|
+
authenticated
|
|
112
|
+
role "Accounts"
|
|
113
|
+
when SettleInvoice
|
|
114
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
115
|
+
then InvoiceSettled
|
|
116
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
117
|
+
|
|
118
|
+
specification VoidingAnInvoice
|
|
119
|
+
given caller
|
|
120
|
+
authenticated
|
|
121
|
+
role "Accounts"
|
|
122
|
+
when VoidInvoice
|
|
123
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
124
|
+
reason = "Issued in error"
|
|
125
|
+
then InvoiceVoided
|
|
126
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
127
|
+
reason = "Issued in error"
|
|
128
|
+
|
|
129
|
+
specification RefusingSettlementWithoutTheAccountsRole
|
|
130
|
+
given caller
|
|
131
|
+
authenticated
|
|
132
|
+
when SettleInvoice
|
|
133
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
134
|
+
then denied
|
|
135
|
+
|
|
136
|
+
specification RefusingAVoidWithoutTheAccountsRole
|
|
137
|
+
given caller
|
|
138
|
+
authenticated
|
|
139
|
+
when VoidInvoice
|
|
140
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
141
|
+
reason = "Issued in error"
|
|
142
|
+
then denied
|
|
143
|
+
|
|
144
|
+
specification RejectingSettlementOfAVoidedInvoice
|
|
145
|
+
given caller
|
|
146
|
+
authenticated
|
|
147
|
+
role "Accounts"
|
|
148
|
+
given InvoiceVoided
|
|
149
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
150
|
+
reason = "Issued in error"
|
|
151
|
+
when SettleInvoice
|
|
152
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
153
|
+
then error "Constraint 'SettleOrVoid' is violated: the event source already has the constrained event."
|
|
154
|
+
|
|
155
|
+
specification RejectingTheVoidingOfASettledInvoice
|
|
156
|
+
given caller
|
|
157
|
+
authenticated
|
|
158
|
+
role "Accounts"
|
|
159
|
+
given InvoiceSettled
|
|
160
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
161
|
+
when VoidInvoice
|
|
162
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
163
|
+
reason = "Issued in error"
|
|
164
|
+
then error "Constraint 'SettleOrVoid' is violated: the event source already has the constrained event."
|
|
165
|
+
|
|
166
|
+
slice StateChange RequestPayment
|
|
167
|
+
description "Starts a payment attempt. PaymentRequested says only that we asked the gateway; it is NOT the outcome. The outcome arrives later as an external fact (slice PaymentGatewayResults). A request may be repeated after a decline, so there is deliberately no once-only constraint here."
|
|
168
|
+
command RequestPayment
|
|
169
|
+
invoiceId InvoiceId identifier
|
|
170
|
+
produces PaymentRequested
|
|
171
|
+
for invoiceId
|
|
172
|
+
event PaymentRequested
|
|
173
|
+
|
|
174
|
+
specification RequestingPayment
|
|
175
|
+
given caller
|
|
176
|
+
authenticated
|
|
177
|
+
role "Accounts"
|
|
178
|
+
given InvoiceIssued
|
|
179
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
180
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
181
|
+
amount = 130
|
|
182
|
+
when RequestPayment
|
|
183
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
184
|
+
then PaymentRequested
|
|
185
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
186
|
+
|
|
187
|
+
specification RetryingPaymentAfterADecline
|
|
188
|
+
given caller
|
|
189
|
+
authenticated
|
|
190
|
+
role "Accounts"
|
|
191
|
+
given InvoiceIssued
|
|
192
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
193
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
194
|
+
amount = 130
|
|
195
|
+
given PaymentRequested
|
|
196
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
197
|
+
given PaymentDeclined
|
|
198
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
199
|
+
reason = "Card declined"
|
|
200
|
+
when RequestPayment
|
|
201
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
202
|
+
then PaymentRequested
|
|
203
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
204
|
+
|
|
205
|
+
slice Translate PaymentGatewayResults
|
|
206
|
+
description "Per external field: reference -> correlation key (our invoice id, echoed by the gateway); outcome -> translated to our enum; reason -> kept; cardholder -> ignored (personal data, no consumer). Authenticity of the webhook is a target requirement, not in the model. PaymentReceived and PaymentDeclined are OUR facts; PaymentGatewayResultReceived is the provider's."
|
|
207
|
+
capture PaymentGatewayResults
|
|
208
|
+
source webhook
|
|
209
|
+
path /webhooks/payments/results
|
|
210
|
+
key reference
|
|
211
|
+
map
|
|
212
|
+
outcome = outcome translate
|
|
213
|
+
"C" => captured
|
|
214
|
+
"D" => declined
|
|
215
|
+
append PaymentGatewayResultReceived
|
|
216
|
+
when outcome
|
|
217
|
+
outcome = $.outcome
|
|
218
|
+
reason = $.reason
|
|
219
|
+
reaction ReceivedTranslator
|
|
220
|
+
when PaymentGatewayResultReceived
|
|
221
|
+
outcome
|
|
222
|
+
produces PaymentReceived
|
|
223
|
+
where outcome == "captured"
|
|
224
|
+
reaction DeclinedTranslator
|
|
225
|
+
when PaymentGatewayResultReceived
|
|
226
|
+
outcome
|
|
227
|
+
reason
|
|
228
|
+
produces PaymentDeclined
|
|
229
|
+
reason = reason
|
|
230
|
+
where outcome == "declined"
|
|
231
|
+
event PaymentGatewayResultReceived
|
|
232
|
+
outcome GatewayOutcome
|
|
233
|
+
reason String
|
|
234
|
+
event PaymentReceived
|
|
235
|
+
event PaymentDeclined
|
|
236
|
+
reason String
|
|
237
|
+
|
|
238
|
+
specification TranslatingADeclinedCardResult
|
|
239
|
+
when capture PaymentGatewayResults
|
|
240
|
+
reference = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
241
|
+
outcome = "D"
|
|
242
|
+
reason = "Card declined"
|
|
243
|
+
then PaymentGatewayResultReceived
|
|
244
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
245
|
+
outcome = "declined"
|
|
246
|
+
reason = "Card declined"
|
|
247
|
+
then PaymentDeclined
|
|
248
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
249
|
+
reason = "Card declined"
|
|
250
|
+
|
|
251
|
+
slice StateView OpenInvoices
|
|
252
|
+
description "Todo list: membership means 'still to collect'; there is no status flag."
|
|
253
|
+
readmodel OpenInvoice
|
|
254
|
+
invoiceId InvoiceId
|
|
255
|
+
member MemberId
|
|
256
|
+
amount Decimal
|
|
257
|
+
query OpenInvoiceById => OpenInvoice optional
|
|
258
|
+
by invoiceId InvoiceId
|
|
259
|
+
projection OpenInvoices => OpenInvoice
|
|
260
|
+
from InvoiceIssued
|
|
261
|
+
invoiceId = $eventSourceId
|
|
262
|
+
member = member
|
|
263
|
+
amount = amount
|
|
264
|
+
remove with PaymentReceived
|
|
265
|
+
remove with InvoiceVoided
|
|
266
|
+
remove with InvoiceSettled
|
|
267
|
+
|
|
268
|
+
specification OpenInvoicesLifecycle1Empty
|
|
269
|
+
given caller
|
|
270
|
+
authenticated
|
|
271
|
+
role "Accounts"
|
|
272
|
+
then query OpenInvoiceById
|
|
273
|
+
arguments
|
|
274
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
275
|
+
|
|
276
|
+
specification OpenInvoicesLifecycle2Issued
|
|
277
|
+
given caller
|
|
278
|
+
authenticated
|
|
279
|
+
role "Accounts"
|
|
280
|
+
given InvoiceIssued
|
|
281
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
282
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
283
|
+
amount = 130
|
|
284
|
+
then query OpenInvoiceById
|
|
285
|
+
arguments
|
|
286
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
287
|
+
result
|
|
288
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
289
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
290
|
+
amount = 130
|
|
291
|
+
|
|
292
|
+
specification OpenInvoicesLifecycle3Paid
|
|
293
|
+
given caller
|
|
294
|
+
authenticated
|
|
295
|
+
role "Accounts"
|
|
296
|
+
given InvoiceIssued
|
|
297
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
298
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
299
|
+
amount = 130
|
|
300
|
+
when append PaymentReceived
|
|
301
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
302
|
+
then no readmodel OpenInvoice for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
303
|
+
then query OpenInvoiceById
|
|
304
|
+
arguments
|
|
305
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
306
|
+
|
|
307
|
+
specification OpenInvoicesLifecycle4Voided
|
|
308
|
+
given caller
|
|
309
|
+
authenticated
|
|
310
|
+
role "Accounts"
|
|
311
|
+
given InvoiceIssued
|
|
312
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
313
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
314
|
+
amount = 130
|
|
315
|
+
when append InvoiceVoided
|
|
316
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
317
|
+
reason = "Issued in error"
|
|
318
|
+
then no readmodel OpenInvoice for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
319
|
+
then query OpenInvoiceById
|
|
320
|
+
arguments
|
|
321
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
322
|
+
|
|
323
|
+
specification OpenInvoicesLifecycle5Settled
|
|
324
|
+
given caller
|
|
325
|
+
authenticated
|
|
326
|
+
role "Accounts"
|
|
327
|
+
given InvoiceIssued
|
|
328
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
329
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
330
|
+
amount = 130
|
|
331
|
+
when append InvoiceSettled
|
|
332
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
333
|
+
then no readmodel OpenInvoice for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
334
|
+
then query OpenInvoiceById
|
|
335
|
+
arguments
|
|
336
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
337
|
+
|
|
338
|
+
slice StateChange TopUpCredit
|
|
339
|
+
description "Adds credit to a member. Why an amount above zero: a zero top-up changes nothing and hides a mistake."
|
|
340
|
+
command TopUpCredit
|
|
341
|
+
member MemberId identifier
|
|
342
|
+
amount Decimal
|
|
343
|
+
validate
|
|
344
|
+
amount > 0 message "A top-up needs an amount above zero"
|
|
345
|
+
produces CreditToppedUp
|
|
346
|
+
for member
|
|
347
|
+
amount = amount
|
|
348
|
+
event CreditToppedUp
|
|
349
|
+
amount Decimal
|
|
350
|
+
|
|
351
|
+
specification ToppingUpCredit
|
|
352
|
+
given caller
|
|
353
|
+
authenticated
|
|
354
|
+
role "Accounts"
|
|
355
|
+
when TopUpCredit
|
|
356
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
357
|
+
amount = 40
|
|
358
|
+
then CreditToppedUp
|
|
359
|
+
for "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
360
|
+
amount = 40
|
|
361
|
+
|
|
362
|
+
specification RejectingATopUpWithoutAnAmount
|
|
363
|
+
given caller
|
|
364
|
+
authenticated
|
|
365
|
+
role "Accounts"
|
|
366
|
+
when TopUpCredit
|
|
367
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
368
|
+
amount = 0
|
|
369
|
+
then error "A top-up needs an amount above zero"
|
|
370
|
+
|
|
371
|
+
specification RefusingATopUpWithoutTheAccountsRole
|
|
372
|
+
given caller
|
|
373
|
+
authenticated
|
|
374
|
+
when TopUpCredit
|
|
375
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
376
|
+
amount = 40
|
|
377
|
+
then denied
|
|
378
|
+
|
|
379
|
+
slice StateView MemberCredit
|
|
380
|
+
description "Running credit balance per member: every top-up adds to it."
|
|
381
|
+
readmodel Credit
|
|
382
|
+
member MemberId
|
|
383
|
+
balance Decimal
|
|
384
|
+
query CreditByMember => Credit optional
|
|
385
|
+
by member MemberId
|
|
386
|
+
projection MemberCredit => Credit
|
|
387
|
+
from CreditToppedUp
|
|
388
|
+
member = $eventSourceId
|
|
389
|
+
add balance by amount
|
|
390
|
+
|
|
391
|
+
specification MemberCreditAccumulatesTopUps
|
|
392
|
+
given caller
|
|
393
|
+
authenticated
|
|
394
|
+
role "Accounts"
|
|
395
|
+
given CreditToppedUp
|
|
396
|
+
for "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
397
|
+
amount = 40
|
|
398
|
+
when append CreditToppedUp
|
|
399
|
+
for "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
400
|
+
amount = 70
|
|
401
|
+
then query CreditByMember
|
|
402
|
+
arguments
|
|
403
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
404
|
+
result
|
|
405
|
+
balance = 110
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## Notes
|
|
409
|
+
- The command that reverses a payment, the refund reaction and their specifications
|
|
410
|
+
(`ReversingAReceivedPayment`, `RequestingARefundAfterAReversal`) are in
|
|
411
|
+
`invoicing-dues-design.md`, because the command needs a stored-state rule.
|
|
412
|
+
- The query answers "absent" with no `result` block; the whole-list query and the `OpenInvoices`
|
|
413
|
+
list view in the excerpts are design-mode expectations (list queries compile but do not bind at
|
|
414
|
+
4.64.0, PLAY0268, `cratis-screenplay-toolchain`, so they are retained as design-mode expectations): see `view-and-story-specs.md`.
|
|
@@ -12,16 +12,25 @@ Source: TrogonStack/agentskills at `7b249d3ee42d8b7e11fa564141ebd5fbc37aadf1`, M
|
|
|
12
12
|
|---|---|---|
|
|
13
13
|
| `plugins/trogonstack-eventmodeling/skills/eventmodeling-elaborating-scenarios/SKILL.md`, Interview Phase and Critical Questions | `SKILL.md` "Interview phase" | Skip condition and four critical questions kept in structure (coverage depth, known edge cases and rules, how scenarios will be used, who reviews); rewritten for Screenplay specifications, the coverage matrix and unattended assumptions |
|
|
14
14
|
| same file, Workshop Facilitation Guide (Before the Workshop, During per command and view, Multi-Role Review, Common Workshop Mistakes, Tips for Rapid Creation) | `references/scenario-workshop.md` | Structure and the six-step per-command cycle adapted; steps extended to the full scenario catalogue; time-boxes and per-command quotas deliberately dropped because they conflict with obligation-driven coverage |
|
|
15
|
-
| same file, Quality Checklist and Gherkin Best Practices (explicit givens, explicit outcomes, named reasons) | `SKILL.md` "Quality checklist" | Mapped onto `.play` specification style (exact events, pinned messages, `for`, one
|
|
16
|
-
| same file, Scenario Organization (happy path, validation, state violation, duplicates, alternatives, error handling, compensation) | `references/scenario-catalogue.md` ordering | Extended with denial, competing claim, ordering, evolution and view types |
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
| same file, Quality Checklist and Gherkin Best Practices (explicit givens, explicit outcomes, named reasons), and its Workflow sections 1-5 (command, state validation, view, error path, compensation) | `SKILL.md` "Quality checklist", `references/scenario-examples.md` "Good and bad forms" and categories | Mapped onto `.play` specification style (exact events, pinned messages, `for`, one behavior per spec) |
|
|
16
|
+
| same file, Scenario Organization (happy path, validation, state violation, duplicates, alternatives, error handling, compensation) | `references/scenario-catalogue.md` ordering, `references/scenario-examples.md` categories | Extended with denial, competing claim, ordering, evolution and view types |
|
|
17
|
+
|
|
18
|
+
## Adapted closely (Martin Dilger and Nebulit GmbH, with agreement)
|
|
19
|
+
|
|
20
|
+
Source: https://github.com/Nebulit-GmbH/agentic-engineer at commit `07b0f30648d663cb588d7e2c7aa031af9dfc21f2`,
|
|
21
|
+
by Martin Dilger and Nebulit GmbH (https://nebulit.de). The repository carries no licence file; this material
|
|
22
|
+
is adapted with the agreement of Martin Dilger and Nebulit GmbH.
|
|
23
|
+
|
|
24
|
+
| Source file | Used in | How |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| `.claude/skills/eventmodeling-elaborating-scenarios/SKILL.md`: Interview Phase, Workshop Facilitation Guide, Multi-Role Review, Common Workshop Mistakes, Tips for Rapid Creation | `SKILL.md` "Interview phase", `references/scenario-workshop.md` | Text shared with TrogonStack's version (rows above, MIT; rationale, "what if" capture and multi-role review passages are not Nebulit-only); the Nebulit file is recorded here for completeness. Time-boxes and per-command quotas still deliberately dropped |
|
|
27
|
+
| same file: GWT vs. Storyline decision rule, Workflow 0 (decide per read model before drafting any payload; one reused schema may indicate a skipped judgment), todo lists as the prime storyline candidate, repeated event type as a driver | `SKILL.md` Procedure 5, `references/view-and-story-specs.md` "Worked family: a todo list" | Restored from #493 and adapted closely; storylines become lifecycle families of independent specs because Screenplay has no multi-step specification (Screenplay#394); storyline JSON, beats and layout dropped (board transport) |
|
|
28
|
+
| same file: Scenario Types (seven questions, "not a good/bad pair", skip only for a domain reason) | `references/scenario-catalogue.md` | Idea; our own, broader catalogue kept |
|
|
29
|
+
| same file: Quality Checklist (no command has only two scenarios; read models a separate, equally mandatory pass; why behind rules documented) | `SKILL.md` "Quality checklist" | Adapted closely; board posting and `expectEmptyList` items dropped |
|
|
30
|
+
| same file: Gherkin Best Practices (good and bad givens, outcomes, rejections), Key Principles | `references/scenario-examples.md` "Good and bad forms" | Shared with TrogonStack's version (row above); adapted closely, mapped to `.play` specification style |
|
|
31
|
+
| `.claude/skills/eventmodeling-elaborating-scenarios/references/examples.md`: command, state validation, view, list-view, error-path and compensation examples | `references/scenario-examples.md` | Category structure and cases (retry after failure, state violations, reversal with a consequence, list and accumulating views) adapted closely; shared with TrogonStack's version for most categories; rewritten as Screenplay specifications in the compiled `references/invoicing-dues-example.md` (runnable) and `references/invoicing-dues-design.md` (design mode, stored-state rules), with the capture, retry and refund-request specs added by us |
|
|
32
|
+
| `.claude/skills/examples/SKILL.md`: neighborhood-first reading, never overwrite existing examples, short domain-specific values, report fields changed and reused | `references/scenario-catalogue.md` "Example data" | Handoff report (fixtures changed, preserved, reused value origins, inconsistencies) adapted; rest idea, our own wording kept (board tooling, `add_field_examples` and name-based type guessing dropped because declared types decide values) |
|
|
33
|
+
| `.claude/skills/eventmodeling-elaborating-scenarios/SKILL.md`: Step 3 skip unresolved steps, board-only restrictions, "every scenario produces events" | none | Considered and not adopted: removing a prerequisite changes the test; Screenplay has rejections and queries |
|
|
25
34
|
|
|
26
35
|
## Cratis-original
|
|
27
36
|
Coverage matrix and obligation derivation from declarations, cell vocabulary (`spec`, `n/a`,
|
package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md
CHANGED
|
@@ -192,5 +192,9 @@ rules, gates, mappings or contracts to make an example pass.
|
|
|
192
192
|
condition. Denial: valid business input, vary only the caller. Validation: satisfy every other
|
|
193
193
|
rule.
|
|
194
194
|
- Unknown domain values stay questions, not plausible inventions.
|
|
195
|
-
-
|
|
196
|
-
|
|
195
|
+
- Handoff after fixture work reports: the spec names added or changed; each meaningful fixture
|
|
196
|
+
change and why (a demonstrated contradiction, never a rule changed to fit); which existing
|
|
197
|
+
intentional examples were preserved; where a reused value came from (the event, command input
|
|
198
|
+
or mapping it is traced to) and where values could not be traced; and unresolved
|
|
199
|
+
inconsistencies between specs. Check the resulting source, not just that a write succeeded; a
|
|
200
|
+
clean compile does not show the expected outcomes are right.
|
package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-examples.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Scenario examples, category by category
|
|
2
|
+
|
|
3
|
+
Compact examples for each scenario category, in one invoicing domain so the shapes compare
|
|
4
|
+
easily. Every excerpt below is copied verbatim from the complete document in
|
|
5
|
+
`invoicing-dues-example.md`, which compiles with warnings as errors and whose 21 specifications
|
|
6
|
+
pass in the reference evaluator; it also holds the declarations the excerpts depend on. The two
|
|
7
|
+
compensation excerpts in section 4 come from `invoicing-dues-design.md` instead: that document
|
|
8
|
+
holds the stored-state rules (`reads` + `require`), compiles but does not bind (PLAY0271,
|
|
9
|
+
PLAY0268), so its specifications are design mode and do not run. A second
|
|
10
|
+
complete example, with competing claims and denial fixtures, is `berth-reservations.md`. The category structure and the good/bad contrast follow the worked
|
|
11
|
+
examples in `eventmodeling-elaborating-scenarios` by TrogonStack and by Martin Dilger and Nebulit GmbH (`provenance.md`), translated to
|
|
12
|
+
Screenplay specifications.
|
|
13
|
+
|
|
14
|
+
## Good and bad forms
|
|
15
|
+
| Part | Good | Bad |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| Given | the facts that exist, each with its `for` source: `given InvoiceIssued` with `for "<invoice id>"` | "given an invoice" with no fact, no source |
|
|
18
|
+
| When | one action with every input stated | an action with inputs left to defaults |
|
|
19
|
+
| Then (success) | every production with payload and `for` | "an event is produced" |
|
|
20
|
+
| Then (refusal) | `then error "Invoice already settled"`, the rule's own message | `then error` with no message, or `then error ""` |
|
|
21
|
+
| Then (denial) | `then denied` | `then error` for a caller who is not allowed |
|
|
22
|
+
| Reason | the slice `description` says why the rule exists | the rule appears only in a spec title |
|
|
23
|
+
|
|
24
|
+
## 1. Command: success, rule rejection and denial
|
|
25
|
+
One spec for the success, one per rule (varying only the value the rule checks), one denial.
|
|
26
|
+
```screenplay excerpt
|
|
27
|
+
specification IssuingAnInvoice
|
|
28
|
+
given caller
|
|
29
|
+
authenticated
|
|
30
|
+
role "Accounts"
|
|
31
|
+
when IssueInvoice
|
|
32
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
33
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
34
|
+
amount = 130
|
|
35
|
+
then InvoiceIssued
|
|
36
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
37
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
38
|
+
amount = 130
|
|
39
|
+
|
|
40
|
+
specification RejectingAnInvoiceWithoutAnAmount
|
|
41
|
+
given caller
|
|
42
|
+
authenticated
|
|
43
|
+
role "Accounts"
|
|
44
|
+
when IssueInvoice
|
|
45
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
46
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
47
|
+
amount = 0
|
|
48
|
+
then error "An invoice needs an amount above zero"
|
|
49
|
+
|
|
50
|
+
specification RefusingACallerWithoutTheAccountsRole
|
|
51
|
+
given caller
|
|
52
|
+
authenticated
|
|
53
|
+
when IssueInvoice
|
|
54
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
55
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
56
|
+
amount = 130
|
|
57
|
+
then denied
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 2. Command: state violations
|
|
61
|
+
After which earlier facts must the command be refused? Establish the wrong state with its real
|
|
62
|
+
facts, not a description of it. Settling a voided invoice and voiding a settled one are different
|
|
63
|
+
questions: one spec each.
|
|
64
|
+
```screenplay excerpt
|
|
65
|
+
specification RejectingSettlementOfAVoidedInvoice
|
|
66
|
+
given caller
|
|
67
|
+
authenticated
|
|
68
|
+
role "Accounts"
|
|
69
|
+
given InvoiceVoided
|
|
70
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
71
|
+
reason = "Issued in error"
|
|
72
|
+
when SettleInvoice
|
|
73
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
74
|
+
then error "Constraint 'SettleOrVoid' is violated: the event source already has the constrained event."
|
|
75
|
+
|
|
76
|
+
specification RejectingTheVoidingOfASettledInvoice
|
|
77
|
+
given caller
|
|
78
|
+
authenticated
|
|
79
|
+
role "Accounts"
|
|
80
|
+
given InvoiceSettled
|
|
81
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
82
|
+
when VoidInvoice
|
|
83
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
84
|
+
reason = "Issued in error"
|
|
85
|
+
then error "Constraint 'SettleOrVoid' is violated: the event source already has the constrained event."
|
|
86
|
+
```
|
|
87
|
+
A rule over stored state that no constraint can hold (for example, "the invoice must exist") is
|
|
88
|
+
written as `reads <View>` + `require ... message`, marked NOT enforced with its target, given a
|
|
89
|
+
design-mode rejection spec and `recorded` in the matrix. See `RejectingSettlementOfAnUnknownInvoice`
|
|
90
|
+
in `invoicing-dues-design.md`; it is never prose and never a spec that pretends to enforce it.
|
|
91
|
+
|
|
92
|
+
## 3. External failure: the capture, then the retry
|
|
93
|
+
Two separate obligations. First, the **capture specification**: concrete external input in, our
|
|
94
|
+
facts out. The provider's refusal is a fact (never a `then error`), kept in the provider's
|
|
95
|
+
vocabulary and then translated.
|
|
96
|
+
```screenplay excerpt
|
|
97
|
+
specification TranslatingADeclinedCardResult
|
|
98
|
+
when capture PaymentGatewayResults
|
|
99
|
+
reference = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
100
|
+
outcome = "D"
|
|
101
|
+
reason = "Card declined"
|
|
102
|
+
then PaymentGatewayResultReceived
|
|
103
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
104
|
+
outcome = "declined"
|
|
105
|
+
reason = "Card declined"
|
|
106
|
+
then PaymentDeclined
|
|
107
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
108
|
+
reason = "Card declined"
|
|
109
|
+
```
|
|
110
|
+
Second, the **retry**. `PaymentRequested` only says we asked the gateway; it is not the outcome.
|
|
111
|
+
After the decline, requesting again is an ordinary accepted command, and its exact declared
|
|
112
|
+
outcome is `PaymentRequested`, not `PaymentReceived`: the eventual success is a later external
|
|
113
|
+
fact that arrives through the capture, not something this command produces.
|
|
114
|
+
```screenplay excerpt
|
|
115
|
+
specification RetryingPaymentAfterADecline
|
|
116
|
+
given caller
|
|
117
|
+
authenticated
|
|
118
|
+
role "Accounts"
|
|
119
|
+
given InvoiceIssued
|
|
120
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
121
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
122
|
+
amount = 130
|
|
123
|
+
given PaymentRequested
|
|
124
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
125
|
+
given PaymentDeclined
|
|
126
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
127
|
+
reason = "Card declined"
|
|
128
|
+
when RequestPayment
|
|
129
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
130
|
+
then PaymentRequested
|
|
131
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
132
|
+
```
|
|
133
|
+
A view that shows the decline (a failure view) is a third, separate specification of a read
|
|
134
|
+
model; it tests the projection only, never the translation.
|
|
135
|
+
|
|
136
|
+
## 4. Compensation
|
|
137
|
+
A reversal needs a paid history, the reversal action and the exact consequence. The command spec
|
|
138
|
+
lists the declared consequence (`RefundRequested`); the reaction is also specified on its own.
|
|
139
|
+
`RefundRequested` is a recorded request, not proof that money moved, and there is no
|
|
140
|
+
`then <Command>` form. What the target must do to deliver the refund is a requirement, not a spec.
|
|
141
|
+
From `invoicing-dues-design.md` (design mode; the specs do not run at 4.64.0):
|
|
142
|
+
```screenplay excerpt
|
|
143
|
+
specification ReversingAReceivedPayment
|
|
144
|
+
given caller
|
|
145
|
+
authenticated
|
|
146
|
+
role "Accounts"
|
|
147
|
+
given InvoiceIssued
|
|
148
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
149
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
150
|
+
amount = 130
|
|
151
|
+
given PaymentReceived
|
|
152
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
153
|
+
when ReversePayment
|
|
154
|
+
invoiceId = "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
155
|
+
amount = 130
|
|
156
|
+
then PaymentReversed
|
|
157
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
158
|
+
amount = 130
|
|
159
|
+
then RefundRequested
|
|
160
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
161
|
+
amount = 130
|
|
162
|
+
|
|
163
|
+
specification RequestingARefundAfterAReversal
|
|
164
|
+
when append PaymentReversed
|
|
165
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
166
|
+
amount = 130
|
|
167
|
+
then RefundRequested
|
|
168
|
+
for "9c1f0a52-6a4e-4b1c-9f55-0d2c7b8e1a01"
|
|
169
|
+
amount = 130
|
|
170
|
+
```
|
|
171
|
+
If nothing in the model can reverse a fact the business can reverse, the model lacks an event:
|
|
172
|
+
ask. Voiding an issued invoice that is not yet paid is the other compensation (the `VoidInvoice` rule in `invoicing-dues-design.md`; `SettleOrVoid` only keeps settle and void exclusive).
|
|
173
|
+
|
|
174
|
+
## 5. Views: population, update, accumulation
|
|
175
|
+
A repeated event type can matter as much as a multi-event lifecycle. Two top-ups of 40 and 70
|
|
176
|
+
walk a balance to 110; give the second occurrence as the action so the accumulation is what is
|
|
177
|
+
tested.
|
|
178
|
+
```screenplay excerpt
|
|
179
|
+
specification MemberCreditAccumulatesTopUps
|
|
180
|
+
given caller
|
|
181
|
+
authenticated
|
|
182
|
+
role "Accounts"
|
|
183
|
+
given CreditToppedUp
|
|
184
|
+
for "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
185
|
+
amount = 40
|
|
186
|
+
when append CreditToppedUp
|
|
187
|
+
for "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
188
|
+
amount = 70
|
|
189
|
+
then query CreditByMember
|
|
190
|
+
arguments
|
|
191
|
+
member = "6f1c2a8e-0b1d-4d55-9a3e-2f6a7c1d0e11"
|
|
192
|
+
result
|
|
193
|
+
balance = 110
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## 6. Views: list contents and the empty list
|
|
197
|
+
A list query asserts one `result` block per expected row (count and order are exact), and the
|
|
198
|
+
empty-list intent is a separate claim from a keyed row being absent (`view-and-story-specs.md`
|
|
199
|
+
"Removal is a positive obligation"). The backing example proves the keyed forms only; whole-list
|
|
200
|
+
queries stay design-mode expectations and are recorded as such in the coverage matrix.
|