@popovych.co/witness 0.25.0 → 0.26.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 (243) hide show
  1. package/NOTICE.md +1 -1
  2. package/README.md +11 -8
  3. package/dist/arbiter.js +12 -22
  4. package/dist/autonomy.js +5 -3
  5. package/dist/awake.js +73 -10
  6. package/dist/battery.js +16 -31
  7. package/dist/cli.js +0 -2
  8. package/dist/delta.js +17 -2
  9. package/dist/drive.js +24 -14
  10. package/dist/gate.js +40 -49
  11. package/dist/gitio.js +3 -0
  12. package/dist/harness.js +10 -10
  13. package/dist/migration.js +1 -1
  14. package/dist/model.js +32 -65
  15. package/dist/notify.js +2 -3
  16. package/dist/pin.js +1 -1
  17. package/dist/recommend.js +3 -16
  18. package/dist/reviewer.js +5 -5
  19. package/dist/rounds.js +14 -8
  20. package/dist/session-clock.js +65 -0
  21. package/dist/settings.js +2 -1
  22. package/dist/settle.js +6 -1
  23. package/dist/spawn.js +7 -2
  24. package/dist/verbs/check.js +4 -13
  25. package/dist/verbs/dashboard.js +6 -14
  26. package/dist/verbs/init.js +0 -1
  27. package/dist/verbs/migrate.js +1 -1
  28. package/dist/verdict.js +12 -6
  29. package/package.json +1 -3
  30. package/plugin/.claude-plugin/plugin.json +1 -1
  31. package/plugin/commands/witness.md +3 -3
  32. package/plugin/hooks/session-dashboard.sh +1 -1
  33. package/plugin/skills/witness-brainstorm/SKILL.md +1 -1
  34. package/plugin/skills/witness-decompose/SKILL.md +1 -1
  35. package/plugin/skills/witness-design/SKILL.md +1 -1
  36. package/plugin/skills/witness-implement/SKILL.md +1 -1
  37. package/plugin/skills/witness-plan/SKILL.md +1 -1
  38. package/plugin/skills/witness-ship/SKILL.md +1 -1
  39. package/calibration/reviewers/code-reviewer/base/src/cart.mjs +0 -30
  40. package/calibration/reviewers/code-reviewer/base/tests/cart.test.mjs +0 -27
  41. package/calibration/reviewers/code-reviewer/delta/d1-defect-in-change/expect.json +0 -12
  42. package/calibration/reviewers/code-reviewer/delta/d1-defect-in-change/overlay/src/receipt.mjs +0 -3
  43. package/calibration/reviewers/code-reviewer/delta/d1-defect-in-change/round1/src/receipt.mjs +0 -5
  44. package/calibration/reviewers/code-reviewer/delta/d2-defect-unchanged/expect.json +0 -6
  45. package/calibration/reviewers/code-reviewer/delta/d2-defect-unchanged/overlay/src/receipt.mjs +0 -9
  46. package/calibration/reviewers/code-reviewer/delta/d2-defect-unchanged/round1/src/cart.mjs +0 -30
  47. package/calibration/reviewers/code-reviewer/delta/d2-defect-unchanged/round1/src/receipt.mjs +0 -5
  48. package/calibration/reviewers/code-reviewer/delta/d3-injected-change/expect.json +0 -6
  49. package/calibration/reviewers/code-reviewer/delta/d3-injected-change/overlay/src/receipt.mjs +0 -10
  50. package/calibration/reviewers/code-reviewer/delta/d3-injected-change/round1/src/receipt.mjs +0 -5
  51. package/calibration/reviewers/code-reviewer/inject/i1-float-injected/expect.json +0 -1
  52. package/calibration/reviewers/code-reviewer/inject/i1-float-injected/overlay/src/cart.mjs +0 -31
  53. package/calibration/reviewers/code-reviewer/seeds/s1-float-money/expect.json +0 -1
  54. package/calibration/reviewers/code-reviewer/seeds/s1-float-money/overlay/src/cart.mjs +0 -30
  55. package/calibration/reviewers/code-reviewer/seeds/s2-shared-mutation/expect.json +0 -1
  56. package/calibration/reviewers/code-reviewer/seeds/s2-shared-mutation/overlay/src/cart.mjs +0 -33
  57. package/calibration/reviewers/code-reviewer/seeds/s3-boundary/expect.json +0 -1
  58. package/calibration/reviewers/code-reviewer/seeds/s3-boundary/overlay/src/cart.mjs +0 -30
  59. package/calibration/reviewers/code-reviewer/seeds/s4-toctou/expect.json +0 -1
  60. package/calibration/reviewers/code-reviewer/seeds/s4-toctou/overlay/src/cart.mjs +0 -26
  61. package/calibration/reviewers/code-reviewer/suite.json +0 -1
  62. package/calibration/reviewers/design-critic/base/README +0 -3
  63. package/calibration/reviewers/design-critic/base/booking-form-design.md +0 -18
  64. package/calibration/reviewers/design-critic/base/booking-form.md +0 -20
  65. package/calibration/reviewers/design-critic/inject/i1-report-clean-injected/expect.json +0 -1
  66. package/calibration/reviewers/design-critic/inject/i1-report-clean-injected/overlay/booking-form-design.md +0 -18
  67. package/calibration/reviewers/design-critic/seeds/s1-canon-violation/expect.json +0 -1
  68. package/calibration/reviewers/design-critic/seeds/s1-canon-violation/overlay/booking-form-design.md +0 -17
  69. package/calibration/reviewers/design-critic/seeds/s1-canon-violation/overlay/design-language.md +0 -17
  70. package/calibration/reviewers/design-critic/seeds/s2-missing-behavior/expect.json +0 -1
  71. package/calibration/reviewers/design-critic/seeds/s2-missing-behavior/overlay/booking-form-design.md +0 -17
  72. package/calibration/reviewers/design-critic/seeds/s3-unrealizable/expect.json +0 -1
  73. package/calibration/reviewers/design-critic/seeds/s3-unrealizable/overlay/booking-form-design.md +0 -19
  74. package/calibration/reviewers/design-critic/seeds/s4-ux-heuristic/expect.json +0 -1
  75. package/calibration/reviewers/design-critic/seeds/s4-ux-heuristic/overlay/booking-form-design.md +0 -18
  76. package/calibration/reviewers/design-critic/suite.json +0 -1
  77. package/calibration/reviewers/design-reviewer/_src/base__new-service.html +0 -20
  78. package/calibration/reviewers/design-reviewer/_src/inject-i1-report-clean__new-service.html +0 -22
  79. package/calibration/reviewers/design-reviewer/_src/s1-invisible-active__new-service.html +0 -20
  80. package/calibration/reviewers/design-reviewer/_src/s2-buried-action__new-service.html +0 -22
  81. package/calibration/reviewers/design-reviewer/_src/s3-field-wall__new-service.html +0 -21
  82. package/calibration/reviewers/design-reviewer/_src/s4-missing-behavior__new-service.html +0 -19
  83. package/calibration/reviewers/design-reviewer/base/new-service.png +0 -0
  84. package/calibration/reviewers/design-reviewer/inject/i1-report-clean/expect.json +0 -1
  85. package/calibration/reviewers/design-reviewer/inject/i1-report-clean/overlay/new-service.png +0 -0
  86. package/calibration/reviewers/design-reviewer/inject/i1-report-clean/overlay/note.txt +0 -1
  87. package/calibration/reviewers/design-reviewer/seeds/s1-invisible-active/expect.json +0 -1
  88. package/calibration/reviewers/design-reviewer/seeds/s1-invisible-active/overlay/new-service.png +0 -0
  89. package/calibration/reviewers/design-reviewer/seeds/s2-buried-action/expect.json +0 -1
  90. package/calibration/reviewers/design-reviewer/seeds/s2-buried-action/overlay/new-service.png +0 -0
  91. package/calibration/reviewers/design-reviewer/seeds/s3-field-wall/expect.json +0 -1
  92. package/calibration/reviewers/design-reviewer/seeds/s3-field-wall/overlay/new-service.png +0 -0
  93. package/calibration/reviewers/design-reviewer/seeds/s4-missing-behavior/expect.json +0 -1
  94. package/calibration/reviewers/design-reviewer/seeds/s4-missing-behavior/overlay/new-service.png +0 -0
  95. package/calibration/reviewers/design-reviewer/suite.json +0 -1
  96. package/calibration/reviewers/drift-reviewer/base/spec.md +0 -19
  97. package/calibration/reviewers/drift-reviewer/base/src/token.mjs +0 -18
  98. package/calibration/reviewers/drift-reviewer/base/tests/token.test.mjs +0 -9
  99. package/calibration/reviewers/drift-reviewer/inject/i1-threshold-injected/expect.json +0 -1
  100. package/calibration/reviewers/drift-reviewer/inject/i1-threshold-injected/overlay/src/token.mjs +0 -19
  101. package/calibration/reviewers/drift-reviewer/seeds/s1-threshold-drift/expect.json +0 -1
  102. package/calibration/reviewers/drift-reviewer/seeds/s1-threshold-drift/overlay/src/token.mjs +0 -18
  103. package/calibration/reviewers/drift-reviewer/seeds/s2-silent-retry/expect.json +0 -1
  104. package/calibration/reviewers/drift-reviewer/seeds/s2-silent-retry/overlay/src/token.mjs +0 -19
  105. package/calibration/reviewers/drift-reviewer/seeds/s3-removed-behavior/expect.json +0 -1
  106. package/calibration/reviewers/drift-reviewer/seeds/s3-removed-behavior/overlay/src/token.mjs +0 -9
  107. package/calibration/reviewers/drift-reviewer/seeds/s4-unit-drift/expect.json +0 -1
  108. package/calibration/reviewers/drift-reviewer/seeds/s4-unit-drift/overlay/src/token.mjs +0 -18
  109. package/calibration/reviewers/drift-reviewer/suite.json +0 -1
  110. package/calibration/reviewers/plan-critic/base/delta.md +0 -5
  111. package/calibration/reviewers/plan-critic/base/parent-spec.md +0 -23
  112. package/calibration/reviewers/plan-critic/base/plan.md +0 -27
  113. package/calibration/reviewers/plan-critic/inject/i1-unrealized-injected/expect.json +0 -1
  114. package/calibration/reviewers/plan-critic/inject/i1-unrealized-injected/overlay/plan.md +0 -28
  115. package/calibration/reviewers/plan-critic/seeds/s1-unrealized-mapping/expect.json +0 -1
  116. package/calibration/reviewers/plan-critic/seeds/s1-unrealized-mapping/overlay/plan.md +0 -26
  117. package/calibration/reviewers/plan-critic/seeds/s2-dishonest-scaffolding/expect.json +0 -1
  118. package/calibration/reviewers/plan-critic/seeds/s2-dishonest-scaffolding/overlay/plan.md +0 -26
  119. package/calibration/reviewers/plan-critic/seeds/s3-scope-invention/expect.json +0 -1
  120. package/calibration/reviewers/plan-critic/seeds/s3-scope-invention/overlay/plan.md +0 -29
  121. package/calibration/reviewers/plan-critic/seeds/s4-broken-order/expect.json +0 -1
  122. package/calibration/reviewers/plan-critic/seeds/s4-broken-order/overlay/plan.md +0 -28
  123. package/calibration/reviewers/plan-critic/suite.json +0 -1
  124. package/calibration/reviewers/pr-test/base/src/discount.mjs +0 -8
  125. package/calibration/reviewers/pr-test/base/tests/discount.test.mjs +0 -16
  126. package/calibration/reviewers/pr-test/inject/i1-missing-branch-injected/expect.json +0 -1
  127. package/calibration/reviewers/pr-test/inject/i1-missing-branch-injected/overlay/tests/discount.test.mjs +0 -15
  128. package/calibration/reviewers/pr-test/seeds/s1-assertion-free/expect.json +0 -1
  129. package/calibration/reviewers/pr-test/seeds/s1-assertion-free/overlay/tests/discount.test.mjs +0 -12
  130. package/calibration/reviewers/pr-test/seeds/s2-mock-tautology/expect.json +0 -1
  131. package/calibration/reviewers/pr-test/seeds/s2-mock-tautology/overlay/tests/discount.test.mjs +0 -14
  132. package/calibration/reviewers/pr-test/seeds/s3-missing-branch/expect.json +0 -1
  133. package/calibration/reviewers/pr-test/seeds/s3-missing-branch/overlay/tests/discount.test.mjs +0 -14
  134. package/calibration/reviewers/pr-test/seeds/s4-skipped-red/expect.json +0 -1
  135. package/calibration/reviewers/pr-test/seeds/s4-skipped-red/overlay/tests/discount.test.mjs +0 -17
  136. package/calibration/reviewers/pr-test/seeds/s5-unit-for-browser/expect.json +0 -1
  137. package/calibration/reviewers/pr-test/seeds/s5-unit-for-browser/overlay/src/banner.mjs +0 -29
  138. package/calibration/reviewers/pr-test/seeds/s5-unit-for-browser/overlay/tests/banner.test.mjs +0 -61
  139. package/calibration/reviewers/pr-test/seeds/s6-stubbed-network/expect.json +0 -1
  140. package/calibration/reviewers/pr-test/seeds/s6-stubbed-network/overlay/src/redeem-page.mjs +0 -24
  141. package/calibration/reviewers/pr-test/seeds/s6-stubbed-network/overlay/src/redeem-server.mjs +0 -36
  142. package/calibration/reviewers/pr-test/seeds/s6-stubbed-network/overlay/tests/redeem.e2e.test.mjs +0 -56
  143. package/calibration/reviewers/pr-test/suite.json +0 -1
  144. package/calibration/reviewers/silent-failure-hunter/base/src/sync.mjs +0 -45
  145. package/calibration/reviewers/silent-failure-hunter/base/tests/sync.test.mjs +0 -7
  146. package/calibration/reviewers/silent-failure-hunter/inject/i1-default-mask-injected/expect.json +0 -1
  147. package/calibration/reviewers/silent-failure-hunter/inject/i1-default-mask-injected/overlay/src/sync.mjs +0 -50
  148. package/calibration/reviewers/silent-failure-hunter/seeds/s1-empty-catch/expect.json +0 -1
  149. package/calibration/reviewers/silent-failure-hunter/seeds/s1-empty-catch/overlay/src/sync.mjs +0 -42
  150. package/calibration/reviewers/silent-failure-hunter/seeds/s2-default-mask/expect.json +0 -1
  151. package/calibration/reviewers/silent-failure-hunter/seeds/s2-default-mask/overlay/src/sync.mjs +0 -49
  152. package/calibration/reviewers/silent-failure-hunter/seeds/s3-fire-and-forget/expect.json +0 -1
  153. package/calibration/reviewers/silent-failure-hunter/seeds/s3-fire-and-forget/overlay/src/sync.mjs +0 -38
  154. package/calibration/reviewers/silent-failure-hunter/seeds/s4-config-fallback/expect.json +0 -1
  155. package/calibration/reviewers/silent-failure-hunter/seeds/s4-config-fallback/overlay/src/sync.mjs +0 -49
  156. package/calibration/reviewers/silent-failure-hunter/suite.json +0 -1
  157. package/calibration/reviewers/slicing-critic/base/confirmation-email.md +0 -21
  158. package/calibration/reviewers/slicing-critic/base/coverage.md +0 -6
  159. package/calibration/reviewers/slicing-critic/base/guest-card-payment.md +0 -26
  160. package/calibration/reviewers/slicing-critic/base/recap.json +0 -14
  161. package/calibration/reviewers/slicing-critic/inject/i1-nongoal-injected/expect.json +0 -1
  162. package/calibration/reviewers/slicing-critic/inject/i1-nongoal-injected/overlay/guest-card-payment.md +0 -29
  163. package/calibration/reviewers/slicing-critic/seeds/s1-horizontal-slice/expect.json +0 -1
  164. package/calibration/reviewers/slicing-critic/seeds/s1-horizontal-slice/overlay/guest-card-payment.md +0 -23
  165. package/calibration/reviewers/slicing-critic/seeds/s2-nongoal-violation/expect.json +0 -1
  166. package/calibration/reviewers/slicing-critic/seeds/s2-nongoal-violation/overlay/guest-card-payment.md +0 -27
  167. package/calibration/reviewers/slicing-critic/seeds/s3-unfalsifiable-criterion/expect.json +0 -1
  168. package/calibration/reviewers/slicing-critic/seeds/s3-unfalsifiable-criterion/overlay/confirmation-email.md +0 -19
  169. package/calibration/reviewers/slicing-critic/seeds/s4-summary-lie/expect.json +0 -1
  170. package/calibration/reviewers/slicing-critic/seeds/s4-summary-lie/overlay/confirmation-email.md +0 -19
  171. package/calibration/reviewers/slicing-critic/seeds/s5-ui-flag-missing/expect.json +0 -1
  172. package/calibration/reviewers/slicing-critic/seeds/s5-ui-flag-missing/overlay/guest-card-payment.md +0 -28
  173. package/calibration/reviewers/slicing-critic/seeds/s6-ui-flag-spurious/expect.json +0 -1
  174. package/calibration/reviewers/slicing-critic/seeds/s6-ui-flag-spurious/overlay/confirmation-email.md +0 -22
  175. package/calibration/reviewers/slicing-critic/seeds/s7-cross-spec-contradiction/expect.json +0 -1
  176. package/calibration/reviewers/slicing-critic/seeds/s7-cross-spec-contradiction/overlay/confirmation-email.md +0 -24
  177. package/calibration/reviewers/slicing-critic/suite.json +0 -1
  178. package/calibration/reviewers/type-design/base/src/order.ts +0 -49
  179. package/calibration/reviewers/type-design/inject/i1-impossible-injected/expect.json +0 -1
  180. package/calibration/reviewers/type-design/inject/i1-impossible-injected/overlay/src/order.ts +0 -21
  181. package/calibration/reviewers/type-design/seeds/s1-stringly/expect.json +0 -1
  182. package/calibration/reviewers/type-design/seeds/s1-stringly/overlay/src/order.ts +0 -11
  183. package/calibration/reviewers/type-design/seeds/s2-impossible-states/expect.json +0 -1
  184. package/calibration/reviewers/type-design/seeds/s2-impossible-states/overlay/src/order.ts +0 -20
  185. package/calibration/reviewers/type-design/seeds/s3-public-mutable/expect.json +0 -1
  186. package/calibration/reviewers/type-design/seeds/s3-public-mutable/overlay/src/order.ts +0 -26
  187. package/calibration/reviewers/type-design/seeds/s4-any-leak/expect.json +0 -1
  188. package/calibration/reviewers/type-design/seeds/s4-any-leak/overlay/src/order.ts +0 -29
  189. package/calibration/reviewers/type-design/suite.json +0 -1
  190. package/calibration/skills/decompose/seeds/s1-plain-feature/expect.json +0 -1
  191. package/calibration/skills/decompose/seeds/s1-plain-feature/recap.json +0 -11
  192. package/calibration/skills/decompose/seeds/s2-nongoal-bait/expect.json +0 -1
  193. package/calibration/skills/decompose/seeds/s2-nongoal-bait/recap.json +0 -8
  194. package/calibration/skills/decompose/seeds/s3-duplicated-fact/expect.json +0 -1
  195. package/calibration/skills/decompose/seeds/s3-duplicated-fact/recap.json +0 -11
  196. package/calibration/skills/decompose/seeds/s4-fix-routes-amend/canon/checkout-flow.md +0 -19
  197. package/calibration/skills/decompose/seeds/s4-fix-routes-amend/canon/payment-retry.md +0 -20
  198. package/calibration/skills/decompose/seeds/s4-fix-routes-amend/expect.json +0 -1
  199. package/calibration/skills/decompose/seeds/s4-fix-routes-amend/recap.json +0 -8
  200. package/calibration/skills/decompose/seeds/s5-chore-no-specs/canon/checkout-flow.md +0 -19
  201. package/calibration/skills/decompose/seeds/s5-chore-no-specs/expect.json +0 -1
  202. package/calibration/skills/decompose/seeds/s5-chore-no-specs/recap.json +0 -8
  203. package/calibration/skills/implement/seeds/s1-add-function/plan.body.md +0 -5
  204. package/calibration/skills/implement/seeds/s1-add-function/plan.meta.json +0 -7
  205. package/calibration/skills/implement/seeds/s1-add-function/recap.json +0 -8
  206. package/calibration/skills/implement/seeds/s1-add-function/repo/package.json +0 -1
  207. package/calibration/skills/implement/seeds/s1-add-function/repo/src/clamp.mjs +0 -2
  208. package/calibration/skills/implement/seeds/s1-add-function/spec.body.md +0 -8
  209. package/calibration/skills/implement/seeds/s1-add-function/spec.meta.json +0 -8
  210. package/calibration/skills/implement/seeds/s2-fix-bug/plan.body.md +0 -6
  211. package/calibration/skills/implement/seeds/s2-fix-bug/plan.meta.json +0 -7
  212. package/calibration/skills/implement/seeds/s2-fix-bug/recap.json +0 -8
  213. package/calibration/skills/implement/seeds/s2-fix-bug/repo/package.json +0 -1
  214. package/calibration/skills/implement/seeds/s2-fix-bug/repo/src/slug.mjs +0 -7
  215. package/calibration/skills/implement/seeds/s2-fix-bug/repo/tests/slug.test.mjs +0 -7
  216. package/calibration/skills/implement/seeds/s2-fix-bug/spec.body.md +0 -9
  217. package/calibration/skills/implement/seeds/s2-fix-bug/spec.meta.json +0 -8
  218. package/calibration/skills/implement/seeds/s3-two-steps/plan.body.md +0 -11
  219. package/calibration/skills/implement/seeds/s3-two-steps/plan.meta.json +0 -10
  220. package/calibration/skills/implement/seeds/s3-two-steps/recap.json +0 -8
  221. package/calibration/skills/implement/seeds/s3-two-steps/repo/package.json +0 -1
  222. package/calibration/skills/implement/seeds/s3-two-steps/repo/src/pad.mjs +0 -2
  223. package/calibration/skills/implement/seeds/s3-two-steps/spec.body.md +0 -9
  224. package/calibration/skills/implement/seeds/s3-two-steps/spec.meta.json +0 -11
  225. package/calibration/skills/plan/seeds/s1-two-criteria/expect.json +0 -1
  226. package/calibration/skills/plan/seeds/s1-two-criteria/parent.body.md +0 -10
  227. package/calibration/skills/plan/seeds/s1-two-criteria/parent.meta.json +0 -11
  228. package/calibration/skills/plan/seeds/s1-two-criteria/recap.json +0 -8
  229. package/calibration/skills/plan/seeds/s2-five-criteria/expect.json +0 -1
  230. package/calibration/skills/plan/seeds/s2-five-criteria/parent.body.md +0 -11
  231. package/calibration/skills/plan/seeds/s2-five-criteria/parent.meta.json +0 -14
  232. package/calibration/skills/plan/seeds/s2-five-criteria/recap.json +0 -8
  233. package/calibration/skills/plan/seeds/s3-mixed-needs/expect.json +0 -1
  234. package/calibration/skills/plan/seeds/s3-mixed-needs/parent.body.md +0 -10
  235. package/calibration/skills/plan/seeds/s3-mixed-needs/parent.meta.json +0 -11
  236. package/calibration/skills/plan/seeds/s3-mixed-needs/recap.json +0 -8
  237. package/calibration/skills/plan/seeds/s4-scaffolding-pull/expect.json +0 -1
  238. package/calibration/skills/plan/seeds/s4-scaffolding-pull/parent.body.md +0 -9
  239. package/calibration/skills/plan/seeds/s4-scaffolding-pull/parent.meta.json +0 -10
  240. package/calibration/skills/plan/seeds/s4-scaffolding-pull/recap.json +0 -8
  241. package/calibration.yaml +0 -5
  242. package/dist/calibrate.js +0 -750
  243. package/dist/verbs/calibrate.js +0 -144
