@sublang/playbook 15.1.0 → 16.0.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 (76) hide show
  1. package/docs/embedding.md +2 -2
  2. package/package.json +1 -1
  3. package/reference/sdlc/branch.playbook/branch.fsm.d.ts +63 -33
  4. package/reference/sdlc/branch.playbook/branch.fsm.js +190 -108
  5. package/reference/sdlc/branch.playbook/branch.fsm.ts +269 -147
  6. package/reference/sdlc/branch.playbook/branch.gears.md +7 -17
  7. package/reference/sdlc/branch.playbook/branch.playbook.d.ts +12 -16
  8. package/reference/sdlc/branch.playbook/branch.playbook.js +112 -101
  9. package/reference/sdlc/branch.playbook/branch.playbook.ts +128 -171
  10. package/reference/sdlc/branch.playbook/branch.registry.d.ts +3 -2
  11. package/reference/sdlc/branch.playbook/branch.registry.ts +6 -2
  12. package/reference/sdlc/code.playbook/code.fsm.d.ts +143 -90
  13. package/reference/sdlc/code.playbook/code.fsm.introspect.d.ts +8 -8
  14. package/reference/sdlc/code.playbook/code.fsm.introspect.ts +13 -13
  15. package/reference/sdlc/code.playbook/code.fsm.js +609 -649
  16. package/reference/sdlc/code.playbook/code.fsm.ts +890 -821
  17. package/reference/sdlc/code.playbook/code.gears.md +39 -29
  18. package/reference/sdlc/code.playbook/code.playbook.d.ts +13 -16
  19. package/reference/sdlc/code.playbook/code.playbook.js +166 -147
  20. package/reference/sdlc/code.playbook/code.playbook.ts +180 -229
  21. package/reference/sdlc/code.playbook/code.registry.d.ts +3 -2
  22. package/reference/sdlc/code.playbook/code.registry.ts +6 -2
  23. package/reference/sdlc/code.playbook/playbook-captain.d.ts +42 -0
  24. package/reference/sdlc/code.playbook/playbook-captain.js +829 -194
  25. package/reference/sdlc/code.playbook/playbook-captain.ts +1227 -220
  26. package/reference/sdlc/decide.md +1 -0
  27. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +270 -154
  28. package/reference/sdlc/decide.playbook/decide.fsm.js +765 -732
  29. package/reference/sdlc/decide.playbook/decide.fsm.ts +1167 -945
  30. package/reference/sdlc/decide.playbook/decide.gears.md +28 -21
  31. package/reference/sdlc/decide.playbook/decide.playbook.d.ts +11 -59
  32. package/reference/sdlc/decide.playbook/decide.playbook.js +155 -3696
  33. package/reference/sdlc/decide.playbook/decide.playbook.ts +186 -5244
  34. package/reference/sdlc/decide.playbook/decide.registry.d.ts +8 -4
  35. package/reference/sdlc/decide.playbook/decide.registry.js +2 -2
  36. package/reference/sdlc/decide.playbook/decide.registry.ts +13 -6
  37. package/reference/sdlc/dev.playbook/dev.fsm.d.ts +113 -131
  38. package/reference/sdlc/dev.playbook/dev.fsm.js +517 -575
  39. package/reference/sdlc/dev.playbook/dev.fsm.ts +667 -787
  40. package/reference/sdlc/dev.playbook/dev.gears.md +52 -54
  41. package/reference/sdlc/dev.playbook/dev.playbook.d.ts +13 -10
  42. package/reference/sdlc/dev.playbook/dev.playbook.js +128 -120
  43. package/reference/sdlc/dev.playbook/dev.playbook.ts +143 -193
  44. package/reference/sdlc/dev.playbook/dev.registry.d.ts +3 -2
  45. package/reference/sdlc/dev.playbook/dev.registry.ts +6 -2
  46. package/reference/sdlc/pr.playbook/pr.fsm.d.ts +92 -85
  47. package/reference/sdlc/pr.playbook/pr.fsm.js +461 -518
  48. package/reference/sdlc/pr.playbook/pr.fsm.ts +533 -663
  49. package/reference/sdlc/pr.playbook/pr.gears.md +47 -63
  50. package/reference/sdlc/pr.playbook/pr.playbook.d.ts +13 -23
  51. package/reference/sdlc/pr.playbook/pr.playbook.js +118 -112
  52. package/reference/sdlc/pr.playbook/pr.playbook.ts +136 -190
  53. package/reference/sdlc/pr.playbook/pr.registry.d.ts +3 -2
  54. package/reference/sdlc/pr.playbook/pr.registry.ts +4 -2
  55. package/reference/sdlc/review.md +3 -3
  56. package/reference/sdlc/review.playbook/review.fsm.d.ts +150 -116
  57. package/reference/sdlc/review.playbook/review.fsm.js +479 -550
  58. package/reference/sdlc/review.playbook/review.fsm.ts +717 -662
  59. package/reference/sdlc/review.playbook/review.gears.md +32 -29
  60. package/reference/sdlc/review.playbook/review.playbook.d.ts +12 -12
  61. package/reference/sdlc/review.playbook/review.playbook.js +180 -155
  62. package/reference/sdlc/review.playbook/review.playbook.ts +190 -230
  63. package/reference/sdlc/review.playbook/review.registry.d.ts +6 -5
  64. package/reference/sdlc/review.playbook/review.registry.js +3 -3
  65. package/reference/sdlc/review.playbook/review.registry.ts +9 -5
  66. package/slc/gears2fsm.md +72 -3
  67. package/slc/link.md +50 -27
  68. package/slc/materialize-link.mjs +51 -13
  69. package/slc/optimize.md +4 -1
  70. package/slc/prefix-prompts.mjs +29 -28
  71. package/slc/prefix.md +27 -24
  72. package/slc/slc.pin-inputs.json +11 -2
  73. package/slc/text2gears.md +71 -11
  74. package/src/xstate-playbook-runtime.d.ts +54 -15
  75. package/src/xstate-playbook-runtime.js +1154 -248
  76. package/src/xstate-playbook-runtime.ts +1603 -317
