@popovych.co/witness 0.30.0 → 0.32.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 (321) hide show
  1. package/README.md +289 -7
  2. package/dist/abandon.js +19 -0
  3. package/dist/act.d.ts +1 -1
  4. package/dist/allowlist.d.ts +15 -0
  5. package/dist/allowlist.js +223 -28
  6. package/dist/always.d.ts +22 -0
  7. package/dist/always.js +108 -0
  8. package/dist/arbiter.d.ts +12 -5
  9. package/dist/arbiter.js +170 -13
  10. package/dist/ask.d.ts +6 -1
  11. package/dist/ask.js +35 -16
  12. package/dist/autonomy.d.ts +5 -2
  13. package/dist/autonomy.js +23 -2
  14. package/dist/base-lint.d.ts +31 -0
  15. package/dist/base-lint.js +213 -0
  16. package/dist/base-tests.d.ts +19 -0
  17. package/dist/base-tests.js +142 -0
  18. package/dist/behavior-map.d.ts +44 -0
  19. package/dist/behavior-map.js +408 -0
  20. package/dist/births.d.ts +35 -0
  21. package/dist/births.js +273 -0
  22. package/dist/breadth.d.ts +10 -0
  23. package/dist/breadth.js +423 -0
  24. package/dist/busy.js +4 -3
  25. package/dist/caps.js +3 -1
  26. package/dist/carry.d.ts +1 -1
  27. package/dist/carry.js +8 -11
  28. package/dist/cf-tree.d.ts +28 -0
  29. package/dist/cf-tree.js +157 -0
  30. package/dist/change-set.d.ts +9 -0
  31. package/dist/change-set.js +135 -0
  32. package/dist/checks.d.ts +20 -0
  33. package/dist/checks.js +114 -0
  34. package/dist/clash.d.ts +1 -0
  35. package/dist/clash.js +3 -2
  36. package/dist/cli.js +17 -5
  37. package/dist/config.d.ts +27 -3
  38. package/dist/config.js +115 -3
  39. package/dist/content-sha.js +9 -1
  40. package/dist/criteria.d.ts +12 -1
  41. package/dist/criteria.js +72 -2
  42. package/dist/deadline.d.ts +13 -0
  43. package/dist/deadline.js +205 -0
  44. package/dist/decide-view.d.ts +10 -0
  45. package/dist/decide-view.js +30 -3
  46. package/dist/definitions.d.ts +21 -0
  47. package/dist/definitions.js +388 -0
  48. package/dist/delta.js +5 -5
  49. package/dist/design.d.ts +3 -2
  50. package/dist/design.js +25 -10
  51. package/dist/diagnostics.d.ts +27 -0
  52. package/dist/diagnostics.js +212 -0
  53. package/dist/drafts.js +5 -1
  54. package/dist/drift.js +17 -5
  55. package/dist/drive-jobs.d.ts +43 -0
  56. package/dist/drive-jobs.js +210 -0
  57. package/dist/drive-presence.d.ts +3 -1
  58. package/dist/drive-presence.js +9 -3
  59. package/dist/drive-report.d.ts +1 -0
  60. package/dist/drive-report.js +43 -3
  61. package/dist/drive.d.ts +12 -4
  62. package/dist/drive.js +365 -103
  63. package/dist/dsl.d.ts +7 -0
  64. package/dist/dsl.js +22 -2
  65. package/dist/evidence.d.ts +4 -3
  66. package/dist/evidence.js +134 -312
  67. package/dist/explore-bridge.d.ts +33 -0
  68. package/dist/explore-bridge.js +332 -0
  69. package/dist/explore-claims.d.ts +43 -0
  70. package/dist/explore-claims.js +175 -0
  71. package/dist/explore-config.d.ts +21 -0
  72. package/dist/explore-config.js +67 -0
  73. package/dist/explore-env.d.ts +3 -0
  74. package/dist/explore-env.js +5 -0
  75. package/dist/explore-host.d.ts +53 -0
  76. package/dist/explore-host.js +212 -0
  77. package/dist/explore-job.d.ts +7 -0
  78. package/dist/explore-job.js +120 -0
  79. package/dist/explore-maps.d.ts +17 -0
  80. package/dist/explore-maps.js +107 -0
  81. package/dist/explore-marker.d.ts +8 -0
  82. package/dist/explore-marker.js +38 -0
  83. package/dist/explore-pi.d.ts +19 -0
  84. package/dist/explore-pi.js +99 -0
  85. package/dist/explore-relay.d.ts +1 -0
  86. package/dist/explore-relay.js +28 -0
  87. package/dist/explore-run.d.ts +49 -0
  88. package/dist/explore-run.js +251 -0
  89. package/dist/explore-verbs.d.ts +39 -0
  90. package/dist/explore-verbs.js +200 -0
  91. package/dist/explore-when.d.ts +25 -0
  92. package/dist/explore-when.js +141 -0
  93. package/dist/explorer-prompt.d.ts +9 -0
  94. package/dist/explorer-prompt.js +20 -0
  95. package/dist/explorer-session.d.ts +31 -0
  96. package/dist/explorer-session.js +229 -0
  97. package/dist/features-off.d.ts +7 -0
  98. package/dist/features-off.js +36 -0
  99. package/dist/findings.d.ts +22 -0
  100. package/dist/findings.js +120 -0
  101. package/dist/fm.js +2 -2
  102. package/dist/gate-run-view.d.ts +7 -2
  103. package/dist/gate-run-view.js +23 -9
  104. package/dist/gate.d.ts +10 -1
  105. package/dist/gate.js +159 -23
  106. package/dist/gates/decompose.js +38 -26
  107. package/dist/gates/design.js +16 -8
  108. package/dist/gates/implement.js +115 -41
  109. package/dist/gates/index.d.ts +1 -0
  110. package/dist/gates/index.js +1 -0
  111. package/dist/gates/map.d.ts +1 -0
  112. package/dist/gates/map.js +93 -0
  113. package/dist/gates/plan.js +20 -16
  114. package/dist/gates/ship.js +180 -42
  115. package/dist/gh-repo.d.ts +13 -0
  116. package/dist/gh-repo.js +100 -0
  117. package/dist/gitio.d.ts +2 -0
  118. package/dist/gitio.js +17 -3
  119. package/dist/glob.js +6 -0
  120. package/dist/guard.d.ts +108 -0
  121. package/dist/guard.js +567 -0
  122. package/dist/harness.d.ts +24 -0
  123. package/dist/harness.js +96 -3
  124. package/dist/held.d.ts +41 -0
  125. package/dist/held.js +411 -0
  126. package/dist/history.d.ts +5 -0
  127. package/dist/history.js +22 -0
  128. package/dist/install.d.ts +9 -2
  129. package/dist/install.js +152 -11
  130. package/dist/jobs.d.ts +103 -0
  131. package/dist/jobs.js +370 -0
  132. package/dist/journal.d.ts +13 -1
  133. package/dist/journal.js +11 -0
  134. package/dist/json-format.d.ts +7 -0
  135. package/dist/json-format.js +49 -0
  136. package/dist/junit.d.ts +18 -0
  137. package/dist/junit.js +48 -2
  138. package/dist/ledger.d.ts +332 -0
  139. package/dist/ledger.js +815 -0
  140. package/dist/lint-config.d.ts +17 -0
  141. package/dist/lint-config.js +241 -0
  142. package/dist/lint-effect.d.ts +71 -0
  143. package/dist/lint-effect.js +406 -0
  144. package/dist/lint-lane.d.ts +13 -0
  145. package/dist/lint-lane.js +229 -0
  146. package/dist/lint-parts.d.ts +12 -0
  147. package/dist/lint-parts.js +58 -0
  148. package/dist/lint-readers.d.ts +13 -0
  149. package/dist/lint-readers.js +172 -0
  150. package/dist/live-page.d.ts +3 -0
  151. package/dist/live-page.js +31 -0
  152. package/dist/live.js +3 -1
  153. package/dist/map-act.d.ts +15 -0
  154. package/dist/map-act.js +165 -0
  155. package/dist/map-page.d.ts +36 -0
  156. package/dist/map-page.js +233 -0
  157. package/dist/markers.d.ts +2 -0
  158. package/dist/markers.js +73 -0
  159. package/dist/matcher.d.ts +6 -0
  160. package/dist/matcher.js +25 -2
  161. package/dist/mcp-client.d.ts +14 -0
  162. package/dist/mcp-client.js +269 -0
  163. package/dist/merge-clock.d.ts +9 -0
  164. package/dist/merge-clock.js +43 -0
  165. package/dist/migration.d.ts +1 -0
  166. package/dist/migration.js +9 -3
  167. package/dist/models.d.ts +2 -0
  168. package/dist/models.js +4 -0
  169. package/dist/mutation-reports.d.ts +28 -0
  170. package/dist/mutation-reports.js +171 -0
  171. package/dist/mutation-scope.d.ts +20 -0
  172. package/dist/mutation-scope.js +171 -0
  173. package/dist/mutation.d.ts +65 -0
  174. package/dist/mutation.js +506 -0
  175. package/dist/needs-you.d.ts +11 -0
  176. package/dist/needs-you.js +47 -12
  177. package/dist/owed.d.ts +26 -0
  178. package/dist/owed.js +66 -0
  179. package/dist/parent-approvals.d.ts +3 -0
  180. package/dist/parent-approvals.js +26 -0
  181. package/dist/prepare.d.ts +13 -0
  182. package/dist/prepare.js +107 -0
  183. package/dist/progress.js +15 -1
  184. package/dist/proof-markdown.d.ts +16 -0
  185. package/dist/proof-markdown.js +241 -0
  186. package/dist/proof-text.d.ts +18 -0
  187. package/dist/proof-text.js +172 -0
  188. package/dist/proof.d.ts +175 -0
  189. package/dist/proof.js +435 -0
  190. package/dist/recommend.d.ts +5 -1
  191. package/dist/recommend.js +164 -7
  192. package/dist/record.d.ts +117 -0
  193. package/dist/record.js +354 -0
  194. package/dist/referral.d.ts +17 -0
  195. package/dist/referral.js +58 -0
  196. package/dist/released-comments.js +19 -0
  197. package/dist/repair-check-run.d.ts +20 -0
  198. package/dist/repair-check-run.js +119 -0
  199. package/dist/repair-check.d.ts +12 -0
  200. package/dist/repair-check.js +87 -0
  201. package/dist/replay-job.d.ts +24 -0
  202. package/dist/replay-job.js +90 -0
  203. package/dist/replay-points.d.ts +34 -0
  204. package/dist/replay-points.js +127 -0
  205. package/dist/replay-read.d.ts +41 -0
  206. package/dist/replay-read.js +87 -0
  207. package/dist/replay-run.d.ts +50 -0
  208. package/dist/replay-run.js +216 -0
  209. package/dist/replay-search.d.ts +11 -0
  210. package/dist/replay-search.js +58 -0
  211. package/dist/resource-lock.d.ts +23 -0
  212. package/dist/resource-lock.js +520 -0
  213. package/dist/retired-payload.d.ts +1 -0
  214. package/dist/retired-payload.js +98 -0
  215. package/dist/reviewed.js +6 -5
  216. package/dist/reviewer.d.ts +1 -1
  217. package/dist/reviewer.js +7 -5
  218. package/dist/rounds.d.ts +169 -4
  219. package/dist/rounds.js +142 -14
  220. package/dist/runner-lock.d.ts +26 -1
  221. package/dist/runner-lock.js +377 -29
  222. package/dist/runner.d.ts +26 -2
  223. package/dist/runner.js +84 -36
  224. package/dist/schemas.js +25 -0
  225. package/dist/scratch-checkout.d.ts +40 -0
  226. package/dist/scratch-checkout.js +262 -0
  227. package/dist/scratch-lock.d.ts +22 -0
  228. package/dist/scratch-lock.js +348 -0
  229. package/dist/scratch.d.ts +4 -0
  230. package/dist/scratch.js +34 -0
  231. package/dist/screens.d.ts +26 -0
  232. package/dist/screens.js +156 -0
  233. package/dist/self.d.ts +9 -0
  234. package/dist/self.js +88 -0
  235. package/dist/session-clock.d.ts +2 -0
  236. package/dist/session-clock.js +28 -8
  237. package/dist/settings.d.ts +34 -1
  238. package/dist/settings.js +151 -9
  239. package/dist/settle.d.ts +4 -0
  240. package/dist/settle.js +83 -4
  241. package/dist/sha.d.ts +1 -1
  242. package/dist/sha.js +1 -1
  243. package/dist/ship.d.ts +7 -3
  244. package/dist/ship.js +179 -36
  245. package/dist/slice.js +2 -0
  246. package/dist/snapshot.d.ts +1 -0
  247. package/dist/snapshot.js +39 -16
  248. package/dist/stamp.js +22 -2
  249. package/dist/steps.d.ts +5 -0
  250. package/dist/steps.js +15 -0
  251. package/dist/streams.d.ts +3 -0
  252. package/dist/streams.js +6 -0
  253. package/dist/switch-offs.d.ts +42 -0
  254. package/dist/switch-offs.js +511 -0
  255. package/dist/tests-effect.d.ts +48 -0
  256. package/dist/tests-effect.js +132 -0
  257. package/dist/tolerated-lists.d.ts +33 -0
  258. package/dist/tolerated-lists.js +247 -0
  259. package/dist/tolerated.d.ts +35 -0
  260. package/dist/tolerated.js +335 -0
  261. package/dist/verbs/abandon.js +31 -1
  262. package/dist/verbs/adopt.js +8 -1
  263. package/dist/verbs/check.js +108 -7
  264. package/dist/verbs/dashboard.d.ts +2 -1
  265. package/dist/verbs/dashboard.js +97 -5
  266. package/dist/verbs/decide.d.ts +3 -1
  267. package/dist/verbs/decide.js +306 -33
  268. package/dist/verbs/design.js +53 -5
  269. package/dist/verbs/diff.js +31 -7
  270. package/dist/verbs/dismiss.js +122 -4
  271. package/dist/verbs/draft.js +6 -2
  272. package/dist/verbs/drive.js +1 -1
  273. package/dist/verbs/evidence.js +11 -1
  274. package/dist/verbs/finding.d.ts +7 -0
  275. package/dist/verbs/finding.js +248 -0
  276. package/dist/verbs/gate.js +1 -1
  277. package/dist/verbs/guard.d.ts +2 -0
  278. package/dist/verbs/guard.js +244 -0
  279. package/dist/verbs/init.js +42 -4
  280. package/dist/verbs/job.d.ts +2 -0
  281. package/dist/verbs/job.js +123 -0
  282. package/dist/verbs/log.js +73 -3
  283. package/dist/verbs/map.d.ts +2 -0
  284. package/dist/verbs/map.js +159 -0
  285. package/dist/verbs/migrate.d.ts +3 -0
  286. package/dist/verbs/migrate.js +94 -18
  287. package/dist/verbs/next.d.ts +4 -2
  288. package/dist/verbs/next.js +256 -84
  289. package/dist/verbs/recap.d.ts +2 -0
  290. package/dist/verbs/recap.js +473 -7
  291. package/dist/verbs/recover.js +68 -3
  292. package/dist/verbs/rename.js +8 -2
  293. package/dist/verbs/review.js +1 -1
  294. package/dist/verbs/start.js +11 -0
  295. package/dist/verbs/trust.d.ts +22 -1
  296. package/dist/verbs/trust.js +149 -8
  297. package/dist/verbs/turn.js +5 -0
  298. package/dist/verbs/write.d.ts +1 -0
  299. package/dist/verbs/write.js +49 -10
  300. package/dist/verdict.d.ts +8 -0
  301. package/dist/verdict.js +17 -0
  302. package/dist/worktree.d.ts +4 -1
  303. package/dist/worktree.js +76 -22
  304. package/package.json +1 -1
  305. package/plugin/.claude-plugin/plugin.json +1 -1
  306. package/plugin/commands/witness.md +6 -5
  307. package/plugin/hooks/session-dashboard.sh +1 -1
  308. package/plugin/skills/witness-brainstorm/SKILL.md +7 -3
  309. package/plugin/skills/witness-decompose/SKILL.md +26 -6
  310. package/plugin/skills/witness-design/SKILL.md +4 -2
  311. package/plugin/skills/witness-implement/SKILL.md +10 -8
  312. package/plugin/skills/witness-plan/SKILL.md +7 -1
  313. package/plugin/skills/witness-ship/SKILL.md +5 -5
  314. package/prompts/arbiter.md +4 -0
  315. package/prompts/code-reviewer.md +2 -0
  316. package/prompts/explorer.md +23 -0
  317. package/prompts/map-reviewer.md +38 -0
  318. package/prompts/pr-test.md +5 -1
  319. package/prompts/silent-failure-hunter.md +2 -0
  320. package/prompts/slicing-critic.md +1 -1
  321. package/prompts/type-design.md +2 -0
