approval-md 0.3.0 → 0.4.1

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 (270) hide show
  1. package/README.md +83 -914
  2. package/SPEC.md +101 -13
  3. package/cli.js +134 -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 +72 -0
  8. package/dist/src/channels/contract.js +161 -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.d.ts +25 -0
  17. package/dist/src/channels/tagging.js +63 -6
  18. package/dist/src/channels/tagging.js.map +1 -1
  19. package/dist/src/channels/telegram-minimal.d.ts +251 -0
  20. package/dist/src/channels/telegram-minimal.js +618 -0
  21. package/dist/src/channels/telegram-minimal.js.map +1 -0
  22. package/dist/src/channels/telegram-webhook.d.ts +273 -0
  23. package/dist/src/channels/telegram-webhook.js +536 -0
  24. package/dist/src/channels/telegram-webhook.js.map +1 -0
  25. package/dist/src/channels/telegram.d.ts +725 -20
  26. package/dist/src/channels/telegram.js +1332 -123
  27. package/dist/src/channels/telegram.js.map +1 -1
  28. package/dist/src/cli/amend.js +358 -5
  29. package/dist/src/cli/amend.js.map +1 -1
  30. package/dist/src/cli/attest.js +43 -6
  31. package/dist/src/cli/attest.js.map +1 -1
  32. package/dist/src/cli/audit-card.d.ts +1 -1
  33. package/dist/src/cli/audit-card.js +40 -1
  34. package/dist/src/cli/audit-card.js.map +1 -1
  35. package/dist/src/cli/audit.d.ts +7 -5
  36. package/dist/src/cli/audit.js +22 -10
  37. package/dist/src/cli/audit.js.map +1 -1
  38. package/dist/src/cli/channel-relay.d.ts +108 -0
  39. package/dist/src/cli/channel-relay.js +334 -0
  40. package/dist/src/cli/channel-relay.js.map +1 -0
  41. package/dist/src/cli/channel-telegram-webhook.d.ts +275 -0
  42. package/dist/src/cli/channel-telegram-webhook.js +716 -0
  43. package/dist/src/cli/channel-telegram-webhook.js.map +1 -0
  44. package/dist/src/cli/channel-telegram.d.ts +347 -28
  45. package/dist/src/cli/channel-telegram.js +648 -56
  46. package/dist/src/cli/channel-telegram.js.map +1 -1
  47. package/dist/src/cli/channel.d.ts +1 -1
  48. package/dist/src/cli/channel.js +5 -1
  49. package/dist/src/cli/channel.js.map +1 -1
  50. package/dist/src/cli/daemon.js +37 -5
  51. package/dist/src/cli/daemon.js.map +1 -1
  52. package/dist/src/cli/doctor.d.ts +63 -0
  53. package/dist/src/cli/doctor.js +856 -111
  54. package/dist/src/cli/doctor.js.map +1 -1
  55. package/dist/src/cli/execute.d.ts +29 -1
  56. package/dist/src/cli/execute.js +387 -21
  57. package/dist/src/cli/execute.js.map +1 -1
  58. package/dist/src/cli/exit-codes.d.ts +12 -0
  59. package/dist/src/cli/exit-codes.js +13 -0
  60. package/dist/src/cli/exit-codes.js.map +1 -1
  61. package/dist/src/cli/gate.d.ts +2 -0
  62. package/dist/src/cli/gate.js +233 -2
  63. package/dist/src/cli/gate.js.map +1 -1
  64. package/dist/src/cli/help.d.ts +10 -1
  65. package/dist/src/cli/help.js +283 -54
  66. package/dist/src/cli/help.js.map +1 -1
  67. package/dist/src/cli/hook.d.ts +485 -6
  68. package/dist/src/cli/hook.js +2370 -70
  69. package/dist/src/cli/hook.js.map +1 -1
  70. package/dist/src/cli/init.js +16 -7
  71. package/dist/src/cli/init.js.map +1 -1
  72. package/dist/src/cli/instructions.js +24 -3
  73. package/dist/src/cli/instructions.js.map +1 -1
  74. package/dist/src/cli/log-anchor.d.ts +55 -0
  75. package/dist/src/cli/log-anchor.js +199 -60
  76. package/dist/src/cli/log-anchor.js.map +1 -1
  77. package/dist/src/cli/log-unlock.d.ts +23 -0
  78. package/dist/src/cli/log-unlock.js +109 -0
  79. package/dist/src/cli/log-unlock.js.map +1 -0
  80. package/dist/src/cli/main.d.ts +0 -12
  81. package/dist/src/cli/main.js +72 -4
  82. package/dist/src/cli/main.js.map +1 -1
  83. package/dist/src/cli/muse.d.ts +2 -0
  84. package/dist/src/cli/muse.js +62 -0
  85. package/dist/src/cli/muse.js.map +1 -0
  86. package/dist/src/cli/payload.js +79 -1
  87. package/dist/src/cli/payload.js.map +1 -1
  88. package/dist/src/cli/scaffold.js +6 -0
  89. package/dist/src/cli/scaffold.js.map +1 -1
  90. package/dist/src/cli/serve.d.ts +53 -0
  91. package/dist/src/cli/serve.js +270 -0
  92. package/dist/src/cli/serve.js.map +1 -0
  93. package/dist/src/cli/up.js +26 -2
  94. package/dist/src/cli/up.js.map +1 -1
  95. package/dist/src/cli/verb-registry.d.ts +2 -0
  96. package/dist/src/cli/verb-registry.js +338 -39
  97. package/dist/src/cli/verb-registry.js.map +1 -1
  98. package/dist/src/cli/wordmark.d.ts +2 -2
  99. package/dist/src/cli/wordmark.js +2 -2
  100. package/dist/src/core/attest-bootstrap.d.ts +95 -0
  101. package/dist/src/core/attest-bootstrap.js +135 -0
  102. package/dist/src/core/attest-bootstrap.js.map +1 -0
  103. package/dist/src/core/attest.d.ts +20 -3
  104. package/dist/src/core/attest.js +25 -0
  105. package/dist/src/core/attest.js.map +1 -1
  106. package/dist/src/core/audit.d.ts +153 -12
  107. package/dist/src/core/audit.js +415 -20
  108. package/dist/src/core/audit.js.map +1 -1
  109. package/dist/src/core/channel-lease.d.ts +322 -0
  110. package/dist/src/core/channel-lease.js +663 -0
  111. package/dist/src/core/channel-lease.js.map +1 -0
  112. package/dist/src/core/command-class.d.ts +51 -0
  113. package/dist/src/core/command-class.js +766 -8
  114. package/dist/src/core/command-class.js.map +1 -1
  115. package/dist/src/core/daemon-host.d.ts +178 -0
  116. package/dist/src/core/daemon-host.js +228 -0
  117. package/dist/src/core/daemon-host.js.map +1 -0
  118. package/dist/src/core/daemon-identity.d.ts +238 -0
  119. package/dist/src/core/daemon-identity.js +252 -0
  120. package/dist/src/core/daemon-identity.js.map +1 -0
  121. package/dist/src/core/gate.d.ts +364 -6
  122. package/dist/src/core/gate.js +802 -27
  123. package/dist/src/core/gate.js.map +1 -1
  124. package/dist/src/core/harness-version.d.ts +128 -4
  125. package/dist/src/core/harness-version.js +179 -12
  126. package/dist/src/core/harness-version.js.map +1 -1
  127. package/dist/src/core/harness-wait.d.ts +82 -3
  128. package/dist/src/core/harness-wait.js +89 -3
  129. package/dist/src/core/harness-wait.js.map +1 -1
  130. package/dist/src/core/log-lock.d.ts +435 -0
  131. package/dist/src/core/log-lock.js +1093 -0
  132. package/dist/src/core/log-lock.js.map +1 -0
  133. package/dist/src/core/log-subscribe.d.ts +21 -0
  134. package/dist/src/core/log-subscribe.js +16 -6
  135. package/dist/src/core/log-subscribe.js.map +1 -1
  136. package/dist/src/core/log-write-layer.d.ts +55 -0
  137. package/dist/src/core/log-write-layer.js +91 -0
  138. package/dist/src/core/log-write-layer.js.map +1 -0
  139. package/dist/src/core/log.d.ts +130 -22
  140. package/dist/src/core/log.js +473 -50
  141. package/dist/src/core/log.js.map +1 -1
  142. package/dist/src/core/payload-census.d.ts +51 -0
  143. package/dist/src/core/payload-census.js +125 -2
  144. package/dist/src/core/payload-census.js.map +1 -1
  145. package/dist/src/core/payload-store.d.ts +31 -0
  146. package/dist/src/core/payload-store.js +113 -8
  147. package/dist/src/core/payload-store.js.map +1 -1
  148. package/dist/src/core/payload.d.ts +18 -3
  149. package/dist/src/core/payload.js +20 -4
  150. package/dist/src/core/payload.js.map +1 -1
  151. package/dist/src/core/policy-diff.d.ts +10 -0
  152. package/dist/src/core/policy-diff.js +10 -2
  153. package/dist/src/core/policy-diff.js.map +1 -1
  154. package/dist/src/core/policy-explain.d.ts +7 -1
  155. package/dist/src/core/policy-explain.js +16 -1
  156. package/dist/src/core/policy-explain.js.map +1 -1
  157. package/dist/src/core/policy-load.d.ts +24 -0
  158. package/dist/src/core/policy-load.js.map +1 -1
  159. package/dist/src/core/policy-match.d.ts +38 -0
  160. package/dist/src/core/policy-match.js +35 -0
  161. package/dist/src/core/policy-match.js.map +1 -1
  162. package/dist/src/core/policy-proposal.d.ts +40 -0
  163. package/dist/src/core/policy-proposal.js +37 -16
  164. package/dist/src/core/policy-proposal.js.map +1 -1
  165. package/dist/src/core/prompt-layout.d.ts +186 -1
  166. package/dist/src/core/prompt-layout.js +345 -3
  167. package/dist/src/core/prompt-layout.js.map +1 -1
  168. package/dist/src/core/read-scope.d.ts +10 -0
  169. package/dist/src/core/read-scope.js +4 -0
  170. package/dist/src/core/read-scope.js.map +1 -1
  171. package/dist/src/core/run-payload.d.ts +160 -0
  172. package/dist/src/core/run-payload.js +304 -0
  173. package/dist/src/core/run-payload.js.map +1 -0
  174. package/dist/src/core/sender-identity.d.ts +59 -11
  175. package/dist/src/core/sender-identity.js +79 -11
  176. package/dist/src/core/sender-identity.js.map +1 -1
  177. package/dist/src/core/state.d.ts +52 -1
  178. package/dist/src/core/state.js +52 -6
  179. package/dist/src/core/state.js.map +1 -1
  180. package/dist/src/core/telegram-config.d.ts +79 -0
  181. package/dist/src/core/telegram-config.js +108 -0
  182. package/dist/src/core/telegram-config.js.map +1 -1
  183. package/dist/src/core/validate.d.ts +20 -6
  184. package/dist/src/core/validate.js +0 -0
  185. package/dist/src/core/validate.js.map +1 -1
  186. package/dist/src/core/verify.d.ts +23 -1
  187. package/dist/src/core/verify.js +20 -2
  188. package/dist/src/core/verify.js.map +1 -1
  189. package/dist/src/daemon/audit.d.ts +80 -5
  190. package/dist/src/daemon/audit.js +126 -6
  191. package/dist/src/daemon/audit.js.map +1 -1
  192. package/dist/src/daemon/daemon.d.ts +174 -2
  193. package/dist/src/daemon/daemon.js +298 -7
  194. package/dist/src/daemon/daemon.js.map +1 -1
  195. package/dist/src/daemon/git-evidence.d.ts +2 -2
  196. package/dist/src/daemon/git-evidence.js +1 -1
  197. package/dist/src/daemon/projection.d.ts +13 -2
  198. package/dist/src/daemon/projection.js +39 -6
  199. package/dist/src/daemon/projection.js.map +1 -1
  200. package/dist/src/mcp/server.d.ts +39 -3
  201. package/dist/src/mcp/server.js +22 -3
  202. package/dist/src/mcp/server.js.map +1 -1
  203. package/dist/src/muse/server.d.ts +16 -0
  204. package/dist/src/muse/server.js +238 -0
  205. package/dist/src/muse/server.js.map +1 -0
  206. package/dist/src/serve/archive.d.ts +166 -0
  207. package/dist/src/serve/archive.js +363 -0
  208. package/dist/src/serve/archive.js.map +1 -0
  209. package/dist/src/serve/arguments.d.ts +93 -0
  210. package/dist/src/serve/arguments.js +228 -0
  211. package/dist/src/serve/arguments.js.map +1 -0
  212. package/dist/src/serve/credentials.d.ts +91 -0
  213. package/dist/src/serve/credentials.js +143 -0
  214. package/dist/src/serve/credentials.js.map +1 -0
  215. package/dist/src/serve/follow.d.ts +86 -0
  216. package/dist/src/serve/follow.js +101 -0
  217. package/dist/src/serve/follow.js.map +1 -0
  218. package/dist/src/serve/hook-thread.d.ts +134 -0
  219. package/dist/src/serve/hook-thread.js +333 -0
  220. package/dist/src/serve/hook-thread.js.map +1 -0
  221. package/dist/src/serve/hook-worker.d.ts +134 -0
  222. package/dist/src/serve/hook-worker.js +173 -0
  223. package/dist/src/serve/hook-worker.js.map +1 -0
  224. package/dist/src/serve/server.d.ts +412 -0
  225. package/dist/src/serve/server.js +1251 -0
  226. package/dist/src/serve/server.js.map +1 -0
  227. package/docs/README-extended.md +768 -0
  228. package/docs/cli-reference.md +2139 -67
  229. package/package.json +4 -2
  230. package/schema/event.schema.json +413 -30
  231. package/schema/fixtures/event/invalid/audit-lock-reclaimed-age-without-created.json +19 -0
  232. package/schema/fixtures/event/invalid/audit-lock-reclaimed-agent-actor.json +14 -0
  233. package/schema/fixtures/event/invalid/audit-lock-reclaimed-lockfile-path.json +14 -0
  234. package/schema/fixtures/event/invalid/audit-lock-reclaimed-operator-cleared-system-actor.json +14 -0
  235. package/schema/fixtures/event/invalid/audit-lock-reclaimed-unknown-reason.json +14 -0
  236. package/schema/fixtures/event/invalid/audit-lock-reclaimed-without-age.json +13 -0
  237. package/schema/fixtures/event/invalid/audit-reviewed-agent-actor.json +6 -1
  238. package/schema/fixtures/event/invalid/audit-reviewed-bad-payload-hash.json +21 -0
  239. package/schema/fixtures/event/invalid/audit-reviewed-loved-no-note.json +5 -0
  240. package/schema/fixtures/event/invalid/audit-reviewed-no-subject-hash.json +19 -0
  241. package/schema/fixtures/event/invalid/audit-reviewed-no-subject-seq.json +19 -0
  242. package/schema/fixtures/event/invalid/audit-reviewed-no-verdict-source.json +19 -0
  243. package/schema/fixtures/event/invalid/audit-reviewed-no-verdict.json +19 -0
  244. package/schema/fixtures/event/invalid/audit-reviewed-system-actor.json +6 -1
  245. package/schema/fixtures/event/invalid/audit-sampled-no-policy-hash.json +14 -0
  246. package/schema/fixtures/event/invalid/daemon-id-malformed.json +15 -0
  247. package/schema/fixtures/event/invalid/execution-started-truncated-policy-sha256.json +18 -0
  248. package/schema/fixtures/event/invalid/harness-cap-at-margin.json +16 -0
  249. package/schema/fixtures/event/invalid/harness-cap-fractional.json +16 -0
  250. package/schema/fixtures/event/invalid/harness-cap-negative.json +16 -0
  251. package/schema/fixtures/event/invalid/harness-cap-string.json +16 -0
  252. package/schema/fixtures/event/invalid/harness-cap-without-harness-execution.json +16 -0
  253. package/schema/fixtures/event/invalid/harness-cap-zero.json +16 -0
  254. package/schema/fixtures/event/valid/approval-requested-harness-cap.json +18 -0
  255. package/schema/fixtures/event/valid/audit-lock-reclaimed-implausible-created.json +18 -0
  256. package/schema/fixtures/event/valid/audit-lock-reclaimed-legacy.json +14 -0
  257. package/schema/fixtures/event/valid/audit-lock-reclaimed-unlock.json +19 -0
  258. package/schema/fixtures/event/valid/audit-lock-reclaimed.json +19 -0
  259. package/schema/fixtures/event/valid/audit-reviewed-reaction.json +5 -0
  260. package/schema/fixtures/event/valid/audit-reviewed.json +6 -1
  261. package/schema/fixtures/event/valid/audit-sampled.json +2 -1
  262. package/schema/fixtures/event/valid/daemon-identity-declared.json +17 -0
  263. package/schema/fixtures/event/valid/daemon-identity.json +16 -0
  264. package/schema/fixtures/event/valid/execution-started-policy-sha256.json +18 -0
  265. package/schema/fixtures/event/valid/harness-kind-hermes.json +23 -0
  266. package/schema/fixtures/policy/invalid/daemons-malformed-id.json +10 -0
  267. package/schema/fixtures/policy/valid/daemons-allowlist.json +19 -0
  268. package/schema/fixtures/policy-md/invalid/schema-invalid-agent-may-request.md +21 -0
  269. package/schema/fixtures/policy-md/valid/agent-may-request.md +24 -0
  270. package/schema/policy.schema.json +102 -6
