@sublang/playbook 13.1.0 → 13.3.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 (43) hide show
  1. package/README.md +7 -5
  2. package/docs/cli.md +28 -9
  3. package/docs/configuration.md +27 -14
  4. package/docs/embedding.md +1 -1
  5. package/package.json +40 -2
  6. package/reference/sdlc/branch.md +37 -0
  7. package/reference/sdlc/branch.playbook/branch.fsm.d.ts +169 -0
  8. package/reference/sdlc/branch.playbook/branch.fsm.js +325 -0
  9. package/reference/sdlc/branch.playbook/branch.fsm.ts +458 -0
  10. package/reference/sdlc/branch.playbook/branch.gears.md +44 -0
  11. package/reference/sdlc/branch.playbook/branch.playbook.d.ts +20 -0
  12. package/reference/sdlc/branch.playbook/branch.playbook.js +121 -0
  13. package/reference/sdlc/branch.playbook/branch.playbook.ts +217 -0
  14. package/reference/sdlc/branch.playbook/branch.registry.d.ts +40 -0
  15. package/reference/sdlc/branch.playbook/branch.registry.js +63 -0
  16. package/reference/sdlc/branch.playbook/branch.registry.ts +121 -0
  17. package/reference/sdlc/code.playbook/bin/session-host.js +13 -3
  18. package/reference/sdlc/code.playbook/playbook-captain.d.ts +26 -1
  19. package/reference/sdlc/code.playbook/playbook-captain.js +218 -6
  20. package/reference/sdlc/code.playbook/playbook-captain.ts +281 -6
  21. package/reference/sdlc/code.playbook/playbook.config.template.yaml +21 -8
  22. package/reference/sdlc/code.playbook/session-host.d.ts +26 -0
  23. package/reference/sdlc/dev.md +24 -3
  24. package/reference/sdlc/dev.playbook/dev.fsm.d.ts +100 -9
  25. package/reference/sdlc/dev.playbook/dev.fsm.js +235 -18
  26. package/reference/sdlc/dev.playbook/dev.fsm.ts +368 -24
  27. package/reference/sdlc/dev.playbook/dev.gears.md +45 -7
  28. package/reference/sdlc/dev.playbook/dev.playbook.js +13 -1
  29. package/reference/sdlc/dev.playbook/dev.playbook.ts +13 -1
  30. package/reference/sdlc/dev.playbook/dev.registry.d.ts +1 -1
  31. package/reference/sdlc/dev.playbook/dev.registry.js +7 -2
  32. package/reference/sdlc/dev.playbook/dev.registry.ts +7 -2
  33. package/reference/sdlc/pr.md +108 -0
  34. package/reference/sdlc/pr.playbook/pr.fsm.d.ts +352 -0
  35. package/reference/sdlc/pr.playbook/pr.fsm.js +902 -0
  36. package/reference/sdlc/pr.playbook/pr.fsm.ts +1251 -0
  37. package/reference/sdlc/pr.playbook/pr.gears.md +155 -0
  38. package/reference/sdlc/pr.playbook/pr.playbook.d.ts +27 -0
  39. package/reference/sdlc/pr.playbook/pr.playbook.js +133 -0
  40. package/reference/sdlc/pr.playbook/pr.playbook.ts +235 -0
  41. package/reference/sdlc/pr.playbook/pr.registry.d.ts +40 -0
  42. package/reference/sdlc/pr.playbook/pr.registry.js +68 -0
  43. package/reference/sdlc/pr.playbook/pr.registry.ts +124 -0
