@popovych.co/witness 0.28.2 → 0.29.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 (207) hide show
  1. package/README.md +15 -3
  2. package/dist/abandon.d.ts +67 -0
  3. package/dist/act.d.ts +17 -0
  4. package/dist/act.js +70 -0
  5. package/dist/adopt.d.ts +21 -0
  6. package/dist/allowlist.d.ts +48 -0
  7. package/dist/allowlist.js +79 -5
  8. package/dist/arbiter.d.ts +37 -0
  9. package/dist/arbiter.js +7 -5
  10. package/dist/ask.d.ts +29 -0
  11. package/dist/ask.js +11 -5
  12. package/dist/autonomy.d.ts +46 -0
  13. package/dist/autonomy.js +24 -12
  14. package/dist/awake.d.ts +15 -0
  15. package/dist/basis.d.ts +9 -0
  16. package/dist/battery.d.ts +23 -0
  17. package/dist/bin.d.ts +2 -0
  18. package/dist/busy.d.ts +38 -0
  19. package/dist/busy.js +274 -0
  20. package/dist/caps.d.ts +21 -0
  21. package/dist/caps.js +24 -3
  22. package/dist/cli.d.ts +18 -0
  23. package/dist/config-file.d.ts +12 -0
  24. package/dist/config.d.ts +96 -0
  25. package/dist/config.js +2 -1
  26. package/dist/contain.d.ts +16 -0
  27. package/dist/context.d.ts +25 -0
  28. package/dist/criteria.d.ts +27 -0
  29. package/dist/criteria.js +2 -1
  30. package/dist/decide-view.d.ts +52 -0
  31. package/dist/decide-view.js +155 -0
  32. package/dist/decisions.d.ts +23 -0
  33. package/dist/deferral.d.ts +26 -0
  34. package/dist/delta.d.ts +58 -0
  35. package/dist/departure.d.ts +66 -0
  36. package/dist/design.d.ts +34 -0
  37. package/dist/drafts.d.ts +31 -0
  38. package/dist/drafts.js +5 -3
  39. package/dist/drift.d.ts +23 -0
  40. package/dist/drive-presence.d.ts +30 -0
  41. package/dist/drive-presence.js +29 -6
  42. package/dist/drive-report.d.ts +24 -0
  43. package/dist/drive-report.js +4 -4
  44. package/dist/drive.d.ts +114 -0
  45. package/dist/drive.js +328 -115
  46. package/dist/dsl.d.ts +23 -0
  47. package/dist/dsl.js +8 -3
  48. package/dist/evidence.d.ts +67 -0
  49. package/dist/evidence.js +8 -2
  50. package/dist/floor.d.ts +6 -0
  51. package/dist/fm.d.ts +9 -0
  52. package/dist/gate-run-view.d.ts +57 -0
  53. package/dist/gate-run-view.js +100 -0
  54. package/dist/gate.d.ts +91 -0
  55. package/dist/gate.js +51 -71
  56. package/dist/gates/decompose.d.ts +1 -0
  57. package/dist/gates/decompose.js +3 -1
  58. package/dist/gates/design.d.ts +1 -0
  59. package/dist/gates/design.js +6 -2
  60. package/dist/gates/implement.d.ts +1 -0
  61. package/dist/gates/implement.js +20 -5
  62. package/dist/gates/index.d.ts +5 -0
  63. package/dist/gates/plan.d.ts +1 -0
  64. package/dist/gates/plan.js +10 -4
  65. package/dist/gates/ship.d.ts +1 -0
  66. package/dist/gates/ship.js +13 -6
  67. package/dist/gitio.d.ts +35 -0
  68. package/dist/gitio.js +31 -3
  69. package/dist/glob.d.ts +2 -0
  70. package/dist/harness.d.ts +73 -0
  71. package/dist/harness.js +36 -15
  72. package/dist/history.d.ts +10 -0
  73. package/dist/idlists.d.ts +2 -0
  74. package/dist/install.d.ts +29 -0
  75. package/dist/journal.d.ts +74 -0
  76. package/dist/journal.js +5 -1
  77. package/dist/junit.d.ts +9 -0
  78. package/dist/live.d.ts +29 -0
  79. package/dist/live.js +15 -3
  80. package/dist/lock.d.ts +9 -0
  81. package/dist/matcher.d.ts +8 -0
  82. package/dist/migration.d.ts +25 -0
  83. package/dist/model.d.ts +8 -0
  84. package/dist/models.d.ts +9 -0
  85. package/dist/models.js +10 -0
  86. package/dist/needs-you.d.ts +91 -0
  87. package/dist/needs-you.js +153 -51
  88. package/dist/needs.d.ts +44 -0
  89. package/dist/needs.js +37 -7
  90. package/dist/notify.d.ts +12 -0
  91. package/dist/opener.d.ts +15 -0
  92. package/dist/pin.d.ts +12 -0
  93. package/dist/pin.js +9 -2
  94. package/dist/principles.d.ts +3 -0
  95. package/dist/probe.d.ts +1 -0
  96. package/dist/progress.d.ts +3 -0
  97. package/dist/progress.js +2 -0
  98. package/dist/recommend.d.ts +31 -0
  99. package/dist/recommend.js +51 -42
  100. package/dist/refusal.d.ts +20 -0
  101. package/dist/refusal.js +12 -4
  102. package/dist/registry.d.ts +1 -0
  103. package/dist/released-comments.d.ts +1 -0
  104. package/dist/review.d.ts +27 -0
  105. package/dist/reviewed.d.ts +27 -0
  106. package/dist/reviewed.js +9 -0
  107. package/dist/reviewer.d.ts +47 -0
  108. package/dist/rounds.d.ts +139 -0
  109. package/dist/rounds.js +75 -25
  110. package/dist/runner-lock.d.ts +5 -0
  111. package/dist/runner.d.ts +30 -0
  112. package/dist/scan.d.ts +27 -0
  113. package/dist/schemas.d.ts +11 -0
  114. package/dist/schemas.js +7 -3
  115. package/dist/session-clock.d.ts +16 -0
  116. package/dist/settings.d.ts +73 -0
  117. package/dist/settings.js +12 -2
  118. package/dist/settle.d.ts +62 -0
  119. package/dist/settle.js +177 -39
  120. package/dist/sha.d.ts +5 -0
  121. package/dist/ship-outcome.d.ts +24 -0
  122. package/dist/ship-outcome.js +76 -0
  123. package/dist/ship.d.ts +31 -0
  124. package/dist/ship.js +324 -82
  125. package/dist/slice.d.ts +45 -0
  126. package/dist/slice.js +2 -2
  127. package/dist/snapshot.d.ts +10 -0
  128. package/dist/spawn.d.ts +22 -0
  129. package/dist/stamp.d.ts +33 -0
  130. package/dist/stamp.js +20 -8
  131. package/dist/steps.d.ts +31 -0
  132. package/dist/steps.js +39 -10
  133. package/dist/toon.d.ts +17 -0
  134. package/dist/toon.js +150 -14
  135. package/dist/txn.d.ts +28 -0
  136. package/dist/usage.d.ts +25 -0
  137. package/dist/verbs/abandon.d.ts +2 -0
  138. package/dist/verbs/adopt.d.ts +2 -0
  139. package/dist/verbs/adopt.js +9 -4
  140. package/dist/verbs/ask.d.ts +2 -0
  141. package/dist/verbs/check.d.ts +2 -0
  142. package/dist/verbs/check.js +29 -10
  143. package/dist/verbs/clean.d.ts +2 -0
  144. package/dist/verbs/dashboard.d.ts +59 -0
  145. package/dist/verbs/dashboard.js +11 -3
  146. package/dist/verbs/decide.d.ts +46 -0
  147. package/dist/verbs/decide.js +168 -149
  148. package/dist/verbs/design.d.ts +2 -0
  149. package/dist/verbs/design.js +8 -5
  150. package/dist/verbs/diff.d.ts +2 -0
  151. package/dist/verbs/diff.js +4 -2
  152. package/dist/verbs/dismiss.d.ts +2 -0
  153. package/dist/verbs/dispatch.d.ts +2 -0
  154. package/dist/verbs/dispatch.js +2 -2
  155. package/dist/verbs/draft.d.ts +2 -0
  156. package/dist/verbs/draft.js +6 -3
  157. package/dist/verbs/drive.d.ts +2 -0
  158. package/dist/verbs/evidence.d.ts +5 -0
  159. package/dist/verbs/evidence.js +40 -3
  160. package/dist/verbs/floor.d.ts +2 -0
  161. package/dist/verbs/gate.d.ts +3 -0
  162. package/dist/verbs/index-verb.d.ts +2 -0
  163. package/dist/verbs/init.d.ts +2 -0
  164. package/dist/verbs/log.d.ts +9 -0
  165. package/dist/verbs/migrate.d.ts +13 -0
  166. package/dist/verbs/next.d.ts +78 -0
  167. package/dist/verbs/next.js +373 -131
  168. package/dist/verbs/read.d.ts +2 -0
  169. package/dist/verbs/read.js +3 -1
  170. package/dist/verbs/recap.d.ts +28 -0
  171. package/dist/verbs/recap.js +3 -3
  172. package/dist/verbs/recover.d.ts +5 -0
  173. package/dist/verbs/recover.js +14 -9
  174. package/dist/verbs/rename.d.ts +2 -0
  175. package/dist/verbs/rename.js +1 -1
  176. package/dist/verbs/retry.d.ts +2 -0
  177. package/dist/verbs/review.d.ts +2 -0
  178. package/dist/verbs/review.js +1 -1
  179. package/dist/verbs/satisfy.d.ts +2 -0
  180. package/dist/verbs/ship.d.ts +3 -0
  181. package/dist/verbs/start.d.ts +2 -0
  182. package/dist/verbs/start.js +12 -7
  183. package/dist/verbs/step-close.d.ts +2 -0
  184. package/dist/verbs/sync.d.ts +15 -0
  185. package/dist/verbs/trust.d.ts +4 -0
  186. package/dist/verbs/trust.js +34 -32
  187. package/dist/verbs/turn.d.ts +2 -0
  188. package/dist/verbs/wait.d.ts +9 -0
  189. package/dist/verbs/wait.js +33 -8
  190. package/dist/verbs/write.d.ts +18 -0
  191. package/dist/verbs/write.js +11 -5
  192. package/dist/verdict.d.ts +60 -0
  193. package/dist/version.d.ts +4 -0
  194. package/dist/worker-stream.d.ts +22 -0
  195. package/dist/worktree.d.ts +22 -0
  196. package/dist/worktree.js +1 -1
  197. package/package.json +7 -1
  198. package/plugin/.claude-plugin/plugin.json +1 -1
  199. package/plugin/commands/witness.md +17 -11
  200. package/plugin/hooks/canon-guard.mjs +71 -10
  201. package/plugin/hooks/session-dashboard.sh +1 -1
  202. package/plugin/skills/witness-brainstorm/SKILL.md +3 -3
  203. package/plugin/skills/witness-decompose/SKILL.md +3 -3
  204. package/plugin/skills/witness-design/SKILL.md +2 -2
  205. package/plugin/skills/witness-implement/SKILL.md +5 -5
  206. package/plugin/skills/witness-plan/SKILL.md +3 -3
  207. package/plugin/skills/witness-ship/SKILL.md +3 -3
