approval-md 0.3.0 → 0.4.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 (226) hide show
  1. package/README.md +83 -914
  2. package/SPEC.md +98 -13
  3. package/cli.js +66 -7
  4. package/dist/src/adapters/smtp.d.ts +18 -0
  5. package/dist/src/adapters/smtp.js +24 -3
  6. package/dist/src/adapters/smtp.js.map +1 -1
  7. package/dist/src/channels/contract.d.ts +19 -0
  8. package/dist/src/channels/contract.js +105 -1
  9. package/dist/src/channels/contract.js.map +1 -1
  10. package/dist/src/channels/relay-server.d.ts +90 -0
  11. package/dist/src/channels/relay-server.js +295 -0
  12. package/dist/src/channels/relay-server.js.map +1 -0
  13. package/dist/src/channels/relay.d.ts +273 -0
  14. package/dist/src/channels/relay.js +564 -0
  15. package/dist/src/channels/relay.js.map +1 -0
  16. package/dist/src/channels/tagging.js +6 -1
  17. package/dist/src/channels/tagging.js.map +1 -1
  18. package/dist/src/channels/telegram-webhook.d.ts +273 -0
  19. package/dist/src/channels/telegram-webhook.js +536 -0
  20. package/dist/src/channels/telegram-webhook.js.map +1 -0
  21. package/dist/src/channels/telegram.d.ts +271 -1
  22. package/dist/src/channels/telegram.js +403 -45
  23. package/dist/src/channels/telegram.js.map +1 -1
  24. package/dist/src/cli/amend.js +350 -4
  25. package/dist/src/cli/amend.js.map +1 -1
  26. package/dist/src/cli/attest.js +43 -6
  27. package/dist/src/cli/attest.js.map +1 -1
  28. package/dist/src/cli/channel-relay.d.ts +108 -0
  29. package/dist/src/cli/channel-relay.js +334 -0
  30. package/dist/src/cli/channel-relay.js.map +1 -0
  31. package/dist/src/cli/channel-telegram-webhook.d.ts +273 -0
  32. package/dist/src/cli/channel-telegram-webhook.js +709 -0
  33. package/dist/src/cli/channel-telegram-webhook.js.map +1 -0
  34. package/dist/src/cli/channel-telegram.d.ts +272 -26
  35. package/dist/src/cli/channel-telegram.js +478 -41
  36. package/dist/src/cli/channel-telegram.js.map +1 -1
  37. package/dist/src/cli/channel.d.ts +1 -1
  38. package/dist/src/cli/channel.js +5 -1
  39. package/dist/src/cli/channel.js.map +1 -1
  40. package/dist/src/cli/daemon.js +37 -5
  41. package/dist/src/cli/daemon.js.map +1 -1
  42. package/dist/src/cli/doctor.d.ts +63 -0
  43. package/dist/src/cli/doctor.js +856 -111
  44. package/dist/src/cli/doctor.js.map +1 -1
  45. package/dist/src/cli/execute.d.ts +17 -1
  46. package/dist/src/cli/execute.js +341 -20
  47. package/dist/src/cli/execute.js.map +1 -1
  48. package/dist/src/cli/exit-codes.d.ts +12 -0
  49. package/dist/src/cli/exit-codes.js +13 -0
  50. package/dist/src/cli/exit-codes.js.map +1 -1
  51. package/dist/src/cli/gate.d.ts +2 -0
  52. package/dist/src/cli/gate.js +233 -2
  53. package/dist/src/cli/gate.js.map +1 -1
  54. package/dist/src/cli/help.d.ts +9 -1
  55. package/dist/src/cli/help.js +246 -38
  56. package/dist/src/cli/help.js.map +1 -1
  57. package/dist/src/cli/hook.d.ts +371 -3
  58. package/dist/src/cli/hook.js +1926 -44
  59. package/dist/src/cli/hook.js.map +1 -1
  60. package/dist/src/cli/init.js +16 -7
  61. package/dist/src/cli/init.js.map +1 -1
  62. package/dist/src/cli/instructions.js +24 -3
  63. package/dist/src/cli/instructions.js.map +1 -1
  64. package/dist/src/cli/log-anchor.d.ts +55 -0
  65. package/dist/src/cli/log-anchor.js +199 -60
  66. package/dist/src/cli/log-anchor.js.map +1 -1
  67. package/dist/src/cli/main.d.ts +0 -12
  68. package/dist/src/cli/main.js +51 -0
  69. package/dist/src/cli/main.js.map +1 -1
  70. package/dist/src/cli/muse.d.ts +2 -0
  71. package/dist/src/cli/muse.js +62 -0
  72. package/dist/src/cli/muse.js.map +1 -0
  73. package/dist/src/cli/payload.js +79 -1
  74. package/dist/src/cli/payload.js.map +1 -1
  75. package/dist/src/cli/scaffold.js +6 -0
  76. package/dist/src/cli/scaffold.js.map +1 -1
  77. package/dist/src/cli/serve.d.ts +53 -0
  78. package/dist/src/cli/serve.js +270 -0
  79. package/dist/src/cli/serve.js.map +1 -0
  80. package/dist/src/cli/up.js +21 -2
  81. package/dist/src/cli/up.js.map +1 -1
  82. package/dist/src/cli/verb-registry.d.ts +2 -0
  83. package/dist/src/cli/verb-registry.js +337 -39
  84. package/dist/src/cli/verb-registry.js.map +1 -1
  85. package/dist/src/cli/wordmark.d.ts +2 -2
  86. package/dist/src/cli/wordmark.js +2 -2
  87. package/dist/src/core/attest-bootstrap.d.ts +95 -0
  88. package/dist/src/core/attest-bootstrap.js +135 -0
  89. package/dist/src/core/attest-bootstrap.js.map +1 -0
  90. package/dist/src/core/attest.d.ts +20 -3
  91. package/dist/src/core/attest.js +25 -0
  92. package/dist/src/core/attest.js.map +1 -1
  93. package/dist/src/core/audit.d.ts +55 -3
  94. package/dist/src/core/audit.js +52 -5
  95. package/dist/src/core/audit.js.map +1 -1
  96. package/dist/src/core/channel-lease.d.ts +322 -0
  97. package/dist/src/core/channel-lease.js +663 -0
  98. package/dist/src/core/channel-lease.js.map +1 -0
  99. package/dist/src/core/command-class.d.ts +51 -0
  100. package/dist/src/core/command-class.js +760 -8
  101. package/dist/src/core/command-class.js.map +1 -1
  102. package/dist/src/core/daemon-host.d.ts +178 -0
  103. package/dist/src/core/daemon-host.js +228 -0
  104. package/dist/src/core/daemon-host.js.map +1 -0
  105. package/dist/src/core/daemon-identity.d.ts +238 -0
  106. package/dist/src/core/daemon-identity.js +252 -0
  107. package/dist/src/core/daemon-identity.js.map +1 -0
  108. package/dist/src/core/gate.d.ts +306 -5
  109. package/dist/src/core/gate.js +772 -24
  110. package/dist/src/core/gate.js.map +1 -1
  111. package/dist/src/core/harness-version.d.ts +128 -4
  112. package/dist/src/core/harness-version.js +179 -12
  113. package/dist/src/core/harness-version.js.map +1 -1
  114. package/dist/src/core/harness-wait.d.ts +82 -3
  115. package/dist/src/core/harness-wait.js +89 -3
  116. package/dist/src/core/harness-wait.js.map +1 -1
  117. package/dist/src/core/log-subscribe.d.ts +21 -0
  118. package/dist/src/core/log-subscribe.js +16 -6
  119. package/dist/src/core/log-subscribe.js.map +1 -1
  120. package/dist/src/core/log-write-layer.d.ts +55 -0
  121. package/dist/src/core/log-write-layer.js +91 -0
  122. package/dist/src/core/log-write-layer.js.map +1 -0
  123. package/dist/src/core/log.d.ts +50 -21
  124. package/dist/src/core/log.js +197 -19
  125. package/dist/src/core/log.js.map +1 -1
  126. package/dist/src/core/payload-census.d.ts +51 -0
  127. package/dist/src/core/payload-census.js +125 -2
  128. package/dist/src/core/payload-census.js.map +1 -1
  129. package/dist/src/core/payload-store.d.ts +31 -0
  130. package/dist/src/core/payload-store.js +113 -8
  131. package/dist/src/core/payload-store.js.map +1 -1
  132. package/dist/src/core/payload.d.ts +18 -3
  133. package/dist/src/core/payload.js +20 -4
  134. package/dist/src/core/payload.js.map +1 -1
  135. package/dist/src/core/policy-diff.d.ts +10 -0
  136. package/dist/src/core/policy-diff.js +10 -2
  137. package/dist/src/core/policy-diff.js.map +1 -1
  138. package/dist/src/core/policy-explain.d.ts +7 -1
  139. package/dist/src/core/policy-explain.js +16 -1
  140. package/dist/src/core/policy-explain.js.map +1 -1
  141. package/dist/src/core/policy-load.d.ts +24 -0
  142. package/dist/src/core/policy-load.js.map +1 -1
  143. package/dist/src/core/policy-match.d.ts +38 -0
  144. package/dist/src/core/policy-match.js +35 -0
  145. package/dist/src/core/policy-match.js.map +1 -1
  146. package/dist/src/core/policy-proposal.d.ts +23 -0
  147. package/dist/src/core/policy-proposal.js +8 -2
  148. package/dist/src/core/policy-proposal.js.map +1 -1
  149. package/dist/src/core/read-scope.d.ts +10 -0
  150. package/dist/src/core/read-scope.js +4 -0
  151. package/dist/src/core/read-scope.js.map +1 -1
  152. package/dist/src/core/run-payload.d.ts +160 -0
  153. package/dist/src/core/run-payload.js +304 -0
  154. package/dist/src/core/run-payload.js.map +1 -0
  155. package/dist/src/core/sender-identity.d.ts +35 -10
  156. package/dist/src/core/sender-identity.js +48 -11
  157. package/dist/src/core/sender-identity.js.map +1 -1
  158. package/dist/src/core/state.d.ts +52 -1
  159. package/dist/src/core/state.js +52 -6
  160. package/dist/src/core/state.js.map +1 -1
  161. package/dist/src/core/telegram-config.d.ts +79 -0
  162. package/dist/src/core/telegram-config.js +108 -0
  163. package/dist/src/core/telegram-config.js.map +1 -1
  164. package/dist/src/core/verify.d.ts +23 -1
  165. package/dist/src/core/verify.js +20 -2
  166. package/dist/src/core/verify.js.map +1 -1
  167. package/dist/src/daemon/audit.d.ts +80 -5
  168. package/dist/src/daemon/audit.js +126 -6
  169. package/dist/src/daemon/audit.js.map +1 -1
  170. package/dist/src/daemon/daemon.d.ts +174 -2
  171. package/dist/src/daemon/daemon.js +298 -7
  172. package/dist/src/daemon/daemon.js.map +1 -1
  173. package/dist/src/daemon/git-evidence.d.ts +2 -2
  174. package/dist/src/daemon/git-evidence.js +1 -1
  175. package/dist/src/daemon/projection.d.ts +13 -2
  176. package/dist/src/daemon/projection.js +39 -6
  177. package/dist/src/daemon/projection.js.map +1 -1
  178. package/dist/src/mcp/server.d.ts +39 -3
  179. package/dist/src/mcp/server.js +22 -3
  180. package/dist/src/mcp/server.js.map +1 -1
  181. package/dist/src/muse/server.d.ts +16 -0
  182. package/dist/src/muse/server.js +238 -0
  183. package/dist/src/muse/server.js.map +1 -0
  184. package/dist/src/serve/archive.d.ts +158 -0
  185. package/dist/src/serve/archive.js +354 -0
  186. package/dist/src/serve/archive.js.map +1 -0
  187. package/dist/src/serve/arguments.d.ts +93 -0
  188. package/dist/src/serve/arguments.js +228 -0
  189. package/dist/src/serve/arguments.js.map +1 -0
  190. package/dist/src/serve/credentials.d.ts +91 -0
  191. package/dist/src/serve/credentials.js +143 -0
  192. package/dist/src/serve/credentials.js.map +1 -0
  193. package/dist/src/serve/follow.d.ts +86 -0
  194. package/dist/src/serve/follow.js +101 -0
  195. package/dist/src/serve/follow.js.map +1 -0
  196. package/dist/src/serve/hook-thread.d.ts +134 -0
  197. package/dist/src/serve/hook-thread.js +333 -0
  198. package/dist/src/serve/hook-thread.js.map +1 -0
  199. package/dist/src/serve/hook-worker.d.ts +134 -0
  200. package/dist/src/serve/hook-worker.js +173 -0
  201. package/dist/src/serve/hook-worker.js.map +1 -0
  202. package/dist/src/serve/server.d.ts +412 -0
  203. package/dist/src/serve/server.js +1251 -0
  204. package/dist/src/serve/server.js.map +1 -0
  205. package/docs/README-extended.md +766 -0
  206. package/docs/cli-reference.md +1633 -43
  207. package/package.json +4 -2
  208. package/schema/event.schema.json +59 -2
  209. package/schema/fixtures/event/invalid/daemon-id-malformed.json +15 -0
  210. package/schema/fixtures/event/invalid/execution-started-truncated-policy-sha256.json +18 -0
  211. package/schema/fixtures/event/invalid/harness-cap-at-margin.json +16 -0
  212. package/schema/fixtures/event/invalid/harness-cap-fractional.json +16 -0
  213. package/schema/fixtures/event/invalid/harness-cap-negative.json +16 -0
  214. package/schema/fixtures/event/invalid/harness-cap-string.json +16 -0
  215. package/schema/fixtures/event/invalid/harness-cap-without-harness-execution.json +16 -0
  216. package/schema/fixtures/event/invalid/harness-cap-zero.json +16 -0
  217. package/schema/fixtures/event/valid/approval-requested-harness-cap.json +18 -0
  218. package/schema/fixtures/event/valid/daemon-identity-declared.json +17 -0
  219. package/schema/fixtures/event/valid/daemon-identity.json +15 -0
  220. package/schema/fixtures/event/valid/execution-started-policy-sha256.json +18 -0
  221. package/schema/fixtures/event/valid/harness-kind-hermes.json +23 -0
  222. package/schema/fixtures/policy/invalid/daemons-malformed-id.json +10 -0
  223. package/schema/fixtures/policy/valid/daemons-allowlist.json +19 -0
  224. package/schema/fixtures/policy-md/invalid/schema-invalid-agent-may-request.md +21 -0
  225. package/schema/fixtures/policy-md/valid/agent-may-request.md +24 -0
  226. package/schema/policy.schema.json +50 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-telegram-webhook.js","sourceRoot":"","sources":["../../../src/cli/channel-telegram-webhook.ts"],"names":[],"mappings":"AAAA;;;;;;;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K,EAAE,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;QACnC,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;QACrC,GAAG,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,IAAI,CAAC;QACrD,GAAG,WAAW,CAAC,KAAK,EAAE,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE;YAC1D,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CACrB,OAAO,CAAC,GAAG,CAAC,sCAAsC,MAAM,4BAA4B,CAAC;SACxF,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,2EAA2E;QAC3E,yEAAyE;QACzE,2DAA2D;QAC3D,OAAO,QAAQ,CAAC,IAAI,KAAK,gBAAgB,IAAI,QAAQ,CAAC,IAAI,KAAK,qBAAqB;YAClF,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;YAC1C,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC"}