package/README.md CHANGED
@@ -149,6 +149,16 @@ with `cli-behind-state` rather than answering from rules the repository has move
149
149
  release, say — lower it first with `witness floor --set <version> --note <why>`; the
150
150
  decision is journaled, and `floor` is the one verb that still runs under a bound it fails.
151
151
 
152
+ From **0.30.1** witness's Claude Code hooks live in `.witness/hooks/`, which a repo's lint
153
+ usually skips. `init --agent claude-code` moves them from `.claude/hooks/` at the root,
154
+ rewires `.claude/settings.json` and writes it in your formatter's default style; your own
155
+ hooks in `.claude/hooks/` stay where they are. The settings file is rewritten and committed
156
+ once, so commit your own edits to it first. Restart any open Claude Code session in the
157
+ repo (a session keeps the hooks it started with) and push the init commit (new worktrees
158
+ and `witness ship` read the remote). A worktree started earlier keeps its old hooks until
159
+ `witness ship` carries it onto the moved base. `witness check` warns `payload-linted` when
160
+ your Biome config would still check witness's files.
161
+
152
162
  ### Support tiers
153
163
 
154
164
  | Tier | Agents | What they get |
@@ -179,11 +189,28 @@ the list the CLI reads (`src/settings.ts`).
179
189
  | `criteria.runner` | how a spec's criteria run · a command with {id}, or full-suite — accepts: a filtered template containing {id}, or full-suite | `'npm test -- -t "@spec:{id}"'` |