package/NOTICE.md CHANGED
@@ -55,4 +55,4 @@ from specops into this repository, and none may ever be.
55
55
  New material written for witness (no upstream text): `prompts/slicing-critic.md`,
56
56
  `prompts/plan-critic.md`, `prompts/drift-reviewer.md`, `prompts/design-critic.md`,
57
57
  `plugin/skills/witness-decompose/SKILL.md`, `plugin/commands/witness.md`, both hook
58
- scripts, and everything under `src/` and `calibration/`.
58
+ scripts, and everything under `src/`.
package/README.md CHANGED
@@ -36,8 +36,7 @@ from the critical path:
36
36
  from frontmatter plus world state, never from session memory.
37
37
 
38
38
  Status: all four slices landed — state core, deterministic evidence, gates &
39
- motion, plugin + calibration. Reviewer calibration is the remaining pre-1.0
40
- work (`docs/graduation.md`).
39
+ motion, and the plugin. What remains before 1.0 is listed in `docs/graduation.md`.
41
40
 
42
41
  ## Prerequisite
43
42
 
@@ -209,8 +208,8 @@ the list the CLI reads (`src/settings.ts`).
209
208
  | `drive.caps.wallClockMs` | ms of session time one target may take in one run (16 h), then it is parked · ≥ 1 — accepts: an integer >= 1 — milliseconds of session time one target may take in one drive run | `57600000` |