@@ -107,12 +107,13 @@
107
107
  * a send failure: an operator who has just mistyped a chat id or a token should
108
108
  * learn it immediately rather than watch a listener retry forever.
109
109
  */
110
- import type { DecideOptions } from "../core/gate.js";
110
+ import { type DecideOptions } from "../core/gate.js";
111
111
  import { type ChannelRequest, type DeliveryId } from "../channels/contract.js";
112
112
  import { type ChannelTagRefusalCode, type TagOptions } from "../channels/tagging.js";
113
113
  import { type CheckpointTap } from "./checkpoint-tap.js";
114
114
  import { TelegramChannel, type CheckpointTapResponse, type ReviewCard, type ReviewTapResponse, type TelegramCommand, type TelegramTerminalState } from "../channels/telegram.js";
115
115
  import { type TelegramDelivery } from "../core/telegram-config.js";
116
+ import { type ChannelLease, type ChannelLeaseMode } from "../core/channel-lease.js";
116
117
  import { type InstanceFinding } from "../core/instance.js";
117
118
  import { type ChannelSender } from "../core/sender-identity.js";
118
119
  import { type ParsedFlags } from "./args.js";
@@ -213,33 +214,94 @@ export interface ListenSetup {
213
214
  checkpoint: CheckpointTap;
214
215
  }