package/slc/text2gears.md CHANGED
@@ -157,13 +157,37 @@ Keep each declaration outside plain-text parentheses; explanatory symbols in
157
157
  parenthetical guidance use plain text, never separate backticks, because those
158
158
  backticks would declare extra required fields. Guidance may instead occur
159
159
  inside a field's complete annotation, including any parentheses there.
160
- For example, use `` `codeCommit` (new code-owned commit) `` or
161
- `` `codeCommit: <new code-owned commit>` ``, without backticks around code.
160
+ For example, use `` `latestCommit` (new code-owned commit) `` or
161
+ `` `latestCommit: <commit identity>` ``, without backticks around code.
162
+ The commit a call itself creates is always declared as `latestCommit`, the
163
+ canonical effect-owned property every linked runtime fills from the
164
+ repository receipt and every terminal output projects from.
162
165
  An output property name shall match the same ASCII identifier pattern as a
163
166
  guard name: a kebab-case Source placeholder such as `<coder-output>` names the
164
167
  property `coderOutput` through the canonical kebab-token-to-camel-field mapping
165
168
  of [link](link.md), never a quoted kebab-case key, because downstream artifacts
166
169
  and calling playbooks consume these properties by name.
170
+ A result shall declare an output property only where a consumer requires it:
171
+ a later item's `<placeholder>`, the workflow's terminal return, or the
172
+ workflow's declared public interface below.
173
+ A detail the acting agent reports only within its final text — a reason, a
174
+ summary, a list — travels in the result's verbatim final-text property and is
175
+ not a separate judge-authored property.
176
+
177
+ Where the selected pipeline supplies the
178
+ [workflow contracts](workflow-contracts.json) catalog and the Source's basename
179
+ is one of its `literalTargetBindings`, the compiled workflow is held to that
180
+ builtin's declared output interface, because callers compiled against the
181
+ catalog address it by that id: a result property whose value that interface
182
+ returns shall take the interface's property name — `branch`, `issueSummary`,
183
+ and `coderOutput` for `branch`; `evaluatedRevision` for the revision a clean
184
+ review round evaluated — whether the value is semantic, presentation, or
185
+ effect-owned, while the commit a call itself creates keeps the canonical
186
+ `latestCommit` for the FSM to project into the interface's field.
187
+ A Source placeholder that names such a value otherwise is an inconsistency
188
+ between the Source and the catalog: leave the Target unwritten and report it
189
+ as an incompatible compiler input rather than rename or invent.
190
+ A Source outside those ids is named from its own words as above.
167
191
 
