@holmes-lab/holmes-kit 0.38.0 → 0.40.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 (308) hide show
  1. package/CHANGELOG.md +370 -6
  2. package/README.md +58 -40
  3. package/dist/.build-id +1 -1
  4. package/dist/holmes/admission/core/admission-policy.d.ts +37 -0
  5. package/dist/holmes/admission/core/admission-policy.js +147 -0
  6. package/dist/holmes/admission/core/bounded-reader.d.ts +56 -0
  7. package/dist/holmes/admission/core/bounded-reader.js +135 -0
  8. package/dist/holmes/admission/core/change-classifier.d.ts +34 -0
  9. package/dist/holmes/admission/core/change-classifier.js +278 -0
  10. package/dist/holmes/admission/core/config-loader.d.ts +30 -0
  11. package/dist/holmes/admission/core/config-loader.js +145 -0
  12. package/dist/holmes/admission/core/event-judgement.d.ts +37 -0
  13. package/dist/holmes/admission/core/event-judgement.js +251 -0
  14. package/dist/holmes/admission/core/path-rules.d.ts +35 -0
  15. package/dist/holmes/admission/core/path-rules.js +88 -0
  16. package/dist/holmes/admission/core/pin.d.ts +7 -0
  17. package/dist/holmes/admission/core/pin.js +29 -0
  18. package/dist/holmes/admission/core/ports.d.ts +48 -0
  19. package/dist/holmes/admission/core/ports.js +11 -0
  20. package/dist/holmes/admission/core/range-resolver.d.ts +32 -0
  21. package/dist/holmes/admission/core/range-resolver.js +51 -0
  22. package/dist/holmes/admission/core/self-containment.d.ts +1 -0
  23. package/dist/holmes/admission/core/self-containment.js +125 -0
  24. package/dist/holmes/admission/core/signature-source.d.ts +9 -0
  25. package/dist/holmes/admission/core/signature-source.js +4 -0
  26. package/dist/holmes/admission/core/transition-planner.d.ts +15 -0
  27. package/dist/holmes/admission/core/transition-planner.js +14 -0
  28. package/dist/holmes/admission/core/verdict.d.ts +38 -0
  29. package/dist/holmes/admission/core/verdict.js +17 -0
  30. package/dist/holmes/admission/core/wiring.d.ts +44 -0
  31. package/dist/holmes/admission/core/wiring.js +618 -0
  32. package/dist/holmes/admission/forge/git-object-port.d.ts +4 -0
  33. package/dist/holmes/admission/forge/git-object-port.js +132 -0
  34. package/dist/holmes/assoc/assoc-arm.d.ts +1 -1
  35. package/dist/holmes/assoc/assoc-arm.js +1 -1
  36. package/dist/holmes/cli/agents.d.ts +8 -0
  37. package/dist/holmes/cli/agents.js +9 -5
  38. package/dist/holmes/cli/approve-cli.d.ts +2 -0
  39. package/dist/holmes/cli/approve-cli.js +392 -0
  40. package/dist/holmes/cli/approve-ref.d.ts +13 -7
  41. package/dist/holmes/cli/approve-ref.js +30 -10
  42. package/dist/holmes/cli/approve-status.d.ts +26 -2
  43. package/dist/holmes/cli/approve-status.js +98 -18
  44. package/dist/holmes/cli/approve-watch.d.ts +5 -0
  45. package/dist/holmes/cli/approve-watch.js +10 -5
  46. package/dist/holmes/cli/approve.d.ts +50 -13
  47. package/dist/holmes/cli/approve.js +260 -67
  48. package/dist/holmes/cli/attest.js +2 -1
  49. package/dist/holmes/cli/autonomy.d.ts +4 -1
  50. package/dist/holmes/cli/autonomy.js +17 -10
  51. package/dist/holmes/cli/codex-oracle.d.ts +11 -0
  52. package/dist/holmes/cli/codex-oracle.js +5 -1
  53. package/dist/holmes/cli/codex-toml.d.ts +10 -0
  54. package/dist/holmes/cli/codex-toml.js +36 -2
  55. package/dist/holmes/cli/doctor-boundary.d.ts +76 -0
  56. package/dist/holmes/cli/doctor-boundary.js +308 -0
  57. package/dist/holmes/cli/doctor-locks.d.ts +15 -0
  58. package/dist/holmes/cli/doctor-locks.js +119 -0
  59. package/dist/holmes/cli/doctor.d.ts +2 -0
  60. package/dist/holmes/cli/doctor.js +45 -5
  61. package/dist/holmes/cli/flags.d.ts +23 -0
  62. package/dist/holmes/cli/flags.js +89 -0
  63. package/dist/holmes/cli/index.d.ts +5 -1
  64. package/dist/holmes/cli/index.js +206 -424
  65. package/dist/holmes/cli/init.js +33 -0
  66. package/dist/holmes/cli/lock-recover.d.ts +5 -0
  67. package/dist/holmes/cli/lock-recover.js +126 -0
  68. package/dist/holmes/cli/mcp-processes.d.ts +32 -0
  69. package/dist/holmes/cli/mcp-processes.js +132 -0
  70. package/dist/holmes/cli/release-docs.js +1 -1
  71. package/dist/holmes/cli/run-exec.d.ts +141 -0
  72. package/dist/holmes/cli/run-exec.js +1435 -0
  73. package/dist/holmes/cli/run-provision.d.ts +8 -0
  74. package/dist/holmes/cli/run-provision.js +325 -0
  75. package/dist/holmes/cli/run-wiring.d.ts +69 -0
  76. package/dist/holmes/cli/run-wiring.js +270 -0
  77. package/dist/holmes/cli/run.d.ts +26 -0
  78. package/dist/holmes/cli/run.js +364 -83
  79. package/dist/holmes/cli/runtime-binding-approval.js +32 -19
  80. package/dist/holmes/cli/screen-safe.d.ts +3 -92
  81. package/dist/holmes/cli/screen-safe.js +18 -756
  82. package/dist/holmes/config/config.d.ts +2 -0
  83. package/dist/holmes/config/config.js +5 -2
  84. package/dist/holmes/cpg/foundation/language-matrix.js +2 -2
  85. package/dist/holmes/cpg/import-resolver.js +1 -1
  86. package/dist/holmes/governance/approval-decisions.d.ts +47 -0
  87. package/dist/holmes/governance/approval-decisions.js +29 -0
  88. package/dist/holmes/governance/approval-grants.d.ts +220 -1
  89. package/dist/holmes/governance/approval-grants.js +612 -33
  90. package/dist/holmes/governance/approval-queue.d.ts +31 -0
  91. package/dist/holmes/governance/approval-queue.js +122 -11
  92. package/dist/holmes/governance/approval-spend.d.ts +95 -0
  93. package/dist/holmes/governance/approval-spend.js +191 -0
  94. package/dist/holmes/governance/autonomous-shell.d.ts +61 -0
  95. package/dist/holmes/governance/autonomous-shell.js +332 -0
  96. package/dist/holmes/governance/autonomy.d.ts +5 -0
  97. package/dist/holmes/governance/autonomy.js +16 -11
  98. package/dist/holmes/governance/constitution.d.ts +5 -0
  99. package/dist/holmes/governance/constitution.js +32 -12
  100. package/dist/holmes/governance/full-autonomy.d.ts +10 -0
  101. package/dist/holmes/governance/full-autonomy.js +103 -7
  102. package/dist/holmes/governance/harness-catalog.d.ts +103 -0
  103. package/dist/holmes/governance/harness-catalog.js +348 -0
  104. package/dist/holmes/governance/human-channel.d.ts +38 -0
  105. package/dist/holmes/governance/human-channel.js +49 -0
  106. package/dist/holmes/governance/install-manifest.d.ts +22 -0
  107. package/dist/holmes/governance/install-manifest.js +160 -0
  108. package/dist/holmes/governance/ledger-rechain.js +2 -0
  109. package/dist/holmes/governance/ledger-store.conformance.d.ts +7 -1
  110. package/dist/holmes/governance/ledger-store.conformance.js +66 -0
  111. package/dist/holmes/governance/ledger-store.d.ts +88 -11
  112. package/dist/holmes/governance/ledger-store.js +186 -8
  113. package/dist/holmes/governance/provenance-chain.d.ts +16 -4
  114. package/dist/holmes/governance/provenance-chain.js +19 -4
  115. package/dist/holmes/governance/provenance-ledger.d.ts +6 -3
  116. package/dist/holmes/governance/provenance-ledger.js +53 -18
  117. package/dist/holmes/governance/push-gate-runner.js +11 -7
  118. package/dist/holmes/governance/recorded-pairs.d.ts +96 -0
  119. package/dist/holmes/governance/recorded-pairs.js +522 -0
  120. package/dist/holmes/governance/replica-id.d.ts +1 -1
  121. package/dist/holmes/governance/replica-id.js +1 -1
  122. package/dist/holmes/governance/spec-seam.d.ts +59 -0
  123. package/dist/holmes/governance/spec-seam.js +587 -0
  124. package/dist/holmes/governance/spend-kinds.d.ts +16 -0
  125. package/dist/holmes/governance/spend-kinds.js +18 -0
  126. package/dist/holmes/governance/tool-actions.js +2 -0
  127. package/dist/holmes/guardrail/decision-ledger.d.ts +2 -1
  128. package/dist/holmes/guardrail/decision-ledger.js +2 -1
  129. package/dist/holmes/guardrail/impact-gate.d.ts +1 -0
  130. package/dist/holmes/guardrail/impact-gate.js +1 -1
  131. package/dist/holmes/guardrail/line-continuation.d.ts +8 -0
  132. package/dist/holmes/guardrail/line-continuation.js +39 -0
  133. package/dist/holmes/guardrail/operator-person.d.ts +28 -4
  134. package/dist/holmes/guardrail/operator-person.js +57 -11
  135. package/dist/holmes/guardrail/refusal-codes.d.ts +8 -3
  136. package/dist/holmes/guardrail/refusal-codes.js +70 -10
  137. package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
  138. package/dist/holmes/guardrail/risk-classifier.js +245 -15
  139. package/dist/holmes/guardrail/risk-gate.d.ts +2 -8
  140. package/dist/holmes/guardrail/risk-gate.js +7 -34
  141. package/dist/holmes/guardrail/risk-types.d.ts +10 -0
  142. package/dist/holmes/guardrail/run-plan-scope.js +3 -1
  143. package/dist/holmes/guardrail/run-refusals.d.ts +6 -1
  144. package/dist/holmes/guardrail/run-refusals.js +36 -14
  145. package/dist/holmes/guardrail/run-stages.d.ts +10 -0
  146. package/dist/holmes/guardrail/run-stages.js +46 -6
  147. package/dist/holmes/guardrail/scope-judgment.js +1 -1
  148. package/dist/holmes/guardrail/shell-words.js +24 -3
  149. package/dist/holmes/guardrail/unresolved-write.d.ts +40 -0
  150. package/dist/holmes/guardrail/unresolved-write.js +556 -0
  151. package/dist/holmes/guardrail/write-target.d.ts +3 -0
  152. package/dist/holmes/guardrail/write-target.js +26 -5
  153. package/dist/holmes/hooks/pre-tool-use.d.ts +105 -1
  154. package/dist/holmes/hooks/pre-tool-use.js +1167 -168
  155. package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -1
  156. package/dist/holmes/hooks/rtm-refresh-child.js +1 -1
  157. package/dist/holmes/hooks/session-start.d.ts +5 -0
  158. package/dist/holmes/hooks/session-start.js +29 -1
  159. package/dist/holmes/hooks/stop.d.ts +23 -0
  160. package/dist/holmes/hooks/stop.js +88 -33
  161. package/dist/holmes/mcp/approval-adapters.js +3 -1
  162. package/dist/holmes/mcp/approval-commit.js +3 -2
  163. package/dist/holmes/mcp/approval-policy.d.ts +2 -1
  164. package/dist/holmes/mcp/approval-policy.js +3 -1
  165. package/dist/holmes/mcp/handlers/adoption.d.ts +1 -1
  166. package/dist/holmes/mcp/handlers/approval-ask.d.ts +14 -0
  167. package/dist/holmes/mcp/handlers/approval-ask.js +31 -6
  168. package/dist/holmes/mcp/handlers/entity-integration.d.ts +3 -3
  169. package/dist/holmes/mcp/handlers/entity-integration.js +29 -11
  170. package/dist/holmes/mcp/handlers/entity-renumber.d.ts +4 -4
  171. package/dist/holmes/mcp/handlers/entity-renumber.js +29 -11
  172. package/dist/holmes/mcp/handlers/entity-store.d.ts +2 -2
  173. package/dist/holmes/mcp/handlers/entity-store.js +133 -59
  174. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +9 -5
  175. package/dist/holmes/mcp/handlers/operator-inspection.js +79 -16
  176. package/dist/holmes/mcp/handlers/phase-queries.d.ts +1 -1
  177. package/dist/holmes/mcp/handlers/requirement-triage.d.ts +4 -4
  178. package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -2
  179. package/dist/holmes/mcp/handlers/review-evidence.js +35 -11
  180. package/dist/holmes/mcp/handlers/review-queries.d.ts +5 -0
  181. package/dist/holmes/mcp/handlers/review-queries.js +8 -1
  182. package/dist/holmes/mcp/handlers/review-verdict.d.ts +3 -0
  183. package/dist/holmes/mcp/handlers/review-verdict.js +10 -3
  184. package/dist/holmes/mcp/handlers/risk-assessment.d.ts +7 -2
  185. package/dist/holmes/mcp/handlers/risk-assessment.js +34 -12
  186. package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +2 -2
  187. package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +6 -1
  188. package/dist/holmes/mcp/handlers/slice-orchestration.js +14 -1
  189. package/dist/holmes/mcp/handlers/spec-approval.d.ts +15 -3
  190. package/dist/holmes/mcp/handlers/spec-approval.js +32 -5
  191. package/dist/holmes/mcp/handlers/spec-authoring.d.ts +2 -2
  192. package/dist/holmes/mcp/handlers/spec-authoring.js +19 -2
  193. package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +11 -38
  194. package/dist/holmes/mcp/handlers/spec-lifecycle.js +441 -94
  195. package/dist/holmes/mcp/handlers/spec-queries.d.ts +2 -2
  196. package/dist/holmes/mcp/handlers/taint-screening.d.ts +1 -1
  197. package/dist/holmes/mcp/handlers/taint-screening.js +2 -2
  198. package/dist/holmes/mcp/handlers/test-execution.d.ts +1 -1
  199. package/dist/holmes/mcp/handlers/workspace-preflight.d.ts +5 -0
  200. package/dist/holmes/mcp/handlers/workspace-preflight.js +10 -2
  201. package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
  202. package/dist/holmes/mcp/handlers.d.ts +99 -79
  203. package/dist/holmes/mcp/handlers.js +93 -25
  204. package/dist/holmes/mcp/harness-attestation.d.ts +78 -5
  205. package/dist/holmes/mcp/harness-attestation.js +325 -53
  206. package/dist/holmes/mcp/maintenance-analyze.d.ts +1 -1
  207. package/dist/holmes/mcp/maintenance-analyze.js +9 -9
  208. package/dist/holmes/mcp/maintenance-evidence.js +31 -2
  209. package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
  210. package/dist/holmes/mcp/server-staleness.d.ts +43 -0
  211. package/dist/holmes/mcp/server-staleness.js +158 -0
  212. package/dist/holmes/mcp/server.js +34 -9
  213. package/dist/holmes/mcp/spec-id-guard.js +1 -1
  214. package/dist/holmes/mcp/tool-schemas.d.ts +13 -0
  215. package/dist/holmes/mcp/tool-schemas.js +42 -2
  216. package/dist/holmes/project/act-root.d.ts +19 -0
  217. package/dist/holmes/project/act-root.js +100 -0
  218. package/dist/holmes/project/baseline.js +4 -3
  219. package/dist/holmes/project/bounded-group.d.ts +47 -0
  220. package/dist/holmes/project/bounded-group.js +140 -0
  221. package/dist/holmes/project/bounded-io.d.ts +50 -2
  222. package/dist/holmes/project/bounded-io.js +138 -6
  223. package/dist/holmes/project/change-source.js +2 -2
  224. package/dist/holmes/project/instance-id.d.ts +10 -0
  225. package/dist/holmes/project/instance-id.js +233 -0
  226. package/dist/holmes/project/machine-identity.d.ts +25 -0
  227. package/dist/holmes/project/machine-identity.js +133 -0
  228. package/dist/holmes/project/owned-lock.d.ts +84 -0
  229. package/dist/holmes/project/owned-lock.js +263 -0
  230. package/dist/holmes/project/plain-lock-fs.d.ts +2 -0
  231. package/dist/holmes/project/plain-lock-fs.js +126 -0
  232. package/dist/holmes/project/request-lock.d.ts +85 -0
  233. package/dist/holmes/project/request-lock.js +459 -0
  234. package/dist/holmes/project/root.d.ts +12 -4
  235. package/dist/holmes/project/root.js +26 -7
  236. package/dist/holmes/project/run-records.d.ts +19 -0
  237. package/dist/holmes/project/run-records.js +94 -12
  238. package/dist/holmes/project/screen-text.d.ts +94 -0
  239. package/dist/holmes/project/screen-text.js +763 -0
  240. package/dist/holmes/project/spend-lock.d.ts +82 -0
  241. package/dist/holmes/project/spend-lock.js +413 -0
  242. package/dist/holmes/project/workspace-preflight.d.ts +5 -0
  243. package/dist/holmes/project/workspace-preflight.js +24 -1
  244. package/dist/holmes/refresh/freshness-coordinator.d.ts +1 -1
  245. package/dist/holmes/refresh/freshness-coordinator.js +1 -1
  246. package/dist/holmes/review/condition-hunk-replay.js +4 -2
  247. package/dist/holmes/review/confidence-calibration.d.ts +1 -1
  248. package/dist/holmes/review/confidence-calibration.js +1 -1
  249. package/dist/holmes/review/content-verify.js +1 -1
  250. package/dist/holmes/review/hop-ablation.d.ts +4 -4
  251. package/dist/holmes/review/hop-ablation.js +5 -5
  252. package/dist/holmes/review/point-in-time-replay.js +12 -3
  253. package/dist/holmes/review/rank-diagnosis.d.ts +2 -2
  254. package/dist/holmes/review/rank-diagnosis.js +1 -1
  255. package/dist/holmes/review/replay-corpus.d.ts +10 -4
  256. package/dist/holmes/review/replay-corpus.js +25 -9
  257. package/dist/holmes/review/requirement-triage.js +2 -2
  258. package/dist/holmes/review/semantic-arm.d.ts +3 -3
  259. package/dist/holmes/review/semantic-arm.js +3 -3
  260. package/dist/holmes/review/test-outcomes.js +3 -1
  261. package/dist/holmes/review/test-runner.d.ts +11 -0
  262. package/dist/holmes/review/test-runner.js +31 -10
  263. package/dist/holmes/review/test-selection-breadth.js +2 -2
  264. package/dist/holmes/review/verdicts.d.ts +109 -7
  265. package/dist/holmes/review/verdicts.js +653 -34
  266. package/dist/holmes/rtm/anchor-census.d.ts +9 -0
  267. package/dist/holmes/rtm/anchor-census.js +151 -0
  268. package/dist/holmes/rtm/anchor-ids.d.ts +25 -1
  269. package/dist/holmes/rtm/anchor-ids.js +45 -2
  270. package/dist/holmes/rtm/comment-ranges.d.ts +2 -0
  271. package/dist/holmes/rtm/comment-ranges.js +104 -0
  272. package/dist/holmes/rtm/counted-tests.d.ts +1 -0
  273. package/dist/holmes/rtm/counted-tests.js +63 -0
  274. package/dist/holmes/rtm/impact-advisory.d.ts +1 -1
  275. package/dist/holmes/rtm/known-defects.js +1 -1
  276. package/dist/holmes/rtm/localize.js +1 -1
  277. package/dist/holmes/rtm/taint-benchmark.d.ts +1 -1
  278. package/dist/holmes/rtm/taint-vocabulary.d.ts +1 -1
  279. package/dist/holmes/rtm/test-scope.d.ts +31 -0
  280. package/dist/holmes/rtm/test-scope.js +166 -5
  281. package/dist/holmes/rtm/trace-gaps.js +1 -1
  282. package/dist/holmes/runtime/dispatch.d.ts +10 -0
  283. package/dist/holmes/runtime/dispatch.js +12 -1
  284. package/dist/holmes/semantic/cloud-usage.d.ts +1 -1
  285. package/dist/holmes/semantic/cloud-usage.js +1 -1
  286. package/dist/holmes/semantic/unreadable-paths.d.ts +1 -1
  287. package/dist/holmes/semantic/unreadable-paths.js +1 -1
  288. package/dist/holmes/spec/approval-blockers.js +1 -1
  289. package/dist/holmes/spec/entity-store.d.ts +6 -1
  290. package/dist/holmes/spec/entity-store.js +16 -2
  291. package/dist/holmes/spec/entity-transaction.d.ts +7 -2
  292. package/dist/holmes/spec/entity-transaction.js +87 -170
  293. package/dist/holmes/spec/spec-store.d.ts +12 -6
  294. package/dist/holmes/spec/spec-store.js +4 -2
  295. package/dist/holmes/spec/spec-types.js +1 -1
  296. package/dist/holmes/spec/succession-guard.d.ts +56 -0
  297. package/dist/holmes/spec/succession-guard.js +187 -0
  298. package/dist/holmes/spec/succession.d.ts +70 -0
  299. package/dist/holmes/spec/succession.js +171 -0
  300. package/dist/holmes/spec/transition-policy.d.ts +2 -2
  301. package/docs/install-guide.md +9 -3
  302. package/docs/language-support.md +78 -0
  303. package/package.json +4 -3
  304. package/playbooks/author-slice/PLAYBOOK.md +1 -1
  305. package/playbooks/promote-slice/PLAYBOOK.md +5 -1
  306. package/playbooks/publish/PLAYBOOK.md +45 -33
  307. package/dist/holmes/review/manual-baseline.d.ts +0 -209
  308. package/dist/holmes/review/manual-baseline.js +0 -2847