215
216
  /**
216
- * Claim this listener's bot before it polls (APRV-390).
217
+ * Claim this listener's bot before it polls (APRV-390, extended by APRV-424).
217
218
  *
218
- * ONE `getMe`, once per process, before the first `getUpdates`. Two things
219
- * come out of it: the bot's identity, which is the only thing that can tell
220
- * two instances holding two differently-named copies of one token apart; and
221
- * a claim in the per-machine registry, which is what makes the SECOND such
222
- * listener refuse instead of joining a 409 loop.
219
+ * Three questions, in order, and each one has its own authority:
223
220
  *
224
- * ## Why an unreachable Bot API is not a refusal
221
+ * 1. **Does anything else in THIS gate already hold the Telegram transport?**
222
+ * A lockfile in the gate's own `daemon/` directory (`core/channel-lease.ts`)
223
+ * answers it, and the answer is per PROCESS. This is the check the review of
224
+ * APRV-424 added, and the hole it closes is the one neither of the other two
225
+ * could see: an `approval up` long-polling and an `approval channel telegram
226
+ * webhook` started in the same project pass both of them — `getWebhookInfo`
227
+ * is empty while the poller is the one running, and the ownership registry
228
+ * compares instance ids, which are equal because it IS the same instance —
229
+ * and then each runs its own dispatch cycle over its own state against one
230
+ * log, so every request reaches the phone twice under two nonces and only
231
+ * one copy can resolve a tap.
232
+ * 2. **What is the Bot API delivering this bot's updates to?** `getWebhookInfo`
233
+ * answers it, and it is the only thing that can see a webhook registered
234
+ * from another machine. A webhook beats a poller outright — `getUpdates` is
235
+ * refused while one is set — so any registration refuses a poller.
236
+ * 3. **Does another INSTANCE on this machine hold this bot?** `getMe` plus the
237
+ * per-machine registry answers it (APRV-390's incident: two gates, one
238
+ * token, two names, a 409 on every poll).
225
239
  *
226
- * A `getMe` that fails says nothing about ownership. The machine may be behind
227
- * a captive portal, the API may be rate-limiting, the network may be down for
228
- * four seconds. Refusing to start on that would mean a transient network fault
229
- * took the phone channel down until somebody noticed, in exchange for no
230
- * safety: an unreachable Bot API is also a `getUpdates` that cannot conflict
231
- * with anything. So the preflight says what happened and lets the listener
232
- * start, where the existing retry loop is already the right behaviour. The
233
- * refusal is reserved for the case this task is about, which is a bot that is
234
- * demonstrably somebody else's.
240
+ * ## An unreachable Bot API: fail-soft for a poller, fail-closed for a webhook
241
+ *
242
+ * A `getMe` or a `getWebhookInfo` that fails says nothing about ownership. The
243
+ * machine may be behind a captive portal, the API may be rate-limiting, the
244
+ * network may be down for four seconds. For a POLLER, refusing on that would
245
+ * mean a transient network fault took the phone channel down until somebody
246
+ * noticed, in exchange for no safety: an unreachable Bot API is also a
247
+ * `getUpdates` that cannot conflict with anything, and the HTTP 409 the loop
248
+ * already reports is the backstop. So the poller says what happened and starts.
249
+ *
250
+ * For the WEBHOOK VERB there is no such backstop, and the review of APRV-424
251
+ * turned this direction around. Its next act is `setWebhook`, which overwrites
252
+ * whatever registration exists without asking, so proceeding on an unknown
253
+ * answer is proceeding to take another host's taps with no error anywhere. A
254
+ * probe it could not make is therefore a refusal (`webhook-probe-failed`), and
255
+ * the operator retries or passes `--reclaim` deliberately.
235
256
  */