package/cli.js CHANGED
@@ -9,22 +9,149 @@
9
9
  * The exit code is set via `process.exitCode` rather than `process.exit()`, so
10
10
  * stdout is flushed by the normal exit path — a JSON object truncated by an
11
11
  * early exit would be worse than no output.
12
+ *
13
+ * ONE exception to "no behaviour here" (APRV-445 refutation, S3): the Hermes
14
+ * hook. Hermes reads any non-zero exit with an EMPTY stdout as an ALLOW, so a
15
+ * failure to load the runtime at all (a missing or half-written dist/, a
16
+ * static import that throws) must still answer with a block. That is the only
17
+ * thing this file can do that the runtime cannot: it runs before the runtime
18
+ * exists. For `approval hook hermes` it prints `{"action":"block",...}` and
19
+ * exits 2 on any failure to load or run, and on a SIGTERM or SIGINT that lands
20
+ * before the runtime's own guard is listening (APRV-466); every other
21
+ * invocation keeps its old behaviour exactly.
12
22
  */
13
23
 
14
- import { existsSync } from "node:fs";
24
+ import { existsSync, writeSync } from "node:fs";
25
+
26
+ const argv = process.argv.slice(2);
27
+ // Matched the way `main` dispatches it: `--no-color` is the one global flag it
28
+ // strips, wherever it appears (APRV-445 recheck L-d).
29
+ const dispatched = argv.filter((word) => word !== "--no-color");
30
+ const hermesHook = dispatched[0] === "hook" && dispatched[1] === "hermes";
31
+
32
+ /** Has anything reached stdout? Tracked only for the Hermes hook. */
33
+ let printed = false;
34
+ /** Has `main` returned its verdict to this file? */
35
+ let answered = false;
36
+
37
+ /**
38
+ * The runtime's `hook-interrupted` directive, byte for byte
39
+ * (`hermesInterruptedDirective` in src/cli/hook.ts). Spelled by hand because a
40
+ * signal can land before that module exists in this process;
41
+ * `tests/hermes-bin-signal-guard.test.ts` pins the two equal.
42
+ */
43
+ function hermesInterrupted(signal) {
44
+ return `${JSON.stringify({ action: "block", message: `hook-interrupted: the hook received ${signal} before it reached a verdict; nothing authorizes this call` })}\n`;
45
+ }
46
+
47
+ // The first guard (APRV-466), installed before anything else runs. The default
48
+ // disposition of SIGTERM and SIGINT is to die with nothing on stdout, which
49
+ // Hermes reads as an ALLOW, and Hermes sends SIGTERM on its hook timeout and on
50
+ // gateway shutdown. Until now the earliest handler was the runtime's own
51
+ // (`hermesFailClosed`), so a signal during the ESM load of dist/ (the longest
52
+ // stretch of a cold start) took the default action.
53
+ //
54
+ // A JS signal listener runs only when the event loop turns. So this guard
55
+ // prints the directive when a signal is dispatched while dist/ is loading and
56
+ // the load yields to the loop (it does on Node 24, which turned the loop about
57
+ // thirty times during the load; on Node 26 the load turned it zero times). A
58
+ // signal that is caught but not dispatched during the load is held into the
59
+ // hook run, which turns the loop at every pause since APRV-473: between the
60
+ // wait's polls and once before anything records `execution.started`. There the
61
+ // runtime's own guards answer it (the wait's handler withdraws the question
62
+ // first). A signal that lands after the run's last pause is dispatched after
63
+ // the hook has answered: then `answered` is set (in the same microtask drain as
64
+ // the run's return) and the process exits with the answer the hook gave. Either
65
+ // way the default disposition, death with an empty stdout, is gone from this
66
+ // file's first statement on.
67
+ //
68
+ // Ownership: the runtime's own guards (`hermesFailClosed`, the wait's handler)
69
+ // raise HERMES_SIGNAL_OWNER while they are registered, and this guard steps
70
+ // aside for them, so the two never both print. With something on stdout and no
71
+ // answer yet, this exits 2 without printing a second object (unparseable
72
+ // stdout).
73
+ //
74
+ // What no guard here can cover is the moment before this file's first
75
+ // statement: Node's own bootstrap. A signal there is a death by signal with an
76
+ // empty stdout, and the gated image's patch to Hermes's `shell_hooks`
77
+ // (HOSTED-32) is the layer meant to block it (docs/hermes-hook.md, "Two layers
78
+ // against a signal").
79
+ const HERMES_SIGNAL_OWNER = Symbol.for("approval-md.hermes-signal-owner");
80
+ if (hermesHook) {
81
+ const onSignal = (signal) => {
82
+ if (globalThis[HERMES_SIGNAL_OWNER] === true) return;
83
+ if (answered) process.exit();
84
+ if (!printed) {
85
+ try {
86
+ writeSync(1, hermesInterrupted(signal));
87
+ } catch {
88
+ // stdout is gone; the exit code below is the whole verdict.
89
+ }
90
+ }
91
+ process.exit(2);
92
+ };
93
+ process.on("SIGTERM", onSignal);
94
+ process.on("SIGINT", onSignal);
95
+ }
15
96
 
