@sublang/playbook 9.0.0 → 10.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 (64) hide show
  1. package/docs/cli.md +51 -8
  2. package/docs/embedding.md +38 -12
  3. package/package.json +7 -3
  4. package/reference/sdlc/captain.md +14 -10
  5. package/reference/sdlc/captain.playbook/captain.fsm.d.ts +33 -13
  6. package/reference/sdlc/captain.playbook/captain.fsm.js +80 -9
  7. package/reference/sdlc/captain.playbook/captain.fsm.ts +137 -18
  8. package/reference/sdlc/captain.playbook/captain.gears.md +10 -6
  9. package/reference/sdlc/captain.playbook/captain.playbook.d.ts +5 -1
  10. package/reference/sdlc/captain.playbook/captain.playbook.js +140 -10
  11. package/reference/sdlc/captain.playbook/captain.playbook.ts +188 -16
  12. package/reference/sdlc/code.md +0 -1
  13. package/reference/sdlc/code.playbook/bin/interactive-session.js +170 -17
  14. package/reference/sdlc/code.playbook/bin/launch-config.js +136 -4
  15. package/reference/sdlc/code.playbook/bin/playbook.js +81 -4
  16. package/reference/sdlc/code.playbook/bin/repository-effects.js +2930 -0
  17. package/reference/sdlc/code.playbook/bin/run.js +365 -63
  18. package/reference/sdlc/code.playbook/bin/session-store.js +2877 -209
  19. package/reference/sdlc/code.playbook/code.fsm.d.ts +7 -0
  20. package/reference/sdlc/code.playbook/code.fsm.js +74 -25
  21. package/reference/sdlc/code.playbook/code.fsm.ts +83 -29
  22. package/reference/sdlc/code.playbook/code.gears.md +0 -2
  23. package/reference/sdlc/code.playbook/code.playbook.d.ts +5 -2
  24. package/reference/sdlc/code.playbook/code.playbook.js +54 -2
  25. package/reference/sdlc/code.playbook/code.playbook.ts +75 -6
  26. package/reference/sdlc/code.playbook/code.registry.d.ts +10 -3
  27. package/reference/sdlc/code.playbook/code.registry.js +10 -3
  28. package/reference/sdlc/code.playbook/code.registry.ts +23 -5
  29. package/reference/sdlc/code.playbook/playbook-captain.d.ts +99 -7
  30. package/reference/sdlc/code.playbook/playbook-captain.js +1850 -72
  31. package/reference/sdlc/code.playbook/playbook-captain.ts +2759 -96
  32. package/reference/sdlc/decide.md +0 -1
  33. package/reference/sdlc/decide.playbook/decide.fsm.d.ts +7 -0
  34. package/reference/sdlc/decide.playbook/decide.fsm.js +80 -29
  35. package/reference/sdlc/decide.playbook/decide.fsm.ts +89 -31
  36. package/reference/sdlc/decide.playbook/decide.gears.md +0 -1
  37. package/reference/sdlc/decide.playbook/decide.playbook.d.ts +13 -5
  38. package/reference/sdlc/decide.playbook/decide.playbook.js +1712 -91
  39. package/reference/sdlc/decide.playbook/decide.playbook.ts +2677 -136
  40. package/reference/sdlc/decide.playbook/decide.registry.d.ts +7 -3
  41. package/reference/sdlc/decide.playbook/decide.registry.js +10 -3
  42. package/reference/sdlc/decide.playbook/decide.registry.ts +20 -5
  43. package/reference/sdlc/review.playbook/review.fsm.d.ts +7 -0
  44. package/reference/sdlc/review.playbook/review.fsm.js +133 -12
  45. package/reference/sdlc/review.playbook/review.fsm.ts +140 -12
  46. package/reference/sdlc/review.playbook/review.playbook.d.ts +5 -2
  47. package/reference/sdlc/review.playbook/review.playbook.js +65 -2
  48. package/reference/sdlc/review.playbook/review.playbook.ts +83 -6
  49. package/reference/sdlc/review.playbook/review.registry.d.ts +10 -3
  50. package/reference/sdlc/review.playbook/review.registry.js +10 -3
  51. package/reference/sdlc/review.playbook/review.registry.ts +23 -5
  52. package/slc/gears2fsm.md +6 -5
  53. package/slc/link.md +544 -41
  54. package/src/accepted-outcome.d.ts +18 -0
  55. package/src/accepted-outcome.js +94 -0
  56. package/src/accepted-outcome.ts +140 -0
  57. package/src/runtime.d.ts +164 -3
  58. package/src/runtime.ts +213 -2
  59. package/src/xstate-playbook-runtime.d.ts +149 -10
  60. package/src/xstate-playbook-runtime.js +2569 -270
  61. package/src/xstate-playbook-runtime.ts +4133 -490
  62. package/src/xstate-runtime.d.ts +59 -1
  63. package/src/xstate-runtime.js +866 -7
  64. package/src/xstate-runtime.ts +1397 -7
