@milehimikey/em 1.16.1 → 1.18.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.
Files changed (219) hide show
  1. package/.claude/skills/event-modeling/SKILL.md +1 -1
  2. package/.claude/skills/event-modeling-conform/SKILL.md +3 -2
  3. package/.claude/skills/event-modeling-conform/reference/conform.md +7 -0
  4. package/.claude/skills/event-modeling-design/SKILL.md +46 -5
  5. package/.claude/skills/event-modeling-discover/SKILL.md +43 -8
  6. package/.claude/skills/event-modeling-discover/reference/extract.md +6 -1
  7. package/.claude/skills/event-modeling-discover/reference/prd-rubric.md +102 -0
  8. package/.claude/skills/event-modeling-discover/reference/prd-spec-path.md +171 -0
  9. package/.claude/skills/event-modeling-engagement/SKILL.md +28 -6
  10. package/.claude/skills/event-modeling-engagement/reference/engagement.md +5 -4
  11. package/.claude/skills/event-modeling-implement/SKILL.md +1 -1
  12. package/.claude/skills/event-modeling-implement/reference/implement.md +18 -8
  13. package/.claude/skills/event-modeling-review/SKILL.md +1 -1
  14. package/.claude/skills/event-modeling-shared/reference/em-dsl.md +107 -10
  15. package/.claude/skills/event-modeling-shared/reference/methodology.md +268 -0
  16. package/.claude/skills/event-modeling-shared/reference/slice-doc-schema.md +122 -15
  17. package/.claude/skills/event-modeling-shared/templates/slice.md +11 -3
  18. package/.claude-plugin/marketplace.json +2 -2
  19. package/dist/catalog/docJoin.d.ts +13 -5
  20. package/dist/catalog/docJoin.js +6 -1
  21. package/dist/catalog/docJoin.js.map +1 -1
  22. package/dist/catalog/docModelConsistencyValidate.js +160 -0
  23. package/dist/catalog/docModelConsistencyValidate.js.map +1 -1
  24. package/dist/catalog/invariantsValidate.d.ts +2 -0
  25. package/dist/catalog/invariantsValidate.js +67 -1
  26. package/dist/catalog/invariantsValidate.js.map +1 -1
  27. package/dist/catalog/scenarioQualityValidate.d.ts +4 -0
  28. package/dist/catalog/scenarioQualityValidate.js +148 -0
  29. package/dist/catalog/scenarioQualityValidate.js.map +1 -0
  30. package/dist/catalog/scenarios.d.ts +5 -0
  31. package/dist/catalog/scenarios.js +80 -0
  32. package/dist/catalog/scenarios.js.map +1 -1
  33. package/dist/catalog/signedBodyValidate.d.ts +7 -0
  34. package/dist/catalog/signedBodyValidate.js +29 -0
  35. package/dist/catalog/signedBodyValidate.js.map +1 -0
  36. package/dist/catalog/sliceDoc.d.ts +53 -7
  37. package/dist/catalog/sliceDoc.js +89 -10
  38. package/dist/catalog/sliceDoc.js.map +1 -1
  39. package/dist/catalog/sliceReadyValidate.d.ts +23 -2
  40. package/dist/catalog/sliceReadyValidate.js +54 -22
  41. package/dist/catalog/sliceReadyValidate.js.map +1 -1
  42. package/dist/catalog/sliceSections.d.ts +3 -2
  43. package/dist/catalog/sliceSections.js +99 -9
  44. package/dist/catalog/sliceSections.js.map +1 -1
  45. package/dist/cli/ciInit.d.ts +4 -11
  46. package/dist/cli/ciInit.js +24 -6
  47. package/dist/cli/ciInit.js.map +1 -1
  48. package/dist/cli/coverage.d.ts +9 -0
  49. package/dist/cli/coverage.js +18 -0
  50. package/dist/cli/coverage.js.map +1 -1
  51. package/dist/cli/defer.d.ts +60 -17
  52. package/dist/cli/defer.js +187 -86
  53. package/dist/cli/defer.js.map +1 -1
  54. package/dist/cli/engagement.d.ts +46 -0
  55. package/dist/cli/engagement.js +156 -1
  56. package/dist/cli/engagement.js.map +1 -1
  57. package/dist/cli/engagementFoundation.d.ts +47 -0
  58. package/dist/cli/engagementFoundation.js +164 -0
  59. package/dist/cli/engagementFoundation.js.map +1 -0
  60. package/dist/cli/frontmatterSurgery.d.ts +5 -0
  61. package/dist/cli/frontmatterSurgery.js +15 -0
  62. package/dist/cli/frontmatterSurgery.js.map +1 -1
  63. package/dist/cli/ledgerCheck.d.ts +5 -1
  64. package/dist/cli/ledgerCheck.js +50 -20
  65. package/dist/cli/ledgerCheck.js.map +1 -1
  66. package/dist/cli/markImplemented.d.ts +14 -10
  67. package/dist/cli/markImplemented.js +49 -1
  68. package/dist/cli/markImplemented.js.map +1 -1
  69. package/dist/cli/prdTriage.d.ts +109 -0
  70. package/dist/cli/prdTriage.js +378 -0
  71. package/dist/cli/prdTriage.js.map +1 -0
  72. package/dist/cli/ratify.d.ts +14 -2
  73. package/dist/cli/ratify.js +34 -6
  74. package/dist/cli/ratify.js.map +1 -1
  75. package/dist/cli/refsCheck.d.ts +78 -0
  76. package/dist/cli/refsCheck.js +153 -0
  77. package/dist/cli/refsCheck.js.map +1 -0
  78. package/dist/cli/render-inputs.d.ts +2 -0
  79. package/dist/cli/render-inputs.js +4 -0
  80. package/dist/cli/render-inputs.js.map +1 -1
  81. package/dist/cli/revise.d.ts +12 -3
  82. package/dist/cli/revise.js +43 -10
  83. package/dist/cli/revise.js.map +1 -1
  84. package/dist/cli/shape.d.ts +27 -0
  85. package/dist/cli/shape.js +77 -0
  86. package/dist/cli/shape.js.map +1 -0
  87. package/dist/cli/sliceConform.js +9 -0
  88. package/dist/cli/sliceConform.js.map +1 -1
  89. package/dist/cli/sliceIndex.d.ts +6 -1
  90. package/dist/cli/sliceIndex.js +28 -13
  91. package/dist/cli/sliceIndex.js.map +1 -1
  92. package/dist/cli/sliceNew.d.ts +4 -1
  93. package/dist/cli/sliceNew.js +26 -9
  94. package/dist/cli/sliceNew.js.map +1 -1
  95. package/dist/cli/status.d.ts +26 -5
  96. package/dist/cli/status.js +28 -6
  97. package/dist/cli/status.js.map +1 -1
  98. package/dist/cli/storylineSuggest.d.ts +26 -0
  99. package/dist/cli/storylineSuggest.js +252 -0
  100. package/dist/cli/storylineSuggest.js.map +1 -0
  101. package/dist/cli/upgrade.d.ts +15 -3
  102. package/dist/cli/upgrade.js +537 -8
  103. package/dist/cli/upgrade.js.map +1 -1
  104. package/dist/cli/upgradeReshape.d.ts +60 -0
  105. package/dist/cli/upgradeReshape.js +425 -0
  106. package/dist/cli/upgradeReshape.js.map +1 -0
  107. package/dist/cli.js +430 -57
  108. package/dist/cli.js.map +1 -1
  109. package/dist/emit/dot.d.ts +2 -0
  110. package/dist/emit/dot.js +44 -8
  111. package/dist/emit/dot.js.map +1 -1
  112. package/dist/emit/engagementJson.d.ts +4 -1
  113. package/dist/emit/engagementJson.js +27 -1
  114. package/dist/emit/engagementJson.js.map +1 -1
  115. package/dist/emit/json.d.ts +21 -1
  116. package/dist/emit/json.js +29 -2
  117. package/dist/emit/json.js.map +1 -1
  118. package/dist/emit/ledgerJson.d.ts +1 -1
  119. package/dist/emit/ledgerJson.js +6 -1
  120. package/dist/emit/ledgerJson.js.map +1 -1
  121. package/dist/emit/queryJson.d.ts +1 -1
  122. package/dist/emit/queryJson.js +3 -1
  123. package/dist/emit/queryJson.js.map +1 -1
  124. package/dist/emit/refsJson.d.ts +4 -0
  125. package/dist/emit/refsJson.js +19 -0
  126. package/dist/emit/refsJson.js.map +1 -0
  127. package/dist/emit/statusJson.d.ts +1 -1
  128. package/dist/emit/statusJson.js +6 -1
  129. package/dist/emit/statusJson.js.map +1 -1
  130. package/dist/emit/theme.d.ts +1 -0
  131. package/dist/emit/theme.js +13 -0
  132. package/dist/emit/theme.js.map +1 -1
  133. package/dist/emit/validateJson.d.ts +5 -2
  134. package/dist/emit/validateJson.js +41 -2
  135. package/dist/emit/validateJson.js.map +1 -1
  136. package/dist/layout/grid.d.ts +5 -1
  137. package/dist/layout/grid.js +93 -2
  138. package/dist/layout/grid.js.map +1 -1
  139. package/dist/mcp/server.js +79 -14
  140. package/dist/mcp/server.js.map +1 -1
  141. package/dist/model/edges.d.ts +7 -0
  142. package/dist/model/edges.js +33 -16
  143. package/dist/model/edges.js.map +1 -1
  144. package/dist/model/model.d.ts +33 -0
  145. package/dist/model/model.js +87 -3
  146. package/dist/model/model.js.map +1 -1
  147. package/dist/model/queryIndex.js +2 -2
  148. package/dist/model/queryIndex.js.map +1 -1
  149. package/dist/model/refs.js +8 -5
  150. package/dist/model/refs.js.map +1 -1
  151. package/dist/model/rules.d.ts +167 -1
  152. package/dist/model/rules.js +164 -3
  153. package/dist/model/rules.js.map +1 -1
  154. package/dist/model/shapeLint.d.ts +12 -0
  155. package/dist/model/shapeLint.js +170 -0
  156. package/dist/model/shapeLint.js.map +1 -0
  157. package/dist/model/storylines.d.ts +51 -0
  158. package/dist/model/storylines.js +188 -0
  159. package/dist/model/storylines.js.map +1 -0
  160. package/dist/model/validate.d.ts +6 -1
  161. package/dist/model/validate.js +317 -14
  162. package/dist/model/validate.js.map +1 -1
  163. package/dist/parser/againSugar.d.ts +30 -0
  164. package/dist/parser/againSugar.js +105 -0
  165. package/dist/parser/againSugar.js.map +1 -0
  166. package/dist/parser/ast.d.ts +33 -0
  167. package/dist/parser/lexer.d.ts +9 -1
  168. package/dist/parser/lexer.js +17 -2
  169. package/dist/parser/lexer.js.map +1 -1
  170. package/dist/parser/parser.js +284 -4
  171. package/dist/parser/parser.js.map +1 -1
  172. package/dist/query/format.js +1 -0
  173. package/dist/query/format.js.map +1 -1
  174. package/dist/query/verbs.d.ts +4 -0
  175. package/dist/query/verbs.js +30 -3
  176. package/dist/query/verbs.js.map +1 -1
  177. package/dist/render/drawEdges.js +100 -4
  178. package/dist/render/drawEdges.js.map +1 -1
  179. package/dist/render/render.js +20 -2
  180. package/dist/render/render.js.map +1 -1
  181. package/dist/render/sliceDiagram.js +5 -5
  182. package/dist/render/sliceDiagram.js.map +1 -1
  183. package/dist/render/storylineBands.d.ts +11 -0
  184. package/dist/render/storylineBands.js +80 -0
  185. package/dist/render/storylineBands.js.map +1 -0
  186. package/dist/render/storylineDiagram.d.ts +14 -0
  187. package/dist/render/storylineDiagram.js +142 -0
  188. package/dist/render/storylineDiagram.js.map +1 -0
  189. package/dist/roster/check.d.ts +32 -0
  190. package/dist/roster/check.js +92 -0
  191. package/dist/roster/check.js.map +1 -0
  192. package/dist/roster/context.d.ts +3 -0
  193. package/dist/roster/context.js +23 -0
  194. package/dist/roster/context.js.map +1 -0
  195. package/dist/roster/init.d.ts +15 -0
  196. package/dist/roster/init.js +52 -0
  197. package/dist/roster/init.js.map +1 -0
  198. package/dist/roster/roster.d.ts +79 -0
  199. package/dist/roster/roster.js +298 -0
  200. package/dist/roster/roster.js.map +1 -0
  201. package/package.json +1 -1
  202. package/plugin/.claude-plugin/plugin.json +2 -2
  203. package/plugin/shared/reference/em-dsl.md +107 -10
  204. package/plugin/shared/reference/methodology.md +268 -0
  205. package/plugin/shared/reference/slice-doc-schema.md +122 -15
  206. package/plugin/shared/templates/slice.md +11 -3
  207. package/plugin/skills/conform/SKILL.md +3 -2
  208. package/plugin/skills/conform/reference/conform.md +7 -0
  209. package/plugin/skills/design/SKILL.md +46 -5
  210. package/plugin/skills/discover/SKILL.md +43 -8
  211. package/plugin/skills/discover/reference/extract.md +6 -1
  212. package/plugin/skills/discover/reference/prd-rubric.md +103 -0
  213. package/plugin/skills/discover/reference/prd-spec-path.md +172 -0
  214. package/plugin/skills/engagement/SKILL.md +28 -6
  215. package/plugin/skills/engagement/reference/engagement.md +5 -4
  216. package/plugin/skills/event-modeling/SKILL.md +1 -1
  217. package/plugin/skills/implement/SKILL.md +1 -1
  218. package/plugin/skills/implement/reference/implement.md +18 -8
  219. package/plugin/skills/review/SKILL.md +1 -1