16
97
  const entry = new URL("./dist/src/cli/main.js", import.meta.url);
17
98
 
99
+ /** Hermes's own block directive, spelled here because the runtime may not load. */
100
+ function hermesBlock(message) {
101
+ writeSync(1, `${JSON.stringify({ action: "block", message: `hook-io: ${message}; nothing authorizes this call` })}\n`);
102
+ printed = true;
103
+ process.exitCode = 2;
104
+ }
105
+
106
+ // The last guard (recheck L-d): whatever path the process takes out, a Hermes
107
+ // hook that leaves with a non-zero code other than 2 and nothing on stdout is
108
+ // an ALLOW to Hermes. Such an exit leaves as 2, with the directive when nothing
109
+ // was printed. Exit 0 with nothing on stdout is the post-event answer and is
110
+ // left alone; the adapter itself never answers a pre-event that way.
111
+ if (hermesHook) {
112
+ const write = process.stdout.write.bind(process.stdout);
113
+ process.stdout.write = (chunk, ...rest) => {
114
+ if (chunk !== undefined && String(chunk).length > 0) printed = true;
115
+ return write(chunk, ...rest);
116
+ };
117
+ process.on("exit", (code) => {
118
+ if (code === 0 || code === 2) return;
119
+ if (!printed) {
120
+ try {
121
+ writeSync(1, `${JSON.stringify({ action: "block", message: `hook-io: the hook exited ${String(code)} without a verdict; nothing authorizes this call` })}\n`);
122
+ } catch {
123
+ // stdout is gone; the exit code below is the whole verdict.
124
+ }
125
+ }
126
+ // Exit 2 blocks whatever stdout says, so it is the code a Hermes hook
127
+ // leaves with on any non-zero path.
128
+ process.exitCode = 2;
129
+ });
130
+ }
131
+
18
132
  if (!existsSync(entry)) {
19
- // Exit 4 = I/O error in the frozen exit-code table (src/cli/exit-codes.ts).
20
- process.stderr.write(
21
- "approval: dist/src/cli/main.js is missing — run `npm run build` first.\n",
22
- );
23
- process.exitCode = 4;
133
+ if (hermesHook) {
134
+ hermesBlock("the approval runtime is not built (dist/src/cli/main.js is missing)");
135
+ answered = true;
136
+ } else {
137
+ // Exit 4 = I/O error in the frozen exit-code table (src/cli/exit-codes.ts).
138
+ process.stderr.write(
139
+ "approval: dist/src/cli/main.js is missing — run `npm run build` first.\n",
140
+ );
141
+ process.exitCode = 4;
142
+ }
143
+ } else if (hermesHook) {
144
+ try {
145
+ const { main } = await import(entry.href);
146
+ process.exitCode = await main(argv);
147
+ } catch (cause) {
148
+ hermesBlock(`the hook could not run: ${cause instanceof Error ? cause.message : String(cause)}`);
149
+ }
150
+ answered = true;
24
151
  } else {
25
152
  const { main } = await import(entry.href);
26
153
  // `main` is asynchronous since APRV-209: every verb is loaded on demand, and
27
154
  // ESM has no synchronous dynamic import. The exit code still travels through
28
155
  // `process.exitCode`, so the flush behaviour described above is unchanged.
29
- process.exitCode = await main(process.argv.slice(2));
156
+ process.exitCode = await main(argv);
30
157
  }