@@ -8,20 +8,23 @@
8
8
  // callerInput; pending player questions retain BOSS_REPLY
9
9
  // Adjudication: LLM judge per state; coderOutput and reviewerOutput are
10
10
  // carried verbatim
11
- // Compat: artifact schema 2 / runtime ABI 1
11
+ // Compat: artifact schema 3 / runtime ABI 1
12
12
 
13
13
  import {
14
14
  createXStatePlaybookRuntime,
15
15
  snapshotJsonValue,
16
16
  type PlaybookPlayerInput,
17
+ type XStatePlaybookRuntimeFactory,
18
+ type XStatePlaybookRuntimeConstruction,
17
19
  type XStatePromptIdentity,
18
- type XStatePlaybookRuntimeSpec,
20
+ type XStatePlaybookRuntimeSpecV3,
19
21
  } from '@sublang/playbook/xstate-runtime';
20
22
  import {
21
23
  reviewMachine,
22
24
  type PlayerInput,
23
25
  type ReviewInput,
24
26
  } from './review.fsm.js';
27
+ import type { PlaybookHostConstructionCapabilities } from '../code.playbook/playbook-captain.js';
25
28
  import type {
26
29
  CaptainCallOptions,
27
30
  CaptainResult,
@@ -75,6 +78,9 @@ export type {
75
78
  };
76
79
 
77
80
  export type ReviewPlaybookOptions = ReviewInput;
81
+ export type ReviewPlaybookHostCapabilities =
82
+ PlaybookHostConstructionCapabilities &
83
+ XStatePlaybookRuntimeConstruction<ReviewPlaybookOptions, object>['hostCapabilities'];
78
84
 
79
85
  const PLACEHOLDER = /<(#|[A-Za-z_$][A-Za-z0-9_$-]*)>/g;
80
86
  const CONTINUATION_PREAMBLE =
@@ -84,6 +90,7 @@ const VERBATIM_PAYLOAD_FIELDS: ReadonlySet<string> = new Set([
84
90
  'reviewerOutput',
85
91
  'coderOutput',
86
92
  ]);
93
+ const UNFINISHED_FINAL_STATE_IDS: ReadonlySet<string> = new Set();
87
94
 
88
95
  function snapshotReviewOptions(value: unknown): ReviewPlaybookOptions {
89
96
  const captured = snapshotJsonValue(value, 'REVIEW runtime options');
@@ -151,6 +158,7 @@ function composePlayerPrompt(
151
158
  export const _internal = {
152
159
  composePlayerPrompt,
153
160
  VERBATIM_PAYLOAD_FIELDS,
161
+ UNFINISHED_FINAL_STATE_IDS,
154
162
  };
155
163
 
156
164
  const runtimeSpec = {
@@ -159,7 +167,7 @@ const runtimeSpec = {
159
167
  // time — a literal, never the loading engine's RUNTIME_ABI self-report,
160
168
  // which would follow whatever engine loads the module and make the
161
169
  // factory's skew check compare that engine with itself.
162
- compat: { artifactSchema: 2, runtimeAbi: 1 },
170
+ compat: { artifactSchema: 3, runtimeAbi: 1 },
163
171
  snapshotOptions: snapshotReviewOptions,
164
172
  entryEvent: {
165
173
  type: 'START_REVIEW',
@@ -190,12 +198,73 @@ const runtimeSpec = {
190
198
  'REVIEW-4: Reviewer adjudicates an all-rejected Coder disposition.',
191
199
  },
192
200
  },
201
+ outcomeAuthority: {
202
+ governedPlayerStates: {
203
+ reviewInitial: {
204
+ hasFindings: {
205
+ fields: { reviewerOutput: 'presentation' },
206
+ repositoryDisposition: 'unchanged',
207
+ },
208
+ noFindings: {
209
+ fields: {},
210
+ repositoryDisposition: 'unchanged',
211
+ },
212
+ needsBossReply: {
213
+ fields: { question: 'presentation' },
214
+ repositoryDisposition: 'unchanged',
215
+ },
216
+ },
217
+ addressFindings: {
218
+ committed: {
219
+ fields: { coderOutput: 'presentation' },
220
+ repositoryDisposition: 'one-descendant-commit',
221
+ },
222
+ rejectedAll: {
223
+ fields: { coderOutput: 'presentation' },
224
+ repositoryDisposition: 'unchanged',
225
+ },
226
+ needsBossReply: {
227
+ fields: { question: 'presentation' },
228
+ repositoryDisposition: 'deferred',
229
+ },
230
+ },
231
+ reviewAfterCommit: {
232
+ hasFindings: {
233
+ fields: { reviewerOutput: 'presentation' },
234
+ repositoryDisposition: 'unchanged',
235
+ },
236
+ noFindings: {
237
+ fields: {},
238
+ repositoryDisposition: 'unchanged',
239
+ },
240
+ needsBossReply: {
241
+ fields: { question: 'presentation' },
242
+ repositoryDisposition: 'unchanged',
243
+ },
244
+ },
245
+ reviewAfterRebuttal: {
246
+ hasFindings: {
247
+ fields: { reviewerOutput: 'presentation' },
248
+ repositoryDisposition: 'unchanged',
249
+ },
250
+ noFindings: {
251
+ fields: {},
252
+ repositoryDisposition: 'unchanged',
253
+ },
254
+ needsBossReply: {
255
+ fields: { question: 'presentation' },
256
+ repositoryDisposition: 'unchanged',
257
+ },
258
+ },
259
+ },
260
+ },
193
261
  composePlayerPrompt: (
194
262
  input: PlaybookPlayerInput,
195
263
  promptIdentity: XStatePromptIdentity,
196
264
  ) => composePlayerPrompt(input as PlayerInput, promptIdentity),
197
265
  verbatimPayloadFields: VERBATIM_PAYLOAD_FIELDS,
198
266
  controlContextFields: [],
267
+ unfinishedFinalStateIds: UNFINISHED_FINAL_STATE_IDS,
199
268
  transitionEventFields: [
200
269
  'callerInput',
201
270
  'bossIntent',
@@ -203,9 +272,17 @@ const runtimeSpec = {
203
272
  'answer',
204
273
  'questionId',
205
274
  ],
206
- } satisfies XStatePlaybookRuntimeSpec<ReviewPlaybookOptions>;
275
+ } satisfies XStatePlaybookRuntimeSpecV3<ReviewPlaybookOptions>;
207
276
 
208
- const createPlaybookRuntime: PlaybookRuntimeFactory<ReviewPlaybookOptions> =
209
- createXStatePlaybookRuntime(reviewMachine, runtimeSpec);
277
+ const createPlaybookRuntime: XStatePlaybookRuntimeFactory<
278
+ XStatePlaybookRuntimeConstruction<
279
+ ReviewPlaybookOptions,
280
+ ReviewPlaybookHostCapabilities
281
+ >,
282
+ 3
283
+ > = createXStatePlaybookRuntime<
284
+ ReviewPlaybookOptions,
285
+ ReviewPlaybookHostCapabilities
286
+ >(reviewMachine, runtimeSpec);
210
287
 
211
288
  export default createPlaybookRuntime;
@@ -1,4 +1,4 @@
1
- import { type PlaybookRuntime } from './review.playbook.js';
1
+ import { type ReviewPlaybookHostCapabilities, type PlaybookRuntime } from './review.playbook.js';
2
2
  export interface PlaybookSummaryPolicy {
3
3
  stateCountLabels: Readonly<Record<string, string>>;
4
4
  copyPasteGuardNames: readonly string[];
@@ -12,12 +12,19 @@ export interface ReviewPlaybookRegistryEntry {
12
12
  id: 'review';
13
13
  command: 'review';
14
14
  intent: string;
15
- artifactSchema: 2;
15
+ artifactSchema: 3;
16
+ runtimeProfile: {
17
+ readonly kind: 'shared-factory';
18
+ readonly compat: {
19
+ readonly artifactSchema: 3;
20
+ readonly runtimeAbi: number;
21
+ };
22
+ };
16
23
  requiredRoleIds: readonly ['coder', 'reviewer'];
17
24
  concurrentRoleSets: readonly [];
18
25
  summaryPolicy: PlaybookSummaryPolicy;
19
26
  validateOptions(optionSlice: unknown): ReviewOptions;
20
- createRuntime(options: ReviewOptions): PlaybookRuntime;
27
+ createRuntime(options: ReviewOptions, hostCapabilities: ReviewPlaybookHostCapabilities): PlaybookRuntime;
21
28
  }
22
29
  export declare const reviewStateCountLabels: {
23
30
  readonly reviewInitial: "review round";
@@ -48,13 +48,20 @@ export const reviewPlaybookRegistryEntry = {
48
48
  id: 'review',
49
49
  command: 'review',
50
50
  intent: 'review the latest commit until no material correctness or spec findings remain',
51
- artifactSchema: 2,
51
+ artifactSchema: 3,
52
+ runtimeProfile: Object.freeze({
53
+ kind: 'shared-factory',
54
+ compat: createPlaybookRuntime.compat,
55
+ }),
52
56
  requiredRoleIds: ['coder', 'reviewer'],
53
57
  concurrentRoleSets: [],
54
58
  summaryPolicy: reviewSummaryPolicy,
55
59
  validateOptions: validateReviewOptions,
56
- createRuntime(options) {
57
- return createPlaybookRuntime(options);
60
+ createRuntime(options, hostCapabilities) {
61
+ return createPlaybookRuntime({
62
+ configuredOptions: options,
63
+ hostCapabilities,
64
+ });
58
65
  },
59
66
  };
60
67
  export default reviewPlaybookRegistryEntry;
@@ -2,6 +2,7 @@
2
2
  // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
3
 
4
4
  import createPlaybookRuntime, {
5
+ type ReviewPlaybookHostCapabilities,
5
6
  type PlaybookRuntime,
6
7
  } from './review.playbook.js';
7
8
 
@@ -20,12 +21,22 @@ export interface ReviewPlaybookRegistryEntry {
20
21
  id: 'review';
21
22
  command: 'review';
22
23
  intent: string;
23
- artifactSchema: 2;
24
+ artifactSchema: 3;
25
+ runtimeProfile: {
26
+ readonly kind: 'shared-factory';
27
+ readonly compat: {
28
+ readonly artifactSchema: 3;
29
+ readonly runtimeAbi: number;
30
+ };
31
+ };
24
32
  requiredRoleIds: readonly ['coder', 'reviewer'];
25
33
  concurrentRoleSets: readonly [];
26
34
  summaryPolicy: PlaybookSummaryPolicy;
27
35
  validateOptions(optionSlice: unknown): ReviewOptions;
28
- createRuntime(options: ReviewOptions): PlaybookRuntime;
36
+ createRuntime(
37
+ options: ReviewOptions,
38
+ hostCapabilities: ReviewPlaybookHostCapabilities,
39
+ ): PlaybookRuntime;
29
40
  }
30
41
 
31
42
  export const reviewStateCountLabels = {
@@ -94,13 +105,20 @@ export const reviewPlaybookRegistryEntry: ReviewPlaybookRegistryEntry = {
94
105
  command: 'review',
95
106
  intent:
96
107
  'review the latest commit until no material correctness or spec findings remain',
97
- artifactSchema: 2,
108
+ artifactSchema: 3,
109
+ runtimeProfile: Object.freeze({
110
+ kind: 'shared-factory',
111
+ compat: createPlaybookRuntime.compat,
112
+ }),
98
113
  requiredRoleIds: ['coder', 'reviewer'],
99
114
  concurrentRoleSets: [],
100
115
  summaryPolicy: reviewSummaryPolicy,
101
116
  validateOptions: validateReviewOptions,
102
- createRuntime(options) {
103
- return createPlaybookRuntime(options);
117
+ createRuntime(options, hostCapabilities) {
118
+ return createPlaybookRuntime({
119
+ configuredOptions: options,
120
+ hostCapabilities,
121
+ });
104
122
  },
105
123
  };
106
124
 
package/slc/gears2fsm.md CHANGED
@@ -222,12 +222,13 @@ teardown event. The completion rule of
222
222
  output clause binds only where Source declares a terminal result, which a
223
223
  controller Source does not.
224
224
  The controller decision state's direct-Captain result contract discriminates
225
- the closed action set of DR-029. Its guard discriminants are a stable
226
- compiler contract, not names the compiler may invent — `respond`, `start`,
227
- `switch`, `dismiss`, `deliver`, and `runtime` — with each guard's required
228
- payload fields:
225
+ the closed action set of DR-029 as extended by DR-038. Its guard discriminants
226
+ are a stable compiler contract, not names the compiler may invent — `respond`, `resume`,
227
+ `start`, `switch`, `dismiss`, `deliver`, and `runtime` — with each guard's
228
+ required payload fields:
229
229
 
230
230
  - `respond` requires `text`;
231
+ - `resume` requires `playbookId` and carries no `input`;
231
232
  - `start` and `switch` each require `playbookId` and `input`;
232
233
  - `runtime` requires `actionId`;
233
234
  - `dismiss` and `deliver` require none — a `deliver` result in particular
@@ -653,7 +654,7 @@ Boss-reply suspension, because its hub already receives every Boss turn and a
653
654
  clarifying question to Boss is a `respond` selection over the closed action
654
655
  set. The rule below is therefore universal over workflow states and silent
655
656
  about that class; in particular, adding `needsBossReply` to the controller
656
- decision state would add a seventh outcome to a closed six-action contract
657
+ decision state would add an eighth outcome to a closed seven-action contract
657
658
  whose guard discriminants [Setup](#setup) fixes, and is nonconformant.
658
659
  There is no source-level opt-in annotation and no `needsBossReply` result metadata in GEARS output.
659
660
  The FSM compiler shall preserve the GEARS blockquote as the state's domain `prompt` body and shall not inject any Boss-question instruction into `invoke.input.prompt`.