approval-md 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +83 -914
  2. package/SPEC.md +98 -13
  3. package/cli.js +66 -7
  4. package/dist/src/adapters/smtp.d.ts +18 -0
  5. package/dist/src/adapters/smtp.js +24 -3
  6. package/dist/src/adapters/smtp.js.map +1 -1
  7. package/dist/src/channels/contract.d.ts +19 -0
  8. package/dist/src/channels/contract.js +105 -1
  9. package/dist/src/channels/contract.js.map +1 -1
  10. package/dist/src/channels/relay-server.d.ts +90 -0
  11. package/dist/src/channels/relay-server.js +295 -0
  12. package/dist/src/channels/relay-server.js.map +1 -0
  13. package/dist/src/channels/relay.d.ts +273 -0
  14. package/dist/src/channels/relay.js +564 -0
  15. package/dist/src/channels/relay.js.map +1 -0
  16. package/dist/src/channels/tagging.js +6 -1
  17. package/dist/src/channels/tagging.js.map +1 -1
  18. package/dist/src/channels/telegram-webhook.d.ts +273 -0
  19. package/dist/src/channels/telegram-webhook.js +536 -0
  20. package/dist/src/channels/telegram-webhook.js.map +1 -0
  21. package/dist/src/channels/telegram.d.ts +271 -1
  22. package/dist/src/channels/telegram.js +403 -45
  23. package/dist/src/channels/telegram.js.map +1 -1
  24. package/dist/src/cli/amend.js +350 -4
  25. package/dist/src/cli/amend.js.map +1 -1
  26. package/dist/src/cli/attest.js +43 -6
  27. package/dist/src/cli/attest.js.map +1 -1
  28. package/dist/src/cli/channel-relay.d.ts +108 -0
  29. package/dist/src/cli/channel-relay.js +334 -0
  30. package/dist/src/cli/channel-relay.js.map +1 -0
  31. package/dist/src/cli/channel-telegram-webhook.d.ts +273 -0
  32. package/dist/src/cli/channel-telegram-webhook.js +709 -0
  33. package/dist/src/cli/channel-telegram-webhook.js.map +1 -0
  34. package/dist/src/cli/channel-telegram.d.ts +272 -26
  35. package/dist/src/cli/channel-telegram.js +478 -41
  36. package/dist/src/cli/channel-telegram.js.map +1 -1
  37. package/dist/src/cli/channel.d.ts +1 -1
  38. package/dist/src/cli/channel.js +5 -1
  39. package/dist/src/cli/channel.js.map +1 -1
  40. package/dist/src/cli/daemon.js +37 -5
  41. package/dist/src/cli/daemon.js.map +1 -1
  42. package/dist/src/cli/doctor.d.ts +63 -0
  43. package/dist/src/cli/doctor.js +856 -111
  44. package/dist/src/cli/doctor.js.map +1 -1
  45. package/dist/src/cli/execute.d.ts +17 -1
  46. package/dist/src/cli/execute.js +341 -20
  47. package/dist/src/cli/execute.js.map +1 -1
  48. package/dist/src/cli/exit-codes.d.ts +12 -0
  49. package/dist/src/cli/exit-codes.js +13 -0
  50. package/dist/src/cli/exit-codes.js.map +1 -1
  51. package/dist/src/cli/gate.d.ts +2 -0
  52. package/dist/src/cli/gate.js +233 -2
  53. package/dist/src/cli/gate.js.map +1 -1
  54. package/dist/src/cli/help.d.ts +9 -1
  55. package/dist/src/cli/help.js +246 -38
  56. package/dist/src/cli/help.js.map +1 -1
  57. package/dist/src/cli/hook.d.ts +371 -3
  58. package/dist/src/cli/hook.js +1926 -44
  59. package/dist/src/cli/hook.js.map +1 -1
  60. package/dist/src/cli/init.js +16 -7
  61. package/dist/src/cli/init.js.map +1 -1
  62. package/dist/src/cli/instructions.js +24 -3
  63. package/dist/src/cli/instructions.js.map +1 -1
  64. package/dist/src/cli/log-anchor.d.ts +55 -0
  65. package/dist/src/cli/log-anchor.js +199 -60
  66. package/dist/src/cli/log-anchor.js.map +1 -1
  67. package/dist/src/cli/main.d.ts +0 -12
  68. package/dist/src/cli/main.js +51 -0
  69. package/dist/src/cli/main.js.map +1 -1
  70. package/dist/src/cli/muse.d.ts +2 -0
  71. package/dist/src/cli/muse.js +62 -0
  72. package/dist/src/cli/muse.js.map +1 -0
  73. package/dist/src/cli/payload.js +79 -1
  74. package/dist/src/cli/payload.js.map +1 -1
  75. package/dist/src/cli/scaffold.js +6 -0
  76. package/dist/src/cli/scaffold.js.map +1 -1
  77. package/dist/src/cli/serve.d.ts +53 -0
  78. package/dist/src/cli/serve.js +270 -0
  79. package/dist/src/cli/serve.js.map +1 -0
  80. package/dist/src/cli/up.js +21 -2
  81. package/dist/src/cli/up.js.map +1 -1
  82. package/dist/src/cli/verb-registry.d.ts +2 -0
  83. package/dist/src/cli/verb-registry.js +337 -39
  84. package/dist/src/cli/verb-registry.js.map +1 -1
  85. package/dist/src/cli/wordmark.d.ts +2 -2
  86. package/dist/src/cli/wordmark.js +2 -2
  87. package/dist/src/core/attest-bootstrap.d.ts +95 -0
  88. package/dist/src/core/attest-bootstrap.js +135 -0
  89. package/dist/src/core/attest-bootstrap.js.map +1 -0
  90. package/dist/src/core/attest.d.ts +20 -3
  91. package/dist/src/core/attest.js +25 -0
  92. package/dist/src/core/attest.js.map +1 -1
  93. package/dist/src/core/audit.d.ts +55 -3
  94. package/dist/src/core/audit.js +52 -5
  95. package/dist/src/core/audit.js.map +1 -1
  96. package/dist/src/core/channel-lease.d.ts +322 -0
  97. package/dist/src/core/channel-lease.js +663 -0
  98. package/dist/src/core/channel-lease.js.map +1 -0
  99. package/dist/src/core/command-class.d.ts +51 -0
  100. package/dist/src/core/command-class.js +760 -8
  101. package/dist/src/core/command-class.js.map +1 -1
  102. package/dist/src/core/daemon-host.d.ts +178 -0
  103. package/dist/src/core/daemon-host.js +228 -0
  104. package/dist/src/core/daemon-host.js.map +1 -0
  105. package/dist/src/core/daemon-identity.d.ts +238 -0
  106. package/dist/src/core/daemon-identity.js +252 -0
  107. package/dist/src/core/daemon-identity.js.map +1 -0
  108. package/dist/src/core/gate.d.ts +306 -5
  109. package/dist/src/core/gate.js +772 -24
  110. package/dist/src/core/gate.js.map +1 -1
  111. package/dist/src/core/harness-version.d.ts +128 -4
  112. package/dist/src/core/harness-version.js +179 -12
  113. package/dist/src/core/harness-version.js.map +1 -1
  114. package/dist/src/core/harness-wait.d.ts +82 -3
  115. package/dist/src/core/harness-wait.js +89 -3
  116. package/dist/src/core/harness-wait.js.map +1 -1
  117. package/dist/src/core/log-subscribe.d.ts +21 -0
  118. package/dist/src/core/log-subscribe.js +16 -6
  119. package/dist/src/core/log-subscribe.js.map +1 -1
  120. package/dist/src/core/log-write-layer.d.ts +55 -0
  121. package/dist/src/core/log-write-layer.js +91 -0
  122. package/dist/src/core/log-write-layer.js.map +1 -0
  123. package/dist/src/core/log.d.ts +50 -21
  124. package/dist/src/core/log.js +197 -19
  125. package/dist/src/core/log.js.map +1 -1
  126. package/dist/src/core/payload-census.d.ts +51 -0
  127. package/dist/src/core/payload-census.js +125 -2
  128. package/dist/src/core/payload-census.js.map +1 -1
  129. package/dist/src/core/payload-store.d.ts +31 -0
  130. package/dist/src/core/payload-store.js +113 -8
  131. package/dist/src/core/payload-store.js.map +1 -1
  132. package/dist/src/core/payload.d.ts +18 -3
  133. package/dist/src/core/payload.js +20 -4
  134. package/dist/src/core/payload.js.map +1 -1
  135. package/dist/src/core/policy-diff.d.ts +10 -0
  136. package/dist/src/core/policy-diff.js +10 -2
  137. package/dist/src/core/policy-diff.js.map +1 -1
  138. package/dist/src/core/policy-explain.d.ts +7 -1
  139. package/dist/src/core/policy-explain.js +16 -1
  140. package/dist/src/core/policy-explain.js.map +1 -1
  141. package/dist/src/core/policy-load.d.ts +24 -0
  142. package/dist/src/core/policy-load.js.map +1 -1
  143. package/dist/src/core/policy-match.d.ts +38 -0
  144. package/dist/src/core/policy-match.js +35 -0
  145. package/dist/src/core/policy-match.js.map +1 -1
  146. package/dist/src/core/policy-proposal.d.ts +23 -0
  147. package/dist/src/core/policy-proposal.js +8 -2
  148. package/dist/src/core/policy-proposal.js.map +1 -1
  149. package/dist/src/core/read-scope.d.ts +10 -0
  150. package/dist/src/core/read-scope.js +4 -0
  151. package/dist/src/core/read-scope.js.map +1 -1
  152. package/dist/src/core/run-payload.d.ts +160 -0
  153. package/dist/src/core/run-payload.js +304 -0
  154. package/dist/src/core/run-payload.js.map +1 -0
  155. package/dist/src/core/sender-identity.d.ts +35 -10
  156. package/dist/src/core/sender-identity.js +48 -11
  157. package/dist/src/core/sender-identity.js.map +1 -1
  158. package/dist/src/core/state.d.ts +52 -1
  159. package/dist/src/core/state.js +52 -6
  160. package/dist/src/core/state.js.map +1 -1
  161. package/dist/src/core/telegram-config.d.ts +79 -0
  162. package/dist/src/core/telegram-config.js +108 -0
  163. package/dist/src/core/telegram-config.js.map +1 -1
  164. package/dist/src/core/verify.d.ts +23 -1
  165. package/dist/src/core/verify.js +20 -2
  166. package/dist/src/core/verify.js.map +1 -1
  167. package/dist/src/daemon/audit.d.ts +80 -5
  168. package/dist/src/daemon/audit.js +126 -6
  169. package/dist/src/daemon/audit.js.map +1 -1
  170. package/dist/src/daemon/daemon.d.ts +174 -2
  171. package/dist/src/daemon/daemon.js +298 -7
  172. package/dist/src/daemon/daemon.js.map +1 -1
  173. package/dist/src/daemon/git-evidence.d.ts +2 -2
  174. package/dist/src/daemon/git-evidence.js +1 -1
  175. package/dist/src/daemon/projection.d.ts +13 -2
  176. package/dist/src/daemon/projection.js +39 -6
  177. package/dist/src/daemon/projection.js.map +1 -1
  178. package/dist/src/mcp/server.d.ts +39 -3
  179. package/dist/src/mcp/server.js +22 -3
  180. package/dist/src/mcp/server.js.map +1 -1
  181. package/dist/src/muse/server.d.ts +16 -0
  182. package/dist/src/muse/server.js +238 -0
  183. package/dist/src/muse/server.js.map +1 -0
  184. package/dist/src/serve/archive.d.ts +158 -0
  185. package/dist/src/serve/archive.js +354 -0
  186. package/dist/src/serve/archive.js.map +1 -0
  187. package/dist/src/serve/arguments.d.ts +93 -0
  188. package/dist/src/serve/arguments.js +228 -0
  189. package/dist/src/serve/arguments.js.map +1 -0
  190. package/dist/src/serve/credentials.d.ts +91 -0
  191. package/dist/src/serve/credentials.js +143 -0
  192. package/dist/src/serve/credentials.js.map +1 -0
  193. package/dist/src/serve/follow.d.ts +86 -0
  194. package/dist/src/serve/follow.js +101 -0
  195. package/dist/src/serve/follow.js.map +1 -0
  196. package/dist/src/serve/hook-thread.d.ts +134 -0
  197. package/dist/src/serve/hook-thread.js +333 -0
  198. package/dist/src/serve/hook-thread.js.map +1 -0
  199. package/dist/src/serve/hook-worker.d.ts +134 -0
  200. package/dist/src/serve/hook-worker.js +173 -0
  201. package/dist/src/serve/hook-worker.js.map +1 -0
  202. package/dist/src/serve/server.d.ts +412 -0
  203. package/dist/src/serve/server.js +1251 -0
  204. package/dist/src/serve/server.js.map +1 -0
  205. package/docs/README-extended.md +766 -0
  206. package/docs/cli-reference.md +1633 -43
  207. package/package.json +4 -2
  208. package/schema/event.schema.json +59 -2
  209. package/schema/fixtures/event/invalid/daemon-id-malformed.json +15 -0
  210. package/schema/fixtures/event/invalid/execution-started-truncated-policy-sha256.json +18 -0
  211. package/schema/fixtures/event/invalid/harness-cap-at-margin.json +16 -0
  212. package/schema/fixtures/event/invalid/harness-cap-fractional.json +16 -0
  213. package/schema/fixtures/event/invalid/harness-cap-negative.json +16 -0
  214. package/schema/fixtures/event/invalid/harness-cap-string.json +16 -0
  215. package/schema/fixtures/event/invalid/harness-cap-without-harness-execution.json +16 -0
  216. package/schema/fixtures/event/invalid/harness-cap-zero.json +16 -0
  217. package/schema/fixtures/event/valid/approval-requested-harness-cap.json +18 -0
  218. package/schema/fixtures/event/valid/daemon-identity-declared.json +17 -0
  219. package/schema/fixtures/event/valid/daemon-identity.json +15 -0
  220. package/schema/fixtures/event/valid/execution-started-policy-sha256.json +18 -0
  221. package/schema/fixtures/event/valid/harness-kind-hermes.json +23 -0
  222. package/schema/fixtures/policy/invalid/daemons-malformed-id.json +10 -0
  223. package/schema/fixtures/policy/valid/daemons-allowlist.json +19 -0
  224. package/schema/fixtures/policy-md/invalid/schema-invalid-agent-may-request.md +21 -0
  225. package/schema/fixtures/policy-md/valid/agent-may-request.md +24 -0
  226. package/schema/policy.schema.json +50 -6