package/README.md CHANGED
@@ -181,7 +181,7 @@ the list the CLI reads (`src/settings.ts`).
181
181
  | `criteria.exclude` | extra globs never scanned for criteria tags · [] = none — accepts: a list of globs ([] = none) | `[]` |
182
182
  | `ship.test` | the suite command ship runs · full-suite criteria run it too — accepts: a shell command | `npm test` |
183
183
  | `ship.lint` | the lint command ship runs — accepts: a shell command | `npm run lint` |
184
- | `ship.branch` | the branch witness ships into — accepts: a branch name | `main` |
184
+ | `ship.branch` | the branch witness ships into — accepts: a branch name: letters, digits and . _ / + -, as git allows them — it is printed into git commands | `main` |
185
185
  | `ship.merge` | how ship merges its own PR under autonomy · merge \| squash \| rebase — accepts: merge \| squash \| rebase | `merge` |
186
186
  | `ship.ciSettleMs` | ms green CI must hold still before an autonomous merge · 0–1800000 — accepts: an integer from 0 to 1800000 — milliseconds a green check set must hold before witness merges | `60000` |
187
187
  | `autonomy` | on = the CLI settles its own stops and merges green PRs · on \| off · counts once committed — accepts: on \| off | `off` |
@@ -244,7 +244,19 @@ own and every `witness turn`, which is how a session runs its tests — because
244
244
  servers or browsers collide. On Windows each session, test run and gate reviewer runs in a job
245
245
  object, so whatever it starts — detached, or orphaned by an installer that exited — ends with it;
246
246
  elsewhere a session's process group does. A target that reaches any `drive.caps.*` bound is
