approval-md 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (416) hide show
  1. package/README.md +629 -559
  2. package/SPEC.md +99 -24
  3. package/dist/src/adapters/agentmail.d.ts +426 -0
  4. package/dist/src/adapters/agentmail.js +2 -2
  5. package/dist/src/adapters/conformance.d.ts +149 -0
  6. package/dist/src/adapters/contract.d.ts +628 -0
  7. package/dist/src/adapters/contract.js +110 -16
  8. package/dist/src/adapters/contract.js.map +1 -1
  9. package/dist/src/adapters/email.d.ts +324 -0
  10. package/dist/src/adapters/env-passphrase.d.ts +93 -0
  11. package/dist/src/adapters/public.d.ts +11 -0
  12. package/dist/src/adapters/public.js +11 -0
  13. package/dist/src/adapters/public.js.map +1 -0
  14. package/dist/src/adapters/registry.d.ts +59 -0
  15. package/dist/src/adapters/registry.js +2 -1
  16. package/dist/src/adapters/registry.js.map +1 -1
  17. package/dist/src/adapters/smtp.d.ts +213 -0
  18. package/dist/src/adapters/vault-provider.d.ts +114 -0
  19. package/dist/src/adapters/vault-provider.js +3 -3
  20. package/dist/src/adapters/zzz.d.ts +66 -0
  21. package/dist/src/adapters/zzz.js +299 -0
  22. package/dist/src/adapters/zzz.js.map +1 -0
  23. package/dist/src/channels/batch.d.ts +109 -0
  24. package/dist/src/channels/cli.d.ts +193 -0
  25. package/dist/src/channels/conformance.d.ts +92 -0
  26. package/dist/src/channels/contract.d.ts +656 -0
  27. package/dist/src/channels/contract.js +200 -7
  28. package/dist/src/channels/contract.js.map +1 -1
  29. package/dist/src/channels/payload-view.d.ts +35 -0
  30. package/dist/src/channels/render-queue.d.ts +149 -0
  31. package/dist/src/channels/tagging.d.ts +196 -0
  32. package/dist/src/channels/telegram.d.ts +1944 -0
  33. package/dist/src/channels/telegram.js +218 -23
  34. package/dist/src/channels/telegram.js.map +1 -1
  35. package/dist/src/channels/web.d.ts +350 -0
  36. package/dist/src/channels/web.js +17 -0
  37. package/dist/src/channels/web.js.map +1 -1
  38. package/dist/src/cli/adapter.d.ts +90 -0
  39. package/dist/src/cli/adapter.js +25 -15
  40. package/dist/src/cli/adapter.js.map +1 -1
  41. package/dist/src/cli/amend.d.ts +59 -0
  42. package/dist/src/cli/amend.js +214 -30
  43. package/dist/src/cli/amend.js.map +1 -1
  44. package/dist/src/cli/args.d.ts +43 -0
  45. package/dist/src/cli/attest.d.ts +50 -0
  46. package/dist/src/cli/attest.js +134 -7
  47. package/dist/src/cli/attest.js.map +1 -1
  48. package/dist/src/cli/audit-card.d.ts +62 -0
  49. package/dist/src/cli/audit.d.ts +59 -0
  50. package/dist/src/cli/channel-telegram.d.ts +879 -0
  51. package/dist/src/cli/channel-telegram.js +311 -13
  52. package/dist/src/cli/channel-telegram.js.map +1 -1
  53. package/dist/src/cli/channel-web.d.ts +131 -0
  54. package/dist/src/cli/channel.d.ts +80 -0
  55. package/dist/src/cli/channel.js +9 -0
  56. package/dist/src/cli/channel.js.map +1 -1
  57. package/dist/src/cli/checkpoint-tap.d.ts +169 -0
  58. package/dist/src/cli/codex-bridge.d.ts +819 -0
  59. package/dist/src/cli/codex-bridge.js +1607 -0
  60. package/dist/src/cli/codex-bridge.js.map +1 -0
  61. package/dist/src/cli/codex.d.ts +2 -0
  62. package/dist/src/cli/codex.js +469 -0
  63. package/dist/src/cli/codex.js.map +1 -0
  64. package/dist/src/cli/coverage.d.ts +61 -0
  65. package/dist/src/cli/daemon.d.ts +120 -0
  66. package/dist/src/cli/daemon.js +4 -1
  67. package/dist/src/cli/daemon.js.map +1 -1
  68. package/dist/src/cli/doctor.d.ts +129 -0
  69. package/dist/src/cli/doctor.js +586 -17
  70. package/dist/src/cli/doctor.js.map +1 -1
  71. package/dist/src/cli/env.d.ts +65 -0
  72. package/dist/src/cli/execute.d.ts +202 -0
  73. package/dist/src/cli/execute.js +25 -2
  74. package/dist/src/cli/execute.js.map +1 -1
  75. package/dist/src/cli/exit-codes.d.ts +73 -0
  76. package/dist/src/cli/feedback.d.ts +60 -0
  77. package/dist/src/cli/gate-window.d.ts +40 -0
  78. package/dist/src/cli/gate.d.ts +68 -0
  79. package/dist/src/cli/git-scope.d.ts +190 -0
  80. package/dist/src/cli/gloss-attach.d.ts +85 -0
  81. package/dist/src/cli/gloss-codex-child.d.ts +9 -0
  82. package/dist/src/cli/gloss-codex.d.ts +24 -0
  83. package/dist/src/cli/gloss-options.d.ts +42 -0
  84. package/dist/src/cli/gloss.d.ts +265 -0
  85. package/dist/src/cli/help.d.ts +107 -0
  86. package/dist/src/cli/help.js +320 -93
  87. package/dist/src/cli/help.js.map +1 -1
  88. package/dist/src/cli/hook-codex.d.ts +126 -0
  89. package/dist/src/cli/hook-codex.js +226 -0
  90. package/dist/src/cli/hook-codex.js.map +1 -0
  91. package/dist/src/cli/hook.d.ts +787 -0
  92. package/dist/src/cli/hook.js +1235 -181
  93. package/dist/src/cli/hook.js.map +1 -1
  94. package/dist/src/cli/import.d.ts +35 -0
  95. package/dist/src/cli/import.js +1 -1
  96. package/dist/src/cli/import.js.map +1 -1
  97. package/dist/src/cli/init.d.ts +84 -0
  98. package/dist/src/cli/init.js +2 -2
  99. package/dist/src/cli/init.js.map +1 -1
  100. package/dist/src/cli/instructions.d.ts +23 -0
  101. package/dist/src/cli/journal.d.ts +41 -0
  102. package/dist/src/cli/log-advance.d.ts +287 -0
  103. package/dist/src/cli/log-advance.js +102 -11
  104. package/dist/src/cli/log-advance.js.map +1 -1
  105. package/dist/src/cli/log-anchor.d.ts +176 -0
  106. package/dist/src/cli/log-checkpoint.d.ts +22 -0
  107. package/dist/src/cli/log-sync.d.ts +243 -0
  108. package/dist/src/cli/log-verbs.d.ts +16 -0
  109. package/dist/src/cli/log-verbs.js +7 -1
  110. package/dist/src/cli/log-verbs.js.map +1 -1
  111. package/dist/src/cli/long-help.d.ts +70 -0
  112. package/dist/src/cli/main.d.ts +77 -0
  113. package/dist/src/cli/main.js +159 -7
  114. package/dist/src/cli/main.js.map +1 -1
  115. package/dist/src/cli/mcp.d.ts +52 -0
  116. package/dist/src/cli/paths.d.ts +56 -0
  117. package/dist/src/cli/payload.d.ts +58 -0
  118. package/dist/src/cli/policy-apply.d.ts +195 -0
  119. package/dist/src/cli/policy-apply.js +573 -0
  120. package/dist/src/cli/policy-apply.js.map +1 -0
  121. package/dist/src/cli/policy.d.ts +43 -0
  122. package/dist/src/cli/policy.js +14 -1
  123. package/dist/src/cli/policy.js.map +1 -1
  124. package/dist/src/cli/preflight.d.ts +501 -0
  125. package/dist/src/cli/preflight.js +689 -45
  126. package/dist/src/cli/preflight.js.map +1 -1
  127. package/dist/src/cli/progress.d.ts +78 -0
  128. package/dist/src/cli/prompt.d.ts +209 -0
  129. package/dist/src/cli/quickstart.d.ts +46 -0
  130. package/dist/src/cli/quickstart.js +297 -0
  131. package/dist/src/cli/quickstart.js.map +1 -0
  132. package/dist/src/cli/records.d.ts +34 -0
  133. package/dist/src/cli/render.d.ts +22 -0
  134. package/dist/src/cli/sandbox.d.ts +51 -0
  135. package/dist/src/cli/sandbox.js +17 -1
  136. package/dist/src/cli/sandbox.js.map +1 -1
  137. package/dist/src/cli/scaffold.d.ts +79 -0
  138. package/dist/src/cli/scaffold.js +1 -1
  139. package/dist/src/cli/setup-adapter.d.ts +137 -0
  140. package/dist/src/cli/setup-adapter.js +38 -4
  141. package/dist/src/cli/setup-adapter.js.map +1 -1
  142. package/dist/src/cli/setup-channel.d.ts +126 -0
  143. package/dist/src/cli/setup-channel.js +28 -1
  144. package/dist/src/cli/setup-channel.js.map +1 -1
  145. package/dist/src/cli/setup-checkpoint.d.ts +57 -0
  146. package/dist/src/cli/setup-common.d.ts +277 -0
  147. package/dist/src/cli/setup-common.js +3 -2
  148. package/dist/src/cli/setup-common.js.map +1 -1
  149. package/dist/src/cli/setup-flow.d.ts +287 -0
  150. package/dist/src/cli/setup-service.d.ts +96 -0
  151. package/dist/src/cli/setup.d.ts +204 -0
  152. package/dist/src/cli/setup.js +94 -2
  153. package/dist/src/cli/setup.js.map +1 -1
  154. package/dist/src/cli/style.d.ts +320 -0
  155. package/dist/src/cli/token.d.ts +39 -0
  156. package/dist/src/cli/up.d.ts +155 -0
  157. package/dist/src/cli/up.js +119 -53
  158. package/dist/src/cli/up.js.map +1 -1
  159. package/dist/src/cli/usage.d.ts +37 -0
  160. package/dist/src/cli/values.d.ts +40 -0
  161. package/dist/src/cli/values.js +3 -4
  162. package/dist/src/cli/values.js.map +1 -1
  163. package/dist/src/cli/vault.d.ts +59 -0
  164. package/dist/src/cli/vault.js +2 -2
  165. package/dist/src/cli/vault.js.map +1 -1
  166. package/dist/src/cli/verb-registry.d.ts +76 -0
  167. package/dist/src/cli/verb-registry.js +344 -11
  168. package/dist/src/cli/verb-registry.js.map +1 -1
  169. package/dist/src/cli/wordmark.d.ts +31 -0
  170. package/dist/src/cli/wordmark.js +2 -2
  171. package/dist/src/codex/broker.d.ts +229 -0
  172. package/dist/src/codex/broker.js +548 -0
  173. package/dist/src/codex/broker.js.map +1 -0
  174. package/dist/src/codex/doctor.d.ts +13 -0
  175. package/dist/src/codex/doctor.js +41 -0
  176. package/dist/src/codex/doctor.js.map +1 -0
  177. package/dist/src/codex/manifest.d.ts +49 -0
  178. package/dist/src/codex/manifest.js +103 -0
  179. package/dist/src/codex/manifest.js.map +1 -0
  180. package/dist/src/codex/runner.d.ts +178 -0
  181. package/dist/src/codex/runner.js +231 -0
  182. package/dist/src/codex/runner.js.map +1 -0
  183. package/dist/src/codex/serve.d.ts +56 -0
  184. package/dist/src/codex/serve.js +98 -0
  185. package/dist/src/codex/serve.js.map +1 -0
  186. package/dist/src/codex/templates.d.ts +41 -0
  187. package/dist/src/codex/templates.js +319 -0
  188. package/dist/src/codex/templates.js.map +1 -0
  189. package/dist/src/codex/trust.d.ts +19 -0
  190. package/dist/src/codex/trust.js +183 -0
  191. package/dist/src/codex/trust.js.map +1 -0
  192. package/dist/src/codex/workspace-commit.d.ts +219 -0
  193. package/dist/src/codex/workspace-commit.js +549 -0
  194. package/dist/src/codex/workspace-commit.js.map +1 -0
  195. package/dist/src/codex/workspace-plan.d.ts +131 -0
  196. package/dist/src/codex/workspace-plan.js +561 -0
  197. package/dist/src/codex/workspace-plan.js.map +1 -0
  198. package/dist/src/core/actor.d.ts +2 -0
  199. package/dist/src/core/actor.js +5 -0
  200. package/dist/src/core/actor.js.map +1 -0
  201. package/dist/src/core/advance-cycle.d.ts +221 -0
  202. package/dist/src/core/advance-cycle.js +66 -2
  203. package/dist/src/core/advance-cycle.js.map +1 -1
  204. package/dist/src/core/agents-md.d.ts +278 -0
  205. package/dist/src/core/agents-md.js +33 -31
  206. package/dist/src/core/agents-md.js.map +1 -1
  207. package/dist/src/core/apply-patch.d.ts +49 -0
  208. package/dist/src/core/apply-patch.js +266 -0
  209. package/dist/src/core/apply-patch.js.map +1 -0
  210. package/dist/src/core/attest.d.ts +635 -0
  211. package/dist/src/core/attest.js +326 -4
  212. package/dist/src/core/attest.js.map +1 -1
  213. package/dist/src/core/audit.d.ts +510 -0
  214. package/dist/src/core/audit.js +13 -0
  215. package/dist/src/core/audit.js.map +1 -1
  216. package/dist/src/core/budgets.d.ts +238 -0
  217. package/dist/src/core/channel-owner.d.ts +213 -0
  218. package/dist/src/core/channel-owner.js +358 -0
  219. package/dist/src/core/channel-owner.js.map +1 -0
  220. package/dist/src/core/checkpoint.d.ts +500 -0
  221. package/dist/src/core/child-env.d.ts +88 -0
  222. package/dist/src/core/clock.d.ts +52 -0
  223. package/dist/src/core/command-class.d.ts +697 -0
  224. package/dist/src/core/command-class.js +713 -25
  225. package/dist/src/core/command-class.js.map +1 -1
  226. package/dist/src/core/commit-guard.d.ts +272 -0
  227. package/dist/src/core/commit-guard.js +424 -0
  228. package/dist/src/core/commit-guard.js.map +1 -0
  229. package/dist/src/core/coverage-sources/adapter.d.ts +40 -0
  230. package/dist/src/core/coverage-sources/gh.d.ts +48 -0
  231. package/dist/src/core/coverage-sources/git.d.ts +101 -0
  232. package/dist/src/core/coverage.d.ts +217 -0
  233. package/dist/src/core/credential-spec.d.ts +72 -0
  234. package/dist/src/core/daemon-actor.d.ts +45 -0
  235. package/dist/src/core/daemon-actor.js +54 -0
  236. package/dist/src/core/daemon-actor.js.map +1 -0
  237. package/dist/src/core/dark-session.d.ts +432 -0
  238. package/dist/src/core/dark-session.js +266 -82
  239. package/dist/src/core/dark-session.js.map +1 -1
  240. package/dist/src/core/decision-refusal.d.ts +206 -0
  241. package/dist/src/core/decision-refusal.js +24 -2
  242. package/dist/src/core/decision-refusal.js.map +1 -1
  243. package/dist/src/core/env-file.d.ts +455 -0
  244. package/dist/src/core/env-file.js +60 -1
  245. package/dist/src/core/env-file.js.map +1 -1
  246. package/dist/src/core/execute.d.ts +871 -0
  247. package/dist/src/core/execute.js +59 -8
  248. package/dist/src/core/execute.js.map +1 -1
  249. package/dist/src/core/frontmatter.d.ts +78 -0
  250. package/dist/src/core/gate-window.d.ts +312 -0
  251. package/dist/src/core/gate.d.ts +1449 -0
  252. package/dist/src/core/gate.js +149 -14
  253. package/dist/src/core/gate.js.map +1 -1
  254. package/dist/src/core/gesture-refusal.d.ts +166 -0
  255. package/dist/src/core/gesture-refusal.js +188 -0
  256. package/dist/src/core/gesture-refusal.js.map +1 -0
  257. package/dist/src/core/git-run.d.ts +73 -0
  258. package/dist/src/core/harness-version.d.ts +157 -0
  259. package/dist/src/core/harness-version.js +4 -1
  260. package/dist/src/core/harness-version.js.map +1 -1
  261. package/dist/src/core/harness-wait.d.ts +55 -0
  262. package/dist/src/core/head-retry.d.ts +107 -0
  263. package/dist/src/core/instance.d.ts +310 -0
  264. package/dist/src/core/instance.js +113 -0
  265. package/dist/src/core/instance.js.map +1 -1
  266. package/dist/src/core/intake-limits.d.ts +247 -0
  267. package/dist/src/core/jcs.d.ts +52 -0
  268. package/dist/src/core/journal.d.ts +144 -0
  269. package/dist/src/core/live-draw.d.ts +436 -0
  270. package/dist/src/core/log-reconcile.d.ts +89 -0
  271. package/dist/src/core/log-subscribe.d.ts +36 -0
  272. package/dist/src/core/log-subscribe.js +162 -0
  273. package/dist/src/core/log-subscribe.js.map +1 -0
  274. package/dist/src/core/log.d.ts +316 -0
  275. package/dist/src/core/log.js.map +1 -1
  276. package/dist/src/core/loop.d.ts +274 -0
  277. package/dist/src/core/loop.js +11 -0
  278. package/dist/src/core/loop.js.map +1 -1
  279. package/dist/src/core/md-fence.d.ts +41 -0
  280. package/dist/src/core/money.d.ts +147 -0
  281. package/dist/src/core/payload-census.d.ts +74 -0
  282. package/dist/src/core/payload-store.d.ts +175 -0
  283. package/dist/src/core/payload.d.ts +71 -0
  284. package/dist/src/core/policy-diff.d.ts +292 -0
  285. package/dist/src/core/policy-diff.js +27 -4
  286. package/dist/src/core/policy-diff.js.map +1 -1
  287. package/dist/src/core/policy-expectations.d.ts +199 -0
  288. package/dist/src/core/policy-explain.d.ts +160 -0
  289. package/dist/src/core/policy-explain.js +63 -3
  290. package/dist/src/core/policy-explain.js.map +1 -1
  291. package/dist/src/core/policy-load.d.ts +567 -0
  292. package/dist/src/core/policy-load.js +36 -6
  293. package/dist/src/core/policy-load.js.map +1 -1
  294. package/dist/src/core/policy-match.d.ts +324 -0
  295. package/dist/src/core/policy-match.js +72 -9
  296. package/dist/src/core/policy-match.js.map +1 -1
  297. package/dist/src/core/policy-proposal.d.ts +317 -0
  298. package/dist/src/core/policy-proposal.js +102 -2
  299. package/dist/src/core/policy-proposal.js.map +1 -1
  300. package/dist/src/core/prompt-layout.d.ts +221 -0
  301. package/dist/src/core/protected-path-guard.d.ts +566 -0
  302. package/dist/src/core/protected-path-guard.js +848 -55
  303. package/dist/src/core/protected-path-guard.js.map +1 -1
  304. package/dist/src/core/question-preempted.d.ts +141 -0
  305. package/dist/src/core/question-preempted.js +152 -0
  306. package/dist/src/core/question-preempted.js.map +1 -0
  307. package/dist/src/core/read-scope.d.ts +172 -0
  308. package/dist/src/core/read-scope.js +252 -0
  309. package/dist/src/core/read-scope.js.map +1 -0
  310. package/dist/src/core/registration.d.ts +25 -0
  311. package/dist/src/core/reindex.d.ts +99 -0
  312. package/dist/src/core/sampler.d.ts +313 -0
  313. package/dist/src/core/sandbox.d.ts +371 -0
  314. package/dist/src/core/sandbox.js +190 -1
  315. package/dist/src/core/sandbox.js.map +1 -1
  316. package/dist/src/core/seal.d.ts +165 -0
  317. package/dist/src/core/sender-identity.d.ts +476 -0
  318. package/dist/src/core/sender-identity.js +572 -0
  319. package/dist/src/core/sender-identity.js.map +1 -0
  320. package/dist/src/core/shlex.d.ts +102 -0
  321. package/dist/src/core/shlex.js +159 -0
  322. package/dist/src/core/shlex.js.map +1 -0
  323. package/dist/src/core/state.d.ts +505 -0
  324. package/dist/src/core/task-file.d.ts +185 -0
  325. package/dist/src/core/telegram-config.d.ts +93 -0
  326. package/dist/src/core/token.d.ts +409 -0
  327. package/dist/src/core/token.js +21 -38
  328. package/dist/src/core/token.js.map +1 -1
  329. package/dist/src/core/validate.d.ts +138 -0
  330. package/dist/src/core/values.d.ts +147 -0
  331. package/dist/src/core/values.js +36 -1
  332. package/dist/src/core/values.js.map +1 -1
  333. package/dist/src/core/vault.d.ts +291 -0
  334. package/dist/src/core/verified-snapshot.d.ts +204 -0
  335. package/dist/src/core/verify.d.ts +336 -0
  336. package/dist/src/core/version.d.ts +8 -0
  337. package/dist/src/core/wysiwys.d.ts +370 -0
  338. package/dist/src/daemon/advance-child.d.ts +39 -0
  339. package/dist/src/daemon/advance.d.ts +476 -0
  340. package/dist/src/daemon/advance.js +25 -4
  341. package/dist/src/daemon/advance.js.map +1 -1
  342. package/dist/src/daemon/audit.d.ts +87 -0
  343. package/dist/src/daemon/daemon.d.ts +1180 -0
  344. package/dist/src/daemon/daemon.js +9 -0
  345. package/dist/src/daemon/daemon.js.map +1 -1
  346. package/dist/src/daemon/dark-session.d.ts +64 -0
  347. package/dist/src/daemon/draw-child.d.ts +36 -0
  348. package/dist/src/daemon/draw.d.ts +154 -0
  349. package/dist/src/daemon/git-evidence.d.ts +173 -0
  350. package/dist/src/daemon/git-evidence.js +1 -1
  351. package/dist/src/daemon/projection.d.ts +180 -0
  352. package/dist/src/daemon/prune.d.ts +207 -0
  353. package/dist/src/mcp/http.d.ts +113 -0
  354. package/dist/src/mcp/server.d.ts +265 -0
  355. package/dist/src/mcp/server.js +17 -1
  356. package/dist/src/mcp/server.js.map +1 -1
  357. package/docs/adapter-api.md +106 -0
  358. package/docs/cli-reference.md +1316 -63
  359. package/docs/codex-enforced-session.md +103 -0
  360. package/docs/codex-workspace-broker.md +118 -0
  361. package/package.json +14 -2
  362. package/schema/codex-instance.schema.json +82 -0
  363. package/schema/event.schema.json +539 -9
  364. package/schema/fixtures/codex-instance/invalid/unpinned-codex-version.json +40 -0
  365. package/schema/fixtures/codex-instance/valid/canonical.json +40 -0
  366. package/schema/fixtures/event/invalid/approval-granted-sender-hashed-false.json +20 -0
  367. package/schema/fixtures/event/invalid/approval-granted-sender-hashed-raw-id.json +20 -0
  368. package/schema/fixtures/event/invalid/audit-gesture-refused-human-actor.json +16 -0
  369. package/schema/fixtures/event/invalid/audit-gesture-refused-no-actor-no-sender.json +15 -0
  370. package/schema/fixtures/event/invalid/audit-gesture-refused-unknown-gesture.json +16 -0
  371. package/schema/fixtures/event/invalid/audit-question-preempted-agent-actor.json +16 -0
  372. package/schema/fixtures/event/invalid/audit-question-preempted-no-question-id.json +16 -0
  373. package/schema/fixtures/event/invalid/audit-question-preempted-unknown-source.json +15 -0
  374. package/schema/fixtures/event/invalid/gate-path-signed-off-absolute-path.json +14 -0
  375. package/schema/fixtures/event/invalid/gate-path-signed-off-agent-actor.json +14 -0
  376. package/schema/fixtures/event/invalid/gate-path-signed-off-missing-path.json +13 -0
  377. package/schema/fixtures/event/valid/approval-granted-sender-hashed.json +20 -0
  378. package/schema/fixtures/event/valid/audit-gesture-refused-review-note.json +21 -0
  379. package/schema/fixtures/event/valid/audit-gesture-refused-sender-key-unavailable.json +19 -0
  380. package/schema/fixtures/event/valid/audit-gesture-refused.json +19 -0
  381. package/schema/fixtures/event/valid/audit-question-preempted-no-verdict.json +16 -0
  382. package/schema/fixtures/event/valid/audit-question-preempted.json +20 -0
  383. package/schema/fixtures/event/valid/gate-path-signed-off.json +14 -0
  384. package/schema/fixtures/event/valid/harness-kind-claude-code.json +23 -0
  385. package/schema/fixtures/event/valid/harness-kind-codex.json +23 -0
  386. package/schema/fixtures/event/valid/harness-kind-cursor.json +23 -0
  387. package/schema/fixtures/event/valid/harness-kind-grok.json +23 -0
  388. package/schema/fixtures/event/valid/harness-kind-muse.json +23 -0
  389. package/schema/fixtures/policy/invalid/senders-half-keyed.json +20 -0
  390. package/schema/fixtures/policy/valid/canonical.json +1 -1
  391. package/schema/fixtures/policy/valid/senders-keyed.json +24 -0
  392. package/schema/fixtures/policy-md/valid/canonical.md +1 -1
  393. package/schema/fixtures/policy-md/valid/with-values.md +5 -7
  394. package/schema/fixtures/values/invalid/class-shaped.json +1 -1
  395. package/schema/fixtures/values/invalid/duplicate-entry.json +1 -1
  396. package/schema/fixtures/values/invalid/non-string-item.json +1 -1
  397. package/schema/fixtures/values/invalid/over-cap.json +1 -1
  398. package/schema/fixtures/values/invalid/unknown-key.json +1 -1
  399. package/schema/fixtures/values/invalid/version-float.json +1 -0
  400. package/schema/fixtures/values/invalid/version-integer.json +1 -0
  401. package/schema/fixtures/values/invalid/version-wrong-string.json +1 -0
  402. package/schema/fixtures/values/valid/empty-lists.json +2 -3
  403. package/schema/fixtures/values/valid/full.json +5 -7
  404. package/schema/fixtures/values/valid/minimal.json +1 -1
  405. package/schema/fixtures/values-md/invalid/schema-invalid.md +5 -3
  406. package/schema/fixtures/values-md/invalid/two-blocks.md +3 -3
  407. package/schema/fixtures/values-md/invalid/unterminated.md +2 -2
  408. package/schema/fixtures/values-md/invalid/version-1.md +69 -0
  409. package/schema/fixtures/values-md/invalid/version-unquoted.md +64 -0
  410. package/schema/fixtures/values-md/invalid/yaml-error.md +2 -2
  411. package/schema/fixtures/values-md/valid/absent.md +1 -1
  412. package/schema/fixtures/values-md/valid/with-values.md +5 -7
  413. package/schema/policy.schema.json +75 -3
  414. package/schema/values.schema.json +7 -11
  415. package/templates/codex/README.md +9 -0
  416. package/schema/fixtures/values/invalid/version-string.json +0 -1
