approval-md 0.4.0 → 0.4.2

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 (190) hide show
  1. package/SPEC.md +11 -0
  2. package/cli.js +72 -4
  3. package/dist/src/channels/contract.d.ts +53 -0
  4. package/dist/src/channels/contract.js +56 -0
  5. package/dist/src/channels/contract.js.map +1 -1
  6. package/dist/src/channels/tagging.d.ts +25 -0
  7. package/dist/src/channels/tagging.js +57 -5
  8. package/dist/src/channels/tagging.js.map +1 -1
  9. package/dist/src/channels/telegram-minimal.d.ts +251 -0
  10. package/dist/src/channels/telegram-minimal.js +618 -0
  11. package/dist/src/channels/telegram-minimal.js.map +1 -0
  12. package/dist/src/channels/telegram.d.ts +454 -19
  13. package/dist/src/channels/telegram.js +931 -80
  14. package/dist/src/channels/telegram.js.map +1 -1
  15. package/dist/src/cli/amend.js +8 -1
  16. package/dist/src/cli/amend.js.map +1 -1
  17. package/dist/src/cli/attest.js +2 -1
  18. package/dist/src/cli/attest.js.map +1 -1
  19. package/dist/src/cli/audit-card.d.ts +1 -1
  20. package/dist/src/cli/audit-card.js +40 -1
  21. package/dist/src/cli/audit-card.js.map +1 -1
  22. package/dist/src/cli/audit.d.ts +7 -5
  23. package/dist/src/cli/audit.js +25 -12
  24. package/dist/src/cli/audit.js.map +1 -1
  25. package/dist/src/cli/channel-telegram-webhook.d.ts +2 -0
  26. package/dist/src/cli/channel-telegram-webhook.js +7 -0
  27. package/dist/src/cli/channel-telegram-webhook.js.map +1 -1
  28. package/dist/src/cli/channel-telegram.d.ts +75 -2
  29. package/dist/src/cli/channel-telegram.js +172 -16
  30. package/dist/src/cli/channel-telegram.js.map +1 -1
  31. package/dist/src/cli/channel-web.js +2 -1
  32. package/dist/src/cli/channel-web.js.map +1 -1
  33. package/dist/src/cli/channel.js +2 -1
  34. package/dist/src/cli/channel.js.map +1 -1
  35. package/dist/src/cli/doctor.js +1 -1
  36. package/dist/src/cli/doctor.js.map +1 -1
  37. package/dist/src/cli/execute.d.ts +12 -0
  38. package/dist/src/cli/execute.js +50 -4
  39. package/dist/src/cli/execute.js.map +1 -1
  40. package/dist/src/cli/gate.js +2 -1
  41. package/dist/src/cli/gate.js.map +1 -1
  42. package/dist/src/cli/help.d.ts +1 -0
  43. package/dist/src/cli/help.js +39 -18
  44. package/dist/src/cli/help.js.map +1 -1
  45. package/dist/src/cli/hook.d.ts +121 -3
  46. package/dist/src/cli/hook.js +719 -79
  47. package/dist/src/cli/hook.js.map +1 -1
  48. package/dist/src/cli/log-checkpoint.js +2 -1
  49. package/dist/src/cli/log-checkpoint.js.map +1 -1
  50. package/dist/src/cli/log-unlock.d.ts +23 -0
  51. package/dist/src/cli/log-unlock.js +110 -0
  52. package/dist/src/cli/log-unlock.js.map +1 -0
  53. package/dist/src/cli/main.js +23 -6
  54. package/dist/src/cli/main.js.map +1 -1
  55. package/dist/src/cli/setup-common.js +2 -1
  56. package/dist/src/cli/setup-common.js.map +1 -1
  57. package/dist/src/cli/up.js +5 -0
  58. package/dist/src/cli/up.js.map +1 -1
  59. package/dist/src/cli/vault.js +2 -1
  60. package/dist/src/cli/vault.js.map +1 -1
  61. package/dist/src/cli/verb-registry.js +1 -0
  62. package/dist/src/cli/verb-registry.js.map +1 -1
  63. package/dist/src/cli/wordmark.d.ts +2 -2
  64. package/dist/src/cli/wordmark.js +2 -2
  65. package/dist/src/core/attest-bootstrap.js +2 -1
  66. package/dist/src/core/attest-bootstrap.js.map +1 -1
  67. package/dist/src/core/attest.js +5 -4
  68. package/dist/src/core/attest.js.map +1 -1
  69. package/dist/src/core/audit.d.ts +113 -9
  70. package/dist/src/core/audit.js +382 -18
  71. package/dist/src/core/audit.js.map +1 -1
  72. package/dist/src/core/budgets.d.ts +12 -0
  73. package/dist/src/core/budgets.js +54 -1
  74. package/dist/src/core/budgets.js.map +1 -1
  75. package/dist/src/core/checkpoint.js +3 -2
  76. package/dist/src/core/checkpoint.js.map +1 -1
  77. package/dist/src/core/command-class.js +6 -0
  78. package/dist/src/core/command-class.js.map +1 -1
  79. package/dist/src/core/decision-refusal.js +2 -1
  80. package/dist/src/core/decision-refusal.js.map +1 -1
  81. package/dist/src/core/delegation.d.ts +109 -0
  82. package/dist/src/core/delegation.js +244 -0
  83. package/dist/src/core/delegation.js.map +1 -0
  84. package/dist/src/core/execute.js +12 -3
  85. package/dist/src/core/execute.js.map +1 -1
  86. package/dist/src/core/gate-window.js +4 -3
  87. package/dist/src/core/gate-window.js.map +1 -1
  88. package/dist/src/core/gate.d.ts +84 -43
  89. package/dist/src/core/gate.js +114 -6
  90. package/dist/src/core/gate.js.map +1 -1
  91. package/dist/src/core/gesture-refusal.js +2 -1
  92. package/dist/src/core/gesture-refusal.js.map +1 -1
  93. package/dist/src/core/identity.d.ts +105 -0
  94. package/dist/src/core/identity.js +122 -0
  95. package/dist/src/core/identity.js.map +1 -0
  96. package/dist/src/core/log-lock.d.ts +435 -0
  97. package/dist/src/core/log-lock.js +1093 -0
  98. package/dist/src/core/log-lock.js.map +1 -0
  99. package/dist/src/core/log.d.ts +82 -3
  100. package/dist/src/core/log.js +285 -40
  101. package/dist/src/core/log.js.map +1 -1
  102. package/dist/src/core/loop.d.ts +11 -0
  103. package/dist/src/core/loop.js +63 -4
  104. package/dist/src/core/loop.js.map +1 -1
  105. package/dist/src/core/policy-diff.js +20 -1
  106. package/dist/src/core/policy-diff.js.map +1 -1
  107. package/dist/src/core/policy-explain.js +18 -2
  108. package/dist/src/core/policy-explain.js.map +1 -1
  109. package/dist/src/core/policy-load.d.ts +38 -1
  110. package/dist/src/core/policy-load.js +34 -2
  111. package/dist/src/core/policy-load.js.map +1 -1
  112. package/dist/src/core/policy-match.js +30 -5
  113. package/dist/src/core/policy-match.js.map +1 -1
  114. package/dist/src/core/policy-proposal.d.ts +17 -0
  115. package/dist/src/core/policy-proposal.js +32 -16
  116. package/dist/src/core/policy-proposal.js.map +1 -1
  117. package/dist/src/core/prompt-layout.d.ts +186 -1
  118. package/dist/src/core/prompt-layout.js +345 -3
  119. package/dist/src/core/prompt-layout.js.map +1 -1
  120. package/dist/src/core/sender-identity.d.ts +24 -1
  121. package/dist/src/core/sender-identity.js +31 -0
  122. package/dist/src/core/sender-identity.js.map +1 -1
  123. package/dist/src/core/token.js +11 -0
  124. package/dist/src/core/token.js.map +1 -1
  125. package/dist/src/core/tool-map.d.ts +125 -0
  126. package/dist/src/core/tool-map.js +179 -0
  127. package/dist/src/core/tool-map.js.map +1 -0
  128. package/dist/src/core/validate.d.ts +20 -6
  129. package/dist/src/core/validate.js +0 -0
  130. package/dist/src/core/validate.js.map +1 -1
  131. package/dist/src/daemon/git-evidence.d.ts +2 -2
  132. package/dist/src/daemon/git-evidence.js +1 -1
  133. package/dist/src/serve/archive.d.ts +8 -0
  134. package/dist/src/serve/archive.js +11 -2
  135. package/dist/src/serve/archive.js.map +1 -1
  136. package/docs/README-extended.md +15 -0
  137. package/docs/cli-reference.md +571 -28
  138. package/package.json +2 -2
  139. package/schema/event.schema.json +387 -29
  140. package/schema/fixtures/event/invalid/audit-lock-reclaimed-age-without-created.json +19 -0
  141. package/schema/fixtures/event/invalid/audit-lock-reclaimed-agent-actor.json +14 -0
  142. package/schema/fixtures/event/invalid/audit-lock-reclaimed-lockfile-path.json +14 -0
  143. package/schema/fixtures/event/invalid/audit-lock-reclaimed-operator-cleared-system-actor.json +14 -0
  144. package/schema/fixtures/event/invalid/audit-lock-reclaimed-unknown-reason.json +14 -0
  145. package/schema/fixtures/event/invalid/audit-lock-reclaimed-without-age.json +13 -0
  146. package/schema/fixtures/event/invalid/audit-reviewed-agent-actor.json +6 -1
  147. package/schema/fixtures/event/invalid/audit-reviewed-bad-payload-hash.json +21 -0
  148. package/schema/fixtures/event/invalid/audit-reviewed-loved-no-note.json +5 -0
  149. package/schema/fixtures/event/invalid/audit-reviewed-model-actor.json +20 -0
  150. package/schema/fixtures/event/invalid/audit-reviewed-no-subject-hash.json +19 -0
  151. package/schema/fixtures/event/invalid/audit-reviewed-no-subject-seq.json +19 -0
  152. package/schema/fixtures/event/invalid/audit-reviewed-no-verdict-source.json +19 -0
  153. package/schema/fixtures/event/invalid/audit-reviewed-no-verdict.json +19 -0
  154. package/schema/fixtures/event/invalid/audit-reviewed-system-actor.json +6 -1
  155. package/schema/fixtures/event/invalid/audit-reviewed-verdict-source-model.json +20 -0
  156. package/schema/fixtures/event/invalid/audit-sampled-no-policy-hash.json +14 -0
  157. package/schema/fixtures/event/invalid/execution-started-harness-tool-space.json +18 -0
  158. package/schema/fixtures/event/valid/audit-lock-reclaimed-implausible-created.json +18 -0
  159. package/schema/fixtures/event/valid/audit-lock-reclaimed-legacy.json +14 -0
  160. package/schema/fixtures/event/valid/audit-lock-reclaimed-unlock.json +19 -0
  161. package/schema/fixtures/event/valid/audit-lock-reclaimed.json +19 -0
  162. package/schema/fixtures/event/valid/audit-reviewed-reaction.json +5 -0
  163. package/schema/fixtures/event/valid/audit-reviewed.json +6 -1
  164. package/schema/fixtures/event/valid/audit-sampled.json +2 -1
  165. package/schema/fixtures/event/valid/daemon-identity.json +2 -1
  166. package/schema/fixtures/event/valid/execution-started-harness-tool.json +19 -0
  167. package/schema/fixtures/policy/invalid/delegation-advice-string.json +15 -0
  168. package/schema/fixtures/policy/invalid/delegation-class-duplicate.json +18 -0
  169. package/schema/fixtures/policy/invalid/delegation-class-wildcard.json +17 -0
  170. package/schema/fixtures/policy/invalid/delegation-daily-cap-fractional.json +15 -0
  171. package/schema/fixtures/policy/invalid/delegation-daily-cap-negative.json +15 -0
  172. package/schema/fixtures/policy/invalid/delegation-daily-cap-too-high.json +15 -0
  173. package/schema/fixtures/policy/invalid/delegation-escalate-duplicate.json +18 -0
  174. package/schema/fixtures/policy/invalid/delegation-escalate-unknown.json +17 -0
  175. package/schema/fixtures/policy/invalid/delegation-max-autonomy-alias.json +15 -0
  176. package/schema/fixtures/policy/invalid/delegation-max-autonomy-autonomous.json +15 -0
  177. package/schema/fixtures/policy/invalid/delegation-model-no-version.json +15 -0
  178. package/schema/fixtures/policy/invalid/delegation-model-provider-form.json +15 -0
  179. package/schema/fixtures/policy/invalid/delegation-null.json +7 -0
  180. package/schema/fixtures/policy/invalid/delegation-reviewer-agent.json +17 -0
  181. package/schema/fixtures/policy/invalid/delegation-reviewer-bare-id.json +17 -0
  182. package/schema/fixtures/policy/invalid/delegation-unknown-key.json +16 -0
  183. package/schema/fixtures/policy/invalid/tools-class-wildcard.json +9 -0
  184. package/schema/fixtures/policy/invalid/tools-match-double-star.json +9 -0
  185. package/schema/fixtures/policy/invalid/unmapped-tool-unknown.json +7 -0
  186. package/schema/fixtures/policy/valid/delegation-empty.json +7 -0
  187. package/schema/fixtures/policy/valid/delegation-grammar-full.json +41 -0
  188. package/schema/fixtures/policy/valid/delegation-off.json +15 -0
  189. package/schema/fixtures/policy/valid/tools-mapping.json +17 -0
  190. package/schema/policy.schema.json +178 -0