@@ -34,22 +34,28 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DEFAULT_TTL_MINUTES = void 0;
37
+ exports.grantValidityText = grantValidityText;
37
38
  exports.grantRequest = grantRequest;
39
+ exports.revokeCandidates = revokeCandidates;
38
40
  exports.revokeGrant = revokeGrant;
41
+ exports.revokeWord = revokeWord;
39
42
  exports.denyRequest = denyRequest;
40
43
  exports.withdrawRequest = withdrawRequest;
41
44
  exports.holdRequest = holdRequest;
42
45
  exports.staleView = staleView;
46
+ exports.targetArg = targetArg;
43
47
  exports.outsideInboxFooter = outsideInboxFooter;
48
+ exports.listedRequests = listedRequests;
44
49
  exports.renderPending = renderPending;
45
50
  exports.subjectCells = subjectCells;
46
51
  exports.subjectRoom = subjectRoom;
47
52
  exports.decisionSubject = decisionSubject;
48
53
  exports.decisionDetail = decisionDetail;
54
+ exports.subjectDigest = subjectDigest;
49
55
  exports.renderRefusals = renderRefusals;
50
56
  exports.renderNonTtyHint = renderNonTtyHint;
51
57
  exports.runInteractive = runInteractive;
52
- // @implements A-SPEC-246, A-SPEC-626, A-SPEC-532.5, A-SPEC-770.3, A-SPEC-770.6, A-SPEC-770.12, A-SPEC-779.2, A-SPEC-792.2
58
+ // @implements A-SPEC-794.55, A-SPEC-246, A-SPEC-794.30, A-SPEC-794.31, A-SPEC-794.32, A-SPEC-794.33, A-SPEC-794.34, A-SPEC-794.35, A-SPEC-794.37, A-SPEC-794.41,A-SPEC-626,A-SPEC-532.5, A-SPEC-770.3, A-SPEC-770.6, A-SPEC-770.12, A-SPEC-779.2, A-SPEC-792.2, A-SPEC-245.9, A-SPEC-245.15, A-SPEC-245.17
53
59
  // @implements A-SPEC-549.4 — renderPending and renderNonTtyHint in this file are the English CLI