@@ -0,0 +1,55 @@
1
+ /**
2
+ * How long a harness hook waits, and how long the question it opened outlives
3
+ * that wait (APRV-287).
4
+ *
5
+ * Two numbers with two readers each, which is the whole reason they live here
6
+ * rather than beside either one. `cli/hook.ts` uses them to decide when a
7
+ * request it opened has been abandoned; `cli/channel-telegram.ts` uses the wait
8
+ * to decide which pending requests on a listener's first cycle are stale enough
9
+ * to collapse into one message. Two copies of the same duration would be two
10
+ * answers to "is anybody still waiting on this", and the channel would collapse
11
+ * questions the hook was still holding open, or leave a dead queue on a phone.
12
+ *
13
+ * Nothing here reads a clock, a policy or the log: these are durations, and
14
+ * every judgment made with them is made by a caller that already holds the
15
+ * instant it is judging against.
16
+ */
17
+ /**
18
+ * The hook's default wait, chosen to sit inside Claude Code's own 60s hook
19
+ * default. The string form is what the flag parser takes; the millisecond form
20
+ * is what a comparison takes.
21
+ */
22
+ export declare const HOOK_DEFAULT_WAIT = "55s";
23
+ /** {@link HOOK_DEFAULT_WAIT} in milliseconds. */
24
+ export declare const HOOK_DEFAULT_WAIT_MS = 55000;
25
+ /**
26
+ * How long a request outlives the wait that opened it, before the hook takes it
27
+ * back (APRV-287).
28
+ *
29
+ * The window exists for exactly one thing: the retry. A hook whose wait expires
30
+ * leaves its question open because a decision inside the policy's TTL still
31
+ * authorizes an identical retry of the identical command (APRV-117), and the
32
+ * agent that was denied usually retries within a minute or two. So the question
33
+ * stays live for that long and no longer.
34
+ *
35
+ * Past it, nobody is coming back for the answer. The request was accruing on an
36
+ * approver's phone as one more message a restarted listener would re-deliver,
37
+ * and on 2026-09-06 a dozen of those arrived at once behind a dead daemon. A
38
+ * request nothing will adopt is withdrawn (reason `timeout`), which authorizes
39
+ * nothing, refuses a late tap in the approver's own words, and leaves the log
40
+ * saying exactly what happened: the asker gave up.
41
+ *
42
+ * Five minutes because it is longer than any retry loop this runtime has been
43
+ * observed to take and shorter than the shortest TTL an operator is likely to
44
+ * write. It is a default: `--retry-grace` moves it per invocation, and `0`
45
+ * withdraws at the moment the wait expires.
46
+ */
47
+ export declare const HOOK_RETRY_GRACE_MS: number;
48
+ /**
49
+ * How old a request opened under `waitMs` must be before the grace has run out.
50
+ *
51
+ * Measured from the `approval.requested` record's own timestamp, which is the
52
+ * instant the runtime wrote at the write boundary, and never from anything a
53
+ * caller states about when it started waiting.
54
+ */
55
+ export declare function abandonedAfterMs(waitMs: number, graceMs: number): number;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The bounded head-moved retry, in one place (APRV-150, APRV-236).
3
+ *
4
+ * ## The fact this module is about
5
+ *
6
+ * `core/log.ts` takes a compare-and-append precondition: a writer states the
7
+ * `(seq, hash)` its checks were made against, and the append is refused under
8
+ * the lock when the tail is something else. That refusal is `append-failed`
9
+ * with `append.code === "head-moved"`, and it is correct: every read-dependent
10
+ * check that authorized the write is stale.
11
+ *
12
+ * Stale is not the same as wrong. A moved head says the verdict must be
13
+ * computed again; it does not say what the verdict is. Treating the two as the
14
+ * same is what turned a busy log into a lottery, twice:
15
+ *
16
+ * - 2026-08-29 (APRV-150): a session's first `git status` — class `read.shell`,
17
+ * autonomous, no human anywhere near it — was denied by the Claude Code hook
18
+ * because an unrelated record landed a few milliseconds earlier.
19
+ * - 2026-09-02 (APRV-236): `approval grant` refused a human's decision with
20
+ * `head moved: expected seq 14218, found 14219` while two lanes and the
21
+ * daemon were appending. The human ran it again. Twice more.
22
+ *
23
+ * The second one is the worse of the two, because the caller it handed the
24
+ * retry to was a person. A compare-and-append refusal is a fact about timing
25
+ * rather than about authority, and asking a human to retype is the wrong party
26
+ * to hand it to.
27
+ *
28
+ * ## What a retry is here, and what it is not
29
+ *
30
+ * The unit of retry is the WHOLE read-check-append cycle: a new read of the
31
+ * verified log, a new read of the policy, a fresh attestation, a fresh
32
+ * derivation of the request's state, fresh escalation, single-use, intake and
33
+ * budget checks, and a new append against the head that the new read observed.
34
+ * Nothing crosses an attempt except the caller's own inputs.
35
+ *
36
+ * The append is never retried on its own. That distinction is the whole safety
37
+ * argument, and it is worth stating as three properties:
38
+ *
39
+ * - **compare-and-append is untouched.** Every attempt supplies the head it
40
+ * read, and a stale write is still refused under the lock. SPEC.md §11.1
41
+ * invariant 5 holds per attempt, which is where it has to hold.
42
+ * - **A changed verdict is the new verdict.** If the record that moved the head
43
+ * decided the request, spent the key, exhausted the budget, lapsed the TTL or
44
+ * re-attested a different policy, the next attempt derives that and refuses
45
+ * it with the code those fresh facts produce — `already-decided`,
46
+ * `request-withdrawn`, `already-executed`, `budget-exceeded`, `expired`,
47
+ * `policy-drift` — never `append-failed`. A retry cannot launder a denial
48
+ * into an allow, because it never replays the earlier conclusion.
49
+ * - **Only `head-moved` retries.** Every other refusal, a real verdict included,
50
+ * is returned on the first attempt. So is a lock timeout, a corrupt log and a
51
+ * schema refusal at the write boundary: retrying those would be either
52
+ * pointless or a second write.
53
+ *
54
+ * The bound is what keeps a busy log from turning one call into an unbounded
55
+ * write loop. When it is spent the last `head-moved` refusal is returned with
56
+ * its code and its `append` error unchanged, and with the attempt count added to
57
+ * its message so a reader can tell one lost race from a log under sustained
58
+ * contention. The caller fails closed on it exactly as it always did.
59
+ */
60
+ import type { AppendError } from "./log.js";
61
+ /**
62
+ * How many times a gate writer re-derives its verdict against a moved head
63
+ * before it gives up. Small, fixed, and not configurable upward.
64
+ *
65
+ * APRV-150 chose three for the hook's writers; APRV-236 gives the same three to
66
+ * every other writer a human or a session drives, rather than inventing a
67
+ * second number for the same fact.
68
+ */
69
+ export declare const HEAD_MOVED_ATTEMPTS = 3;
70
+ /**
71
+ * The shape this module needs of a writer's result: an `ok` discriminator, and
72
+ * on the refusal side a code and the append error beneath it.
73
+ *
74
+ * Deliberately structural. `GateRefusal`, `ExecuteRefusal`, `TokenRefusal` and
75
+ * `GateWindowRefusal` are four frozen unions in four modules that must not
76
+ * learn about each other; what they share is this, and this is all the helper
77
+ * reads.
78
+ */
79
+ export interface HeadRetryable {
80
+ ok: boolean;
81
+ code?: string;
82
+ message?: string;
83
+ append?: AppendError;
84
+ }
85
+ /** Did this refusal come from the compare-and-append precondition alone? */
86
+ export declare function isHeadMoved(result: HeadRetryable): boolean;
87
+ /**
88
+ * The attempt budget for one operation: `ceiling` unless the caller asked for
89
+ * fewer.
90
+ *
91
+ * Clamped rather than trusted, and clamped in the one direction that matters: a
92
+ * caller may ask for LESS tolerance of a moved head (a test pinning the
93
+ * unretried behaviour, a caller that would rather fail fast), never for more.
94
+ * Ambiguity — a non-integer, a zero, a negative — resolves to the value the
95
+ * runtime chose, not the caller's.
96
+ */
97
+ export declare function attemptsOf(asked: number | undefined, ceiling?: number): number;
98
+ /**
99
+ * Run one whole read-check-append cycle, and run it again from the top while it
100
+ * loses the race, up to `attempts` times.
101
+ *
102
+ * `cycle` MUST be the entire operation: it re-reads, re-runs every check on the
103
+ * head it just read, and returns either the append it attempted or the refusal
104
+ * those fresh facts produced. A `cycle` that closes over a stale read would
105
+ * defeat the only property that makes this safe.
106
+ */
107
+ export declare function withHeadRetry<T extends HeadRetryable>(attempts: number, cycle: () => T): T;
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Which gate instance this process is talking about (APRV-178).
3
+ *
4
+ * Everything else in this runtime is directory-scoped already: the policy is
5
+ * the `APPROVAL.md` beside the working directory, the log is that directory's
6
+ * `.approval/log/events.jsonl`, the vault and `.approval/env` sit next to it.
7
+ * Two checkouts on one machine are two gates, and nothing they hold is shared.
8
+ *
9
+ * The OS keystore was the exception, and it cost a live incident: the item
10
+ * names were three fixed strings, so a demo instance provisioned in another
11
+ * directory stored its bot token over the production instance's item and then
12
+ * read the production token back. Both gates then long-polled ONE bot, the
13
+ * `getUpdates` offsets fought, and a human's approval tap was consumed by the
14
+ * listener that had not asked for it. A keystore is machine-global; the names
15
+ * put into it have to carry the scoping the filesystem gave everything else.
16
+ *
17
+ * ## What the identity is
18
+ *
19
+ * The absolute path of the instance's `.approval` directory, hashed. Not the
20
+ * repository root (a gate may be configured with `--log` somewhere else), not
21
+ * a random id written into a file (a file the operator can copy is an identity
22
+ * that travels, which is the bug), and not the log path itself (a `--log` that
23
+ * names the same instance's log by a different but equivalent spelling should
24
+ * not mint a second identity, and `envFilePathFor` already normalises the two
25
+ * spellings this runtime supports).
26
+ *
27
+ * Symlinks are deliberately NOT resolved. `realpathSync` would touch the
28
+ * filesystem, so the identity of an instance would depend on whether its
29
+ * directory currently exists — and `approval setup` must be able to name the
30
+ * item it is about to create before anything is on disk. Two paths that reach
31
+ * one directory by different routes are therefore two identities; that is the
32
+ * safe direction of the error (two names, no sharing) rather than the unsafe
33
+ * one.
34
+ *
35
+ * ## What the names look like
36
+ *
37
+ * ```
38
+ * approval-tg-token-3f2a9c11
39
+ * approval-vault-passphrase-3f2a9c11
40
+ * approval-sampling-secret-3f2a9c11
41
+ * ```
42
+ *
43
+ * Eight hex digits: long enough that two instances on one machine will not
44
+ * collide by accident, short enough that an operator reading
45
+ * `keychain:approval-tg-token-3f2a9c11` in `.approval/env` and the same suffix
46
+ * in `approval doctor` can compare them at a glance. The suffix is not a
47
+ * secret and is not derived from one — it is a hash of a directory path, which
48
+ * `.approval/env` already carries in the open.
49
+ */
50
+ import { type ResolvedVariable, type SourceRunner } from "./env-file.js";
51
+ import type { PolicyLoadResult } from "./policy-load.js";
52
+ /**
53
+ * The unscoped item names this project used before APRV-178.
54
+ *
55
+ * Kept, and kept named, for two reasons: an instance provisioned before the
56
+ * change still has its token under one of them, and the migration path is to
57
+ * READ them as a fallback and say so out loud, never to silently adopt them.
58
+ */
59
+ export declare const LEGACY_SERVICE_TELEGRAM_TOKEN = "approval-tg-token";
60
+ export declare const LEGACY_SERVICE_VAULT_PASSPHRASE = "approval-vault-passphrase";
61
+ export declare const LEGACY_SERVICE_SAMPLING_SECRET = "approval-sampling-secret";
62
+ /**
63
+ * The sender key (APRV-370). Born scoped, so it has no legacy instance to be a
64
+ * fallback for; it sits in this list because the naming rule is the list's, and
65
+ * a name minted outside it is a name `approval env --check` reports as unknown.
66
+ */
67
+ export declare const SERVICE_SENDER_KEY = "approval-sender-key";
68
+ /** Every unscoped name, for the "is this the legacy one?" test. */
69
+ export declare const LEGACY_SERVICES: readonly string[];
70
+ /** How many hex digits of the digest a scoped name carries. */
71
+ export declare const INSTANCE_ID_LENGTH = 8;
72
+ /**
73
+ * The `.approval` directory this log path belongs to, absolute as given.
74
+ *
75
+ * `envFilePathFor` already answers "which instance is this log in", by walking
76
+ * up out of `log/` when it is there; the env file's own directory IS the
77
+ * instance home, so this is that answer with the filename removed rather than
78
+ * a second rule that could disagree with it.
79
+ */
80
+ export declare function instanceHomeFor(logPath: string): string;
81
+ /** The instance's short identity: {@link INSTANCE_ID_LENGTH} hex digits. */
82
+ export declare function instanceIdFor(logPath: string): string;
83
+ /** The keystore item name `base` takes in the instance owning `logPath`. */
84
+ export declare function scopedService(base: string, logPath: string): string;
85
+ /**
86
+ * How a service name relates to the instance owning `logPath`.
87
+ *
88
+ * Answered from the NAME alone, with no keystore lookup: `approval doctor`
89
+ * reports on this and a diagnostic may not pop a keychain-unlock prompt (see
90
+ * `cli/doctor.ts`'s `NON_RESOLVING_RUNNER`). The name is enough, because the
91
+ * name is what decides which item a lookup would find.
92
+ *
93
+ * - `mine` — the scoped name this instance writes.
94
+ * - `legacy` — one of the unscoped pre-APRV-178 names, which every instance on
95
+ * the machine resolves to the same item.
96
+ * - `other-instance` — a scoped name whose suffix is some other instance's.
97
+ * - `unknown` — a name this runtime never wrote; the operator chose it, and
98
+ * nothing here can say whose it is.
99
+ */
100
+ export type ServiceScope = "mine" | "legacy" | "other-instance" | "unknown";
101
+ export declare function scopeOfService(service: string, logPath: string): ServiceScope;
102
+ /**
103
+ * The variable `approval env`'s export block uses to say what it exported.
104
+ *
105
+ * ## The bug this exists to close
106
+ *
107
+ * The bleed rule below reads no values, on purpose: it runs inside `approval
108
+ * doctor` and `approval up`, neither of which may pop a keystore-unlock dialog
109
+ * to produce a diagnostic (`NON_RESOLVING_RUNNER`). So it saw "this variable is
110
+ * exported, and the file has a line for it" and reported that the value in use
111
+ * was not the one the instance configured. It could not know that. The
112
+ * documented start ritual is
113
+ *
114
+ * ```sh
115
+ * eval "$(approval env)"
116
+ * ```
117
+ *
118
+ * which exports THIS instance's own values from THIS instance's own file, and
119
+ * leaves behind exactly the state the rule was calling an incident: exported,
120
+ * with a file line naming a source. Observed on 2026-09-06 in the primary,
121
+ * where `unset APPROVAL_SAMPLING_SECRET && eval "$(approval env)" && approval
122
+ * up` printed the finding for the variable the eval had just resolved from the
123
+ * gate's own keychain item. A check that asserts a fact it never tested is
124
+ * worse than no check: it teaches the operator to skip the line.
125
+ *
126
+ * ## What is exported, and why it is value-free
127
+ *
128
+ * ```
129
+ * APPROVAL_ENV_PROVENANCE=1:3f2a9c11:<64 hex>:APPROVAL_TG_TOKEN,APPROVAL_TG_CHAT
130
+ * │ │ │ └ the NAMES it exported from the file
131
+ * │ │ └ sha256 of the env file bytes it read
132
+ * │ └ the instance whose file that was
133
+ * └ the format version
134
+ * ```
135
+ *
136
+ * Four colon-separated fields; the names are shell variable names, which cannot
137
+ * contain a colon or a comma, so the shape needs no escaping. Every field is a
138
+ * NAME, an id or a digest: the same three kinds of thing `.approval/env` already
139
+ * carries in the open, and none of them is a value. The rule stays as value-free
140
+ * after this change as it was before it, which is the point — a check that had
141
+ * to read the secret to decide whether to complain about the secret would be a
142
+ * worse trade than the false positive.
143
+ *
144
+ * ## What it does NOT weaken
145
+ *
146
+ * Invariant 7 (no verb loads `.approval/env` implicitly) is untouched: this
147
+ * variable reaches a shell only when a human evaluates `approval env`'s output,
148
+ * exactly like every other line in that block, and no verb gains the ability to
149
+ * read the file for its values. And it cannot launder a foreign export, because
150
+ * `approval env` lists only the names it resolved FROM THE FILE. A value that
151
+ * was already in the environment is re-exported by that block for fidelity, and
152
+ * deliberately left out of this list, so a bled variable stays reported however
153
+ * many times the ritual is run over it.
154
+ *
155
+ * Trusting the variable is safe in the only direction that matters. Anything
156
+ * able to set it in this process's environment could already set the credential
157
+ * variables themselves, so it buys an attacker nothing; and being wrong here
158
+ * silences a WARNING rather than opening a gate. The reverse default — believing
159
+ * the exported value is foreign — is the bug being fixed.
160
+ */
161
+ export declare const ENV_PROVENANCE_VAR = "APPROVAL_ENV_PROVENANCE";
162
+ /** The only format version this build writes, and the only one it reads. */
163
+ export declare const ENV_PROVENANCE_VERSION = "1";
164
+ /** What one `approval env` export block claims about itself. */
165
+ export interface EnvProvenance {
166
+ /** The instance whose env file it resolved from. */
167
+ instanceId: string;
168
+ /** `envFileDigest` of the bytes it resolved from (`core/env-file.ts`). */
169
+ digest: string;
170
+ /** The names it exported FROM that file. Never the ones it passed through. */
171
+ names: ReadonlySet<string>;
172
+ }
173
+ /**
174
+ * The value for {@link ENV_PROVENANCE_VAR}, for an export block that resolved
175
+ * `names` out of the file `digest` identifies.
176
+ */
177
+ export declare function formatEnvProvenance(logPath: string, digest: string, names: readonly string[]): string;
178
+ /**
179
+ * Read the claim back, or `null` for anything this build does not recognise.
180
+ *
181
+ * Strict on every field, and `null` rather than a partial answer: a malformed
182
+ * claim is an unverified one, an unverified one earns no credit, and no credit
183
+ * means the finding is still reported. That is the fail-closed direction (the
184
+ * check stays loud) for a value whose whole job is to make the check quieter.
185
+ */
186
+ export declare function parseEnvProvenance(raw: string | undefined): EnvProvenance | null;
187
+ /**
188
+ * One way this instance's credentials can belong to somebody else.
189
+ *
190
+ * - `foreign-instance` — `.approval/env` names a keystore item whose scope
191
+ * suffix is another instance's. Two gates then hold one credential, which is
192
+ * the incident: one bot, two long pollers, and a human's tap consumed by the
193
+ * listener that did not ask the question. This is WRONG, not a state.
194
+ * - `legacy-shared` — the file names one of the unscoped pre-APRV-178 items.
195
+ * Correct on a machine with one gate and a trap on a machine with two, so it
196
+ * is reported and not failed: it is what every existing installation looks
197
+ * like, and the repair is one re-run of `approval setup channel telegram`.
198
+ * - `ambient-bleed` — the value was exported before this process started, the
199
+ * file names a source of its own, and the export is NOT one this instance's
200
+ * `approval env` made (see {@link ENV_PROVENANCE_VAR}). The shell wins on
201
+ * purpose (invariant 7); what was missing is anyone saying so. This is the
202
+ * half of the incident that survived fixing the file: the operator's rc
203
+ * exported the production token, so every fresh terminal kept using the
204
+ * production bot.
205
+ * - `stale-export` — the value in this shell is NOT what this instance's file
206
+ * resolves to today (APRV-390). The name-only rules above cannot see this at
207
+ * all, and it is the case that actually cost an evening: a token re-stored in
208
+ * the keychain does not reach a shell that exported the old one, because
209
+ * `approval env` never overrides a variable that is already set. The daemon
210
+ * then answered 401 while the keychain item behind the same line passed
211
+ * `getMe` by hand. Only {@link valueFindings} produces it, because only that
212
+ * function is allowed to read a value.
213
+ */
214
+ export type InstanceFindingKind = "foreign-instance" | "legacy-shared" | "ambient-bleed" | "stale-export";
215
+ export interface InstanceFinding {
216
+ kind: InstanceFindingKind;
217
+ /** The environment variable the finding is about. */
218
+ variable: string;
219
+ /** The item name, for the two name-shaped findings. */
220
+ service?: string;
221
+ /** One sentence, and never a value. */
222
+ detail: string;
223
+ }
224
+ /**
225
+ * What is wrong with WHOSE credentials this instance is using (APRV-178).
226
+ *
227
+ * Answered from names alone. No keystore is consulted ({@link
228
+ * NON_RESOLVING_RUNNER}), so this may be called from `approval doctor` and from
229
+ * `approval up`'s start-up without either of them blocking on an unlock dialog.
230
+ * No value is read, compared or printed on any path: the inputs are a service
231
+ * name, a scheme, a variable name, and (since APRV-278) an instance id, a file
232
+ * digest and a list of variable names out of {@link ENV_PROVENANCE_VAR} — all of
233
+ * which `.approval/env` and `approval env --check` carry in the open. The
234
+ * exported VALUES this reports on are still never read, compared or printed.
235
+ *
236
+ * A file this runtime cannot read at all produces no findings rather than a
237
+ * guess; `approval env --check` and doctor's `environment` row are what report
238
+ * an unreadable or wrong-moded file, and saying it twice in different words is
239
+ * how two commands come to disagree.
240
+ */
241
+ export declare function instanceFindings(logPath: string, load: PolicyLoadResult, ambientEnv?: NodeJS.ProcessEnv): InstanceFinding[];
242
+ /**
243
+ * What the rule may consult beyond the names (APRV-278).
244
+ *
245
+ * Both fields are optional and an absent one only ever makes the report LOUDER:
246
+ * a caller that supplies neither gets the pre-APRV-278 behaviour, where every
247
+ * exported variable with a file line is reported.
248
+ */
249
+ export interface FindingsContext {
250
+ /** The environment the report is about. Read for {@link ENV_PROVENANCE_VAR}. */
251
+ ambientEnv?: NodeJS.ProcessEnv;
252
+ /** `envFileDigest` of this instance's env file as it now reads. */
253
+ envFileDigest?: string;
254
+ }
255
+ /**
256
+ * The exported names this instance's OWN current `approval env` vouches for
257
+ * (APRV-278).
258
+ *
259
+ * Empty unless {@link ENV_PROVENANCE_VAR} parses, names this instance, and
260
+ * matches the env file as it now reads. `approval env --check` and the finding
261
+ * rule below both answer "is this export the documented ritual's?" from this one
262
+ * function, because two spellings of that question are two chances for `approval
263
+ * env --check` and `approval up` to say different things about one shell.
264
+ */
265
+ export declare function ownEnvExports(logPath: string, context?: FindingsContext): ReadonlySet<string>;
266
+ /**
267
+ * The same question, answered by COMPARING VALUES (APRV-390).
268
+ *
269
+ * ## Why a second function, and why only start-up may call it
270
+ *
271
+ * Everything above answers from names, so that a diagnostic never blocks on a
272
+ * keystore-unlock dialog ({@link NON_RESOLVING_RUNNER}). That constraint is
273
+ * right for `approval doctor` and wrong for the thing `approval up` is about to
274
+ * do, which is USE the value. Two cases observed on 2026-09-19 are invisible to
275
+ * every name-only rule:
276
+ *
277
+ * 1. **A stale export.** `approval env` never overrides a variable already set
278
+ * in the shell — that is invariant 7 working as designed — so a token
279
+ * re-stored in the keychain never reaches a terminal that exported the old
280
+ * one. The names agree, the file is this instance's, the provenance claim is
281
+ * this instance's own, and the value is wrong. The daemon got 401 from a
282
+ * token that passed `getMe` when read from the keychain by hand.
283
+ * 2. **A false positive on the correct ritual.** `APPROVAL_HUMAN` was reported
284
+ * cross-instance when the export came from this instance's own `eval
285
+ * "$(approval env)"` seconds earlier, because the provenance claim did not
286
+ * match. A finding about a value that IS the file's value is noise, and
287
+ * noise in a refusal is how a refusal gets overridden by habit.
288
+ *
289
+ * Comparing answers both: a value equal to what the file resolves to is
290
+ * correct however it got there, and a value that differs is wrong however
291
+ * honest its provenance looks.
292
+ *
293
+ * ## What it does with the values
294
+ *
295
+ * It compares them and drops them. Nothing is printed, returned, logged or put
296
+ * in a message on any path — every finding this produces carries a variable
297
+ * name, a file path and a line number, exactly like the name-only ones. The
298
+ * only new capability is answering "same or different".
299
+ *
300
+ * ## Where it fails soft, and in which direction
301
+ *
302
+ * A file entry that cannot be resolved (a locked keychain, a helper that is not
303
+ * installed, a `secret-tool` with no D-Bus) yields no comparison, and the
304
+ * name-only finding for that variable stands unchanged. That is the safe
305
+ * direction: an unverifiable value keeps whatever scrutiny it already had, and
306
+ * a caller that cannot resolve anything gets exactly the pre-APRV-390 report.
307
+ */
308
+ export declare function valueFindings(logPath: string, load: PolicyLoadResult, runner: SourceRunner, ambientEnv?: NodeJS.ProcessEnv): InstanceFinding[];
309
+ /** The name-only rules, over an already-resolved variable set. */
310
+ export declare function findingsFor(logPath: string, variables: readonly ResolvedVariable[], context?: FindingsContext): InstanceFinding[];
@@ -60,11 +60,18 @@ import { NON_RESOLVING_RUNNER, envFilePathFor, resolveEnvironment, } from "./env
60
60
  export const LEGACY_SERVICE_TELEGRAM_TOKEN = "approval-tg-token";