@@ -144,6 +144,17 @@ command** — it never records an event directly.
144
144
  duplicated name.
145
145
  - Socratic prompts: *"What should happen without a human? What condition triggers it? What work
146
146
  list does the processor watch? What command does it fire? What if it fails or retries?"*
147
+ - **Outcomes are events of the SAME slice.** Success, failure, retry-scheduled and timeout are
148
+ outcome events of the one command (`Fulfilment Succeeded` / `Fulfilment Failed` / `Fulfilment
149
+ Retry Scheduled`), not sibling slices per control-flow branch (1.18.0 adds the
150
+ lint `automation-split-by-outcome`). Retry policy and failure handling are invariants and scenarios
151
+ in that slice's doc. A new slice only when a different actor or a different trigger is
152
+ involved. Canon: Dilger, "one business action… two different possible outcomes"
153
+ (`PaymentIssued` / `PaymentFailed`); a failure that continues the story is "Linearized" as a
154
+ later chapter linked to the originating event, never a branch; it reads the failure event
155
+ through a view or a reaction (Law 1 forbids event-to-event arrows). A retry is the processor's
156
+ to-do view reading the retry-scheduled event (`view X again`), so the same reaction re-fires. Same rule for State Change: one
157
+ command, several outcome events, one slice.
147
158
 
148
159
  ### 4. Translation
149
160
  **Boundary crossing → command → event, the reaction and what it triggers together in one slice.**