package/README.md CHANGED
@@ -3,979 +3,148 @@
3
3
  [![ci](https://github.com/approval-md/approval.md/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/approval-md/approval.md/actions/workflows/ci.yml)
4
4
  [![fable](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fapproval-md%2Fapproval.md%2Fmain%2Fmetrics%2Fagent-hours.json&query=%24.agents.claude-fable.hours&label=fable&suffix=h&color=d97757)](docs/agent-hours.md) [![opus](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fapproval-md%2Fapproval.md%2Fmain%2Fmetrics%2Fagent-hours.json&query=%24.agents.claude-opus.hours&label=opus&suffix=h&color=d97757)](docs/agent-hours.md) [![astra](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fapproval-md%2Fapproval.md%2Fmain%2Fmetrics%2Fagent-hours.json&query=%24.agents.codex-astra.hours&label=astra&suffix=h&color=10a37f)](docs/agent-hours.md) [![sol](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fapproval-md%2Fapproval.md%2Fmain%2Fmetrics%2Fagent-hours.json&query=%24.agents.codex-sol.hours&label=sol&suffix=h&color=10a37f)](docs/agent-hours.md) [![cursor](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fapproval-md%2Fapproval.md%2Fmain%2Fmetrics%2Fagent-hours.json&query=%24.agents.cursor.hours&label=cursor&suffix=h&color=6c5ce7)](docs/agent-hours.md) [![agent hours](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fapproval-md%2Fapproval.md%2Fmain%2Fmetrics%2Fagent-hours.json&query=%24.total_hours&label=agent%20hours&suffix=h&color=555)](docs/agent-hours.md)
5
5
 
6
- **A harness-agnostic, open-source framework for approving agent actions with a
7
- human in the loop.**
6
+ **A harness-agnostic, open-source framework for approving agent actions with a human in the loop.**
8
7
 
9
- Your agent is about to send the email, push to main, spend the money, delete
10
- the folder, or publish the post. A bad diff can be reverted. A sent message
11
- cannot, and it carries your name.
8
+ Let your agents work. Decide where they need you.
12
9
 
13
- approval.md puts a button between the agent and that action. You write a
14
- short policy file saying which kinds of action need you. The agent runs freely
15
- inside those lines. When it reaches one, a message arrives on your phone with
16
- exactly what is about to happen, and nothing happens until you tap.
10
+ Write an `APPROVAL.md` that says which actions can happen freely, which need a tap, and which stay in human hands. Approve from Telegram, a terminal, or a local web queue. Keep the policy and the record of decisions in files you can read and verify.
17
11
 
18
- Two things people use it for first:
12
+ Let an agent draft your email, but ask before sending it. Let it edit your project, but stop before pushing to main. Review a sample of routine work instead of every action.
19
13
 
20
- - **Signing off an email.** The agent drafts, you read the recipients, subject
21
- and body on your phone, you tap Approve, and the adapter sends it once with a
22
- credential the agent never held.
23
- - **Watching a coding agent.** A hook classifies every command Claude Code or
24
- Cursor runs. Reads and edits go through; `git push origin main`, `npm
25
- install`, `curl -d`, `rm -rf` come to your phone first, and every decision is
26
- in a log you can verify.
14
+ [Website](https://approval.md/) · [Extended guide](docs/README-extended.md) · [Specification](SPEC.md) · [CLI reference](docs/cli-reference.md)
27
15
 
28
- Spec site: https://approval.md · Specification: [SPEC.md](SPEC.md) · Package:
29
- `approval-md` on npm.
16
+ ## Get started
30
17
 
31
- ## Five minutes to a working gate
32
-
33
- **1. Install.** No source checkout is required for the published CLI.
18
+ **Node.js 20 or newer.** In your project directory:
34
19
 
35
20
  ```sh
36
21
  npm install -g approval-md
37
- ```
38
-
39
- **2. Make a gate.** For the published 0.2.0 package, run `approval init`, edit
40
- and read `APPROVAL.md`, run `approval setup identity`, optionally run
41
- `approval setup channel telegram`, then run `approval policy attest --as human:<id>`.
42
-
43
- The `quickstart` command combines these steps and ships in the published
44
- package. Run the three-question ceremony in the project directory.
45
- It asks who you are, whether decisions appear in this terminal or on Telegram,
46
- and which five class families always ask. It shows the exact policy and requires
47
- the typed word `understood` before attesting it. From a source checkout, build
48
- first (`npm ci` and `npm run build`) and run the same verb through your linked
49
- binary.
50
-
51
- ```sh
52
22
  approval quickstart
53
23
  ```
54
24
 
55
- Then run the `activate:` command quickstart prints. It includes the absolute
56
- project directory, so it resolves this instance even if the next shell starts
57
- somewhere else.
58
-
59
- ```
60
- ready: 5 selected class families ask human:yourname on cli; other classified reversible actions use the autonomous default
61
- ```
25
+ The walkthrough asks who you are, where approvals should arrive, and which action families should always ask. It shows the policy before you attest it. Telegram setup is included when you choose it.
62
26
 
63
- The gate is operative. `.approval/env` remains inert until you run the explicit
64
- `eval` line. Protected controls, failed policy loads, irreversible declarations,
65
- and commands the classifier cannot read still take their stricter paths.
27
+ The quickstart gives **other classified, reversible actions an autonomous default**. Change `defaults.autonomy` to `manual` for a more conservative policy, then re-attest. Runtime safety floors and unclassified-command refusals still apply.
66
28
 
67
- **3. Run the local service.** If you chose Telegram, message **@BotFather**
68
- with `/newbot` before quickstart so you have the token it asks for. After setup
69
- and human attestation, start the full runtime from this policy project's directory:
29
+ Activate the environment using the command the walkthrough prints. From the same project directory:
70
30
 
71
31
  ```sh
72
- cd /path/to/your/project
73
- eval "$(approval env)" # explicitly load this instance's environment
74
- approval up # daemon and configured channels, one foreground process
32
+ eval "$(approval env)"
33
+ approval up
75
34
  ```
76
35
 
77
- For a source checkout, use `node /path/to/approval.md/cli.js env` inside the
78
- `eval` line and `node /path/to/approval.md/cli.js up` to start the service.
79
- Leave the service running. Requests use your configured channel; Telegram
80
- requests reach your phone. `up` does not load `.approval/env` itself. An already
81
- exported approval variable wins over the environment map, so start with a clean
82
- shell or unset another instance's approval variables before evaluating it.
83
-
84
- Use `approval up` for normal operation. `approval channel telegram listen` runs
85
- only the Telegram component, for focused use or diagnosis. Never run both
86
- against the same bot, or run two instances polling that bot: Telegram returns
87
- HTTP 409. Stop the polling runtime before rerunning `approval setup channel
88
- telegram`, then reload the environment and start `up` again.
89
-
90
- `up` runs a preflight before it starts anything: it fetches, fast-forwards when
91
- the upstream range is safe, and rebuilds when `dist/` is older than `src/`. When
92
- the log directory lives in that checkout, a pull that changes
93
- `.approval/log/events.jsonl` while this copy has appended to it is the routine
94
- state rather than an incident, so the preflight reconciles it through `approval
95
- log sync` itself and prints one line saying what it fast-forwarded to and how
96
- many local records it kept. The one case left for a hand-run `approval log
97
- sync` is a genuine fork: two chains that share a prefix and then carry different
98
- records at the same `seq`. Hash chains do not merge, so `up` refuses
99
- `up-preflight-log-diverged` there, changes nothing, and leaves the decision to
100
- you.
101
-
102
- By default the daemon scans `backlog/tasks/`. If your envelopes live elsewhere,
103
- use `approval up --tasks /path/to/existing/task-folder`. The scan reads `.md`
104
- files directly inside that folder, without descending into subdirectories.
105
- Creating an empty default folder does not monitor envelopes stored elsewhere.
106
- A missing default folder warns about envelope drift coverage; TTL sweeping,
107
- queue rendering and configured channels can still run. See [runtime startup
108
- checks](docs/cli-reference.md#up) for the draw socket and optional web channel.
109
-
110
- **4. Pick your first experience.**
111
-
112
- - *A coding agent*: [gate your coding agent](#gate-your-coding-agent) is two
113
- more steps, a classification you can try immediately and a hook you paste
114
- into `.claude/settings.json`.
115
- - *An email*: [hand a grant to a real credential](#hand-a-grant-to-a-real-credential)
116
- adds an SMTP or AgentMail credential to the vault, and
117
- [examples/email-demo.md](examples/email-demo.md) walks the whole send.
118
-
119
- When something does not work, `approval doctor` prints one line per check with
120
- a `fix:` line under each failure. It is described under [Running the
121
- checks](#running-the-checks), and it is not a step you need on the way in.
122
-
123
- ## What it is made of
124
-
125
- - **A policy file you wrote.** `APPROVAL.md` is markdown at the root of your
126
- project with one YAML block declaring which classes of side effect an agent
127
- may take on its own, which need you, and under what budgets. A human signs
128
- for its exact bytes; an edit makes it inoperative until someone signs again.
129
- - **A message on your phone.** A request arrives over Telegram carrying what
130
- the runtime computed, what the agent claimed, and the exact bytes about to
131
- leave. You tap Approve or Reject. A local web page and the terminal are the
132
- other two channels.
133
- - **A single-use execution token.** Minted at one place in the code, only as a
134
- human decision is recorded, spent once, stored nowhere. Manual and selected
135
- live executions require it. An attested class rule may instead explicitly
136
- authorize an irreversible supervised or autonomous execution.
137
- - **A log nobody can quietly rewrite.** Every proposal, decision and execution
138
- is an append-only, hash-chained JSONL record. `approval log verify` answers
139
- for the chain.
140
-
141
- Not everything is worth a tap. A class declared `supervised` runs at once, and
142
- a fraction of those runs is sampled for your retrospective review using a
143
- secret the agent cannot read, so you see one in a hundred `gh pr merge` calls
144
- rather than all of them.
145
-
146
- The design rule is **files are the interface, the log is the truth, the
147
- database is a cache**. Routing, gating, budget math and chain verification are
148
- deterministic code. Models propose; the runtime decides.
149
-
150
- ## How the gate holds
151
-
152
- - **Credentials live in an encrypted vault**, never in the policy file and never
153
- in the agent's environment. `APPROVAL.md` carries the *name* of an environment
154
- variable, and there is no `approval vault get`.
155
- - **Adapters answer only inside a verified execution.** Manual and selected-live
156
- executions present and consume a valid token. An irreversible supervised or
157
- autonomous execution must be explicitly enabled by its attested class rule.
158
- The adapter opens the credential window only after the runtime authorizes the
159
- declared action, then closes it as soon as the adapter returns.
160
- - **Tokens are minted at one site**, in the path that records a human decision,
161
- and the log holds only their SHA-256. A second spend is refused
162
- `token-consumed`.
163
- - **The log makes tampering evident.** Each record chains to the previous one.
164
- Projections rebuild from the log and never write back.
165
- - **The harness hook covers the direct-shell path.** `approval hook claude-code`
166
- classifies the commands a coding agent runs on its own and answers allow or
167
- deny, fail-closed.
168
- - **The escape hatch is a recorded ceremony.** When the gate itself is broken, a
169
- human opens a time-boxed window with `approval gate open`: a terminal, a
170
- required `--reason`, and the typed word `understood`. Every call it lets
171
- through is logged as `gate.bypassed`, human-only classes stay refused, and
172
- `approval status` reports unhealthy until it closes
173
- ([docs/cli-reference.md#gate](docs/cli-reference.md#gate)).
174
-
175
- This is an oversight layer for broadly cooperative agents, with hard
176
- enforcement at the adapter boundaries that hold the credentials (SPEC.md
177
- section 11). Identity in v0.1 is config-declared, so the trust boundary is the
178
- machine rather than cryptography. ["Can't the agent just go around
179
- it?"](#cant-the-agent-just-go-around-it) works through each evasion.
36
+ This starts the daemon and configured channel listeners. It **does not install a harness hook**: connect your agent below. For terminal decisions, run `approval channel cli` in another human-controlled terminal.
180
37
 
181
- ## Gate your coding agent
182
-
183
- `approval run` gates the commands an agent hands to the runtime. It cannot gate
184
- the ones the harness runs directly, and those are most of them. Two surfaces
185
- close that gap: a PreToolUse hook for Claude Code and an MCP server for any
186
- harness that speaks MCP. Both resolve against the same policy and append to the
187
- same log as the CLI.
188
-
189
- Codex support is opt-in while native compatibility and everyday activation are
190
- still being verified. See the bounded [Codex hook operator
191
- runbook](docs/codex-hook.md) before installing or trusting it, and
192
- [activation and rollback](docs/codex-activation.md) for what a trust tap does
193
- and does not buy on the Codex version installed today.
194
-
195
- **1. See how a command classifies.** This touches nothing.
196
-
197
- ```
198
- $ approval hook classify -- npm install left-pad
199
- class rule command
200
- deps.add npm-install-package npm install left-pad
201
-
202
- classes: deps.add
203
- ```
38
+ Prefer to build the policy yourself? Start with `approval init` and follow the [manual setup](docs/README-extended.md#manual-setup). For unreleased features or contributions, use a [source checkout](docs/README-extended.md#install-from-source).
204
39
 
205
- Every segment of a command line is classified and the command takes the union,
206
- so `git status && curl -d …` is gated as `network.call`.
207
-
208
- **2. Install the hook.** It lives in `.claude/settings.json`, and a human
209
- commits that file: an agent that could write its own hook entry could write
210
- itself out of it.
211
-
212
- ```json
213
- { "hooks": { "PreToolUse": [ {
214
- "matcher": "Bash|Edit|Write|MultiEdit|NotebookEdit",
215
- "hooks": [ { "type": "command", "timeout": 600,
216
- "command": "approval hook claude-code --dir <primary checkout> --as agent:claude-code --timeout 9m" } ]
217
- } ] } }
218
- ```
219
-
220
- Register the same command under `PostToolUse` as well, without `--timeout`, so
221
- the runtime learns how each command ended. `--dir` resolves the policy and the
222
- log together, so a session inside a linked worktree still writes to the one
223
- log. Keep `--timeout` (how long the hook waits for you) below `timeout` (Claude
224
- Code's cap on the process).
225
-
226
- **3. Watch a verdict.** An `autonomous` class allows and logs nothing. A
227
- `supervised` class allows and records the action for sampling. A `manual` class
228
- waits for your tap. Anything the classifier cannot read denies. There is no
229
- "ask" answer: a decision taken outside the log is a decision nothing can audit.
230
- The deny reason is `<code>: <detail>`, and the codes are frozen
231
- (`hook-unclassified`, `hook-opaque`, `hook-rejected`, `hook-timeout` and the
232
- rest in [docs/claude-code-hook.md](docs/claude-code-hook.md)).
233
-
234
- **4. Know the sharp edges.** The hook never creates a log: pointed at a path
235
- with no log it denies `hook-log-unreachable` rather than forking a second
236
- chain. A wait that runs out keeps its question open for a short grace and then
237
- withdraws it, so nobody is pinged about a question whose asker has left. A hook
238
- grant mints no token: the harness runs the command itself.
239
-
240
- **5. Or connect the MCP server.** `approval mcp serve` is a stdio server
241
- publishing the agent's verbs as tools.
40
+ ## Define what needs approval
242
41
 
243
- ```sh
244
- claude mcp add approval -- \
245
- node /path/to/approval-md/dist/src/cli/main.js mcp serve \
246
- --as agent:claude-code \
247
- --dir /path/to/project
248
- ```
42
+ Five autonomy levels, chosen per action class:
249
43
 
250
- `register`, `request`, `wait`, `run`, `queue`, `status` and the rest of the
251
- agent's surface are there. `grant`, `reject`, `revoke`, `policy attest` and
252
- `vault set` are not: an MCP client is the agent's harness, and a `grant` tool
253
- on it would hand the agent the overseer's pen. Grant never travels over MCP,
254
- and neither does the token it mints. The identity is fixed at startup and
255
- `--as` is removed from every published schema, so a tool call cannot name an
256
- actor. Walkthrough: [examples/mcp-demo.md](examples/mcp-demo.md).
44
+ | Level | What happens |
45
+ | --- | --- |
46
+ | `autonomous` | Proceeds without asking, subject to the policy and runtime checks. |
47
+ | `supervised-retro` | Proceeds; a configured sample is reviewed afterwards. |
48
+ | `supervised-live` | A declared fraction pauses for approval; the rest proceeds. |
49
+ | `manual` | Each action waits for human approval. |
50
+ | `human-only` | The human performs the action. An agent cannot request permission to do it. |
257
51
 
258
- A harness that can run commands needs neither surface: `request`, `wait`, `run`
259
- is how sessions in this repository take manual-class actions
260
- ([docs/dogfood-cutover.md](docs/dogfood-cutover.md)). The task-file side of
261
- that flow, on a Backlog.md board, is
262
- [examples/backlog-md-project/README.md](examples/backlog-md-project/README.md).
52
+ An `APPROVAL.md` can look like this. This example uses a more conservative default than the quickstart; replace `you` with your chosen approver ID.
263
53
 
264
- ## Put approvals on your phone
54
+ ````markdown
55
+ # Approval Policy
265
56
 
266
- **1. Setup writes the environment map, not the secrets.** `approval setup
267
- channel telegram` puts the bot token in the OS keystore (macOS Keychain, or
268
- `secret-tool` on Linux) and records in `.approval/env` only where it lives. The
269
- verbs are interactive by refusal: a pipe or `--json` exits 2 and prints the
270
- non-interactive commands, because a setup a CI job could drive would let a CI
271
- job declare a human identity. `approval env` is the only command that reads
272
- that file, and evaluating it is a step a human takes. Stop any `approval up`
273
- process or standalone listener polling this bot before setup, because setup
274
- also polls to discover the chat. After setup, from this project's directory run
275
- `eval "$(approval env)"` and `approval up`. Full walkthrough:
276
- [examples/telegram-demo.md](examples/telegram-demo.md).
277
-
278
- **2. A request binds to exact bytes.** The payload lives in a file, the
279
- envelope declares its `payload_hash`, and `--payload` supplies the bytes at
280
- request time:
57
+ Work freely inside this project. Ask before reaching outside it.
281
58
 
282
- ```sh
283
- approval payload hash payload.json # the binding the envelope declares
284
- approval register task-demo.md --as agent:drafter
285
- approval request task-demo --action task-demo:chaser --payload payload.json --as agent:drafter
59
+ ```yaml approval-policy
60
+ version: "0.1"
61
+ defaults: { autonomy: manual, channel: cli, approval_ttl: 24h }
62
+ approvers:
63
+ you: { channels: [cli] }
64
+ classes:
65
+ read.*: { autonomy: autonomous }
66
+ read.file.out_of_scope: { autonomy: manual }
67
+ files.write.workspace: { autonomy: autonomous }
68
+ vcs.push.main: { autonomy: manual }
69
+ communicate.email.external: { autonomy: manual }
70
+ financial.spend: { autonomy: manual, limits: { per_action_usd: 25 } }
71
+ account.credential: { autonomy: human-only }
286
72
  ```
73
+ ````
287
74
 
288
- ```
289
- registered task-demo at seq 2: 1 action(s)
290
- requested task-demo task-demo:chaser at seq 3 (manual)
291
- ```
75
+ Class names describe actions; they do not install an integration for them. `supervised-live` needs a `live_rate` and sampling setup. The deprecated `supervised` spelling remains an alias of `supervised-retro`.
292
76
 
293
- Material that hashes to something else is refused `payload-mismatch`, and
294
- nothing is stored or appended. Class, cost and reversibility come from the
295
- registered envelope rather than from flags, so an agent cannot rename its own
296
- class between registering and asking. An approval is about specific bytes,
297
- never about a description of them.
298
-
299
- **3. The runtime delivers it.** `approval up` prints `notified
300
- task-demo:chaser (message 501)` and your phone has it. That one foreground
301
- process is the daemon loop (envelope drift, expiry, queue regeneration,
302
- retrospective sampling) plus every channel the policy configures. A channel
303
- whose credential is unset is not started and says so; a channel that falls over
304
- is restarted with backoff while the loop keeps ticking. `approval setup service`
305
- writes the launchd or systemd user unit that starts it at login, and prints the
306
- whole unit for you to read first.
307
-
308
- The message shows the action key, a **COMPUTED** block the runtime derived
309
- (class, task, binding, budget verdicts, chain head), a **CLAIMED** block naming
310
- the agent and marked unverified, the **FULL PAYLOAD**, and two buttons. It says
311
- how long an answer still has: `waiting: requested 4 min ago · expires 13:07
312
- UTC`, or, for a request a process is blocked on, `requester waits until 13:07
313
- UTC`. An email-shaped payload is rendered field by field with real line
314
- breaks, with the canonical JSON and its hash underneath. Detection is
315
- structural and never reads a self-declared type. Agent-authored text is
316
- HTML-escaped, so markup stays inert.
317
-
318
- An optional gloss, a one-line plain-English reading of the payload by a model,
319
- can sit above the computed block. It is marked unverified, it never changes a
320
- verdict, and a failed gloss is omitted while delivery continues:
77
+ An edit invalidates the previous attestation. To land a change, run the amendment ceremony: it shows the semantic diff, attests the exact bytes, and commits the policy and the log together. In a git repository, add `--pr` and it opens the pull request for you.
321
78
 
322
79
  ```sh
323
- approval up --gloss-provider codex --gloss-model gpt-5.4-mini # or the default, claude/haiku
324
- ```
325
-
326
- **4. Tap Approve.** The prompt rewrites itself in place. The buttons go away and
327
- the text becomes the outcome:
328
-
329
- ```
330
- ✓ APPROVED
331
- task-demo:chaser
332
-
333
- by human:alice at 10:20 UTC (seq 4)
80
+ approval policy amend --require-load --as human:you
334
81
  ```
335
82
 
336
- One edit carries the annotation and the disarming together, so there is no
337
- moment when the message reads "approved" and still offers a tap. Rejections,
338
- revocations, expiries and withdrawals settle the same way, and a tap on a stale
339
- button records nothing.
83
+ `approval policy attest --as human:you` is the bare attestation for a policy you have already reviewed by other means. Loosen some rules, tighten others, amend, keep going. [Policy details](docs/README-extended.md#define-what-needs-approval).
340
84
 
341
- **5. The token stays off the chat.** The grant mints a single-use execution
342
- token. With `defaults.token_delivery: sealed` the requesting process opens it
343
- itself and no human ever sees it, which is how this repository releases. With
344
- the default `manual` delivery it is printed once, in a panel, at the surface
345
- that recorded the decision:
85
+ <a id="the-other-half-of-the-word"></a>
346
86
 
347
- ```
348
- granted task-demo:chaser at seq 4 by human:alice
349
- ─────────────────────────────────────────────────────────────
350
- execution token task-demo:chaser
351
- 516670320878e97dede99cf84bc48025fc80b7cf14bd9e9782bb1cfd0d92a787
352
- single-use · stored nowhere · copy it now
353
- ─────────────────────────────────────────────────────────────
354
- ```
87
+ ### Add your voice
355
88
 
356
- For a tap on your phone that panel appears on the terminal running the
357
- runtime, and its last line reads `not sent to Telegram`: a chat transcript
358
- lives on servers you do not control, so a credential does not go there. The
359
- local **web** channel shows the token once in the response page for the grant
360
- that minted it, served over loopback, gone on reload, because there the browser
361
- is already the surface you are looking at. In every case the log holds only the
362
- token's SHA-256. Lose it, revoke the grant, and request again.
89
+ The file can also carry an optional `yaml approval-values` block: what you `love`, `like`, `dislike`, and how you prefer to communicate. `approval values` and `approval feedback` make that guidance available to agents; `approval journal write` gives them a channel back.
363
90
 
364
- **6. Spend it.** `approval run <action> --token "$TOKEN" -- <command>` appends
365
- `execution.started` before spawning the child and `execution.completed` after,
366
- and exits with the child's own exit code, so it composes with `make`, CI and
367
- `&&`. Run it before the approval and it refuses `token-required` at exit 5.
368
- Run it twice and it refuses:
91
+ Values and reactions inform the work. They do not change permissions. [Values and feedback](docs/README-extended.md#values-and-feedback).
369
92
 
370
- ```
371
- ✗ token-consumed action task-demo:chaser already executed: execution.started at seq 5 spent this token. A token is single-use and the log is the proof.
372
- ```
373
-
374
- A request is not owed an answer forever. `approval withdraw` lets the party
375
- that opened one take it back while it is pending, and `approval wait
376
- --withdraw-on-timeout` does it when your own wait elapses.
93
+ ## Gate your coding agent
377
94
 
378
- **7. Read the whole story.** Two actors, one clean chain:
95
+ Use the integration for the harness you actually run. A hook controls the tool calls it is wired to receive, not every possible action on the machine.
379
96
 
380
- ```
381
- 1 2026-08-19T19:03:58.381Z policy.updated human:alice -
382
- 2 2026-08-19T19:03:58.585Z task.registered agent:drafter task-demo
383
- 3 2026-08-19T19:03:58.767Z approval.requested agent:drafter task-demo
384
- 4 2026-08-19T19:04:31.192Z approval.granted human:alice task-demo
385
- 5 2026-08-19T19:04:41.371Z execution.started agent:drafter task-demo
386
- 6 2026-08-19T19:04:41.499Z execution.completed agent:drafter task-demo
387
- ```
97
+ | Integration | Route and important distinction |
98
+ | --- | --- |
99
+ | [Claude Code](docs/claude-code-hook.md) | `approval hook claude-code`; wire pre-execution and outcome hooks. |
100
+ | [Cursor](docs/cursor-hook.md) | `approval hook cursor`; the hook entry requires `failClosed: true`. |
101
+ | [Claude Agent SDK](docs/agent-sdk-hook.md) | Python `HookMatcher` shim calling the same Claude Code hook. |
102
+ | [Codex](docs/README-extended.md#codex-is-several-integration-paths) | MCP, an app-server bridge, and constrained-workspace tooling; native hook enforcement remains experimental. |
103
+ | [Grok Build](docs/grok-hook.md) / [Muse Code](docs/muse-hook.md) | Dedicated hooks; both have documented harness-level fail-open limitations. |
104
+ | [Hermes Agent](docs/hermes-hook.md) | New source-only hook; live verification is still pending. |
105
+ | [Any MCP client](examples/mcp-demo.md) | `approval mcp serve`; exposes gate tools, but does not intercept the client's native tools. |
388
106
 
389
- That is `approval log tail`, tab-separated for `cut` when piped, aligned and
390
- coloured on a terminal. `approval log verify` answers for the chain: `clean: 6
391
- record(s), head seq 6 843705c6bbea…`.
392
-
393
- Downstream services can follow the same channel-independent record with
394
- `approval log follow --from <seq> --cursor-hash <hash> --json`. The sequence is
395
- exclusive and the hash binds the resume point to the prefix already consumed.
396
- Each JSON line is emitted only after a complete chain verification. Delivery
397
- across reconnects is at least once: apply an idempotent effect, then persist the
398
- event's `seq` and `hash`. See [the CLI reference](docs/cli-reference.md#log-follow)
399
- for failure behavior, resource costs, and the weaker sequence-only bootstrap.
400
-
401
- **8. Review what ran without you.** Supervised actions the sampler picks arrive
402
- on the same chat as review cards, after the fact: what ran, when, and that the
403
- runtime allowed it unasked. ✅ records that you looked, 🛑 twice records a
404
- denial and opens a reconciliation obligation, and 👎 😐 👍 ❤️ leave a graded
405
- reaction. `approval audit list` and `approval audit review` are the same
406
- backlog at the terminal.
407
-
408
- ## The other half of the word
409
-
410
- Everything above is control. The file carries your voice too. Below the policy
411
- block, `APPROVAL.md` may hold one optional `yaml approval-values` block: four
412
- keys under `version: "0.2"`, which are what you `love`, `like` and `dislike` in
413
- the work (what you ask of an agent as behaviour goes in `like` beside what you
414
- prefer) and `communication`, one sentence on how you read and answer.
107
+ Inspect a shell command's classification without running it:
415
108
 
416
109
  ```sh
417
- approval values # the operator's block, or "the operator has declared no values here."
418
- approval feedback # the reactions and notes humans left on this log's actions
110
+ approval hook classify -- git push origin main
419
111
  ```
420
112
 
421
- A retrospective review or a grant can carry a graded reaction (`disliked`,
422
- `indifferent`, `liked`, `loved`; the two extremes need a note), and `approval
423
- feedback` reads them back to the agent whose work they were about. Both verbs
424
- print human-authored guidance behind a banner that says so, and neither reaches
425
- enforcement: no verdict, sample, budget or token moves because of them (SPEC.md
426
- section 11.1, invariant 10). They mirror `approval journal write`, the agent's
427
- outlet the gate does not stand in front of. `approval import agents-md` drafts
428
- the block from a "What I value" heading in an AGENTS.md.
429
-
430
- ## Define what needs approval
431
-
432
- A policy is a fenced `yaml approval-policy` block inside a markdown file named
433
- `APPROVAL.md`. The prose around the block is for you; the runtime parses the
434
- block and ignores the rest. The thing you sign for is text you read.
435
-
436
- **1. Name the classes.** A class is a dotted path from the side-effect taxonomy
437
- of SPEC.md section 7 (`communicate.email.external`, `financial.spend`,
438
- `public.post`, `data.delete`, `read.*`). Matching is most-specific-first, `*`
439
- is a single-segment wildcard, a trailing `.*` matches any depth, and at equal
440
- specificity the strictest rule wins.
441
-
442
- **2. Pick an autonomy for each.** Six values, strictest first: `human-only` (a
443
- person performs the action outside agent execution, and every gate verb refuses
444
- an agent with `class-human-only`), `manual` (a human decides before execution),
445
- `supervised-live` (a policy-declared fraction blocks on the gate exactly as
446
- `manual` does, and the rest proceed, so the rule carries a `live_rate`),
447
- `supervised-retro` (executes immediately, a sampled fraction escalated for
448
- retrospective review), `supervised` (the deprecated alias of
449
- `supervised-retro`, still parsed and removed in a future schema version), and
450
- `autonomous` (executes freely). A truthful `reversible: false` declaration
451
- normally engages section 7's manual floor. An operator who deliberately accepts
452
- irreversible execution for one nonmanual class can add
453
- `allow_irreversible: true` to that class rule. Every equally most-specific rule
454
- must opt in, and the edit has no effect until the policy is re-attested.
455
-
456
- **3. Set the budgets.** Class `limits` and the `budgets` scopes are conjunctive,
457
- so an action must pass both, and consumption is computed from the log over
458
- rolling windows rather than from a mutable counter. An action whose class
459
- matches no rule takes `defaults.autonomy`, and a policy that does not parse
460
- resolves every class to `manual`: unattested and unparseable are both strict.
461
-
462
- **4. Widen the protected paths.** `APPROVAL.md`, the agent instruction files,
463
- `.approval/`, the harness settings and the release configuration are protected
464
- by the runtime whatever a policy says. `protected_paths` adds repo-relative
465
- literals (an exact file, `SPEC.md`, or a directory prefix, `design/`), so a
466
- project can put its own governing documents behind the same gate. The key can
467
- only widen, and globs are a schema violation.
468
-
469
- An entry can also be an object, `{path, class}`, routing that path family to a
470
- named `policy.edit` sub-class with its own autonomy and live rate. Four names
471
- are reserved: `policy.edit.spec` (the governing specification),
472
- `policy.edit.harness` (agent instruction files and harness configuration),
473
- `policy.edit.ci` (continuous-integration and release configuration),
474
- `policy.edit.design` (design documents and decision records). Any other
475
- lowercase word may be minted beside them, and nothing outside `policy.edit` may
476
- be named: a route to `policy.core` or `log.mutate` is refused. A route aimed at
477
- a built-in protected path must land at least as strictly as the `policy.edit`
478
- line itself, or the policy is refused at load with `protected-route-floor`.
479
-
480
- **5. Attest it.** `approval policy attest` is what makes a policy operative. An
481
- attestation records that a human saw these exact bytes, as their SHA-256. Edit
482
- `APPROVAL.md` afterwards and every gated operation refuses `hash-mismatch`
483
- until you attest again. Attestation is human-only, and identity in v0.1 is
484
- config-declared, so what one proves is that someone with local control signed
485
- off.
486
-
487
- **6. Amend it with the verb, not by hand.** Changing a policy is two facts that
488
- have to land together, the new bytes and a human's attestation of them, and
489
- `approval policy amend` owns the ceremony (`--dry-run` reports only,
490
- `--require-load` refuses to attest a policy that does not load, `--commit`
491
- lands the two files as one commit and opens the pull request). It prints a
492
- semantic diff (class resolutions, approver changes, defaults, limits) rather
493
- than a text diff, then a load advisory saying whether the edited policy parses.
494
- Attesting one that does not parse is allowed, since attestation records bytes
495
- rather than correctness, and such a policy fails closed to all-manual.
496
-
497
- ### Why this verb exists: seq 2
498
-
499
- Read this repository's own log. At **seq 2** a policy amendment was attested at
500
- 11:56:07. It was **superseded** seven minutes later, at seq 3, because the edit
501
- broke a pinned assertion and nobody found out until the test suite ran against
502
- it. The operator attested bytes whose consequences had never been shown to
503
- them. (This account originally said eleven minutes. The log says seven, and
504
- the log won.)
505
-
506
- That is the failure the load advisory is for. Had `approval policy amend`
507
- existed that morning, the load failure would have been on screen while the
508
- human was deciding, and `--require-load` would have refused to attest at all.
113
+ The [extended guide](docs/README-extended.md#harnesses-and-mcp) covers wiring, read scope, coverage gaps, and what each route has actually demonstrated.
509
114
 
510
- ## Hand a grant to a real credential
511
-
512
- `echo sent` is a demo. The point of the gate is the send that cannot be undone,
513
- so the runtime holds a credential the agent never sees. Four commands carry the
514
- ceremony; the walkthrough against real Telegram and a real mail provider is
515
- [examples/email-demo.md](examples/email-demo.md).
516
-
517
- ```sh
518
- approval setup vault # mint the passphrase, store it, record where
519
- approval setup adapter email # the five SMTP settings, into the vault
520
- eval "$(approval env)" # the variable the policy names, in this shell
521
- approval adapter email task-042:chaser --token "$TOKEN" \
522
- --payload message.json --as agent:claude-admin
523
- ```
524
-
525
- **1. Two stores.** `.approval/env` says where the values that unlock the
526
- machine come from, and `approval setup vault` writes the passphrase line under
527
- whatever name `vault.passphrase_env` declares. The SMTP password is an adapter
528
- credential, so it goes in the vault, where a gated adapter spends it inside a
529
- verified execution window.
530
-
531
- **2. Setup fills the vault and proves it.** `approval setup adapter email` reads
532
- the credential manifest the adapter declares, then probes the server without
533
- sending anything.
534
-
535
- **3. A credential's only journey is into an adapter.** `approval vault set`
536
- stores one credential in `.approval/vault.enc`, encrypted under a passphrase
537
- the policy names and never carries. The value comes from stdin or `--value-env
538
- <VAR>`; there is no `--value` flag, because a secret on a command line is a
539
- secret in the shell history. There is no `approval vault get`; `approval vault
540
- list` shows the names.
541
-
542
- **4. The send happens inside the execution window.** `approval adapter email`
543
- re-hashes `message.json` against the declaration or grant binding, applies the
544
- attested policy, appends `execution.started`, opens the vault, reads the SMTP
545
- settings, sends over STARTTLS, closes the window, and appends
546
- `execution.completed`. Manual and selected-live paths verify and spend the
547
- grant token; an explicitly opted-in supervised or autonomous path has no grant
548
- and mints no token. On that no-token path, the vault passphrase must already be
549
- in the adapter process environment. The `.approval/env` fallback remains
550
- token-only. The credential exists for one send and appears in no event, output
551
- or error message.
552
-
553
- **5. Check two properties in your own mailbox.** The bytes that left are the
554
- bytes you approved, since the hash the token spend verified is the hash of the
555
- payload your phone displayed. And the `Message-ID` is derived from the action
556
- key, the payload hash and the sender, so the header in a mailbox and the
557
- binding in the chain identify each other months later.
558
-
559
- ### The same grant over AgentMail
560
-
561
- `communicate.email.external` has a second adapter. Where the email adapter
562
- opens an SMTP session, `approval adapter agentmail` calls the AgentMail API, and
563
- a mail the agent has already composed as a Draft leaves only when a grant says
564
- so. Walkthrough: [examples/agentmail-demo.md](examples/agentmail-demo.md).
115
+ ## Put approvals on your phone
565
116
 
566
- ```sh
567
- approval setup adapter agentmail # inbox id + sending key, into the vault
568
- approval payload agentmail-draft "$INBOX" "$DRAFT" > payload.json
569
- approval adapter agentmail task-042:chaser --token "$TOKEN" \
570
- --payload payload.json --as agent:claude-admin
571
- ```
117
+ Telegram prompts separate runtime-computed facts from agent claims and show the payload being approved. A tap records the decision; the agent can continue through the appropriate execution path. The terminal and loopback web queue use the same log.
572
118
 
573
- **Two keys, and the split is the enforcement.** AgentMail API keys carry
574
- per-permission booleans, and `draft_create`, `draft_update` and `draft_read` are
575
- separate from `draft_send` and `message_send`. Give the agent a key holding the
576
- first three and none of the last two, and put a key holding the send permissions
577
- in the vault. The agent composes all day and cannot send at all: an ungated
578
- send is refused by AgentMail itself, `agentmail-unauthorized`, before this
579
- runtime is involved. `AGENTMAIL_` is withheld from every child `approval run`
580
- spawns, so a key in the agent's environment cannot ride into a command.
581
-
582
- **A draft is mutable, so the grant binds its bytes.** `approval payload
583
- agentmail-draft` snapshots the draft's recipients, subject and text at request
584
- time, and that snapshot is what the hash binds and what your phone displays.
585
- Before it sends, the adapter re-fetches the draft and compares; a draft edited
586
- after the grant refuses `agentmail-draft-drifted`, sends nothing, and names
587
- which fields differ without quoting text nobody approved. That comparison runs
588
- before the token is spent, so the refusal costs no authority: restore the
589
- approved text and the same token still sends.
590
-
591
- ### First-class zzz.bot messages
592
-
593
- `approval adapter zzz` creates a thread or replies through zzz.bot's versioned
594
- HTTP API. Put the invited write credential in the vault, then approve the
595
- complete tagged payload. The environment, destination, body, metadata, tags and
596
- references all sit inside the payload hash.
597
-
598
- This adapter is available from a source checkout containing APRV-320 until the
599
- next approval.md package release. The published npm `approval-md@0.1.0`
600
- predates it, and this change does not publish a package.
119
+ [Telegram walkthrough](examples/telegram-demo.md) · [Channel setup and identity](docs/README-extended.md#channels-and-identity)
601
120
 
602
- ```sh
603
- approval setup adapter zzz
604
- approval adapter zzz task-320:announce --token "$TOKEN" \
605
- --payload zzz-message.json --as agent:codex
606
- ```
121
+ <a id="first-class-zzzbot-messages"></a>
607
122
 
608
- Thread payload:
123
+ ## Hand a grant to a real credential
609
124
 
610
- ```json
611
- {"environment":"production","operation":"create_thread",
612
- "room_id":"<room-id-from-GET-api-v1-rooms>",
613
- "title":"Release ready","body":"The verified build is ready for review.",
614
- "tags":["release"],"references":[]}
615
- ```
125
+ The runtime includes adapters for [SMTP email](examples/email-demo.md), [AgentMail drafts](examples/agentmail-demo.md), and [zzz.bot threads and replies](docs/README-extended.md#first-class-zzzbot-messages), plus a [public adapter API](docs/adapter-api.md).
616
126
 
617
- A reply uses `"operation":"create_reply"` and `"thread_id"` instead of
618
- `room_id` and `title`. The adapter chooses only fixed production or preview
619
- origins, rejects redirects, and derives zzz.bot's idempotency key from the
620
- approval action key and payload hash.
127
+ Keep the sending credential in the runtime's vault, not in the agent's hands. On paths requiring approval, a single-use grant binds the payload before the adapter executes. Explicitly permitted autonomous or supervised paths do not require a human grant.
621
128
 
622
- Public writes require an invited credential with write scope. Private writes
623
- also require active room membership and accepted, unexpired approval.md workflow
624
- evidence. The setup probe performs one authenticated room-list GET. It proves
625
- that zzz.bot accepts the credential and does not prove those write or private
626
- room prerequisites. A local non-guest MCP server exposes the same adapter verb,
627
- but MCP use is voluntary; custody is enforced only when the write credential is
628
- kept solely in the approval.md vault.
129
+ <a id="cant-the-agent-just-go-around-it"></a>
629
130
 
630
- ### Build a third-party adapter
131
+ ## Know the boundary
631
132
 
632
- Adapter authors can import the supported ESM API from `approval-md/adapters`.
633
- It exposes the shared execution contract, conformance runner, vault credential
634
- provider, refusal unions, and TypeScript types without making internal package
635
- paths public. See the [adapter API guide](docs/adapter-api.md).
133
+ approval.md is an oversight layer for broadly cooperative agents, not blanket containment for a hostile process on a machine it controls. Credential custody, hook wiring, and the harness's failure behavior determine what is enforced. Local human identity is config-declared; a hash-chained log is tamper-evident, not proof of personhood or an immutable history by itself.
636
134
 
637
- ## The APPROVAL.md dictionary
135
+ **Before committing real data:** the scaffold does not ignore the event log or stored approval payloads. Decide what should remain private before putting messages or other sensitive material in a public repository.
638
136
 
639
- Every key that can appear in the policy block, and after it the four of the
640
- optional values block. The schema is closed at every level: an unrecognised key
641
- fails validation, which fails the policy closed to all-manual, because a key the
642
- runtime did not understand is a rule its author believed was in force. A values
643
- key the schema refuses fails the values reader alone and never the policy. Full
644
- semantics: SPEC.md section 5.
137
+ [Security and evidence limits](docs/README-extended.md#security-and-evidence-limits)
645
138
 
646
- | key | what it says |
647
- | --- | --- |
648
- | `version` | Policy format version, quoted (`"0.1"`). The only required key (§5.1). |
649
- | `defaults.autonomy` | Autonomy for an action matching no class rule. Five of the six levels are admitted: `supervised-live` is not, since it needs a `live_rate` that `defaults` has nowhere to hold. `human-only` is, and reserves every unnamed class to human hands. No default of its own, and `manual` is the fail-closed choice (§5.2, APRV-185). |
650
- | `defaults.channel` | Channel name requests surface on by default; expected to name a key of `channels`, which is a runtime cross-check rather than a schema one. No default (§5.1, §10.3). |
651
- | `defaults.approval_ttl` | How long a pending request stays actionable. Duration string, `24h`. No default; the scaffolded policy writes one (§5.1). |
652
- | `defaults.token_delivery` | How a minted token reaches the process that will spend it. `manual` (the default, and what an absent key means): printed once on the granting surface and carried by a human. `sealed`: sealed to a per-request X25519 key so `approval wait` can hand it back, which addresses the token and never authorizes it (§10.4, APRV-105). |
653
- | `defaults.on_expiry` | What happens when the TTL lapses. `reject` is the only value, and absent means `reject` (§5.1). |
654
- | `payload_retention` | How long payload bytes are kept after their action is terminal. Absent means nothing is ever pruned (§5.2). |
655
- | `protected_paths` | Repo-relative files and directory prefixes whose edit is classified `policy.edit`. A bare string is the whole entry. Additive only, no globs, and absent means the built-in protected set alone (§5.2, APRV-107). |
656
- | `protected_paths[].path` | The path half of the object form: the same grammar as the bare string, an exact file (`SPEC.md`) or a directory prefix (`design/`) (§5.2, APRV-266). |
657
- | `protected_paths[].class` | The class half: one lowercase segment under `policy.edit`. Four reserved names, `policy.edit.spec`, `policy.edit.harness`, `policy.edit.ci` and `policy.edit.design`, plus any word an author mints beside them. Nothing outside `policy.edit` may be named, and a route below the `policy.edit` line is refused `protected-route-floor`. No default: an entry that wants a sub-class states it (§5.2, APRV-266). |
658
- | `read_scope` | Directories an agent's reads may stay inside. A read resolving outside every root is `read.file.out_of_scope`. Additive only: the gate root (this policy's own directory), the session scratchpad and the system temp root are in scope whatever this says, and absent means those alone (§5.2, APRV-347). |
659
- | `read_scope.roots` | The extra directories. Absolute, or relative to the gate root. No globs and no negation; each is resolved on disk before it is compared, so a symlink cannot smuggle a read out of one. Absent means no widening (§5.2, APRV-347). |
660
- | `approvers.<name>.channels` | The channels one approver can decide on. At least one: an approver reachable nowhere can never grant. No default (§5.1). |
661
- | `approvers.<name>.senders` | The transport account ids this person decides from, per channel: `senders.telegram: "12345678"`, the numeric `callback_query.from.id` and never a `@handle`, which is mutable and would transfer an identity. Optional and additive; absent everywhere means every decision is recorded against the identity the deciding process was launched with, exactly as before the key existed. Declaring the first entry for a channel turns enforcement on for that channel: a sender it authenticates and this block does not name is refused `sender-unmapped` and nothing is recorded. Two approvers claiming one id refuses the whole policy (`sender-ambiguous`), so every class resolves `manual`. Only channels whose transport authenticates a sender may appear, which today is `telegram` alone (§5.2, §10.3, APRV-324). |
662
- | `classes.<pattern>.autonomy` | Required on every class rule, so it has no default. Six levels, strictest first: `human-only`, `manual`, `supervised-live`, `supervised-retro`, `autonomous`, and `supervised`, which is the pre-split spelling and the DEPRECATED alias of `supervised-retro`: it still parses, `approval doctor`'s `autonomy-alias` row names every rule that writes it, and a future schema version removes it (§5.2, APRV-127, APRV-185, APRV-335). |
663
- | `classes.<pattern>.live_rate` | The fraction of a `supervised-live` class that blocks on the gate, in (0, 1]. Required there and refused everywhere else, so it has no default: a live mode with no fraction declares a control without saying how much of it runs. Selection is HMAC-SHA-256 over the payload hash under the operator's secret (§5.2, APRV-127). |
664
- | `classes.<pattern>.retro_rate` | This class's retrospective sampling rate, in (0, 1], overriding `audit.supervised_sample_rate` for it alone. Optional on `supervised`, `supervised-retro` and `supervised-live`, refused on the rest. Absent means the global rate (§5.2, APRV-183). |
665
- | `classes.<pattern>.allow_irreversible` | Explicit operator permission for a truthful `reversible: false` action to retain this rule's `autonomous` or supervised behavior. Optional boolean; absent or `false` preserves the manual floor. `true` is refused on `manual` and `human-only`, cannot appear in `defaults`, and takes effect only when every equally most-specific matching rule says `true` (§5.2, §7, APRV-317). |
666
- | `classes.<pattern>.approvers` | Approver ids permitted to decide this class. Absent restricts nobody, since the list is a narrowing and a narrowing nobody wrote narrows nothing; a named list refuses everyone else with `actor-not-approver` (§5.1). |
667
- | `classes.<pattern>.limits` | Per-class ceilings, every value a positive number: `per_action_usd`, `daily_usd`, and the request-volume counts `max_pending` and `requests_per_hour`. Absent means this class carries no ceiling of its own (§5.1, §5.2). |
668
- | `budgets.global.daily_usd` | Repo-wide spend ceiling per rolling day, computed from the log. Absent means no spend ceiling (§5.1). |
669
- | `budgets.global.daily_actions` | Repo-wide count of side-effecting actions per rolling day. Absent means no count ceiling (§5.1). |
670
- | `budgets.global.max_pending` | Simultaneously pending requests across the scope; excess is refused `queue-full`. Absent means no ceiling (§5.2). |
671
- | `budgets.<scope>` | Any other named scope, same three keys. Budgets are conjunctive with class limits (§5.2). |
672
- | `audit.supervised_sample_rate` | The FALLBACK fraction of supervised actions escalated for retrospective review, in [0, 1], for classes declaring no `retro_rate`. Absent means no fallback rate is configured (§5.2, APRV-183). |
673
- | `audit.sampling_secret_env` | Name of the variable holding the operator's HMAC sampling secret. Unnamed means sampling is off and says so (§5.2, §11). |
674
- | `audit.skew_tolerance` | How far a gate-typed event's timestamp may step back before verification reports an anomaly. Report-only; default 2 seconds (§8). |
675
- | `audit.checkpoint_keys` | Public halves of the Ed25519 keys permitted to sign a `log.checkpoint`, base64 DER SPKI. The private halves live in the vault and never in this file. A list, so a retired key stays listed: a checkpoint signed by a key the list does not carry is refused. Absent, empty or unreadable means verification skips the checkpoint check with a reason and never reports it as a pass (§9, APRV-220). |
676
- | `audit.checkpoint_every` | How long the log may go without a human-signed checkpoint before verification says one is due, and before the listener puts one `CHECKPOINT DUE` prompt on the approver's channel (`approval setup checkpoint` mints the key). Report-only at every layer: a due checkpoint is a warning and never a refusal. Absent means the cadence is off and nothing is ever reported as due (§9, APRV-220, APRV-257). |
677
- | `daemon.read_proof` | Which prefix proof a long-lived reader runs before reusing a cached prefix: `full` (the default, re-hash the whole prefix on every read) or `incremental` (hash only the appended bytes, re-proving in full on a cadence). One-shot processes, the Claude Code hook and `approval log verify` prove in full regardless (§5.2, APRV-217). |
678
- | `daemon.full_reproof_every` | Reads one full re-proof may cover under `incremental`, the anchoring read included. Default 50 (§5.2). |
679
- | `daemon.full_reproof_after` | Wall clock one full re-proof may cover under `incremental`. Duration string, default `60s` (§5.2). |
680
- | `vault.passphrase_env` | Name of the variable holding the vault passphrase. Absent means `APPROVAL_VAULT_PASSPHRASE` (§5.2, §10.4). |
681
- | `channels.telegram.token_env` | Name of the variable holding the bot token. Default `APPROVAL_TG_TOKEN` (§5.1). |
682
- | `channels.telegram.chat_id_env` | Name of the variable holding the approver chat id. Default `APPROVAL_TG_CHAT` (§5.1). |
683
- | `channels.telegram.delivery` | `paced` (the default) shows one summary line and the oldest pending request, then the next one after a decision, `/skip` or `/next`; `burst` sends every pending request the listener has not sent yet. Neither mode changes what is pending: that is re-derived from the verified log on every cycle (§10.3, APRV-216). |
684
- | `channels.web.port` | TCP port for the local approval UI, bound on loopback only. No default in the schema; the scaffolded policy names `4680`, and 0 is excluded because the policy must name a port a human can navigate to (§5.1). |
685
- | `channels.<name>.prompt.rows` | Order only, for `telegram`, `web` and `cli`: the rows named here render in this order ahead of the rest, which keep their default relative order behind them. Never a whitelist, so a field added later cannot be lost to a list written before it existed. Absent means the layout the channel ships (§5.2, §10.3, APRV-218). |
686
- | `channels.<name>.prompt.always` | Rows this channel renders only when abnormal, or not at all, render on every prompt instead. The anomaly mark stays a statement about the value, so a forced-on row shouts only when the value is in fact the reason to look. Absent means the channel's own visibility rules (§5.2, §10.3, APRV-218). |
687
- | `channels.<name>.prompt.hide` | Rows this channel never renders. Refused for the rows required for a decision (`action_key`, `class`, `command_breakdown`, `protected_path`, `policy_diff`, `policy_load`) with `prompt-row-required`, and refused for a row `always` also names. Absent means nothing is hidden, and the canonical payload block is out of reach either way (§5.2, §10.3, APRV-218). |
688
- | `channels.<other>` | An unknown channel name is accepted as an object, so a third-party transport does not fail the whole policy closed (§10.3). A `prompt` block written under such a name is still validated: a layout is checked wherever it appears. |
689
-
690
- And the values block (SPEC.md §5.3), which is guidance and reaches no
691
- enforcement path:
692
-
693
- | key | what it says |
694
- | --- | --- |
695
- | `version` | Values format version, quoted (`"0.2"`), spelled as the policy block's `"0.1"` is. The only required key here too. The quotes are load-bearing: a bare `0.2` is a float to YAML, and the reader refuses it by name (§5.3, APRV-336). |
696
- | `love` | What you love in the work. The strongest of the three standing grades. Absent means you named none (§5.3). |
697
- | `like` | What you like, which since APRV-336 is also where what you ask of an agent as behaviour lives: the former `wants` list folded in here (§5.3). |
698
- | `dislike` | What you dislike. NOT a prohibition, which belongs in the policy block where it is enforced (§5.3). |
699
- | `communication` | One string, at most 500 characters, on how you read and answer, so an agent can read silence or terseness correctly. Called `responds` before APRV-336 (§5.3). |
700
-
701
- Every key ending in `_env` carries a variable's *name* and never its value:
702
- agents may read `APPROVAL.md`, so a secret it carried would be a secret they
703
- hold. Where those values live is recorded in `.approval/env`, which a single
704
- verb reads, `approval env`, whose output is an export block a human evaluates.
705
-
706
- ## How this compares
707
-
708
- Three kinds of thing already exist in this space, and each solves a different
709
- part of the problem. A hosted daemon and reviewer layer is operated by
710
- Bountify.ai; it is optional, and nothing in the format depends on it
711
- ([GOVERNANCE.md](GOVERNANCE.md)).
712
-
713
- **Harness-native permission prompts** (Claude Code permission rules and hooks,
714
- Cursor auto-run, Codex CLI approval modes) enforce inside the one harness they
715
- ship with. That enforcement is real: a Claude Code PreToolUse deny holds even
716
- under its bypass mode, and Codex backs its gate with an OS-level sandbox, which
717
- this project does not attempt. What they lack is a durable record and
718
- portability. None writes an append-only log of what was asked, who decided and
719
- what ran; the decision reaches a human only as a terminal prompt; and the
720
- mechanism does not travel to another harness. approval.md's Claude Code hook is
721
- built on that PreToolUse mechanism and adds the two missing pieces: the
722
- decision comes from an attested policy file, and it lands in a verifiable log.
723
-
724
- **AGENTS.md permissions prose** states the policy in English and trusts the
725
- agent to obey. Nothing parses it, nothing blocks a call against it, and no
726
- record exists when it is violated. approval.md is the enforcement layer that
727
- convention is missing, and treats it as an input: the permissions section of
728
- this repository's own CLAUDE.md is the first import fixture.
729
-
730
- **Framework interrupts** (LangGraph `interrupt()`, CrewAI human input, AutoGen
731
- `UserProxyAgent`, the OpenAI Agents SDK's `needsApproval`, Temporal signal
732
- approvals) give a developer a pause-and-resume primitive and leave policy,
733
- audit format, the human channel and the credential boundary to them. They also
734
- require adopting the framework. Temporal's event history is a real append-only
735
- execution record with crash recovery this project does not claim, though it
736
- lives in Temporal's storage rather than as policy-attested files in your repo.
737
-
738
- **Hosted approval platforms** (HumanLayer, gotoHuman, Permit.io's access
739
- requests) are the closest relatives: multi-channel human routing, review UIs,
740
- and in Permit.io's case a real authorization engine richer than autonomy
741
- classes. Their model is a third-party service in the decision path, with the
742
- audit trail in the platform's backend, and the agent's own process still
743
- choosing to honor the returned verdict. They bring hosted infrastructure,
744
- escalation and team routing, and compliance certifications.
745
-
746
- The difference is the combination: policy as a hash-attested markdown file in
747
- your repo; an append-only, hash-chained log you verify locally with one
748
- command; and an execution boundary where the credential is inert until a
749
- single-use token is minted at the moment a human decides. Every framework
750
- primitive and hosted API above relies on the agent's process honoring a
751
- returned decision. Here the thing the agent needs, the credential, answers only
752
- to the thing it cannot make, the token. The tradeoffs: you run the daemon and
753
- listener yourself, there is no OS-level sandbox, no compliance certification,
754
- and the reference phone channel is one app, Telegram.
755
-
756
- ## Can't the agent just go around it?
757
-
758
- **Edit the policy?** An attestation records the SHA-256 of the policy's bytes,
759
- and every gated operation refuses `hash-mismatch` when the live file disagrees
760
- with it. An unattested policy refuses too, and attesting is human-only. Under
761
- the harness hook the edit itself is classified `policy.edit` before it happens,
762
- because `APPROVAL.md` is in the built-in protected set no policy can narrow.
763
-
764
- **Fabricate or rewrite the log?** Each record chains to the previous one's
765
- hash, so an edited or reordered record breaks the chain and `approval log
766
- verify` says so. Appends go through compare-and-append against the head, and
767
- projections (`QUEUE.md`, the SQLite index) rebuild from the log and never write
768
- back to it.
769
-
770
- **Mint its own token, or reuse one?** Tokens are minted at one site, inside the
771
- path that records a human decision, and the log stores only the hash. No verb
772
- and no tool returns a token for a grant it did not just record, and a hook
773
- grant mints none at all. The second spend is refused `token-consumed`, naming
774
- the seq of the `execution.started` that spent it.
775
-
776
- **Call the adapter or the credential directly?** Credentials live in
777
- `.approval/vault.enc` under a passphrase the policy names and never carries,
778
- and an adapter opens the vault only inside an execution window admitted by the
779
- attested policy. There is no `approval vault get`. Manual and selected-live
780
- paths need a grant token. An explicitly opted-in supervised or autonomous path
781
- needs the passphrase already present in the adapter process environment; it
782
- cannot use the token-scoped `.approval/env` fallback. This is where the hard
783
- enforcement lives.
784
-
785
- **Run the side effect from its own shell?** That is what the PreToolUse hook is
786
- for: it classifies the command text, resolves the class, and answers allow or
787
- deny before the harness runs anything, fail-closed and with no "ask". The
788
- classifier reads shell text without being a shell, so parameter expansion,
789
- aliases and wrapper binaries are gaps, and each resolves toward denial or the
790
- stricter class. `bash -c`, `eval`, `sudo`, `xargs` and `node -e` deny as
791
- `hook-opaque`.
792
-
793
- **POST straight at the web queue?** It can. `approval channel web` binds
794
- `127.0.0.1` with no `--host` flag, because with no authentication the loopback
795
- interface is the entire access control, and every decision the page collects is
796
- recorded against the human the runtime was started with: it proves "someone
797
- with access to this machine approved". There is no CSRF token in v0.1,
798
- deliberately: a CSRF token defends a session, and with no session anything that
799
- can open a socket to `127.0.0.1:4680` can POST with or without one. The
800
- same-origin check that rejects a POST naming a non-loopback `Origin` allows one
801
- carrying neither header, since `curl` sends neither: treat it as a speed bump
802
- rather than a control. A session, or a wider bind address, would need a real
803
- anti-CSRF token.
804
-
805
- **Lie in its self-report?** Self-reported fields never reduce scrutiny (SPEC.md
806
- section 11.1, invariant 4). They may raise it, inform display, or feed
807
- retrospective analysis, and they can never downgrade a resolved autonomy level
808
- or supply `allow_irreversible`. Only an explicit class rule in the attested
809
- operator policy can retain nonmanual autonomy for a truthful `reversible:
810
- false` declaration. The prompt keeps computed facts apart from claimed fields.
811
-
812
- **So what is left?** A fully adversarial agent on a machine it controls.
813
- Identity in v0.1 is config-declared, so anyone who can set that variable and
814
- write to the log is inside the trust boundary; cryptographic identity is future
815
- work ([docs/proposals/hardened-authorization.md](docs/proposals/hardened-authorization.md)).
816
- What holds regardless of what the harness believes it is running: the vault,
817
- the adapter boundary, and the single-use token. Section 7 keeps irreversible
818
- classes at `manual` unless the attested policy explicitly opts a class into the
819
- exception.
820
-
821
- ## Running the checks
139
+ <a id="the-approvalmd-dictionary"></a>
140
+ <a id="running-the-checks"></a>
141
+ <a id="exit-codes"></a>
142
+ <a id="how-this-compares"></a>
822
143
 
823
- ```
824
- npm run ci:local # run the CI tier this diff would get, before pushing
825
- npm run check:changed # classify the working tree, then run that tier
826
- npm run check:tier -- <path> # classify the given paths and print the tier
827
- approval doctor # the other check: this machine, not the code
828
- ```
144
+ ## Read on
829
145
 
830
- `approval doctor` prints **33 rows** and a tally, in the order their failures
831
- cascade: build freshness, identity, attestation, the log chain, the channels
832
- (`telegram`, `web-port`), the payload store, audit sampling, envelope
833
- integrity, the vault, the environment source map, then the rows that ask git
834
- and the harness what happened (`log-drift`, `reconciliation`,
835
- `harness-hook-outcomes`, `harness-hook-wiring`, `keychain-scope`,
836
- `log-advance-cadence`, `dark-sessions`, `verified-snapshot`, `read-proof`,
837
- `main-behind-origin`, `attested-policy-on-main`,
838
- `harness-version-unverified`, `live-draw`,
839
- `values-block`, `checkpoint`, `gate-organs`, `sealed-keys`,
840
- `codex-hook-wiring`, `autonomy-alias`, `pending-sign-off`,
841
- `codex-auto-reviewer`). Each failure
842
- carries a `fix:` line you run yourself. Doctor appends nothing, sends nothing
843
- and repairs nothing, and no credential value appears in its output. Three
844
- of the 33 lines from a fresh directory, plus the tally:
146
+ The [extended guide](docs/README-extended.md) covers policy controls, channels, credentials, the event log, troubleshooting, and development. The [specification](SPEC.md), [schemas](schema/), and [CLI reference](docs/cli-reference.md) carry the detailed contracts.
845
147
 
846
- ```
847
- ✓ identity APPROVAL_HUMAN=human:alice (config-declared: the trust boundary is this machine, not cryptography)
848
- ✓ log /your/project/.approval/log/events.jsonl verifies: 1 record(s), head seq 1 0f3c4a19187a…
849
- ✗ audit-sampling disabled (secret-env-unnamed): APPROVAL.md sets audit.supervised_sample_rate to 0.1 but names no audit.sampling_secret_env. …
850
- fix: approval policy attest --as human:<id> — after setting audit.supervised_sample_rate and audit.sampling_secret_env in the policy; then export the named variable where the daemon runs
851
- 12 ok · 20 not applicable · 1 failed
852
- ```
148
+ [Contributing](CONTRIBUTING.md) · [Conformance](conformance/README.md) · [Changelog](CHANGELOG.md) · [Governance](GOVERNANCE.md)
853
149
 
854
- That one failure is expected on the scaffolded policy: it samples supervised
855
- actions for audit, sampling needs an operator-held secret the policy only
856
- names, and a control that looks on while the party under oversight could steer
857
- it is worse than one that is visibly off. Name the secret when you want
858
- sampling, or delete the `audit` block if one person's gate has no use for it.
859
-
860
- **20 of the 33 report `not applicable` in a fresh directory**, and each names
861
- the absence it skipped on: `telegram` (no bot variables), `envelope-integrity`
862
- (no task folder), `vault` (no vault file), `environment` (no `.approval/env`),
863
- `read-proof` (no `daemon` block), `live-draw` (no `supervised-live` class),
864
- `checkpoint` (no `audit.checkpoint_keys`), `sender-mapping` (no approver
865
- declares a `senders` block, so decisions carry the identity the deciding
866
- process was launched with), `harness-hook-outcomes`,
867
- `harness-hook-wiring`, `codex-hook-wiring`, `harness-version-unverified` and
868
- `gate-organs` (no harness settings file), `verified-snapshot` (no daemon has
869
- run), and
870
- `log-drift`, `log-advance-cadence`, `dark-sessions`, `main-behind-origin`,
871
- `attested-policy-on-main` and
872
- `sealed-keys` (not a git checkout). `sealed-keys` asks git what it tracks:
873
- `.approval/payloads/` is tracked on purpose, and a sealed-delivery private key
874
- swept in by a `git add` of that directory would open that action's token for
875
- everyone holding the log. `gate-organs` is informational wherever it lands: it
876
- lists the harness files whose current bytes carry no `approval policy attest
877
- --organ` record, and never moves the exit code.
878
-
879
- Checks come in three tiers.
880
-
881
- | Tier | Chosen when every changed path is | What runs |
882
- | --- | --- | --- |
883
- | light | `README.md`, `docs/**/*.md`, `examples/**/*.md` | the documentation guard (`tests/docs-guard.test.ts`) |
884
- | records | `backlog/**`, `MILESTONES.md` | the tests that read records (`milestones-guard`, `backlog-fixtures`, `docs-guard`), on Node 20 |
885
- | full | anything else, or a mix of the above | the whole suite in three shards plus `npm run lint`, on Node 22; the Node 20 floor runs the same three shards on the merge queue and on pushes to `main` |
886
-
887
- A denylist forces the full tier regardless of file extension: `APPROVAL.md`,
888
- `CLAUDE.md`, `.claude/**`, `SPEC.md`, `schema/**`, `**/fixtures/**`,
889
- `backlog/**`, `scripts/**`, `.github/**`, the packaging files, and `cli.js`.
890
- `backlog/**` sits on both that denylist and the records list, so a task file
891
- mixed with any other path takes the full tier. Classification is computed from
892
- the changed paths by `scripts/classify-tier.mjs`, never asserted by the author
893
- of the change, and every merge to `main` runs the full suite.
894
-
895
- ### Before the push: `npm run ci:local`
896
-
897
- The merge queue is serial, so every red run there costs a slot and another
898
- wait. `npm run ci:local` asks the same classifier the workflow asks and runs
899
- the jobs `.github/workflows/ci.yml` declares for that tier: the docs guard for
900
- light, the record-reading tests for records, the three shards plus lint for
901
- full, and the protected-path grant cross-check on every tier when a merge base
902
- is computable. `--base <ref>` picks the base, `--working-tree` and explicit
903
- paths are the other path sources, `--dry-run` prints the plan, `--json` prints
904
- it as data, and `--parallel` runs the tier's jobs concurrently. What it cannot
905
- reproduce it says: the Node 20 legs need Node 20, and CI's runner is
906
- `ubuntu-latest`. A green run locally is a prediction; the workflow is the
907
- verdict.
908
-
909
- `npm run check:changed` answers a different question: it classifies the
910
- working tree and runs the tier in its own shape, which for full is `npm test`,
911
- `npm run lint` and `npm run typecheck`. Use it while working, and `ci:local`
912
- before pushing. `scripts/run-tests.mjs --shard <k>/<n>` takes shard `k` of the
913
- sorted file list, so the shards of a matrix partition the suite.
914
-
915
- ## Exit codes
916
-
917
- An agent branches on the exit code before it reads stdout, so these numbers
918
- are frozen. Adding one is a spec change; changing a meaning is breaking.
919
-
920
- | Code | Meaning |
921
- | --- | --- |
922
- | 0 | success |
923
- | 1 | integrity failure (corrupt log) |
924
- | 2 | usage error |
925
- | 3 | torn tail |
926
- | 4 | I/O error |
927
- | 5 | no valid execution token (approval run only) |
928
- | 6 | timeout (approval wait only) |
929
-
930
- Code 1 and code 4 are kept apart deliberately: "I could not read the file" and
931
- "the file has been tampered with" are different facts, and conflating them
932
- either cries wolf over a permission bit or lets tampering read as a filesystem
933
- hiccup. Code 3, a torn tail, is the signature of a crashed write, and nothing
934
- is repaired automatically: truncating a torn line is a human decision. A gate
935
- refusal is exit 1 and never 2, since the command was well-formed and the answer
936
- is no; branch on `error.code` under `--json`.
937
-
938
- ## Where to look next
939
-
940
- [SPEC.md](SPEC.md) is the source of truth for every design decision, and this
941
- README defers to it wherever the two could be read differently.
942
- [CLAUDE.md](CLAUDE.md) describes how this repository builds itself behind its
943
- own gate; the 0.1.0 release was published, tagged and pushed through three
944
- grants from a phone.
945
-
946
- Every command carries its own instructions. `approval --help` lists them
947
- grouped by purpose, `approval <command> --help` gives one command's flags,
948
- refusal codes and JSON shape, and `--help --long` appends that verb's
949
- reasoning from [docs/cli-reference.md](docs/cli-reference.md). `approval
950
- instructions` is the agent-facing guide, and `--schemas` prints the verb
951
- registry as JSON.
952
-
953
- Every external adapter, harness, updater or gateway this project has weighed
954
- has an entry in
955
- [docs/integrations-considered.md](docs/integrations-considered.md).
956
- [examples/grok-bot-connector/runbook.md](examples/grok-bot-connector/runbook.md)
957
- puts a Grok Bot agent on the far end of `approval mcp serve --http --guest`
958
- and rehearses both halves of the story: the agent asking for a branch push and
959
- an email and a human deciding on a phone, then the agent skipping the gate and
960
- finding the credential inert.
961
-
962
- Designs proposed and not yet built live under `docs/proposals/`.
963
- [docs/proposals/solo-dev-quickstart.md](docs/proposals/solo-dev-quickstart.md)
964
- and [docs/proposals/no-daemon-mode.md](docs/proposals/no-daemon-mode.md) are
965
- the next step for the path at the top of this page: a three-question
966
- `approval quickstart`, one `approval guard -- <command>` verb that replaces
967
- the register, request, wait, run quartet, and a runtime that lives inside the
968
- waiting command instead of a daemon.
969
- [docs/proposals/hardened-authorization.md](docs/proposals/hardened-authorization.md)
970
- works through what a grant in this log can and cannot prove to a service that
971
- does not trust the operator, and what a stronger identity tier would have to
972
- be.
973
-
974
- ## License and governance
975
-
976
- Code: Apache 2.0, see [LICENSE](LICENSE) and [NOTICE](NOTICE). Specification
977
- and schemas: CC0 1.0, so any language can implement the format without asking.
978
- Who holds the specification and the name, the relationship to Bountify.ai's
979
- hosted offering, and the plan for neutral governance:
980
- [GOVERNANCE.md](GOVERNANCE.md). How to contribute, including the DCO sign-off:
981
- [CONTRIBUTING.md](CONTRIBUTING.md).
150
+ Code: [Apache 2.0](LICENSE). Specification and schemas: [CC0 1.0](schema/LICENSE). Releases are approved through approval.md.