247
- parked.
247
+ parked. Below the round bound a parked gate goes back to work with your own
248
+ `witness decide <gate> <target> --revise --note "<why>"` — it lifts the park without running the
249
+ gate, and `next` routes the owed work, steps first; `witness status` and `decide --show` print it on a
250
+ `revise:` row, beside a `fresh:` row (a re-review of the work as it stands) when no work is owed. It
251
+ also restarts drive's caps for that target.
252
+
253
+ A ship that ends on a hold only you can clear is a stop of yours, remembered in the journal, so it
254
+ survives a drive restart: `waiting: merge` (no CI checks, or none passed) with the merge command
255
+ pinned to the approved commit (`gh pr merge N --<ship.merge> --match-head-commit <sha>`), or
256
+ `waiting: fix` (the PR aims at another branch, was closed, holds commits the worktree lacks, or a
257
+ login was refused) with no merge command at all. Each has a `recheck:` row, `witness ship <plan>`,
258
+ for when you have acted. A hold that clears by itself — CI still running, GitHub not answering — is
259
+ drive's to check again, within its caps.
248
260
 
249
261
  ### Upgrading
250
262
 
@@ -302,7 +314,7 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
302
314
  | `next` | the one next action across every effort |
303
315
  | `drive [--flow <plan-id>] [--max-spawns <n>] [--manual] [--detach]` | runs every session itself · under autonomy it needs no terminal and reports when nothing else can move. Up to `drive.parallel` targets at once, one session per target; usage limits are waited out; a target past a cap is parked. `--detach` (autonomy only) runs it in the background into `.witness/drive.log` — each session's start, every command and file its agent touches, every act it journals for its flow, a `still running` line after 5 quiet minutes, and how it ended; drive's pi sessions are kept in pi's session store under `witness-drive/`; `--manual` runs serially and asks you at every stop. One drive per repo. A session drive spawned is refused — agents are what drive spawns, never what spawns drive |
304
316
  | `ship <plan-id> [--manual]` | lanes → ship gate → PR → CI watch → under autonomy: merge on green · `--manual` keeps that run's stop and merge for a human |
305
- | `test-evidence <plan-id> --phase red\|green [--step <id>]` / `verify-red <plan-id> [--base <ref>] [--step <id>]` | journal red/green criteria evidence from a worktree; `--step` names the plan step the cycle closes — required before the plan's first implement gate (on a plan with a criteria step), left off for a fix round after it. A green that closes a step prints `context:`, `steps:` and `slice:` |
317
+ | `test-evidence <plan-id> --phase red\|green [--step <id>]` / `verify-red <plan-id> [--base <ref>] [--step <id>]` | journal red/green criteria evidence from a worktree; `--step` names the plan step the cycle closes — required before the plan's first implement gate (on a plan with a criteria step), and after it while a criteria step is open (an amendment's step routes first); left off for a fix round, once every step is closed. A green that closes a step prints `context:`, `steps:` and `slice:` |
306
318
  | `turn -- <command> [args…]` | run one command in the repo's test turn — it waits while another worktree's test run holds it, unless `drive.parallelSuites: true` — and on Windows inside a job object, so whatever it starts ends with it; exits with the command's code · the implement and ship skills run every test a session runs itself through it |
307
319
  | `step-close <plan-id> --step <id>` | close a scaffolding step, which has no red→green to witness; prints `context:`, `steps:` and `slice:` as a closing green does, and closing it again changes nothing |
308
320
  | `adopt <path>` | absolve a finished hand-edit into the journal — content only: a hand edit that moves `status`, `drift`, `pr` or `design` is refused, since only witness writes a doc's position |