61
61
  export const LEGACY_SERVICE_VAULT_PASSPHRASE = "approval-vault-passphrase";
62
62
  export const LEGACY_SERVICE_SAMPLING_SECRET = "approval-sampling-secret";
63
+ /**
64
+ * The sender key (APRV-370). Born scoped, so it has no legacy instance to be a
65
+ * fallback for; it sits in this list because the naming rule is the list's, and
66
+ * a name minted outside it is a name `approval env --check` reports as unknown.
67
+ */
68
+ export const SERVICE_SENDER_KEY = "approval-sender-key";
63
69
  /** Every unscoped name, for the "is this the legacy one?" test. */
64
70
  export const LEGACY_SERVICES = [
65
71
  LEGACY_SERVICE_TELEGRAM_TOKEN,
66
72
  LEGACY_SERVICE_VAULT_PASSPHRASE,
67
73
  LEGACY_SERVICE_SAMPLING_SECRET,
74
+ SERVICE_SENDER_KEY,
68
75
  ];
69
76
  /** How many hex digits of the digest a scoped name carries. */
70
77
  export const INSTANCE_ID_LENGTH = 8;
@@ -265,6 +272,112 @@ export function ownEnvExports(logPath, context = {}) {
265
272
  const view = provenanceView(logPath, context);
266
273
  return view.claimsThisFile ? view.names : new Set();
267
274
  }