168
192
  A produced value consumed later shall have a declared producer: where any
169
193
  later item's blockquote reads a value through a `<placeholder>`, the item
@@ -172,14 +196,37 @@ whose relevant description names the produced output property, using the
172
196
  placeholder's exact identifier — this is what lets the FSM thread the value
173
197
  through typed context.
174
198
  A single-outcome producer then declares exactly one bullet naming the
175
- property; this consumed-output case is the sole one in which a
176
- single-outcome behavior carries a `Results:` label.
199
+ property; this consumed-output case and the qualified-outcome case below are
200
+ the two in which a single-outcome behavior carries a `Results:` label.
201
+ The commit a call itself creates is the one exception to naming the property
202
+ after the placeholder: its producer declares `latestCommit: <commit identity>`
203
+ whatever placeholder a later prompt reads it through — `<code-commit>` or
204
+ `<decide-commit>`, for instance — because the linked runtime fills that
205
+ property from the repository receipt rather than from the player, and
206
+ [gears2fsm](gears2fsm.md#context-and-prompts) binds the Source's placeholder
207
+ to the retained commit.
208
+ A placeholder the Source defines as a labelled section of another relayed
209
+ value, naming the label that opens the section and the labels that end it —
210
+ `<original-intent>` as the `Original intent:` section of the caller's request,
211
+ which runs to the `Review scope:` line or to the end of the request, for
212
+ instance — is derived, not produced: text2gears shall keep that defining
213
+ sentence verbatim in the package introduction, or in the item's prose where the
214
+ Source states it there, name the placeholder as the Source does, and declare no
215
+ result property for it, because no player produces the value and
216
+ [gears2fsm](gears2fsm.md#context-and-prompts) derives it from the relayed text.
177
217
 
178
218
  Where a later prompt relays a delegated player's whole final response as quoted context, the producer shall declare that property in the exact annotated form `` `<field>: <verbatim final text>` ``.
179
219
  The annotation makes the field runtime-owned: the adjudicator selects the result guard, while the linked runtime carries the player's canonical final text into that field instead of asking a judge to reproduce it.
180
220
  A distinct typed field extracted from that response remains judge-authored even when a later prompt quotes its exact value; quoting a field does not turn it into the player's whole final response.
181
221
  One property name shall not be annotated as verbatim in one result contract and judge-authored in another; text2gears shall choose distinct properties or report that the Source cannot be represented by the current contract.
182
222
 
223
+ A Source statement that qualifies an outcome's evidence — what affirmatively
224
+ supports it, what supports no outcome, such as "a progress report, status
225
+ update, or promise of a later result supports no review outcome" — shall be
226
+ carried in that outcome's result description, the only text the adjudicator
227
+ reads when it selects the guard; left in the item's prose, it reaches no
228
+ judge.
229
+
183
230
  Result metadata is compiler control data, not part of the acting agent's
184
231
  prompt.
185
232
  text2gears shall not put guard names, result-property schema, JSON control
@@ -194,12 +241,16 @@ Where Source restricts an initial Captain to routing, text2gears shall preserve
194
241
  only the authored question and delegation outcomes and shall not infer a
195
242
  direct-answer or terminal result merely because Captain is the acting agent.
196
243
 
197
- A single-outcome behavior whose output no later item consumes carries no
198
- `Results:` label; downstream,
244
+ A single-outcome behavior whose output no later item consumes and whose
245
+ outcome Source leaves unqualified carries no `Results:` label; downstream,
199
246
  [gears2fsm](gears2fsm.md#setup) gives its state the default single-outcome
200
247
  contract, so text2gears shall not invent a one-bullet `Results:` block for it.
201
248
  When a later item does consume its output, the produced-value rule above
202
- applies instead.
249
+ applies instead; when Source qualifies the one outcome's evidence — what
250
+ affirmatively supports it, what supports no outcome — the behavior carries
251
+ exactly one `Results:` bullet naming that outcome and carrying the
252
+ qualification, with an output property only where a consumer requires one,
253
+ because the adjudicator reads the qualification nowhere else.
203
254
 
204
255
  When Source requires a terminal return to the caller, preserve every returned value or fact and its return condition as an explicit workflow output obligation in GEARS.
205
256
  Merely naming a value in a completion predicate or an acting result does not state that the workflow returns it.
@@ -215,10 +266,16 @@ when the answer changes its complete runtime prompt. It shall not emit a
215
266
  second item solely for "Boss answers," "after the question," or clearing the
216
267
  consumed question/reply. The FSM and linker own the same-leaf suspension,
217
268
  continuation blocks, and consumed-context cleanup.
218
- When such an authored result asks Boss and waits, its `Results:` description
219
- shall declare `question: <verbatim final text>` as an output property; the
220
- result name or prose saying that a question is asked is not the field
221
- declaration.
269
+ Outside the decide-call-observe routing contract, an authored Boss question
270
+ is the framework-owned `needsBossReply` outcome that
271
+ [gears2fsm](gears2fsm.md#boss-reply-suspension) adds to every Captain- or
272
+ player-invoking state: text2gears shall keep the question's conditions in the
273
+ prompt and its continuation in the item's prose and shall declare no result
274
+ for it, because a second guard for the same wait would give the adjudicator
275
+ two equivalent outcomes.
276
+ Only the routing contract's own `question` and `followUpQuestion` results
277
+ declare the question, as `question: <verbatim final text>`; there, the result
278
+ name or prose saying that a question is asked is not the field declaration.
222
279
 
223
280
  This rule is an exception to splitting by accumulated prompt content below.
224
281
  Split only when Source requires a genuinely different acting behavior after
@@ -395,6 +452,9 @@ Markdown escaping is Source syntax, not content: extraction shall resolve escape
395
452
 
396
453
  Partition items by every variable that determines prompt content — including accumulated state when the trigger alone doesn't.
397
454
 
455
+ Conversely, do not split by trigger alone: where two or more triggers lead to one behavior with the same acting clause, prompt, and result contract — a nested call Source says a later path makes "with the same input as" an earlier path's, for instance — text2gears shall emit one item whose condition joins the triggers and shall keep each path's continuation as that item's prose.
456
+ An item per trigger duplicates an identical prompt and multiplies the FSM's states without a content difference.
457
+
398
458
  ### Prune dead disjuncts
399
459
 
400
460
  Drop disjunctive branches incompatible with the rest of an item's condition or prompt.
@@ -63,7 +63,7 @@ export interface RuntimeBoundaryCalls {
63
63
  * with the cause the boundary decided at the call itself, where the role,
64
64
  * the resolved player, and the reported error are known.
65
65
  */
66
- markPlayerResultFailure?(error: Error): Error;
66
+ markPlayerResultFailure?(error: Error, result?: PlayerResult): Error;
67
67
  callJudge(purpose: JudgePurpose, stateId: string | undefined, prompt: string, signal: AbortSignal): Promise<string>;
68
68
  callCaptain?(input: PlaybookCaptainInput, prompt: string, signal: AbortSignal, callOptions?: XStateCaptainCallOptions): Promise<CaptainResult>;
69
69
  }
@@ -125,17 +125,18 @@ export declare function playerFailureCause(input: {
125
125
  /**
126
126
  * DR-063 §1: the cause of an unresolved governed settlement. A reconciled
127
127
  * mismatch supplies its own receipt-read cause; the reasons a runtime owns map
128
- * to adjudication, abort, and runtime-defect codes. Shared with DECIDE's
129
- * bespoke runtime, which decides the same reasons.
128
+ * to adjudication, abort, and runtime-defect codes. Exported so linked
129
+ * machinery of an artifact's own decides the same reasons.
130
130
  */
131
131
  export declare function governedSettlementCause(reason: string, error: unknown, aborted: boolean, supplied: PlaybookFailureCause | undefined): PlaybookFailureCause;
132
132
  /**
133
133
  * DR-063 §2: the causes decided for thrown values that cannot carry the
134
- * marker — a string, a frozen error — kept by identity for as long as the
135
- * failure stands, so every surface that reads the FSM's own `lastError`
136
- * publishes the cause decided for exactly that value, whatever turn reads it.
137
- * A value that carries the marker answers from it; the map is bounded, since
138
- * only values that refuse the marker need an entry.
134
+ * marker — a string, a frozen error — and for the record a machine keeps in
135
+ * place of the thrown value, kept by identity for as long as the failure
136
+ * stands, so every surface that reads the FSM's own `lastError` publishes the
137
+ * cause decided for exactly that failure, whatever turn reads it. A value
138
+ * that carries the marker answers from it; the map is bounded, since only
139
+ * values that lack the marker need an entry.
139
140
  */
140
141
  export interface PlaybookFailureCauseRetention {
141
142
  retain(error: unknown, cause: PlaybookFailureCause): void;
@@ -195,6 +196,17 @@ interface XStateRepositoryDeferredRestoreResult {
195
196
  readonly effectLedger: PlaybookEffectLedger;
196
197
  }
197
198
  type XStateEffectBoundarySeed = Omit<PlaybookEffectBoundaryStart, 'playbookId' | 'canonicalWorktree' | 'baseline' | 'cohortId'>;
199
+ /** One member's completion inside a repository cohort (DR-067 §1). */
200
+ type XStateRepositoryCohortCompletion<T> = XStateRepositoryExclusiveCompletion<T> & {
201
+ readonly roleId: string;
202
+ };
203
+ interface XStateRepositoryCohortResult<T> {
204
+ readonly baseline: PlaybookRepositoryReceipt['baseline'];
205
+ readonly invocationId: string;
206
+ readonly operations: Readonly<Record<string, XStateRepositoryOperationSettlement<T> | XStateRepositoryOperationRejection>>;
207
+ readonly receipts: Readonly<Record<string, PlaybookRepositoryReceipt>>;
208
+ readonly effectLedger: PlaybookEffectLedger;
209
+ }
198
210
  export interface XStateRepositoryCapability {
199
211
  runExclusive<T>(options: {
200
212
  readonly signal: AbortSignal;
@@ -222,6 +234,27 @@ export interface XStateRepositoryCapability {
222
234
  readonly signal: AbortSignal;
223
235
  readonly operationId: string;
224
236
  }): Promise<XStateRepositoryDeferredParked | XStateRepositoryDeferredRestoreResult>;
237
+ /**
238
+ * DR-067 §1 / PBRT-73: one repository claim over the working leaves of a
239
+ * parallel state entered together — every member an `unchanged` boundary
240
+ * of one cohort, the operations run concurrently under that claim, and
241
+ * one completion callback per member. Required for an artifact that
242
+ * declares a parallel state.
243
+ */
244
+ runCohort?<T>(options: {
245
+ readonly signal: AbortSignal;
246
+ readonly invocationId: string;
247
+ readonly roleIds: readonly string[];
248
+ readonly dispositionsByRole: Readonly<Record<string, readonly ['unchanged']>>;
249
+ readonly effectBoundaries: Readonly<Record<string, XStateEffectBoundarySeed>>;
250
+ readonly operations: Readonly<Record<string, (context: {
251
+ readonly baseline: PlaybookRepositoryReceipt['baseline'];
252
+ readonly identity: unknown;
253
+ readonly invocationId: string;
254
+ readonly roleId: string;
255
+ }) => Promise<T>>>;
256
+ readonly completeEffectBoundary: (completion: XStateRepositoryCohortCompletion<T>) => XStateRepositoryCompletionEvidence | Promise<XStateRepositoryCompletionEvidence>;
257
+ }): Promise<XStateRepositoryCohortResult<T>>;
225
258
  }
226
259
  /** The runtime ABI this engine implements (DR-022). */
227
260
  export declare const RUNTIME_ABI = 1;
@@ -458,8 +491,8 @@ export declare function defaultBuildJudgePrompt(input: PlaybookPlayerInput, fina
458
491
  * so the judge omits it. Rendering the clause verbatim asked the judge for
459
492
  * `question`, `planningResult`, or `evaluatedRevision`, which the reconciler
460
493
  * rejects as a structural error, spending the single correction on a
461
- * self-inflicted defect. Exported so a bespoke linked runtime (DECIDE's
462
- * parallel machinery) renders the identical contract instead of restating it.
494
+ * self-inflicted defect. Exported so linked machinery of an artifact's own
495
+ * renders the identical contract instead of restating it.
463
496
  */
464
497
  export declare function renderGovernedOutcomeContract(guard: string, description: string, outcome: XStateGovernedOutcomeSpec | undefined): string[];
465
498
  export interface PlayerAdjudicationSpec {
@@ -495,7 +528,11 @@ export declare function defaultBuildCaptainJudgePrompt(input: {
495
528
  readonly sourceItem: string;
496
529
  readonly result: Readonly<Record<string, string>>;
497
530
  }, finalText: string): string;
498
- /** Targets of the FSM's `awaitBossReply` BOSS_REPLY transitions. */
531
+ /**
532
+ * Targets of the FSM's `awaitBossReply` BOSS_REPLY transitions, plus — for
533
+ * the parallel shape gears2fsm compiles (DR-067) — the targets of each
534
+ * region wait leaf's branch-local BOSS_REPLY arms, resolved to state ids.
535
+ */
499
536
  export declare function resumableStateIdsFromMachine(machine: AnyStateMachine): ReadonlySet<string>;
500
537
  /**
501
538
  * Source state descriptions by state key, node id, and `meta.playbook`
@@ -524,10 +561,12 @@ export declare function terminalOutcomesFromMachine(machine: AnyStateMachine, la
524
561
  * the optional parked-session snapshot capability (DR-014) and the retained-
525
562
  * snapshot adoption capability (DR-038).
526
563
  *
527
- * Scope: flat single-region machines — no parallel state, no compound
528
- * child states, and every root state's `meta.playbook.stateId` equal to its
529
- * state key — so each snapshot exposes exactly one playbook state id.
530
- * Parallel-region FSMs keep their own linked runtimes.
564
+ * Scope: flat single-region machines — every root state's
565
+ * `meta.playbook.stateId` equal to its state key, so each snapshot exposes
566
+ * exactly one playbook state id — plus the parallel profile of DR-067: root
567
+ * `type: 'parallel'` states of the shape gears2fsm compiles, whose regions
568
+ * run as one all-`unchanged` repository cohort with keyed pending questions.
569
+ * A machine declaring a parallel state omits `adopt`.
531
570
  */
532
571
  export declare function createXStatePlaybookRuntime<TOptions, THostCapabilities extends object>(machine: AnyStateMachine, spec: XStatePlaybookRuntimeSpecV3<TOptions>): XStatePlaybookRuntimeFactory<XStatePlaybookRuntimeConstruction<TOptions, THostCapabilities>, 3>;
533
572
  export {};