@@ -0,0 +1,67 @@
1
+ import type { Ctx } from './cli.js';
2
+ import { type Departure, type Return, type WriteAct } from './departure.js';
3
+ import { type StatusEntry } from './journal.js';
4
+ import { type Canon, type CanonDoc } from './scan.js';
5
+ import { type Result, type Violation } from './refusal.js';
6
+ import { type PreparedStamp } from './stamp.js';
7
+ export declare function writeAct(root: string, id: string, sha: string, at?: string, among?: ReadonlySet<string>): WriteAct | undefined;
8
+ export declare function stoodAtAbandon(root: string, effort: string, rel: string, sha: string): boolean;
9
+ export declare const effortWrite: (root: string, effort: string, id: string, sha?: string) => {
10
+ commit: string;
11
+ } | undefined;
12
+ export declare function leftUnder(root: string, canon: Canon, spec: CanonDoc, effort: string, walk: Walk, abandonSet: Set<string>): string | undefined;
13
+ export declare function takenBackAlready(root: string, effort: string, id: string, rel: string, sha: string): boolean;
14
+ export interface Walk {
15
+ passed: string[];
16
+ stop?: {
17
+ src: string;
18
+ sha: string;
19
+ };
20
+ }
21
+ export type SpecRevert = {
22
+ doc: CanonDoc;
23
+ action: 'restore';
24
+ content: string;
25
+ toStatus: string;
26
+ design?: {
27
+ rel: string;
28
+ prior: Buffer | undefined;
29
+ };
30
+ returns: Return[];
31
+ unwound: StatusEntry[];
32
+ walk: Walk;
33
+ } | {
34
+ doc: CanonDoc;
35
+ action: 'delete';
36
+ departure: Departure;
37
+ returns: Return[];
38
+ unwound: StatusEntry[];
39
+ walk: Walk;
40
+ };
41
+ export interface SpecKeep {
42
+ doc: CanonDoc;
43
+ action: 'keep';
44
+ standing: string[];
45
+ shipped: boolean;
46
+ }
47
+ export declare const keptLine: (k: SpecKeep) => string;
48
+ export declare function abandonLines(items: AbandonItem[], kept: SpecKeep[]): string[];
49
+ export declare function specRevertFor(root: string, canon: Canon, spec: CanonDoc, pin: string, abandonSet: Set<string>, act: WriteAct, efforts?: string[]): Result<SpecRevert | SpecKeep | undefined>;
50
+ export interface AbandonItem {
51
+ planStamp?: PreparedStamp;
52
+ planId?: string;
53
+ revert?: SpecRevert;
54
+ kept?: SpecKeep;
55
+ note?: string;
56
+ }
57
+ export declare function returnCollisions(root: string, canon: Canon, items: AbandonItem[]): Violation[];
58
+ export declare function landingEdges(root: string, canon: Canon, items: AbandonItem[], abandonSet?: Set<string>): Violation[];
59
+ export declare function keepDependencies(items: AbandonItem[], kept: SpecKeep[]): {
60
+ items: AbandonItem[];
61
+ kept: SpecKeep[];
62
+ };
63
+ export declare function executeAbandon(root: string, ctx: Ctx, items: AbandonItem[], efforts: string[], subject: string): Result<{
64
+ sha: string;
65
+ }>;
66
+ export type Pairing = 'pair-parent' | 'stamp-only';
67
+ export declare function planItems(root: string, canon: Canon, plan: CanonDoc, abandonSet: Set<string>, pairing: Pairing): Result<AbandonItem>;
package/dist/act.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { type Platform } from './toon.js';
2
+ export type ActInputName = 'why' | 'effort';
3
+ export interface ActInput {
4
+ name: ActInputName;
5
+ at: number;
6
+ }
7
+ export interface Act {
8
+ argv: readonly string[];
9
+ inputs: readonly ActInput[];
10
+ line: string;
11
+ withheld?: string;
12
+ }
13
+ export declare function actOn(platform: Platform, argv: readonly string[]): Act;
14
+ export declare function cliAct(...argv: string[]): Act;
15
+ export declare function runRow(act: Act, label?: 'run' | 'then' | 'revise' | 'fresh' | 'recheck', indent?: string): string;
16
+ export declare function exitsLine(acts: readonly Act[], platform?: Platform): string;
17
+ export declare function reopenRows(reopen: readonly Act[]): string[];
package/dist/act.js ADDED
@@ -0,0 +1,70 @@
1
+ import { shellWord, withheldOn } from './toon.js';
2
+ // Rows 139/203. Inputs are positional: the CLI writes `<why>` only as a note and `<effort>` only
3
+ // as an upstream, so those two words, whole and in those two slots, are the only ones a human
4
+ // fills. Any other word is literal, even one that reads `<why>`: a repo-authored trust command
5
+ // stays a literal grant and never becomes a slot to fill.
6
+ const slotOf = (flag) => flag === '--note' ? 'why' : flag === '--upstream' ? 'effort' : undefined;
7
+ function inputAt(argv, at) {
8
+ const name = slotOf(argv[at - 1]);
9
+ return name !== undefined && argv[at] === `<${name}>` ? name : undefined;
10
+ }
11
+ // One word as the line prints it. An input prints as it always has, `"<why>"` or `<effort>`: a
12
+ // placeholder the human replaces, never pasted as it stands. Row 239: every other word prints
13
+ // through the quoter (`shellWord`), the `--note` and `--cmd` words included — bare where the
14
+ // platform's shell reads it as written, so a line of ids and flags prints byte for byte as it
15
+ // always did, and quoted where not. A line therefore reads back by the quoter's grammar (off
16
+ // Windows, `shellWords`), no longer by D120's raw `--note "…"`, and a word pastes as the one word
17
+ // it is, whatever quotes, spaces or `$(…)` it holds: an id, a note, or a repo-authored command the
18
+ // trust verb takes as one word.
19
+ function word(argv, at, platform) {
20
+ const w = argv[at];
21
+ const input = inputAt(argv, at);
22
+ if (input === 'why')
23
+ return `"${w}"`;
24
+ return input === 'effort' ? w : shellWord(w, platform);
25
+ }
26
+ const words = (argv, platform) => argv.map((_, at) => word(argv, at, platform));
27
+ // Row 239. An act printed for the shell `platform` pastes into: bash, zsh or dash off Windows,
28
+ // PowerShell on it. An input is the CLI's own placeholder, so it is never withheld.
29
+ export function actOn(platform, argv) {
30
+ const inputs = argv.flatMap((_, at) => {
31
+ const name = inputAt(argv, at);
32
+ return name !== undefined ? [{ name, at }] : [];
33
+ });
34
+ const withheld = withheldOn(argv.filter((_, at) => inputAt(argv, at) === undefined), platform);
35
+ return { argv, inputs, line: ['witness', ...words(argv, platform)].join(' '), ...(withheld !== undefined ? { withheld } : {}) };
36
+ }
37
+ // An act for this machine's shell.
38
+ export function cliAct(...argv) {
39
+ return actOn(process.platform, argv);
40
+ }
41
+ // Row 239 (the plan's B4, ruling R16(b)). An act as the row printed under the line it belongs to:
42
+ // `run: <line>`, or `then:` for the step after it. An act that is withheld is shown with why on a
43
+ // `note:` row, which offers nothing to paste. Every `run:` and `then:` row printed from an act goes
44
+ // through here, so no printer can forget the check, but one: a decision block's own `run:` line
45
+ // (`renderDecision`), which prints only an option `option()` made `runnable`, and `option()` never
46
+ // makes a withheld act runnable.
47
+ export function runRow(act, label = 'run', indent = ' ') {
48
+ return act.withheld === undefined ? `${indent}${label}: ${act.line}` : `${indent}note: ${act.line} — ${act.withheld}`;
49
+ }
50
+ // `liveExits`' grammar: the acts' lines joined by ` | `, where a decide act on the same gate and
51
+ // target as the act before it prints only the words after them — `witness decide plan p1
52
+ // --approve | --stop`. A decide act with no word past its target prints whole, never as an
53
+ // empty segment. Row 239: those words print for `platform`, the one the acts were built for.
54
+ export function exitsLine(acts, platform = process.platform) {
55
+ return acts.map((a, i) => {
56
+ const prev = acts[i - 1];
57
+ const shared = prev !== undefined && a.argv[0] === 'decide' && a.argv.length > 3 &&
58
+ [0, 1, 2].every((k) => a.argv[k] === prev.argv[k]);
59
+ return shared ? words(a.argv, platform).slice(3).join(' ') : a.line;
60
+ }).join(' | ');
61
+ }
62
+ // Row 241 (R11). A parked gate's reopen as rows: below the bound a `revise:` row, and a `fresh:` row
63
+ // beside it when no work is owed; at the bound the endgame menu, a set of choices, as `exits:`.
64
+ export function reopenRows(reopen) {
65
+ const labelOf = (a) => a.argv[0] === 'decide' && a.argv.includes('--revise') && !a.argv.includes('--upstream') && !a.argv.includes('--repair') ? 'revise'
66
+ : a.argv[0] === 'gate' && a.argv.includes('--fresh') ? 'fresh' : undefined;
67
+ if (reopen.length > 0 && reopen.every((a) => labelOf(a) !== undefined))
68
+ return reopen.map((a) => runRow(a, labelOf(a)));
69
+ return reopen.length === 1 ? [runRow(reopen[0])] : [` exits: ${exitsLine(reopen)}`];
70
+ }
@@ -0,0 +1,21 @@
1
+ import { VOLATILE_FIELDS } from './sha.js';
2
+ export type Position = Record<(typeof VOLATILE_FIELDS)[number], unknown>;
3
+ export interface Witnessed {
4
+ sha: string;
5
+ criteria: unknown;
6
+ id: string;
7
+ commit: string;
8
+ position: Position;
9
+ }
10
+ export declare const positionOf: (meta: Record<string, unknown>) => Position;
11
+ export declare function lastWitnessed(root: string, rel: string, absolved?: Set<string>, opts?: {
12
+ follow?: boolean;
13
+ }): Witnessed | undefined;
14
+ export declare function untrailedCommitsFor(root: string, rel: string): string[];
15
+ export declare function adoptedCommits(root: string): Set<string>;
16
+ export declare function adoptedCommitsFor(root: string, id: string): Set<string>;
17
+ export declare function absolutions(root: string): Map<string, Set<string>>;
18
+ export declare function unabsolvedPaths(root: string, sha: string, ids: Set<string>, dirs: {
19
+ docs: string[];
20
+ other: string[];
21
+ }): string[];
@@ -0,0 +1,48 @@
1
+ import { type Act } from './act.js';
2
+ import type { Ctx } from './cli.js';
3
+ import type { Config } from './config.js';
4
+ import { type Result } from './refusal.js';
5
+ import { type Canon, type CanonDoc } from './scan.js';
6
+ import { type Platform } from './toon.js';
7
+ export declare function trustedCommands(root: string): string[];
8
+ export declare function grantCommands(root: string, cmds: string[]): void;
9
+ export declare function untrustedCmdsFor(root: string, doc: CanonDoc | undefined): string[];
10
+ export interface RunCommand {
11
+ cmd: string;
12
+ source: string;
13
+ }
14
+ export declare const shownCmd: (c: RunCommand) => string;
15
+ export declare const UNGRANTABLE = "never granted here \u2014 rewrite it in printable ASCII where it is written";
16
+ export declare const unsafeLeft: (n: number) => string;
17
+ export declare function grantAct(target: string, c: Pick<RunCommand, 'cmd'>, platform?: Platform): Act | undefined;
18
+ export declare const grantOf: (target: string, c: Pick<RunCommand, "cmd">, platform?: Platform) => string;
19
+ export declare function grantRows(target: string, c: Pick<RunCommand, 'cmd'>, platform?: Platform): string[];
20
+ export declare function grantRowsOf(grant: Act | undefined, list: Act): string[];
21
+ export declare function configCommands(cfg: Config): RunCommand[];
22
+ export declare function commandsRun(cfg: Config, canon: Canon, doc: CanonDoc): RunCommand[];
23
+ export declare function sourced(cfg: Config, canon: Canon, target: string, cmds: readonly string[]): RunCommand[];
24
+ export declare function repoCommands(cfg: Config, canon: Canon): Array<RunCommand & {
25
+ doc: string;
26
+ }>;
27
+ export type TrustStatus = 'trusted' | 'untrusted' | 'unsafe';
28
+ export interface TrustRow {
29
+ cmd: string;
30
+ source: string;
31
+ doc?: string;
32
+ status: TrustStatus;
33
+ }
34
+ export interface TrustListing {
35
+ target?: string;
36
+ rows: TrustRow[];
37
+ pending: Act[];
38
+ untrusted: number;
39
+ unsafe: number;
40
+ }
41
+ export declare const pendingCmds: (listing: TrustListing) => string[];
42
+ export declare function pendingRows(listing: TrustListing, platform?: Platform): string[];
43
+ export declare function trustListing(root: string, cfg: Config, canon: Canon, target?: string, platform?: Platform): Result<TrustListing>;
44
+ export declare function trustOwed(root: string, env: Record<string, string | undefined>, cfg: Config, canon: Pick<Canon, 'docs'>, action: {
45
+ line: string;
46
+ target?: string;
47
+ }): RunCommand[];
48
+ export declare function ensureTrusted(root: string, ctx: Ctx, cmd: string): Promise<'trusted' | 'declined' | 'blocked'>;
package/dist/allowlist.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import { actOn, runRow } from './act.js';
3
4
  import { heldCriteria } from './needs.js';