@@ -138,6 +138,24 @@ export interface SmtpTransportOptions {
138
138
  /** Applied to every string this module returns. See the module header. */
139
139
  redact?(text: string): string;
140
140
  }
141
+ /**
142
+ * The TLS `servername` (SNI) to use for `host`, or `undefined` when there is
143
+ * none to send (APRV-416).
144
+ *
145
+ * SNI names a virtual host, and an IP address is not one. Sending an address
146
+ * there has always been meaningless; Node 26 turned the long-standing
147
+ * deprecation into a hard error, so a session against an IP-addressed relay
148
+ * fails at the handshake with "Setting the TLS ServerName to an IP address is
149
+ * not permitted" before it reaches the certificate. Omitting it is the whole
150
+ * fix: verification of an IP host then rests on the certificate's IP SAN
151
+ * entry, which is what TLS intends for an address, and `rejectUnauthorized`
152
+ * keeps its meaning either way.
153
+ *
154
+ * A bracketed IPv6 literal (`[::1]`, the URL spelling) is unwrapped before the
155
+ * test, because it is an address in every sense that matters here and nothing
156
+ * that reaches this function is a hostname shaped like one.
157
+ */
158
+ export declare function tlsServername(host: string): string | undefined;
141
159
  /** The SMTP envelope, which is not the message's headers. */