package/SPEC.md CHANGED
@@ -133,6 +133,8 @@ channels:
133
133
 
134
134
  **Agent-requestable classes.** A class rule MAY set `agent_may_request: true` to let an agent open a request in that class with `approval propose` (§10.1), which names the class itself and carries the payload inline. Two conditions MUST both hold before a proposal is admitted: the class is an exact key of `classes` (a class reached only through a wildcard pattern is never proposable, so the set of proposable classes is a set of lines the operator wrote by name), and either that exact key or a declared family key `<prefix>.*` whose literal prefix the class extends sets the flag `true`. The exact key's own value wins when it states one, so `false` on a member closes it under an open family; otherwise the most specific family that states a value decides. Interior-wildcard patterns and the bare `*` are never read for this flag. The key is optional and boolean, absent means `false`, and `true` on a `human-only` rule is schema-invalid and fails closed. Adding or changing it is an edit to the policy like any other, so it takes effect only once a human attests the new bytes, and that attestation voids every request pending under the previous hash (`policy-drift`): a proposal pending across a policy edit must be filed again. The check runs before anything is registered and again inside the request's own read-check-append cycle, against the bytes that cycle attested. A refusal is `class-not-agent-requestable` (§11.2). (Amended APRV-445.)
135
135
 
136
+ **The `delegation` block is reserved.** A policy MAY carry one top-level `delegation` block with the keys `model` (null, or a judge identity `model:<name>@<major>.<minor>.<patch>`), `classes` (exact keys of `classes`), `max_autonomy` (`manual`, `supervised-live` or `supervised-retro`; absent means `manual`), `daily_cap` (an integer from 0 to 1000; absent means 0), `escalate_on` (a subset of `deny`, `low_confidence`, `irreversible`, `unknown_class`), `advice` (boolean; absent means false) and `reviewers` (`human:<approver id>` or `model:<name>@<version>`). Implementations MUST validate the block's relationships to the rest of the file and fail the policy closed when one does not hold: every `classes` entry is an exact key of `classes` whose declared autonomy is neither `human-only` nor `autonomous`; every listed class declares an autonomy at least as strict as `max_autonomy` (a pin between the block and the class rows, so loosening a delegated row without rewriting the block fails the load); a `daily_cap` above 0 requires `escalate_on` to contain `irreversible` and `unknown_class`; a `model:` reviewer equals `model`; a `human:` reviewer names a key of `approvers`; and `advice: true`, a cap above 0 or a `model:` reviewer requires `model`. An implementation that does not implement delegation MUST load the block only when every key is absent or at its off value (`model: null`, `classes: []`, `max_autonomy: manual`, `daily_cap: 0`, `escalate_on: []`, `advice: false`, `reviewers: []`), where it changes nothing, and MUST refuse any other value with the load code `delegation-not-supported`, so the policy resolves every class `manual`. When a block both breaks one of the relationship rules above and is switched on, the relationship rule wins and the load fails `schema-invalid`: `delegation-not-supported` is answered only for a block that is well-formed and switched on. A setting its author believes is in force is never silently ignored. Delegation never changes a class's autonomy; it changes who may supply a decision or a review. (Amended APRV-500, pending sign-off.)
137
+
136
138
  ### 5.2 Policy semantics
