@sublang/playbook 13.3.0 → 14.1.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 (56) hide show
  1. package/README.md +5 -5
  2. package/docs/cli.md +14 -14
  3. package/docs/configuration.md +10 -2
  4. package/docs/embedding.md +20 -1
  5. package/package.json +6 -1
  6. package/reference/sdlc/branch.playbook/branch.fsm.d.ts +1 -1
  7. package/reference/sdlc/code.playbook/bin/launch-config.js +88 -5
  8. package/reference/sdlc/code.playbook/bin/playbook.js +4 -0
  9. package/reference/sdlc/code.playbook/bin/repository-effects.js +198 -17
  10. package/reference/sdlc/code.playbook/bin/run.js +4 -0
  11. package/reference/sdlc/code.playbook/bin/session-store.js +2 -2
  12. package/reference/sdlc/code.playbook/code.fsm.d.ts +1 -1
  13. package/reference/sdlc/code.playbook/host-capabilities.d.ts +6 -0
  14. package/reference/sdlc/code.playbook/playbook-captain.d.ts +3 -1
  15. package/reference/sdlc/code.playbook/playbook-captain.js +374 -20
  16. package/reference/sdlc/code.playbook/playbook-captain.ts +478 -38
  17. package/reference/sdlc/code.playbook/session-host.d.ts +6 -3
  18. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +1 -1
  19. package/reference/sdlc/decide.playbook/decide.playbook.js +25 -1
  20. package/reference/sdlc/decide.playbook/decide.playbook.ts +35 -2
  21. package/reference/sdlc/dev.md +15 -8
  22. package/reference/sdlc/dev.playbook/dev.fsm.d.ts +1 -1
  23. package/reference/sdlc/dev.playbook/dev.fsm.js +18 -12
  24. package/reference/sdlc/dev.playbook/dev.fsm.ts +18 -13
  25. package/reference/sdlc/dev.playbook/dev.gears.md +19 -12
  26. package/reference/sdlc/dev.playbook/dev.playbook.d.ts +3 -10
  27. package/reference/sdlc/dev.playbook/dev.playbook.js +6 -6
  28. package/reference/sdlc/dev.playbook/dev.playbook.ts +8 -9
  29. package/reference/sdlc/dev.playbook/dev.registry.js +1 -1
  30. package/reference/sdlc/dev.playbook/dev.registry.ts +1 -1
  31. package/reference/sdlc/pr.md +17 -4
  32. package/reference/sdlc/pr.playbook/pr.fsm.d.ts +18 -4
  33. package/reference/sdlc/pr.playbook/pr.fsm.js +49 -18
  34. package/reference/sdlc/pr.playbook/pr.fsm.ts +63 -20
  35. package/reference/sdlc/pr.playbook/pr.gears.md +20 -7
  36. package/reference/sdlc/pr.playbook/pr.playbook.js +2 -1
  37. package/reference/sdlc/pr.playbook/pr.playbook.ts +2 -1
  38. package/reference/sdlc/review.playbook/review.fsm.d.ts +1 -1
  39. package/slc/experiments/fsm-scaffold-guidance.md +31 -0
  40. package/slc/gears2fsm.md +145 -58
  41. package/slc/link.md +190 -7
  42. package/slc/materialize-link.mjs +460 -0
  43. package/slc/optimize.md +46 -6
  44. package/slc/scaffold-fsm.mjs +225 -0
  45. package/slc/slc.pin-inputs.json +13 -0
  46. package/slc/text2gears.md +38 -3
  47. package/slc/workflow-contracts.json +371 -0
  48. package/src/runtime.d.ts +70 -0
  49. package/src/runtime.js +232 -1
  50. package/src/runtime.ts +358 -1
  51. package/src/xstate-playbook-runtime.d.ts +9 -10
  52. package/src/xstate-playbook-runtime.js +407 -21
  53. package/src/xstate-playbook-runtime.ts +514 -20
  54. package/src/xstate-runtime.d.ts +9 -1
  55. package/src/xstate-runtime.js +299 -19
  56. package/src/xstate-runtime.ts +362 -21