180
190
  | `criteria.report` | the junit report witness reads · junit:<glob>, or none · full-suite needs one — accepts: none, or junit:<glob> (only junit is supported) | `none` |
181
191
  | `criteria.exclude` | extra globs never scanned for criteria tags · [] = none — accepts: a list of globs ([] = none) | `[]` |
192
+ | `criteria.byFile` | a command running the given test files, {files} = their paths — witness guard runs a test guard's files with it · none = the full suite — accepts: a command containing {files}, or none — e.g. pnpm vitest run --reporter=junit --outputFile=reports/junit.xml {files} | `none` |
182
193
  | `ship.test` | the suite command ship runs · full-suite criteria run it too — accepts: a shell command | `npm test` |
183
- | `ship.lint` | the lint command ship runs — accepts: a shell command | `npm run lint` |
194
+ | `ship.lint` | the lint the implement and ship gates run · one command, or name: command parts, each run on its own · a part named biome, eslint, clippy or tsc is read per diagnostic — accepts: a shell command, or a map of part names to shell commands — e.g. {biome: pnpm exec biome check ., tsc: pnpm exec tsc --noEmit} · a name is a lowercase letter, then up to 39 lowercase letters, digits or - | `npm run lint` |
184
195
  | `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
196
  | `ship.merge` | how ship merges its own PR under autonomy · merge \| squash \| rebase — accepts: merge \| squash \| rebase | `merge` |
186
197
  | `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` |
198
+ | `readers.biome` | reads the ship.lint part named biome per diagnostic · a command printing biome's SARIF report (--reporter=sarif) with every error, or none — accepts: a shell command, or none — run from the repo root, it prints only biome's SARIF report (--reporter=sarif) for what the part named biome checks, every error, never stopping at the first failure (cargo --keep-going, pnpm -r --no-bail, ; rather than && between runs) | `none` |
199
+ | `readers.eslint` | reads the ship.lint part named eslint per diagnostic · a command printing ESLint's JSON report (-f json) with every error, or none — accepts: a shell command, or none — run from the repo root, it prints only ESLint's JSON report (-f json) for what the part named eslint checks, every error, never stopping at the first failure (cargo --keep-going, pnpm -r --no-bail, ; rather than && between runs) | `none` |
200
+ | `readers.clippy` | reads the ship.lint part named clippy per diagnostic · a command printing cargo's JSON messages (--message-format=json) with every error, or none — accepts: a shell command, or none — run from the repo root, it prints only cargo's JSON messages (--message-format=json) for what the part named clippy checks, every error, never stopping at the first failure (cargo --keep-going, pnpm -r --no-bail, ; rather than && between runs) | `none` |
201
+ | `readers.tsc` | reads the ship.lint part named tsc per diagnostic · a command printing tsc's diagnostic lines (--pretty false) with every error, or none — accepts: a shell command, or none — run from the repo root, it prints only tsc's diagnostic lines (--pretty false) for what the part named tsc checks, every error, never stopping at the first failure (cargo --keep-going, pnpm -r --no-bail, ; rather than && between runs) | `none` |
202
+ | `checks.switchOffs` | extra switch-off tokens the implement and ship gates flag in the lines a plan adds, beside witness's own lists · [] = none — accepts: a list of literal tokens, each 1–100 printable ASCII characters with no space at either end — e.g. ['istanbul ignore', 'c8 ignore'] ([] = none) | `[]` |
203
+ | `checks.definitions` | files whose base copy the implement and ship gates restore to see what a plan's check-definition changes hide · [] = off — accepts: a list of repo paths or globs (no / = any folder), each optionally #member for one top-level key of a JSON file — e.g. ['.gitignore', 'biome.json', 'package.json#scripts'] ([] = off) | `[.gitignore, .eslintignore, .prettierignore, .editorconfig, biome.json, biome.jsonc, eslint.config.*, .eslintrc*, prettier.config.*, .prettierrc*, tsconfig*.json, jsconfig*.json, package.json#scripts, vitest.config.*, vitest.workspace.*, jest.config.*, playwright.config.*, stryker.config.*, stryker.conf.*, .stryker.conf.*, .stryker.config.*, clippy.toml, .clippy.toml, .cargo/mutants.toml, rustfmt.toml, .rustfmt.toml, ruff.toml, .ruff.toml, .golangci.*]` |
204
+ | `mutation.stryker` | measures how well the tests catch changes to a plan's lines at ship · a Stryker run command witness appends its config file to, or none — accepts: a shell command, or none — e.g. pnpm exec stryker run (witness appends the path of the Stryker config it writes for the run) | `none` |
205
+ | `mutation.cargo-mutants` | measures how well the tests catch changes to a plan's lines at ship · a cargo-mutants command witness appends --in-diff and --output to, or none — accepts: a shell command, or none — e.g. cargo mutants (witness appends --in-diff <its diff> --output <its folder>) | `none` |
206
+ | `proof.screens` | whether ship shows a plan's screenshots in its PR description, pushed to a hidden ref of this repository · none \| private (only while GitHub reads it private) \| public (whatever its visibility) — accepts: none \| private \| public — private pushes screenshots only while GitHub reads the repository private or internal; public is the opt-in for a public repository | `none` |
207
+ | `scratch.prepare` | what makes witness's scratch checkout runnable, run when a lockfile changes · a shell command, or none — accepts: a shell command, or none — what witness runs in its scratch checkout when a lockfile or a package manager's config changes | `none` |
208
+ | `explore.when` | when drive explores the built app: after each merge, at the tip when drive is idle, at each release tag, or off · one value, or one per class (feature, fix, chore) — accepts: off \| merge \| idle \| release, or a map naming feature, fix and chore, each one of them — e.g. {feature: merge, fix: idle, chore: off} | `off` |
209
+ | `explore.host` | the script that resets, provisions and drives the app with its stand-ins — witness runs it with reset, provision or drive appended · {run, files}, files the scripts a trust grant pins, or none — accepts: none, or {run: <command>, files: [<repo path or glob>, …]} — 1 to 50 repo-relative files outside .witness/ — e.g. {run: node scripts/explore/host.mjs, files: [scripts/explore/**]} | `none` |
210
+ | `explore.login` | logs the app in with stand-in identities only, its secrets read from the repo's own gitignored env · {run, files}, or none — accepts: none, or {run: <command>, files: [<repo path or glob>, …]} — 1 to 50 repo-relative files outside .witness/ — e.g. {run: node scripts/explore/login.mjs, files: [scripts/explore/**]} | `none` |
211
+ | `explore.resources` | what the explored app holds that a test run also uses (a port, a database) — every test run waits while explore holds one · a list of names, [] = nothing shared, or none — accepts: none, or a list of up to 16 distinct names — a lowercase letter, then up to 39 lowercase letters, digits or -, never starting wait- (explore is witness's own) — e.g. [port-3000, dynamodb] | `none` |
212
+ | `explore.budgetMs` | awake ms one explore run may take, from its first reset to its last (1 h) · 60000–86400000 — accepts: an integer from 60000 to 86400000 — awake milliseconds one explore run may take | `3600000` |
213
+ | `explore.model` | model for the explorer that walks the built app after merges · exact id, no aliases — accepts: [provider/]model[:thinking] | `claude-opus-5-5` |
187
214
  | `autonomy` | on = the CLI settles its own stops and merges green PRs · on \| off · counts once committed — accepts: on \| off | `off` |
188
215
  | `arbiter.model` | model for the arbiter that settles stops under autonomy · exact id, no aliases — accepts: [provider/]model[:thinking] | `claude-opus-5-5` |
189
216
  | `session.contextLimit` | % of the context window at which a session hands over to a fresh one · 1–100 — accepts: an integer from 1 to 100 — % of the session's context window at which witness hands over to a fresh session | `20` |
@@ -191,6 +218,8 @@ the list the CLI reads (`src/settings.ts`).
191
218
  | `gates.reviewerTimeoutMs` | ms one reviewer, or the arbiter, may run before it is stopped (10 min) · ≥ 1 — accepts: an integer >= 1 — milliseconds each reviewer invocation may take | `600000` |
192
219
  | `gates.decompose.model` | model for this gate's reviewers · exact id, [provider/]id[:thinking], no aliases — accepts: [provider/]model[:thinking] | `claude-opus-5-5` |
193
220
  | `gates.decompose.reviewers` | reviewers this gate runs · one list, or one list per class (feature, fix, chore) — accepts: a reviewer list or a per-class map of lists in witness.config.yaml — e.g. reviewers: [code-reviewer] — a per-class map names feature, fix and chore | `[slicing-critic]` |
221
+ | `gates.map.model` | model for this gate's reviewer · it reads the behavior maps of specs a user reaches, once their slicing is approved — accepts: [provider/]model[:thinking] | `claude-opus-5-5` |
222
+ | `gates.map.reviewers` | reviewers this gate runs · one list, or one list per class — accepts: a reviewer list or a per-class map of lists in witness.config.yaml — e.g. reviewers: [code-reviewer] — a per-class map names feature, fix and chore | `[map-reviewer]` |
194
223
  | `gates.plan.model` | model for this gate's reviewers · exact id, no aliases — accepts: [provider/]model[:thinking] | `claude-opus-5-5` |
195
224
  | `gates.plan.reviewers` | reviewers this gate runs · one list, or one list per class — accepts: a reviewer list or a per-class map of lists in witness.config.yaml — e.g. reviewers: [code-reviewer] — a per-class map names feature, fix and chore | `[plan-critic]` |
196
225
  | `gates.design.model` | model for this gate's reviewers · runs only on specs marked ui — accepts: [provider/]model[:thinking] | `claude-opus-5-5` |
@@ -239,9 +268,9 @@ plain-words question per turn with up to three ranked answers, the repo explored
239
268
  draft after every settled answer, so a dead session resumes. Design shows up to three rendered,
240
269
  checked directions on one page before it asks which.
241
270
 
242
- **`drive`.** `drive.parallelSuites: false` makes test runs in two worktrees take turns — witness's
243
- own and every `witness turn`, which is how a session runs its tests — because suites that boot
244
- servers or browsers collide. On Windows each session, test run and gate reviewer runs in a job
271
+ **`drive`.** `drive.parallelSuites: false` makes test runs in two worktrees take turns, in the
272
+ order they asked — witness's own and every `witness turn`, which is how a session runs its tests —
273
+ because suites that boot servers or browsers collide; lint takes no turn. On Windows each session, test run and gate reviewer runs in a job
245
274
  object, so whatever it starts — detached, or orphaned by an installer that exited — ends with it;
246
275
  elsewhere a session's process group does. A target that reaches any `drive.caps.*` bound is
247
276
  parked. Below the round bound a parked gate goes back to work with your own
@@ -250,9 +279,86 @@ gate, and `next` routes the owed work, steps first; `witness status` and `decide
250
279
  `revise:` row, beside a `fresh:` row (a re-review of the work as it stands) when no work is owed. It
251
280
  also restarts drive's caps for that target.
252
281
 
282
+ **The scratch (`scratch.prepare`).** Machine work on a tree other than a plan's — the first is the
283
+ base tree's lint, below — runs in one scratch checkout per repo,
284
+ `.witness/scratch`: a detached worktree witness resets before every run, which `git status` never
285
+ shows. `scratch.prepare` is the command that makes it runnable, run again only when a lockfile or a
286
+ package manager's config changes; `init` and `migrate` write the one your root lockfile names
287
+ (`pnpm install --frozen-lockfile --config.confirm-modules-purge=false` for pnpm), and `none`
288
+ installs nothing. A repo command — the runner, `ship.test`, each `ship.lint` part, a reader,
289
+ `scratch.prepare`, a mutation tool's command — is granted once with `witness trust --cmd '<cmd>'`, or when `witness migrate`
290
+ proposes it at a terminal; until then a job that runs it waits for you (`wait: trust grant · jobs`)
291
+ and never fails for it.
292
+
293
+ **Lint parts and readers (`ship.lint`, `readers.*`).** `ship.lint` may name its parts —
294
+ `{biome: pnpm exec biome check ., eslint: pnpm exec eslint ., ui: pnpm check:ui, types: pnpm typecheck}`
295
+ — and ship runs every part on its own, whatever an earlier one did, so a red first part never hides
296
+ the others. A part named after a tool witness reads (`biome`, `eslint`, `clippy`, `tsc`) has a reader,
297
+ `readers.<tool>`: a command printing that tool's report with every error (`init` and `migrate` write
298
+ Biome's and ESLint's when your root has their configs, and say so when no part bears the tool's name
299
+ yet — a one-command `ship.lint` is one part named `lint`, which no reader binds). When such a part is
300
+ red on the plan's base too, it is judged per diagnostic: only the errors the plan added are red, and
301
+ drive lints the base in the scratch when a gate asks (`pending` until then). Without drive the base
302
+ reads "not measured" and the red part withholds; starting drive once lints the base for it. A part with
303
+ no reader that is red on the base reads "not judged", never green.
304
+
305
+ **Checks before reviewers.** The implement and ship gates run the conflict-marker check (an opener
306
+ like `<<<<<<< HEAD` on a line the plan adds) and every `ship.lint` part before any reviewer. A red
307
+ one ends the round as "checks only": no reviewer runs, no round of your budget is spent, and nothing
308
+ is offered to approve — fix what the check names and re-run the gate. Under drive with autonomy on, a
309
+ round whose red lint parts all wait on the base's lint result waits for drive's base lint
310
+ (`awaits-drive:`), then runs again.
311
+
312
+ When a lint part is red on the base too, or red in a way only you can accept,
313
+ `witness decide <gate> <plan> --book lint` books it — exactly the errors witness can read, or the
314
+ whole part until main moves — and the gate runs again. Under autonomy it is yours alone, typed at your
315
+ own terminal, and drive leaves a stop for you when no author could clear it (every red part red on
316
+ the base too and not judgeable); otherwise the author is sent to fix it first. `witness status` lists every open booking; each
317
+ closes once main no longer holds it, and `witness dismiss ledger` ends one at your terminal.
318
+
319
+ **Switch-offs.** A line a plan adds that turns a check off — an `eslint-disable` or `@ts-ignore`
320
+ comment, a `biome-ignore`, an `it.skip(` or `.only(` in a test file, a `{ retry: 3 }`, a Rust
321
+ `#[allow(`, a `# noqa` — makes the implement and ship gates' `switch-offs` check red. Each token counts
322
+ where its tool reads it (`process.exit(` is never `xit(`, and `retry: false` is no switch-off), and only
323
+ the copies beyond the base's are the plan's, so a moved line is not new. The reviewers still run and are
324
+ told every such line. The way on is the revise that removes it, or
325
+ `witness decide <gate> <plan> --book switch-offs` when it is right as it stands: one ledger item per
326
+ line, which waives that line for this plan. You or, under autonomy, the AI judge may book it — the
327
+ judge reading only facts (the token, how many rules it names, whether a test file holds it) — never the policy, and
328
+ never beside a blocking finding or another red check, or at the round bound; approving over the red
329
+ books nothing, so the next gate meets it again. A booked line closes once a merged tree no longer
330
+ holds it. `checks.switchOffs` adds your repo's own literal tokens (e.g. `['istanbul ignore']`).
331
+
332
+ **Lost tests.** In full-suite mode the same check compares each spec's tagged tests with the base's: a
333
+ new skip, in any spelling, always counts, and so do passing cases that disappear beyond new failures
334
+ (removed, untagged, excluded). A plan whose own spec was amended since its last plan may remove that
335
+ spec's cases — the reviewers are told, but it is not red — never skip them. The base comes from a shipped
336
+ summary of the same code, else drive runs the base's suite in the scratch; until it has one the check reads
337
+ `tests not checked` and stays green. A lost spec is booked like a line (`tests of <spec>`) and closes once
338
+ main's shipped summary has its cases back.
339
+
340
+ **Test strength (`mutation.stryker`, `mutation.cargo-mutants`).** At ship, each mutation tool you set
341
+ measures how well the tests catch changes to the lines the plan added: drive runs it in the scratch on
342
+ the round's tree under the base's tool and test-runner configuration, handing it only those lines (a
343
+ Stryker config file, or a diff for cargo-mutants, that witness writes in `.witness-mutation/`). While
344
+ drive measures, the ship round waits (`awaits-drive:`) and spends no suite and no reviewer; the next
345
+ round reads the result. What survived goes to the code reviewer, the AI judge hears the counts, and
346
+ survivors never make the check red. With no drive, scratch runs off, or a run that failed twice, it reads
347
+ "not measured" and ship goes on. Code no test the tool runs reaches — end-to-end-only code — reads "not
348
+ reached", never a survivor. To turn Stryker on: have it in the repo's dev dependencies with a root config
349
+ that lists its test runner in `plugins` (pnpm's isolation hides the runner otherwise) and a test-runner
350
+ config of your fast tests (an end-to-end project can outlast Stryker's five-minute dry run), the services
351
+ the suite needs running; then set `mutation.stryker` in `witness.config.yaml` (e.g. `pnpm exec stryker
352
+ run`) and grant it with `witness trust --cmd '<cmd>'`. For cargo-mutants: install it on the machine and set
353
+ `mutation.cargo-mutants` to a command run from the repo root (`cargo mutants`), granted the same way.
354
+ `init`, and a `migrate` from a schema before 4, propose and grant the command themselves when your root
355
+ shows the tool (a Stryker config beside a lockfile; `.cargo/mutants.toml` beside `Cargo.toml`); a file
356
+ already on schema 4 holds `none` until you set it. `witness check` names test strength off while both are
357
+ `none`.
358
+
253
359
  A ship that ends on a hold only you can clear is a stop of yours, remembered in the journal, so it
254
360
  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
361
+ pinned to the approved commit, with witness's own commit message (`gh pr merge N --<ship.merge> --match-head-commit <sha> --body '…'`), or
256
362
  `waiting: fix` (the PR aims at another branch, was closed, holds commits the worktree lacks, or a
257
363
  login was refused) with no merge command at all. Each has a `recheck:` row, `witness ship <plan>`,
258
364
  for when you have acted. A hold that clears by itself — CI still running, GitHub not answering — is
@@ -294,7 +400,8 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
294
400
  | verb | does |
295
401
  | --- | --- |
296
402
  | `init [--agent claude-code\|pi\|auto]` | scaffold config, principles, journal — one trailer commit; `--agent` also installs that harness's engine, guard and dashboard (idempotent) |
297
- | `recap [--amend] --file <json>` | validate + persist a scope recap — class, goals, non-goals, constraints and numbered decisions; births the effort journal |
403
+ | `recap [--amend] --file <json>` | validate + persist a scope recap — class, goals, non-goals, constraints and numbered decisions; births the effort journal; a fix adds `"cause": "escape"` or `"cause": "decision"` |
404
+ | `recap --effort <slug> --cause escape\|decision` | the human names the cause of a fix that predates causes, in their own chat or terminal (refused in a witness-spawned session); `status` lists those fixes under `cause-owed` |
298
405
  | `draft <key> [--file <json>]` | a grill's or design session's local draft — saved after every settled answer, read back to resume; never committed or journaled |
299
406
  | `write <id> --effort <e> --meta <json> --body <md>` | validated manifest → spec/plan on disk + journal entry; a spec's `covers` and `carries` map it to the recap's goals and decisions |
300
407
  | `diff <spec-id>` | delta since the last realized state (plan pin → empty), and the decisions that moved since that plan |
@@ -315,6 +422,7 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
315
422
  | `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 |
316
423
  | `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 |
317
424
  | `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:` |
425
+ | `guard <plan-id> --finding <anchor> --files <path>… (--rule <tool>:<rule> \| --test <name>…)` | prove the check a fix adds for a guard-marked finding: it fails on the tree the marking round reviewed (with the guard's files folded over it) and passes on the worktree now, both in the scratch through the base's scripts; a lint rule must also catch a renamed, re-indented copy of the flagged file; journals `guard` only on a proof |
318
426
  | `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 |
319
427
  | `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 |
320
428
  | `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 |
@@ -324,9 +432,183 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
324
432
  | `clean` | reap stale worktrees |
325
433
  | `sync` | pull --rebase + push state commits |
326
434
  | `recover [--complete\|--rollback]` | resolve a crashed write transaction |
327
- | `status` | orientation: flows, blocked docs, reconcile rows, pending gates |
435
+ | `status [--record \| --proof <plan-id>]` | orientation: flows, blocked docs, reconcile rows, pending gates and the track record's line; `--record` prints the track record in full; `--proof` prints one plan's PR proof in full |
328
436
  | *(no verb)* | the same screen as `status` |
329
437
 
438
+ ### The PR proof
439
+
440
+ Every PR witness opens says in its description what it promises (the spec's summary at the plan's pin), what is
441
+ proven and by how many witnessed tests (each seen failing before it passed), what it leaves unproven (bookings, waived
442
+ guards, held criteria, checks or findings a gate was approved over, mutation survivors), what could not be measured,
443
+ how many review rounds ran, who decided, and which look and behavior map the plan was written against. The rest sits in collapsed sections: each step's tests, the checks, every
444
+ blocking finding's fate. witness owns the part between its two markers and rewrites it after every push of the approved
445
+ tree; write your own notes above or below them, and they are kept as you wrote them. Text the proof quotes — test
446
+ names, findings, paths — sits only in code, so a closing keyword (`fix #93`) or a mention in it fires nothing.
447
+ `witness status --proof <plan-id>` prints its lines and detail tables in the terminal, and `decide --show` opens a
448
+ plan's implement and ship screens with them (a decision still owed shows what approving would leave). witness's own
449
+ merge (under autonomy) and the merge command it offers you carry witness's own commit message, so a repository whose
450
+ merge message is "pull request title and description" does not copy the proof into history through them; a merge made
451
+ with GitHub's button would, and `witness check` warns of that setting.
452
+
453
+ With `proof.screens: private` or `public`, the description also shows the screenshots the plan's tests took (see the browser-test
454
+ captures in the implement skill): up to six from its own step tests right under the top lines, up to twenty more in a
455
+ collapsed section, each captioned by the test that took it. ship pushes them, verified against the shas `test-evidence`
456
+ witnessed, as one commit to `refs/witness/screens/<plan-id>` on origin — a ref outside `refs/heads`, so no branch
457
+ list, default clone or fetch shows or downloads it (`git ls-remote` lists it), and no workflow runs for it; it is kept after the merge, since the merged
458
+ description links it. `private` (what `migrate` and `init` write where GitHub reads the repository private) checks the
459
+ visibility again before every push and pushes nothing once the repository is public; `public` shows them whatever the
460
+ visibility; `none` never pushes. Nothing is pushed either when the repository gh reads (`gh repo set-default`) is not
461
+ the one origin names — after a rename or a move, point origin's URL at the new name — and `witness check` warns of both. A ruleset or hook that refuses `refs/witness/*` stops ship
462
+ until you allow `refs/witness/screens/*` or set `proof.screens: none`. The images show for signed-in viewers who can
463
+ see the repository.
464
+
465
+ ### Always-rules
466
+
467
+ An always-rule is a behavior a spec promises whatever the order or input — "a token rotates before its expiry,
468
+ whatever the elapsed time past 80%". It is a criterion of its own, tagged with the spec's tag plus `::` and its id, and
469
+ stated in plain sentences under its own heading in `## Behavior`:
470
+
471
+ ```yaml
472
+ criteria:
473
+ - { id: ac-rotate, test: "@spec:auth-refresh" }
474
+ - { id: token-rotates, test: "@spec:auth-refresh::token-rotates" }
475
+ ```
476
+
477
+ ```markdown
478
+ ### Always: token-rotates
479
+
480
+ A token rotates before its expiry, whatever the elapsed time past 80%.
481
+ ```
482
+
483
+ Its tests carry `@spec:auth-refresh::token-rotates` in their names, and count for the spec too; a Rust test carries it
484
+ in its path (`mod spec_auth_refresh` holding `fn token_rotates`), as cargo-nextest writes it. A rule is judged by its own
485
+ tests alone, which only a junit report names, so it needs `criteria.report: junit:<glob>` — witness refuses one
486
+ without — and in filtered mode the runner template must write it (vitest: `--reporter=junit --outputFile=<path>`).
487
+ A framework whose junit names are identifiers or dotted paths (pytest functions, JUnit or xUnit methods) cannot carry
488
+ the `::` tag: always-rules are unproven there. A plan with a step for the rule brings pr-test to its implement review,
489
+ whatever its class, to judge whether those tests explore many orders or inputs rather than one example.
490
+
491
+ ### Behavior maps
492
+
493
+ A spec a person reaches carries a behavior map: a spec marked `ui: true` (a screen), or `entry: true` (a command, an
494
+ endpoint or a message a person meets without a screen). The map is one mermaid `stateDiagram-v2` under
495
+ `## Behavior map`, in witness's subset — transitions, descriptions, `state "…" as X`, composites, fork, join and choice,
496
+ notes, direction and `%%` comments; no styling, init, front matter or click:
497
+
498
+ ````markdown
499
+ ## Behavior map
500
+
501
+ ```mermaid
502
+ stateDiagram-v2
503
+ [*] --> Signed_in
504
+ Signed_in --> Rotated : token near expiry
505
+ ```
506
+ ````
507
+
508
+ `witness write` refuses such a spec without one; specs written before maps, and specs no person reaches (engine specs,
509
+ which show their always-rules instead), need none and never warn. Once an effort's slicing is approved, the map gate's
510
+ reviewer checks each map against its `## Behavior` prose and always-rules. Where the reviewer finds a map and its prose
511
+ disagreeing, under autonomy witness's judge reads the effort's recap first: it sends the map back naming the side the
512
+ recap supports, or, where the recap says nothing, leaves the stop to you (`witness decide map <effort> --show` names its
513
+ reason; you approve the maps as they stand or send one back naming the side); the page shows each map's Behavior prose
514
+ beside it. A human is asked only when a map or an
515
+ always-rule of such a spec is new or changed — never for a prose-only change, never for an old spec nobody amends —
516
+ once per decompose or amendment: `witness map <effort> --open` opens one page with every changed map, what changed
517
+ since the approved one highlighted, and each spec's always-rules; `witness decide map <effort> --approve` stamps them
518
+ all (`--revise --note "<why>"`, naming the spec, sends one back). Dropping `ui`/`entry` and the map from a spec whose map was approved is a change too: it stops for a human, and approving it clears the stamp. No plan is written against a map that waits, and no
519
+ autonomous decision approves one: under autonomy it is the kept stop `behavior maps`. The page renders the maps with
520
+ mermaid 12.3.0 from jsDelivr, pinned by its SRI hash under a Content-Security-Policy that loads nothing else; offline,
521
+ or if the build does not match its hash, it shows each map's source and says why.
522
+
523
+ A screen's map rides its look. For a `ui` spec in a feature effort, the map reviewer passes the map first, then
524
+ `witness design <spec> --open` shows the map on its own page beside the look, and approving the look
525
+ (`witness decide design <spec> --approve`) approves the map too — one approval, never a separate map act. Other specs a
526
+ person reaches (`entry: true`) keep the one-page map act above.
527
+
528
+ ### Explore
529
+
530
+ Explore runs your built app after merges, with stand-ins for everything real, and a sealed agent — the explorer — tries
531
+ what your specs' behavior maps say a person does. It is off until four settings are set; `witness check` names what
532
+ keeps it off.
533
+
534
+ ```yaml
535
+ explore:
536
+ when: merge # off | merge | idle | release, or {feature: merge, fix: idle, chore: off}
537
+ host: {run: node scripts/explore/host.mjs, files: [scripts/explore/**]}
538
+ login: {run: node scripts/explore/login.mjs, files: [scripts/explore/login.mjs]}
539
+ resources: [port-3000] # what a test run also uses; [] = nothing shared
540
+ budgetMs: 3600000 # one run's box
541
+ model: claude-opus-5-5 # the explorer's model, on your judge's harness
542
+ ```
543
+
544
+ - **`host`** — witness runs `run` with one word appended. `reset` tears the app down (idempotent: it runs before
545
+ every provision and after every run), `provision` brings it up with its stand-ins, and both exit 0 when done.
546
+ `drive` is an MCP stdio server whose tools are your app's driver verbs: each takes a flat object of typed scalars
547
+ (a free string needs `maxLength`), and at least one is a check, marked `_meta: {"witness/check": true}`, whose
548
+ `isError: true` answer means an expectation failed. witness re-emits each schema it checked, never yours.
549
+ - **`login`** — logs the app in with stand-in identities only, after `provision`. Its secrets come from the repo's own
550
+ gitignored env, which lives at `$WITNESS_ROOT` (a fresh checkout never holds it).
551
+ - Every step runs in witness's own checkout, `.witness/explore`, at the commit explored, with `WITNESS_ROOT` and
552
+ `WITNESS_EXPLORE_COMMIT` set. A provision that starts the app in the background must redirect its output, or the
553
+ step waits for the app to exit. On Windows the app lives inside the run's job and dies with it.
554
+ - **`resources`** — what the explored app holds that a test run also uses (a port, a database). While explore holds
555
+ one, every test run waits for it (its session's clock waits too); test runs still overlap each other as
556
+ `drive.parallelSuites` allows. `[]` says the app shares nothing.
557
+ - **`when`** — `merge` explores each merge's commit, `idle` the tip of the ship branch once drive has nothing else to
558
+ run, `release` the first tag at or after a merge. Each merge's mode is read from the config in that merge's own
559
+ commit, so turning explore on never owes a run to every merge since the repo began. A per-class map uses the merged
560
+ plan's class.
561
+
562
+ - **The explorer** — after `login`, witness starts an agent on your judge's harness with `explore.model`. Its only
563
+ tools are your host's driver verbs and witness's `report_finding`: no shell, no file reads (it runs in an empty
564
+ folder), no session saved, and witness checks its tool list before it serves a single call. It walks the approved
565
+ behavior maps of the explored commit's live specs — the specs the explored merges touched first — and witness forwards
566
+ each call to your `drive`, one at a time, and records it. Each run spends that model for up to `explore.budgetMs` less
567
+ the host's steps; `idle` and a per-class `when` are how to spend less. A usage limit before its first call defers the
568
+ run, without a strike; with no approved map, a run only proves your host.
569
+ - **Claims** — the explorer reports a failed check as a claim: the spec, the state on its map, the calls a person would
570
+ repeat (ending in the check witness saw fail), what it expected and observed, and a proposed test (never run). drive's
571
+ report counts calls, failed checks and claims, and prints none of the explorer's words. Claims — each step's verb,
572
+ arguments and the first 300 characters of your app's answer — are journaled in witness's state and pushed with it, so
573
+ a host should show stand-in data only.
574
+ - **Findings** — drive then replays each claim: its recorded calls run again through your host, twice, each time from a
575
+ fresh reset, provision and login, at the explored commit and at older code states back to the last explored merge
576
+ (or the spec's last shipped merge). A claim becomes a finding only when it fails both times at the explored commit
577
+ and passes both times at an older state, and both still read so when witness reads them again; witness narrows it to
578
+ the commit that flipped it, and charges that merge when its code is that merge's alone and the commit's message (the
579
+ `#N` GitHub writes) agrees. Anything else — your stand-in down, a flaky check, a claim that no longer
580
+ reproduces — is "could not verify". Findings show in drive's report and `witness status --record`, never on a pull
581
+ request. A replay runs your host at several commits, within `explore.budgetMs`, and each older commit's scripts run
582
+ only where your grant covers their files. A finding needs room for about eight host cycles (reset to teardown) in
583
+ `explore.budgetMs`; a host whose cycle takes longer than an eighth of it never makes one.
584
+ - **Repairs** — when the explorer quotes the words of the spec a finding breaks (`basis`: the exact words of its map or
585
+ Behavior text, which witness checks against what the run was handed), drive repairs it unasked: it births a `fix`
586
+ effort for the finding (`witness recap --from <finding>`), plans it on that spec with the witnessed failing test as
587
+ its first step, and the spec's text stays. The plan ships like any other; its merge closes the repair, naming that
588
+ test. Once that merge is on your upstream, drive checks it. It replays the explorer's own steps at the repair's
589
+ merge, and if they still fail there but pass where the break began, the repair missed: `witness status --record`
590
+ says so, and the finding asks you again as `wait: finding`, naming the repair that missed. A repair waits while its spec has a change of yours still unplanned or a plan in flight, and drive births one
591
+ machine change at a time. An explore after a repair's merge only reports, as does a break already being repaired.
592
+ - **Findings that ask you** — a finding the spec is silent about (no quote), or whose quoted words your spec no longer
593
+ holds, shows in `witness status`'s needs-you as `wait: finding`. `witness finding <key>` shows witness's facts, then
594
+ the explorer's words spelled out as data; at your own terminal, `--approve` has drive repair it test-first (the
595
+ spec's text stays), and `--no` declines it and queues one ask, so the grill settles what the spec should say. No
596
+ witness session can answer for you. `witness diff <spec>` lists the repairs owed against a spec, and
597
+ `witness status --record` lists every repair and charges each to the merge its finding flipped at.
598
+ - **Your verbs' arguments are untrusted values**: witness types and bounds them, but a model chose them — read them as
599
+ input from a stranger.
600
+ - A merge is explored once a sync has pushed its stamp: explore reads the ship branch's upstream, where every stamp holds
601
+ its merge's code. A ship branch with no upstream explores nothing.
602
+
603
+ The host and login scripts are trusted by their files, not their names: `witness trust --cmd '<run>' --at <commit>`
604
+ pins the blobs of every file the globs match at that commit, and a run at a commit whose files differ waits for a new
605
+ grant naming it. The wait says what changed since your last grant (an edited script, changed globs), and the grant
606
+ lists every file it pins. Declare every file the host loads that you would want to read before it runs: a module
607
+ outside the globs runs unpinned. Nothing runs until a merge lands after the commit that turns explore on (an
608
+ uncommitted edit never counts), and `release` needs the tags in this clone. If a run is stopped mid-way, test runs
609
+ wait while drive's explore job resets the host it left up; with no drive running, reset it yourself and remove
610
+ `.witness/live/explore/up.json`.
611
+
330
612
  ## Exit codes
331
613
 
332
614
  `0` ok · `1` findings · `2` refused (structured `{field, rule, got, want}` rows) · `3` blocked (lock/txn/untrusted cmd in non-TTY) · `9` test-only injected crash
package/dist/abandon.js CHANGED
@@ -13,6 +13,8 @@ import { humanCall, ok, refuse, v } from './refusal.js';
13
13
  import { prepareStamp, writeStamp } from './stamp.js';
14
14
  import { kv } from './toon.js';
15
15
  import { removeWorktree, worktreePath } from './worktree.js';
16
+ import { abandonCloses, declines, ledgerTaken } from './ledger.js';
17
+ import { LEDGER_STREAM } from './streams.js';
16
18
  const isWrite = (e, id, sha) => {
17
19
  const w = e;
18
20
  return w.t === 'write' && w.artifact === id && (sha === undefined || w.sha === sha);
@@ -371,6 +373,21 @@ export function executeAbandon(root, ctx, items, efforts, subject) {
371
373
  if (!lockR.ok)
372
374
  return lockR;
373
375
  try {
376
+ // Row 269. The abandoned plans' open ledger items close in this transaction, read under its lock:
377
+ // a plan that never merges brings nothing it booked to main. A taken ledger stream takes nothing.
378
+ const plans = items.flatMap((i) => (i.planId !== undefined ? [i.planId] : []));
379
+ const free = ledgerTaken(root) === undefined;
380
+ // Row 290. And each cleanup born into an abandoned effort is declined, in the same transaction.
381
+ const ledgerEnds = [
382
+ ...(plans.length > 0 && free ? abandonCloses(root, plans) : []),
383
+ ...(efforts.length > 0 && free ? declines(root, efforts) : []),
384
+ ];
385
+ const closes = ledgerEnds.map((c) => c);
386
+ const closeLines = closes.map((c) => entryLine(c));
387
+ if (closes.length > 0)
388
+ files.add(journalRel(LEDGER_STREAM));
389
+ for (const l of closeLines)
390
+ journalMulti.push({ stream: LEDGER_STREAM, line: l });
374
391
  return withTxn(root, { op: 'abandon', files: [...files], journalMulti }, () => {
375
392
  for (const item of items) {
376
393
  if (item.revert) {
@@ -400,6 +417,8 @@ export function executeAbandon(root, ctx, items, efforts, subject) {
400
417
  appendEntry(root, re.stream, re.entry);
401
418
  for (const l of effortLines)
402
419
  appendEntry(root, l.stream, JSON.parse(l.line));
420
+ for (const c of closes)
421
+ appendEntry(root, LEDGER_STREAM, c);
403
422
  crashPoint(ctx.env, 'abandon-commit');
404
423
  const r = stateCommit(root, [...files], subject);
405
424
  // D141. `abandon` runs from wherever the human typed it, which may be the very
package/dist/act.d.ts CHANGED
@@ -12,6 +12,6 @@ export interface Act {
12
12
  }
13
13
  export declare function actOn(platform: Platform, argv: readonly string[]): Act;
14
14
  export declare function cliAct(...argv: string[]): Act;
15
- export declare function runRow(act: Act, label?: 'run' | 'then' | 'revise' | 'fresh' | 'recheck', indent?: string): string;
15
+ export declare function runRow(act: Act, label?: 'run' | 'then' | 'revise' | 'fresh' | 'recheck' | 'book', indent?: string): string;
16
16
  export declare function exitsLine(acts: readonly Act[], platform?: Platform): string;
17
17
  export declare function reopenRows(reopen: readonly Act[]): string[];
@@ -4,17 +4,31 @@ import type { Config } from './config.js';
4
4
  import { type Result } from './refusal.js';
5
5
  import { type Canon, type CanonDoc } from './scan.js';
6
6
  import { type Platform } from './toon.js';
7
+ export interface PinEntry {
8
+ cmd: string;
9
+ globs: string[];
10
+ files: Record<string, string>;
11
+ }
12
+ export declare const loadPins: (root: string) => PinEntry[];
7
13
  export declare function trustedCommands(root: string): string[];
8
14
  export declare function grantCommands(root: string, cmds: string[]): void;
15
+ export declare function grantPin(root: string, e: PinEntry): void;
16
+ export declare function pinSet(root: string, globs: readonly string[], commit: string): Result<Record<string, string>>;
17
+ export declare function pinNote(root: string, c: Pick<RunCommand, 'cmd' | 'files'>, commit: string): string | undefined;
18
+ export declare function pinnedTrusted(root: string, env: Record<string, string | undefined>, c: Pick<RunCommand, 'cmd' | 'files'>, commit: string): boolean;
9
19
  export declare function untrustedCmdsFor(root: string, doc: CanonDoc | undefined): string[];
10
20
  export interface RunCommand {
11
21
  cmd: string;
12
22
  source: string;
23
+ files?: readonly string[];
24
+ at?: string;
25
+ note?: string;
13
26
  }
14
27
  export declare const shownCmd: (c: RunCommand) => string;
15
28
  export declare const UNGRANTABLE = "never granted here \u2014 rewrite it in printable ASCII where it is written";
16
29
  export declare const unsafeLeft: (n: number) => string;
17
30
  export declare function grantAct(target: string, c: Pick<RunCommand, 'cmd'>, platform?: Platform): Act | undefined;
31
+ export declare function repoGrantAct(c: Pick<RunCommand, 'cmd' | 'at'>, platform?: Platform): Act | undefined;
18
32
  export declare const grantOf: (target: string, c: Pick<RunCommand, "cmd">, platform?: Platform) => string;
19
33
  export declare function grantRows(target: string, c: Pick<RunCommand, 'cmd'>, platform?: Platform): string[];
20
34
  export declare function grantRowsOf(grant: Act | undefined, list: Act): string[];
@@ -45,4 +59,5 @@ export declare function trustOwed(root: string, env: Record<string, string | und
45
59
  line: string;
46
60
  target?: string;
47
61
  }): RunCommand[];
62
+ export declare function trustedNow(root: string, env: Record<string, string | undefined>, cmd: string): boolean;
48
63
  export declare function ensureTrusted(root: string, ctx: Ctx, cmd: string): Promise<'trusted' | 'declined' | 'blocked'>;