137
139
 
138
140
  - **Matching.** Classes match most-specific-first; `*` is a single-segment wildcard, a trailing `.*` matches any depth. An action whose class matches no rule takes `defaults.autonomy`. Implementations MUST fail closed: unparseable policy means everything is `manual`. A trailing `.*` consumes one or more segments: `read.*` matches `read.web` and `read.web.page`, and it does not match the bare class `read`. The schema admits `read` and `read.*` as two distinct keys a policy may list separately with different autonomy, so neither is an alias of the other, and a policy that wants the bare class covered writes it as its own rule or leaves it to `defaults.autonomy`. A bare `*` is a single-segment wildcard rather than a trailing one, so it matches any one-segment class and nothing deeper, and `*.*` matches any class of two or more segments. (Amended APRV-137.)
@@ -158,9 +160,12 @@ channels:
158
160
  - **`payload_retention`.** An optional top-level duration bounding how long the payload bytes in `.approval/payloads/` (§9) are kept. A payload is prunable once the action it is bound to has been in a terminal state (`executed`, `rejected`, `expired`, `revoked`) for longer than the duration. A payload whose action is not terminal is never prunable, at any age: a pending or granted approval binds to those exact bytes, and discarding them would leave a live authorization pointing at nothing. When the key is present, orphaned payloads (bytes with no recorded binding) are prunable at any age: the duration governs bound payloads and does not gate residue nothing ever bound. When the key is absent, the pruning subsystem does not run and nothing is deleted, orphaned or not; the store holds the material evidence of what a human approved, so forgetting anything is an operator's explicit choice, and an operator who never made that choice never asked the runtime to delete anything (amended APRV-49 to match the enforcement shipped in APRV-41). Pruning is performed by the daemon and by nothing else, and each removal appends a `payload.pruned` event, so a log states what its store no longer holds. The bytes an attestation binds (§5.2, §10.4) are never prunable while that attestation is the one in force: they are not bound to an action and have no terminal state, and the policy in force binds them exactly as a live approval binds its own material. (Policy vocabulary in v0.1; enforcement lands with the M5 daemon. The attestation sentence is APRV-356.)
159
161
  - **`protected_paths`.** An optional top-level list widening the set of files whose edit is classified `policy.edit`, so a project can put its own governing documents (a specification, a constitution, a design directory) behind the gate that already stands in front of `APPROVAL.md`. Entries are repo-relative and literal: an exact file path (`SPEC.md`, `docs/constitution.md`) or a directory prefix ending in `/` (`design/`). Globs, negation, absolute paths and `..` segments are schema violations, because a pattern language the runtime half-implemented would leave an author believing a file is gated when it is not. Matching is by path segments and never resolves against a checkout, so a linked worktree and the primary answer alike: an exact path matches a candidate whose trailing segments are that path (a single-segment entry therefore matches that filename in any directory, exactly as the built-in filenames do), and a directory prefix matches a candidate containing those segments as a contiguous run. The key is ADDITIVE and can only widen: the runtime's built-in protected set (the policy file, the agent instruction files, the approval home, the harness settings, the release configuration) stays protected whatever this list says or omits, and a policy that fails to load leaves those built-ins in force while every class resolves to `manual`. (Amended APRV-107.) Every path a policy adds is `policy.edit`: a policy widening its own protected surface is naming prose and configuration, and cannot mint authority over the gate's organs, whose classes the runtime fixes. (Amended APRV-198.)