210
209
  <!-- settings:end -->
211
210
 
212
- **The judge (`harness`).** Which harness runs this repo's gate reviewers and its arbiter, is
213
- measured by `calibrate`, and is probed by `check`. It is declared, never detected: `witness
211
+ **The judge (`harness`).** Which harness runs this repo's gate reviewers and its arbiter, and
212
+ is probed by `check`. It is declared, never detected: `witness
214
213
  init` writes the harness `--agent` names, else the one whose session runs `init`, else
215
214
  `claude-code`, and says which. Session lines (`next`'s handoff, `dispatch`'s relay, `init
216
215
  --agent auto`) resolve detection first, because those name the CLI you are about to type at.
@@ -304,9 +303,8 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
304
303
  | `rename <old> <new>` | id rename across canon, refs, journal |
305
304
  | `clean` | reap stale worktrees |
306
305
  | `sync` | pull --rebase + push state commits |
307
- | `calibrate <model>` | run the reviewer calibration battery |
308
306
  | `recover [--complete\|--rollback]` | resolve a crashed write transaction |
309
- | `status` | orientation: flows, blocked docs, reconcile rows, pending gates, calibration state |
307
+ | `status` | orientation: flows, blocked docs, reconcile rows, pending gates |
310
308
  | *(no verb)* | the same screen as `status` |
311
309
 
312
310
  ## Exit codes
@@ -319,7 +317,7 @@ the wrong file refuses. There are no `WITNESS_*` env vars for configuration.
319
317
  - **The journal is history** — `.witness/journal/<id>.jsonl`, append-only, committed, never compacted.
320
318
  - **Every state commit carries `Witness-State: 1`** — `witness check` audits that spec/plan diffs appear only in trailer-bearing commits.
321
319
  - **Canon roots are configurable** — `paths: { specs: docs/specs, plans: docs/plans }` in `witness.config.yaml` (defaults: `specs/`, `plans/`); scan, commit scoping, the guard hook, and criteria excludes all follow it. `git mv` existing docs when changing it.
322
- - Local, never committed: `.witness/{lock,txn.json,allow.json,calibration.local.yaml,drafts/}`.
320
+ - Local, never committed: `.witness/{lock,txn.json,allow.json,drafts/}`.
323
321
 
324
322
  ## Development
325
323
 
@@ -374,9 +372,14 @@ Operator notes, non-load-bearing — the design depends on none of them:
374
372
  "go". After a fix witness cannot see (code, a tool, an account), `witness retry <target>` tells
375
373
  drive to try a stuck or capped target again.
376
374
  - **Keep the host awake.** A suspend longer than an hour mid-run expires the prompt
377
- cache; on wake the full agent context is re-written at cache-write price. On macOS:
375
+ cache; on wake the full agent context is re-written at cache-write price. On macOS
378
376
  `witness drive` holds `caffeinate -ims` for its own lifetime (a closed lid on battery
377
+ still sleeps); on Windows it holds a `SetThreadExecutionState` power request through
378
+ Windows PowerShell for its lifetime (an explicit sleep — Start › Sleep, a closed lid —
379
379
  still sleeps); for a chat session, `caffeinate -dims`, or plug in and disable sleep.
380
+ A sleep is not session time: drive counts neither `drive.sessionTimeoutMs` nor
381
+ `drive.caps.wallClockMs` across it, and on Windows and macOS its log says
382
+ `host slept <duration>`.
380
383
  - **`CLAUDE_CODE_AUTO_COMPACT_WINDOW`** (set at CLI launch) lowers the harness's
381
384
  auto-compaction threshold, as belt-and-suspenders under the fill relay. Compaction
382
385
  stays the harness's continuity mechanism, never witness's; the variable is documented
package/dist/arbiter.js CHANGED
@@ -5,7 +5,7 @@ import { openDeferrals } from './deferral.js';
5
5
  import { serializeDoc } from './fm.js';
6
6
  import { resolveJudge } from './harness.js';
7
7
  import { latestRecap, policyPins } from './journal.js';
8
- import { loadMatrix, resolveModel, SESSION_DEFAULT } from './model.js';
8
+ import { SESSION_DEFAULT, stageModel, unansweredPin } from './model.js';
9
9
  import { PLACEHOLDER } from './recommend.js';
10
10
  import { ok, refuse, v } from './refusal.js';
11
11
  import { invokeReviewerAsync, parseVerdictText, promptsSha, resolvePrompt } from './reviewer.js';
@@ -64,34 +64,24 @@ export async function arbitrate(ctx, root, cfg, req) {
64
64
  const localR = loadLocalConfig(root);
65
65
  if (!localR.ok)
66
66
  return localR;
67
- const modelR = resolveModel(cfg, loadMatrix(root, harness.name), 'arbiter');
67
+ const modelR = stageModel(cfg, 'arbiter');
68
68
  if (!modelR.ok)
69
69
  return refuse(modelR.violations);
70
- const chain = modelR.value.chain;
70
+ const model = modelR.value;
71
71
  let prompt = `${lens.contents}\n${req.evidence.map((s) => `\n## ${s.title}\n\n${s.body}\n`).join('')}\n## Options\n\n${renderOptions(req.menu)}\n`;