54
60
  // surface the Hangul-absence guard reads.
55
61
  const execution_context_1 = require("../project/execution-context");
@@ -61,6 +67,7 @@ const approval_queue_1 = require("../governance/approval-queue");
61
67
  const screen_safe_1 = require("./screen-safe");
62
68
  const approval_grants_1 = require("../governance/approval-grants");
63
69
  const workspace_identity_1 = require("../project/workspace-identity");
70
+ const human_channel_1 = require("../governance/human-channel");
64
71
  /**
65
72
  * `holmes-kit approve` — the surface where a human decides.
66
73
  *
@@ -140,7 +147,9 @@ const appendEvent = (root, event) => {
140
147
  fs.mkdirSync(path.dirname(file), { recursive: true });
141
148
  if (!isWritablePath(file))
142
149
  return false;
143
- fs.appendFileSync(file, JSON.stringify({ ...event, ts: new Date().toISOString(), ...(execution ? { execution } : {}) }) + '\n');
150
+ // @implements A-SPEC-792.26 — the queue's decision seam: its actor is judged where it is written
151
+ const judged = 'actor' in event ? { ...event, actor: (0, human_channel_1.ledgerActor)(event.actor) } : event;
152
+ fs.appendFileSync(file, JSON.stringify({ ...judged, ts: new Date().toISOString(), ...(execution ? { execution } : {}) }) + '\n');
144
153
  return true;
145
154
  }
146
155
  catch {
@@ -178,13 +187,22 @@ function recordIsSelfConsistent(entry) {
178
187
  */