160
162
  - **`read_scope`.** An optional top-level block, `{ roots: [...] }`, naming directories an agent's reads may stay inside, beyond the runtime's built-in ones. A read whose resolved target falls outside every root classifies `read.file.out_of_scope` (§7). The BUILT-IN roots are the GATE ROOT (the directory holding the policy file the runtime resolved), the session scratchpad the harness allots, and the system temp root; they stand whatever this block says or omits, because a runtime denied its own policy, log and workspace cannot run, and because a policy able to NARROW its own read scope would be a policy an agent could edit until nothing was gated. The key is therefore ADDITIVE in the same sense `protected_paths` is, in the opposite direction: that one may only widen what is protected, this one may only widen what is permitted, and neither may shrink. An entry is absolute or resolved against the gate root; globs, negation and values requiring expansion are schema violations, for the reason `protected_paths` rejects them. Comparison is by path segment after the runtime RESOLVES the candidate on disk, so a symlink inside a root that points out of it is outside. Omitting the block entirely is the ordinary case and needs no grammar: a session whose policy sits in one project directory is confined to that project. A policy that fails to load leaves the built-in roots in force while every class resolves to `manual`. (Amended APRV-347.)
163
+ - **`tools`.** An optional top-level ordered list of `{match, class}` entries naming the class a harness's own tool call is judged under, by tool name, for a call the harness adapter's built-in tables do not claim (its shell, file, read and pass-through tools and any rule table that reads the call's arguments). `match` is compared against the whole tool name, case-sensitively; `*` is the only wildcard and matches any run of characters, including none; any other character outside letters, digits, `_`, `.`, `:` and `-`, and two `*` in a row, are schema violations. The first entry whose `match` matches decides, and later entries are not read. `class` is a concrete class that MUST be declared by `classes`, as an exact key or under a trailing family key `<prefix>.*` whose literal prefix it extends; it MUST NOT be `harness.tool.unmapped`; two entries MUST NOT share a `match`. A violation of any of these makes the policy fail to load, so every class resolves `manual`, and an implementation MUST then refuse a harness tool call it would otherwise have answered from the mapping, rather than treat it as unmapped. The adapter's built-in tables keep precedence over every entry: an entry reads only a name and MUST NOT reclassify a call the runtime classified from its arguments. A call an entry claims is gated under that class with the whole call (`{tool, input}`) as its payload. An implementation MUST NOT answer a call it does not classify as outside the gate on the strength of policy bytes that are not attested (§11.1). (Amended APRV-499, pending sign-off.)
164
+ - **`defaults.unmapped_tool`.** Optional, `record` or `ask`: what a harness hook does with a tool call that neither the adapter's tables nor any `tools` entry claims. Either value classifies the call `harness.tool.unmapped` (§7), and the key is that class's default: when no `classes` rule matches it, it resolves `autonomous` under `record` and `manual` under `ask`, in place of `defaults.autonomy`. A rule matching the class decides it as a rule decides any class. Absent, such a call is not a gate question and leaves no record, which is the behaviour of every policy written before the key. A start recorded under `record` with no human grant is a record of unclassified tool use: global `daily_actions` budgets do not count it, and §10.2's harness streaks do not accrue it. (Amended APRV-499, pending sign-off.)
161
165
  - **`daemons`.** An optional top-level list of the daemon ids permitted to append to the log (§8, the writing daemon), read only from the attested policy: an absent key is no restriction, and an empty list admits no daemon at all. (Amended APRV-454.)
162
166
  - **`vault.passphrase_env`.** An optional top-level key naming the environment variable that holds the passphrase for the credential vault of §10.4. The policy carries the variable's *name*, never the passphrase, on the same reasoning as `audit.sampling_secret_env` and the channel credential keys (`chat_id_env`, `token_env`): agents may read `APPROVAL.md`, and a passphrase they can read is a vault they can open. The passphrase MUST NOT appear in the log, in any command's output, or in any error message. When the key is absent the runtime reads `APPROVAL_VAULT_PASSPHRASE`; a variable name is not a permission, so an unnamed one MUST NOT lock an operator out of credentials they created, and a policy that fails to load leaves the default in force for this key alone. (Amended APRV-68, which implements the reference vault.)
163
167
  - **`channels.telegram.token_env` and `channels.telegram.chat_id_env`** are honoured by the runtime exactly as `audit.sampling_secret_env` and `vault.passphrase_env` are: the policy carries the variable's *name*, the runtime reads the value from the environment under that name, and a policy that declares neither (or fails to load) gets the reference runtime's defaults, `APPROVAL_TG_TOKEN` and `APPROVAL_TG_CHAT`. (Amended APRV-72.)
168
+ - **`channels.<name>.prompt.style` and `channels.<name>.prompt.say`** choose how a channel lays out a prompt. (`say` may not set the phrase of a class the runtime phrases itself, and its phrase is used only for a payload the runtime does not read itself; an operator class's phrase is a verb phrase with no sentence punctuation, and labels are plain words.) `style` is `technical` (the default, and what an absent key or a policy that did not load means: the prompt every earlier build sent) or `minimal`, the collapsed presentation of §10.3: a headline the runtime computes from the class, verbatim quotations from the bound payload, a deadline in plain words, and the canonical rendering collapsed in the message that carries the buttons. `say` maps an exact class name (never a pattern, so one phrase cannot stand for several classes) to the operator's plain-words phrase for it (`does`), the closed field set of an opaque payload (`quote`, every top-level key with the label it is quoted under or `~` for a key deliberately left off, at least one key shown), and whether the agent's own summary is shown (`note`). A payload carrying a key its declaration does not name, or a class with an opaque payload and no declaration, is presented in the ordinary form; a field left off with `~` is named on the visible card. Both keys are validated on every channel and an unknown value fails the policy closed; a channel that has no minimal presentation (the reference `cli` and `web`) ignores them. Because the style is a policy key, choosing it is an attested act, and choosing to see less is on the record. (Amended APRV-489, pending sign-off.)
164
169
  - **The environment map.** Every key above that ends in `_env` carries a variable's name rather than its value, which leaves an operator with several values to establish before any gate operation works and nowhere to record where those values live. `.approval/env` is that place: a SOURCE MAP, sibling of the log directory as the vault is, one `KEY=VALUE` per line with `#` comments and blank lines ignored, no quoting and no interpolation. The VALUE says where the value lives, in one of four forms: `keychain:<service>` (macOS, `security find-generic-password -a "$USER" -s <service> -w`), `secret-service:<label>` (Linux desktop, `secret-tool lookup approval <label>`), `env:` (inherited from the ambient environment, and reported as inherited), or a bare literal. A literal is permitted and is ALWAYS reported as plaintext, by every diagnostic, because a rule people route around is not a control: an operator told plainly that their token sits in a file in the working tree can weigh that, while an operator forbidden from writing it there writes it into a shell profile where nothing can see it to say so. Values are never passed to a helper in an argv; they arrive on its stdout. The file MUST be mode 0600 (anything else is refused, with the `chmod` to run) and `approval init` adds it to `.gitignore`. **No command loads this file implicitly. A single verb, `approval env`, resolves it and emits an export block for a shell to evaluate, so the environment a gate operation runs under is always one a human established** (§11, §11.1 invariant 7). An already-exported value always wins over the file, and an absent file is not an error. The variables answered for are the human identity variable, the two Telegram variables, the vault passphrase, the sampling secret when the policy names one, and any other string-valued `_env` key in the policy. (Amended APRV-73.) The explicitly invoked human-only quickstart ceremony (§10.1) MAY resolve the declared sources of the fresh instance it just created solely for its health-preflight child. This is an explicit setup operation, not ambient loading by a gate, listener, agent tool or later process. It MUST NOT import another instance's ambient approval credentials, change the calling shell, or attest bytes that were not shown and confirmed. The operator still establishes the later gate environment through `approval env`. (Amended APRV-309, pending sign-off.)
165
170
  - **Durations.** Every duration-valued field (`approval_ttl`, budget windows, `max_latency`, `payload_retention`) is a string matching `<positive integer><unit>` with unit one of `ms`, `s`, `m`, `h`, `d`, `w` (weeks = 7 days). Single unit only: compound (`1h30m`), fractional (`1.5h`), zero, and leading-zero forms are invalid. An invalid duration anywhere in the policy is a schema violation and the policy fails closed.
166
171
 
@@ -300,6 +305,7 @@ The developer-workstation namespaces below are reserved alongside them. They nam
300
305
  | `policy.*` | `.edit` (agent instructions, CI and release configuration, and the paths a policy protects), `.core` (the policy file itself and the gate's own directory, minus its log) | manual, always; a policy MAY declare `.core` human-only |
301
306
  | `log.*` | `.sync`, `.advance` (section 10.1), `.mutate` (any write, redirect, append, truncation or rename aimed at the log directory) | manual, always; a policy MAY declare `.mutate` human-only |
302
307
  | `harness.launch.*` | `.codex`, `.muse`, `.grok`, `.claude`, `.cursor` (starting an agent harness session) | manual, always; never inferred autonomous; a policy MAY declare a member human-only |
308
+ | `harness.tool.*` | `.unmapped` (a harness tool call no adapter table and no `tools` entry claims, under `defaults.unmapped_tool`) | as `defaults.unmapped_tool` says when no rule matches: `record` autonomous, `ask` manual; a policy MAY declare it at any level (Amended APRV-499, pending sign-off.) |
303
309
 
304
310
  The `policy.*` split is by consequence rather than by file type. `policy.edit` is the prose and configuration ABOUT the gate, which a policy may reasonably sample; `policy.core` is the gate's own organs (the policy file, the approval home, and the harness files that install the hook), where sampling would let nine touches in ten through unprompted; `log.mutate` is a write to the record of what happened rather than to the rules. An implementation MUST answer a path by the strictest surface it names, and MUST classify a copy OUT of a protected path exactly as it classifies a copy into it. (Amended APRV-198.) The journal directory of section 10.1 is deliberately outside the approval home and takes no class of its own: a write there is an ordinary `files.write.workspace`, and an implementation MUST NOT make an ungated write reachable by relaxing a protected-path rule instead. (Amended APRV-195.)
305
311
 
@@ -348,6 +354,7 @@ For `record.*` classes, grant means adoption: the action proposes a write to a s
348
354
  - **The provider reference.** An `execution.completed` MAY carry `payload.provider_ref`, an object of exactly two non-empty strings and no others: `adapter`, the name of the adapter that executed the action, and `id`, the identifier the provider's own record files the effect under (an AgentMail `message_id`, a queue's receipt handle). Both are written by the runtime at the write boundary. `adapter` is the registered adapter's name, which the runtime already holds; `id` is lifted from what the adapter returned for that call and passes the same redaction sweep as every other string it returned (§11.1 invariant 3). The field exists to be a join key. `approval coverage` (§10.1) reads a provider's own record of what it did and asks whether this log ever saw each effect, and with no reference the strongest available answer is a record of a matching class inside the effect's window, so one gated send covers an ungated one of the same class beside it. With a reference, a record that names an effect by id is evidence about that exact effect, and an effect the provider recorded that no record names is a gap no window can close. It authorizes nothing: no grant, budget, verdict, or refusal reads it back, so §11.1 invariant 4 is untouched by a value that came in part from the far side. It is bounded in length and restricted to printable characters, so that an identifier cannot become a place to put a message body. It is OPTIONAL and additive: an execution whose adapter names no reference records none, every record written before the field existed still validates and still verifies, and a reader treats absence as the pre-amendment behaviour. An id the redaction sweep touched is omitted rather than recorded, because a redacted identifier matches nothing and would read like one that does. (Amended APRV-251.)
349
355
  - **The writing daemon.** A record appended by a daemon MAY carry `daemon`, the id of the daemon instance that wrote it, so that a log hosted by one party for another states which host process acted. The value is the id declared in that process's launch environment or one derived from the instance the log belongs to; it is stamped by the runtime at the write boundary and is never a caller's parameter. It is OPTIONAL and additive: a record written without it validates and verifies unchanged, and its absence is absence rather than a claim that no daemon wrote the record. An implementation MAY let an attested policy list the ids permitted to append (`daemons`, §5.2) and MUST then refuse an append from an unlisted id at the write boundary with a distinct code (`daemon-not-allowed` in the reference runtime), leaving the file byte-identical. The id is self-reported, so §11.1 invariant 4 binds it completely: an implementation MUST NOT let a listed id reduce any scrutiny, and MUST NOT read the field as an input to a verdict, an autonomy, a budget, a floor, a sampling draw or a token. (Amended APRV-383.)
350
356
  - **The policy a harness start was resolved under.** An `execution.started` that a harness path records (`execution: "harness"`) carries `payload.policy_sha256`, the SHA-256 of the attested policy bytes the write boundary re-checked the action's class against when it recorded the start, taken from the same attestation check and the same single read of the policy file that the write boundary's class resolution used. The runtime writes it at the write boundary, as it writes `ts`, and no caller parameter, option or field of the action's payload supplies it; a value of that name arriving by any of those routes is ignored. A start under a policy that is not attested, or whose bytes changed since attestation, is refused before anything is appended, so no stamp names bytes nobody attested. A policy-authorized start (autonomous, supervised, an unselected supervised-live draw) has no other record naming its policy, and the field lets a reader of the start alone say which rules were in force when it was recorded. A granted start, which could already recover its policy through `grant_seq`, carries it from the same code path, and there it equals the grant's own pin wherever the grant carries one, since a spend under a different attested policy is refused `policy-drift`. Where a harness adapter computes its verdict from an earlier read of the policy than the write boundary's, a re-attestation between the two leaves the stamp naming the policy in force at the append; an implementation SHOULD carry the verdict's attested hash to the write boundary and refuse a mismatch. It authorizes nothing: no verdict, budget, draw, loop floor or refusal reads it back, so §11.1 invariant 4 is untouched. It is covered by the record hash like every other payload field. It is OPTIONAL and additive: every record written before the field existed still validates and still verifies, a start written by a non-harness path (`approval run`, an adapter's `act`) records none at v0.1, and a reader treats absence as the pre-amendment behaviour, reconstructing the policy from the latest `policy.updated` before the record's seq. (Amended APRV-447.)
357
+ - A harness `execution.started` whose class came from the policy's tool mapping (a `tools` entry, or `harness.tool.unmapped`) MAY carry `payload.harness_tool`, the tool name, so that several tools sharing one class remain distinguishable. It is the name only: the call's arguments are bound by `payload_hash` and MUST NOT be written to the log. (Amended APRV-499, pending sign-off.)
351
358
  - Events MUST validate against the JSON Schemas in `schema/` before append. Validation at the write boundary is itself a control: an agent physically cannot request execution without declaring a class, key, and cost estimate.
352
359
  - Every record MUST carry an explicit hash-scheme identifier, `alg`. Version 0.1 defines exactly one value: `sha256/jcs`, meaning SHA-256 over the RFC 8785 (JCS) canonical serialization of the record with `prev` included. Verifiers MUST reject records whose `alg` is missing or unrecognized. Records with different `alg` values MAY coexist in one log, so a future scheme change is a migration, never a schism.
353
360
  - Actor identifiers use exactly three prefixes: `human:` for decisions made by a person, `agent:` for actions proposed or performed by an agent, and `system:` for runtime-originated events such as `approval.expired`. Verifiers MUST reject unrecognized prefixes.
@@ -550,10 +557,14 @@ One tool call is one question. Where several pending requests share one task and
550
557
 
551
558
  Review delivered through a channel (amended APRV-299). A channel MAY deliver a retrospective sample for review, under the same pacing and rendering rules this section already states. A review card is not a request and MUST NOT be presented as one: the action has already executed, so the card carries no payload region, offers no approval, accepts no token, and a channel MUST NOT deliver a sample as an approval request. What it carries is the computed and claimed split below, over facts the log already holds: the class the registration declared, what the payload bytes do, the task, the claimed summary, when it ran, and that the runtime allowed it without asking and at what rate. The gestures it collects are a verdict and, optionally, the graded reaction of §5.2, and every one of them MUST reach the log through the same human-only review a terminal calls, recorded against the human identity the runtime was configured with and never against anything the channel received, so that a reaction collected on a channel and one collected at a terminal are the same record; a refusal MUST reach the approver with its own machine-readable code. A reaction that requires the human's own words (§5.2) MUST collect them before anything is appended. The order and the card currently shown are process memory in the sense of the dispatch paragraph above: their loss MUST degrade to showing a sample again, and a sample absent from the approver's screen MUST remain in the sampled-audit backlog of §9, listable, and reviewable at any other surface. Nothing a channel does may close a sample other than by recording a human's review, because a supervision backlog a transport can empty measures nothing. (Amended APRV-299.)
552
559
 
560
+ Every `audit.reviewed` written records how its verdict was given in `payload.verdict_source`: `explicit`, the reviewer said it. A second value, `model`, is RESERVED for a review given by a judge identity `model:<name>@<version>` that the attested policy's `delegation.reviewers` admits. No implementation that refuses `delegation` writes it, and the write boundary refuses it together with any `model:` actor. A reader that meets `model` MUST NOT count the review as a human approval, and MAY ignore it. The identity kind `model:` is reserved on the same terms: it is admitted in `delegation.reviewers` only, and every human-only verb (grant, reject, revoke, attest, review, checkpoint and every channel decision) continues to require `human:`. (Amended APRV-500, pending sign-off.)
561
+
553
562
  Every displayed field is one of two kinds and MUST be visibly distinguished: **computed** (derived by the runtime from the log, policy, or payload bytes: class resolution, budget state, attestation status, payload hash, chain position) and **claimed** (authored by the requesting agent: summaries, estimates, rationale, confidence). Rendering claimed fields with the visual authority of computed fields misrepresents the verification boundary to the approver and is a conformance failure for a channel.
554
563
 
555
564
  For a `manual` action, a channel MUST present the canonical rendering of the payload described in §9, verbatim, and MUST NOT assemble a reading of its own. Claimed material MAY be appended around that block and MUST be visibly separated from it and labelled as claimed. A channel that shortens the payload before presenting it has no canonical rendering to show and MUST say so rather than giving a partial reading the block's authority. Two conforming channels therefore put the same text in front of two approvers for the same bytes, and the `display_hash` on `approval.requested` names that text. Renderer determinism and the closed-field-set property are conformance requirements, tested as such. (Amended APRV-119.)
556
565
 
566
+ Collapsed presentation (amended APRV-489, pending sign-off). Where the approver's attested policy asks a channel for its minimal style (§5.2), that channel MAY present the canonical rendering collapsed behind one expand gesture. The rendering MUST still be present byte for byte in the same message that carries the decision buttons, and MUST NOT be summarised, shortened, split from those buttons, or moved to another message. Outside the collapsed block, such a message carries only four kinds of text: lines the runtime computes from the log and the policy (a phrase chosen by the exact class the log records and the kind of its payload, from the runtime's own table, or from the attested policy only for a payload the runtime does not read itself, and a deadline that never states time left once none is); quotations of the bound payload, each a payload value verbatim, under a label or alone when it is the only quotation, visibly marked as quotations, with nothing computed, abbreviated, joined or paraphrased inside a quotation; claimed material labelled as not checked, placed below a quotation and never first; and computed notices of what the quotations leave out, which may state a lower bound on what is left out but never an exact count the runtime cannot compute. The first line is always computed. Such a channel MUST state on the visible part of the message, outside the quotations, whenever a quotation is cut or a payload field is not quoted, naming the fields not quoted; MUST mark, inside quotations, every invisible or default-ignorable character except within a grapheme cluster that is wholly a recognised emoji sequence, and every bidirectional formatting character present in the payload, so that no quotation can hide content; MUST isolate each quotation, so that it cannot reorder text outside itself; and MUST present the request in its ordinary form instead whenever the ordinary form would show any computed health or abnormal-state row, for a request delivered as part of a batch or grouped delivery, for an attestation prompt, for a truncated payload, when the whole rendering does not fit in the one message, and when the minimal message cannot be delivered. A decision collected from such a message is bound to the same `display_hash` as one collected from the ordinary form. (Amended APRV-489, pending sign-off.)
567
+
557
568
  Channels MAY present multiple pending requests as a batch and collect one human gesture over the set, and SHOULD for high-volume `record.*` classes. The log never batches: each granted or rejected request receives its own `approval.granted` or `approval.rejected` event carrying the batch's channel delivery id in its payload, so audit granularity survives ergonomic grouping. The id is carried in the payload field `batch_delivery_id`. Earlier v0.1 builds encoded it in the first line of the payload's `note` field as `batch_delivery_id=<id>`; those logs are append-only, so readers MUST accept both encodings for the life of v0.1, preferring the first-class field. A batch MUST NOT mix `manual` classes with differing payload-display requirements in a way that hides any full payload behind the fold of another.
558
569
 
559
570
  **Attestation collected through a channel.** Deciding a request is a tap. Deciding which rules are in force was still a terminal session, because attestation is human-only (§11) and identity is config-declared, so an agent running the amendment ceremony would be claiming the human identity. A channel closes that gap without moving the boundary. A party that has prepared a policy edit appends `policy.proposed`, a channel renders it as an ordinary `manual` prompt, and the approver's tap appends the `policy.updated` attestation under the human identity the listener holds, exactly as a grant lands today. The following four paragraphs amend §8, §10.1, this section, and §11 respectively. (Amended APRV-109.)
package/cli.js CHANGED
@@ -16,19 +16,86 @@
16
16
  * static import that throws) must still answer with a block. That is the only
17
17
  * thing this file can do that the runtime cannot: it runs before the runtime
18
18
  * exists. For `approval hook hermes` it prints `{"action":"block",...}` and
19
- * exits 2 on any failure to load or run; every other invocation keeps its old
20
- * behaviour exactly.
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.
21
22
  */
22
23
 
23
24
  import { existsSync, writeSync } from "node:fs";
24
25
 
25
- const entry = new URL("./dist/src/cli/main.js", import.meta.url);
26
26
  const argv = process.argv.slice(2);
27
27
  // Matched the way `main` dispatches it: `--no-color` is the one global flag it
28
28
  // strips, wherever it appears (APRV-445 recheck L-d).
29
29
  const dispatched = argv.filter((word) => word !== "--no-color");
30
30
  const hermesHook = dispatched[0] === "hook" && dispatched[1] === "hermes";
31
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
+ }
96
+
97
+ const entry = new URL("./dist/src/cli/main.js", import.meta.url);
98
+
32
99
  /** Hermes's own block directive, spelled here because the runtime may not load. */