4
- import { criteriaOwner } from './scan.js';
5
- import { hasControl, shellArg, visible } from './toon.js';
5
+ import { ok, refuse, v } from './refusal.js';
6
+ import { criteriaOwner, findById } from './scan.js';
7
+ import { hasControl, visible } from './toon.js';
6
8
  const allowPath = (root) => join(root, '.witness', 'allow.json');
7
9
  function load(root) {
8
10
  if (!existsSync(allowPath(root)))
@@ -55,12 +57,41 @@ export function untrustedCmdsFor(root, doc) {
55
57
  // that names it only when the verb would take it (printable ASCII, `witness trust`).
56
58
  export const shownCmd = (c) => `${visible(c.cmd)} (${visible(c.source)})`;
57
59
  export const UNGRANTABLE = 'never granted here — rewrite it in printable ASCII where it is written';
58
- export const grantOf = (target, c) => hasControl(c.cmd)
59
- ? UNGRANTABLE
60
- : `witness trust ${target} --cmd ${shellArg(c.cmd)}`;
61
60
  // Row 205. The commands a grant leaves blocked for that reason, counted: the trust verb's summary
62
61
  // and `decide --approve --trust-cmds` say it in these words.
63
62
  export const unsafeLeft = (n) => `${n} carry characters outside printable ASCII — never granted here · rewrite where it is written`;
63
+ // Rows 139/203. The grant as an act: the raw command one argv word, so it runs without a shell.
64
+ // A command the verb would not take has none, so no model ever holds an act for it.
65
+ export function grantAct(target, c, platform = process.platform) {
66
+ return hasControl(c.cmd) ? undefined : actOn(platform, ['trust', target, '--cmd', c.cmd]);
67
+ }
68
+ // The grant's line, or why there is none. Row 239: a grant Windows withholds (`Act.withheld`) is
69
+ // never offered to be pasted, so the line names the listing instead, which grants nothing by
70
+ // itself: the command stays pending, and at a terminal the listing asks for each one.
71
+ export const grantOf = (target, c, platform = process.platform) => {
72
+ const act = grantAct(target, c, platform);
73
+ if (act === undefined)
74
+ return UNGRANTABLE;
75
+ return act.withheld === undefined ? act.line
76
+ : `${act.withheld} · at a terminal, ${actOn(platform, ['trust', target]).line} asks for each command`;
77
+ };
78
+ // Row 239 (the plan's B12). A grant as the rows printed under the line that names its command: a
79
+ // kept stop's, or the inbox's `wait:`. That line holds the repo's command, which can spell a grant
80
+ // of its own, so the grant is never printed after it: it is a `run:` row of its own. A command the
81
+ // verb would not take gets a note and no `run:`. One Windows withholds gets its note, then the
82
+ // listing, which grants nothing by itself: the command stays pending (`trustListing`), and at a
83
+ // terminal the listing asks for each one.
84
+ export function grantRows(target, c, platform = process.platform) {
85
+ return grantRowsOf(grantAct(target, c, platform), actOn(platform, ['trust', target]));
86
+ }
87
+ // The same rows from a grant already built, as a model holds it: never the bytes of a command the
88
+ // verb would not take, so the act decides (`TrustGrant`). `list` is the target's listing. Ruling
89
+ // R16(b): both print through `runRow`, so a listing Windows withholds too is a note, never a `run:`.
90
+ export function grantRowsOf(grant, list) {
91
+ if (grant === undefined)
92
+ return [` note: ${UNGRANTABLE}`];
93
+ return grant.withheld === undefined ? [runRow(grant)] : [` note: ${grant.withheld}`, runRow(list)];
94
+ }
64
95
  // The filtered runner template, `ship.test`, `ship.lint`, each when set. Full-suite mode's
65
96
  // runner IS `ship.test`, and a command listed twice is listed once, under its first source.
66
97
  export function configCommands(cfg) {
@@ -103,6 +134,49 @@ export function repoCommands(cfg, canon) {
103
134
  ...canon.docs.flatMap((d) => [...cmdCriteria(d), ...cmdNeeds(d)].map((c) => ({ ...c, doc: String(d.meta.id) }))),
104
135
  ];
105
136
  }
137
+ // A trusted command is trusted whatever it holds; an untrusted one is grantable only in
138
+ // printable ASCII.
139
+ const trustStatus = (trusted, cmd) => trusted.has(cmd) ? 'trusted' : hasControl(cmd) ? 'unsafe' : 'untrusted';
140
+ // Row 205. The commands a target listing offers to grant, as exact bytes: each pending act's
141
+ // `--cmd` word (`grantAct`: `trust <target> --cmd <cmd>`). Read off the listing, so a grant flow
142
+ // grants from the same allow.json snapshot its rows were read from.
143
+ export const pendingCmds = (listing) => listing.pending.map((a) => a.argv[3]);
144
+ // Row 239 (the plan's B5). The trust verb's rows for the grants it offers when it granted nothing:
145
+ // each pending grant's line to run, and for one Windows withholds its command, escaped, with why it
146
+ // is not offered and the listing that asks for it at a terminal, where it stays pending.
147
+ export function pendingRows(listing, platform = process.platform) {
148
+ return listing.pending.map((a) => a.withheld === undefined ? runRow(a, 'run', '')
149
+ : `note: ${visible(a.argv[3])} — ${a.withheld} · at a terminal, ${actOn(platform, ['trust', listing.target]).line} asks for each command`);
150
+ }
151
+ // Row 239. `platform` is the shell the grants are printed for: a grant Windows withholds stays
152
+ // pending, so the verb's terminal prompt and `--yes` still reach it.
153
+ export function trustListing(root, cfg, canon, target, platform = process.platform) {
154
+ if (target === undefined)
155
+ return ok(listingOf(root, repoCommands(cfg, canon)));
156
+ const doc = findById(canon, target);
157
+ if (!doc)
158
+ return refuse([v('artifact', 'unknown-artifact', target, 'an existing canon doc id', 'witness index')]);
159
+ return ok(listingOf(root, commandsRun(cfg, canon, doc), target, platform));
160
+ }
161
+ // The counts are of the raw commands, never of their escaped rows: two commands can escape to
162
+ // the same text.
163
+ function listingOf(root, listed, target, platform = process.platform) {
164
+ const trusted = new Set(load(root));
165
+ const status = (cmd) => trustStatus(trusted, cmd);
166
+ const once = [...new Set(listed.map((c) => c.cmd))];
167
+ const untrusted = once.filter((c) => status(c) === 'untrusted');
168
+ return {
169
+ ...(target !== undefined ? { target } : {}),
170
+ rows: listed.map((c) => ({
171
+ cmd: visible(c.cmd), source: visible(c.source), ...(c.doc !== undefined ? { doc: visible(c.doc) } : {}), status: status(c.cmd),
172
+ })),
173
+ pending: target === undefined ? [] : untrusted.flatMap((cmd) => grantAct(target, { cmd }, platform) ?? []),
174
+ untrusted: untrusted.length,
175
+ // A residual kept byte for byte: the repo listing counts rows, so a command two docs run
176
+ // counts twice.
177
+ unsafe: (target === undefined ? listed.map((c) => c.cmd) : once).filter((c) => status(c) === 'unsafe').length,
178
+ };
179
+ }
106
180
  // Row 205 (issue #56, P5). The commands the routed action's verb runs that this machine does
107
181
  // not trust yet, checked before any work: found only inside the session, a refusal journaled
108
182
  // nothing, `next` routed the same line again and drive respawned it to the cap. Only the
@@ -0,0 +1,37 @@
1
+ import type { Act } from './act.js';
2
+ import type { Ctx } from './cli.js';
3
+ import { type Config } from './config.js';
4
+ import { type Entry } from './journal.js';
5
+ import type { Decision, Option } from './recommend.js';
6
+ import { type Result } from './refusal.js';
7
+ import { type GateRunEntry } from './rounds.js';
8
+ import { type Canon } from './scan.js';
9
+ export type ArbiterMode = 'decision';
10
+ export interface ArbiterSection {
11
+ title: string;
12
+ body: string;
13
+ }
14
+ export interface ArbiterRequest {
15
+ mode: ArbiterMode;
16
+ menu: readonly Option[];
17
+ evidence: readonly ArbiterSection[];
18
+ }
19
+ export interface ArbiterRuling {
20
+ choice: number;
21
+ reason: string;
22
+ note?: string;
23
+ model: string;
24
+ prompts_sha: string;
25
+ }
26
+ export declare const PROMPT_OF: Record<ArbiterMode, string>;
27
+ export declare function arbitrate(ctx: Ctx, root: string, cfg: Config, req: ArbiterRequest): Promise<Result<ArbiterRuling>>;
28
+ export declare function menuFor(block: Decision, run: GateRunEntry): Array<Option & {
29
+ act: Act;
30
+ }>;
31
+ export declare function decisionEvidence(root: string, canon: Canon, stop: {
32
+ gate: string;
33
+ target: string;
34
+ entries: Entry[];
35
+ run: GateRunEntry;
36
+ block: Decision;
37
+ }): Array<ArbiterSection>;
package/dist/arbiter.js CHANGED
@@ -6,7 +6,6 @@ import { serializeDoc } from './fm.js';
6
6
  import { resolveJudge } from './harness.js';
7
7
  import { latestRecap, policyPins } from './journal.js';
8
8
  import { SESSION_DEFAULT, stageModel, unansweredPin } from './model.js';
9
- import { PLACEHOLDER } from './recommend.js';
10
9
  import { ok, refuse, v } from './refusal.js';
11
10
  import { invokeReviewerAsync, parseVerdictText, promptsSha, resolvePrompt } from './reviewer.js';
12
11
  import { effortCanon, effortOf } from './reviewed.js';
@@ -96,13 +95,16 @@ export async function arbitrate(ctx, root, cfg, req) {
96
95
  // The design gate is the exception that holds whatever the evidence says: the look is the
97
96
  // human's (§3 G2), so no approve of it is ever offered — at the bound or past a spent ladder
98
97
  // the arbiter may revise, reset upstream, repair or park, never stamp.
98
+ // Row 239. Read off each option's act, never its printed line: an option the CLI built from no
99
+ // act is not offered, a word is a flag only where the act holds it as one, and the one input the
100
+ // arbiter may fill is the `<why>` slot (settle fills it through argv).
99
101
  export function menuFor(block, run) {
100
102
  const failed = run.checks.filter((c) => !c.ok);
101
103
  const approveBarred = run.gate === 'design' || (failed.length > 0 && !failed.every((c) => c.name === 'amendment-ack'));
102
- return block.options.filter((o) => o.command.startsWith('witness decide ') &&
103
- !/ --trust-cmds\b/.test(o.command) &&
104
- !PLACEHOLDER.test(o.command.replace(' --note "<why>"', '')) &&
105
- !(approveBarred && / --approve\b/.test(o.command)));
104
+ return block.options.filter((o) => o.act?.argv[0] === 'decide' &&
105
+ !o.act.argv.includes('--trust-cmds') &&
106
+ o.act.inputs.every((i) => i.name === 'why') &&
107
+ !(approveBarred && o.act.argv.includes('--approve')));
106
108
  }
107
109
  const anchorText = (a) => (typeof a === 'string' ? a : `omission:${a.scope}`);
108
110
  const HISTORY_RUNS = 10;
package/dist/ask.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import type { Ctx } from './cli.js';
2
+ import { type Result } from './refusal.js';
3
+ export declare const ASK_STREAM = "asks";
4
+ export interface AskEntry {
5
+ v: 1;
6
+ t: 'ask';
7
+ id: string;
8
+ text: string;
9
+ }
10
+ export interface AskStatus {
11
+ id: string;
12
+ text: string;
13
+ state: 'unanswered' | 'answered' | 'withdrawn';
14
+ effort?: string;
15
+ }
16
+ export declare function askText(text: string): string;
17
+ export declare function oneLine(text: string): string;
18
+ export declare function askQueue(root: string): AskStatus[];
19
+ export declare function reservedId(id: string): string | undefined;
20
+ export declare function queueAsk(ctx: Ctx, root: string, text: string): Result<{
21
+ id: string;
22
+ unanswered: number;
23
+ already: boolean;
24
+ }>;
25
+ export declare function withdrawAsk(ctx: Ctx, root: string, id: string, note?: string): Result<{
26
+ already: boolean;
27
+ }>;
28
+ export declare function nextAsk(root: string): AskStatus | undefined;
29
+ export declare function askOf(root: string, effort: string): AskEntry | undefined;
package/dist/ask.js CHANGED
@@ -1,4 +1,6 @@
1
+ import { cliAct } from './act.js';
1
2
  import { draftLine, dropDraft } from './drafts.js';
3
+ import { isId } from './dsl.js';
2
4
  import { FLOOR_STREAM } from './floor.js';
3
5
  import { stateCommit } from './gitio.js';
4
6
  import { appendEntry, effortStreams, entryLine, journalRel, readStream } from './journal.js';
@@ -26,8 +28,10 @@ export function askQueue(root) {
26
28
  // Row 194. A `human-decision` entry on this stream is an old recap check (row 177): history
27
29
  // `log` still prints, and nothing a queue derives from.
28
30
  for (const e of readStream(root, ASK_STREAM)) {
29
- if (e.t === 'ask')
30
- out.push({ id: String(e.id), text: String(e.text), state: 'unanswered' });
31
+ // Row 239 (the plan's B15). An ask is routed as `--ask <id>`, and the journal is text a commit can
32
+ // make anything: an ask named outside the id set is never queued (`witness check`: `ask-id`).
33
+ if (e.t === 'ask' && isId(e.id))
34
+ out.push({ id: e.id, text: String(e.text), state: 'unanswered' });
31
35
  else if (e.t === 'ask-withdrawn') {
32
36
  const a = out.find((x) => x.id === e.ask);
33
37
  if (a)
@@ -86,8 +90,9 @@ export function queueAsk(ctx, root, text) {
86
90
  const open = queue.find((a) => a.state === 'unanswered' && askText(a.text) === askText(text));
87
91
  if (open !== undefined)
88
92
  return ok({ id: open.id, unanswered: unanswered(), already: true });
89
- // numbered under the lock: two queuers racing must not both take the next id
90
- const id = `a${queue.length + 1}`;
93
+ // numbered under the lock: two queuers racing must not both take the next id. Row 239: counted
94
+ // over every ask the stream holds, the ones the queue skips included, so no id is minted twice.
95
+ const id = `a${readStream(root, ASK_STREAM).filter((e) => e.t === 'ask').length + 1}`;
91
96
  const entry = { t: 'ask', id, text: text.trim() };
92
97
  const stream = journalRel(ASK_STREAM);
93
98
  const res = withTxn(root, { op: `ask(${id})`, files: [stream], journal: { stream: ASK_STREAM, line: entryLine(entry) } }, () => {
@@ -117,7 +122,8 @@ export function withdrawAsk(ctx, root, id, note) {
117
122
  if (ask.state === 'withdrawn')
118
123
  return ok({ already: true });
119
124
  if (ask.state === 'answered') {
120
- return refuse([v('--withdraw', 'ask-answered', `${id} is answered by ${ask.effort}`, `an unanswered ask — ${ask.effort} answers it now · witness abandon ${ask.effort} ends that effort`)]);
125
+ // Row 239. The command it names is an act's line, so the journal's effort prints quoted.
126
+ return refuse([v('--withdraw', 'ask-answered', `${id} is answered by ${ask.effort}`, `an unanswered ask — ${ask.effort} answers it now · ${cliAct('abandon', String(ask.effort)).line} ends that effort`)]);
121
127
  }
122
128
  const entry = { t: 'ask-withdrawn', ask: id, ...(note !== undefined ? { note } : {}) };
123
129
  const stream = journalRel(ASK_STREAM);
@@ -0,0 +1,46 @@
1
+ import { type Act } from './act.js';
2
+ import type { Config } from './config.js';
3
+ import type { Entry } from './journal.js';
4
+ import type { Decision } from './recommend.js';
5
+ import { type DecisionEntry, type GateRunEntry } from './rounds.js';
6
+ export type KeptStop = 'design-look' | 'unmet-need' | 'trust-grant';
7
+ export declare const KEPT_STOP_NAMES: Record<KeptStop, string>;
8
+ export declare function autonomyLines(cfg: Pick<Config, 'autonomy'>): string[];
9
+ export declare function keptStopLine(stop: KeptStop, detail: string): string;
10
+ export declare function unmetNeedLine(needs: ReadonlyArray<{
11
+ text: string;
12
+ satisfyAct: Act;
13
+ }>): string;
14
+ export type Policy = {
15
+ kind: 'take';
16
+ act: Act;
17
+ } | {
18
+ kind: 'pick';
19
+ id: string;
20
+ } | {
21
+ kind: 'arbiter';
22
+ } | {
23
+ kind: 'human';
24
+ stop: KeptStop;
25
+ };
26
+ export type StopFacts = {
27
+ at: 'gate';
28
+ gate: string;
29
+ target: string;
30
+ entries: Entry[];
31
+ run: GateRunEntry;
32
+ block: Decision;
33
+ untrusted: readonly string[];
34
+ } | {
35
+ at: 'choose';
36
+ block: Decision;
37
+ } | {
38
+ at: 'recover';
39
+ block: Decision;
40
+ } | {
41
+ at: 'start';
42
+ target: string;
43
+ unmet: readonly string[];
44
+ };
45
+ export declare function policyFor(facts: StopFacts): Policy;
46
+ export declare function decidedBy(d: Pick<DecisionEntry, 'selected' | 'arbiter'>): string;
package/dist/autonomy.js CHANGED
@@ -1,5 +1,6 @@
1
+ import { cliAct, runRow } from './act.js';
1
2
  import { boundReached, fellBack } from './rounds.js';
2
- import { cmd, kv } from './toon.js';
3
+ import { cmd, kv, logSafe } from './toon.js';
3
4
  export const KEPT_STOP_NAMES = {
4
5
  'design-look': 'design look',
5
6
  'unmet-need': 'unmet need',
@@ -19,9 +20,13 @@ export function keptStopLine(stop, detail) {
19
20
  return cmd('kept-stop', `${KEPT_STOP_NAMES[stop]} — ${detail}`);
20
21
  }
21
22
  // Row 179's kept stop for one plan's start: what is missing, then how to satisfy it. Drive's
22
- // set-aside and the chat's notice (row 195) print this one line.
23
+ // set-aside and the chat's notice (row 195) print it. Row 239 (design §3.4): a need's text is its
24
+ // author's, so it is prose on the kept stop's own line, which a skill never runs, and each satisfy
25
+ // prints on a row of its own under it (`runRow`). Joined to the prose, a text that spells a command
26
+ // would plant it ahead of the real one; ruling R16(a): so would a line break in it, which starts a
27
+ // row of its own, so the text is spelled out (`logSafe`).
23
28
  export function unmetNeedLine(needs) {
24
- return keptStopLine('unmet-need', [...needs.map((u) => u.text), ...needs.map((u) => u.satisfy)].join(' · '));
29
+ return [keptStopLine('unmet-need', logSafe(needs.map((u) => u.text).join(' · '))), ...needs.map((u) => runRow(u.satisfyAct))].join('\n');
25
30
  }
26
31
  // The rules whose recommendation the CLI takes as it stands (design §7 A2's table). Each is
27
32
  // a fix with a right answer — revise here, revise upstream, approve over nits, re-run a
@@ -35,18 +40,25 @@ const TAKEN = new Set(['blocking-here', 'blocking-parent', 'bound-recurrence', '
35
40
  export function policyFor(facts) {
36
41
  if (facts.at === 'start')
37
42
  return { kind: 'human', stop: 'unmet-need' };
38
- if (facts.at !== 'gate')
39
- return { kind: 'take', command: facts.block.options[0].command };
43
+ if (facts.at === 'choose')
44
+ return { kind: 'pick', id: facts.block.options[0].command };
45
+ // `recoverChoice` builds every option from an act; one without an act is no command to take.
46
+ if (facts.at === 'recover') {
47
+ const act = facts.block.options[0]?.act;
48
+ return act !== undefined ? { kind: 'take', act } : { kind: 'arbiter' };
49
+ }
40
50
  const { gate, target, entries, run, block, untrusted } = facts;
41
51
  const failed = run.checks.filter((c) => !c.ok);
42
52
  const blocks = (run.verdicts ?? []).some((rv) => rv.findings.some((f) => f.blocking));
43
53
  const clean = failed.length === 0 && !blocks;
44
- // Option 1 only when it pastes: a placeholder (`<effort>`) means no upstream resolved,
45
- // and filling an id is exactly what the arbiter may never do either — but it can pick
46
- // another option, so the stop goes there rather than to a command that would refuse.
54
+ // Option 1 only when it has no word to fill: a placeholder (`<effort>`) means no upstream
55
+ // resolved, and filling an id is exactly what the arbiter may never do either — but it can
56
+ // pick another option, so the stop goes there rather than to a command that would refuse.
57
+ // Row 239 (the plan's B4): read off the act's inputs, not `runnable`, which is also cleared
58
+ // for a line that is withheld from a paste; the CLI runs the argv with no shell.
47
59
  const first = () => {
48
- const o = block.options[0];
49
- return o !== undefined && o.runnable ? { kind: 'take', command: o.command } : { kind: 'arbiter' };
60
+ const act = block.options[0]?.act;
61
+ return act !== undefined && act.inputs.length === 0 ? { kind: 'take', act } : { kind: 'arbiter' };
50
62
  };
51
63
  if (untrusted.length > 0)
52
64
  return { kind: 'human', stop: 'trust-grant' };
@@ -58,7 +70,7 @@ export function policyFor(facts) {
58
70
  // Row 212. A 0.25.x round that fell back to a model nobody pinned is no verdict to weigh:
59
71
  // re-run it on the pin (free — it never spent the budget), ahead of every arbiter arm.
60
72
  if (fellBack(run))
61
- return { kind: 'take', command: `witness gate ${gate} ${target}` };
73
+ return { kind: 'take', act: cliAct('gate', gate, target) };
62
74
  if (gate === 'design' && clean)
63
75
  return { kind: 'human', stop: 'design-look' };
64
76
  if ((gate === 'ship' || gate === 'decompose') && clean && run.standing !== undefined)
@@ -66,7 +78,7 @@ export function policyFor(facts) {
66
78
  // A trust failure granted since the stop: the check never ran, so the fix is a re-run,
67
79
  // not a revise — sending the author back would have them "fix" a command nobody judged.
68
80
  if (failed.some((c) => (c.untrusted?.length ?? 0) > 0) && !boundReached(entries, gate)) {
69
- return { kind: 'take', command: `witness gate ${gate} ${target}` };
81
+ return { kind: 'take', act: cliAct('gate', gate, target) };
70
82
  }
71
83
  if (block.rule === 'checks-failed') {
72
84
  // amendment-ack is the one check an approve clears, so approving is a judgment about the