@@ -0,0 +1,371 @@
1
+ {
2
+ "schema": "sublang.playbook.workflow-contracts.v1",
3
+ "package": "@sublang/playbook",
4
+ "artifactSchema": 3,
5
+ "runtimeAbi": 1,
6
+ "description": "Public output interfaces for the packaged builtin workflows. The selected pipeline declares literalTargetBindings as its default nested-target namespace; explicit Source or compiler-dependency bindings override defaults and require their own interfaces. Hosts must honor the compiled bindings. Child output fields retain child-owned authority, while the shared envelope and terminal kind govern transport and authored failure; a local basename alone establishes no binding.",
7
+ "$defs": {
8
+ "compactError": {
9
+ "type": "object",
10
+ "properties": {
11
+ "name": {
12
+ "type": "string"
13
+ },
14
+ "message": {
15
+ "type": "string"
16
+ }
17
+ },
18
+ "required": ["name", "message"],
19
+ "additionalProperties": false
20
+ },
21
+ "json": {
22
+ "anyOf": [
23
+ {
24
+ "type": "null"
25
+ },
26
+ {
27
+ "type": "boolean"
28
+ },
29
+ {
30
+ "type": "number"
31
+ },
32
+ {
33
+ "type": "string"
34
+ },
35
+ {
36
+ "type": "array",
37
+ "items": {
38
+ "$ref": "#/$defs/json"
39
+ }
40
+ },
41
+ {
42
+ "type": "object",
43
+ "additionalProperties": {
44
+ "$ref": "#/$defs/json"
45
+ }
46
+ }
47
+ ]
48
+ },
49
+ "completedCodeResult": {
50
+ "anyOf": [
51
+ {
52
+ "type": "object",
53
+ "properties": {
54
+ "playbookId": {
55
+ "const": "code"
56
+ },
57
+ "status": {
58
+ "const": "ok"
59
+ },
60
+ "output": {
61
+ "$ref": "#/$defs/json"
62
+ }
63
+ },
64
+ "required": ["playbookId", "status"],
65
+ "additionalProperties": false
66
+ },
67
+ {
68
+ "type": "object",
69
+ "properties": {
70
+ "playbookId": {
71
+ "const": "code"
72
+ },
73
+ "status": {
74
+ "enum": ["aborted", "error"]
75
+ },
76
+ "error": {
77
+ "$ref": "#/$defs/compactError"
78
+ }
79
+ },
80
+ "required": ["playbookId", "status", "error"],
81
+ "additionalProperties": false
82
+ }
83
+ ]
84
+ }
85
+ },
86
+ "workflows": {
87
+ "review": {
88
+ "callInput": "text",
89
+ "output": {
90
+ "type": "object",
91
+ "properties": {
92
+ "noUnsettledFindings": {
93
+ "const": true
94
+ },
95
+ "evaluatedRevision": {
96
+ "type": "string",
97
+ "description": "Exact receipt-observed repository revision evaluated by the final clean review round; it can include REVIEW-owned fixes after the caller's original commit."
98
+ }
99
+ },
100
+ "required": ["noUnsettledFindings", "evaluatedRevision"],
101
+ "additionalProperties": false
102
+ }
103
+ },
104
+ "decide": {
105
+ "callInput": "text",
106
+ "output": {
107
+ "anyOf": [
108
+ {
109
+ "type": "object",
110
+ "properties": {
111
+ "decideCommit": {
112
+ "type": "string",
113
+ "description": "Exact DECIDE-owned commit."
114
+ },
115
+ "evaluatedRevision": {
116
+ "type": "string",
117
+ "description": "Exact repository revision evaluated by the final passing review."
118
+ },
119
+ "noUnsettledFindings": {
120
+ "const": true
121
+ }
122
+ },
123
+ "required": [
124
+ "decideCommit",
125
+ "evaluatedRevision",
126
+ "noUnsettledFindings"
127
+ ],
128
+ "additionalProperties": false
129
+ },
130
+ {
131
+ "type": "object",
132
+ "properties": {
133
+ "lastDecideCommit": {
134
+ "type": "string",
135
+ "description": "Exact last DECIDE-owned commit."
136
+ },
137
+ "noUnsettledFindings": {
138
+ "const": false
139
+ },
140
+ "reviewStatus": {
141
+ "enum": ["aborted", "error"]
142
+ },
143
+ "error": {
144
+ "$ref": "#/$defs/compactError"
145
+ }
146
+ },
147
+ "required": [
148
+ "lastDecideCommit",
149
+ "noUnsettledFindings",
150
+ "reviewStatus"
151
+ ],
152
+ "additionalProperties": false
153
+ }
154
+ ]
155
+ }
156
+ },
157
+ "code": {
158
+ "callInput": "text",
159
+ "output": {
160
+ "anyOf": [
161
+ {
162
+ "type": "object",
163
+ "properties": {
164
+ "status": {
165
+ "const": "complete"
166
+ },
167
+ "lastCodeCommit": {
168
+ "type": "string",
169
+ "description": "Exact last CODE-owned commit; excludes REVIEW-owned fix commits."
170
+ },
171
+ "finalEvaluatedRevision": {
172
+ "type": "string",
173
+ "description": "Exact repository revision evaluated by the final passing review; it may differ from lastCodeCommit."
174
+ },
175
+ "allReviewsPassed": {
176
+ "const": true
177
+ }
178
+ },
179
+ "required": [
180
+ "status",
181
+ "lastCodeCommit",
182
+ "finalEvaluatedRevision",
183
+ "allReviewsPassed"
184
+ ],
185
+ "additionalProperties": false
186
+ },
187
+ {
188
+ "type": "object",
189
+ "properties": {
190
+ "status": {
191
+ "const": "review-failed"
192
+ },
193
+ "lastCodeCommit": {
194
+ "type": "string",
195
+ "description": "Exact last CODE-owned commit."
196
+ },
197
+ "error": {
198
+ "$ref": "#/$defs/compactError"
199
+ }
200
+ },
201
+ "required": ["status", "lastCodeCommit", "error"],
202
+ "additionalProperties": false
203
+ }
204
+ ]
205
+ }
206
+ },
207
+ "branch": {
208
+ "callInput": "text",
209
+ "output": {
210
+ "anyOf": [
211
+ {
212
+ "type": "object",
213
+ "properties": {
214
+ "status": {
215
+ "const": "branched"
216
+ },
217
+ "branch": {
218
+ "type": "string",
219
+ "description": "Exact new branch name."
220
+ },
221
+ "baseRevision": {
222
+ "type": "string",
223
+ "description": "Exact receipt-observed repository revision the branch was created from."
224
+ },
225
+ "issueSummary": {
226
+ "type": "string",
227
+ "description": "Concise issue-and-comments or request summary."
228
+ }
229
+ },
230
+ "required": ["status", "branch", "baseRevision", "issueSummary"],
231
+ "additionalProperties": false
232
+ },
233
+ {
234
+ "type": "object",
235
+ "properties": {
236
+ "status": {
237
+ "const": "refused"
238
+ },
239
+ "coderOutput": {
240
+ "type": "string",
241
+ "description": "Complete refusal report."
242
+ }
243
+ },
244
+ "required": ["status", "coderOutput"],
245
+ "additionalProperties": false
246
+ }
247
+ ]
248
+ }
249
+ },
250
+ "pr": {
251
+ "callInput": "text",
252
+ "output": {
253
+ "anyOf": [
254
+ {
255
+ "type": "object",
256
+ "properties": {
257
+ "status": {
258
+ "const": "merged"
259
+ },
260
+ "pullRequest": {
261
+ "type": "string",
262
+ "description": "Exact pull request number as reported."
263
+ },
264
+ "pullRequestUrl": {
265
+ "type": "string",
266
+ "description": "Exact pull request URL as reported."
267
+ },
268
+ "localDefaultUpdated": {
269
+ "type": "boolean"
270
+ }
271
+ },
272
+ "required": [
273
+ "status",
274
+ "pullRequest",
275
+ "pullRequestUrl",
276
+ "localDefaultUpdated"
277
+ ],
278
+ "additionalProperties": false
279
+ },
280
+ {
281
+ "type": "object",
282
+ "properties": {
283
+ "status": {
284
+ "const": "not-merged"
285
+ },
286
+ "reason": {
287
+ "const": "not-published"
288
+ },
289
+ "coderOutput": {
290
+ "type": "string",
291
+ "description": "Complete report explaining why publication did not occur."
292
+ }
293
+ },
294
+ "required": ["status", "reason", "coderOutput"],
295
+ "additionalProperties": false
296
+ },
297
+ {
298
+ "type": "object",
299
+ "properties": {
300
+ "status": {
301
+ "const": "not-merged"
302
+ },
303
+ "reason": {
304
+ "const": "fix-failed"
305
+ },
306
+ "pullRequest": {
307
+ "type": "string"
308
+ },
309
+ "pullRequestUrl": {
310
+ "type": "string"
311
+ },
312
+ "childResult": {
313
+ "$ref": "#/$defs/completedCodeResult"
314
+ }
315
+ },
316
+ "required": [
317
+ "status",
318
+ "reason",
319
+ "pullRequest",
320
+ "pullRequestUrl",
321
+ "childResult"
322
+ ],
323
+ "additionalProperties": false
324
+ },
325
+ {
326
+ "type": "object",
327
+ "properties": {
328
+ "status": {
329
+ "const": "not-merged"
330
+ },
331
+ "reason": {
332
+ "enum": ["fix-not-published", "checks-failed"]
333
+ },
334
+ "pullRequest": {
335
+ "type": "string"
336
+ },
337
+ "pullRequestUrl": {
338
+ "type": "string"
339
+ }
340
+ },
341
+ "required": ["status", "reason", "pullRequest", "pullRequestUrl"],
342
+ "additionalProperties": false
343
+ },
344
+ {
345
+ "type": "object",
346
+ "properties": {
347
+ "status": {
348
+ "const": "merge-unconfirmed"
349
+ },
350
+ "pullRequest": {
351
+ "type": "string"
352
+ },
353
+ "pullRequestUrl": {
354
+ "type": "string"
355
+ }
356
+ },
357
+ "required": ["status", "pullRequest", "pullRequestUrl"],
358
+ "additionalProperties": false
359
+ }
360
+ ]
361
+ }
362
+ }
363
+ },
364
+ "literalTargetBindings": {
365
+ "review": "review",
366
+ "decide": "decide",
367
+ "code": "code",
368
+ "branch": "branch",
369
+ "pr": "pr"
370
+ }
371
+ }
package/src/runtime.d.ts CHANGED
@@ -32,10 +32,65 @@ export interface CaptainResult {
32
32
  export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
33
33
  readonly [key: string]: JsonValue;
34
34
  };