@@ -24,6 +24,7 @@ import type {
24
24
  PlaybookCallRequest,
25
25
  PlaybookCallResult,
26
26
  PlaybookCallStart,
27
+ PlaybookControlAction,
27
28
  PlaybookControlView,
28
29
  PlaybookPorts,
29
30
  PlaybookRunResult,
@@ -353,6 +354,31 @@ export interface PlaybookCaptainShell extends Captain {
353
354
  session: CaptainSession,
354
355
  snapshot: PlaybookCaptainShellSnapshot,
355
356
  ): Promise<void>;
357
+ /**
358
+ * The active leaf's currently advertised runtime actions, as the host's own
359
+ * reading of the control view the ControlView digest reads (CAPTAIN-60).
360
+ * Declared optional because capability absence is member absence: a shell
361
+ * that publishes no reader advertises nothing.
362
+ */
363
+ describeRuntimeActions?(): readonly PlaybookControlAction[];
364
+ /**
365
+ * Select one currently advertised runtime action as the next Boss turn's
366
+ * decision and return that turn's Boss text, which the host submits through
367
+ * `handleBossTurn` (CAPTAIN-7).
368
+ */
369
+ submitRuntimeAction?(actionId: string): string;
370
+ /**
371
+ * The controls the shell effects on its own behalf, disjoint from the leaf's
372
+ * advertised runtime actions (CAPTAIN-62). Declared optional for the same
373
+ * reason: a shell that publishes no reader advertises nothing.
374
+ */
375
+ describeShellActions?(): readonly PlaybookControlAction[];
376
+ /**
377
+ * Select one currently advertised shell control as the next Boss turn's
378
+ * decision and return that turn's Boss text, which the host submits through
379
+ * `handleBossTurn` (CAPTAIN-7).
380
+ */
381
+ submitShellAction?(actionId: string): string;
356
382
  }
357
383
 
358
384
  // Per-enabled-playbook binding the shell resolves at init from the exact