275
+ /**
276
+ * The same question, answered by COMPARING VALUES (APRV-390).
277
+ *
278
+ * ## Why a second function, and why only start-up may call it
279
+ *
280
+ * Everything above answers from names, so that a diagnostic never blocks on a
281
+ * keystore-unlock dialog ({@link NON_RESOLVING_RUNNER}). That constraint is
282
+ * right for `approval doctor` and wrong for the thing `approval up` is about to
283
+ * do, which is USE the value. Two cases observed on 2026-09-19 are invisible to
284
+ * every name-only rule:
285
+ *
286
+ * 1. **A stale export.** `approval env` never overrides a variable already set
287
+ * in the shell — that is invariant 7 working as designed — so a token
288
+ * re-stored in the keychain never reaches a terminal that exported the old
289
+ * one. The names agree, the file is this instance's, the provenance claim is
290
+ * this instance's own, and the value is wrong. The daemon got 401 from a
291
+ * token that passed `getMe` when read from the keychain by hand.
292
+ * 2. **A false positive on the correct ritual.** `APPROVAL_HUMAN` was reported
293
+ * cross-instance when the export came from this instance's own `eval
294
+ * "$(approval env)"` seconds earlier, because the provenance claim did not
295
+ * match. A finding about a value that IS the file's value is noise, and
296
+ * noise in a refusal is how a refusal gets overridden by habit.
297
+ *
298
+ * Comparing answers both: a value equal to what the file resolves to is
299
+ * correct however it got there, and a value that differs is wrong however
300
+ * honest its provenance looks.
301
+ *
302
+ * ## What it does with the values
303
+ *
304
+ * It compares them and drops them. Nothing is printed, returned, logged or put
305
+ * in a message on any path — every finding this produces carries a variable
306
+ * name, a file path and a line number, exactly like the name-only ones. The
307
+ * only new capability is answering "same or different".
308
+ *
309
+ * ## Where it fails soft, and in which direction
310
+ *
311
+ * A file entry that cannot be resolved (a locked keychain, a helper that is not
312
+ * installed, a `secret-tool` with no D-Bus) yields no comparison, and the
313
+ * name-only finding for that variable stands unchanged. That is the safe
314
+ * direction: an unverifiable value keeps whatever scrutiny it already had, and
315
+ * a caller that cannot resolve anything gets exactly the pre-APRV-390 report.
316
+ */
317
+ export function valueFindings(logPath, load, runner, ambientEnv = process.env) {
318
+ const envPath = envFilePathFor(logPath);
319
+ const named = instanceFindings(logPath, load, ambientEnv);
320
+ // EVERY variable whose value came from the shell and whose file has a line
321
+ // for it — not only the ones the name-only rule complained about.
322
+ //
323
+ // This is the correction that matters, and the reason the set is not taken
324
+ // from `named`. The provenance claim (APRV-278) vouches for an export by
325
+ // naming this instance, this file's DIGEST and this variable, and all three
326
+ // stay true when the file is untouched and the KEYSTORE ITEM behind one of
327
+ // its lines is re-stored. The claim is honest and the value is stale, so the
328
+ // vouched variables are exactly the ones this check must still look at.
329
+ const nameOnly = resolveEnvironment(load, envPath, NON_RESOLVING_RUNNER, ambientEnv);
330
+ if (!nameOnly.ok)
331
+ return named;
332
+ const ambientNames = new Set(nameOnly.variables
333
+ .filter((variable) => variable.status === "set-in-environment" && variable.fileSource !== undefined)
334
+ .map((variable) => variable.name));
335
+ if (ambientNames.size === 0)
336
+ return named;
337
+ // Resolve the FILE, by hiding exactly those names from the resolution: the
338
+ // ambient environment wins otherwise, and the answer would be the value we
339
+ // are trying to check. Nothing here is exported — this process's own
340
+ // environment is untouched, so invariant 7 is as true after this call as
341
+ // before it. The file cannot SET anything; it can only fail to match.
342
+ const hidden = { ...ambientEnv };
343
+ for (const name of ambientNames)
344
+ delete hidden[name];
345
+ const fromFile = resolveEnvironment(load, envPath, runner, hidden);
346
+ if (!fromFile.ok)
347
+ return named;
348
+ const fileValues = new Map();
349
+ for (const variable of fromFile.variables) {
350
+ if (variable.value !== undefined && variable.status !== "set-in-environment") {
351
+ fileValues.set(variable.name, variable.value);
352
+ }
353
+ }
354
+ // Everything the name-only rule found that is NOT about an ambient value: a
355
+ // foreign item name and a legacy shared one are facts about names, and no
356
+ // comparison of values can make either of them go away.
357
+ const findings = named.filter((finding) => finding.kind !== "ambient-bleed");
358
+ for (const name of ambientNames) {
359
+ const fileValue = fileValues.get(name);
360
+ const ambientValue = ambientEnv[name];
361
+ // Unresolvable (a locked keychain, a missing helper, a missing item): no
362
+ // comparison was made, so whatever the name-only rule said still stands.
363
+ if (fileValue === undefined) {
364
+ const bleed = named.find((finding) => finding.kind === "ambient-bleed" && finding.variable === name);
365
+ if (bleed !== undefined)
366
+ findings.push(bleed);
367
+ continue;
368
+ }
369
+ // The shell holds exactly what the file configures. Correct, however it got
370
+ // there, and whatever the provenance claim did or did not say.
371
+ if (ambientValue === fileValue)
372
+ continue;
373
+ findings.push({
374
+ kind: "stale-export",
375
+ variable: name,
376
+ detail: `${name} is exported in this shell with a value that is NOT what ${envPath} resolves to today, and an export always wins over the file, so this process would use the stale one`,
377
+ });
378
+ }
379
+ return findings;
380
+ }
268
381
  /** The name-only rules, over an already-resolved variable set. */
269
382
  export function findingsFor(logPath, variables, context = {}) {
270
383
  const home = instanceHomeFor(logPath);
@@ -1 +1 @@
1
- {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../../src/core/instance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,kBAAkB,GAEnB,MAAM,eAAe,CAAC;AAGvB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,mBAAmB,CAAC;AACjE,MAAM,CAAC,MAAM,+BAA+B,GAAG,2BAA2B,CAAC;AAC3E,MAAM,CAAC,MAAM,8BAA8B,GAAG,0BAA0B,CAAC;AAEzE,mEAAmE;AACnE,MAAM,CAA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