33
100
  function hermesBlock(message) {
34
101
  writeSync(1, `${JSON.stringify({ action: "block", message: `hook-io: ${message}; nothing authorizes this call` })}\n`);
@@ -41,7 +108,6 @@ function hermesBlock(message) {
41
108
  // an ALLOW to Hermes. Such an exit leaves as 2, with the directive when nothing
42
109
  // was printed. Exit 0 with nothing on stdout is the post-event answer and is
43
110
  // left alone; the adapter itself never answers a pre-event that way.
44
- let printed = false;
45
111
  if (hermesHook) {
46
112
  const write = process.stdout.write.bind(process.stdout);
47
113
  process.stdout.write = (chunk, ...rest) => {
@@ -66,6 +132,7 @@ if (hermesHook) {
66
132
  if (!existsSync(entry)) {
67
133
  if (hermesHook) {
68
134
  hermesBlock("the approval runtime is not built (dist/src/cli/main.js is missing)");
135
+ answered = true;
69
136
  } else {
70
137
  // Exit 4 = I/O error in the frozen exit-code table (src/cli/exit-codes.ts).
71
138
  process.stderr.write(
@@ -80,6 +147,7 @@ if (!existsSync(entry)) {
80
147
  } catch (cause) {
81
148
  hermesBlock(`the hook could not run: ${cause instanceof Error ? cause.message : String(cause)}`);
82
149
  }
150
+ answered = true;
83
151
  } else {
84
152
  const { main } = await import(entry.href);
85
153
  // `main` is asynchronous since APRV-209: every verb is loaded on demand, and
@@ -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.
@@ -672,4 +700,29 @@ export interface ChannelDecisionResult {
672
700
  * dual-read window readers stay inside for the life of v0.1.
673
701
  */
674
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;
675
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). */
@@ -399,6 +405,10 @@ export function recordChannelDecision(logPath, decision, actorOptions, gateOptio
399
405
  if (decision.batchDeliveryId !== undefined) {
400
406
  options.batchDeliveryId = decision.batchDeliveryId;
401
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;
402
412
  // APRV-324. Every surface names itself on the record it writes, so a reader
403
413
  // of a grant can tell a tap on a phone from a line typed into a terminal. The
404
414
  // fallback matches `noteRefusedDecision`'s below.
@@ -519,6 +529,52 @@ export function recordChannelDecision(logPath, decision, actorOptions, gateOptio
519
529
  };
520
530
  return result.token === undefined ? { outcome } : { outcome, token: result.token };
521
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
+ }
522
578
  /**
523
579
  * Append the audit trail of a refused human decision, and swallow whatever goes
524
580
  * wrong doing it (APRV-235).
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/channels/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EACL,MAAM,EACN,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7D,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,KAAK;SACnB;KACF,CAAC;AACJ,CAAC"}
@@ -41,6 +41,7 @@
41
41
  * Determinism: no clock. `now` is a parameter, so a queue rendering is
42
42
  * replayable exactly as it was rendered.
43
43
  */
44
+ import { type PromptSay, type PromptStyle } from "../core/prompt-layout.js";
44
45
  import { type ChannelRequest } from "./contract.js";
45
46
  /**
46
47
  * Where the payload material for an action comes from.
@@ -185,6 +186,30 @@ export type PendingQueueResult = {
185
186
  */
186
187
  skipped: SkippedRequest[];
187
188
  } | ChannelTagRefusal;
189
+ /**
190
+ * The prompt style and `say` map a channel may draw with RIGHT NOW, taken only
191
+ * from attested policy bytes (APRV-489, fix round 2, S4 and its security
192
+ * follow-up).
193
+ *
194
+ * The policy file is read ONCE, and those bytes are both checked and used:
195
+ * they must hash to the latest attestation in the verified log (the digest the
196
+ * gate decides under), and the style and `say` are parsed from the very same
197
+ * buffer. There is no second read for the bytes to change between, so an edit
198
+ * to the file that nobody attested (by the agent the policy governs, in some
199
+ * deployments) can never switch a card to minimal or reword a class's phrase.
200
+ *
201
+ * Anything short of "these bytes are the attested policy" is the technical
202
+ * card: an unreadable file or log, a file that differs from the attestation, a
203
+ * log with no attestation. When the attested policy in force (its stored bytes)
204
+ * does ask for minimal, the answer carries `fallback: "policy-unattested"`, so
205
+ * the decision record says why the approver saw the technical card; under an
206
+ * attested technical policy nothing is added, so its records stay unchanged.
207
+ */
208
+ export declare function attestedPromptOf(logPath: string, options: TagOptions, channel: string): {
209
+ style: PromptStyle;
210
+ say: PromptSay;
211
+ fallback?: "policy-unattested";
212
+ };
188
213
  /**
189
214
  * Build the pending queue: every action key with a live `approval.requested`.
190
215
  *
@@ -42,20 +42,21 @@
42
42
  * replayable exactly as it was rendered.
43
43
  */
44
44
  import { createHash } from "node:crypto";
45
- import { existsSync } from "node:fs";
45
+ import { existsSync, readFileSync } from "node:fs";
46
46
  import { join } from "node:path";
47
- import { checkAttestation, policyFileHash, } from "../core/attest.js";
47
+ import { checkAttestation, checkAttestationOfBytes, policyFileHash, } from "../core/attest.js";
48
48
  import { evaluateBudgetsWithTask, } from "../core/budgets.js";
49
49
  import { usdNumber } from "../core/money.js";
50
50
  import { payloadHash } from "../core/payload.js";
51
51
  import { loadPayload, payloadStoreDirFor } from "../core/payload-store.js";
52
52
  import { explain } from "../core/policy-explain.js";
53
- import { loadPolicy, POLICY_FILENAMES, } from "../core/policy-load.js";
53
+ import { loadPolicy, loadPolicyText, POLICY_FILENAMES, } from "../core/policy-load.js";
54
+ import { DEFAULT_PROMPT_STYLE, promptSayFor, promptStyleFor, } from "../core/prompt-layout.js";
54
55
  import { resolve } from "../core/policy-match.js";
55
- import { ATTESTATION_CLASS, isAttestationActionKey, openProposals, } from "../core/policy-proposal.js";
56
+ import { ATTESTATION_CLASS, inForcePolicyText, isAttestationActionKey, openProposals, } from "../core/policy-proposal.js";
56
57
  import { isRecipientKey, RECIPIENT_KEY_FIELD } from "../core/seal.js";
57
58
  import { payloadOf, readVerifiedRecords, requestState, } from "../core/state.js";
58
- import { claimed, computed, createChannelRequest, } from "./contract.js";
59
+ import { claimed, computed, createChannelRequest, LIVE_TOOL_CALL, } from "./contract.js";
59
60
  import { commandBreakdown, commandPayloadView, protectedPathView } from "./payload-view.js";
60
61
  /** Why the tagger refused. Frozen per SPEC.md §11.1(6). */
61
62
  export const CHANNEL_TAG_REFUSAL_CODES = [
@@ -542,6 +543,12 @@ function tagDerivation(records, headSeq, derivation, load, options, now) {
542
543
  ...(typeof route["confidence"] === "number"
543
544
  ? { confidence: claimed(route["confidence"], registrationActor) }
544
545
  : {}),
546
+ // APRV-489. A tool call the agent is blocked in: the record declared the
547
+ // harness executes it and how long the harness waits. Symbol-keyed, so no
548
+ // channel's row list and no JSON output gains a key (see `LIVE_TOOL_CALL`).
549
+ ...(derivation.declared.execution === "harness" && derivation.declared.harness_cap_ms !== null
550
+ ? { [LIVE_TOOL_CALL]: computed(true, "log") }
551
+ : {}),
545
552
  };
546
553
  const created = createChannelRequest(fields);
547
554
  if (!created.ok)
@@ -671,6 +678,51 @@ function tagProposal(records, headSeq, proposal, load, options, now) {
671
678
  return refuse("request-invalid", created.message);
672
679
  return { ok: true, request: created.request };
673
680
  }
681
+ /**
682
+ * The prompt style and `say` map a channel may draw with RIGHT NOW, taken only
683
+ * from attested policy bytes (APRV-489, fix round 2, S4 and its security
684
+ * follow-up).
685
+ *
686
+ * The policy file is read ONCE, and those bytes are both checked and used:
687
+ * they must hash to the latest attestation in the verified log (the digest the
688
+ * gate decides under), and the style and `say` are parsed from the very same
689
+ * buffer. There is no second read for the bytes to change between, so an edit
690
+ * to the file that nobody attested (by the agent the policy governs, in some
691
+ * deployments) can never switch a card to minimal or reword a class's phrase.
692
+ *
693
+ * Anything short of "these bytes are the attested policy" is the technical
694
+ * card: an unreadable file or log, a file that differs from the attestation, a
695
+ * log with no attestation. When the attested policy in force (its stored bytes)
696
+ * does ask for minimal, the answer carries `fallback: "policy-unattested"`, so
697
+ * the decision record says why the approver saw the technical card; under an
698
+ * attested technical policy nothing is added, so its records stay unchanged.
699
+ */
700
+ export function attestedPromptOf(logPath, options, channel) {
701
+ const technical = { style: DEFAULT_PROMPT_STYLE, say: {} };
702
+ const read = readVerifiedRecords(logPath, options.schemaDir === undefined ? {} : { schemaDir: options.schemaDir });
703
+ if (!read.ok)
704
+ return technical;
705
+ const path = policyPathOf(options);
706
+ let bytes = null;
707
+ try {
708
+ bytes = readFileSync(path);
709
+ }
710
+ catch {
711
+ bytes = null;
712
+ }
713
+ if (bytes !== null && checkAttestationOfBytes(read.records, bytes).status === "attested") {
714
+ const load = loadPolicyText(path, bytes.toString("utf8"), options.schemaDir === undefined ? {} : { schemaDir: options.schemaDir });
715
+ return { style: promptStyleFor(load, channel), say: promptSayFor(load, channel) };
716
+ }
717
+ // Not the attested bytes. Say why only when the policy in force wanted minimal.
718
+ const inForce = inForcePolicyText(read.records, payloadStoreDirFor(logPath));
719
+ if (!inForce.ok)
720
+ return technical;
721
+ const attested = loadPolicyText(path, inForce.text, options.schemaDir === undefined ? {} : { schemaDir: options.schemaDir });
722
+ return promptStyleFor(attested, channel) === "minimal"
723
+ ? { ...technical, fallback: "policy-unattested" }
724
+ : technical;
725
+ }
674
726
  /**
675
727
  * Build the pending queue: every action key with a live `approval.requested`.
676
728
  *