35
+ export declare const PLAYBOOK_FAILURE_CODES: readonly ["commit-missing", "commit-residual", "pre-existing-lost", "commits-more-than-one", "history-rewritten", "foreign-change", "observation-unstable", "attribution-ambiguous", "receipt-missing", "judge-failed", "player-failed", "aborted", "child-failed", "runtime-defect"];
36
+ export type PlaybookFailureCode = (typeof PLAYBOOK_FAILURE_CODES)[number];
37
+ /** The bounded path lists one failure code's evidence may carry (DR-063 §1). */
38
+ export interface PlaybookFailurePaths {
39
+ /** Paths changed in the worktree that no commit carries. */
40
+ readonly uncommitted?: readonly string[];
41
+ /** Pre-existing baseline paths the call changed before committing. */
42
+ readonly altered?: readonly string[];
43
+ /** Pre-existing baseline paths whose content is nowhere. */
44
+ readonly lost?: readonly string[];
45
+ /** Paths whose entry differs or is missing on either side. */
46
+ readonly changed?: readonly string[];
47
+ /** Paths omitted from the lists above by the 32-path bound. */
48
+ readonly truncated?: number;
49
+ }
50
+ /** The bounded error record a failure cause may carry (DR-063 §1). */
51
+ export interface PlaybookFailureErrorEvidence {
52
+ readonly name: string;
53
+ readonly message: string;
54
+ }
55
+ /** The closed evidence object of one failure cause (DR-063 §1). */
56
+ export interface PlaybookFailureEvidence {
57
+ readonly required?: PlaybookRepositoryDisposition;
58
+ readonly observed?: PlaybookRepositoryReceipt['classification'];
59
+ readonly baselineHead?: string;
60
+ readonly afterHead?: string;
61
+ readonly commitOid?: string;
62
+ readonly paths?: PlaybookFailurePaths;
63
+ readonly reason?: string;
64
+ readonly error?: PlaybookFailureErrorEvidence;
65
+ readonly errorCode?: string;
66
+ readonly roleId?: string;
67
+ readonly playerId?: string;
68
+ readonly playbookId?: string;
69
+ readonly cause?: PlaybookFailureCause;
70
+ }
71
+ /**
72
+ * Why a parked workflow failed (DR-063 §1): one code from the closed list and
73
+ * the closed evidence object that code names. Evidence holds repository paths,
74
+ * dispositions, classifications, and revision identities only — never file
75
+ * content, player prose, or internal call and session identities.
76
+ */
77
+ export interface PlaybookFailureCause {
78
+ readonly code: PlaybookFailureCode;
79
+ readonly evidence: PlaybookFailureEvidence;
80
+ }
81
+ /**
82
+ * Validate, detach, and freeze one failure cause (DR-063 §1). The check is
83
+ * closed per code: exactly the evidence members that code names, nothing else,
84
+ * and a `child-failed` cause nests at most four deep. A value this rejects is
85
+ * not a cause, so a caller omits it rather than publishing an invented one.
86
+ */
87
+ export declare function assertPlaybookFailureCause(value: unknown): PlaybookFailureCause;
35
88
  export interface NormalizedError {
36
89
  name: string;
37
90
  message: string;
38
91
  stack?: string;
92
+ /** DR-063 §2: present exactly when the underlying error carried a valid one. */
93
+ cause?: PlaybookFailureCause;
39
94
  }