179
188
  function freshNonce(root, id) {
180
189
  const { FileLedgerStore } = require('../governance/ledger-store');
181
- const ledger = new FileLedgerStore(path.join(root, '.ax', 'ledger'));
182
- if (!ledger.isNonceConsumed(id))
183
- return id;
184
- for (let n = 1; n <= 1000; n++)
185
- if (!ledger.isNonceConsumed(`${id}.r${n}`))
186
- return `${id}.r${n}`;
187
- return null;
190
+ // @implements A-SPEC-245.9 (H-2) — a revoked nonce is skipped as a spent one is: it never covers anything again
191
+ // @implements A-SPEC-794.5 — the walk is the one runtime-binding's "ever spent" uses (nonceWalk)
192
+ const { nonceWalk } = require('../governance/approval-spend');
193
+ return nonceWalk(new FileLedgerStore(path.join(root, '.ax', 'ledger')), id).fresh;
194
+ }
195
+ /**
196
+ * @implements A-SPEC-792.17 — what a decision line says about a grant's life: a grant without a time limit is spent by
197
+ * its first use (A-SPEC-532.5, 792.2), so it never shows the GRANT_NO_EXPIRY date as a validity period.
198
+ */
199
+ function grantValidityText(expires) {
200
+ // @implements A-SPEC-245.9 (1b-6, item 8) — the use count and the expiry, as one phrase, for every grant
201
+ // @implements A-SPEC-245.17 (6c) — an empty expiry is no expiry a grant can carry: expired, it covers nothing
202
+ // @implements A-SPEC-245.18 (5c) — so is one that is not a date
203
+ if (expires === '' || (expires !== undefined && !Number.isFinite(Date.parse(expires))))
204
+ return 'expired — the grant carries no expiry it can be judged by, so it covers nothing';
205
+ return expires === approval_grants_1.GRANT_NO_EXPIRY || expires === undefined ? 'single use, no time limit — spent by its first use' : `single use, until ${expires}`;
188
206
  }