236
- export declare function claimListenerBot(setup: ListenSetup, report: (message: string) => void): Promise<{
257
+ export declare function claimListenerBot(setup: ListenSetup, report: (message: string) => void, options?: {
258
+ /**
259
+ * The webhook URL THIS process is about to register, when it is a webhook
260
+ * runner rather than a poller (APRV-424).
261
+ *
262
+ * Absent for a poller. Present for the webhook verb, and then it is the
263
+ * url a `--reclaim` is measured against: `setWebhook` is idempotent, so a
264
+ * restart re-registering its own url is the ordinary case, while a
265
+ * DIFFERENT url is a second host about to take the first host's taps.
266
+ */
267
+ webhookUrl?: string;
268
+ /**
269
+ * Register over an existing webhook (`--reclaim`, APRV-424 review finding
270
+ * 6).
271
+ *
272
+ * Without it, ANY registration refuses — including one at the same url,
273
+ * which used to be waved through on a bare string compare. Two hosts
274
+ * sharing one configuration both passed that check, the second overwrote
275
+ * the first's `secret_token`, and from then on every real tap arrived at
276
+ * the first host with a secret it did not recognise: a forgery, as far as
277
+ * it could tell, on every press of a button that had worked an hour
278
+ * earlier. So taking over is now a thing the operator says out loud.
279
+ */
280
+ reclaim?: boolean;
281
+ /**
282
+ * Which transport this process is about to run, for the lease.
283
+ *
284
+ * Derived from {@link webhookUrl} when it is not given, because the two
285
+ * callers that pass a url are the two that run a webhook.
286
+ */
287
+ mode?: ChannelLeaseMode;
288
+ }): Promise<ClaimedListenerBot>;
289
+ /**
290
+ * What {@link claimListenerBot} answers.
291
+ *
292
+ * The lease travels with the success, because the caller is the only thing
293
+ * that knows when this process has stopped receiving: `runListener`,
294
+ * `approval up` and `runWebhook` each release it on their way out, and a
295
+ * refusal releases nothing because it took nothing.
296
+ */
297
+ export type ClaimedListenerBot = {
237
298
  ok: true;
299
+ lease: ChannelLease;
238
300
  } | {
239
301
  ok: false;
240
302
  code: ListenRefusalCode;
241
303
  message: string;
242
- }>;
304
+ };
243
305
  /**
244
306
  * What to append to a runtime 409, naming the other instance if one is known.
245
307
  *
@@ -279,7 +341,55 @@ export declare const LISTEN_REFUSAL_CODES: readonly [
279
341
  * (APRV-390). Refused BEFORE the first `getUpdates`, so the operator reads
280
342
  * which two gates are involved instead of an HTTP 409 loop.
281
343
  */