40
95
  export type PlaybookStateValue = string | {
41
96
  readonly [key: string]: PlaybookStateValue;
@@ -181,12 +236,23 @@ export interface PlaybookRepositoryObservation {
181
236
  readonly projection: Readonly<Record<string, JsonValue>>;
182
237
  readonly projectionDigest: string;
183
238
  }
239
+ /**
240
+ * The fate of the baseline projection entries a governed call absorbed into
241
+ * its one commit, altered, or lost (DR-062). Each list holds sorted unique
242
+ * baseline paths and the three are pairwise disjoint.
243
+ */
244
+ export interface PlaybookRepositoryPreExistingChanges {
245
+ readonly absorbed: readonly string[];
246
+ readonly altered: readonly string[];
247
+ readonly lost: readonly string[];
248
+ }
184
249
  /** The fail-closed classification of one complete physical or logical receipt. */
185
250
  export interface PlaybookRepositoryReceipt {
186
251
  readonly classification: 'unchanged' | 'one-descendant-commit' | 'multiple-commits' | 'rewritten-or-non-descendant' | 'worktree-only-change' | 'concurrent-or-foreign-change' | 'observation-ambiguous';
187
252
  readonly baseline: PlaybookRepositoryObservation;
188
253
  readonly after?: PlaybookRepositoryObservation;
189
254
  readonly commitOid?: string;
255
+ readonly preExisting?: PlaybookRepositoryPreExistingChanges;
190
256
  }
191
257
  /** One durably ordered physical governed-player boundary (DR-040). */
192
258
  export interface PlaybookEffectBoundary {
@@ -324,9 +390,13 @@ export interface PlaybookRuntimeSnapshot {
324
390
  };
325
391
  suspendedCall?: PlaybookSuspendedCall;
326
392
  }
393
+ export type PlaybookControlStanding = 'ready' | 'no-op' | 'blocked';
394
+ export type PlaybookControlActionReason = 'receipt-complete';
327
395
  export interface PlaybookControlAction {
328
396
  id: string;
329
397
  label: string;
398
+ standing?: PlaybookControlStanding;
399
+ reason?: PlaybookControlActionReason;
330
400
  }
331
401
  export interface PlaybookControlView {
332
402
  state: PlaybookState;