189
207
  function grantRequest(root, id, opts) {
190
208
  const ttl = opts.ttlMinutes ?? exports.DEFAULT_TTL_MINUTES;
@@ -230,9 +248,13 @@ function grantRequest(root, id, opts) {
230
248
  ...(entry.subject ? { subject: entry.subject } : {}),
231
249
  ...(entry.execution?.runId ? { requestedBy: entry.execution.runId } : {}),
232
250
  };
251
+ // @implements A-SPEC-792.27 — a person's grant keeps its provenance by structure: spending it records grant:<id>
252
+ // (which claims no person channel) and the grant names who decided; a plain string actor is written as judged text
253
+ const person = (0, human_channel_1.isMinted)(opts.actor);
233
254
  const grant = {
234
255
  ...binding,
235
- actor: opts.actor,
256
+ actor: person ? `grant:${id}` : (0, human_channel_1.ledgerActor)(opts.actor),
257
+ ...(person ? { decidedBy: (0, human_channel_1.ledgerActor)(opts.actor) } : {}),
236
258
  token: 'grant',
237
259
  rationale: opts.rationale?.trim() ? opts.rationale : DEFAULT_RATIONALE,
238
260
  // exact (round-14): the queue target is a LITERAL command the operator read on the decision
@@ -277,7 +299,9 @@ function grantRequest(root, id, opts) {
277
299
  fs.renameSync(tmp, path.join(dir, `${id}.json`));
278
300
  }
279
301
  catch (e) {
280
- return { ok: false, reason: `could not move the grant file into place — the approval record is already in the queue, so run this again\n ${(0, screen_safe_1.rowField)(e instanceof Error ? e.message : String(e), 76)}` };
302
+ // A-SPEC-794.32 — "run this again" failed: the record closed the request, so nothing was left to grant (P13). The
303
+ // grant cannot be used; the agent's next attempt is refused and files the request again, and that one is granted.
304
+ return { ok: false, reason: `could not move the grant file into place — the approval is recorded but cannot be used; the agent's next attempt files the request again, and that one can be granted\n ${(0, screen_safe_1.rowField)(e instanceof Error ? e.message : String(e), 76)}` };
281
305
  }
282
306
  return { ok: true, expires };
283
307
  }
@@ -289,37 +313,154 @@ function grantRequest(root, id, opts) {
289
313
  * granted here (nothing to withdraw). A grant already spent has no file; revoking it records the
290
314
  * intent for the audit trail but cannot un-seal — the ledger is the record of what happened.
291
315
  */
316
+ const REQUEST_ID = /^req-[0-9a-f]{12}$/;
317
+ /**
318
+ * @implements A-SPEC-794.33 — what `--revoke` resolves against: the granted decisions and the ids the grant directory names,
319
+ * its claimed copies included (a grant whose row is torn, or whose file an act holds, still covers its act: A-1, A-2).
320
+ * A queue row's id counts only as a request id (a forged row's id is never a candidate: A-4). A-SPEC-794.35 — every grant
321
+ * file the store reads counts by its own name (`grantFileNames`), so a grant that covers its act is always revocable (A-M1).
322
+ */
323
+ function revokeCandidates(root) {
324
+ const granted = Object.entries((0, approval_queue_1.readQueue)(root, { includeAllKinds: true }).decisions).filter(([, d]) => d.event === 'granted').map(([id]) => id)
325
+ .filter((id) => REQUEST_ID.test(id));
326
+ let files = [];
327
+ try {
328
+ files = fs.readdirSync(path.join(root, approval_grants_1.GRANTS_RELDIR)).map(approval_grants_1.grantFileIdOf).filter((n) => n !== null);
329
+ }
330
+ catch {
331
+ files = [];
332
+ }
333
+ return [...new Set([...granted, ...files])];
334
+ }
335
+ /** The grant files (claimed copies included) that are request `id`'s own: named for it, or naming it as request or nonce. */
336
+ function ownGrantFiles(root, id) {
337
+ const dir = path.join(root, approval_grants_1.GRANTS_RELDIR);
338
+ let names = [];
339
+ try {
340
+ names = fs.readdirSync(dir);
341
+ }
342
+ catch {
343
+ return [];
344
+ }
345
+ return names.filter((n) => {
346
+ if ((0, approval_grants_1.grantFileIdOf)(n) === id)
347
+ return true;
348
+ if (!n.endsWith('.json'))
349
+ return false;
350
+ try {
351
+ const g = JSON.parse(fs.readFileSync(path.join(dir, n), 'utf8'));
352
+ return (0, approval_grants_1.namesRequest)(g.request, id) || (0, approval_grants_1.namesRequest)(g.nonce, id);
353
+ }
354
+ catch {
355
+ return false;
356
+ }
357
+ }).map((n) => path.join(dir, n));
358
+ }
292
359
  function revokeGrant(root, id, reason, actor) {
293
360
  if (typeof reason !== 'string' || reason.trim() === '')
294
361
  return { ok: false, reason: 'a revocation needs a --reason the agent can read' };
362
+ // @implements A-SPEC-794.33, A-SPEC-794.35 — only a candidate is revoked: a grant file's own name or a granted request
363
+ // id, never a forged row's id (`../x`, escapes) — membership, so every name the store reads is reachable and no other
364
+ if (!revokeCandidates(root).includes(id))
365
+ return { ok: false, reason: `no grant to revoke for ${(0, screen_safe_1.rowField)(id, 40)} — nothing was granted here` };
295
366
  const decided = (0, approval_queue_1.readQueue)(root, { includeAllKinds: true }).decisions[id];
296
367
  const dir = path.join(root, approval_grants_1.GRANTS_RELDIR);
297
- let hadFile = false;
368
+ // @implements A-SPEC-794.33 — a grant file that is a symbolic link is read as a grant, so it is revoked (as a link) too (A-3)
369
+ // @implements A-SPEC-245.4 (M3) — a grant an act holds claimed is revoked too: its claimed copy goes, so the act's
370
+ // release finds nothing to return and the revoked grant never comes back
371
+ const own = ownGrantFiles(root, id);
372
+ // @implements A-SPEC-245.9 (H-2) — under the spend lock: already spent (on the ledger, or a `consumed` queue event an
373
+ // older writer left), else the nonce-revoked row first, then the grant file and its claimed copies, then the queue event
374
+ // @implements A-SPEC-794.33 — a queue `consumed` row speaks only when no grant file is left: a development build's
375
+ // `consumed` beside a live file blocked revoking a grant that still covers its act (A-M1); the spend ledger decides
376
+ if (decided?.consumedTs && own.length === 0)
377
+ return { ok: false, reason: `the grant for ${(0, screen_safe_1.rowField)(id, 40)} is already spent — its act ran; nothing was revoked` };
378
+ const nonceOf = (file) => {
379
+ try {
380
+ const n = JSON.parse(fs.readFileSync(file, 'utf8')).nonce;
381
+ return typeof n === 'string' && n !== '' ? n : null;
382
+ }
383
+ catch {
384
+ return null;
385
+ }
386
+ };
387
+ // @implements A-SPEC-794.37 — every nonce its own files hold: a spent one does not stop the revocation of the next (A-M1)
388
+ const nonces = [...new Set(own.map(nonceOf).filter((n) => n !== null))];
389
+ if (nonces.length === 0)
390
+ nonces.push(id);
391
+ const spent = new Set();
298
392
  try {
299
- hadFile = fs.readdirSync(dir).some((n) => n === `${id}.json` && fs.lstatSync(path.join(dir, n)).isFile());
393
+ const { revokeNonce } = require('../governance/approval-spend');
394
+ for (const n of nonces)
395
+ if (revokeNonce(root, n, { actor, reason }) === 'spent')
396
+ spent.add(n);
300
397
  }
301
- catch {
302
- hadFile = false;
398
+ catch (e) {
399
+ return { ok: false, reason: `the revocation could not take the spend lock in time — retry\n ${(0, screen_safe_1.rowField)(e instanceof Error ? e.message : String(e), 76)}` };
303
400
  }
304
- if (!hadFile && decided?.event !== 'granted')
305
- return { ok: false, reason: `no grant to revoke for ${(0, screen_safe_1.rowField)(id, 40)} — nothing was granted here` };
306
- if (hadFile) {
401
+ if (spent.size === nonces.length)
402
+ return { ok: false, reason: `the grant for ${(0, screen_safe_1.rowField)(id, 40)} is already spent — its act ran; nothing was revoked` };
403
+ const goes = own.filter((f) => { const n = nonceOf(f); return n === null || !spent.has(n); });
404
+ for (const file of goes) {
307
405
  try {
308
- fs.rmSync(path.join(dir, `${id}.json`), { force: true });
406
+ fs.rmSync(file, { force: true });
309
407
  }
310
408
  catch (e) {
311
409
  return { ok: false, reason: `could not remove the grant file:\n ${(0, screen_safe_1.rowField)(e instanceof Error ? e.message : String(e), 76)}` };
312
410
  }
313
411
  }
412
+ const removed = goes.length > 0;
314
413
  if (!appendEvent(root, { event: 'revoked', id, reason, actor })) {
315
- return { ok: false, reason: hadFile
414
+ return { ok: false, reason: removed
316
415
  ? 'the grant file is gone but the revocation could not be recorded (queue event) — check write permission on .ax/approvals'
317
416
  : 'could not write the revocation record (queue event) — check write permission on .ax/approvals. Nothing was recorded' };
318
417
  }
319
- return { ok: true };
418
+ // @implements A-SPEC-794.37 — asked again after the removal: while a grant still covers the act this is no withdrawal
419
+ const after = (0, approval_grants_1.requestGrantState)(root, id, subjectOf(root, id), new Date().toISOString());
420
+ if (after.state === 'covers') {
421
+ return { ok: false, reason: `grant ${(0, screen_safe_1.rowField)(after.grant, 40)} still covers this act — revoke it too: ${revokeWordOf(after.grant)} --reason <text>${removed ? `\n removed: ${goes.map((f) => (0, screen_safe_1.rowField)(path.basename(f), 40)).join(', ')}` : ''}` };
422
+ }
423
+ // @implements A-SPEC-794.35, A-SPEC-794.37 — what else this reached is named, so a person's own copy does not die unannounced
424
+ const alsoRemoved = goes.map((f) => path.basename(f)).filter((n) => n !== `${id}.json`);
425
+ const stillHeld = (0, approval_grants_1.grantFileNames)(root).filter((n) => { const h = nonceOf(path.join(dir, n)); return h !== null && nonces.includes(h) && !spent.has(h); });
426
+ const notes = [...(alsoRemoved.length > 0 ? [`also removed: ${alsoRemoved.map((n) => (0, screen_safe_1.rowField)(n, 40)).join(', ')}`] : []),
427
+ ...(stillHeld.length > 0 ? [`left holding the revoked nonce, so covering nothing: ${stillHeld.map((n) => (0, screen_safe_1.rowField)(n, 40)).join(', ')}`] : [])];
428
+ return notes.length > 0 ? { ok: true, note: notes.join('; ') } : { ok: true };
320
429
  }
430
+ const subjectOf = (root, id) => (0, approval_queue_1.readQueue)(root, { includeAllKinds: true }).subjects?.[id];
431
+ const revokeWordOf = (file) => revokeWord(file.replace(/\.json$/, ''));
432
+ /**
433
+ * @implements A-SPEC-794.37 — the `--revoke=` word for a grant file's name, safe to paste into a POSIX shell: plain as it
434
+ * is, single-quoted otherwise, and with a control character through `printf` so that none reaches the screen raw.
435
+ */
436
+ function revokeWord(name) {
437
+ // the flag parser refuses a value of blanks, so a blank name goes by its file name
438
+ if (name.trim() === '')
439
+ return `--revoke='${name}.json'`;
440
+ if (/^[A-Za-z0-9_][A-Za-z0-9_.-]*$/.test(name))
441
+ return `--revoke=${name}`;
442
+ // eslint-disable-next-line no-control-regex
443
+ if (/[\x00-\x1f\x7f]/.test(name)) {
444
+ const octal = [...Buffer.from(name)].map((b) => `\\0${b.toString(8).padStart(3, '0')}`).join('');
445
+ return `--revoke="$(printf '%b' '${octal}')"`;
446
+ }
447
+ return `--revoke='${name.replace(/'/g, `'\\''`)}'`;
448
+ }
449
+ /**
450
+ * @implements A-SPEC-794.33 — a request a person may close: a pending or refusal-log one, or one a development build filed
451
+ * (L3). A development record is rebuilt from its latest row and must still derive its own id; a grant never takes this
452
+ * path (0.40.0 grants no development request), so its closing row is a denial or a withdrawal, never a grant.
453
+ */
454
+ const closable = (root, id) => {
455
+ const { entry, state } = findPending(root, id);
456
+ if (entry)
457
+ return entry;
458
+ const dev = state.devFiled?.[id];
459
+ return dev ? { id, kind: dev.kind, target: dev.target, why: '', count: 1, firstTs: '', lastTs: '',
460
+ ...(dev.requesterRun ? { requesterRun: dev.requesterRun } : {}), ...(dev.requesterServer ? { requesterServer: dev.requesterServer } : {}) } : undefined;
461
+ };
321
462
  function denyRequest(root, id, reason, actor) {
322
- const { entry } = findPending(root, id);
463
+ const entry = closable(root, id);
323
464
  if (!entry)
324
465
  return { ok: false, reason: `no pending request ${(0, screen_safe_1.rowField)(id, 40)}` };
325
466
  // @implements A-SPEC-262.1 — round-4: the derivation gate guarded grant only, so a tampered record
@@ -343,15 +484,26 @@ function denyRequest(root, id, reason, actor) {
343
484
  function withdrawRequest(root, id, reason, ctx) {
344
485
  if (reason.trim() === '')
345
486
  return { ok: false, reason: 'a withdrawal needs --reason — it is what the operator reads in place of a decision' };
346
- const { entry } = findPending(root, id);
487
+ const entry = closable(root, id);
347
488
  if (!entry)
348
489
  return { ok: false, reason: `no pending request ${(0, screen_safe_1.rowField)(id, 40)}` };
349
490
  if (!recordIsSelfConsistent(entry))
350
491
  return { ok: false, reason: TAMPERED };
492
+ // @implements A-SPEC-779.7 — the MCP server instance that filed a request withdraws it: an interactive session's
493
+ // request otherwise had no requester, and the operator approved nine abandoned ones (2026-10-23).
494
+ if (entry.requesterServer !== undefined) {
495
+ if (ctx.server !== entry.requesterServer) {
496
+ return { ok: false, reason: `only the session whose MCP server filed ${(0, screen_safe_1.rowField)(id, 40)} withdraws it: filed by server ${(0, screen_safe_1.rowField)(entry.requesterServer, 60)}; this is ${ctx.server ? `server ${(0, screen_safe_1.rowField)(ctx.server, 60)}` : 'not that server'} — if that session is gone, the operator denies it` }; // A-SPEC-794.41 (D8)
497
+ }
498
+ if (!appendEvent(root, { event: 'withdrawn', id, reason: reason.trim(), server: ctx.server, covered: entry.count })) {
499
+ return { ok: false, reason: 'could not write the withdrawal record (queue event) — check write permission on .ax/approvals. Nothing was recorded' };
500
+ }
501
+ return { ok: true };
502
+ }
351
503
  const { runMode } = require('../governance/run-mode');
352
504
  const here = runMode(ctx.env, root, ctx.cwd).id;
353
505
  if (entry.requesterRun === undefined) {
354
- return { ok: false, reason: `${(0, screen_safe_1.rowField)(id, 40)} was filed outside a run, so no requester can withdraw it — the operator denies it` };
506
+ return { ok: false, reason: `${(0, screen_safe_1.rowField)(id, 40)} was filed outside a run and outside an MCP server, so no requester can withdraw it — the operator denies it` };
355
507
  }
356
508
  if (here !== entry.requesterRun) {
357
509
  return { ok: false, reason: `only the run that filed ${(0, screen_safe_1.rowField)(id, 40)} withdraws it: filed by run ${(0, screen_safe_1.rowField)(entry.requesterRun, 60)}; this is ${here ? `run ${(0, screen_safe_1.rowField)(here, 60)}` : 'not a run'}` };
@@ -390,11 +542,34 @@ function holdRequest(root, id, question, actor) {
390
542
  */
391
543
  function staleView(flags) {
392
544
  const raw = flags['stale-hours'];
545
+ // @implements A-SPEC-794.33 — a value that is not a finite number ≥ 0 is refused: `abc`, `-1` and `Infinity` turned the
546
+ // fold off without a word, and the screens then disagreed about what was listed (A-H2)
547
+ if (raw !== undefined && (typeof raw !== 'string' || !/^\s*\d+(?:\.\d+)?\s*$/.test(raw))) {
548
+ return { refusal: `--stale-hours expects a number of hours ≥ 0 (0 turns the fold off) — received: ${(0, screen_safe_1.rowField)(String(raw), 20)}` };
549
+ }
393
550
  const hours = typeof raw === 'string' ? Number(raw) : 24;
394
- if (!Number.isFinite(hours) || hours <= 0)
551
+ // A-SPEC-794.34 — a value of 400 digits is Infinity as a number, which turned the fold off as `abc` once did (A-1)
552
+ if (!Number.isFinite(hours))
553
+ return { refusal: `--stale-hours expects a finite number of hours — received: ${(0, screen_safe_1.rowField)(String(raw), 20)}` };
554
+ if (hours === 0)
395
555
  return null;
396
556
  return { ttlMs: hours * 3_600_000, showAll: flags.all === true };
397
557
  }
558
+ /**
559
+ * @implements A-SPEC-794.33 — the one spelling of `--target <root>` on a line made to be pasted (A-M5). Measured: a root
560
+ * named `/tmp/a;touch PWN1` ran `touch` in /bin/sh, because only white space was quoted. A root of plain path characters
561
+ * is printed bare; any other is POSIX single-quoted (PowerShell-literal on win32), so no byte of it is shell syntax. A
562
+ * root holding a control character is not printed: flattened, it would name another directory.
563
+ */
564
+ function targetArg(root, platform = process.platform) {
565
+ if (root === undefined)
566
+ return '';
567
+ if (/[\u0000-\u001f\u007f-\u009f]/.test(root))
568
+ return ' --target <this project\'s root>';
569
+ if (/^[A-Za-z0-9_.:@/+-]+$/.test(root))
570
+ return ` --target ${root}`;
571
+ return ` --target ${platform === 'win32' ? (0, npx_bin_1.powershellLiteral)(root) : (0, npx_bin_1.posixLiteral)(root)}`;
572
+ }
398
573
  /**
399
574
  * @implements A-SPEC-770 — the one line an inbox screen ends with when this machine's refusal log holds open requests
400
575
  * the screen does not list (A-SPEC-563.1 keeps gate refusals out of the inbox; A-SPEC-563.2 / A-SPEC-690 let
@@ -406,15 +581,36 @@ function outsideInboxFooter(outside, root) {
406
581
  return null;
407
582
  // @implements A-SPEC-770.2 — the commands name the workspace this screen read, so a line pasted elsewhere resolves
408
583
  // the id against the right store (measured 2026-10-13: the hint reached the operator without any `--target`).
409
- const target = root === undefined ? '' : ` --target ${/\s/.test(root) ? `"${root}"` : root}`;
584
+ const target = targetArg(root); // A-SPEC-794.33 — one quoting for every pasted line
410
585
  // `◆` rather than the `◇` the spec sketched: §13 (approve-corpus) admits only the template's own glyphs on a decision
411
586
  // row, and U+25C7 is of ambiguous width while U+25C6 is already furniture of this screen.
412
587
  return `◆ ${outside} refusal(s) on this machine are outside this inbox (shell/gate refusals) — list them: ${(0, npx_bin_1.holmesKitCommand)(root)} approve --refusals${target} · grant one: ${(0, npx_bin_1.holmesKitCommand)(root)} approve --grant <id>${target}`;
413
588
  }
589
+ /**
590
+ * @implements A-SPEC-507.1 — the LIST VIEW folds stale entries (C4: 51 rows, mostly week-old residue, buried the one live
591
+ * approval at [32]); the fold is the caller's `readQueue(root, { now, ttlMs })`.
592
+ * @implements A-SPEC-794.30 (the repair 794.10 made, re-ported) — the one order of the list and of a list number.
593
+ * @implements A-SPEC-794.32 — that order is the filing order, the view or not: newest activity first let a request filed
594
+ * after the list take [1], and `--grant 1` granted what no one had read (P2). A new filing is appended at the end.
595
+ */
596
+ function listedRequests(state, _view) {
597
+ return state.pending;
598
+ }
414
599
  function renderPending(state, view, outside, root) {
415
600
  const withFooter = (lines) => {
416
- const footer = outsideInboxFooter(outside, root);
417
- return (footer === null ? lines : [...lines, footer]).join('\n');
601
+ // @implements A-SPEC-794.31 — development-build requests are named, never listed
602
+ const footers = [(0, approval_queue_1.devFiledNote)(state), outsideInboxFooter(outside, root)].filter((f) => f !== null);
603
+ return [...lines, ...footers].join('\n');
604
+ };
605
+ // A-SPEC-507.1 — the folded entries, named under any list: A-SPEC-794.32 — a queue of stale entries only printed no
606
+ // count of them, and `--all` (accepted again) shows them
607
+ const folded = () => {
608
+ if (!view || state.expired.length === 0)
609
+ return [];
610
+ if (!view.showAll)
611
+ return [`⏳ ${state.expired.length} folded as idle (no activity for over ${view.staleHours}h, still pending) — show with --all`]; // A-SPEC-794.41 (D10)
612
+ // Folding is not concealment: --all shows every expired entry under a template-owned prefix.
613
+ return state.expired.flatMap((p) => [`[idle] ${subjectCells('[idle] ', p)}`, ` last activity: ${(0, screen_safe_1.rowField)(p.lastTs, 28)} · id: ${(0, screen_safe_1.rowField)(p.id, 40)}`, '']);
418
614
  };
419
615
  if (state.pending.length === 0) {
420
616
  // Round-7: this early return made the malformed-line row below UNREACHABLE in exactly the case
@@ -422,19 +618,13 @@ function renderPending(state, view, outside, root) {
422
618
  // what an agent would see after destroying it. approval-queue.ts promises the opposite:
423
619
  // "an empty-looking queue must be distinguishable from a corrupted one".
424
620
  if (state.malformedLines > 0) {
425
- return withFooter(['No requests awaiting approval.',
621
+ return withFooter(['No requests awaiting approval.', ...folded(),
426
622
  `(${state.malformedLines} unreadable line(s) in the queue — check for corruption)`]);
427
623
  }
428
- return withFooter(['No requests awaiting approval.']);
624
+ return withFooter(['No requests awaiting approval.', ...folded()]);
429
625
  }
430
626
  const lines = [`◆ ${state.pending.length} request(s) awaiting approval`, ''];
431
- // @implements A-SPEC-507.1 — the LIST VIEW sorts newest-activity-first and folds stale entries
432
- // (C4: 51 rows, mostly week-old residue, buried the one live approval at [32]). Only when a view
433
- // is passed: callers without one keep the legacy insertion order byte-for-byte.
434
- const shown = view
435
- ? [...state.pending].sort((a, b) => (Date.parse(b.lastTs) || 0) - (Date.parse(a.lastTs) || 0))
436
- : state.pending;
437
- shown.forEach((p, i) => {
627
+ listedRequests(state, view).forEach((p, i) => {
438
628
  // @implements A-SPEC-262.1 — every field here is AGENT-CONTROLLED (the target is the command it
439
629
  // was blocked on). Round-1 forged two extra rows and hid the real ones behind an ANSI conceal,
440
630
  // and the operator granted a `curl … | sh` they never saw. The template owns the line structure.
@@ -450,22 +640,11 @@ function renderPending(state, view, outside, root) {
450
640
  lines.push(` blocked ${p.count}x${since}${p.hold ? ' (on hold)' : ''}`);
451
641
  if (p.hold)
452
642
  lines.push(` question: ${(0, screen_safe_1.rowField)(p.question ?? '(no question)', screen_safe_1.ROW_COLS)}`);
453
- lines.push(` id: ${(0, screen_safe_1.rowField)(p.id, 40)}`);
643
+ // A-SPEC-794.34 — the subject digest the id carries now, so the operator reads it before deciding (A-M1)
644
+ lines.push(` id: ${(0, screen_safe_1.rowField)(p.id, 40)}${subjectDigest(p) ? ` · subject ${subjectDigest(p)}` : ''}`);
454
645
  lines.push('');
455
646
  });
456
- if (view && state.expired.length > 0) {
457
- if (view.showAll) {
458
- // Folding is not concealment: --all shows every expired entry under a template-owned prefix.
459
- for (const p of state.expired) {
460
- lines.push(`[expired] ${subjectCells('[expired] ', p)}`);
461
- lines.push(` last activity: ${(0, screen_safe_1.rowField)(p.lastTs, 28)} · id: ${(0, screen_safe_1.rowField)(p.id, 40)}`);
462
- lines.push('');
463
- }
464
- }
465
- else {
466
- lines.push(`⏳ ${state.expired.length} folded as expired (no activity for over ${view.staleHours}h) — show with --all`);
467
- }
468
- }
647
+ lines.push(...folded());
469
648
  if (state.malformedLines > 0)
470
649
  lines.push(`(${state.malformedLines} unreadable line(s) in the queue — check for corruption)`);
471
650
  return withFooter(lines);
@@ -520,7 +699,15 @@ function decisionSubject(p, prefix = '\u2713 approved \u2014 ') {
520
699
  * grant is keyed by.
521
700
  */
522
701
  function decisionDetail(p, tail = '') {
523
- return ` ${(0, screen_safe_1.rowField)(p.id, 20)}${tail === '' ? '' : ` \u00b7 ${(0, screen_safe_1.rowField)(tail, 40)}`}`;
702
+ // @implements A-SPEC-794.34 \u2014 and, on a row of its own, the subject the id carries now: a re-filing may carry another one
703
+ // (A-M1). `--list` names it on the id row too (A-SPEC-650's "no detail on the list" amended by 794.34, kept by 794.35:
704
+ // twelve hex digits the operator reads before deciding), and `--status` shows it in full context.
705
+ const subject = subjectDigest(p);
706
+ return ` ${(0, screen_safe_1.rowField)(p.id, 20)}${tail === '' ? '' : ` \u00b7 ${(0, screen_safe_1.rowField)(tail, 40)}`}${subject ? `\n subject ${subject}` : ''}`;
707
+ }
708
+ /** @implements A-SPEC-794.34 \u2014 the 12 hex digits a screen shows of a request's subject digest, or '' when it has none. */
709
+ function subjectDigest(p) {
710
+ return typeof p.subject === 'string' && /^sha256:[0-9a-f]{64}$/.test(p.subject) ? p.subject.slice(7, 19) : '';
524
711
  }
525
712
  /**
526
713
  * The non-TTY fallback's next-command hint. Pure.
@@ -539,28 +726,33 @@ function decisionDetail(p, tail = '') {
539
726
  * and this renderer is the reason an operator can find the id the deny message named. Row width
540
727
  * follows the decision list's screen-safe discipline.
541
728
  */
542
- function renderRefusals(refusals, limit = 20, root) {
729
+ function renderRefusals(refusals, limit = 20, root, open) {
543
730
  if (refusals.length === 0)
544
731
  return '◆ no refusals recorded on this machine';
545
732
  const recent = refusals.slice(-Math.max(1, limit));
546
- const lines = [`◆ ${refusals.length} refusal(s) on this machine — showing ${recent.length} (newest last)`, ''];
733
+ // @implements A-SPEC-794.55 — the log keeps every refusal; the open ones are what the --list footer counts
734
+ const openNote = open === undefined ? '' : `, ${open} still open (the --list footer's count)`;
735
+ const lines = [`◆ ${refusals.length} refusal(s) recorded on this machine${openNote} — showing ${recent.length} (newest last)`, ''];
547
736
  for (const r of recent) {
548
737
  lines.push(`${(0, screen_safe_1.rowField)(r.id, 20)} ${(0, screen_safe_1.rowField)(r.kind, screen_safe_1.KIND_COLS)} ${(0, screen_safe_1.rowField)(r.target, 40)}`);
549
738
  lines.push(` \u2502 ${(0, screen_safe_1.rowField)(r.why, 66)} ${(0, screen_safe_1.rowField)(r.ts, 24)}`);
550
739
  }
551
740
  // @implements A-SPEC-770.1 — `--grant <id>`: the positional form this line named since 2026-09-06 is refused.
552
741
  // @implements A-SPEC-770.2 — and the workspace whose log this screen read, when the caller knows it.
553
- const target = root === undefined ? '' : ` --target ${/\s/.test(root) ? `"${root}"` : root}`;
742
+ const target = targetArg(root); // A-SPEC-794.33
554
743
  lines.push('', `decide one: ${(0, npx_bin_1.holmesKitCommand)(root)} approve --grant <id>${target}`);
555
744
  return lines.join('\n');
556
745
  }
557
- function renderNonTtyHint(state) {
746
+ function renderNonTtyHint(state, root) {
558
747
  if (state.pending.length === 0)
559
748
  return '';
749
+ // @implements A-SPEC-794.32 — every command names the workspace the hint read: pasted in another directory, a bare
750
+ // command decided that directory's request (Q2). A-SPEC-794.33 — quoted by targetArg, so pasting it runs nothing (A-M5).
751
+ const target = targetArg(root);
560
752
  // @implements A-SPEC-262.1 — round-2: the id is AGENT-CONTROLLED (foldQueue takes it verbatim and
561
753
  // .ax/approvals has no write gate), and these three lines exist to be COPIED INTO A SHELL. A
562
754
  // crafted id carrying a concealed `curl … | sh` rode into the operator's clipboard invisibly.
563
- // Flattened, so what is pasted is what is read. The index is offered first: it needs no id at all.
755
+ // Flattened, so what is pasted is what is read. A-SPEC-794.33 — no list number is offered: decisions take the id.
564
756
  const p = state.pending[0];
565
757
  // Flattened so it cannot forge a line, then SHELL-QUOTED so pasting it cannot run anything: this
566
758
  // block exists to be copied into a shell, and the id is agent-controlled (round-2).
@@ -582,11 +774,10 @@ function renderNonTtyHint(state) {
582
774
  const id = `${(0, screen_safe_1.safeRef)((0, screen_safe_1.rowField)(p.id, 40))}${wellFormed ? '' : ' # forged id — cannot decide'}`;
583
775
  return [
584
776
  'Interactive decisions work only in a TTY.',
585
- 'In this shell, use the non-interactive commands below:',
586
- ' holmes-kit approve --grant 1 # the first item above (referenceable by number)',
587
- ` holmes-kit approve --grant ${id}`,
588
- ` holmes-kit approve --deny ${id} --reason "<reason>"`,
589
- ` holmes-kit approve --ask ${id} --question "<question>"`,
777
+ 'In this shell, decide by id (a list number is refused):',
778
+ ` holmes-kit approve --grant ${id}${target}`,
779
+ ` holmes-kit approve --deny ${id} --reason "<reason>"${target}`,
780
+ ` holmes-kit approve --ask ${id} --question "<question>"${target}`,
590
781
  ].join('\n');
591
782
  }
592
783
  /**
@@ -603,9 +794,11 @@ function renderNonTtyHint(state) {
603
794
  * (REQ-262 Constraints: nothing is approved unseen). `[d]` still demands a reason, because an
604
795
  * unreasoned denial is invisible to the agent; `[q]` holds with a question; `[s]` leaves it.
605
796
  */
606
- async function runInteractive(root, io, actor) {
607
- const state = (0, approval_queue_1.readQueue)(root);
608
- io.print(renderPending(state, undefined, (0, approval_queue_1.refusalsOutsideInbox)(root), root)); // @implements A-SPEC-770, A-SPEC-770.2
797
+ async function runInteractive(root, io, actor, stale) {
798
+ // @implements A-SPEC-794.33 — the screen folds as --list does (A-H2): an item idle past the window is counted, not presented
799
+ const state = (0, approval_queue_1.readQueue)(root, stale ? { now: Date.now(), ttlMs: stale.ttlMs } : undefined);
800
+ const view = stale ? { staleHours: stale.ttlMs / 3_600_000, showAll: stale.showAll } : undefined;
801
+ io.print(renderPending(state, view, (0, approval_queue_1.refusalsOutsideInbox)(root), root)); // @implements A-SPEC-770, A-SPEC-770.2
609
802
  if (state.pending.length === 0)
610
803
  return;
611
804
  const grantDefault = (p) => {
@@ -615,7 +808,7 @@ async function runInteractive(root, io, actor) {
615
808
  return false;
616
809
  }
617
810
  io.print(`\u2713 approved \u2014 ${decisionSubject(p, '\u2713 approved \u2014 ')}`);
618
- io.print(decisionDetail(p, `valid until ${r.expires}`));
811
+ io.print(decisionDetail(p, grantValidityText(r.expires)));
619
812
  return true;
620
813
  };
621
814
  const queue = [...state.pending];
@@ -711,7 +904,7 @@ async function runInteractive(root, io, actor) {
711
904
  continue;
712
905
  }
713
906
  io.print(`\u2713 approved \u2014 ${decisionSubject(p, '\u2713 approved \u2014 ')}`);
714
- io.print(decisionDetail(p, `valid until ${r.expires}`));
907
+ io.print(decisionDetail(p, grantValidityText(r.expires)));
715
908
  }
716
909
  else if (answer === 'v') {
717
910
  const { renderDecisionContext } = require('./approve-context');
@@ -60,7 +60,8 @@ exports.BADGE_REL = path.join('.ax', 'badges', 'traced.svg');
60
60
  const SPECS_REL = path.join('.ax', 'specs');
61
61
  const git = (root, args) => {
62
62
  try {
63
- return (0, node_child_process_1.execFileSync)('git', ['-C', root, ...args], { maxBuffer: bounded_io_1.GIT_MAX_BUFFER, timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'], env: (0, root_1.cleanSubprocessEnv)(process.env) }).toString('utf8');
63
+ // @implements A-SPEC-792.39 — the shared inert git environment (its work-tree status ran the repository's fsmonitor).
64
+ return (0, node_child_process_1.execFileSync)('git', ['-C', root, ...args], { maxBuffer: bounded_io_1.GIT_MAX_BUFFER, timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'], env: (0, bounded_io_1.gitEnv)((0, root_1.cleanSubprocessEnv)(process.env)) }).toString('utf8');
64
65
  }
65
66
  catch {
66
67
  return undefined;
@@ -12,6 +12,8 @@ export interface AutonomyIO {
12
12
  home?: string;
13
13
  /** Internal: `status` without the full-profile line (the posture line it is followed by). */
14
14
  postureOnly?: boolean;
15
+ /** @implements A-SPEC-245.9 (1b-1) — called once by `on`, after every refusal and before the marker is written; a throw writes nothing. */
16
+ beforeWrite?: () => void;
15
17
  }
16
18
  /** @implements A-SPEC-771 — the delegation subcommand's own inputs, parsed by the CLI entry and passed through. */
17
19
  export interface AutonomyExtra {
@@ -89,9 +91,10 @@ export declare function runAutonomyFull(home: string, args: {
89
91
  }, io: {
90
92
  now: string;
91
93
  actor: string;
94
+ beforeWrite?: () => void;
92
95
  }): AutonomyResult;
93
96
  /** @implements A-SPEC-718.7 — the posture `autonomy status` reports, never coloured by the caller's own environment. */
94
- export declare function autonomyPostureLine(root: string, now: string): string;
97
+ export declare function autonomyPostureLine(root: string, now: string, postureOnly?: boolean): string;
95
98
  /**
96
99
  * The `holmes-kit autonomy status|on|off|delegate|revoke-delegation` core. Pure over injected io (clock/TTY/approval/
97
100
  * env) so every branch is testable. Enabling (`on`) and delegating are protected exactly like `init --autonomy`: the