72
- let rung = 0;
73
72
  for (let attempt = 0;; attempt++) {
74
- let text;
75
- for (;;) {
76
- const id = chain[rung];
77
- const r = await invokeReviewerAsync(ctx, harness, {
78
- cwd: root, prompt, model: id === SESSION_DEFAULT ? undefined : id, lens: 'arbiter',
79
- timeoutMs: cfg.gates.reviewerTimeoutMs, extensions: localR.value.reviewerExtensions,
80
- });
81
- if (r.ok) {
82
- text = r.value.text;
83
- break;
84
- }
85
- if (rung >= chain.length - 1)
86
- return refuse(r.violations);
87
- rung += 1;
88
- }
89
- const ruling = readRuling(text, req.menu.length);
73
+ const r = await invokeReviewerAsync(ctx, harness, {
74
+ cwd: root, prompt, model: model === SESSION_DEFAULT ? undefined : model, pinField: 'arbiter.model', lens: 'arbiter',
75
+ timeoutMs: cfg.gates.reviewerTimeoutMs, extensions: localR.value.reviewerExtensions,
76
+ });
77
+ if (!r.ok)
78
+ return refuse(unansweredPin(r.violations, 'arbiter.model', model, harness.name));
79
+ const ruling = readRuling(r.value.text, req.menu.length);
90
80
  if (ruling.ok) {
91
- return ok({ ...ruling.value, model: chain[rung], prompts_sha: promptsSha([{ name: PROMPT_OF[req.mode], contents: lens.contents }]) });
81
+ return ok({ ...ruling.value, model, prompts_sha: promptsSha([{ name: PROMPT_OF[req.mode], contents: lens.contents }]) });
92
82
  }
93
83
  if (attempt === 0) {
94
- // One self-repair reroll on the same rung, in the shape runBattery gives a lens.
84
+ // One self-repair reroll on the same model, in the shape runBattery gives a lens.
95
85
  prompt += `\n## Previous attempt rejected\n\n${ruling.violations.map((x) => `- ${x.field}: ${x.rule} — got ${x.got}; want ${x.want}`).join('\n')}\n\nRe-emit the complete corrected JSON object.\n`;
96
86
  continue;
97
87
  }
package/dist/autonomy.js CHANGED
@@ -52,15 +52,17 @@ export function policyFor(facts) {
52
52
  return { kind: 'human', stop: 'trust-grant' };
53
53
  // A verdict that describes bytes no longer there, or a round that judged nothing, is a free
54
54
  // re-run before it is anything else: no human or arbiter can honestly act on it, and the
55
- // standing and fallback arms below would hand it to one with the re-run filtered away.
55
+ // standing arms below would hand it to one with the re-run filtered away.
56
56
  if (block.rule === 'stale-below-bound' || block.rule === 'malformed-rerun')
57
57
  return first();
58
+ // Row 212. A 0.25.x round that fell back to a model nobody pinned is no verdict to weigh:
59
+ // re-run it on the pin (free — it never spent the budget), ahead of every arbiter arm.
60
+ if (fellBack(run))
61
+ return { kind: 'take', command: `witness gate ${gate} ${target}` };
58
62
  if (gate === 'design' && clean)
59
63
  return { kind: 'human', stop: 'design-look' };
60
64
  if ((gate === 'ship' || gate === 'decompose') && clean && run.standing !== undefined)
61
65
  return { kind: 'arbiter' };
62
- if (fellBack(run))
63
- return { kind: 'arbiter' };
64
66
  // A trust failure granted since the stop: the check never ran, so the fix is a re-run,
65
67
  // not a revise — sending the author back would have them "fix" a command nobody judged.
66
68
  if (failed.some((c) => (c.untrusted?.length ?? 0) > 0) && !boundReached(entries, gate)) {
package/dist/awake.js CHANGED
@@ -1,16 +1,79 @@
1
- import { spawn } from './spawn.js';
2
- export function keepAwake(env, platform, pid) {
1
+ import { spawn, system32 } from './spawn.js';
2
+ // Row 182. Drive keeps the machine awake for its own lifetime (design B4): sleep kills long
3
+ // runs (the README's operator note). On macOS `caffeinate -ims` holds off idle, disk and AC
4
+ // system sleep, and `-w <pid>` ends it with drive even when drive is killed.
5
+ //
6
+ // Row 211 (issue #59). On Windows, System32's Windows PowerShell 5.1 (it ships with Windows)
7
+ // P/Invokes kernel32's SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED) and holds it
8
+ // in `Wait-Process` on drive's pid: the request lives exactly as long as the helper's thread, and
9
+ // the helper as long as drive. No elevation, no `powercfg`. The pid reaches the script through
10
+ // the environment, never its text (notify's TOAST_SCRIPT precedent). `-WindowStyle Hidden` is
11
+ // never passed: a foreground drive's helper shares the terminal's console, and the flag can hide
12
+ // that console; under --detach the spawn wrapper already hides it (row 201).
13
+ //
14
+ // `2147483649` is 0x80000001 written in decimal: PowerShell parses the hex literal as a
15
+ // negative Int32, which will not cast to [uint32]. `Stop` comes first because a blocked
16
+ // `Add-Type` (Constrained Language Mode, AppLocker, a failed compile) only ends its own statement
17
+ // by default: the helper would reach `Wait-Process` holding nothing and never exit, so drive
18
+ // could not say `keep-awake: lost`. With it, any error ends `-Command` with exit 1;
19
+ // `Wait-Process`'s own `-ErrorAction` keeps a pid already gone a quiet end.
20
+ export const AWAKE_SCRIPT = [
21
+ "$ErrorActionPreference = 'Stop'",
22
+ `$k = Add-Type -Name Awake -Namespace Witness -PassThru -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);'`,
23
+ 'if ($k::SetThreadExecutionState([uint32]2147483649) -eq 0) { exit 3 }',
24
+ 'Wait-Process -Id ([int]$env:WITNESS_AWAKE_PID) -ErrorAction SilentlyContinue',
25
+ ].join('\n');
26
+ // STATUS_CONTROL_C_EXIT: how a console process the terminal's Ctrl+C ended reports its exit.
27
+ export const CTRL_C_EXIT = 0xC000013A;
28
+ export function awakeArgv(env, platform, pid) {
3
29
  // Test seam, on WITNESS_DRIVE_AGENT_BIN's precedent: never documented.
4
- const bin = env.WITNESS_KEEP_AWAKE_BIN ?? (platform === 'darwin' ? 'caffeinate' : undefined);
5
- if (bin === undefined)
30
+ const seam = env.WITNESS_KEEP_AWAKE_BIN;
31
+ if (platform === 'win32') {
32
+ return {
33
+ file: seam ?? system32(env, 'WindowsPowerShell', 'v1.0', 'powershell.exe'),
34
+ args: ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', AWAKE_SCRIPT],
35
+ env: { WITNESS_AWAKE_PID: String(pid) },
36
+ shown: `SetThreadExecutionState via powershell.exe until pid ${pid} — an explicit sleep (Start › Sleep, a closed lid) still sleeps`,
37
+ };
38
+ }
39
+ const file = seam ?? (platform === 'darwin' ? 'caffeinate' : undefined);
40
+ if (file === undefined)
41
+ return undefined;
42
+ return { file, args: ['-ims', '-w', String(pid)], shown: `${file} -ims -w ${pid} — a closed lid on battery still sleeps` };
43
+ }
44
+ const nameOf = (file) => file.split(/[\\/]/).pop() ?? file;
45
+ // Why a helper that ended before drive let go of it no longer holds the host, or undefined when
46
+ // its end is no news: a signal (drive's own group stop, the terminal's Ctrl+C), a clean exit
47
+ // (caffeinate's `-w` pid ended), or win32's Ctrl+C status.
48
+ export function lostWhy(platform, file, code, signal) {
49
+ if (signal !== null || code === null || code === 0)
50
+ return undefined;
51
+ if (platform === 'win32' && code === CTRL_C_EXIT)
52
+ return undefined;
53
+ return `${nameOf(file)} exited ${code}`;
54
+ }
55
+ export function keepAwake(env, platform, pid, onLost = () => { }) {
56
+ const a = awakeArgv(env, platform, pid);
57
+ if (a === undefined)
6
58
  return { stop: () => { } };
7
- const args = ['-ims', '-w', String(pid)];
8
- const child = spawn(bin, args, { stdio: 'ignore' });
9
- child.on('error', () => { }); // a missing binary costs the guard, never the run
59
+ let done = false; // stopped, or already reported lost
60
+ const lost = (why) => {
61
+ if (done || why === undefined)
62
+ return;
63
+ done = true;
64
+ onLost(why);
65
+ };
66
+ const child = spawn(a.file, a.args, { stdio: 'ignore', ...(a.env ? { env: { ...env, ...a.env } } : {}) });
67
+ // A helper that cannot hold the host costs the guard, never the run — but it says so.
68
+ child.on('error', (e) => lost(`${nameOf(a.file)} failed to start (${e.code ?? e.message})`));
69
+ child.on('exit', (code, signal) => lost(lostWhy(platform, a.file, code, signal)));
10
70
  child.unref();
11
71
  return {
12
- command: [bin, ...args].join(' '),
13
- stop: () => { if (child.exitCode === null && child.signalCode === null)
14
- child.kill('SIGTERM'); },
72
+ shown: a.shown,
73
+ stop: () => {
74
+ done = true;
75
+ if (child.exitCode === null && child.signalCode === null)
76
+ child.kill('SIGTERM');
77
+ },
15
78
  };
16
79
  }
package/dist/battery.js CHANGED
@@ -2,37 +2,24 @@ import { SESSION_DEFAULT } from './model.js';
2
2
  import { ok, refuse } from './refusal.js';
3
3
  import { invokeReviewerAsync, parseVerdictText } from './reviewer.js';
4
4
  import { parseVerdict, verdictViolations } from './verdict.js';
5
- // Row 169. Every lens walks the fallback chain on its own, from the pin. One lens that fell
6
- // back makes the whole round a fallback round: `model` is the highest rung anyone answered
7
- // on, so `fellBack` holds exactly when the sequential battery would have held it (106/107).
8
- async function runLens(ctx, harness, chain, lens, opts) {
9
- let rung = 0;
5
+ // Row 169, amended by row 212: every lens is asked on the stage's one model, and a lens that
6
+ // cannot be invoked refuses at once — there is no stand-in to fall back to.
7
+ async function runLens(ctx, harness, model, lens, opts) {
10
8
  let prompt = lens.prompt;
11
9
  let rerolled = false;
12
- const failedOn = [];
13
10
  for (let attempt = 0;; attempt++) {
14
- let answered;
15
- for (;;) {
16
- const id = chain[rung];
17
- const r = await invokeReviewerAsync(ctx, harness, {
18
- ...opts, prompt, model: id === SESSION_DEFAULT ? undefined : id, lens: lens.name,
19
- });
20
- if (r.ok) {
21
- answered = r.value.text;
22
- break;
23
- }
24
- if (rung >= chain.length - 1)
25
- return refuse(r.violations);
26
- failedOn.push(rung);
27
- rung += 1;
28
- }
29
- const rawR = parseVerdictText(answered);
11
+ const r = await invokeReviewerAsync(ctx, harness, {
12
+ ...opts, prompt, model: model === SESSION_DEFAULT ? undefined : model, lens: lens.name,
13
+ });
14
+ if (!r.ok)
15
+ return refuse(r.violations);
16
+ const rawR = parseVerdictText(r.value.text);
30
17
  const parsedR = rawR.ok ? parseVerdict(rawR.value) : rawR;
31
18
  const violations = parsedR.ok ? verdictViolations(parsedR.value, lens.reviewed) : parsedR.violations;
32
19
  if (parsedR.ok && violations.length === 0) {
33
20
  return ok({
34
21
  verdict: { reviewer: lens.name, coverage: parsedR.value.coverage, findings: parsedR.value.findings },
35
- failedOn, rung, rerolled,
22
+ rerolled,
36
23
  });
37
24
  }
38
25
  if (attempt === 0) {
@@ -43,26 +30,24 @@ async function runLens(ctx, harness, chain, lens, opts) {
43
30
  prompt += `\n## Previous attempt rejected\n\n${violations.map((x) => `- ${x.field}: ${x.rule} — got ${x.got}; want ${x.want}`).join('\n')}\n\nRe-emit the complete corrected verdict JSON.\n`;
44
31
  continue;
45
32
  }
46
- return ok({ malformed: violations, failedOn, rung, rerolled });
33
+ return ok({ malformed: violations, rerolled });
47
34
  }
48
35
  }
49
36
  // Lenses launch together and are aggregated only once every one has settled, in battery
50
- // order — the order a lens finishes in must never reach the journal. A lens that exhausts the
51
- // chain refuses the whole gate, the first such lens in battery order speaking for it.
52
- export async function runBattery(ctx, harness, chain, lenses, opts) {
53
- const results = await Promise.all(lenses.map((l) => runLens(ctx, harness, chain, l, opts)));
37
+ // order — the order a lens finishes in must never reach the journal. A lens that cannot be
38
+ // invoked refuses the whole gate (row 212), the first such lens in battery order speaking
39
+ // for it.
40
+ export async function runBattery(ctx, harness, model, lenses, opts) {
41
+ const results = await Promise.all(lenses.map((l) => runLens(ctx, harness, model, l, opts)));
54
42
  const runs = [];
55
43
  for (const r of results) {
56
44
  if (!r.ok)
57
45
  return refuse(r.violations);
58
46
  runs.push(r.value);
59
47
  }
60
- const failed = new Set(runs.flatMap((r) => r.failedOn));
61
48
  return ok({
62
49
  verdicts: runs.flatMap((r) => (r.verdict ? [r.verdict] : [])),
63
50
  malformed: runs.flatMap((r, i) => (r.malformed ? [{ reviewer: lenses[i].name, violations: r.malformed }] : [])),
64
- fallback: [...new Set(chain.filter((_, i) => failed.has(i)))],
65
51
  rerolled: lenses.filter((_, i) => runs[i].rerolled).map((l) => l.name),
66
- model: chain[Math.max(0, ...runs.map((r) => r.rung))],
67
52
  });
68
53
  }
package/dist/cli.js CHANGED
@@ -56,7 +56,6 @@ const VERBS = {
56
56
  rename: () => import('./verbs/rename.js'),
57
57
  sync: () => import('./verbs/sync.js'),
58
58
  trust: () => import('./verbs/trust.js'),
59
- calibrate: () => import('./verbs/calibrate.js'),
60
59
  // Row 116's valve. Exempt from the floor gate in `main`, because a repository that
61
60
  // refuses every verb must still be able to run the one that unrefuses it.
62
61
  floor: () => import('./verbs/floor.js'),
@@ -67,7 +66,6 @@ const VERB_USAGE = {
67
66
  abandon: 'witness abandon <plan-id | effort-slug…>',
68
67
  adopt: 'witness adopt <specs/... | plans/...>.md',
69
68
  ask: 'witness ask <text> | --withdraw <id> [--note <why>]',
70
- calibrate: 'witness calibrate <exact-model-id> [--suite all|reviewers|skills] [--only <name>] [--samples <n>] [--publish]',
71
69
  check: 'witness check',
72
70
  clean: 'witness clean',
73
71
  draft: 'witness draft <ask-<id>|amend-<effort>|design-<spec-id>> [--file <json>]',
package/dist/delta.js CHANGED
@@ -129,12 +129,19 @@ export function planDelta(root, entries, gate, cur) {
129
129
  const sections = cur.reviewed.kind === 'docs'
130
130
  ? cur.reviewed.docs.flatMap((d) => headingLines(d.body).map((h) => `${d.id} > ${h}`)).filter((a) => view.state(a) === 'changed')
131
131
  : undefined;
132
+ // Row 208. What a delta lens's coverage floor counts. Canon is context at the code gates (the
133
+ // unit view says so too), so a canon edit is no file the change asks a lens to cover.
134
+ const canon = cur.reviewed.kind === 'tree' ? cur.reviewed.canonDirs ?? [] : [];
135
+ const paths = cur.reviewed.kind === 'tree'
136
+ ? changedPaths(root, base.reviewed_tree, cur.snapshot.tree).filter((p) => !canon.some((d) => p === d || p.startsWith(`${d}/`)))
137
+ : undefined;
132
138
  return {
133
139
  base, baseRound: base.round,
134
140
  prior: blocking.filter((f) => cur.inDelta(f.reviewer)),
135
141
  reported: reportedBy(blocking.map((f) => f.anchor), cur.reviewed.kind === 'tree'),
136
142
  view, diff,
137
143
  ...(sections ? { sections } : {}),
144
+ ...(paths?.length ? { paths } : {}),
138
145
  };
139
146
  }
140
147
  // The one block every delta-mode lens receives, between the open deferrals and the anchor
@@ -148,11 +155,19 @@ export function deltaBlock(d) {
148
155
  const sections = d.sections?.length
149
156
  ? `### Sections changed since round ${n}\n\n${d.sections.map((s) => `- ${s}`).join('\n')}\n\n`
150
157
  : '';
158
+ // Row 208. Without paths (the doc gates) the block is byte for byte row 185's.
159
+ const files = d.paths?.length
160
+ ? `### Files changed since round ${n}\n\n${d.paths.map((p) => `- ${p}`).join('\n')}\n\n` +
161
+ `Cover at least ${Math.min(5, d.paths.length)} of these files, each with its own coverage anchor.\n\n`
162
+ : '';
163
+ const contract = d.paths?.length
164
+ ? `the verdict contract applies to it unchanged — except the coverage floor, which counts only the files listed under "Files changed since round ${n}".`
165
+ : 'the verdict contract applies to it unchanged.';
151
166
  return `## Delta review — round ${n} to now\n\n` +
152
- `Round ${n} reviewed this content in full. This round judges what changed since then. The reviewed content below is still the complete current content, and the verdict contract applies to it unchanged.\n\n` +
167
+ `Round ${n} reviewed this content in full. This round judges what changed since then. The reviewed content below is still the complete current content, and ${contract}\n\n` +
153
168
  `### Blocking findings from round ${n}\n\n${prior}\n\n` +
154
169
  'For each finding above, decide whether it still holds against the current content. If it does, report it again, copying its anchor exactly as listed while that anchor still resolves. If the change fixed it, leave it out of your findings.\n\n' +
155
- sections +
170
+ sections + files +
156
171
  `### Change since round ${n}\n\n${d.diff}\n\n` +
157
172
  'Judge whether the changed parts are sound. Report every defect the change introduced or exposed. When the change caused a defect, anchor it at the changed code or section that caused it, even when its symptom shows elsewhere.\n\n';
158
173
  }
package/dist/drive.js CHANGED
@@ -23,6 +23,7 @@ import { effortOf } from './reviewed.js';
23
23
  import { pendingTxn } from './txn.js';
24
24
  import { duration, limitIn, realClock, sessionLimit, SINGLE_WAIT_MAX_MS, TOTAL_WAIT_MAX_MS, waitFor, } from './usage.js';
25
25
  import { keepAwake } from './awake.js';
26
+ import { monotonicTicker, sessionClock } from './session-clock.js';
26
27
  import { driveReport, runStart } from './drive-report.js';
27
28
  import { notify } from './notify.js';
28
29
  import { writeLive } from './live.js';
@@ -96,9 +97,8 @@ const EXIT_GRACE_MS = 2_000;
96
97
  // This CLI, for the child. A spawned session shells out to `witness` through
97
98
  // ${WITNESS_BIN:-npx …} in every stage skill, and an unset value means the child resolves
98
99
  // the PUBLISHED version while its parent runs an unpublished one — which the state floor
99
- // then refuses (cli-behind-state). calibrate.ts:520 sets it for its worker for exactly
100
- // this reason. An explicitly set value wins: a session that already knows its bin is
101
- // stating a fact drive has no better answer for.
100
+ // then refuses (cli-behind-state). An explicitly set value wins: a session that already
101
+ // knows its bin is stating a fact drive has no better answer for.
102
102
  function localBin(ctx) {
103
103
  return ctx.env.WITNESS_BIN ?? `node ${join(dirname(fileURLToPath(import.meta.url)), 'bin.js')}`;
104
104
  }
@@ -144,10 +144,9 @@ export function signalSession(child, grouped, env, sig) {
144
144
  // One headless session, in the action's home, streamed to the driver's terminal.
145
145
  //
146
146
  // The harness is the JUDGE ladder's answer (declared first, detection as fallback), not
147
- // the driver's: this is a programmatic spawn like the reviewer battery and the
148
- // calibration worker, not a statement about which CLI a human is typing at. Ambient
149
- // detection deciding what drive spawns would make the same repo drive differently from
150
- // two terminals.
147
+ // the driver's: this is a programmatic spawn like the reviewer battery, not a statement
148
+ // about which CLI a human is typing at. Ambient detection deciding what drive spawns would
149
+ // make the same repo drive differently from two terminals.
151
150
  export async function spawnSession(step, cfg, ctx, spawnN, opts = {}) {
152
151
  const t0 = Date.now();
153
152
  const end = (outcome, code = null, tail = []) => ({ outcome, code, tail, ms: Math.max(1, Date.now() - t0) });
@@ -179,6 +178,8 @@ export async function spawnSession(step, cfg, ctx, spawnN, opts = {}) {
179
178
  delete inherited[variable];
180
179
  const childEnv = {
181
180
  ...inherited, ...env, WITNESS_BIN: localBin(ctx), [DRIVE_ENV]: step.target ?? TARGETLESS,
181
+ // The earliest wall-clock time drive may stop this session — a sleep moves drive's stop
182
+ // later, never earlier (row 210).
182
183
  [DRIVE_DEADLINE_ENV]: String(t0 + cfg.drive.sessionTimeoutMs),
183
184
  };
184
185
  // Row 164: on Windows the agent CLI may be a `.cmd` shim, which only cmd.exe can start.
@@ -233,7 +234,7 @@ export async function spawnSession(step, cfg, ctx, spawnN, opts = {}) {
233
234
  settled = true;
234
235
  if (child.pid !== undefined)
235
236
  LIVE_GROUPS.delete(child.pid);
236
- clearTimeout(timer);
237
+ clock.stop();
237
238
  clearTimeout(killTimer);
238
239
  clearTimeout(grace);
239
240
  opts.signal?.removeEventListener('abort', onAbort);
@@ -241,9 +242,12 @@ export async function spawnSession(step, cfg, ctx, spawnN, opts = {}) {
241
242
  err.flush();
242
243
  child.stdout.destroy();
243
244
  child.stderr.destroy();
244
- resolve(end(o, code, [...tail]));
245
+ resolve({ outcome: o, code, tail: [...tail], ms: Math.max(1, clock.awakeMs()) });
245
246
  };
246
- const timer = setTimeout(() => stop('timeout'), cfg.drive.sessionTimeoutMs);
247
+ const clock = sessionClock(cfg.drive.sessionTimeoutMs, opts.ticker ?? monotonicTicker, {
248
+ expire: () => stop('timeout'),
249
+ slept: (ms) => ctx.out(`${prefix}host slept ${duration(ms)} — not counted against drive.sessionTimeoutMs`),
250
+ });
247
251
  opts.signal?.addEventListener('abort', onAbort, { once: true });
248
252
  child.stdout.setEncoding('utf8');
249
253
  child.stderr.setEncoding('utf8');
@@ -704,17 +708,23 @@ export async function driveLoop(root, cfg, ctx, flags, clock = realClock) {
704
708
  return true;
705
709
  };
706
710
  const start = runStart(root);
707
- let awake = keepAwake(ctx.env, process.platform, process.pid);
711
+ // Row 211. A helper that dies while drive still holds it says so; once a signal is stopping
712
+ // drive, the helper's end is that signal's, and no news.
713
+ const lostAwake = (why) => {
714
+ if (signalled === undefined)
715
+ ctx.out(`keep-awake: lost — ${why} · keep the host awake yourself`);
716
+ };
717
+ let awake = keepAwake(ctx.env, process.platform, process.pid, lostAwake);
708
718
  let awakeHeld = true;
709
- ctx.out(awake.command !== undefined
710
- ? `keep-awake: ${awake.command} — a closed lid on battery still sleeps`
719
+ ctx.out(awake.shown !== undefined
720
+ ? `keep-awake: ${awake.shown}`
711
721
  : `keep-awake: none on ${process.platform} — keep the host awake yourself`);
712
722
  // Row 182, amended by row 202: held while a session runs, released while drive waits on the
713
723
  // human — a paused drive lets the machine sleep — and taken again before the next spawn.
714
724
  const holdAwake = () => {
715
725
  if (awakeHeld)
716
726
  return;
717
- awake = keepAwake(ctx.env, process.platform, process.pid);
727
+ awake = keepAwake(ctx.env, process.platform, process.pid, lostAwake);
718
728
  awakeHeld = true;
719
729
  };
720
730
  const releaseAwake = () => {