282
- "bot-owned-elsewhere"];
344
+ "bot-owned-elsewhere",
345
+ /**
346
+ * This bot's updates are being delivered to a webhook (APRV-424).
347
+ *
348
+ * The two transports are alternatives per bot: the Bot API refuses
349
+ * `getUpdates` outright while a webhook is set, so a listener that started
350
+ * here would print a 409 every few seconds and receive not one tap. Refused
351
+ * BEFORE the first poll, in the same preflight and for the same reason
352
+ * `bot-owned-elsewhere` is, so the operator reads which transport owns the
353
+ * bot instead of a status code.
354
+ *
355
+ * Since the review of APRV-424 it carries a second, local source: the
356
+ * transport lease in this gate's own `daemon/` directory, when the process
357
+ * holding it is a webhook runner. Same fact, same repair, so the same code.
358
+ */
359
+ "webhook-registered",
360
+ /**
361
+ * A long-poll listener in THIS gate already holds the Telegram transport
362
+ * (APRV-424 review finding 1).
363
+ *
364
+ * The counterpart to `webhook-registered`, from the same lease. It is what
365
+ * the webhook verb meets when an `approval up` or an `approval channel
366
+ * telegram listen` is already running in the same project — the case
367
+ * `getWebhookInfo` cannot see (nothing is registered yet) and the ownership
368
+ * registry cannot see either (it is the same instance). Two of them on one
369
+ * log put every prompt on the phone twice, under two nonces, and only one
370
+ * copy can resolve a tap.
371
+ */
372
+ "telegram-poller-running",
373
+ /**
374
+ * The transport lease could not be taken at all (APRV-424 review finding 1).
375
+ *
376
+ * A `daemon/` directory that cannot be created, a lockfile that cannot be
377
+ * written. Unlike the bot registry, whose absence is the status quo, this
378
+ * file is the only thing keeping one gate from running two transports, so a
379
+ * gate that cannot hold one does not start.
380
+ */
381
+ "telegram-lease-unavailable",
382
+ /**
383
+ * The webhook verb could not learn what already holds this bot (APRV-424
384
+ * review finding 8).
385
+ *
386
+ * `getMe` or `getWebhookInfo` failed, and the next act would have been a
387
+ * `setWebhook` that overwrites a registration nobody saw. A poller keeps its
388
+ * fail-soft on the same failure, because an unreachable Bot API is also a
389
+ * `getUpdates` that cannot conflict and the HTTP 409 loop is its backstop;
390
+ * this verb has no backstop, so it refuses.
391
+ */
392
+ "webhook-probe-failed"];
283
393
  export type ListenRefusalCode = (typeof LISTEN_REFUSAL_CODES)[number];