@@ -193,6 +204,260 @@ The `em` shape only tracks the second question — trigger source doesn't change
193
204
 
194
205
  ---
195
206
 
207
+ ## The story, not the schema
208
+
209
+ A model is a story of what success looks like, not a data model (Dymitruk, *What is Event Modeling*: a
210
+ story "on a time line and with no branching"; commands capture intent, "as opposed to simply saving form
211
+ data to a table"; "all information has to have an origin and a destination"). Models drafted from a spec
212
+ drift into **CRUD laid on a timeline**; these rules stop that. Quoted lines are the canon; rulings marked
213
+ *(em ruling)* are em's own — neither Dymitruk nor Dilger states a child-entity rule or bans "Update" or
214
+ "Set" by name. Full write-up with the canon quotes: `docs/storyline.md`.
215
+
216
+ - **One journey per process, start to finish.** The timeline holds one business journey per process,
217
+ ending in an outcome. The **main storyline** is the end-to-end happy path; retire, extend and
218
+ reorganize are **secondary storylines** (chapters; Dilger: "one linear flow from left to right. No
219
+ exceptions… Linearize it!", "Model one process at a time, each with its own clear ending"). Never one
220
+ lifecycle block per entity. Name the main and every secondary storyline; a `storyline "Name" { … }`
221
+ block groups the slices (`dsl.md`, Storylines).
222
+ - **Build from walkthroughs first.** The story already lives in the spec's walkthroughs, use cases and
223
+ user journeys. Build the timeline from those; the resource/API reference (OpenAPI, endpoint tables,
224
+ migrations) fills only the operations no walkthrough touches, and is read last. Headless: a persona
225
+ per API caller, and that caller's journey is the story.
226
+ - **The CRUD shape.** N entities × (create, update, archive), one trailing view per entity, no read
227
+ across contexts. Recognise it in your own output. Both models below validate; only the second is a
228
+ story:
229
+ ```em
230
+ model "Catalog (CRUD shape)"
231
+
232
+ persona Merchandiser
233
+
234
+ context Product
235
+
236
+ slice "Create Product" {
237
+ ui Product Form @Merchandiser
238
+ command Create Product
239
+ event Product Created @Product
240
+ }
241
+
242
+ slice "Update Product" {
243
+ ui Product Form @Merchandiser
244
+ command Update Product
245
+ event Product Updated @Product
246
+ }
247
+
248
+ slice "Archive Product" {
249
+ ui Product Form @Merchandiser
250
+ command Archive Product
251
+ event Product Archived @Product
252
+ }
253
+
254
+ slice "Products" {
255
+ view Products from "Product Created", "Product Updated", "Product Archived"
256
+ ui Product List @Merchandiser
257
+ }
258
+ ```
259
+ ```em
260
+ model "Catalog (storyline shape)"
261
+
262
+ persona Merchandiser
263
+
264
+ context Product
265
+
266
+ storyline "Bring a product to market" {
267
+ slice "Create Product" {
268
+ ui Product Form @Merchandiser
269
+ command Create Product
270
+ event Product Created @Product
271
+ }
272
+
273
+ slice "Catalog" {
274
+ view Catalog from "Product Created"
275
+ ui Browse Catalog @Merchandiser
276
+ }
277
+
278
+ slice "Set Price" {
279
+ ui Pricing Panel @Merchandiser
280
+ command Set Price
281
+ event Price Set @Product
282
+ }
283
+
284
+ slice "Catalog with Price" {
285
+ view Catalog again from "Price Set"
286
+ ui Browse Catalog @Merchandiser
287
+ }
288
+ }
289
+
290
+ storyline "Retire a product" after "Bring a product to market" {
291
+ slice "Retire Product" {
292
+ ui Pricing Panel @Merchandiser
293
+ command Retire Product
294
+ event Product Retired @Product
295
+ }
296
+
297
+ slice "Catalog without Product" {
298
+ view Catalog again from "Product Retired"
299
+ ui Browse Catalog @Merchandiser
300
+ }
301
+ }
302
+ ```
303
+ The `timeline-entity-clustered` lint is the mechanical half (it fires only once two or more
304
+ contexts are written; this one-entity pair stays silent); once any storyline exists,
305
+ `slice-outside-storyline` flags slices left outside one.
306
+ - **Commands name intent, not endpoints** (Dilger: "Name by intent", "Every command has a reason"). One
307
+ endpoint may carry several intents. Signal of two intents in one command: invariants or field rules
308
+ that apply only "if `<field>` is set" — split it, and both commands may record the same event
309
+ (`CreateProduct` / `CreateProductVariant`, same `POST /products`, same `ProductCreated`). **Intent
310
+ test:** if a storyline step reads awkwardly with the command's name, the command is named after the
311
+ endpoint. `command-second-intent` and `command-repeated-across-slices` are the mechanical half.
312
+ - **A read model is one information need** (Dilger: "Every Read Model answers a question. No question,
313
+ no Read Model."). **Question test:** write the question each view answers; add a view only when no
314
+ existing one answers it. A nested route hints the child belongs in the parent's view; the real test
315
+ is whether the query needs information the parent view lacks. Child with references only → the parent
316
+ view carries ids; child with its own data → embedded in the parent view; child queried without the
317
+ parent id → its own view. Aggregate rules decide write-side consistency, never read models. *(em
318
+ ruling)*
319
+ - **Write side: children belong in the parent's context** when the child's invariants are checks against
320
+ the parent. A sub-resource schema shared across parent types is one event per parent on the parent's
321
+ context, not a shared aggregate — check the spec's event reference, not its resource section. Where
322
+ two slices record the same fact, repeat the event bare (same name, same context). *(em ruling)*
323
+ - **Repeat the view after every command that changes it** (`again`, span-1 — see State View above), so
324
+ the reader sees the information arrive rather than a view at the end.
325
+ - **Outcomes are events of one slice** (Dilger: "One decision. One event. One state change."; one
326
+ action with two outcomes is the legitimate exception): alternative events on one context in one slice
327
+ (`event A | B @Ctx`, GH #278), failure as a scenario first, a chapter only when core (it changes what the user does next, or has
328
+ its own actor/SLA). Stated once for
329
+ automations in the Automation pattern (`docs/patterns.md#automation`); `automation-split-by-outcome`
330
+ and `retry-slice-of` are the mechanical half. Two forms, alternatives always on one context: inline `event A | B @Ctx`
331
+ (shared clauses and fields) and `oneof { … }` (each alternative keeps its own fields and clauses):
332
+ ```em
333
+ model "Payments"
334
+
335
+ persona Customer
336
+
337
+ context Payment
338
+
339
+ slice "Settle Payment" {
340
+ ui Pay Screen @Customer
341
+ command Settle Payment
342
+ event Payment Issued | Payment Failed @Payment { paymentId: UUID }
343
+ }
344
+
345
+ slice "Payment Status" {
346
+ view Payment Status from "Payment Issued", "Payment Failed"
347
+ ui Payment Result @Customer
348
+ }
349
+
350
+ slice "Refund Payment" {
351
+ ui Refund Screen @Customer
352
+ command Refund Payment
353
+ oneof {
354
+ event Refund Issued @Payment { paymentId: UUID, amount: Decimal }
355
+ event Refund Declined @Payment { paymentId: UUID, reason: String }
356
+ }
357
+ }
358
+
359
+ slice "Refund Status" {
360
+ view Refund Status from "Refund Issued", "Refund Declined"
361
+ ui Refund Result @Customer
362
+ }
363
+ ```
364
+ - **One event, two commands.** When two commands record the same fact, repeat the event bare
365
+ (`event X @Ctx`, same name and context) in the second slice: it inherits the first declaration, no
366
+ marker needed. Declaring different fields is `shared-event-field-mismatch`. (The arrow set for a
367
+ shared event read by a repeated view is under review: GH #328.)
368
+ ```em
369
+ model "Ordering"
370
+
371
+ persona Customer
372
+
373
+ context Sales
374
+
375
+ slice "Place Order" {
376
+ ui Checkout @Customer
377
+ command Place Order
378
+ event Order Placed @Sales { orderId: UUID }
379
+ }
380
+
381
+ slice "Order Status" {
382
+ view Order Status from "Order Placed"
383
+ ui Track Order @Customer
384
+ }
385
+
386
+ slice "Reorder" {
387
+ ui Reorder Button @Customer
388
+ command Reorder
389
+ event Order Placed @Sales
390
+ }
391
+
392
+ slice "Order Status after Reorder" {
393
+ view Order Status again from "Order Placed"
394
+ ui Track Order @Customer
395
+ }
396
+ ```
397
+ Combined with alternatives: when one alternative is a shared repeat, use `oneof` and write that
398
+ alternative bare so it inherits its fields (an inline line's fields would be copied onto every
399
+ alternative and mismatch):
400
+ ```em
401
+ model "Payments"
402
+
403
+ persona Customer
404
+
405
+ context Payment
406
+
407
+ slice "Settle Payment" {
408
+ ui Pay Screen @Customer
409
+ command Settle Payment
410
+ oneof {
411
+ event Payment Issued @Payment { paymentId: UUID }
412
+ event Payment Failed @Payment { paymentId: UUID, reason: String }
413
+ }
414
+ }
415
+
416
+ slice "Payment Status" {
417
+ view Payment Status from "Payment Issued", "Payment Failed"
418
+ ui Payment Result @Customer
419
+ }
420
+
421
+ slice "Retry Payment" {
422
+ ui Retry Screen @Customer
423
+ command Retry Payment
424
+ oneof {
425
+ event Payment Issued @Payment
426
+ event Payment Retry Declined @Payment { paymentId: UUID }
427
+ }
428
+ }
429
+
430
+ slice "Payment Status after Retry" {
431
+ view Payment Status again from "Payment Issued", "Payment Retry Declined"
432
+ ui Payment Result @Customer
433
+ }
434
+ ```
435
+ - **Reference-only PRD groups sit outside storylines.** A group that only carries reference material
436
+ (#327) is not a journey; leave it out of every `storyline` block.
437
+ - **Business terms in the events.** "If your Event Model doesn't reflect terms used by business experts —
438
+ especially in the recorded Events — that's a red flag." (Dilger, *Seven insights*.)
439
+
440
+ ### Reshaping an existing model
441
+
442
+ The upgrade path for a CRUD-shaped model. After each step run `em validate`.
443
+
444
+ `em storyline suggest <model>.em` proposes the `storyline` blocks as a diff (advisory, never
445
+ writes); `em upgrade` offers `collapse-alternative-events` and the opt-in `fold-continuations`.
446
+
447
+ 1. Name the processes (list each spec's walkthroughs or journeys, not endpoints): the main storyline and each secondary one.
448
+ 2. Reorder the slices into those stories and wrap each in a `storyline` block (`after "…"` where one
449
+ follows another); a slice that fits no story is a deletion candidate.
450
+ 3. Intent test per command: rename to the business intent; split any command with "if X is set" rules.
451
+ 4. Apply the information-need test to each read model and fold children into parents: merge views
452
+ answering the same question; add one only for an unanswered one.
453
+ 5. Move child-entity events onto the parent's context when the child's invariants check the parent.
454
+ 6. Repeat each view (`again`, span-1) after every command that changes it; drop the lone trailing view.
455
+ 7. Fold success/failure slice pairs into one slice with alternative events.
456
+ 8. Tooling, last: `em validate` (and `em validate --shape`, the 1.18.0 design exit gate), `em slice sync
457
+ --check` then `em slice sync`, `em slice index`, and regenerate TypeSpec/contracts last.
458
+
459
+ ---
460
+
196
461
  ## The 7 steps
197
462
 
198
463
  Run them in order. The skill groups them into phases: **discover = 1–4**, **model = 5–7**,
@@ -256,6 +521,9 @@ dedicated `slice` phase writes the full rich spec (see `../templates/slice.md`).
256
521
  - Prompts: *"Given what starting state, when this command/trigger fires, then what event(s)
257
522
  result? What must always be true? What are the failure paths? Which fields are essential and
258
523
  what are their rules?"*
524
+ - **Failure, retry, timeout surface here?** Add the outcome events and the scenarios to the
525
+ SAME slice, never a new slice per branch (Dymitruk: "a few of these stories to show how a
526
+ command can and cannot succeed" — Given/When/Then scenarios first).
259
527
  - **Existing codebase:** before finalizing field names/types, check adjacent real sources
260
528
  (OpenAPI specs, DB migrations, existing DTOs/event classes in sibling contexts) rather than
261
529
  guessing — mirrors `extract.md`'s whole-system grounding, applied per-slice.
@@ -67,17 +67,18 @@ to decide `frontmatter-invalid` without re-deriving frontmatter-shape rules of i
67
67
  | `reviewedOn` | string | `YYYY-MM-DD` | written only by `em slice review` (MIL-201); joined into `em export`'s `slice.doc.reviewedOn` (schema `1.11`) |
68
68
  | `ratifiedBy` | string | free text (typically a person's name) | written only by `em slice ratify` (MIL-165 — see [cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-ratify-file-slice-key---by-name)); joined into `em export`'s `slice.doc.ratifiedBy` (schema `1.8`) and `em slice index`'s Ratified by column |
69
69
  | `ratifiedOn` | string | `YYYY-MM-DD` | written only by `em slice ratify` (MIL-165); joined into `em export`'s `slice.doc.ratifiedOn` (schema `1.8`) |
70
- | `ratifiedRef` | string | full commit sha | written only by `em slice ratify` (MIL-284 — see [cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-ratify-file-slice-key---by-name)) when the model directory is inside a git repository: `HEAD` at ratification, the commit whose tree holds the body that was signed (ratify refuses a doc with uncommitted changes so this holds). Absent when ratified before 1.15 or outside git. Cleared by `em slice reratify`. Joined into `em export`'s `slice.doc.ratifiedRef` (schema `1.16`). Not a target-repo revision: `em slice conform --at` still names that itself |
71
- | `ratifiedHash` | string | `sha256:<64 hex>` | written only by `em slice ratify` (MIL-284): `sha256` over the doc body (everything after the frontmatter fence, EOLs normalised) — the signed content's identity without git. Cleared by `em slice reratify`. Read by `em validate --slice-ready` (`slice-ready-body-changed-since-ratification`); joined into `em export`'s `slice.doc.ratifiedHash` (schema `1.16`) |
70
+ | `ratifiedRef` | string | full commit sha | written only by `em slice ratify` (MIL-284 — see [cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-ratify-file-slice-key---by-name)) when the model directory is inside a git repository: `HEAD` at ratification, the commit whose tree holds the body that was signed (ratify refuses a doc with uncommitted changes so this holds). Absent when ratified before 1.15, outside git, or with `em slice ratify --no-ref` (GH #255 — for a repo whose squash/rebase merges would leave the commit unreachable from the target branch; `--no-ref` also removes a line already present). **An address, not the identity:** valid only while the commit stays reachable; `ratifiedHash` is what identifies the signed content. Cleared by `em slice revise`. Joined into `em export`'s `slice.doc.ratifiedRef` (schema `1.16`). Not a target-repo revision: `em slice conform --at` still names that itself |
71
+ | `ratifiedHash` | string | `sha256:<64 hex>` | written only by `em slice ratify` (MIL-284): `sha256` over the doc body (everything after the frontmatter fence, EOLs normalised) **minus what describes a later version** (GH #253, since 1.17.0): inside `## Open Questions` the heading line, blank lines and every `deferred to v<n>` item are left out, then trailing whitespace is trimmed — so `em slice defer` can record a question on a ratified or shipped doc without moving the hash, while answered `- [x]` history, any `- [ ]`, and every other section stay signed. The signed content's identity without git. A hash recorded before 1.17.0 (whole body) is still read as intact; `em upgrade`'s `ratified-hash-scope` step re-stamps it. Cleared by `em slice revise`. Read by `em validate --slice-ready` (`slice-ready-body-changed-since-ratification`) and by `ratify`'s same-sign-off re-run; joined into `em export`'s `slice.doc.ratifiedHash` (schema `1.16`) |
72
72
  | `shippedVersion` | integer | positive integer | written only by `em slice mark-implemented` (MIL-284): the doc's `version:` when the merge was recorded. With `shippedRef`/`shippedOn`/`implementedIn`, joined into `em export`'s `slice.doc.shipped` (schema `1.16`). Additive in 1.15 — `status`/`implementedIn` still carry the lifecycle for every reader |
73
- | `shippedRef` | string | full commit sha | written only by `em slice mark-implemented` (MIL-284): the doc's `ratifiedRef` at merge time, i.e. the ref the shipped version was signed at; absent when the doc had none |
73
+ | `shippedRef` | string | full commit sha | written only by `em slice mark-implemented` (MIL-284): the doc's `ratifiedRef` at merge time, i.e. the ref the shipped version was signed at; absent when the doc had none (ratified before 1.15, outside git, or with `--no-ref`, GH #255). Same caveat as `ratifiedRef`: an address, valid while reachable — `ratifiedHash` identifies the content |
74
74
  | `shippedOn` | string | `YYYY-MM-DD` | written only by `em slice mark-implemented` (MIL-284): the local date of the merge record, or `--on <date>` |
75
75
  | `meaningConfirmed` | boolean | `true` | written only by `em slice ratify --meaning-unchanged` (MIL-238 — see [cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-ratify-file-slice-key---by-name)): the API-first sign-off on a public-touching slice — this version does not change what the public contract means. Joined into `em export`'s `slice.doc.meaningConfirmed` (schema `1.15`; `false` when absent) |
76
76
  | `contractChange` | string | quoted free text (`contractChange: "<why>"`) | written only by `em slice ratify --contract-change "<why>"` (MIL-238): the API-first sign-off on a public-touching slice — why a consumer must read this change differently. Joined into `em export`'s `slice.doc.contractChange` (schema `1.15`, quotes stripped; `null` when absent) |
77
+ | `reviewSkipped` | string | a `status` value (`draft`, …) | written only by `em slice ratify --skip-review` (GH #260 — see [cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-ratify-file-slice-key---by-name)), and only when the bypass is what let the ratification through: the status the doc was ratified from. A ratification that passed the review gate writes nothing. Cleared by `em slice revise` with the rest of the sign-off. Joined into `em export`'s `slice.doc.reviewSkipped` (schema `1.18`, `null` when absent) and `em validate --slice-ready --json`'s top-level `reviewSkipped` (schema `1.3`) |
77
78
  | `owner` | string | free text (typically a person or team name) | hand-filled — no `em` command writes it; joined into `em export`'s `slice.doc.owner` (schema `1.9`, MIL-171), `em slice index`'s Owner column, and `em status`'s per-slice `owners[]` |
78
79
  | `tracking` | string | free text (typically an external ticket/issue URL) | hand-filled — no `em` command writes it; joined into `em export`'s `slice.doc.tracking` (schema `1.9`, MIL-171) and `em slice index`'s Tracking column. This is the exact field `em-tracker-bridge` reads to find the ticket mirroring this slice — `em` only stores and displays it, it never talks to a tracker itself |
79
80
  | `conformedVersion` | integer | positive integer | written only by `em slice conform` (MIL-214 — see [cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-conform-file-slice-key---at-rev)): this slice's `version:` at the time a conform sweep last certified it. Joined into `em export`'s `slice.doc.conformedVersion` (schema `1.13`); paired with `version` to compute `slice.doc.driftSignal`'s `"uncertified"` case |
80
- | `conformedAt` | string | free text (a target-repo revision, NOT a `<slice-key>@v<N>` lineage ref) | written only by `em slice conform` (MIL-214): the revision that certification sweep diffed against. Joined into `em export`'s `slice.doc.conformedAt` (schema `1.13`) and `em slice index`'s Conformed column |
81
+ | `conformedAt` | string | a target-repo revision, or `<kind>:<id>` (NOT a `<slice-key>@v<N>` lineage ref) | written only by `em slice conform` (MIL-214): the revision that certification sweep diffed against — or, since 1.17.0 (GH #261), an opaque identifier with an explicit kind (`build:1234`, `deploy:eu-1-2026-10-15`) for what was exercised when that is not a commit that stays reachable (a PR-branch HEAD under squash/rebase merges). A bare value is git (`parseConformedAt()`); reachability checks skip a kinded value. Joined into `em export`'s `slice.doc.conformedAt` (schema `1.13`) and `em slice index`'s Conformed column |
81
82
  | `conformedOn` | string | `YYYY-MM-DD` | written only by `em slice conform` (MIL-214). Joined into `em export`'s `slice.doc.conformedOn` (schema `1.13`) |
82
83
 
83
84
  Five keys — `schemaVersion`/`pattern`/`swimlane`/`status`/`version` — are what
@@ -87,6 +88,68 @@ over an omission — it reports). `implementedIn` and the lineage keys are the g
87
88
  optional ones; `implementedIn`'s required-once-implemented rule in the table below is
88
89
  convention, not parser-enforced.
89
90
 
91
+ ## Who may ratify
92
+
93
+ The schema records *who* signed (`reviewedBy`, `ratifiedBy`) but, by default, accepts any
94
+ non-empty name: who is allowed to sign is the host repo's decision. A host that wants em to
95
+ enforce it supplies an optional **roster**, `ratifiers.yaml`, beside the model. See
96
+ [examples/order-fulfillment/ratifiers.yaml](https://github.com/milehimikey/em/blob/main/examples/order-fulfillment/ratifiers.yaml).
97
+
98
+ ```yaml
99
+ rosterSchemaVersion: "1.0"
100
+ ratifiers:
101
+ - name: Aaron McKay
102
+ contexts: [Product, Attribute] # omit = the whole model
103
+ - name: Mike Key
104
+ - name: Dana Lee
105
+ models: [pim] # omit = every model the roster governs
106
+ reviewers: # optional; same shape, checked by `em slice review --by`
107
+ - name: Mike Key
108
+ ```
109
+
110
+ - **Schema.** `rosterSchemaVersion` is required (`"1.0"`); at least one of `ratifiers:` /
111
+ `reviewers:` is required; each is a non-empty list of `{ name, contexts?, models? }`. Unknown
112
+ keys are errors (`roster-invalid`). A missing `ratifiers:` / `reviewers:` key leaves that role
113
+ unrestricted.
114
+ - **Placement.** The nearest `ratifiers.yaml` walking up from the model's directory, stopping at
115
+ the nearest directory holding `.git` (or the filesystem root). If no `.git` exists anywhere
116
+ above the model, only the model's own directory is searched. `--roster <path>` on `ratify`,
117
+ `review`, `validate --slice-ready`, `roster check` overrides discovery; a path that does not
118
+ exist is an error, never "no roster".
119
+ - **A slice's contexts** are the contexts of its **events** plus the contexts of the events its
120
+ **views read** - each view instance's **own** `from`, never a union across the read model's
121
+ instances (adding a later `again` instance never changes an earlier slice's contexts). A
122
+ continuation slice also takes its originating instance's own `from`. A slice with neither has no
123
+ context and is permitted only by entries without `contexts`.
124
+ A continuation fed from a different context than its originating view (e.g. `tool-shows-on-loan` =
125
+ Loan + Tool) therefore needs a ratifier permitted for every one of those contexts, so a team with
126
+ one lead per context needs a joint or whole-model roster entry for such slices.
127
+ - **An entry permits a slice** when it applies to the model and either has no `contexts` or lists
128
+ **every** context of the slice: a cross-context slice needs a ratifier who may sign for all of
129
+ them (a leading `@` is tolerated in `contexts`).
130
+ - **Per-model scoping.** `models: [<modelKey>]` (the key `em export` reports as `model.key`) limits
131
+ an entry to those models; an entry without it applies to every model the roster governs. Context
132
+ names are matched **per model** against that model's declared contexts, so a shared root roster
133
+ needs `models:` whenever the models' ratifiers differ. A `models:` key the enclosing
134
+ `system.yaml` does not list is `roster-invalid`.
135
+ - **Validation against the model.** A `contexts:` entry the model does not declare (case-sensitive)
136
+ is `roster-invalid`, naming the context; only entries that apply to the model are checked.
137
+ - **File absent: today's behaviour**, no warning. **File present but invalid: fail closed** -
138
+ `ratify` and `review` refuse, `--slice-ready` and `roster check` report `roster-invalid`.
139
+ - **`grandfathered (unsigned before em 1.14)`** is em's own migration marker (`em upgrade`'s
140
+ `ratified-signoff`), not a signer: exempt from the `--slice-ready` check and from `roster check`
141
+ (which counts it) until the slice is re-ratified - but only the **exact** string, and only on a
142
+ doc with no `ratifiedHash` (the state `em upgrade` leaves). `grandfathered by X`, or the marker on
143
+ a doc that carries a hash, is a signer and is checked.
144
+ - **Where it is enforced.** At write time by `em slice ratify` / `em slice review` (the refusal
145
+ lists the permitted names); at check time by `em validate --slice-ready <key>`
146
+ (`ratified-by-not-in-roster`, error - one `ready-to-implement` slice, ratifier only) and by
147
+ `em roster check <model>` (every doc, `ratifiedBy` on `ready-to-implement` and `implemented`,
148
+ `reviewedBy` on any), the command `em ci init` wires into CI when a roster exists - see
149
+ [ci.md](ci.md#ratifier-roster-gate). `em status` reports `roster: present|absent|invalid`.
150
+ - `em roster init <model>` seeds the file from the names already in the docs
151
+ ([cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-roster-init-file)).
152
+
90
153
  ## Required vs optional, by `status`
91
154
 
92
155
  | Key | draft | reviewed | ready-to-implement | implemented |
@@ -98,6 +161,7 @@ convention, not parser-enforced.
98
161
  | `covers` | optional in every state — present only on a doc that deliberately also serves another slice (MIL-121, see below); most docs never carry it |
99
162
  | `reviewedBy`, `reviewedOn` | optional in every state — present once `em slice review` (MIL-201) has run at least once; a doc that never went through the review gate, or was hand-flipped to `reviewed`, simply omits both. `em slice ratify` never clears them; `em slice reratify` does (they describe the version that shipped) |
100
163
  | `ratifiedBy`, `ratifiedOn` | optional in every state, but `ready-to-implement` needs `ratifiedBy` to pass `em validate --slice-ready` (`slice-ready-not-ratified`, MIL-259) — present once `em slice ratify` (MIL-165) has run; `em slice reratify` clears both. `em upgrade` (`ratified-signoff`, 1.14) grandfathers a `version: 1` `ready-to-implement` doc that never had one by writing `ratifiedBy: "grandfathered (unsigned before em 1.14)"` and `ratifiedOn:` the upgrade date |
164
+ | `reviewSkipped` | optional in every state — present only when `em slice ratify --skip-review` is what let the ratification through (GH #260); the value is the status it skipped from. Written right after `ratifiedOn:`; cleared by `em slice revise` with the rest of the sign-off. Absent on every ratification that passed the review gate, and on docs ratified with `--skip-review` before 1.17.0 |
101
165
  | `meaningConfirmed`, `contractChange` | optional in every state, at most one present — written right after `ratifiedOn:` by `em slice ratify` and right after `version:` by `em slice reratify` (MIL-238). On a **public-touching** slice (one owning a `public` command, event or view) both commands refuse without `--meaning-unchanged` or `--contract-change "<why>"`, so a doc ratified on 1.14+ carries one; elsewhere either is optional. `em slice reratify` clears both before writing its own (they describe the prior version, same as `reviewedBy`/`ratifiedBy`). `em status` counts public-touching `ready-to-implement`/`implemented` docs with neither (`publicSlicesUnconfirmed`) |
102
166
  | `owner`, `tracking` | optional in every state — hand-filled whenever a team wants a who-holds-this / external-tracker link; most docs never carry either (MIL-171) |
103
167
  | `conformedVersion`, `conformedAt`, `conformedOn` | optional in every state — present once `em slice conform` (MIL-214) has run at least once for the CURRENT version; a doc that's never been through a conform sweep, or whose `version` has since bumped past what was certified, simply has none of the three (or a stale triple — see `driftSignal`'s `uncertified` case below) |
@@ -259,6 +323,21 @@ the union of events every later `again` instance of that view reads via `from`,
259
323
  order — so implementing the read model from one export never means walking every `again`
260
324
  slice's doc by hand to assemble the full event list.
261
325
 
326
+ The generated `em-slice-view` region follows the same rule (GH #280, 1.18.0): its `built from
327
+ events:` line lists the union of `from` across the originating instance and every `again`
328
+ instance (originating first, then timeline order, deduped), and each field's `from event` note
329
+ resolves against that union (each later event annotated `(via "<slice>")` with its instance's slice) — whichever instance's slice the doc is bound to. `em slice sync`
330
+ rewrites existing view regions accordingly.
331
+
332
+ **Synthesized continuations (GH #287).** A `view X again` line written inside a command's own slice
333
+ is lifted into a continuation column right after it. That column is a continuation like any other
334
+ (`continuationOf` names the view's originating slice, `alsoReads` counts its events) but exists
335
+ only as sugar over the host slice's text: its export key is `<host-slice-key>--again` (one column per host slice, its lifted lines stacked),
336
+ it never has a doc, and `em slice index` lists no row for it. A slice key never contains `/` (the slug generator emits single dashes only, so `--` cannot occur in a hand-written key); the `/` in an element ref `<slice-key>/<kind>.<slug>` is always the first and only one. A hand-written continuation slice
337
+ may also hold several `again` views, and may omit its name (auto-named `"<View> View: <Event>"`).
338
+ When one slice stacks views of different read models, `continuationOf` names the originating
339
+ slice of the FIRST view; the others are listed in their originating slices' `alsoReads` (with this slice's key as `atSlice`).
340
+
262
341
  **Authoring convention:** a continuation's behavior belongs in the originating doc's own
263
342
  `## Scenarios (Given / When / Then)` section — one scenario per event a later `again` instance
264
343
  feeds — rather than in a doc of its own; no new frontmatter is needed to record it.
@@ -395,7 +474,7 @@ re-run `em slice sync`.
395
474
  |---|---|---|
396
475
  | `em-slice-command` | `## Command / Input` | `**Command:** \`Name\`` + `\| Field \| Type \| Required \| Rules / Validation \|` (Required is `no` for a `name?: Type` field) |
397
476
  | `em-slice-event` | `## Event(s) Emitted` | `**Event:** \`Name\` → context \`Ctx\`` + `\| Field \| Type \| Immutable Fact? \| Source / Notes \|` (Source: the same-slice command field it is copied from, `assigned` for a system-assigned field, else `{{ }}`) |
398
- | `em-slice-view` | `## Read Model / View` | `- **View:** \`Name\` built from events: …` + `\| Field \| Type \| Source / Notes \|` (Source: the source event carrying the field, `Derived` for a `derived` field, else `{{ }}`) |
477
+ | `em-slice-view` | `## Read Model / View` | `- **View:** \`Name\` built from events: …` (the union across the originating and every `again` instance; each later event is annotated `(via "<slice>")` with the slice of the instance that adds it) + `\| Field \| Type \| Source / Notes \|` (Source: the source event, from that union, carrying the field, `Derived` for a `derived` field, `Collection of \`T\`, fed by …` for a `T[] derived from …` field — followed by one neutral Given/Then scenario stub per named event under the table, to copy into `## Scenarios` and complete there (the region itself stays read-only) — else `{{ }}`) |
399
478
  | `em-slice-invariants` | `## Invariants / Business Rules` | one `- **INV-X** — rule` line per model-declared invariant of the slice's commands and events |
400
479
 
401
480
  A slice with several elements of one kind gets one region per element, the name suffixed with
@@ -434,12 +513,22 @@ case is a block:
434
513
  - **Given:**
435
514
  - a basket whose total is 0
436
515
  - **When:**
437
- - the customer submits the order
516
+ - the customer issues PlaceOrder
438
517
  - **Then:**
439
518
  - the command is rejected with a validation error
440
519
  - no event is recorded
441
520
  ```
442
521
 
522
+ **Scenario quality (citation convention).** A scenario is tied to exactly one command: its When
523
+ names the slice's command (a reaction slice: the command it triggers), its Then names an event
524
+ the slice records or a rejection/error, and it **cites the `INV-…` ids it exercises** anywhere in
525
+ the block (the title above, or a Given/When/Then bullet). Every invariant declared for the slice
526
+ (an `invariant` line in the model, or the doc's Invariants section) should be cited by at least one
527
+ scenario. `em validate` advises on all three — `scenario-when-not-command`,
528
+ `scenario-then-not-outcome`, `invariant-without-scenario` — see
529
+ [validation.md](https://github.com/milehimikey/em/blob/main/docs/validation.md#scenario-quality). Older bullet-format scenarios are checked too; a doc with no scenarios is never
530
+ flagged.
531
+
443
532
  A `### Scenario: <title>` heading, then the three column-0 bullets `- **Given:**`, `- **When:**`,
444
533
  `- **Then:**`, each with nested ` - ` items (text after the label on the same line counts as a
445
534
  first item). `em export --json` publishes the parsed blocks as `slice.doc.scenarios`
@@ -490,7 +579,11 @@ not deleted: `em slice defer` checks it and rewrites it as `- [x] <original> —
490
579
  `em slice revise` (and `mark-implemented`, which opens v<n> at merge when something is deferred to it) reads: when the doc reaches v<n> it rewrites each such item back to
491
580
  `- [ ] <original>`, so the question must be resolved or re-deferred before `--slice-ready` passes
492
581
  again. The prune rule above does not apply to a deferred item before v<n> (it stays as the
493
- record); once reopened it is an ordinary open question.
582
+ record); once reopened it is an ordinary open question. A deferred item describes v<n>, not the
583
+ version that was signed, so it sits **outside `ratifiedHash`** (GH #253, with the section heading
584
+ and its blank lines; see the `ratifiedHash` row above) — which is what lets `em slice defer` write
585
+ one into a ratified or shipped doc. Every other line of the section — an answered `- [x]`, a hand-added
586
+ `- [ ]` — is inside the hash and moves it.
494
587
 
495
588
  **Not a parsing/grammar change.** `countOpenQuestions()` (`sliceDoc.ts`) and
496
589
  `slice-ready-open-questions-unchecked` (`sliceReadyValidate.ts`,
@@ -514,6 +607,13 @@ one it is asking about:
514
607
  slice shipped, and which" is `shippedRecordOf()` (`src/catalog/sliceDoc.ts`); `em export`
515
608
  publishes its answer as `slice.doc.shipped`.
516
609
 
610
+ **Reading a PR that shows `status: draft`.** When `mark-implemented` opened the next version
611
+ (`status: draft`, `version: <N+1>`), the diff of that slice doc does not say "never marked": the
612
+ `shippedVersion: <N>` / `implementedIn:` lines **are** the record that v<N> was implemented, and
613
+ `status:` is the state of v<N+1>. The command prints a notice naming both
614
+ ([cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-mark-implemented-file-slice-key-pr-url)), and `em status` lists the slice
615
+ as `implemented (v<N>) · draft v<N+1> open` rather than a bare `draft`.
616
+
517
617
  So a shipped slice can be a `draft` again. `em slice revise <key>`
518
618
  ([cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-revise-file-slice-key)) opens v<N+1> as `status: draft`, bumps
519
619
  `version:`, clears the prior version's review and sign-off, and leaves `implementedIn`/`shipped*`
@@ -521,6 +621,10 @@ alone — v<N> stays shipped. `em slice mark-implemented` does the same automati
521
621
  question was deferred to v<N+1> (`em slice defer`), so known work is on the list the moment the
522
622
  previous version lands. Version 2 then takes both human gates like version 1 did: `em slice review
523
623
  --by`, then `em slice ratify --by` (which records a fresh `ratifiedRef`/`ratifiedHash`).
624
+ A ratified doc that never shipped may instead be reopened at the **same** `version:` with
625
+ `em slice revise --withdraw --keep-version` (GH #262) — a correction before a first release, not a
626
+ delta, so no `## Delta` is owed; the status flip and sign-off clearing are the same. Refused on a
627
+ shipped doc: the shipped version keeps its number.
524
628
 
525
629
  The deliberate mismatch — `version: 2` open while `implementedIn`/`shippedVersion` still name v1's
526
630
  work — is not staleness, it's the **drift signal**: `em export`'s `slice.doc.driftSignal` is
@@ -545,14 +649,17 @@ ratification of v<N> is withdrawn and nothing shipped, so no shipped record is w
545
649
  withdraws the only implementable version, `em slice revise` **refuses it without `--withdraw`**
546
650
  (GH #236).
547
651
 
548
- **Questions found against a ratified or shipped version are queued, not written into the body**
549
- (GH #236). `ratifiedHash` covers the whole body, `## Open Questions` included, so `em slice defer` on
550
- a `ready-to-implement` + `ratifiedBy:` or `implemented` doc does not edit the doc: it records the
551
- question in the model's `.event-modeling.md` as queued for `<key>@v<N+1>` (exact bullet shape in
552
- [cli.md](https://github.com/milehimikey/em/blob/main/docs/cli.md#em-slice-defer-file-slice-key-question)), keeping `ratifiedHash` and `--slice-ready`
553
- valid. When v<N+1> opens as a draft — `mark-implemented` at merge, or `revise` — each queued item is
554
- injected into that draft's `## Open Questions` (unchecked, carrying its decision) and the queue is
555
- cleared. `em export` reports the waiting count as `slice.doc.queuedForNext` (schema `1.17`). **A
652
+ **Questions found against a ratified or shipped version are written into the body, outside the
653
+ hash** (GH #253, superseding GH #236's 1.16 queue). `ratifiedHash` leaves out the `## Open Questions`
654
+ heading and its `deferred to v<n>` items, so `em slice defer` on a `ready-to-implement` +
655
+ `ratifiedBy:` or `implemented` doc appends the already-deferred item
656
+ `- [x] <question> — v<N>: <decision>; deferred to v<n> (<date>[, <by>])` to the doc — visible to
657
+ every reader of the ratified doc — and `ratifiedHash`, `--slice-ready` and `ratify`'s re-run all
658
+ stay valid. When v<n> opens as a draft — `mark-implemented` at merge, or `revise` — the item is
659
+ reopened as `- [ ] <question>` exactly as a pre-ratification deferral is. A question `em slice
660
+ defer` queued in `.event-modeling.md` under 1.16.x is still injected when the next draft opens, and
661
+ `em upgrade`'s `ratified-hash-scope` step moves any leftover into its doc. `em export` reports the
662
+ work waiting on later versions as `slice.doc.queuedForNext` (schema `1.17`). **A
556
663
  `ready-to-implement` doc with no `ratifiedBy`** is the leftover of a pre-1.15 `reratify` (which
557
664
  bumped the version and left the doc unsigned at that status); no command produces it any more and
558
665
  `em slice ratify` no longer accepts it — `em slice revise` reopens it as a `draft` at the same
@@ -209,15 +209,23 @@ an event directly.}}
209
209
  --json` → slice.doc.scenarios). Cover the happy path AND the key rule boundaries, one block
210
210
  per case: a `### Scenario: <title>` heading, then exactly the three column-0 bullets
211
211
  `- **Given:**`, `- **When:**`, `- **Then:**`, each with its beats as nested ` - ` bullets.
212
- A block missing any of the three is flagged `slice-doc/structured-section-malformed`. -->
212
+ A block missing any of the three is flagged `slice-doc/structured-section-malformed`.
213
+ Quality (advisory warnings): each scenario is tied to exactly ONE command — its When names
214
+ this slice's command (a reaction slice: the reaction, its view, or the command it triggers); its Then names an event (or a stated no-op)
215
+ this slice records, or a rejection/error; and it CITES the INV ids it exercises (in the
216
+ title or any bullet). Every INV declared for the slice should be cited by some scenario
217
+ (`scenario-when-not-command`, `scenario-then-not-outcome`, `invariant-without-scenario`). -->
213
218
  ### Scenario: Happy path
214
219
  - **Given:**
215
220
  - {{starting state / prior events}}
216
221
  - **When:**
217
- - {{command/trigger}}
222
+ - {{the command, by name}}
218
223
  - **Then:**
219
- - {{event(s) recorded}}
224
+ - {{the event(s) recorded, by name}}
220
225
  - {{resulting read-model change}}
226
+ <!-- Add one block per rule boundary, citing the INV id in the title, e.g.
227
+ `### Scenario: Non-positive total is rejected (INV-CHK-1)` — When names the command, Then
228
+ names the rejection. -->
221
229
 
222
230
  ## Alternate & Error Flows
223
231
  <!-- Failure paths, retries, compensations, timeouts, idempotency. -->
@@ -1,9 +1,9 @@
1
1
  {
2
- "name": "em-1-16-1",
2
+ "name": "em-1-18-0",
3
3
  "owner": {
4
4
  "name": "Mike Key"
5
5
  },
6
- "description": "em v1.16.1: the Event Modeling skill bundle and MCP server as a Claude Code plugin.",
6
+ "description": "em v1.18.0: the Event Modeling skill bundle and MCP server as a Claude Code plugin.",
7
7
  "plugins": [
8
8
  {
9
9
  "name": "em",
@@ -73,7 +73,9 @@ export interface SliceDocExport {
73
73
  ratifiedRef: string | null;
74
74
  /** MIL-284: `sha256:<hex>` over the doc body at ratification (frontmatter `ratifiedHash:`),
75
75
  * written only by `em slice ratify` — null when absent. `--slice-ready` compares it to the
76
- * current body (`slice-ready-body-changed-since-ratification`). */
76
+ * current body (`slice-ready-body-changed-since-ratification`). Since 1.17.0 the `## Open
77
+ * Questions` heading and its `deferred to v<n>` items are outside the hash (GH #253,
78
+ * `sliceDoc.ts`'s `ratifiedBody`); a pre-1.17 whole-body hash is still accepted as intact. */
77
79
  ratifiedHash: string | null;
78
80
  /** MIL-283/284: the shipped record — `em slice mark-implemented`'s `shippedVersion:`/
79
81
  * `shippedRef:`/`shippedOn:` beside `implementedIn:`, or, for a doc shipped before em 1.15
@@ -107,14 +109,20 @@ export interface SliceDocExport {
107
109
  * differently (`--contract-change "<why>"`); null when absent. At most one of
108
110
  * `meaningConfirmed`/`contractChange` is set by em's own writers. */
109
111
  contractChange: string | null;
112
+ /** GH #260 (schema 1.18): frontmatter `reviewSkipped:` — the status `em slice ratify
113
+ * --skip-review` ratified from, when that bypass is what let the ratification through. Null
114
+ * when the ratification passed the review gate, when the doc predates 1.17, and whenever no
115
+ * doc was found. A host gate reads it to fail or warn on an unreviewed ratification. */
116
+ reviewSkipped: string | null;
110
117
  /** MIL-266: the doc's authored `### Scenario:` blocks (catalog/scenarios.ts), each as
111
118
  * `{ title, given, when, then }` string arrays, in document order. Null when the doc has no
112
119
  * well-formed block (every 1.13-style doc) or isn't found / usable. */
113
120
  scenarios: Scenario[] | null;
114
- /** GH #236: how many questions `em slice defer` has QUEUED for this slice's next version
115
- * (`.event-modeling.md` parking lot, catalog/deferQueue.ts) — known work for v<version+1> that
116
- * a ratified/shipped doc could not take without breaking its sign-off. 0 when none, when the
117
- * state file is absent, and whenever no doc was found. */
121
+ /** Known work waiting on a later version of this slice: the doc's `## Open Questions` items
122
+ * deferred to a version past `version` (GH #253, `countDeferredBeyond`), plus any question
123
+ * GH #236's 1.16 state-file queue still holds for v<version+1> (catalog/deferQueue.ts) until
124
+ * `em upgrade`'s `ratified-hash-scope` step or the next `revise`/`mark-implemented` drains it.
125
+ * 0 when none, and whenever no doc was found. */
118
126
  queuedForNext: number;
119
127
  }
120
128
  export interface SliceDocJoinResult {
@@ -35,6 +35,7 @@
35
35
  // one) to tell "extra" from "dangling" from "unratified". It reuses `NOTE_SLICE_PATH` and
36
36
  // `resolveCrossCandidate` below rather than re-deriving the ratification predicate.
37
37
  import { queuedCount } from "./deferQueue.js";
38
+ import { countDeferredBeyond } from "./sliceDoc.js";
38
39
  import { parseScenarios } from "./scenarios.js";
39
40
  import { continuationOf } from "../model/continuation.js";
40
41
  import { makeDiag } from "../model/rules.js";
@@ -83,6 +84,7 @@ const EMPTY_CONTENT = {
83
84
  conformedOn: null,
84
85
  meaningConfirmed: false,
85
86
  contractChange: null,
87
+ reviewSkipped: null,
86
88
  scenarios: null,
87
89
  queuedForNext: 0,
88
90
  };
@@ -204,8 +206,11 @@ function foundDoc(path, parsed, baseDir, docKey) {
204
206
  conformedOn: parsed.conformedOn,
205
207
  meaningConfirmed: parsed.meaningConfirmed,
206
208
  contractChange: parsed.contractChange,
209
+ reviewSkipped: parsed.reviewSkipped,
207
210
  scenarios: scenariosOf(parsed.body),
208
- queuedForNext: queuedCount(baseDir, docKey, parsed.version),
211
+ // GH #253: the doc carries its own deferrals now; the state-file count is the 1.16 queue's
212
+ // leftovers until `em upgrade` (or the next `revise`/`mark-implemented`) drains them.
213
+ queuedForNext: countDeferredBeyond(parsed.body, parsed.version) + queuedCount(baseDir, docKey, parsed.version),
209
214
  };
210
215
  }
211
216
  function scenariosOf(body) {