142
160
  export interface SmtpEnvelope {
143
161
  /** MAIL FROM. The return path, not necessarily the From: header. */
@@ -76,7 +76,7 @@
76
76
  * Deterministic apart from the network and the clock it does not read: no
77
77
  * randomness, no ambient configuration, no environment reads.
78
78
  */
79
- import { connect as netConnect } from "node:net";
79
+ import { connect as netConnect, isIP } from "node:net";
80
80
  import { connect as tlsConnect } from "node:tls";
81
81
  export function isSmtpSecurity(value) {
82
82
  return value === "implicit" || value === "starttls" || value === "none";
@@ -103,6 +103,27 @@ export const SMTP_TRANSPORT_FAILURE_CODES = [
103
103
  export const SMTP_REPLY_CODE_PATTERN = /^smtp-[1-5]\d\d$/u;
104
104
  /** The default whole-session budget, in milliseconds. */
105
105
  export const DEFAULT_SMTP_TIMEOUT_MS = 30_000;
106
+ /**
107
+ * The TLS `servername` (SNI) to use for `host`, or `undefined` when there is
108
+ * none to send (APRV-416).
109
+ *
110
+ * SNI names a virtual host, and an IP address is not one. Sending an address
111
+ * there has always been meaningless; Node 26 turned the long-standing
112
+ * deprecation into a hard error, so a session against an IP-addressed relay
113
+ * fails at the handshake with "Setting the TLS ServerName to an IP address is
114
+ * not permitted" before it reaches the certificate. Omitting it is the whole
115
+ * fix: verification of an IP host then rests on the certificate's IP SAN
116
+ * entry, which is what TLS intends for an address, and `rejectUnauthorized`
117
+ * keeps its meaning either way.
118
+ *
119
+ * A bracketed IPv6 literal (`[::1]`, the URL spelling) is unwrapped before the
120
+ * test, because it is an address in every sense that matters here and nothing
121
+ * that reaches this function is a hostname shaped like one.
122
+ */
123
+ export function tlsServername(host) {
124
+ const bare = host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
125
+ return isIP(bare) === 0 ? host : undefined;
126
+ }
106
127
  // ---------------------------------------------------------------------------
107
128
  // Internals
108
129
  // ---------------------------------------------------------------------------
@@ -307,7 +328,7 @@ async function runSession(options, envelope, message) {
307
328
  host: options.host,
308
329
  port: options.port,
309
330
  rejectUnauthorized,
310
- servername: options.host,
331
+ servername: tlsServername(options.host),
311
332
  };
312
333
  const created = tlsConnect(tlsOptions, () => {
313
334
  created.removeListener("error", onError);
@@ -349,7 +370,7 @@ async function runSession(options, envelope, message) {
349
370
  const onError = (cause) => {
350
371
  reject(new SmtpError("smtp-tls-failed", `the STARTTLS handshake failed: ${redact(cause.message)}`));
351
372
  };
352
- const upgraded = tlsConnect({ socket: plain, rejectUnauthorized, servername: options.host }, () => {
373
+ const upgraded = tlsConnect({ socket: plain, rejectUnauthorized, servername: tlsServername(options.host) }, () => {
353
374
  upgraded.removeListener("error", onError);
354
375
  resolve(upgraded);
355
376
  });
@@ -1 +1 @@
1
- {"version":3,"file":"smtp.js","sourceRoot":"","sources":["../../../src/adapters/smtp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAe,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,UAAU,EAA0C,MAAM,UAAU,CAAC;AAmBzF,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,MAAM,CAAC;AAC1E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,0DAA0D;IAC1D,qBAAqB;IACrB,4EAA4E;IAC5E,iBAAiB;IACjB,yDAAyD;IACzD,cAAc;IACd,yEAAyE;IACzE,qBAAqB;CACb,CAAC;AAIX,0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,IAAI,CAAC,CAAC;IACd,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;AACvD,CAAC"}
@@ -55,6 +55,7 @@ import { type ChannelDecisionRefusalCode, type ChannelSender } from "../core/sen
55
55
  import type { EventRecord } from "../core/log.js";
56
56
  import type { Autonomy } from "../core/policy-load.js";
57
57
  import type { Provenance } from "../core/policy-match.js";
58
+ import type { PromptRendering } from "../core/prompt-layout.js";
58
59
  import { type RequestState } from "../core/state.js";
59
60
  /**
60
61
  * The canonical `source` values the runtime tagger stamps on computed fields.
@@ -347,7 +348,27 @@ export interface ChannelRequest {
347
348
  chain: TaggedField<ChainPosition>;
348
349
  /** The derived approval state; always `requested` for a live pending item. */
349
350
  state: TaggedField<RequestState>;
351
+ /**
352
+ * Present, and `true`, when the request is a tool call the requesting agent
353
+ * is blocked in right now (APRV-489): the request record declared
354
+ * `execution: "harness"` and a `harness_cap_ms`, so the gate's window is the
355
+ * harness wait and the call is withdrawn when it ends.
356
+ *
357
+ * **Computed**, by the tagger from the verified request record. Keyed by a
358
+ * symbol on purpose: the CLI and web channels, `--json` and `approval queue`
359
+ * enumerate a request's string keys, and this fact only chooses the wording
360
+ * of the minimal card's deadline line ("Your agent is waiting" versus "Open
361
+ * for"), so it must not add a row or a JSON key anywhere else. The time
362
+ * itself is `ttl_remaining_ms`, already the gate's own window.
363
+ */
364
+ readonly [LIVE_TOOL_CALL]?: TaggedField<true>;
350
365
  }
366
+ /**
367
+ * The key of {@link ChannelRequest}'s live-tool-call fact (APRV-489). A symbol,
368
+ * so `Object.keys`, `Object.entries` and `JSON.stringify` never see it, and
369
+ * object spread (as `attachGloss` copies a request) carries it.
370
+ */
371
+ export declare const LIVE_TOOL_CALL: unique symbol;
351
372
  /** Refusals {@link createChannelRequest} can return. Frozen, per §11.1(6). */
352
373
  export declare const CHANNEL_REQUEST_REFUSAL_CODES: readonly [
353
374
  /** A `manual` request was built with no full payload to present (§10.4). */
@@ -484,6 +505,13 @@ export interface ChannelDecision {
484
505
  deliveryId: DeliveryId;
485
506
  /** Set when the delivery was a batch (SPEC.md §10.3). */
486
507
  batchDeliveryId?: DeliveryId;
508
+ /**
509
+ * Which layout the approver answered on (APRV-489), recorded as
510
+ * `payload.rendering`. Set only by a channel that was asked for a
511
+ * non-default style; absent, the record is unchanged. A statement about the
512
+ * channel's own screen, never an input to a decision.
513
+ */
514
+ rendering?: PromptRendering;
487
515
  }
488
516
  /**
489
517
  * What the runtime tells the channel became of a reported decision.
@@ -612,6 +640,25 @@ export interface ChannelActorOptions {
612
640
  actor: string;
613
641
  /** The channel that collected the gesture, for audit context in the note. */
614
642
  channel?: string;
643
+ /**
644
+ * Refuse every gesture whose actor would come from {@link actor} rather than
645
+ * from the sender mapping (APRV-455).
646
+ *
647
+ * A listener that holds a human identity of its own (a Telegram listener
648
+ * launched `--as human:carter`) keeps it for the modes `resolveSender` calls
649
+ * `configured`: no sender observed, or a policy that maps no sender for the
650
+ * channel. That fallback is the migration path for a person's own phone, and
651
+ * it is exactly wrong for a RELAY. A relay holds no human identity at all; the
652
+ * only thing it can honestly attribute a gesture to is the account the
653
+ * operator mapped, so where the attested policy maps nobody on the channel,
654
+ * the answer is `sender-unmapped` and one `audit.decision_refused`, never a
655
+ * decision recorded under whatever `actor` the relay was started with.
656
+ *
657
+ * Applies to decisions and attestations alike. A gesture with no sender at
658
+ * all under this flag is refused without a record: there is nobody to
659
+ * attribute the attempt to, and the relay never builds one.
660
+ */
661
+ requireSenderMapping?: boolean;
615
662
  }
616
663
  /**
617
664
  * {@link recordChannelDecision}'s result: the channel-safe outcome, plus the
@@ -653,4 +700,29 @@ export interface ChannelDecisionResult {
653
700
  * dual-read window readers stay inside for the life of v0.1.
654
701
  */
655
702
  export declare function recordChannelDecision(logPath: string, decision: ChannelDecision, actorOptions: ChannelActorOptions, gateOptions?: DecideOptions): ChannelDecisionResult;
703
+ /**
704
+ * Record a decision the SURFACE refused before the gate was asked (APRV-456),
705
+ * and do nothing else.
706
+ *
707
+ * The first caller is the Telegram listener's `nonce-not-issued` refusal: a tap
708
+ * on a button this process is not holding, on a channel whose stale-copy
709
+ * fallback is off. The tap never reaches {@link recordChannelDecision}, because
710
+ * that function's whole job is to call `decide()`, and this one never does. It
711
+ * appends one audit-tier `audit.decision_refused` through the same
712
+ * {@link noteRefusedDecision} every other refused human decision goes through,
713
+ * which grants nothing, settles nothing, charges nothing and is never sampled.
714
+ *
715
+ * Who the record names follows the rule a refused decision has followed since
716
+ * APRV-324: the sender the transport authenticated, resolved against the
717
+ * policy, in the form the record takes (raw or keyed, APRV-370). A sender the
718
+ * policy maps to an approver names that approver; one it maps to nobody is
719
+ * recorded with no `actor` and its account; a channel the policy maps no
720
+ * senders for falls back to the surface's configured identity, as a decision
721
+ * would. None of these widens anything: the record is an observation, and the
722
+ * refusal it describes has already happened.
723
+ *
724
+ * Best effort, like every refusal record: a failure is swallowed, and the
725
+ * caller has already told the human what happened to their tap.
726
+ */
727
+ export declare function recordSurfaceRefusal(logPath: string, decision: ChannelDecision, refusal: ChannelDecisionRefusal, actorOptions: ChannelActorOptions, gateOptions?: DecideOptions): void;
656
728
  export declare function recordAttestationDecision(logPath: string, decision: ChannelDecision, actorOptions: ChannelActorOptions, gateOptions?: DecideOptions): ChannelDecisionResult;
@@ -187,6 +187,12 @@ export function isTaggedField(value) {
187
187
  return typeof field["author"] === "string";
188
188
  return false;
189
189
  }
190
+ /**
191
+ * The key of {@link ChannelRequest}'s live-tool-call fact (APRV-489). A symbol,
192
+ * so `Object.keys`, `Object.entries` and `JSON.stringify` never see it, and
193
+ * object spread (as `attachGloss` copies a request) carries it.
194
+ */
195
+ export const LIVE_TOOL_CALL = Symbol("approval.md/live-tool-call");
190
196
  /** Refusals {@link createChannelRequest} can return. Frozen, per §11.1(6). */
191
197
  export const CHANNEL_REQUEST_REFUSAL_CODES = [
192
198
  /** A `manual` request was built with no full payload to present (§10.4). */
@@ -314,6 +320,47 @@ export function batchDeliveryIdOf(record) {
314
320
  export function isTestableChannel(channel) {
315
321
  return typeof channel.lastRendered === "function";
316
322
  }
323
+ /**
324
+ * The policy IN FORCE, loaded from its verified bytes (APRV-455 refuter H1).
325
+ *
326
+ * `inForcePolicyText` recovers the attested text from the payload store and
327
+ * checks it against the attested digest from the verified log; this loads it
328
+ * under the path this process enforces, so a load failure reads the way the
329
+ * file's own would.
330
+ */
331
+ function inForceLoad(logPath, gateOptions) {
332
+ const read = readVerifiedRecords(logPath, gateOptions.schemaDir === undefined ? {} : { schemaDir: gateOptions.schemaDir });
333
+ // A log that cannot be read keeps its own code (SPEC.md §11.1 invariant 6):
334
+ // a torn tail is not an unattested policy, and the repairs differ.
335
+ if (!read.ok)
336
+ return { ok: false, reason: read.message, log: { code: read.code, message: read.message } };
337
+ const inForce = inForcePolicyText(read.records, gateOptions.payloadStoreDir ?? payloadStoreDirFor(logPath));
338
+ if (!inForce.ok)
339
+ return { ok: false, reason: inForce.reason };
340
+ return {
341
+ ok: true,
342
+ load: loadPolicyText(listenerPolicyPath(gateOptions) ?? "APPROVAL.md", inForce.text, gateOptions.schemaDir === undefined ? {} : { schemaDir: gateOptions.schemaDir }),
343
+ };
344
+ }
345
+ /**
346
+ * The refusal {@link ChannelActorOptions.requireSenderMapping} turns a
347
+ * configured-actor fallback into (APRV-455).
348
+ *
349
+ * `sender-unmapped`, the existing member of the surface's union, because the
350
+ * fact is the same one: the attested policy names nobody for this account on
351
+ * this channel. The recorded form follows the file, as every refusal that does
352
+ * not reach a mapping does (`recordedSenderFor`).
353
+ */
354
+ function mappingRequiredRefusal(sender, load, subject) {
355
+ return {
356
+ refusal: {
357
+ ok: false,
358
+ code: "sender-unmapped",
359
+ message: `${subject} refused: the ${sender.channel} sender this gesture arrived from is not mapped to an approver in the attested policy, and this surface records no gesture it cannot attribute to a mapped account. It holds no human identity of its own to fall back on, by design: a relay that decided as its launch identity whenever the policy mapped nobody would let whoever holds its secret decide as that identity. Nothing was decided; the observed account is on the audit.decision_refused record. An operator who recognizes it adds it to that approver's \`senders\` block and re-attests.`,
360
+ },
361
+ recorded: recordedSenderFor(load, sender, senderKeyFrom()),
362
+ };
363
+ }
317
364
  /**
318
365
  * Turn a reported gesture into a log event — by calling the gate, and by doing
319
366
  * nothing else.
@@ -358,6 +405,10 @@ export function recordChannelDecision(logPath, decision, actorOptions, gateOptio
358
405
  if (decision.batchDeliveryId !== undefined) {
359
406
  options.batchDeliveryId = decision.batchDeliveryId;
360
407
  }
408
+ // APRV-489. Which layout the approver answered on, when a channel drew a
409
+ // non-default one. A record of the screen; nothing below reads it.
410
+ if (decision.rendering !== undefined)
411
+ options.rendering = decision.rendering;
361
412
  // APRV-324. Every surface names itself on the record it writes, so a reader
362
413
  // of a grant can tell a tap on a phone from a line typed into a terminal. The
363
414
  // fallback matches `noteRefusedDecision`'s below.
@@ -367,12 +418,56 @@ export function recordChannelDecision(logPath, decision, actorOptions, gateOptio
367
418
  // mapping the operator attested, and the gate's own authorization logic is
368
419
  // untouched by it. `namesApprover` and `actor-not-approver` then run exactly
369
420
  // as they always have, over an identity that is better evidenced.
370
- const resolution = actorForSender(readGatePolicy(gateOptions), actorOptions.actor, decision.sender,
421
+ // APRV-455 refuter H1. A relay resolves the sender against the policy IN
422
+ // FORCE (the verified bytes the latest attestation names), never against the
423
+ // file on disk. Its own `propose` gesture puts unattested bytes on disk as a
424
+ // matter of course, and a mapping in those bytes must not decide who may
425
+ // answer anything until a human has attested them. Where the in-force bytes
426
+ // cannot be recovered the gesture is refused `policy-not-attested` and
427
+ // nothing is appended: the rule SPEC.md §10.3 already sets for checkpoint
428
+ // signatures and reviews, for the same reason.
429
+ let load = readGatePolicy(gateOptions);
430
+ if (actorOptions.requireSenderMapping === true) {
431
+ const inForce = inForceLoad(logPath, gateOptions);
432
+ if (!inForce.ok && inForce.log !== undefined) {
433
+ return { outcome: { ok: false, code: inForce.log.code, message: inForce.log.message } };
434
+ }
435
+ if (!inForce.ok) {
436
+ return {
437
+ outcome: {
438
+ ok: false,
439
+ code: "policy-not-attested",
440
+ message: `decision on ${decision.action_key} refused: this surface resolves a sender only against the policy in force, and ${inForce.reason}. Nothing was decided and nothing was recorded.`,
441
+ },
442
+ };
443
+ }
444
+ load = inForce.load;
445
+ }
446
+ const resolution = actorForSender(load, actorOptions.actor, decision.sender,
371
447
  // APRV-370. The operator's sender key, where the policy's mapping is keyed.
372
448
  // `null` when it is unset, which is a REFUSAL of the whole channel rather
373
449
  // than a fallback to the raw comparison; `sender-key-unavailable` carries
374
450
  // the reasoning.
375
451
  senderKeyFrom());
452
+ // APRV-455. A surface that holds no human identity (the relay) never falls
453
+ // back to its configured actor: an actor that did not come from the mapping
454
+ // is a refusal here, before the gate is called.
455
+ if (resolution.ok && resolution.sender === undefined && actorOptions.requireSenderMapping === true) {
456
+ if (decision.sender === undefined) {
457
+ return {
458
+ outcome: {
459
+ ok: false,
460
+ code: "sender-unmapped",
461
+ message: `decision on ${decision.action_key} refused: this surface records only gestures attributed to a mapped account, and this one carried no sender. Nothing was decided and nothing was recorded, because there is no party to attribute the attempt to.`,
462
+ },
463
+ };
464
+ }
465
+ const { refusal, recorded } = mappingRequiredRefusal(decision.sender, load, `decision on ${decision.action_key}`);
466
+ noteRefusedDecision(logPath, decision, { ...actorOptions, actor: null }, gateOptions, refusal, {
467
+ sender: recorded,
468
+ });
469
+ return { outcome: refusal };
470
+ }
376
471
  if (!resolution.ok) {
377
472
  const refusal = {
378
473
  ok: false,
@@ -434,6 +529,52 @@ export function recordChannelDecision(logPath, decision, actorOptions, gateOptio
434
529
  };
435
530
  return result.token === undefined ? { outcome } : { outcome, token: result.token };
436
531
  }
532
+ /**
533
+ * Record a decision the SURFACE refused before the gate was asked (APRV-456),
534
+ * and do nothing else.
535
+ *
536
+ * The first caller is the Telegram listener's `nonce-not-issued` refusal: a tap
537
+ * on a button this process is not holding, on a channel whose stale-copy
538
+ * fallback is off. The tap never reaches {@link recordChannelDecision}, because
539
+ * that function's whole job is to call `decide()`, and this one never does. It
540
+ * appends one audit-tier `audit.decision_refused` through the same
541
+ * {@link noteRefusedDecision} every other refused human decision goes through,
542
+ * which grants nothing, settles nothing, charges nothing and is never sampled.
543
+ *
544
+ * Who the record names follows the rule a refused decision has followed since
545
+ * APRV-324: the sender the transport authenticated, resolved against the
546
+ * policy, in the form the record takes (raw or keyed, APRV-370). A sender the
547
+ * policy maps to an approver names that approver; one it maps to nobody is
548
+ * recorded with no `actor` and its account; a channel the policy maps no
549
+ * senders for falls back to the surface's configured identity, as a decision
550
+ * would. None of these widens anything: the record is an observation, and the
551
+ * refusal it describes has already happened.
552
+ *
553
+ * Best effort, like every refusal record: a failure is swallowed, and the
554
+ * caller has already told the human what happened to their tap.
555
+ */
556
+ export function recordSurfaceRefusal(logPath, decision, refusal, actorOptions, gateOptions = {}) {
557
+ const options = { ...actorOptions, channel: actorOptions.channel ?? "cli" };
558
+ let resolution;
559
+ try {
560
+ resolution = actorForSender(readGatePolicy(gateOptions), actorOptions.actor, decision.sender, senderKeyFrom());
561
+ }
562
+ catch {
563
+ return;
564
+ }
565
+ if (resolution.ok) {
566
+ noteRefusedDecision(logPath, decision, { ...options, actor: resolution.actor }, gateOptions, refusal, resolution.sender === undefined
567
+ ? {}
568
+ : {
569
+ sender: resolution.sender,
570
+ ...(resolution.source === undefined ? {} : { senderSource: resolution.source }),
571
+ });
572
+ return;
573
+ }
574
+ noteRefusedDecision(logPath, decision, { ...options, actor: null }, gateOptions, refusal, {
575
+ sender: resolution.sender,
576
+ });
577
+ }
437
578
  /**
438
579
  * Append the audit trail of a refused human decision, and swallow whatever goes
439
580
  * wrong doing it (APRV-235).
@@ -665,6 +806,25 @@ export function recordAttestationDecision(logPath, decision, actorOptions, gateO
665
806
  noteRefusedDecision(logPath, decision, { ...actorOptions, actor: null }, gateOptions, refusal, { sender: resolved.sender });
666
807
  return { outcome: refusal };
667
808
  }
809
+ // APRV-455. The relay rule, on the privileged gesture: an attestation whose
810
+ // actor did not come from the mapping in force is refused, whichever rung of
811
+ // the ladder above produced the configured actor.
812
+ if (resolved.sender === undefined && actorOptions.requireSenderMapping === true) {
813
+ if (decision.sender === undefined) {
814
+ return {
815
+ outcome: {
816
+ ok: false,
817
+ code: "sender-unmapped",
818
+ message: `attestation of ${sha256} refused: this surface attests only for a mapped account, and this gesture carried no sender. Nothing was attested and nothing was recorded.`,
819
+ },
820
+ };
821
+ }
822
+ const { refusal, recorded } = mappingRequiredRefusal(decision.sender, readGatePolicy(gateOptions), `attestation of ${sha256}`);
823
+ noteRefusedDecision(logPath, decision, { ...actorOptions, actor: null }, gateOptions, refusal, {
824
+ sender: recorded,
825
+ });
826
+ return { outcome: refusal };
827
+ }
668
828
  if (resolved.sender !== undefined) {
669
829
  options.sender = resolved.sender;
670
830
  if (resolved.source !== undefined)