284
394
  /** Everything {@link prepareListen} needs, already resolved to absolute paths. */
285
395
  export interface ListenRequest {
@@ -443,9 +553,15 @@ export interface PacedState {
443
553
  /**
444
554
  * Every pending action key, in the order this process will show them.
445
555
  *
446
- * Seeded from log order (oldest first, which is what `buildPendingQueue`
447
- * returns) and rearranged by `/skip` alone. Keys the log no longer calls
448
- * pending are dropped on every cycle, and newly pending ones join the back.
556
+ * Seeded from `orderPending`'s order (live newest first, then stale oldest
557
+ * first, attestation prompts last — APRV-425; it was log order before that)
558
+ * and rearranged by `/skip` alone. Keys the log no longer calls pending are
559
+ * dropped on every cycle, and newly pending ones join the back.
560
+ *
561
+ * The ordering reaches this only through the SEEDING, which is the property
562
+ * that matters for `/skip`: a key already in the list keeps the place the
563
+ * approver's own navigation gave it, and only keys this process has not seen
564
+ * before are inserted in the new order.
449
565
  */
450
566
  order: string[];
451
567
  /**
@@ -666,10 +782,12 @@ export interface DispatchResult {
666
782
  * Action keys dropped from the delivery bookkeeping this cycle (APRV-196),
667
783
  * with why. Neither kind can cost a re-send: the pending queue is the log's
668
784
  * answer, and a dropped key that is still pending is simply re-delivered.
785
+ * `released` (APRV-442) is the one kind that is dropped BECAUSE it is still
786
+ * pending: a refused tap disarmed its card, and this cycle re-offers it.
669
787
  */
670
788
  pruned: {
671
789
  action_key: string;
672
- reason: "settled" | "stale";
790
+ reason: "settled" | "stale" | "released";
673
791
  }[];
674
792
  /**
675
793
  * The collapsed re-delivery this cycle sent, when it sent one (APRV-287):
@@ -748,8 +866,118 @@ export declare function dispatchPending(setup: ListenSetup, streams: Streams, st
748
866
  * it takes to say they are there.
749
867
  */
750
868
  export declare const COLLAPSE_STALE_AFTER_MS: number;
751
- /** The computed lines a collapsed re-delivery leads with (APRV-287). */
752
- export declare function staleLines(requests: ChannelRequest[], now: string): string[];
869
+ /**
870
+ * Pending requests a NEWER pending request has superseded (APRV-425).
871
+ *
872
+ * Two requests naming the same payload bytes and the same class are two askings
873
+ * of one question, and only the newer one has an asker. The shape that produces
874
+ * them is APRV-287's own: a hook whose wait ran out leaves its request open for
875
+ * the retry grace, the grace runs out, the hook withdraws it on its NEXT
876
+ * invocation — and if that next invocation never comes while a later session
877
+ * asks the same thing, both sit in the queue. Dogfooding produced exactly this
878
+ * complaint (APRV-118): a live prompt buried behind dead ones, and an approver
879
+ * rejecting the one they wanted.
880
+ *
881
+ * Keyed by `(payload_hash, class)` and not by task, because the task id a
882
+ * harness adapter mints is fresh per tool call (SPEC.md §10.2), so two askings
883
+ * of one command never share one. The bytes and the class are what a decision
884
+ * binds to, which is what makes them the right identity here.
885
+ *
886
+ * Computed from the pending set alone, which is re-derived from the verified log
887
+ * every cycle, so this decides nothing and remembers nothing. A superseded
888
+ * request is COLLAPSED, never closed: it stays pending in the log, listable, and
889
+ * decidable from any copy already delivered. Only a human's decision or the
890
+ * requester's own withdrawal ends it.
891
+ */
892
+ export declare function supersededPending(requests: ChannelRequest[]): Set<string>;
893
+ /**
894
+ * The pending set in the order an approver should meet it (APRV-425).
895
+ *
896
+ * Three rules, in this order, and each is a complaint from running the gate:
897
+ *
898
+ * 1. **Attestation prompts last.** `buildPendingQueue` puts them there on
899
+ * purpose: a policy amendment changes the rules every entry above it was
900
+ * routed by, so an approver reading top to bottom answers the questions asked
901
+ * under the current policy before changing what the current policy is. That
902
+ * placement is not this function's to relitigate, so proposals are lifted
903
+ * out, ordered among themselves by nothing at all (log order), and put back
904
+ * at the end.
905
+ * 2. **Live requests first, newest first.** Live means younger than
906
+ * {@link COLLAPSE_STALE_AFTER_MS}, the hook's wait plus its retry grace,
907
+ * which is the same boundary the collapse uses — one number, one meaning of
908
+ * "somebody may still be holding this". Newest first because the newest is
909
+ * the one most likely to have a tool call blocked on it right now, and the
910
+ * observed failure was a live prompt buried behind dead ones.
911
+ * 3. **Stale requests after them, oldest first.** They are what the collapse
912
+ * takes on a first cycle, and where the collapse does not apply (fewer than
913
+ * {@link COLLAPSE_MIN} of them) oldest-first is the order to work through a
914
+ * backlog in.
915
+ *
916
+ * Stable inside each bucket, so log order breaks every tie and the result is
917
+ * deterministic for one log and one instant. It is an ORDER and nothing else:
918
+ * no request is dropped, none is decided, and the set that comes out is the set
919
+ * that went in.
920
+ */
921
+ export declare function orderPending(requests: ChannelRequest[], now: string): ChannelRequest[];
922
+ /**
923
+ * The computed lines a collapsed re-delivery leads with (APRV-287).
924
+ *
925
+ * `superseded` is the subset a newer pending request replaced (APRV-425), and
926
+ * the first line states the split rather than claiming every member is old.
927
+ * Before this the line said "all older than the hook's wait plus its retry
928
+ * grace", which stopped being true the moment the collapse widened: a message
929
+ * that overstates what it collapsed is the stale-documentation failure in
930
+ * message form, and this one is read by the person deciding.
931
+ */
932
+ export declare function staleLines(requests: ChannelRequest[], now: string, superseded?: ReadonlySet<string>): string[];
933
+ /**
934
+ * Put the requests nobody is waiting on into ONE message, and hand back the
935
+ * ones that still get a message each (APRV-287, widened by APRV-425).
936
+ *
937
+ * Called on a process's first cycle only, which is exactly a daemon start or a
938
+ * listener reconnect. Everything it does is bookkeeping in the sense SPEC.md
939
+ * §10.3 fixes: the pending set is re-derived from the verified log every cycle,
940
+ * so a summary that fails to send, or a process that forgets it sent one,
941
+ * degrades to showing those requests again, and never to a pending request
942
+ * nobody is shown.
943
+ *
944
+ * ## Two ways in, one exit (APRV-425)
945
+ *
946
+ * A request is collapsed when it is older than the hook's wait plus its retry
947
+ * grace (nobody is holding it), or when a NEWER pending request names the same
948
+ * payload bytes and class ({@link supersededPending} — the newer one is the live
949
+ * asking, whatever the age of either). The second is what answers the observed
950
+ * complaint that a live prompt arrives buried behind dead ones.
951
+ *
952
+ * ## This is where the sent-record is rebuilt from the log (AC3)
953
+ *
954
+ * Every collapsed member is written into `state.delivered` and `state.sentAtMs`
955
+ * below, and the set it is written from is the pending set re-derived from the
956
+ * verified log. That is the whole of the rebuilding, and it is deliberately not
957
+ * a second mechanism: the log is the only place the question "what is pending"
958
+ * is answered.
959
+ *
960
+ * What it is NOT is evidence of delivery, and the difference is load-bearing.
961
+ * Nothing reads this record to conclude that an approver saw anything: a
962
+ * collapsed request stays pending in the log, is listed by `/queue`, and is
963
+ * decidable from any copy already delivered, because APRV-196 made
964
+ * `callback_data` carry a restart-stable action ref so a button on a
965
+ * pre-restart copy still decides the request. Lose the record and the next
966
+ * cycle shows the requests again, which is the degradation SPEC.md §10.3
967
+ * requires and the one this code takes.
968
+ */
969
+ /**
970
+ * The members a first-cycle collapse would put into one message: stale or
971
+ * superseded, and never a proposal (APRV-445 refutation, S2). Proposals are
972
+ * long-lived by design, so after a six-minute outage every one of them would
973
+ * otherwise land in one digest whose only bulk answer is reject-all.
974
+ */
975
+ export declare function collapsibleStale(undecided: readonly ChannelRequest[], now: string, superseded?: ReadonlySet<string>): ChannelRequest[];
976
+ /**
977
+ * Report a steady-state cycle's problems on stderr. Startup reports its own,
978
+ * as exit codes, in {@link runListener}.
979
+ */
980
+ export declare function reportCycle(result: DispatchResult, streams: Streams): void;
753
981
  export declare function checkpointHandlerFor(setup: ListenSetup, streams: Streams): (tap: {
754
982
  sign: boolean;
755
983
  head: {
@@ -857,6 +1085,24 @@ export interface RunningListener {
857
1085
  * queue from the verified log and re-sends everything still pending, exactly as
858
1086
  * a restarted process would. A duplicate on the phone, never a silence.
859
1087
  */
1088
+ /**
1089
+ * Give the channel every handler the runtime answers a gesture with, and hand
1090
+ * back the fresh dispatch bookkeeping (APRV-424).
1091
+ *
1092
+ * Extracted from {@link startListener} so the webhook runner wires the SAME
1093
+ * four handlers rather than a second set that looks like them. This is the
1094
+ * CLI-side half of the property APRV-424 is about: the transport decides where
1095
+ * an update arrives, and nothing else. A tap that arrives by webhook is
1096
+ * recorded by `handlerFor`'s `recordChannelDecision` — the same actor, the
1097
+ * same sender resolution, the same gate — because it is the same function
1098
+ * object, registered here.
1099
+ *
1100
+ * A FRESH {@link DispatchState} per call, which is the whole of the restart
1101
+ * story: a supervisor that restarts a fallen runner re-derives the pending
1102
+ * queue from the verified log and re-sends everything still pending. A
1103
+ * duplicate on the phone, never a silence.
1104
+ */
1105
+ export declare function wireListener(setup: ListenSetup, streams: Streams): DispatchState;
860
1106
  export declare function startListener(setup: ListenSetup, streams: Streams): RunningListener;
861
1107
  /**
862
1108
  * The listener verb. Returns a promise, which is why `main` treats `channel`