@@ -575,6 +601,9 @@ function isCanonicalLocalRoleId(value: unknown): value is string {
575
601
  const UNRESOLVED_EFFECT_RECONCILIATION_ACTION_ID =
576
602
  'reconcile:unresolved-effect';
577
603
  const UNRESOLVED_EFFECT_ABANDONMENT_ACTION_ID = 'abandon:unresolved-effect';
604
+ // CAPTAIN-62: the shell's own control, not a runtime action. The id is machine
605
+ // data the host echoes back; the Boss never sees it (CAPPLAY-5).
606
+ const GIVE_UP_ACTION_ID = 'give-up';
578
607
  // The fixed machine-syntax guard of a player's Boss-question suspension
579
608
  // (slc/link.md §Boss-reply suspension): the accepted outcome that parks on
580
609
  // Boss rather than sparing Boss a relay.
@@ -608,6 +637,19 @@ interface ActiveTurn {
608
637
  */
609
638
  readonly authoritativeText: string;
610
639
  readonly resolution?: CaptainParsedResolution;
640
+ /**
641
+ * The advertised action id the host selected for this turn (CAPTAIN-7). Its
642
+ * presence is the turn's decision: the decision state receives that
643
+ * selection from the shell and allocates no decision call.
644
+ */
645
+ readonly hostRuntimeActionId?: string;
646
+ /**
647
+ * Set where the host decided this turn by selecting the shell's own give-up
648
+ * control (CAPTAIN-62). Like `hostRuntimeActionId` its presence is the
649
+ * turn's decision, and it additionally settles the result phase in the shell
650
+ * so the turn makes no model call at all (CAPTAIN-63).
651
+ */
652
+ readonly hostGiveUp?: true;
611
653
  /** A settlement with status `ok` is final for the turn (DR-029). */
612
654
  settled: boolean;
613
655
  /**
@@ -3118,6 +3160,15 @@ export function createPlaybookCaptainShell(
3118
3160
  outcome: DurableCallOutcome;
3119
3161
  }
3120
3162
  | undefined;
3163
+ // CAPTAIN-7: the control the host selected for the turn it is about to
3164
+ // submit, held with the exact Boss text that turn carries so an unrelated
3165
+ // turn never consumes the selection. One turn consumes it, whichever it is,
3166
+ // and one slot holds it whichever surface it came from — the leaf's
3167
+ // advertised actions or the shell's own controls (CAPTAIN-62).
3168
+ let pendingHostSelection:
3169
+ | { readonly kind: 'runtime'; readonly actionId: string; readonly text: string }
3170
+ | { readonly kind: 'give-up'; readonly text: string }
3171
+ | undefined;
3121
3172
  let lastAction: ControllerAction | undefined;
3122
3173
  let lastSettlementStatus: SettlementEvidence['status'] | undefined;
3123
3174
  // DR-038 §2: a turn can dispose its root before the durable caller asks
@@ -5900,6 +5951,132 @@ export function createPlaybookCaptainShell(
5900
5951
  return lines.join('\n');
5901
5952
  };
5902
5953
 
5954
+ // CAPTAIN-60: the same reading the ControlView digest performs, published as
5955
+ // data instead of prose. It states what the digest states and withholds what
5956
+ // the digest withholds: an idle shell, a leaf with no control surface, and a
5957
+ // control view that cannot be read all advertise nothing, and a leaf fenced
5958
+ // for repository-effect reconciliation advertises only its fence controls.
5959
+ // The pairs are detached and frozen, so a host holds the shell's reading
5960
+ // rather than a live view the runtime can rewrite underneath it.
5961
+ const advertisedRuntimeActions = (): readonly PlaybookControlAction[] => {
5962
+ const empty: readonly PlaybookControlAction[] = Object.freeze([]);
5963
+ if (lifecycle !== 'ready' || terminallyDisposed) return empty;
5964
+ // Between turns: while a turn is running, the leaf's control view is the
5965
+ // decision's grounding and the host can act on no selection, so the shell
5966
+ // publishes none and reads nothing from a runtime mid-run.
5967
+ if (activeTurn !== undefined || activeTurnHostCalls !== undefined) {
5968
+ return empty;
5969
+ }
5970
+ const leaf = leafFrame();
5971
+ if (!leaf || typeof leaf.runtime.describe !== 'function') return empty;
5972
+ refreshRetainedEffectFence();
5973
+ const fenced = retainedEffectReconciliation !== undefined;
5974
+ if (fenced && typeof leaf.runtime.apply !== 'function') return empty;
5975
+ let actions: readonly PlaybookControlAction[];
5976
+ try {
5977
+ actions = leaf.runtime.describe().actions;
5978
+ } catch {
5979
+ // An unreadable control view advertises nothing.
5980
+ return empty;
5981
+ }
5982
+ return Object.freeze(
5983
+ actions
5984
+ .filter(
5985
+ (action) =>
5986
+ !fenced ||
5987
+ action.id === UNRESOLVED_EFFECT_RECONCILIATION_ACTION_ID ||
5988
+ action.id === UNRESOLVED_EFFECT_ABANDONMENT_ACTION_ID,
5989
+ )
5990
+ .map((action) => Object.freeze({ id: action.id, label: action.label })),
5991
+ );
5992
+ };
5993
+
5994
+ // CAPTAIN-62: the controls the shell effects itself, published beside the
5995
+ // leaf's advertised actions and never mixed with them — these are the
5996
+ // shell's own, so an engaged root offers one whatever its leaf advertises,
5997
+ // fenced or not. A fenced root keeps its control because giving up reports
5998
+ // unresolved effects (CAPTAIN-58) rather than reconciling them, and a run
5999
+ // whose effects are unknown is exactly the run a Boss gives up on.
6000
+ const advertisedShellActions = (): readonly PlaybookControlAction[] => {
6001
+ const empty: readonly PlaybookControlAction[] = Object.freeze([]);
6002
+ if (lifecycle !== 'ready' || terminallyDisposed) return empty;
6003
+ // Between turns, on the same rule the leaf's actions take: mid-turn the
6004
+ // host can act on no selection.
6005
+ if (activeTurn !== undefined || activeTurnHostCalls !== undefined) {
6006
+ return empty;
6007
+ }
6008
+ const root = rootFrame();
6009
+ if (!root) return empty;
6010
+ return Object.freeze([
6011
+ Object.freeze({
6012
+ id: GIVE_UP_ACTION_ID,
6013
+ // The label is the turn's durable Boss text, so it names the run the
6014
+ // way the Boss started it rather than the frame that happens to be
6015
+ // parked inside it.
6016
+ label: `Stop ${frameLabel(root)}`,
6017
+ }),
6018
+ ]);
6019
+ };
6020
+
6021
+ // CAPTAIN-7: the host's selection of the shell's own control, validated here
6022
+ // against the same live reading. The returned text is the turn the host
6023
+ // submits, exactly as for an advertised runtime action.
6024
+ const selectShellAction = (actionId: string): string => {
6025
+ if (lifecycle !== 'ready' || terminallyDisposed) {
6026
+ throw new Error(
6027
+ 'a shell control requires an initialized or restored Captain shell',
6028
+ );
6029
+ }
6030
+ if (activeTurn !== undefined || activeTurnHostCalls !== undefined) {
6031
+ throw new Error('a shell control cannot be selected during a Boss turn');
6032
+ }
6033
+ if (typeof actionId !== 'string' || actionId.length === 0) {
6034
+ throw new TypeError('a shell control id must be a nonempty string');
6035
+ }
6036
+ const advertised = advertisedShellActions().find(
6037
+ (action) => action.id === actionId,
6038
+ );
6039
+ if (advertised === undefined) {
6040
+ throw new Error('the shell does not advertise that control');
6041
+ }
6042
+ pendingHostSelection = { kind: 'give-up', text: advertised.label };
6043
+ return advertised.label;
6044
+ };
6045
+
6046
+ // CAPTAIN-7: the host's own selection of one advertised action, validated
6047
+ // here against the same live reading and validated again at the controller
6048
+ // port before any effect. The returned text is the turn the host submits.
6049
+ const selectRuntimeAction = (actionId: string): string => {
6050
+ if (lifecycle !== 'ready' || terminallyDisposed) {
6051
+ throw new Error(
6052
+ 'a runtime action requires an initialized or restored Captain shell',
6053
+ );
6054
+ }
6055
+ if (activeTurn !== undefined || activeTurnHostCalls !== undefined) {
6056
+ throw new Error('a runtime action cannot be selected during a Boss turn');
6057
+ }
6058
+ if (typeof actionId !== 'string' || actionId.length === 0) {
6059
+ throw new TypeError('a runtime action id must be a nonempty string');
6060
+ }
6061
+ const advertised = advertisedRuntimeActions().find(
6062
+ (action) => action.id === actionId,
6063
+ );
6064
+ if (advertised === undefined) {
6065
+ // CAPPLAY-5: the chosen id is control data whether or not the leaf
6066
+ // advertises it, so the refusal names the fact and not the string.
6067
+ throw new Error('the active leaf does not advertise that action');
6068
+ }
6069
+ const text =
6070
+ typeof advertised.label === 'string' ? advertised.label.trim() : '';
6071
+ if (text.length === 0) {
6072
+ throw new Error(
6073
+ 'the advertised action carries no Boss-facing label to submit as its turn',
6074
+ );
6075
+ }
6076
+ pendingHostSelection = { kind: 'runtime', actionId, text };
6077
+ return text;
6078
+ };
6079
+
5903
6080
  // The catalog is registry-authored, not shell-authored: an id, a command,
5904
6081
  // and an intent all arrive from an enabled module. They pass the same seam
5905
6082
  // the ControlView lines do, so an intent carrying a newline cannot open a
@@ -6471,6 +6648,42 @@ export function createPlaybookCaptainShell(
6471
6648
  ? []
6472
6649
  : [labeledBlock('Conversation recap', options.reseedDigest)]),
6473
6650
  ]);
6651
+ // CAPTAIN-7: a turn whose decision the host already made allocates no
6652
+ // decision call. The host's selection is this state's decision reply, so
6653
+ // it passes the runtime's own reply validation and reaches the shell
6654
+ // through the controller port like every other selection — validation,
6655
+ // execution, the outcome report, and the closing reply are the loop's.
6656
+ if (kind === 'decision' && turn?.hostRuntimeActionId !== undefined) {
6657
+ return {
6658
+ status: 'ok' as const,
6659
+ finalText: JSON.stringify({
6660
+ action: 'runtime',
6661
+ actionId: turn.hostRuntimeActionId,
6662
+ }),
6663
+ };
6664
+ }
6665
+ // CAPTAIN-63: a give-up allocates neither call. Its decision is the
6666
+ // host's, and its result phase is answered below from the settlement the
6667
+ // shell already holds, so an exit from a failing provider does not ask
6668
+ // that provider for permission.
6669
+ if (kind === 'decision' && turn?.hostGiveUp === true) {
6670
+ return {
6671
+ status: 'ok' as const,
6672
+ finalText: JSON.stringify({ action: 'dismiss' }),
6673
+ };
6674
+ }
6675
+ if (kind === 'closingReply' && turn?.hostGiveUp === true) {
6676
+ // The durable conversation did not receive this turn, so it is marked
6677
+ // for the CAPTAIN-35 catch-up rather than left believing it is
6678
+ // current: the next call carries the journal records it missed.
6679
+ markConversationCatchUp();
6680
+ // Through the one presentation seam, exactly where a model-composed
6681
+ // reply is presented, so this reply is journaled and single-attempt
6682
+ // like every other. It needs no reply validation or corrective re-ask:
6683
+ // `giveUpReplyText` already validated what it composed.
6684
+ await surfaceSettlement({ context, text: giveUpReplyText() });
6685
+ return { status: 'ok' as const, finalText: 'ok' };
6686
+ }
6474
6687
  const outcome = await durableCall(context, compose);
6475
6688
  if (kind === 'decision') {
6476
6689
  // A model-decided `respond` surfaces this call's own prose, so the
@@ -6701,8 +6914,17 @@ export function createPlaybookCaptainShell(
6701
6914
  if (!root) return false;
6702
6915
  const label = frameLabel(root);
6703
6916
  // Dismissal leaves the procedure unfinished. Persist the latest safe
6704
- // generation captured for this turn before disposal erases the frames.
6705
- retainOrClearDisposedRoot(root);
6917
+ // generation captured for this turn before disposal erases the frames —
6918
+ // unless the Boss gave up on it (CAPTAIN-44), in which case retaining it
6919
+ // would offer the abandoned run back on the idle digest's next reading.
6920
+ if (activeTurn?.hostGiveUp === true) {
6921
+ pendingRetentionUpdates.set(root.entry.id, {
6922
+ kind: 'clear',
6923
+ rootPlaybookId: root.entry.id,
6924
+ });
6925
+ } else {
6926
+ retainOrClearDisposedRoot(root);
6927
+ }
6706
6928
  try {
6707
6929
  await runEffect(() => disposeStack('dismiss'));
6708
6930
  facts.push(`Dismissed the ${label} engagement.`);
@@ -7276,10 +7498,16 @@ export function createPlaybookCaptainShell(
7276
7498
  if (!leaf) {
7277
7499
  return rejectSelection(selection, 'no engagement is active to dismiss');
7278
7500
  }
7501
+ // CAPTAIN-63: a give-up ends the run. An ordinary dismissal of a nested
7502
+ // call returns to its caller, which is the right reading of "stop this
7503
+ // call" and the wrong one of "stop this workflow" — the Boss gave up on
7504
+ // the root, not on whichever child was parked when they did.
7505
+ const giveUp = turn.hostGiveUp === true;
7506
+ const dismissed = giveUp ? (rootFrame() ?? leaf) : leaf;
7279
7507
  turn.settled = true;
7280
- journalAction({ action: 'dismiss', playbookId: leaf.entry.id });
7281
- const label = frameLabel(leaf);
7282
- if (leaf.parent) {
7508
+ journalAction({ action: 'dismiss', playbookId: dismissed.entry.id });
7509
+ const label = frameLabel(dismissed);
7510
+ if (leaf.parent && !giveUp) {
7283
7511
  // No boundary around the return itself: `resumeParent` disposes the
7284
7512
  // child and drives the parent, and each of those is marked where it
7285
7513
  // happens. A visibility rejection raised on the way back is shell
@@ -7615,6 +7843,29 @@ export function createPlaybookCaptainShell(
7615
7843
  // The reply composes from the authoritative report, never the early
7616
7844
  // `settled` guard. That guard closes duplicate submissions before an effect
7617
7845
  // starts; it is not evidence that anything ran.
7846
+ // CAPTAIN-63: the give-up's closing reply, composed from the same settlement
7847
+ // facts the result-phase prompt would have carried. Shell-authored Boss
7848
+ // prose passes the validation every model reply passes (CAPTAIN-34); what it
7849
+ // interpolates is not host-authored all the way down, so a fact set that
7850
+ // fails validation is dropped rather than spoken and the reply still states
7851
+ // the settlement truthfully.
7852
+ const giveUpReplyText = (): string => {
7853
+ const report = activeTurn?.report;
7854
+ const facts = report?.bossFacts ?? report?.facts ?? [];
7855
+ const opening = 'Stopped that workflow. I will not resume it.';
7856
+ const closing = 'Send the command again to start fresh work.';
7857
+ const composed = [
7858
+ opening,
7859
+ ...(facts.length === 0
7860
+ ? []
7861
+ : ['Here is what happened:', ...facts.map((fact) => `- ${fact}`)]),
7862
+ closing,
7863
+ ].join('\n');
7864
+ return replyRejection(composed) === undefined
7865
+ ? composed
7866
+ : [opening, closing].join('\n');
7867
+ };
7868
+
7618
7869
  const failureReplyText = (): string => {
7619
7870
  const commands = [...enablementById.values()]
7620
7871
  .map((enablement) => `/${enablement.command} <task>`)
@@ -8685,6 +8936,14 @@ export function createPlaybookCaptainShell(
8685
8936
 
8686
8937
  installRetainedGenerations,
8687
8938
 
8939
+ describeRuntimeActions: advertisedRuntimeActions,
8940
+
8941
+ submitRuntimeAction: selectRuntimeAction,
8942
+
8943
+ describeShellActions: advertisedShellActions,
8944
+
8945
+ submitShellAction: selectShellAction,
8946
+
8688
8947
  async handleBossTurn(
8689
8948
  turn: BossTurn,
8690
8949
  context: CaptainContext,
@@ -8724,13 +8983,28 @@ export function createPlaybookCaptainShell(
8724
8983
  const turnHostCalls = new Set<Promise<unknown>>();
8725
8984
  activeTurnHostCalls = turnHostCalls;
8726
8985
  activeContext = context;
8727
- const parsed = resolveCommandTurn(turn.prompt);
8986
+ // CAPTAIN-7: one host selection is consumed by one turn. It decides only
8987
+ // the turn carrying the exact text the selection was made for; any other
8988
+ // turn drops it and resolves normally.
8989
+ const selected = pendingHostSelection;
8990
+ pendingHostSelection = undefined;
8991
+ const decided =
8992
+ selected !== undefined && selected.text === turn.prompt
8993
+ ? selected
8994
+ : undefined;
8995
+ const hostRuntimeActionId =
8996
+ decided?.kind === 'runtime' ? decided.actionId : undefined;
8997
+ const hostGiveUp = decided?.kind === 'give-up' ? true : undefined;
8998
+ const parsed =
8999
+ decided === undefined ? resolveCommandTurn(turn.prompt) : undefined;
8728
9000
  activeTurn = {
8729
9001
  id: ++turnSequence,
8730
9002
  captainSyncedJournalSeq: journalSeq,
8731
9003
  bossText: turn.prompt,
8732
9004
  authoritativeText: parsed?.authoritativeText ?? turn.prompt,
8733
9005
  ...(parsed ? { resolution: parsed.resolution } : {}),
9006
+ ...(hostRuntimeActionId === undefined ? {} : { hostRuntimeActionId }),
9007
+ ...(hostGiveUp === undefined ? {} : { hostGiveUp }),
8734
9008
  settled: false,
8735
9009
  presentationAttempted: false,
8736
9010
  settlementFacts: [],
@@ -8880,6 +9154,7 @@ export function createPlaybookCaptainShell(
8880
9154
  failure ??= error;
8881
9155
  }
8882
9156
  }
9157
+ pendingHostSelection = undefined;
8883
9158
  // Quarantine is session-wide by design. Only terminal teardown may drop
8884
9159
  // its ownership after every frame host call and the Captain are drained.
8885
9160
  playerTransactions.clear();
@@ -21,7 +21,8 @@
21
21
  # Drop an adapter from this file and you can skip its SDK entirely.
22
22
  # Every seeded agent runs in cligent's protected auto mode
23
23
  # (permissions.mode: auto): claude maps it to permissionMode auto, codex to
24
- # on-request + auto_review. Codex roles also grant writablePaths: ['.git']
24
+ # on-request + auto_review. A codex agent additionally needs
25
+ # writablePaths: ['.git'] to write git metadata under its sandbox.
25
26
  # so they can inspect and work with repository metadata under the sandbox.
26
27
 
27
28
  # The Captain/Judge agent.
@@ -46,15 +47,13 @@ notifications:
46
47
  # shares one provider conversation across those playbooks.
47
48
  players:
48
49
  dev.coder:
49
- adapter: codex
50
- model: gpt-5.6-sol
51
- effort: ultra
50
+ adapter: claude
51
+ model: claude-opus-5
52
+ effort: high
52
53
  # Adapter-scoped fast mode is validated by the installed Cligent contract;
53
54
  # omitting it takes the provider default.
54
- fastMode: true
55
55
  permissions:
56
56
  mode: auto
57
- writablePaths: ['.git']
58
57
 
59
58
  dev.reviewer:
60
59
  adapter: claude
@@ -78,8 +77,8 @@ players:
78
77
  # `roles` are launcher-owned; every other key is that playbook's option
79
78
  # slice.
80
79
  #
81
- # Every manifest role is bound explicitly. CODE, REVIEW, and DECIDE
82
- # intentionally reuse the same two stable players, while DEV keeps its own
80
+ # Every manifest role is bound explicitly. CODE, REVIEW, DECIDE, BRANCH, and
81
+ # PR intentionally reuse the same two stable players, while DEV keeps its own
83
82
  # Analyst; change an id to isolate its conversation.
84
83
  playbooks:
85
84
  code:
@@ -103,3 +102,17 @@ playbooks:
103
102
  from: "@sublang/playbook/dev/registry"
104
103
  roles:
105
104
  analyst: dev.analyst
105
+
106
+ # Pull-request delivery for DEV (DR-050). BRANCH and PR bind Coder to the
107
+ # same dev.coder player as CODE and REVIEW on purpose: the Coder that read
108
+ # the issue and named the branch makes the commits and then describes
109
+ # them in the pull request. Change an id to isolate its conversation.
110
+ branch:
111
+ from: "@sublang/playbook/branch/registry"
112
+ roles:
113
+ coder: dev.coder
114
+
115
+ pr:
116
+ from: "@sublang/playbook/pr/registry"
117
+ roles:
118
+ coder: dev.coder
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
3
 
4
+ import type { PlaybookControlAction } from '@sublang/playbook/runtime';
4
5
  import type { PlaybookCaptainShell, PlaybookCaptainShellSnapshot } from './playbook-captain.js';
5
6
  import type { PlaybookEffectLedger } from './host-capabilities.js';
6
7
  import type { PlaybookSessionLifecycle, SessionExecutionProjection, SessionStructuralProjection, SessionFreshBoundary, SessionRecovery } from './session-store.js';
@@ -68,6 +69,31 @@ export interface SessionHostController {
68
69
  readonly lease: PlaybookSessionLifecycle;
69
70
  read(): Promise<SessionRecovery | undefined>;
70
71
  handleBossTurn(input: string): Promise<SessionRecovery>;
72
+ /**
73
+ * The active leaf's currently advertised runtime actions, read live between
74
+ * turns; empty whenever nothing is advertised, a turn is active, or the
75
+ * leaf's control view cannot be read.
76
+ */
77
+ listRuntimeActions(): readonly PlaybookControlAction[];
78
+ /**
79
+ * Submit one currently advertised runtime action as the session's next turn.
80
+ * The turn is the same durable transaction `handleBossTurn` runs, and its
81
+ * decision is the submitted selection, so no decision model call is made.
82
+ */
83
+ submitRuntimeAction(actionId: string): Promise<SessionRecovery>;
84
+ /**
85
+ * The controls the shell offers on its own behalf, read live between turns;
86
+ * today one give-up while a root is engaged, and empty while idle or while a
87
+ * turn is active. Disjoint from `listRuntimeActions`, which reads the leaf.
88
+ */
89
+ listShellActions(): readonly PlaybookControlAction[];
90
+ /**
91
+ * Submit one currently advertised shell control as the session's next turn.
92
+ * The turn is the same durable transaction `handleBossTurn` runs; both its
93
+ * decision and its closing reply are the shell's, so the turn makes no model
94
+ * call and a give-up survives a provider that is refusing everything.
95
+ */
96
+ submitShellAction(actionId: string): Promise<SessionRecovery>;
71
97
  retry(): Promise<SessionRecovery>;
72
98
  dispose(): Promise<void>;
73
99
  }
@@ -27,13 +27,14 @@ Do not change files or commit while planning or discussing the request.
27
27
  - If the discussion has concluded after a Boss reply and no repository work should follow, choose `discussion complete`.
28
28
  - If implementation can proceed under the existing decisions, choose `code`.
29
29
  - If implementation first requires a new or amended durable decision that the existing specs do not settle, choose `decide then code`.
30
+ - If the request names a GitHub issue (number or URL) or explicitly asks for pull-request delivery, read the issue and its comments as part of the analysis (`gh issue view --comments` with the issue number) and choose `code via pull request` or `decide then code via pull request` in place of `code` or `decide then code`.
30
31
 
31
32
  A question or exploratory discussion is not by itself authorization to create a durable decision or implement changes.
32
33
  Do not choose `decide then code` merely because the work is large.
33
34
  Consult @specs/map.md for relevant context and @specs/meta.md for spec requirements, if needed.
34
35
  ```
35
36
 
36
- The planning result has four semantic outcomes: needs Boss reply, discussion complete, code, and decide then code.
37
+ The planning result has six semantic outcomes: needs Boss reply, discussion complete, code, decide then code, code via pull request, and decide then code via pull request.
37
38
  Each outcome requires affirmative support in Analyst's result; absence of a reason to choose another outcome is not support.
38
39
  No outcome depends on a fixed presentation format of Analyst's reply.
39
40
  `dev` shall act on the accepted outcome itself and shall not return to the session Captain for another routing decision.
@@ -66,7 +67,27 @@ Only after `decide` succeeds shall `dev` call playbook `code` with the developme
66
67
 
67
68
  `dev` shall not separately call `review` for the design scope already reviewed by `decide`.
68
69
 
70
+ For code via pull request and decide then code via pull request, `dev` shall first call playbook `branch` with the development request, relevant discussion context, and planning result in quotes (`>`).
71
+
72
+ > Original request: <development-request>
73
+ > Prior discussion: <discussion-context>
74
+ > Planning result: <planning-result>
75
+
76
+ Only after `branch` succeeds shall `dev` continue with the `code` call for code via pull request, or the `decide` call and then the `code` call for decide then code via pull request, each with the same input as its plain path above.
77
+
78
+ On a plain path, `code` success completes `dev`.
79
+ On a pull-request path, only after `code` succeeds shall `dev` call playbook `pr` with the development request, issue summary, branch, base revision, last `code`-owned commit, and exact final evaluated repository revision in quotes (`>`).
80
+
81
+ > Original request: <development-request>
82
+ > Issue summary: <issue-summary>
83
+ > Branch: <branch>
84
+ > Base revision: <base-revision>
85
+ > CODE commit: <last-code-commit>
86
+ > Evaluated revision: <final-evaluated-revision>
87
+
88
+ A plain request calls neither `branch` nor `pr`.
89
+
69
90
  `dev` completes with the successful result of its final child call.
70
- If a child returns an authored abort or failure, or a terminal result that does not prove the success required for the selected path, `dev` shall start no later child and shall relay that canonical result.
91
+ If a child returns an authored abort or failure, or a terminal result that does not prove the success required for the selected path, `dev` shall start no later child and shall relay that canonical result; a `branch` or `pr` failure ends `dev` under this same rule.
71
92
  If a child call fails outside its authored result contract, `dev` shall park as failed and retain the control-plane error.
72
- `dev` shall consume commit identities only from each child's canonical structured result, never from player prose.
93
+ `dev` shall consume commit, revision, branch, and pull-request identities only from each child's canonical structured result, never from player prose.