@useanvil/claude-code 0.0.0-stage → 0.8.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,1992 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@useanvil/sdk` are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/), and this project adheres to
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Anvil for Claude Code on Windows: built, in testing (2026-11-19)
10
+
11
+ - **Windows is built end to end, and stays behind a name until it has run on Windows.** `anvil-claude on` turns it on
12
+ there with `ANVIL_WINDOWS_PREVIEW=1`; without it, it says Windows is in testing and changes nothing. The acceptance
13
+ run, and the three lines that turn it on for everyone, are in `docs/coding-agents/WINDOWS.md`.
14
+ - **Claude Code's PowerShell tool is checked.** A PowerShell command is read as the shell line that does the same
15
+ things, so every rule, block and condition judges it as it judges Bash; one Anvil can't read is held. So is a line
16
+ handed to Windows' shells and starters any way (`-EncodedCommand`, `/c`, a script file, stdin, `Start-Process`,
17
+ `wmic process call create`, a scheduled task's `/tr`, `forfiles /c`), and a `.ps1` or `.bat` the session wrote.
18
+ - **Windows' places are the floor's, by any spelling:** drive roots, `C:\Windows`, `C:\Program Files`, `C:\Users`,
19
+ the home folder and its own folders, raw disks (`C:\Users\Me.`, `FileSystem::C:\Users\Me` and `\\.\C:` included);
20
+ `format`, `diskpart`, deleting restore points and `wsl --unregister` are blocked. Registry start-up keys (the
21
+ person's environment and cmd's AutoRun too), `setx`, services, Defender, the firewall, `robocopy /mir`,
22
+ `taskkill /fi` and emptying the Recycle Bin are named.
23
+ - **Hooks with no shell:** on Windows `on` writes Claude Code's exec form (Node and its arguments), whose loader holds
24
+ a call when the hook is missing, damaged or crashes. Claude Code 2.1.310 or later; `on` refuses an older one, and
25
+ says so when it can't tell which one runs.
26
+ - **`off` and the other switches refuse from inside a session on Windows too:** by Claude Code's marker, Claude Code
27
+ among the parents, or a command no one types at that WMI, a scheduled task or an ended shell left behind.
28
+ - **macOS and Linux judge as before:** every one of this Mac's 143,211 real Claude Code calls since Oct 1 is judged
29
+ the same by the branch and its base (`scripts/coding-agents/windows-posix-equivalence.mts`).
30
+
31
+ ## [0.8.0] — Anvil for Claude Code: budgets, helper and model rules, and every screen says what each can do
32
+
33
+ ### The rules box never reads a line turned around (2026-11-19)
34
+
35
+ Found by three independent attacks (on a rewrite step that was then held: its sealed sets missed the bar). Each was a
36
+ line the box read as a stop on the very part the words leave out, or offered that as the closest. A rule only stops
37
+ what it names, so each is can't yet now; no reading of the 2,880 DEV lines changed (per line, against the box before).
38
+
39
+ - **Words that let part of a stop through**: "don't hold Stripe refunds under $50", "Stripe refunds under $50 don't
40
+ need my OK", "hold all Stripe refunds, ones under $50 have my ok", "… under $50 are good to go", "hold emails except
41
+ to acme.com". Where a stop on the whole was said first, that stop is offered (every refund: broader, never the part).
42
+ - **Everything but one thing**: "block anything but deploys", "block everything minus deploys", "hold every action
43
+ that isn't a deploy", "block everything, deploys are fine", "hold everything, let deploys through", "Claude may only
44
+ deploy", "hold non-Stripe refunds", "hold refunds that aren't from Stripe": never a stop on deploys or Stripe, nor a
45
+ closest on them ("Anvil can't stop everything but one thing"). "Anyone but acme.com" is still anyone outside
46
+ acme.com, "not over $500" still $500 or less, "Slack posts should only go out during work hours" still offers Slack
47
+ posts.
48
+ - **A part said as the one left out**: "emails that don't go to clients need my ok", "hold Slack posts that don't go in
49
+ #general", "hold pushes that don't go to main".
50
+ - **A condition said only in what happens**: "hold every deploy, claude keeps shipping on weekends" no longer holds just
51
+ weekend deploys. One pointed back at ("deploying after 9:30pm has burned us twice. hold those") is still read.
52
+ - **An inbox an email comes from**: "hold emails from the support@acme.com inbox" held emails *to* support@acme.com; it
53
+ is can't yet now (Anvil reads who a send goes to, not who it comes from), as "emails sent from …" already was.
54
+
55
+ ### The rules screen, redesigned: a box to type a rule in, four keys (2026-11-17)
56
+
57
+ - **Add a rule by typing it.** Between Always on and your rules sits an Add a rule box, in the product blue: type
58
+ "hold pushes to main", "never force-push", "at most 3 deploys a day" or "$50 a day", and under the box Anvil
59
+ says what it will do ("✓ every deploy waits for your OK"); enter adds it. Faint examples sit under the box until
60
+ the words are understood, and nothing typed is called an error until you press enter. Words Anvil's own reader
61
+ can't place go, on enter, to your Claude Code (Haiku, through your own login), once.
62
+ - **Four keys instead of eleven:** ↑↓ choose, space change, enter add, esc done. ⌫ twice removes a line you wrote
63
+ (one press only asks); type `import` to bring in CLAUDE.md. Each change is saved as it is made: there is no save key
64
+ to forget.
65
+ - **Sorted:** what is on first (blocks, then holds), then caps, budgets, model and helper rules, then what is watched,
66
+ then what is off, each section with room around it and a faint word on what it means.
67
+ - **The file is in the footer**, a link where the terminal opens one: `~/.anvil/rules.md` is plain Markdown, like
68
+ CLAUDE.md, to edit, keep or share. Edited outside the screen, the box says so and enter applies it, as `sync` does.
69
+ - **Proof is its own screen** (`anvil-claude proof`), no longer a tab: the rules screen is for changing rules.
70
+
71
+ ### Turning a rule you wrote down, in one key (2026-11-18)
72
+
73
+ - **Space now turns your own rules down as well as up.** On the rules screen, a rule you wrote used to only go
74
+ stronger with space; to watch it or switch it off you had to delete it and type it again. Now space changes its own
75
+ line and says so ("changed hold: deploys → off: deploys"): hold → off → watch → hold for a kind, a block to a hold
76
+ first, hold ↔ watch for a rule on one app, file or target. ⌫ twice still removes it, and the selected row says both.
77
+ A change that would make the line one Anvil can't use (an always-on kind watched) is refused, saying why; anything
78
+ else keeping the kind stronger is said, never hidden.
79
+
80
+ ### Who a send reaches, said honestly; words your rules can define (2026-11-18)
81
+
82
+ - **"Emails to clients" no longer quietly means every email.** Typed in the rules box or `rules add`, a send narrowed by
83
+ who it reaches ("hold emails to clients", "never email bob@acme.com", "Gmail sends to anyone outside my company") is
84
+ ? Can't yet: "Anvil can't narrow emails Claude sends by recipient yet ("clients")", with every send of it offered,
85
+ one key away. Written by hand in rules.md, the line holds every send, its catch said first ("It holds them whoever
86
+ they go to"), and its row says "every recipient": a line you wrote never stops holding what it held. Lines that were
87
+ refused for words Anvil couldn't place ("never email bob@acme.com") now hold every email, and say so.
88
+ - **`define:` lines.** `- define: clients = @acme.com, @globex.com` gives a word your rules use one meaning, listed under
89
+ your rules on both screens. A project's rules read yours, the project's own winning. (What each word means is read by
90
+ the conditions built next: amounts, recipients, part of an app, time. docs/coding-agents/IMPROVEMENTS-TO-CUSTOM-RULES-FOR-CLAUDE.md.)
91
+
92
+ ### Rule conditions: an amount, who a send reaches, part of an app, a time (2026-11-18)
93
+
94
+ - **A rule can carry a condition, and holds only when it holds.** "hold Stripe refunds over $500", "never email anyone
95
+ outside the company", "hold Slack posts in #general", "hold deploys on Fridays": each reads Ready in the box and
96
+ `rules add`, saying what still runs. A condition only narrows the stop its rule adds, and one Anvil can't read holds
97
+ the call, saying why. Two on one rule ("Stripe refunds over $500 on Fridays") must both hold.
98
+ - **An amount** on Stripe's, PayPal's and Square's refunds, charges, payments, payouts and transfers: over, at least or
99
+ under, in its currency, each field from the app's published schema. A full refund, another currency or a variable
100
+ holds. A refund's currency is read as yours only where you said it: `define: my currency = USD`.
101
+ - **Who a send reaches**, on emails and calendar invites: an address, a domain, a word you define (`define: clients =
102
+ @globex.com, @initech.com`), or anyone outside your company (`define: my company = acme.com`). A reply, a draft sent by
103
+ its id, a list or a relay holds. This replaces the Can't yet above: typed, a word not yet defined says what to write;
104
+ written by hand, what can't be read holds every send, its catch first.
105
+ - **Part of an app**: a Slack channel, a GitHub repository, a Linear team, a Jira project. Slack's and Linear's ids are
106
+ learned from Claude Code's own replies in its logs on this Mac (nothing is sent anywhere), and read again on `sync`
107
+ and as the rules screen opens. A gh command that names no repository is placed by the checkout it runs in.
108
+ - **A time**, on any rule: days, hours, nights across midnight, work hours (`define: work hours = Mon–Fri 9am–6pm`), on
109
+ the Mac's own clock. A time zone the clock can't read holds.
110
+ - **The money cap.** "at most $2,000 of Stripe refunds a day" adds up what each refund moves, and holds the one that
111
+ would go over. An amount it can't read holds and takes no place; one you OK counts the whole cap.
112
+ - **No cost when unused.** The conditions' code loads only when your rules have a condition, so the hook Claude Code
113
+ starts on every tool call stays its size.
114
+ - **Also:** `mailx`, `mutt`, `msmtp` and `swaks` are sends ("never send emails" holds them); "no more than $500 of
115
+ refunds a day" typed is a cap, and `rules add` takes a cap the box reads; what a rule learns of your apps (an id, a
116
+ reconnected connector) reaches the hook on `sync`.
117
+ - **The box reads a rule however you ask for it (2026-11-19).** "I want to approve every Stripe refund over $500",
118
+ "Refunds in Stripe above $1,750 — please check with me", "If Claude refunds more than $650 on Stripe, ask me first",
119
+ "weekends: no pushes to main", "I'd like a heads up whenever Claude posts in #general", "dont deploy on Fridays":
120
+ each reads as the rule it says, with the verb it says (a wish to approve holds, a heads-up watches, "isn't allowed"
121
+ blocks). The asking is only ever taken off: a condition inside it is read as before, never dropped. Also: "I'd like
122
+ X to wait for me", "X should wait", "X needs my say-so", "X, just log them", "X can go through but log them", "Gmail
123
+ shouldn't be emailing outsiders", "make gmail hold anything sent to …", "deny X", "so basically …", a sentence about
124
+ you around the rule. The strongest verb you say wins ("need my OK and should be monitored" holds), and "unless …"
125
+ stays with the rule (Can't yet, never dropped). Measured on fresh sets written by people who never saw the reader:
126
+ short, direct rules read well; plain speech is often Can't yet, with the closest rule, never a weaker one.
127
+ - **Money on more apps.** PayPal invoices by their whole total, and Shopify's refunds. Stripe's and Square's invoices
128
+ stay can't yet: no call that sends or pays one names its total. A Shopify refund is read in your currency, as a
129
+ Stripe refund is (`define: my currency`), and its catch says so.
130
+ - **Fixed: a POST is a read only by its whole body.** A body holding a `"query"` key anywhere (a GraphQL read's) was
131
+ taken for a read, so a refund sent with one ran under every rule. Now a body is a read only when it is a GraphQL
132
+ query or a JSON-RPC read and nothing else. Also held now: curl's URL globs (`{a,b}`, `[1-20]`, which send many
133
+ requests), a money field a form or a query names in a way Anvil can't place, PayPal's invoice updates, an invoice's
134
+ own currency, a tip.
135
+ - **Each condition reads more of how people say it.** Amounts: "north of $6k", "that top £12,000", "a thousand
136
+ dollars", "pay out", "issue refunds"; a share or an amount on what moves no money ("deploys over $500") offers the
137
+ rule without it. Recipients: "outside acme", "non-acme addresses", "people at other companies", lawyers, the board;
138
+ "back to the customer" and "to the attendees" narrow nothing, so the rule holds every one. Part of an app: "anything
139
+ Claude posts to #exec", "the Acme Slack workspace", "over in Jira". Time: a time said first, plan and package names
140
+ ("the Night Owl plan") never read as a time, dates said as can't yet.
141
+
142
+ ### Every rule you type gets one of three answers, said first (2026-11-18)
143
+
144
+ - **Ready, catch, or can't yet.** The rules box, `rules add`, the rule's row and `sync` answer every typed rule in one
145
+ of three states, in the same words. ✓ Ready: it does what you asked. ▲ Catch: it works, with one difference said
146
+ before anything else: an app that isn't connected here ("this covers its API now, and its tools once you connect
147
+ it"), a category that covers every app of it Anvil knows ("the 23 email apps Anvil knows, not just Gmail"), a rule on production that holds a
148
+ deploy which doesn't say where it goes, a command read as its whole kind. Enter adds it anyway, and the row keeps
149
+ the catch ("not connected yet") until it no longer holds. ? Can't yet: what Anvil can't do (a channel, a team or
150
+ repo by name, an amount, a time, an exception, two apps, an app nobody knows), and the closest rule it can, one key
151
+ away: enter adds it, `rules add` prints it as the command to run. A closest is never narrower than what you typed.
152
+ - **`rules add` reads a rule on one app, a file or folder, or one target as the box does.** It refused "hold Stripe
153
+ refunds" before ("name the app"), and turned "never send emails" into a watch on every write to an outside API. A
154
+ line written as rules.md writes it ("hold: Stripe refunds") is added as written.
155
+ - **A time or a condition on a kind** ("hold deploys on Fridays") is a can't yet in the box, offering the kind at any
156
+ time, so the line added says what it does. One written by hand into rules.md still holds every one, as before.
157
+ - **The reader:** a named part of an app ("Linear issues in the Payments team", "the billing-api repo"), "pause" as
158
+ asking first, "schedule" and "book" for calendars, a category named in the singular ("any texting app"), "without
159
+ my say", advice that names an app ("be careful with payments"), and 40 more widely used apps with their API hosts
160
+ (Freshdesk, Okta, Chargebee, TikTok, Mailjet and others), so a rule on one not connected is a catch, not a refusal.
161
+ - **Measured on sets nobody building it saw:** 79 and 81 of 90 on the first two written for the three states
162
+ (87.8% and 90.0%), and 84 and 87 of 90 (93.3% and
163
+ 96.7%) on two more written after the fixes their misses showed, scored once on the reviewed reader.
164
+ - An app connected while the rules screen is open is read again (its catch goes), at the cost of four file checks.
165
+ - **Whole on any screen.** On an 80×24 terminal a catch, the rule and what enter does all fit under the box; where a
166
+ screen has room for one line, that line says the whole state ("▲ Catch: not connected yet enter adds it anyway"),
167
+ never a sentence cut off. Found by the walkthrough in a real terminal.
168
+ - **An independent review found 13 faults, each fixed and pinned (say-the-catch.test.ts):** the apps added today made a
169
+ category's rule let a connector known by its id run (Help Scout's replies, Gusto's payroll): they never do now, and
170
+ the ones that send email or move money joined their category; "leaving" said of emails is their send; a category
171
+ says what it covers ("the apps Anvil knows"), never "any app"; a line applied before as a rule on its kinds stays
172
+ that rule (none holds less after an upgrade); a closest never drops words or reads back as less; `rules add` never
173
+ writes a line twice; a row's catch comes from the rules as applied; phrases like "the service now" or "base camp"
174
+ are no app; two API hosts (Brex, Constant Contact).
175
+
176
+ ### A rule on one app, one file or folder, or one target (2026-11-18)
177
+
178
+ - **One app or service:** `hold Stripe changes`, `never send email through Gmail`, `hold Slack posts`. One line covers
179
+ the app's MCP tools, its API reached from a command (`curl -X POST https://api.stripe.com/…`) and its CLI. Reads run.
180
+ Anvil knows an app by its server's name, your claude.ai connectors, the Claude app's connectors (by the names the app
181
+ keeps for their ids), its API's host and its CLI: names only, never a server's command or key. An app nothing here is
182
+ is refused with the one it may be ("did you mean Stripe?").
183
+ - **A cap on one app:** `at most 5 Stripe refunds a day` holds the sixth and counts nothing else.
184
+ - **One file or folder:** `don't touch migrations/`, `ask before editing package-lock.json`. It holds Claude's file
185
+ tools and every shell write Anvil can read (`>`, `tee`, `sed -i`, `cp`, `mv`, `rm`, a link into the folder); reads run.
186
+ A write Anvil can't read is held when the command names the folder. A secrets file is the secrets kinds' already, and
187
+ the line says so.
188
+ - **One target:** `hold deploys to production` (from the command itself: `vercel --prod`/`--target`, `fly -a`,
189
+ `railway -e`, `kubectl --context`, `modal -e`, terraform's workspace, `gh workflow run` by its name and inputs,
190
+ ansible's inventory, docker on another machine); `hold database destroys on the production database`; `hold pushes to
191
+ main in billing-api` (from the checkout the push runs in); `hold deletes outside the project`. A tool whose default
192
+ may be production, and a deploy Anvil can't place, are held: "Anvil can't tell which environment this deploys to".
193
+ - **A narrowed rule only adds a stop.** Over 2,000+ calls (the corpus, the MCP tools, every part's attack lines) no
194
+ verdict is weaker with every kind of narrowed rule set than without (tests/coding-agents/narrowed-all.test.ts).
195
+ - **The box shows what still runs** under a narrowed rule, and what it matched: "Stripe reads run · app: stripe (your
196
+ MCP server "stripe-live" · api.stripe.com · the stripe CLI)". Asking for your OK in words is the hold verb: "never
197
+ deploy to live without asking", "Stripe refunds need my approval".
198
+ - **Replay says what each narrowed rule let through,** not only what it stopped: "Stripe changes: stopped 12 calls ·
199
+ let 117 of the same kind run that a rule on the whole kind would have held".
200
+ - **Measured on seven sealed sets** (anvil-sealed-sets/: written by people who never saw the readers, kept outside every
201
+ checkout, scored once at integration; tests/coding-agents/typed-rules-sealed.test.ts). First score → after the misses
202
+ were read by pattern and fixed where general: apps 50 → 71 and 57 → 74 of 90 (every miss left is an app Anvil knows
203
+ that isn't connected here, which the spec reads as a rule, or a family read for one app); paths 72 → 90 and
204
+ 73 → 90; targets 60 → 85 and 56 → 84; deploy commands as "hold deploys to production" treats them 78 → 87 of 90,
205
+ with 8 production deploys let through at first (`vercel --target production`, `gh workflow run deploy.yml`,
206
+ `ansible-playbook`, docker on a remote host, none then read as a deploy) and 0 since.
207
+ - **On this Mac's last 30 days** (read-only): the app rules hold 60 of the 177 calls a hold on every app change would;
208
+ a rule on five folders removes 89% of the holds a hold on every write would make, and lets none into the folders
209
+ through; "deploys to production" removes few here (6 of 116: most deploys on this Mac are production, and a folder
210
+ named "…-prod-…" reads as production), each let-through checked by hand.
211
+ - **Fixed on the way:** a curl that wrote to a decoy URL first and Stripe's second ran under "hold Stripe changes";
212
+ Replay judged only a line's first part; `ImageMagick -delete` and a script only checked were read as deploys.
213
+
214
+ ### Narrowed rules: the shared core, and "deletes outside the project" (2026-11-17)
215
+
216
+ - **A rule can name part of a kind** (docs/coding-agents/IMPROVING-CUSTOM-RULES.md): `hold deletes outside the
217
+ project` holds a recursive delete whose target is outside the project folder, and lets the ones inside it run. It
218
+ is its own rule, beside the kind's (never a hold on every delete), listed under On on the rules screen, in `rules`,
219
+ Home and `report`, removed with ⌫ twice or `rules remove narrow-delete-outside`, and named in the held message
220
+ ("your rule "deletes outside the project" (~/.anvil/rules.md line 1)").
221
+ - **What it can't read, it holds:** a delete whose target Anvil can't place (`rm -rf "$DIR"`) is held, and the message
222
+ says what couldn't be read. A narrowed rule only ever adds a stop: over every call in the fixture corpus, no verdict
223
+ is weaker with narrowed rules than without (tests/coding-agents/narrowed-core.test.ts).
224
+ - **Built for the three parts that follow** (one app, one file or folder, one target): each narrowing's reader and
225
+ match live in their own files, so they can be built side by side.
226
+
227
+ ### The box reads what people type, and says why when it can't add it (2026-11-17)
228
+
229
+ - **A command is read the way the hook reads it** when Claude runs it: `docker push` holds a publish, `kubectl delete`
230
+ a deploy (not every delete), `crontab -e` a background job. The same in the box, `rules add` and a rules.md edited by
231
+ hand, so a line means one thing wherever it was written.
232
+ - **More of how people say it:** "ask before it deploys" holds, "don't let Claude force push" blocks; "delete the
233
+ database" is a database destroy, "copy the production database" a copy; more names for every kind.
234
+ - **What can't be a rule says why, and what to type instead:** a command Anvil lets run (`npm install`), one app
235
+ (`Stripe refunds`: try `app changes`), one file or folder, or advice for Claude (CLAUDE.md's). Words narrower than
236
+ their kind say so: "✓ every deploy waits for your OK, not just "fridays"".
237
+ - **Measured:** two sets of 90 lines written by people who never saw the reader, each scored once: 80 and 85 of 90,
238
+ where the reader before read 46 and 40 (tests/coding-agents/typed-rules.test.ts).
239
+ - **The README and `help rules` say what a rule covers and what it can't yet.**
240
+ - On an 80×24 terminal the Always on box folds to one line so your rules have the room; taller, it shows whole.
241
+ - Fixed on the way: a line typed as "hold pushes to main" was written `hold: hold pushes to main`; a count that names
242
+ a kind ("at most 3 publishes a day") was read as a hold, not a cap; a damaged mode file was said as "every kind is
243
+ switched on"; every box with a note in its border drew that border a column short.
244
+
245
+ ### Its own command: `anvil-claude`, beside the SDK's `anvil` (2026-11-17)
246
+
247
+ - **`@useanvil/claude-code` installs as `anvil-claude`**, and never takes the SDK's `anvil`. Both packages declared
248
+ `anvil`, so npm refused the second global install of the two (`EEXIST`), in either order, and the SDK's own pages
249
+ install it globally. Now they install side by side and neither touches the other's command or files.
250
+ `anvil-claude <sub>` is `anvil claude <sub>` (`anvil-claude on`, `anvil-claude rules edit`, `anvil-claude allow
251
+ <code>`); `npx @useanvil/claude-code on` the same through npx; `anvil-claude claude on` still works.
252
+ - **Every command Anvil prints is the one you have**: `anvil claude …` from the SDK, `anvil-claude …` from the small
253
+ package, `npx @useanvil/claude-code …` through npx, in every screen, held message and fix line.
254
+ `anvil-claude help rules` prints the guide in its own words.
255
+ - **The hook holds the agent switching Anvil off through the new command too**, in every form: `anvil-claude off`,
256
+ `npx @useanvil/claude-code ghost all`, `node …/@useanvil/claude-code/dist/cli.js allow …`,
257
+ `node $(which anvil-claude) off`, `xargs anvil-claude`, and a sync under another key.
258
+ - The dashboard's sign-in stays the SDK's (`anvil-claude login` runs `npx @useanvil/sdk login`, its latest): the small
259
+ package can be released without the SDK.
260
+
261
+ ### Runaway helpers held from the first call, and one OK per burst (2026-11-17)
262
+
263
+ - **More than 20 helper launches in 10 minutes in one session wait for your OK**, on every install, whatever the modes
264
+ say: a new always-on hold, "Stop runaway helpers". Each helper bills while it runs and can launch more, so a loop of
265
+ them spends fast. Measured first on four weeks of real sessions: work never launched more than 6 helpers in a minute
266
+ or 24 in 10 minutes, and this would have held 1 task in 1,440. Launches by helpers count in their session.
267
+ - **One OK lets a burst go on.** For helper bursts and delete bursts alike, your OK (`anvil claude allow`, or Yes in
268
+ Claude Code's prompt) starts the count again, so a burst you want asks once. Before, every call past the limit asked
269
+ again until the window passed. A No asks again; so does a prompt not yet answered.
270
+ - **The Always on box says the meter counts:** "Counts what every Claude Code session spends", with today's figure on
271
+ the rules screen. `report` and `/anvil` say it too.
272
+ - Replay counts a burst once. A table compiled before this release says its helper-burst stop is missing until
273
+ `anvil claude on` runs again (an upgrade does that on your first command).
274
+
275
+ ### Your plan budget in the desktop app, and budgets that stop at their number (2026-11-16)
276
+
277
+ - **A plan budget works in the desktop app.** `budget: 80% of my weekly limit` could only be measured where Claude
278
+ Code's status line ran (the terminal); the desktop app runs none. Anvil now asks Claude Code's own `/usage` for your
279
+ plan's use where no status line feeds it: in the background, a few seconds, no model call and nothing spent, at most
280
+ every 5 minutes (2 near your budget), only while a plan budget is set. It asks the Claude Code running the session,
281
+ with a clean environment and nothing saved; Anvil never reads your sign-in. `rules add` and `report` ask at once, so
282
+ they show where your week stands ("Now: 38% of your week · budget 30% · read just now"). Checked live on the desktop
283
+ app's own Claude Code (2.1.325): the first message started the read, the next was refused before the model.
284
+ - **A budget stops at its number, not a few replies past it.** Anvil acts between steps, so a reply under way always
285
+ ends. Each check now also counts what's running (two replies of the main chat and of each helper running, priced as
286
+ their latest replies, a finished helper nothing; at a launch, each new helper's first reply and the launches let
287
+ through just before it), and holds when that could pass the budget: "today's budget is nearly spent: 15K of 20K new
288
+ tokens, and what's running could pass it", or "the helpers starting could pass today's budget: 4K of 20K new tokens
289
+ used". Measured live with three helpers launched at once against 20K new tokens a day: 39,993 before (100% over);
290
+ now it ends at or under 20K. The guess about replies already running counts for at most half a budget, so it never
291
+ holds before half is used.
292
+ - **A helper reporting back continues the task.** Claude Code sends each helper's report to the message hook as a
293
+ message of its own (measured in the desktop app). Anvil took it for yours: a task budget began again at every report
294
+ and a spent budget refused the report, dropping work already paid for. Now it continues the task and is never refused;
295
+ the next action is held.
296
+ - **A launch is priced as helpers really start.** The desktop app's helpers start at 42K new tokens each (they carry its
297
+ connectors' tools), not 10–20K: a launch is now priced by helpers' own first replies on this computer, at their own
298
+ model, and a session's first reply (Claude Code's instructions written once) no longer prices the replies after it.
299
+ In the terminal, a session's first reply is counted while it is still being written (it reaches the disk only after
300
+ its tool calls are checked): a cold-cache run with three helpers ended 14% over its budget that way.
301
+ - **Every session counts.** A day's or a week's budget is shared by every Claude Code session on your computer; each
302
+ now also counts the others' work in progress (their replies running, their helpers, the launches they're making), so
303
+ two busy sessions can't pass it together. A task's budget stays its own. Measured live with two sessions launching
304
+ helpers at once: 23% over before; after, the right number of helpers starts and the day ends within one reply of its
305
+ budget (0.3–2% past it, the last replies reading the holds).
306
+ - **A helper is priced as it will cache.** A helper starting within 5 minutes of another (on the same model) reads its
307
+ instructions from Claude Code's cache and costs about half a cold one; launches are now priced that way, what helpers
308
+ cost is remembered past a week, and a launch held on a guess (no helper run on this computer yet) says so. The guess
309
+ itself is now priced from the session's own first prompt (it took a mid-session one, up to 380K for a 42K helper):
310
+ over 189 real tasks, a first helper is held when the task would have fit 4% / 3% / 1% of the time at 1.25× / 1.5× /
311
+ 2× its cost, was 15% / 11% / 7%.
312
+ - **A helper's hand-back is never held.** Held near a budget, a helper retried its hand-back and ended with no report;
313
+ a budget now never holds a step that only ends or reports the work (the hand-back, the desktop app's end-of-turn box
314
+ and task list). And Claude tells you to run `anvil claude allow` alone when something waits: it lists what's waiting,
315
+ so you don't need to find the code in the desktop app's folded notice.
316
+ - **Your own status line needs no change.** The line `on`, `rules add` and `report` printed for it is gone: the plan
317
+ is read from `/usage` instead.
318
+ - **Clearer words.** A change refused inside Claude Code puts the command on a line of its own (it wrapped mid-command);
319
+ rule conflicts read as one sentence; Home and `report` say the kill switch first; Proof says "action at your budget".
320
+
321
+ ### From the desktop check (2026-11-15)
322
+
323
+ - **`model: never haiku` holds in a session that starts on Haiku.** The desktop app's model picker before a session's
324
+ first message, and `claude --model haiku`, start Claude Code on that model with no switch for Anvil to refuse, so
325
+ the session ran. Now a message on a model your rules say never is refused before it reaches the model, with the way
326
+ to switch ("Switch first (the model picker, or /model opus), then send your message again"). A switch Anvil lets
327
+ through is remembered, so the next message goes on.
328
+ - **Every step says where it runs.** A held action or a refused message read "keep going once: anvil claude allow
329
+ nwr22kqx", which left it open whether that went in the chat. Each step a message asks of you now says it runs in a
330
+ terminal (not in this chat), puts a one-time code on a line of its own to copy, and says what comes after ("Then
331
+ send your message again", "Then tell Claude to go on"). The same for the session's first line, a problem's fix, the
332
+ status line and the desktop notice.
333
+
334
+ ### Every screen says what a limit can do
335
+
336
+ - **One answer for every screen.** `rules add`, `anvil claude rules`, the rules screen, Home, `on` and `report` say
337
+ what each budget, cap, helper and model rule does now: it holds; it can't be measured, and why; Claude Code doesn't
338
+ tell Anvil what it needs, and which Claude Code (by version and path) keeps that out; or nothing checks it here
339
+ (Anvil not on, not in this folder, hooks turned off, the kill switch, the meter file missing). Each comes with its
340
+ fix. Nothing says "past it, Claude Code stops" for a limit that can't.
341
+ - **A plan budget an API key can't fill** says so, with a dollar budget as the fix. (Your own status line: see 2026-11-16
342
+ above.)
343
+ - **The rules screen fits 80×24**, with any number of rules: one list scrolls around the cursor (kinds, then caps,
344
+ budgets, model and helper rules), the title, the always-on stops and the keys stay in view, and no line runs past
345
+ the screen. A limit's state wraps under its own column, never cut.
346
+ - **Only what holds here.** `anvil claude rules` and the rules screen list the rules in force in this folder, label a
347
+ project's ("this project only"), and count another project's instead of listing them as if they held here. `report`
348
+ from a folder a project install doesn't cover says Anvil isn't on there. `anvil claude statusline` says it isn't
349
+ working when its hook can't start, as Home does.
350
+ - **`on --project` keeps your status line.** It adds Anvil's only where no status line shows in that project already.
351
+ - **Help says what each limit needs:** Claude Code 2.1.304 for model rules, 2.1.318 to refuse a message, start a task
352
+ budget, count helpers and refuse a `/model` switch; the desktop app has no status line; the plugin route checks
353
+ actions only. `anvil claude help rules` prints the guide (a package's path to it ran past 80 columns).
354
+ - **Amounts near a budget never round up to it** ($49.60 of $50, $9.99 of $10, $50.40 past it), and Home never says
355
+ "Claude stops" under the kill switch or while an OK you gave still runs ("going on with your OK until 4:12 PM").
356
+ - **Smaller truths.** Proof's worst line leads with how it went ("watched, so it ran"). A rules.md line missing its
357
+ colon is told the line it meant (`- budget: $5 a day`), and `- model opus for deploys` is reported, never ignored. A
358
+ model rule says which kinds its words cover ("pushes" is a push to main and a force-push). `anvil claude rules` shows
359
+ the id `rules remove` takes. A budget hold that can't be recorded names the folder and the fix. `report` names a
360
+ missing meter file as a problem. A person who never turned Anvil on is told "isn't on yet", and Proof says nothing
361
+ has been checked rather than an all-clear.
362
+ - **Found by an independent review, fixed before the release:** a status line that already feeds Anvil is never told it
363
+ doesn't; a hook whose files are gone makes every limit "not checked"; quiet events count only from the settings
364
+ Claude Code reads in that folder; a spent budget leads Home over an OK on another; long paths wrap within their column
365
+ and are never cut; the status line command a person copies works when theirs ends in a comment; the rules screen fits
366
+ 11 rows and up, a note included; the message gate never waits on a named pipe.
367
+ - **The guide that ships is for you.** `YOUR-RULES.md` is the user's guide (what each limit needs, your own status
368
+ line, what Anvil doesn't do); the build record that was in it is `YOUR-RULES-RECORD.md`, in the repository only.
369
+
370
+ ### Added
371
+
372
+ - **What Claude Code spent.** The status line adds today's dollars (`🔹 Anvil on 🔹 14 checked · $3.10 today`), or on a
373
+ Claude plan the share of the week used (`41% of week`). `anvil claude report` shows today and this week (from
374
+ Monday) in dollars and new tokens, and the Proof tab a Spend line for its window. Dollars are Claude Code's own figure where its
375
+ status line ran, and Anvil's estimate at list price (marked `~`) for sessions it didn't see, such as the desktop
376
+ app's. It keeps each reply's model and token counts in `~/.anvil` for 40 days, never its text, and sends nothing.
377
+ - **Upgrades finish themselves.** After `npm i -g` of a newer Anvil, the first command you run in your own terminal
378
+ (Home included) puts the new hook in place, for each place `on` was run, and says so once. Only an intact older build
379
+ is replaced: a damaged install is reported as before, an older package never replaces a newer hook, and nothing
380
+ changes from inside Claude Code. The session start now names an update of any of the hook's files, not only the hook.
381
+ - **Budgets.** `anvil claude rules add "budget: $50 a day"` (also a week or a task, `5M new tokens a day`, or
382
+ `80% of my weekly limit`) sets what Claude Code may spend. At 80% it says so once; spent, the next message is refused
383
+ before it reaches the model and the next action is held, each with a one-time code, and `anvil claude allow <code>`
384
+ lets that task go on. A budget it can't measure (a plan's share with no status line reading yet) is never enforced,
385
+ and every screen says so; Claude can't feed the meter (its hook files run by hand, or `anvil claude statusline`, are
386
+ held). Home, `report`, `anvil claude rules` and the rules screen show where each stands, and Proof counts the stops
387
+ it made ("your budget"). Budgets live in your own `~/.anvil/rules.md`, and the message hook never reads the message. A cap line that reads as a budget (`cap: $50 a day`) says which to write.
388
+ - **Four quiet hook entries** (Claude Code 2.1.318 or later): a prompt, a helper agent starting or stopping, and a
389
+ model switch. Each answers nothing and never blocks, except a message sent past a budget you set and a switch to a
390
+ model your rules say never; `off` takes them out with the rest. Whatever breaks in Anvil, they let the message, the
391
+ helper or the switch through.
392
+ - **The main chat's model.** `model: opus for deploys` (any kind of action) holds a call made on another model
393
+ ("deploys need Opus; this session is Sonnet · switch: /model opus"); after `/model opus` the next try runs. The
394
+ model is read from the request line Claude Code writes as each request goes out (2.1.304 or later), so it is that
395
+ reply's own, and a helper's call is judged by the helper's model. `model: never opus[1m]` refuses that switch through
396
+ Claude Code's PreModelSwitch hook (the terminal's `/model`, the desktop app's picker, an SDK's `set_model`). Anvil
397
+ never switches the main chat's model itself.
398
+ - **`anvil claude rules` lists caps, budgets, helper and model rules** in a box of their own, each with what it does
399
+ now. Before, they showed only on the rules screen.
400
+ - **Helper agents: model and caps.** A rules.md line `model: haiku for exploring` (or `sonnet for helper agents`)
401
+ runs the helpers Claude launches on that model, whatever Claude asked for (checked live: Claude asked for Sonnet, the
402
+ helper ran on Haiku). `cap: at most 5 helper agents at once` holds the next launch until one finishes, counted per
403
+ session from the new entries; Claude is told to wait, not retry. `cap: 20 helper agents an hour` is an ordinary cap.
404
+ A fork keeps the session's model, and Anvil says so. `anvil claude try`, the rules screen, Proof and help show them.
405
+
406
+ ### Bounded OKs and caps
407
+
408
+ - **A budget's OK reaches no further than it says.** `anvil claude allow` past a budget lets that task go on in this
409
+ window only (a new day, week or plan window asks again), up to one more budget's worth, and for an hour at most;
410
+ each action it lets through is recorded. Claude is told of the OK with your next message, so it goes on instead of
411
+ waiting.
412
+ - **The helper cap holds with your own ask rule.** `permissions.ask: ["Agent"]` no longer turns `cap: at most N helper
413
+ agents at once` off. A launch asked in Claude Code's prompt keeps its place until you answer, and a No gives it back.
414
+ A workflow's helpers count. A helper counts until 30 minutes after its transcript last changed (it was 5), long
415
+ enough for a long test run.
416
+ - **Codes don't outlive their call.** A newer OK, or the call running, makes the older codes for the same call in that
417
+ session moot.
418
+ - **A missing meter file is said.** `anvil claude on` won't finish without `claude-meter.js`. If it goes missing, the
419
+ hook says once a session that budgets and model rules can't be checked, and Home and the rules screens say so
420
+ instead of "Claude stops".
421
+ - **The overshoot, stated honestly.** A budget can run over by about two replies per thread plus the reply that reads
422
+ the hold, not "one reply" (BUDGETS.md has the measured bound).
423
+
424
+ ### Fixed: what Claude Code spent is counted whole, from its own figures, and scoped
425
+
426
+ - **Workflow agents count.** The Workflow tool's agents (`<session>/subagents/workflows/…`) are read like helper
427
+ agents: their tokens and dollars reach budgets, `report` and Proof, and a model rule reads their model.
428
+ - **Claude Code's own cost record.** When a process ends, Claude Code writes its running total into the session file
429
+ (side requests such as titles and compactions, and helpers, included). That process's dollars are now Claude Code's
430
+ own, for the desktop app, `claude -p` and an IDE too; Anvil's list-price estimate (`~`) is left only for a process
431
+ still running. A chain of resumed processes, a fork's copy of its parent's record and the status line beside a
432
+ record count each dollar once.
433
+ - **A model with no price says so.** A dollar budget reads "can't measure: no price for claude-opus-6" instead of
434
+ ~$0.00 (its tokens still count); a gateway's model id (`anthropic/claude-opus-5-5`) counts as the model it names.
435
+ - **A plan reading is this session's account's, and shows its age.** Readings are kept per account (from the session
436
+ file's latest process, else its config folder), never another's. Over an hour old, or from before its window reset,
437
+ a plan budget reads "can't measure (last reading 6 days ago)", unless the reading is already past the budget (a
438
+ window's use never falls: it holds until the reset); Home, the rules screen, `report`, Proof and the status line
439
+ show each share's age.
440
+ - **Week budgets count the whole window** from the first check (files changed since it began, 32 MB a round), and say
441
+ "can't measure yet" while files are still unread; a task budget waits only for its own session's files.
442
+ - **A session resumed elsewhere keeps its dollars, counted once**: a new process's first reading no longer covers
443
+ replies another process made; spend in the desktop app or `claude -p` between two terminal days counts in its own
444
+ days, not again in the next; a resume after a process that ended without a record counts only what it added. A
445
+ ledger line cut short by a full disk no longer swallows the next one. A Mythos session is told apart by model rules.
446
+
447
+ ## [0.7.0] — Anvil for Claude Code: see what your agent did, stop the risky few, and watch it from your dashboard
448
+
449
+ Not yet published. (0.6.0 was never published: local builds carried it, so this release takes the next number.) Anvil
450
+ now sits in front of Claude Code itself: a few stops are always on from the first call, everything else starts in
451
+ ghost, and every stop reaches the same dashboard and receipts the SDK uses.
452
+
453
+ ### Added
454
+
455
+ - **`anvil replay`** reads this machine's Claude Code history (`~/.claude/projects`) and shows what
456
+ Anvil would have stopped: a report page and a five-line summary. What it finds stays on the machine,
457
+ apart from one anonymous count (TELEMETRY.md).
458
+ - **`anvil claude on | off | status | proof | enforce | ghost | allow | rules | sync`** puts a hook in front of
459
+ every Claude Code tool call. From the first call it blocks wiping your home folder or the project and
460
+ force-pushing main, and holds changes to Anvil or Claude Code's own settings, use of your account keys, delete
461
+ bursts and calls it can't check (`anvil claude rules` lists them); everything else starts in ghost. `enforce`
462
+ holds the risky kinds (push to main, deploy, publish, secrets, …) for your OK; `allow <code>` lets one held call
463
+ run once; `off` puts `settings.json` back as it was (or, if it changed since, removes only Anvil's hooks), and
464
+ `off --purge` also deletes what Anvil kept on the machine. The hook never touches the network.
465
+ - **Anvil's switches are yours**: `on`, `off`, `ghost`, `allow`, `sync` and changes to your rules run only in your
466
+ own terminal, never from inside a Claude Code session, and every change is on the record (`status`, the Proof tab).
467
+ - **Fails closed**: a check that stalls holds the call (Claude Code 2.1.295+), and `status` names an older Claude
468
+ Code that would let it run.
469
+ - **The Proof tab** (`anvil claude proof`, or tab in `anvil claude`): what Anvil stopped and why, worst first.
470
+ - **Your rules and caps** in `~/.anvil/rules.md` and a project's `.anvil/rules.md` (`hold:`, `block:`, `watch:`,
471
+ `off:`, `cap: at most 3 deploys a day`): `docs/coding-agents/YOUR-RULES.md`.
472
+ - **Your rules from CLAUDE.md**: `anvil claude rules import` reads them with your own Claude Code and
473
+ shows each rule beside its line before saving; `rules add "<sentence>"` adds one.
474
+ - **Dashboard sync** (signed in with `anvil login`): stops reach the workspace within seconds and mode
475
+ flips come back within a minute, through a background process the hook starts; offline, stops wait
476
+ and arrive once. Each stop carries the kind of action, verdict, mode, Anvil rule name and time, the
477
+ machine's label and a short session id; never a command, path or project name. Machines carry a label (`anvil claude on --machine <name>`).
478
+ The actions sidebar groups them under **Claude Code**, with a filter.
479
+ - **A Claude Code plugin** in this repo (`plugins/anvil`; installable once the repository is public): the same hook
480
+ with its own baseline rules,
481
+ `/anvil` (mode, rules, today's counts, the dashboard), the anvil-protect skill and the MCP server.
482
+ Where `anvil claude on` already covers a session, the plugin's hook steps aside.
483
+ - **`TELEMETRY.md`**: three anonymous usage counts (`claude_on`, `replay_run`,
484
+ `decisions_daily`), each shown in a notice before the first send.
485
+
486
+ ### Changed
487
+
488
+ - `POST /v1/decision` accepts the Claude Code hook as a source (`claude_code_hook`, `claude.*` actions
489
+ only, its own stop codes) and a `held` outcome. The SDK pre-flight's contract is unchanged.
490
+ - The CLI honours `DO_NOT_TRACK` for every usage event.
491
+ - The control plane's usage counter keeps the three new event names.
492
+ - **Anvil for Claude Code on its own**: `@useanvil/claude-code` (about 400 KB, no dependencies) has the same `anvil
493
+ claude`, and the README leads with it. Its `anvil replay`, `login` and `open` run the SDK of the same release.
494
+ - **Where it runs**: macOS and Linux · Node 20+ · Claude Code 2.1.295 or later. On Windows `anvil claude on` says so and
495
+ changes nothing; `@useanvil/claude-code` declares the platforms it installs on.
496
+ - **Fits the terminal**: every line `anvil claude` and `anvil replay` print fits 80 columns, broken at a space and never
497
+ inside a word or a command to copy. Piped output keeps whole lines.
498
+ - **Errors say what failed**: one line naming what failed and why, with `--debug` for the details and where to tell us.
499
+ No stack trace unless asked.
500
+ - **`off --purge` checks first**: a file it can't delete changes nothing, and it names the file and the fix.
501
+ - **Replay says what was measured**: on 1,433 real commands the rules had never seen, with every rule on, they
502
+ stopped 94 in 100 of the risky ones and 7 in 100 of the safe ones.
503
+ - **The same bytes from every clean build**: two clean clones of one commit pack identical tarballs.
504
+ - `CHANGELOG.md` ships in both packages, and nothing either one links needs access to the repository.
505
+
506
+ ## [0.5.6] — A stuck claim has a way out, a held payment reaches a person, and no screen reports a lever it never read
507
+
508
+ Published 2026-09-20. Forty-five commits, in three strands. The **durability loop closes**: a
509
+ durable claim that got stuck now has an exit that is not `psql`, and a settle can only ever touch
510
+ the claim its own caller took. **A held payment reaches a person**: a confirmation gate with no
511
+ webhook falls back to email, and every surface says so when a gate would reach nobody at all. And
512
+ the theme 0.5.4 and 0.5.5 ran on — **a surface may not state what the read behind it could not
513
+ support** — reached the last screens that still could: the sidebar under an operator lever, and
514
+ the deploy report.
515
+
516
+ ### Added
517
+
518
+ - **`anvil db settle-claim <key>` — a stuck durable idempotency claim finally has an exit that is
519
+ not a DBA with `psql`.** It applies the reclaim sweep's own classifier to ONE named row, inside a
520
+ single transaction that takes the audit-chain lock first and touches the claim last, so a
521
+ concurrent `/v1/guard` never waits behind it. Who ran it and why land in the audit ledger in that
522
+ same transaction, under a key no money reader can mistake for evidence. It refuses rather than
523
+ guesses: a claim younger than an hour, one whose lease is live, one re-taken mid-review, and —
524
+ the case that matters — one whose only failure receipt predates the attempt now holding the key,
525
+ which would otherwise reopen a key on another attempt's evidence. `--list` shows what is stuck,
526
+ `--dry-run` shows what it would do, and a database without migration 029 answers "cannot look
527
+ here yet" rather than "nothing is stuck".
528
+ - **`anvil doctor` names a service-key mismatch between this app and the plane it reports to**
529
+ (D5-M36). A key minted for one service, used by an app that declares another, produced modes
530
+ that silently never applied; the check names both sides, says which one this process is, and
531
+ prints a remedy that is true for the layout it found.
532
+ - **A confirmation gate that would reach nobody says so at the moment it is armed.** Arming a gate
533
+ on a workspace with no webhook and no proven email address is the one configuration where a held
534
+ payment waits for a person who is never told. The warning is raised where the decision is made,
535
+ not discovered later by a customer whose payment sat.
536
+ - **`/v1/deploy-report` names retired environment variables still set on the service**, and
537
+ `anvil doctor --deploy` gains a `no-retired-env` check that reads it. A variable nothing reads
538
+ any more is not an error — but an operator who believes it still does is one config change from
539
+ a surprise.
540
+ - **The dashboard names the workspace whose decision is in force**, or says plainly that it cannot
541
+ tell, instead of implying the one you are looking at.
542
+ - **Docs: "Where is my API key?"** — where the line lives, how to copy only the value, why Verify
543
+ asks for it, and what to do when it is gone. Placed after Quickstart, where people hit it.
544
+
545
+ ### Fixed
546
+
547
+ - **A degraded claim settle could fail ANOTHER caller's in-flight claim, and re-open a key whose
548
+ money was moving.** Under `ANVIL_DURABLE_CLAIM_FAIL_MODE=closed`, `/v1/guard`'s cleanup for a
549
+ claim it could not confirm settled by `(workspace, key)` alone — and 250ms, the budget that
550
+ triggers it, is also what a caller gets while queued behind another caller's row lock. So the
551
+ cleanup could wait out that lock and stamp `failed` on the winner's row, which is the one status
552
+ the re-claim clause admits: the key re-opened mid-flight and the next retry was granted. The
553
+ settle is now bound to the `lock_token` its own caller minted. A process may settle only a claim
554
+ it can prove it owns. **Latent on the default `open` fail mode**, which is why it had not fired.
555
+ - **`/v1/complete` left the claim `pending` when its lock token was already gone.** The token is
556
+ consumed with a GETDEL, so no retry of the completion could ever settle that row and only
557
+ `anvil db settle-claim` could clear it. It now ends the claim as `unknown` — found by the token,
558
+ scoped to the workspace, and only while the row is still pending, so a duplicate completion
559
+ after a successful one stays a no-op and a key whose money may have moved is never re-opened.
560
+ - **The sidebar reported "enforcing — live" for a flip the runtime had pinned to ghost.** A global
561
+ kill switch and an operator cap each hold every action in ghost at read time, and the write path
562
+ read neither — so on the surface people use most, the dashboard claimed enforcement while
563
+ nothing was blocking. Every surface now reports the mode IN FORCE, and a release of the lever
564
+ hands each row back the mode that is actually running, restoring only decisions somebody stored
565
+ rather than inherited defaults.
566
+ - **A held payment could reach nobody at all.** A confirmation gate with no webhook configured had
567
+ no fallback, and a webhook that failed had no second path. Holds now reach a proven email
568
+ address when the webhook is absent or fails, and one reach authority answers "who would this
569
+ reach?" for every surface, rather than four of them holding separate opinions. A burst of holds
570
+ no longer becomes a burst of mail: past a workspace's budget for one window, a single
571
+ "Anvil held N more" email stands in for the rest, and that summary survives a restart — it is
572
+ flushed on the next boot, re-entering the workspace it was held for. A Resend 429 is retried
573
+ once, honouring `Retry-After` only when the wait fits inside the send's own time bound.
574
+ - **A capped flip rehearsed enforcement and then snapped back.** The row painted enforce
575
+ optimistically and the answer corrected it a moment later, so telling the truth looked like a
576
+ glitch. A flip a known lever cannot let land is no longer animated; the write still goes through,
577
+ the stored intent still applies the moment the lever lifts, and the row catches up from the
578
+ answer if the lever turns out to be gone. The toast says "saved · ghost is what runs" rather
579
+ than reading like an error on a write that worked, and explains the lever once per session
580
+ instead of repeating the paragraph on every action.
581
+ - **The dashboard's Verify box rejected a pasted `.env` line.** Copying a key out of `.env` copies
582
+ `ANVIL_API_KEY=anv_live_…`, and the box answered "not recognized" — a puzzle with exactly one
583
+ answer. The prefix and surrounding quotes are now stripped, and both the hint and the rejection
584
+ name the file and the way back (`anvil keys rotate`).
585
+ - **A reachable control plane lost to a stale cached ghost.** A cached mode from an earlier
586
+ unreachable moment outranked a plane that was answering again, so an action stayed in ghost
587
+ after control was restored.
588
+ - **`anvil doctor`'s service-key remedy was wrong in three ways** — it advised a flip that would
589
+ not write under the app's own service, advised unsetting a service it should not, and claimed a
590
+ dashboard could set modes it can neither set nor show for that app.
591
+ - **Concurrent rotations of one docs log rotated it more than once**, shifting a batch past the
592
+ generation an operator would look in.
593
+
594
+ ### Changed
595
+
596
+ - **The warning printed when a claim settle does not land names `anvil db settle-claim`** instead
597
+ of pointing at a reclaim sweep. The sweep is a command, not a daemon: nothing runs it on a
598
+ schedule, so an operator sent to look for one would never find it.
599
+ - **The enforce-weekly recap and the blast-radius documentation** stop describing a 429 as holding
600
+ an unconfigured tenant. It never did — such a call runs in ghost — and the operations docs now
601
+ say what actually happens.
602
+
603
+ ## [0.5.5] — `anvil key --field` writes a key that runs, and no surface reports a lever it never read
604
+
605
+ Published 2026-09-18. Thirty-eight commits, in two strands. The fixes that landed after 0.5.4 was
606
+ cut, led by one that broke the first command of the quickstart: `anvil key --field` wrote a key
607
+ that threw on every call, and in a JavaScript file wrote one that would not even parse. And the
608
+ theme 0.5.4 started — **a surface may not state what the read
609
+ behind it could not support** — extended from degraded reads to the operator LEVERS that silently
610
+ outrank a write.
611
+
612
+ ### Fixed
613
+
614
+ - **`anvil key --field` wrote a key that threw on the first call — and, in a JavaScript file, one
615
+ that did not parse.** The rewrite emitted `(args) => key.for(…args[0]…)`, but `wrap()` calls a key
616
+ factory with a `WrappedCallContext` — `{ thisArg, args }` — so `args[0]` indexed the context, came
617
+ back `undefined`, and the field read threw on every call to the action the command had just
618
+ "fixed". It also wrote a TypeScript cast, `(args[0] as { ticketId: string })`, into `.js` files,
619
+ which Node refuses to load. `anvil key` and the `protect` codemod now build key factories through
620
+ one shared emitter, the file's own language decides whether the key carries a cast, and candidate
621
+ fields come from the wrapped function's own signature, or from the intersection of its call sites
622
+ when it states none.
623
+ - **⚠ BEHAVIOUR CHANGE for a self-hosted Postgres ledger.** The enforce weekly recap
624
+ (`anvil ghost enforce-weekly`) read the audit ledger with no workspace scope, so on a
625
+ multi-tenant ledger one tenant's email described every tenant's traffic. It now passes
626
+ `workspaceId`, defaulting to `callersOwnWorkspaceId()`. **On a JSONL ledger, or a Postgres one
627
+ with no `ANVIL_WORKSPACE_ID`, nothing changes.** On a Postgres ledger with a *real*
628
+ `ANVIL_WORKSPACE_ID`, pre-tenancy rows written before that column existed (`workspace_id IS
629
+ NULL`) now fall outside the report — Postgres matches a real workspace strictly and adds
630
+ `OR workspace_id IS NULL` only for the DEFAULT workspace. The recap can therefore show fewer
631
+ watched calls and less protected money than the week before the upgrade. That is the deliberate
632
+ WS2/WS3 tenancy semantic, and it is the correct direction — but it is a number an operator
633
+ reads, so it is called out rather than left to be discovered.
634
+ - **The offline rule templates offered a cap 100× too small.** `TEMPLATE_PRIMITIVE_FALLBACKS` —
635
+ the table each dashboard falls back to when `/api/primitives/schema` has no entry for a
636
+ primitive — carried `{amount:1000}` and `{amount:50}` with no `unit`. Untagged money is MINOR
637
+ by contract on both sides of the wire, so the picker handed out a $10.00 amount cap and a $0.50
638
+ workflow budget under cards reading $1,000 and $50 — and `defaultParamsForSpec` clones defaults
639
+ straight into the rule that gets SAVED, so it persisted a policy nobody authored.
640
+ `check:money-format` gains CHECK 6 so no money default can ship untagged again.
641
+ - **A mode write told the caller and every other open dashboard different things.** With the
642
+ global kill switch armed, the HTTP response correctly reported `runtimeMode: 'ghost'` while the
643
+ SSE frame carried the raw intent, so every *other* open dashboard was told the action was
644
+ enforcing. No frame carried `runtimeApplied` at all, so a flip whose control-store write failed
645
+ was indistinguishable on the wire from one that landed.
646
+ - **An operator-capped workspace was told its Enforce flip worked.** A ceiling of `observe`
647
+ (migration 020) pins every action to ghost, and the write path never read it, so a capped tenant
648
+ got a 200 and "your runtime picks it up on the next call". Nothing would enforce.
649
+ - **A dry run of a call that was already released predicted `pending_approval`** — with an approve
650
+ link to an id that 404s. `guard({ dryRun: true })` now makes the same redemption lookup a real
651
+ call makes (a read: nothing is spent, held or written) and predicts `already_released`. Ghost-mode
652
+ calls skip it as before; that is the hot observe path. The shipped type comments also stop saying
653
+ a dry run reserves and refunds spend — it does neither.
654
+ - **The "someone is blocked" alert could go out from a sandbox domain.** It forwarded a sender only
655
+ when `RESEND_FROM_EMAIL` was set in the environment it was handed, leaving the mail layer to fall
656
+ back to the process's own — so a process with a sandbox sender in its `.env` sent the one email
657
+ that says someone is stuck from a domain Anvil does not own, where it bounces or lands in spam.
658
+ The sender is now resolved once, falls back to Anvil's default, and is always forwarded.
659
+ - **Ghost analysis of a large single-entity export was quadratic.** One entity with k records made
660
+ `summarizeEntity` O(k²) and blocked the inline connector path: 1,000 records took 1.4s and 2,000
661
+ took 4.3s. It is linear now — 15ms and 52ms — with byte-identical output.
662
+ - **`strandedEnforce` counted tenants who were not stranded.** The count read only
663
+ `hosted_policies` and never joined `workspaces.enforcement_ceiling`, so an operator-capped
664
+ workspace — which enforces nothing — was reported as enforcing without a policy, while the
665
+ sibling `cappedWorkspaces` counted the same account. The two are described in the code as
666
+ mirrors and were overlapping.
667
+
668
+ ### Added
669
+
670
+ - **The Anvil Deployed page, served by `anvil serve` at `/managed`**, with its booking intake at
671
+ `POST /api/deployed-lead`. Both are public routes. The intake is rate-limited and size-capped, and
672
+ answers `200` only once the lead is durably committed — `400`, `429` and `503` otherwise — because
673
+ the person submitting it is waiting to learn whether they reached anyone. On a production plane
674
+ with no durable store configured it answers `503`, not a `200` for a lead the next deploy would
675
+ erase. The build now fails if any page the server can serve is missing from the tarball:
676
+ this one was a single line from shipping as a 404.
677
+
678
+ ### Changed
679
+
680
+ - The dashboards now surface a "saved, but not yet live" notice when a mode change is persisted
681
+ but the runtime has not taken it, naming the lever — kill switch, operator cap, or an
682
+ unreachable control store — instead of always blaming the store.
683
+
684
+ ## [0.5.4] — Every degraded read says so, and an outage is never money saved
685
+
686
+ Published 2026-09-10. Forty-two commits. The theme is one sentence: **a surface may not state what the
687
+ read behind it could not support.** Several of these were places Anvil's own outages were being
688
+ reported back to you as value it delivered.
689
+
690
+ ### Fixed
691
+
692
+ - **A spend-cap store outage was billed to you as money Anvil saved.** When the cumulative spend-cap
693
+ store was unreachable, Anvil failed closed — correctly — but wrote the receipt as
694
+ `spend_per_user` / `spend_per_workflow`, the codes a *real* cap breach uses. Those count as a policy
695
+ decision, so an outage landed in the prevented totals on the Impact page, in `anvil audit stats` and
696
+ in `anvil cc`. There is now a `spend_store_unavailable` code, classified as an availability event and
697
+ excluded from every money figure, exactly like `dedup_store_unavailable`.
698
+ - **Approval metadata on a *blocked* receipt was read as a release.** Approval fields are stamped on
699
+ every terminal status, so a call Anvil successfully **stopped** was being narrated as money a human
700
+ let through — outranking every later stop. Only a non-`blocked` status counts as a release now.
701
+ - **`anvil cc` printed a confident `Kill switch Off` over an armed switch.** It read the control config
702
+ through a swallowed rejection, so a Redis outage rendered as an all-clear. It now reads with
703
+ provenance and has three states; `anvil control show` was fixed the same way in 0.5.3.
704
+ - **An MCP client was told the emergency stop was off during an outage** — the same defect, one surface
705
+ over.
706
+ - **A degraded read could render as clean** on the Impact page, the actions sidebar and the workspace
707
+ bridge. A rejection is not an answer: an unreadable store now reports itself rather than borrowing
708
+ the empty state, and an all-clear is a positive claim no outage can earn.
709
+ - **The plane published a mode it could not read**, and a wrapped-call badge worked the mode out for
710
+ itself instead of asking the authority. An operator cap now outranks the file entry and is never
711
+ blamed on the customer.
712
+ - **A symlinked `dist/` meant the server never called `listen()`** — on every branch.
713
+ - **A policy Anvil could not load was invisible to every money surface.**
714
+ - **A human's decision no longer dies with a call a later rule refuses.**
715
+
716
+ ### Added
717
+
718
+ - **A lease on the durable idempotency claim, and a sweep that reclaims stuck ones.** A claim carries a
719
+ 15-minute lease, renewed by the keepalive that already runs. The sweep settles an expired claim as
720
+ `unknown` — it does **not** reopen the key, because an expired lease is not evidence the money didn't
721
+ move. Reopening would trade a stuck key for a double charge.
722
+ - **Migration 029** (`lease_expires_at` on `anvil_idempotency_claims`). Self-hosted deployments should
723
+ run it; hosted customers need nothing. A database **without** it still works — claims are written with
724
+ a NULL lease, which the sweep reads as "no lease information", never as expired.
725
+ - **`anvil audit stats` says when a read was capped.** It stops at the store's ceiling (10,000 records)
726
+ and now prints every figure as `N+` instead of computing "all time" from the newest ten thousand.
727
+
728
+ ## [0.5.3] — The money, control and approval fixes reach the SDK
729
+
730
+ Published 2026-09-08. No API changes: this release exists because the published package had drifted
731
+ 170 commits behind the deployed product, so fixes that were live on Anvil Cloud were unreachable by
732
+ `npm i`. Everything below was already running in production; this is the version that puts it in
733
+ your `node_modules`.
734
+
735
+ ### Fixed
736
+
737
+ - **A refused compensating refund was written to the ledger as executed.** A rollback step that
738
+ Anvil refused still recorded a terminal `executed` receipt, so the ledger claimed a refund had
739
+ gone out that never did.
740
+ - **`anvil cc` billed ghost would-blocks as money Anvil protected.** Ghost observations are
741
+ hypothetical by construction; counting them as prevented damage overstated the figure on the one
742
+ surface operators read during an incident.
743
+ - **`anvil control show` could print a confident `OFF` it was unable to back.** A flushed or
744
+ unreachable control store resolved to a default config whose `kill_switch` is `false`, so an
745
+ operator whose switch was **armed** was told it was off. It now reports
746
+ `Kill switch UNKNOWN — the control store could not be read`. (The `anvil cc` control centre
747
+ still has this defect — see [Running in Production](https://anvilcontrol.ai/docs/running-in-production#6-when-it-breaks-the-runbook).)
748
+ - **A restore under an armed kill switch reported stored intent rather than what was in force.**
749
+ Restoring a previous posture while the switch was on echoed back the modes you had asked for, not
750
+ the ghost every action was actually resolving to.
751
+ - **The money tile and its own drawer disagreed.** Two figures, one number: the drawer now prints
752
+ what the tile sorted by.
753
+ - **An unclassified receipt was counted as a ghost catch.** A receipt Anvil could not attribute is
754
+ not evidence of damage prevented, and no longer inflates the caught count.
755
+ - **The approval backlog alert could not drain.** An already-released hold left the alert armed, so
756
+ the "calls are waiting" banner stayed up after every call had been dealt with.
757
+ - **`anvil_failed_open` did not exist in the published package at all** (7 files on the deployed
758
+ tree, 0 at 0.5.2) — so a call that ran unprotected through a fail-open had no code naming it.
759
+
760
+ ## [0.5.2] — A deduped retry hands back the result it deduplicated
761
+
762
+ ### Fixed
763
+
764
+ - **A deduped retry answered `result: null` while the original result sat one field away.** When a
765
+ call was recognised as a duplicate, Anvil returned a receipt whose `replay` artifact carried the
766
+ original value and a summary saying "Exact original result is available for duplicate replay" —
767
+ next to a `resultReplayable: false` flag insisting it was not. The obvious caller line,
768
+ `(await wrappedRefund(t)).result.refundId`, therefore **threw on the retry**: the exact path Anvil
769
+ exists to make safe. `result` and `resultReplayable` are now derived from the artifact in one
770
+ place, so the contract "result stays null unless resultReplayable is true" is structurally true
771
+ rather than separately maintained. Only an `exact` replay hands back a value; a `projection` is a
772
+ caller-authored subset and a `reference` is a provider id, and returning either as `result` would
773
+ hand back something that is not what `execute()` returned while claiming it is.
774
+ - **First run never played on a fresh machine, and `anvil protect` dead-ended.** A cached workspace
775
+ key counted as "this user has onboarded", but `anvil login` and `anvil open`'s auto-pair both mint
776
+ one *without wrapping anything* — so the documented order (install → open → protect) armed every
777
+ first-run gate before the user reached the command those gates exist for. Pairing is not wrapping:
778
+ the gates now read a marker written only after a wrap actually lands.
779
+ - **An unknown command printed the entire reference.** `anvil home` and any other typo fell through
780
+ to the full usage dump — 114 lines on stderr with no error line anywhere, so the useful part
781
+ scrolled off an 80×24 terminal. You now get a headline, one did-you-mean, and where to get more.
782
+ - **`anvil open` re-offered pairing on every run.** If you never finished pairing, it opened two
783
+ tabs and waited 45 seconds again, forever. It now asks at most once a day, records the attempt
784
+ *before* it waits so a Ctrl-C cannot re-trigger it, and does not burn the cooldown when it could
785
+ not reach the control plane. The first Ctrl-C abandons only the pairing; a second still exits.
786
+ - **A workspace's "guarded calls" counted Anvil's own sign-up traffic.** Pairing wrote two internal
787
+ funnel rows, and the usage totals, per-action breakdown and recent feed had no action filter — so
788
+ a brand-new account was told it had made two guarded calls. Internal actions are now excluded
789
+ everywhere a tenant's own traffic is reported.
790
+
791
+ ### Added
792
+
793
+ - **`anvil key <action>`** — answers "is this action's idempotency key actually right?" from
794
+ recorded traffic: whether a duplicate has ever been caught on it, whether the key is too broad
795
+ (distinct calls collapsing onto one key), and `--field <name>` to narrow it. `--json` for scripts.
796
+ - **Currency travels with the amount** on guard records, resolved the same way by every writer, so
797
+ a record and the plane that judged it can never disagree about which unit a number was in.
798
+
799
+ ## [0.5.1] — A guard holds the process open until it has actually decided
800
+
801
+ ### Fixed
802
+
803
+ - **A guarded call could exit mid-decision and report success.** If your `execute()` resolved off
804
+ work that does not itself hold the event loop — an unref'd timer, and in practice a cron job, a
805
+ migration, a CLI or a serverless invocation winding down — the process could leave *after* your
806
+ side effect landed but *before* Anvil recorded it. The call reported success for a decision it
807
+ never finished making. Measured on the previous build, three runs of three. A guard now holds the
808
+ process open from entry until it settles, so the side effect and the record of it cannot come
809
+ apart.
810
+ - **An unreachable Redis stopped the process from exiting at all.** ioredis schedules reconnects on
811
+ an ordinary timer, and nothing was releasing it, so a script that finished its work sat in the
812
+ reconnect backoff until something killed it. Controlled comparison, same script and build, only
813
+ the Redis URL differing: a reachable Redis exited in 883ms, an unreachable one had to be forced
814
+ out at 9.7 seconds. It now exits on its own.
815
+ - **Ghost mode's receipt, journal and audit writes could be lost on the way out.** They were queued
816
+ on a timer that did not hold the process, and had been surviving only because the Redis socket
817
+ happened to keep every process alive by accident. Once processes started exiting promptly, the
818
+ journal row stopped landing. Ghost's entire output is those writes, so they are now held until
819
+ they complete.
820
+
821
+ ### Added
822
+
823
+ - **GitHub, Twilio and Resend are live connectors.** Auto-instrumentation covers them the way it
824
+ already covered Stripe, verified against the genuinely published packages — `@octokit/rest` 22.0.1
825
+ under real `plugin-retry` and `plugin-throttling`, `twilio` 6.1.0 in both ESM and CJS, and
826
+ `resend` 6.19.0 — with no network and no credentials. An unsupported version is refused with a
827
+ reason and the underlying call keeps working, confirmed against `@octokit/rest` 20.x, which the
828
+ adapter leaves byte-for-byte alone.
829
+
830
+ ---
831
+
832
+ ## [0.5.0] — The machine key is created at pickup
833
+
834
+ ### Changed
835
+
836
+ - **Approving a pairing now records intent; the key is created when a machine collects it.** A key used to exist the instant you clicked Approve — a full redirect before anything could receive it — so any interruption stranded a live credential nobody held. A pairing that is approved and never collected now writes nothing at all: no orphan key, nothing in `anvil keys list`, nothing to clean up. Just run `anvil login` again.
837
+ - Tokens minted by the previous build are still honoured, so pairings in flight across the deploy completed normally.
838
+
839
+ ### Added
840
+
841
+ - **`npm run reap:orphaned-keys`** retires credentials created before this change. Read-only by default; never empties a workspace; refuses a cutoff in the future.
842
+ - Pairing counters (`minted` / `claimed` / `claimFailedAfterBurn`) on `/v1/deploy-report` and in `anvil doctor --deploy`, backed by Redis so they stay meaningful behind a load balancer.
843
+
844
+ ### Fixed
845
+
846
+ - **`/v1/install/claim` had been sharing the anonymous signup rate limit** — ten attempts an hour for an entire office behind one NAT. It now has its own ceiling (`ANVIL_INSTALL_CLAIM_MAX_PER_HOUR`, default 60/hr) and the `429` says how long to wait.
847
+ - Pairing health is a 15-minute window rather than a lifetime counter, so a single transient blip no longer marks a deploy unhealthy until it is redeployed.
848
+
849
+ ---
850
+
851
+ ## [0.4.2] — Approve completes the pairing
852
+
853
+ ### Fixed
854
+
855
+ - **The Approve button did nothing in real browsers.** A Content-Security-Policy `form-action` directive covered the form's POST but not the redirect that answers it, so the browser silently dropped the last hop home: no error, no message, a tab that sat there and a terminal that waited forever. Every server-side test passed throughout, because `fetch()` does not enforce CSP.
856
+ - The 120-second consent window now visibly drains, so you can see how long you have.
857
+
858
+ ---
859
+
860
+ ## [0.4.1] — The pairing Approve button actually works
861
+
862
+ ### Fixed
863
+
864
+ - **Approve returned `403 origin_not_allowed` for every real user.** The consent page shipped `Referrer-Policy: no-referrer`, and a form POST from a no-referrer page sends its Origin as the literal string `"null"` — which no allowlist matches. Pairing was completely broken in the browser while every server-side probe stayed green.
865
+ - Approve and Cancel are now centred peers rather than a button and a stray link, and "Wrong account?" is out of the fine print.
866
+
867
+ ---
868
+
869
+ ## [0.4.0] — `anvil login` joins a machine to your account
870
+
871
+ ### Added
872
+
873
+ - **`anvil login`** — pair a machine with your Anvil account in one browser round trip. Both sides show a code you compare before approving, and the machine gets **its own key**, labelled `cli:<hostname>`, that you can revoke on its own. It never rotates your other keys and never disconnects an editor. `--paste` and `--token` cover SSH, containers, and CI; `ANVIL_API_KEY` still outranks any pairing.
874
+ - **`anvil logout`** — unpair a machine, with the option to revoke its key server-side (`--revoke`) or clear every cached account (`--all`).
875
+ - **Sign-in creates your workspace.** Signing in at the dashboard now provisions the workspace itself, so `no_workspace` is unreachable for a signed-in user.
876
+ - `anvil doctor` reports account posture: whether this machine is paired, as whom, and whether its key is still live.
877
+
878
+ ### Changed
879
+
880
+ - The paired identity is first-class across the CLI. Credential resolution is **environment > paired identity > nothing**, so CI keeps working exactly as before.
881
+
882
+ ### Fixed
883
+
884
+ - `anvil keys` told a freshly paired user there was no workspace to manage keys for, and returned a raw stack trace under `--json` where it promised an envelope.
885
+ - `anvil open`'s auto-pair no longer borrows a failure exit code, no longer claims "needs a browser" when only stdin is piped, and gives up after 45 seconds instead of holding your terminal for five minutes.
886
+ - `anvil protect` recovers from "this email already has a workspace" by offering to pair the machine, instead of describing the dead end.
887
+ - The docs site is built for the `/docs` path it is actually served at, so its links and stylesheet resolve.
888
+
889
+ ---
890
+
891
+ ## [0.3.8] — First-run fixes reach the CLI
892
+
893
+ Both of these had been fixed on main for a day, and neither was in anyone's hands: `npx @useanvil/sdk` serves the published version. Both were reported by a first-time user.
894
+
895
+ ### Fixed
896
+
897
+ - **A brand-new workspace showed an action nobody had protected.** The dashboard link the CLI opens fabricated `payment.charge` into itself, so a fresh account arrived at a row that said "Waiting for your first protected call" — for a call that did not exist.
898
+ - **`anvil open` no longer boots a local control plane.** It used to start one and send you there, which meant a hosted user landed on a freshly-started empty server they could not sign in to. A local plane is opened only when one is already serving.
899
+
900
+ ---
901
+
902
+ ## [0.3.7] — Removal for everyone, the editor connects, and Anvil can see your code
903
+
904
+ ### Added
905
+
906
+ - **`anvil remove <action>`** — take an action off your dashboard and the wrapper back out of your code, without an editor. It asks the control plane first, so a refusal or an unreachable plane leaves your code completely untouched.
907
+ - **Connect editor** — one click from the dashboard connects VS Code or Cursor. You never see a credential and you never paste one.
908
+ - **The code map** — the CLI publishes where your protected calls live (paths and line numbers, never your source) so the dashboard can point at them. `anvil sync` refreshes it, `anvil sync --forget` deletes it, `ANVIL_NO_CODE_MAP=1` prevents it.
909
+ - **Suggestions in "+ Protect new"** — the card now proposes risky *unprotected* calls it found, phrased as guesses and capped at three, so someone who doesn't know what to type has somewhere to start.
910
+ - Bare `anvil` is a hub that prints and exits; `anvil open` is the one way to the dashboard.
911
+
912
+ ### Changed
913
+
914
+ - **Removal finishes on the click.** It leaves a tombstone rather than deleting the entry — deleting it would let a still-wrapped call fall back to the workspace default and start blocking live traffic.
915
+ - **The always-on floor is real, and ghost evaluates it.** The retry-storm guard used to live inside policy evaluation, so a tenant with no policy never reached it and ghost was excluded entirely. Enforce with no policy no longer holds every call; it applies the floor and marks the call `floorOnly`.
916
+ - **Ghost sees what enforce would stop.** Spend caps used to return "allowed" in ghost before examining any cap, so you could watch a clean week under a limit you were already blowing. Ghost now evaluates caps against its own window and reserves nothing.
917
+
918
+ ### Fixed
919
+
920
+ - The ghost report's headline counted every action while naming one — "33 confirmed duplicate `refunds.create` executions" for a log holding 11 of them — and folded read-only lookups into a figure presented as money at risk.
921
+ - Two matcher bugs made coverage look better than it was: a call like `stripe.charges.create` matched nothing, and a wrap's lowercased action name hid leftover camelCase calls in the same file.
922
+ - A verdict is history: the decision log stopped relabelling past verdicts from the action's current mode.
923
+
924
+ ---
925
+
926
+ ## [0.3.6] — One paste-safe placeholder, and a scan that says why it found nothing
927
+
928
+ ### Fixed
929
+
930
+ - **The command Anvil printed could not be pasted.** `<your.action>` uses shell redirection characters, so `npx @useanvil/sdk protect <your.action>` is a parse error in both zsh and bash. Every surface now shares one placeholder.
931
+ - **Arrow keys corrupted the action name.** An up-arrow left a stray `a` in the buffer, so the next thing you typed produced a different action than the one you meant — silently wrapped.
932
+ - **Twilio was invisible to the call scanner**, because comms detection required the literal word `send` and Twilio's send API is `messages.create`.
933
+
934
+ ### Added
935
+
936
+ - `anvil protect` now says *why* a scan found nothing, rather than reporting an empty result.
937
+
938
+ ---
939
+
940
+ ## [0.3.5] — The CommonJS hosted crash
941
+
942
+ ### Fixed
943
+
944
+ - **Every CommonJS consumer's first hosted `guard()` call threw.** Resolving the SDK's own version used a construct a CommonJS bundle cannot express, so it threw while building request headers — on the exact call a new user makes first, in ghost, the mode that is contractually incapable of blocking anything. Six shipped bundles carried it.
945
+ - A migration runner reported "All migrations applied successfully" on a run that applied 8 of 22 files. The schema was never wrong; the message was.
946
+
947
+ ---
948
+
949
+ ## [0.3.4] — V1: the money path, tenancy, approver identity and the ledger
950
+
951
+ Four workstreams shipped in this release; each keeps its own section below.
952
+
953
+ ### Hosted enforcement parity: one brain, many bodies
954
+
955
+ ### Fixed — an approval authorized a key, not an act (spec §6 Step 6)
956
+
957
+ - **An approved $50 refund released a $50,000 one.** `lookupApproved` matched on
958
+ `computeApprovalId(action, key)` alone and released whatever turned up next under that key,
959
+ so an agent whose refund was approved could retry the same key for any amount, or repoint it
960
+ at a different recipient, and the gate opened. The approval record already stored the amount
961
+ and the counterparty; nothing ever read them. It now compares the **presented act** against
962
+ the approved one and refuses on any mismatch — and refusing does **not** consume the
963
+ approval, or an attacker replaying an approved key at a new amount would gain a
964
+ denial-of-service on the legitimate call by burning the operator's real decision.
965
+ - **One human decision authorized unlimited executions.** The approved record sat in Redis for
966
+ its whole TTL (up to 24h) releasing every call that reused the key. Approvals are now
967
+ single-use, redeemed by compare-and-delete so two racing retries cannot both be released.
968
+ - **The act is recorded for every hold**, not only the axes that fired: a trigger-word hold on
969
+ a $10 refund stores the amount too, because the escalation this resists does not care which
970
+ axis held the call. Records written before this ships still release — they are compared on
971
+ whatever they can prove — so approvals already in flight are not invalidated mid-window.
972
+ - **A dashboard dry-run was writing real holds.** `/api/test-policy` and `/api/replay` pass
973
+ `simulate: true`, which `evalConfirmationGate` ignored: previewing a policy put a genuine
974
+ pending record in the operator's queue and fired `ANVIL_APPROVAL_WEBHOOK_URL`, paging a human
975
+ about a payment that never happened. Previews now validate exactly as a real call does and
976
+ neither write a hold nor spend an approval.
977
+
978
+ ### Fixed — a human's rejection did not survive the next retry (spec §6 Step 6)
979
+
980
+ - **Reject, and the agent's next retry undid it.** Nothing read the rejected key, so
981
+ `evalConfirmationGate` found no *approved* record and called `recordPending`, writing a fresh
982
+ pending under the same deterministic id. The record flipped `rejected` → `pending` and
983
+ reappeared in the operator's queue as though nobody had decided. A refusal survived exactly
984
+ until the next retry — seconds, for an agent. The mirror of the approval defect above: one was
985
+ too durable, the other not durable at all.
986
+ - **It got worse with `pending`, not better.** The new verdict was telling the caller *"a person
987
+ is looking at this — retry in 5s"* about a decision already made, so the agent polled forever
988
+ and every poll re-queued the item. A refused call now answers **`blocked`**, and the reason
989
+ names who refused it, when, and that retrying will not release it.
990
+ - **The refusal cannot be overridden by the party it refused.** The check runs *before* the
991
+ `approval_field` metadata bypass, which is a field the calling agent controls.
992
+ - **Act-scoped, like approvals.** A materially different request — another amount, another
993
+ recipient — is held afresh for a new human decision rather than inheriting someone else's
994
+ refusal. Never auto-allowed: nudging the amount buys another hold, not an escape. Bounded by
995
+ the rejected record's TTL, so an idempotency key is never permanently stranded.
996
+
997
+ ### Added — hosted holds now reach a human, per tenant (spec §6 Step 6)
998
+
999
+ - **A held payment notified nobody on the hosted plane.** The notification was already built and
1000
+ correct; its URL came from `ANVIL_APPROVAL_WEBHOOK_URL`, a **process-wide** variable read
1001
+ inside whichever process runs `recordPending`. Locally that is the customer's own process. On
1002
+ hosted it is Anvil's, so a tenant could not configure hold alerts at all — money froze and the
1003
+ only signal was someone happening to open the dashboard.
1004
+ - **The obvious fix would have been a cross-tenant leak.** Setting that variable on a
1005
+ multi-tenant server would POST every tenant's holds — action names, amounts, subject and
1006
+ initiator labels — to a single endpoint. The api-server now installs a **per-workspace
1007
+ resolver**, and once installed the env var is never consulted again; a resolver that fails
1008
+ sends nothing rather than falling back.
1009
+ - **`workspaces.approval_webhook_url` / `_secret`** (migration 014) mirror `retry_dispatch_url`
1010
+ and reuse the same `validatePublicWebhookUrl` — private hosts, non-http(s) schemes, embedded
1011
+ credentials, malformed URLs — re-validated on read as well as write. Signed HMAC-SHA256 under
1012
+ its own domain prefix (`anvil.approval.v1:`) so the secret cannot cross-replay from the retry
1013
+ webhook, and the dispatch refuses redirects. Deliberately a separate sink: `retry_dispatch_url`
1014
+ is a COMMAND endpoint, this is an ALERT endpoint.
1015
+ - `GET`/`POST`/`DELETE /api/settings/approval-webhook`, matching the retry-webhook contract so
1016
+ operators learn one pattern. The secret is returned once and never re-exposed on read.
1017
+
1018
+ ### Fixed — `gate:local` could never be green
1019
+
1020
+ - **One suite had failed in every gate run ever recorded** (seven logs, back to before this
1021
+ workstream), for a structural reason rather than a flaky one. `gate:local` runs in a throwaway
1022
+ git worktree and **symlinks** `dist/` instead of rebuilding it;
1023
+ `tests/ghost-come-back-loop.test.ts` simulates an npm install by `cpSync`-ing dist to a temp
1024
+ dir and spawning `dist/server.js` from there. `cpSync` preserves symlinks, so `argv[1]` sat
1025
+ under `/tmp` while `import.meta.url` resolved back to the original — the server's
1026
+ `isDirectEntry` check decided it was not the entry point and exited **without listening and
1027
+ without stderr**. A 40-second boot timeout with no error attached, which is why it survived so
1028
+ long. Fixed with `dereference: true`, proved by A/B in the gate's exact shape.
1029
+ - This matters beyond one file: CI is billing-blocked, `gate:local` is the only gate, and a gate
1030
+ that can never be green is a gate people stop reading.
1031
+
1032
+ ### Added — the receipt now says WHO authorized the payment (spec §6 Step 6)
1033
+
1034
+ - **A hold is the one decision where a person takes responsibility for money moving**, and after
1035
+ they approved, the executed call's audit record was byte-identical to any other allow. The
1036
+ approver, the approval id and whether their identity was *verified* lived only in the policy
1037
+ change log, keyed by nothing the receipt carried — so "show me who approved this payment"
1038
+ needed two logs and a timestamp correlation. `AnvilResponse.humanApproval` and
1039
+ `AuditRecord.humanApproval` now carry it, on **both** transports, through the same path Step 7
1040
+ built for `runtimeEvaluatedPrimitives` rather than a second mechanism.
1041
+ - **`actorVerified` is never inferred upward at any hop.** It is `true` only for a literal
1042
+ `true` — from a trusted proxy at approval time, over the wire, into the record, onto the
1043
+ screen. A compliance trail that lets a typed name read as a validated identity is worse than
1044
+ one that admits the difference.
1045
+ - **Rendered.** The Impact drill-down and the Actions decision log both show an "Approved by"
1046
+ row — hidden entirely when nobody had to approve, which is nearly every call; an empty row
1047
+ would imply a human signed off on all of them.
1048
+ - **The hosted receipt is sanitized as network input.** A malformed one drops *whole*: a partial
1049
+ receipt naming an approval with no approver still reads as evidence.
1050
+
1051
+ ### Added — end-to-end proof of the whole approval chain
1052
+
1053
+ - `tests/integration/hosted-approvals-e2e.test.ts` drives hold → `pending` → approve → release
1054
+ against the **real** spawned api-server on real Postgres and Redis. It asserts directly the
1055
+ identity the two planes had silently disagreed about — that `api_keys.workspace_id` and
1056
+ `resolveWorkspaceIdForEmail(email)` resolve to the same tenant — and that a held call does
1057
+ **not** claim the idempotency key. That last one is the quiet killer: a hold that claimed the
1058
+ key would return `duplicate` forever, so no approval could release anything, and the feature
1059
+ would be dead on arrival with every unit test still green.
1060
+
1061
+ ### Added — `pending`: the wire can say "a person is looking at this"
1062
+
1063
+ - **A fourth `/v1/guard` verdict** carrying the approval id, the reason axes and a poll
1064
+ interval. A hold and a block are different events: a block is final, a hold is the same
1065
+ request succeeding once someone acts. Collapsing them left an agent unable to tell "never
1066
+ going to work" from "try again in a moment".
1067
+ - **Sent only to clients that declare `accepts_pending`.** An older SDK receiving an
1068
+ unrecognised status falls through to `failMode` — and open **executes**, running the very
1069
+ call a human is being asked to authorize. The handshake means the server can deploy ahead of
1070
+ its clients. The caller-facing object deliberately does not fork: a hosted hold lands as
1071
+ `status: 'blocked'` + `blockedBy: 'confirmation_required'` + `policyDetails`, exactly as the
1072
+ local engine already returns it, so Step 3's parity survives Step 6.
1073
+
1074
+ ### Fixed — the approval queue was invisible to the operator who had to act on it
1075
+
1076
+ - **The two planes name the same tenant differently.** The hosted guard API writes holds under
1077
+ `workspaces.id` (a UUID); the dashboard read under `deriveWorkspaceId(email)`
1078
+ (`ws_<base32>`). Those key spaces never intersect, so a hosted tenant's held payment was
1079
+ written where their own dashboard could not see it and the queue rendered **empty** — which
1080
+ reads exactly like "nothing to approve". Both routes now bridge through the same
1081
+ `resolveWorkspaceIdForEmail` the usage and audit surfaces use.
1082
+ - **"Trust this recipient" had the same bug one layer down.** The counterparty seen-set is
1083
+ namespaced identically, so approving-with-trust wrote where the runtime never looks and the
1084
+ next call was held again. The standalone `/api/counterparty` routes had it too.
1085
+ - **An unbridgeable workspace is now said out loud.** The list endpoint reports
1086
+ `store_healthy: false` (the existing "this list is not a fact" contract, already rendered as
1087
+ a warning by both surfaces) rather than an empty all-clear; approve/reject and the trust
1088
+ mutations return **503 and change nothing**, because a silent no-op on a money release is
1089
+ worse than an error — the person walks away believing they acted.
1090
+
1091
+ ### Fixed — the hosted transport enforced two of fifteen rules and said "Enforcing"
1092
+
1093
+ - **`stripUnsupportedForHosted` is gone.** When `ANVIL_API_KEY` is set — which
1094
+ `anvil protect` writes into every onboarding customer's `.env` — `guard()` went over the
1095
+ wire to the api-server, which called the real `evaluatePolicy()` but first ran a
1096
+ fourteen-line filter that deleted `spend_caps`, `workflow_limits` and custom rules, then
1097
+ reduced `rules[]` to an **allowlist of two**: `amount_cap` and `metadata_required`. It
1098
+ also omitted `key` and `workflow` from the evaluation context, leaving the retry-storm
1099
+ floor and every cumulative rule dormant. Thirteen of fifteen authored rules were inert on
1100
+ the documented path, while the dashboard kept saying "Enforcing" — because that badge came
1101
+ from a process-wide environment flag rather than from what the runtime evaluated. The
1102
+ filter is replaced by `stripExcludedForHosted`, a **denylist of one**: customer code, which
1103
+ by design never executes inside Anvil's process (it runs in the caller's own, as an SDK
1104
+ pre-flight). `HOSTED_ENFORCED_PRIMITIVES` is now *derived* from the primitive registry
1105
+ minus that denylist, so a new primitive is enforced on both transports the day it ships and
1106
+ an exclusion is a deliberate, reviewable act rather than something to remember.
1107
+ - **`webhook` was the sharpest leg, and it fails in the worst direction.** The wire never
1108
+ carried webhook data, and `webhook_signature` is DORMANT without it *by contract* — a
1109
+ dormant rule allows. So a hosted `webhook.deliver` call with a missing or forged signature
1110
+ **executed**, while the identical local call blocked; in ghost, the tenant got a report
1111
+ saying the call was fine and flipped to enforce on the strength of it.
1112
+ - **Two live wire-fidelity bugs, both found by running the transport arm for the first
1113
+ time.** `api-client.ts` read only `opts.service` and never the configured `ANVIL_SERVICE`,
1114
+ so `service_blocklist` blocked locally and ALLOWED hosted on the same call — and the
1115
+ custom-rule pre-flight, which does read it, judged a different service than the hosted
1116
+ plane. Separately, `reason`/`blockedBy` were gated to `status === 'blocked'`, so a hosted
1117
+ duplicate returned `blockedBy: null` where the local engine reports `dedup_replay`; hosted
1118
+ tenants' caught duplicates were invisible to the dashboard's dedup filter and its per-rule
1119
+ fire counter — the exact bug the local path had already been fixed for.
1120
+ - **Spend reservations are released, not orphaned.** `evaluatePolicy()` returns only
1121
+ `measured.result` and discards the reservation handle, so enabling cumulative caps through
1122
+ it would have taken budget with no way to give it back — blocking a tenant from spending
1123
+ money they never spent, on the first hosted call against any policy with a cap. The hosted
1124
+ evaluator now uses `evaluatePolicyWithLatency` and releases what it reserved, because this
1125
+ transport has no completion handshake yet. The cap degrades to a per-call ceiling rather
1126
+ than leaking; accumulation remains the open Step 5 work, and its harness stays red for it.
1127
+
1128
+ ### Fixed — every degradation on the hosted money path resolved toward *allow*
1129
+
1130
+ - **A hosted call that could not be evaluated now HOLDS instead of executing.** An evaluator
1131
+ exception was caught, logged as *"degrading to idempotency-only"*, and the call ran
1132
+ unprotected — on an action whose dashboard said **Enforcing**. Enabling the stateful
1133
+ primitives made that far more reachable than it had been, because the evaluator now reaches
1134
+ Redis for rate windows and spend counters, so a store blip throws on the money path.
1135
+ `evaluateHostedDecision` no longer throws at all: every failure is classified
1136
+ (`snapshot_missing`, `snapshot_unreadable`, `policy_invalid`, `policy_eval_failed`) and
1137
+ returned as a decision the caller holds on, audits, and counts. **The polarity is per mode** —
1138
+ enforce holds, ghost carries on, because ghost that changes behaviour is itself a defect.
1139
+ - **An enforce action with no activated policy held instead of waving the call through.** This
1140
+ state is reachable through the product: a dashboard mode-flip writes `control_config` while
1141
+ the snapshot upsert COALESCEs a null policy, so flipping to Enforce before activating a
1142
+ policy left nothing to enforce — and every call executed under a green badge. The refusal now
1143
+ names the gap.
1144
+ - **The default hosted customer failed OPEN on every Anvil blip, and `ANVIL_FAIL_MODE=closed`
1145
+ could not reach them.** The SDK read `ANVIL_MODE !== 'enforce'` as ghost intent, folding
1146
+ *"I declared ghost"* together with *"I declared nothing"* — and `anvil protect` writes
1147
+ `ANVIL_API_KEY`, never `ANVIL_MODE`, because hosted mode lives in the dashboard. So the
1148
+ undeclared bucket is where the documented onboarding path puts everyone. Undeclared now
1149
+ behaves as enforce, matching what the local engine already does with the same absent
1150
+ variable. An explicitly-ghost client is unchanged: ghost never blocks.
1151
+ - **The same collapse double-executed retried charges.** An undeclared client sent
1152
+ `mode: 'ghost'` on the wire, so a server with no snapshot to resolve stamped its duplicate
1153
+ verdict `ghost` — and the SDK observed-and-**executed** a key the server held a receipt for.
1154
+ The local engine refused the identical duplicate. Only a client that has said the word
1155
+ "ghost" now gets behaviour that can run a side effect twice.
1156
+ - **A degradation hold left no trace.** A policy block wrote a full audit record; a
1157
+ dependency-degradation hold wrote nothing, so the customer saw a failure and the operator saw
1158
+ an empty log. `recordDegradationHold()` now fires at every hold on **both** transports with
1159
+ one shared `blockedBy: 'anvil_unavailable'` code and the degraded dependency in `reason`.
1160
+
1161
+ ### Changed — the Enforcing badge is a report from the runtime, not an env var
1162
+
1163
+ - **`ANVIL_ENFORCEMENT_BACKING` no longer decides what the dashboard claims.** It is a
1164
+ configuration value describing intent; the badge is supposed to be a fact about what the
1165
+ runtime just did. A primitive could silently stop enforcing and no surface would know, because
1166
+ no surface was asking. `evaluateHostedDecision` now returns the primitives it **actually**
1167
+ evaluated, threaded into the `/v1/guard` response and both audit receipts, and
1168
+ `resolveRuntimeTruth` narrows the badge to the signed-in workspace's own set.
1169
+ - **"Actually" excludes three things**, each a way the badge could have kept lying with better
1170
+ provenance: a rule that does not apply to this action, a rule after a block (the loop
1171
+ short-circuits — it genuinely did not run), and a **dormant** rule — a `tool_call_cap` with no
1172
+ workflow, a `webhook_signature` with no request body — which ran, could not decide, and allowed
1173
+ for a reason unrelated to safety.
1174
+ - **Not knowing falls back to the capability set.** A signed-out visitor, a failed snapshot read
1175
+ or an unconfigured database is not evidence about a customer's policy, and downgrading a real
1176
+ tenant's badge on Anvil's own ignorance would be a new lie pointing the other way. An empty set
1177
+ is honoured only when a policy was genuinely read.
1178
+ - **`anvil doctor --deploy` gains `enforced-primitives-consistent`.** The control-plane advertises
1179
+ a set of primitives to customers; the api-server now reports the set it can back, and a
1180
+ mismatch is a hard FAIL naming the primitives. Previously `enforcement-truth-consistent` could
1181
+ only compare a boolean, so a control-plane advertising a rule an older api-server had never
1182
+ heard of reconciled clean while that rule was inert.
1183
+
1184
+ ### Added — `AnvilResponse.runtimeEvaluatedPrimitives`: what actually checked your call
1185
+
1186
+ - The runtime measured honestly and **the SDK threw it away**. `api-client.ts` only ever *wrote*
1187
+ `evaluated_primitives` (reporting its own local decision up via `/v1/decision`) and never read
1188
+ the field off a `/v1/guard` response — so a developer could not ask the one question they have
1189
+ after a surprising call, on the transport `anvil protect` puts every customer on.
1190
+ - **One field, both transports, one meaning.** Locally the runtime is the engine in your process;
1191
+ hosted it is the plane. Disjoint from `locallyEvaluatedPrimitives`, which names the layer the
1192
+ hosted plane structurally refuses to run — two actors, two fields, because `whereEnforced()`
1193
+ depends on telling them apart.
1194
+ - **The hosted value is sanitized on the way in** — strings only, snake_case, bounded on count and
1195
+ length, deduped, absent rather than `[]` when unusable. It is network input landing on a field
1196
+ customers log and assert on; a stale proxy or hostile host must not be able to put free text in
1197
+ something read as a fact about their own protection.
1198
+ - Present on allow, block and duplicate — the server evaluates *before* it claims, so a retried
1199
+ call really was checked. Absent on the fail-open path, where the plane never answered.
1200
+
1201
+ ### Added — "Checked by" on the decision log: what actually ran on each call
1202
+
1203
+ - A row could say *blocked by `amount_cap`* and not answer the next question — **what else was
1204
+ checked?** A held call was worse in reverse: it named the degraded dependency and never said
1205
+ what had run before the hold. Both surfaces now render the runtime's per-call report from the
1206
+ audit record they already write.
1207
+ - **The chips carry the mode colour**, which design.md §2.3 calls never-decorative: grey means
1208
+ the rule *observed* this call, blue means it could have *stopped* it.
1209
+ - **The row hides when a record carries no report** rather than rendering empty. An older record
1210
+ means we do not know what ran — not that nothing ran — and "Checked by —" would read as
1211
+ "checked by nothing", which is the same species of lie this whole workstream removes.
1212
+
1213
+ ### Fixed — the hosted spend cap did not exist; now it accumulates
1214
+
1215
+ - **A $100/day cap admitted three committed $60 charges.** Measured against a real api-server:
1216
+ the hosted plane never reserved, never committed and never accumulated, and wrote **zero**
1217
+ spend keys to Redis — while the dashboard showed the cap configured and the local transport
1218
+ enforced it on the identical policy. Note the polarity: this is not the orphaned-reservation
1219
+ leak that gets worried about, which at least fails *safe* by over-blocking. It failed **open**.
1220
+ - **The lifecycle is wired end to end.** The evaluator hands its reservations to the caller, the
1221
+ api-server carries them on the **lock token** — already scoped to the completion window and
1222
+ already `getdel`-consumed exactly once, so a double-commit is structurally impossible — and
1223
+ `/v1/complete` commits on `executed`, refunds on `failed`. Every other exit (duplicate, error,
1224
+ refusal) releases. The rule is "will the customer's code run?", which is deliberately **not**
1225
+ "was it blocked": a ghost would-block still executes, and releasing there would hide a ghost
1226
+ tenant's spend from the very cap they are measuring before trusting it.
1227
+ - **The reservation TTL now outlives the completion window** (660s vs the lock token's 600s).
1228
+ Equal TTLs let a reservation be reaped while a legitimate completion was in flight — the commit
1229
+ would find nothing and a real spend would vanish from the counter, leaving the cap
1230
+ under-counting in the customer's favour. A cap may over-block; it must never under-count.
1231
+ - **The reaper runs on the api-server.** `sweepExpiredReservations` already existed but lived
1232
+ only in the SDK's reconciliation worker, which the api box does not run — so an orphaned
1233
+ reservation was held until its TTL and never counted. It now sweeps every 60s and ships
1234
+ `anvil_spend_reaper_total` from day one: a rising recovery rate means completions are being
1235
+ lost, which is a problem well before any cap is wrong.
1236
+
1237
+ ### Added — `check:stranded-enforce`, so "who does this deploy break?" is answerable first
1238
+
1239
+ - The hold above is a **live** change for any tenant already enforcing an action they have no
1240
+ policy for. `npm run check:stranded-enforce` lists them from the api's Postgres and exits 1 if
1241
+ there are any — and **2, never 0, when it cannot read**, because a preflight that reports a
1242
+ clean bill of health it did not verify is the same fail-open polarity Step 4 removes.
1243
+ Kill-switched tenants are reported separately: not held today, held the moment the switch
1244
+ lifts. `--allow-stranded=N` exists for an operator who has already contacted them.
1245
+ - The count is also **standing**, because any future mode-flip re-creates the state: the api's
1246
+ `/v1/deploy-report` carries `strandedEnforce` (a count, never workspace ids — that endpoint is
1247
+ unauthenticated) and `anvil doctor --deploy` warns on it without failing the verdict. The
1248
+ runtime is correct there; the customer's configuration is what needs a human.
1249
+
1250
+ ### Changed — `ANVIL_HOSTED_POLICY_EVAL` is retired; `ANVIL_HOSTED_FAIL_MODE` replaces it
1251
+
1252
+ - **Hosted policy evaluation is unconditional.** The flag silently disabled *all* policy
1253
+ evaluation on one box, invisible from the customer's seat where the dashboard went on saying
1254
+ "Enforcing" — an outage waiting for a misconfiguration. It is no longer read; a leftover
1255
+ value is called out at boot and by `anvil doctor --deploy` rather than left looking
1256
+ load-bearing. This closes the doctor's hard-FAIL over-claim branch **by construction**.
1257
+ - **`ANVIL_HOSTED_FAIL_MODE`** (`closed` default / `graceful` / `open`) governs only what
1258
+ happens once evaluation has already failed. It reuses the SDK's `resolveRedisFailMode`, so
1259
+ the two sides of the wire cannot drift, and every path through it writes an audit record and
1260
+ increments `fail_open_total` — choosing `open` cannot be quiet.
1261
+ - **`AnvilStatus` gains `'unavailable'`** — held, not blocked, not unknown. It reports as
1262
+ `unknown` in the Impact/CLI/usage projections and deliberately **not** as `blocked`: a block
1263
+ is the product working and is counted as customer value, so folding Anvil's own outages into
1264
+ that number would let a bad Postgres afternoon look like a productive one. The precise rate
1265
+ lives in `anvil_guard_verdicts_total{verdict="unavailable"}`, its own series.
1266
+
1267
+ ### Added — the parity harness now gates, and the gate now runs the money-path lane
1268
+
1269
+ - **`tests/parity/differential.test.ts` (78 tests) moved into the blocking lane**, and
1270
+ `tests/parity/baseline.ts` — the checked-in list of excused divergences — is now an **empty
1271
+ array**. The suite passes under `ANVIL_PARITY_STRICT=1`, which ignores that file entirely.
1272
+ - **`tests/parity/transport-differential.test.ts` runs for the first time.** It reported 38
1273
+ of 38 SKIPPED for want of a real stack while simultaneously being declared red-on-purpose —
1274
+ both readings wrong in the same direction. It now runs **37 passing tests** against a real
1275
+ api-server on live Postgres + Redis, and is registered in `REQUIRED_PROOFS`, so the lane
1276
+ fails rather than shrinks if it ever self-skips again.
1277
+ - Proven by injection rather than assumed: restoring the allowlist reds 29 evaluator tests,
1278
+ dropping `key` from the eval context reds 8, and deleting `workflow` from the `/v1/guard`
1279
+ body reds 3 transport cases *naming that field*. All three restore to green.
1280
+ - **`npm run gate:local` now runs the live-Postgres lane.** With GitHub Actions
1281
+ billing-blocked, `gate:local` is the only gate — and it ran only the redis-only lane, while
1282
+ **five of the six `REQUIRED_PROOFS`** are scheduled solely by `test:postgres`: the
1283
+ crown-jewel no-double-charge dedup, the two-tenant isolation E2E, the workspace-stamped
1284
+ audit plane, the StatusStore conformance suite, and the new transport arm. Those had gated
1285
+ nothing since Actions went quiet. The gate now probes for a reachable database by
1286
+ *connecting* (not by checking whether a variable is set), arms the same
1287
+ `ANVIL_REQUIRE_POSTGRES_TESTS=1` tripwire CI used, and reports **PARTIAL** — never GREEN —
1288
+ when it cannot run, naming each proof that did not execute.
1289
+
1290
+ ### Security
1291
+
1292
+ - **`/v1/guard` validates the new structured context and refuses rather than narrows.**
1293
+ Carrying `workflow` and `webhook` means accepting untrusted structured input on the money
1294
+ path; `src/hosted-guard-context.ts` answers **400** on a malformed field instead of dropping
1295
+ it, because silently continuing without it is the same defect class one layer down. Absent
1296
+ stays free. It is a separate leaf module so it is unit-testable — `src/api-server.ts` calls
1297
+ `start()` at module scope and cannot be imported by a test.
1298
+ - **`currentAttempt` is deliberately not read off the wire.** A client-supplied attempt count
1299
+ is a client-supplied way to defeat its own `max_retries` cap. Absent, the rule falls back to
1300
+ `workflow.retryCount`, exactly as the local engine does under the same absence.
1301
+
1302
+ ## [0.3.4] (continued) — Ghost perimeter closed; tenancy boundary fails closed; custom-code naming pinned
1303
+
1304
+ ### Security — the ghost server's perimeter is closed
1305
+
1306
+ - **`src/server.ts` had no authentication concept at all, and it is the service on
1307
+ `go.anvilcontrol.ai`.** `grep -c ANVIL_CONTROL_TOKEN src/server.ts` returned 0 across
1308
+ 5,455 lines; the request handler's entire prologue was CORS, security headers, a
1309
+ cache-control header and an OPTIONS 204. Confirmed live while writing this entry, with
1310
+ status codes only: `GET /anvil/actions/dashboard` returned **27,080 bytes** of real
1311
+ feed — durable keys, cent amounts, verdicts, current enforcement mode — and `GET /app`
1312
+ returned **2,014,172 bytes** of the full product dashboard, both to an anonymous
1313
+ `curl`. In the same ungated router sat `POST /anvil/actions/mode` and
1314
+ `POST /anvil/ghost/enforce` (which flip enforcement, the second one bypassing the
1315
+ five-character downgrade-reason gate its sibling enforces) and `POST /anvil/ghost/wrap`,
1316
+ a filesystem walk that **rewrites source files** on the container. CORS never helped:
1317
+ it governs what a browser may *read* cross-origin, not whether the request runs.
1318
+ There is now **one prefix gate** at the top of `handleRequest`, above every route, so a
1319
+ route added under `/anvil/` tomorrow is closed the moment it exists — auth at the
1320
+ router prefix, not a per-handler list someone forgets to append to, which is exactly
1321
+ how this happened (the identical `/anvil/*` surface on the control plane has been gated
1322
+ since it was written; only the ghost twin was forgotten, and only the gated copy had
1323
+ tests). The ladder is byte-for-byte the control plane's, so an operator holds one
1324
+ secret: a configured `ANVIL_CONTROL_TOKEN` / `POLICY_IMPORT_TOKEN` is enforced in every
1325
+ environment; production with no token **fails closed** (401), overridable only by the
1326
+ explicit `ANVIL_ALLOW_INSECURE_PROD=true` assertion that a proxy authenticates; and
1327
+ non-production with no token stays **open**, so the local `npx` walkthrough is
1328
+ untouched. `?token=` authorizes reads only and is banked into an
1329
+ `HttpOnly; Secure; SameSite=Strict` session on a page navigation — a URL-parameter
1330
+ token must never flip enforcement, because that is reachable from any link on the
1331
+ internet.
1332
+ - **`/app` now forwards to the sign-in-gated control plane** instead of serving the ghost
1333
+ server's own ungated copy of the dashboard, joining `/tour`, `/intro` and `/start` in
1334
+ `ONBOARDING_FUNNEL_PATHS`. In single-service dev the target resolves to this server's
1335
+ own origin, so `/app` is still served locally and nothing local changed.
1336
+ - **Cookies are Secure by default.** `buildCookieAttributes()` defaulted `secure` to
1337
+ false, and the two call sites relying on that default — the ghost session cookie and
1338
+ the Stripe Connect OAuth `state` cookie, which *is* a CSRF double-submit token —
1339
+ therefore shipped without `Secure` over real HTTPS, so one plaintext request disclosed
1340
+ them. The default is now `IS_PROD`, so a new cookie cannot repeat the omission.
1341
+ - **The guard API ships security headers.** `src/security-headers.ts` had exactly one
1342
+ importer, so `api.anvilcontrol.ai` — the host carrying every `anv_live_` bearer key and
1343
+ every money decision — served no HSTS, no nosniff and no framing policy. A new
1344
+ `apiSecurityHeaders()` (stricter than the ghost variant: `DENY` framing,
1345
+ `default-src 'none'`, `cross-origin-resource-policy: same-origin`) is applied once at
1346
+ the `router()` choke point, so JSON, metrics text and the error paths are all covered.
1347
+ - **The wrap endpoint's filesystem walk is bounded, and honest when it stops.** It is
1348
+ **synchronous**, so while it runs the ghost server's event loop is stopped and every
1349
+ other request — health probe included — waits behind it. The old bound guarded whether
1350
+ to enqueue a directory on the *file* count, which a million-directory tree never trips;
1351
+ pointing it at `/tmp` stalled the process for minutes (measured). It now bounds
1352
+ directories, files and wall-clock, and returns `scan-truncated` / `partial: true` rather
1353
+ than letting "we stopped looking" read as "your project has no call site". Symlinked
1354
+ directories were already skipped by `withFileTypes`; there is now a test that says so.
1355
+ - **The perimeter is now proven against STATE, not status codes.** Every original assertion
1356
+ was about a *response*, which is not the product's claim: "POST /anvil/actions/mode returns
1357
+ 401" and "an anonymous caller cannot weaken your protection" are different sentences, and a
1358
+ refactor that moved the write earlier — into a body-parse side effect, a middleware, or a
1359
+ handler hoisted above the gate — would have kept all of them green while a stranger
1360
+ downgraded a tenant from enforce to ghost. The suite now seeds `enforce`, runs the attack,
1361
+ and reads the resolved mode back; it does the same for `POST /anvil/ghost/enforce` (the
1362
+ sibling that takes a bare boolean and never asks for the downgrade reason), and for
1363
+ `POST /anvil/ghost/wrap` it asserts the source file is **byte-identical** with no `.anvil-bak`
1364
+ written. Each is a positive/negative pair — the same operation with the operator credential
1365
+ *does* take effect — because "unchanged" proves nothing when the fixture was inert or the
1366
+ read-back was stale. Both halves were needed: the first fixture used a camelCase call the
1367
+ codemod patches but the endpoint's safety check rejects, so the refused-wrap assertion was
1368
+ passing for the wrong reason. Verified by mutation: hoisting an enforcement write above the
1369
+ gate turns exactly these three red, each naming its consequence, while every status-code
1370
+ assertion stays green.
1371
+ - **…and in the posture the service actually ships in.** Reading state back needs a credential,
1372
+ so the block above exercises the `token` branch — but the ghost service carries no control
1373
+ token today, which means production will run `fail-closed`. That branch is now covered by two
1374
+ processes sharing one control store: a dev-mode reader seeds and observes, the token-less
1375
+ production box takes the attack. Mutation testing also caught this pair silently passing at
1376
+ first: the reader was serving a 3-second-stale cache (`ANVIL_CONTROL_CACHE_TTL_MS`), so the
1377
+ attacker's write had landed and the observer still reported "unchanged" — the exact false
1378
+ green the pairs exist to prevent, found only because the mutation was run.
1379
+ - **A green blocking lane can no longer skip its crown jewels.** `verifyRequiredProofs` — which
1380
+ reads vitest's JSON report and fails a lane whose declared proof produced zero passing tests —
1381
+ was wired only into `run-lane-files.mjs` (the service lanes). The blocking lane had no such
1382
+ check, so a proof renamed, moved or globbed out would shrink the lane silently. It is wired in
1383
+ now, blocking-lane only, and `tests/ghost-server-perimeter.test.ts` is a declared proof with a
1384
+ floor of 60. **The first implementation contained the very bug it exists to prevent**: it
1385
+ asked whether the proof was still in the lane's scheduled file list, so renaming the file
1386
+ removed it from the list, which switched the check off, which reported green. Ownership now
1387
+ comes from the manifest (`laneFor`), never from what the lane happened to collect. Verified by
1388
+ running the real runner against a scratch lane: proof present → exit 0; gutted below its floor
1389
+ → exit 1; renamed with an otherwise perfectly green lane → exit 1.
1390
+ - **`REQUIRED_PROOFS` itself is gated.** An entry nobody can execute is worse than no entry: it
1391
+ reads as coverage while providing none — the same defect the quarantine's filename globs were,
1392
+ one level up. `check:ci-quarantine` now refuses a proof whose file does not exist, that no lane
1393
+ collects, that is also declared red-on-purpose, that is duplicated, that carries a zero floor or
1394
+ no stated claim, or that is quarantined without any service lane scheduling it (the flaky lane
1395
+ is continue-on-error, so a proof living only there is a declaration with no gate behind it).
1396
+ - **Three new gates, and they were red against production before this shipped.**
1397
+ `scripts/check-ghost-perimeter.mjs` (wired into `npm run verify` and CI) parses
1398
+ `src/server.ts` and fails the build if the gate stops running above every route, stops
1399
+ failing closed in production, loses constant-time comparison, lets a query token
1400
+ authorize a write, or if any mutating route is neither perimeter-gated nor carrying a
1401
+ written-down reason it is public. `tests/ghost-server-perimeter.test.ts` boots the real
1402
+ server in all three postures and **parses the route list out of the source** rather than
1403
+ hand-writing it, so a new route is probed the moment it exists. And
1404
+ `check:serving-drift` gained live assertions that `go.anvilcontrol.ai/anvil/*` is 401
1405
+ and `/app` is a 302 — both of which fail against production today and describe the fix
1406
+ in their own failure text.
1407
+
1408
+ ### Everything else
1409
+
1410
+ - **The latency harness fired real money-path calls at production without anyone
1411
+ typing a flag. It can't now.** `scripts/spike-hosted-parity.mjs` read its remote
1412
+ credential as `--api-key` *falling back to* `process.env.ANVIL_API_KEY` — and the
1413
+ harness imports `src/policy.js` for its fixture validators, which pulls in
1414
+ `src/config.ts`, which autoloads the repo's `.env`, which is where `anvil protect`
1415
+ writes that variable. So simply running the read-only transit measurement from a
1416
+ normal checkout fired 25 real `/v1/guard` calls at a live tenant: receipts, usage
1417
+ rows, idempotency claims and completions, with the flag that was supposed to be the
1418
+ consent left untyped. `--base <url>` alone now measures transit against an
1419
+ unauthenticated static endpoint and writes nothing; the writing phase requires
1420
+ consent that had to be typed (`--api-key`, or `ANVIL_SPIKE_API_KEY` — a name nothing
1421
+ in this repo, no `.env` and no deploy sets), and a bare `ANVIL_API_KEY` is ignored
1422
+ *and said to be ignored*. `resolveRemoteApiKey()` is a pure exported function so the
1423
+ most consequential branch in that file is provable in a unit test instead of by
1424
+ observing the damage.
1425
+ - **"Could not be evaluated" was being reported as "BLOWN".** The server-side budget
1426
+ verdict was a boolean computed as `samples > 0 && inside…`, so a run that collected
1427
+ no `Server-Timing` samples printed a latency *failure* for a run that measured no
1428
+ latency at all. It is now three-valued (`inside` / `blown` / `unmeasurable` /
1429
+ `skipped`), and the exit code reads `ok === false` rather than `!ok`. Not
1430
+ hypothetical: the deployed api-server predates the header, so the first honest
1431
+ measurement against it would have reported a fabricated regression.
1432
+ - **Transit was computed by subtracting percentiles, which is not how percentiles
1433
+ work.** `p95(end-to-end) − p95(server-side)` assumes the call with the 95th-percentile
1434
+ end-to-end is the call with the 95th-percentile server time. Where a response carries
1435
+ `Server-Timing`, both halves are known for the *same* request, so per-call transit is
1436
+ now collected directly and summarised. The old figure is retained under its old name
1437
+ so previously-reported numbers stay readable.
1438
+ - **End-to-end latency is now measured against the real deployment, per origin.**
1439
+ Everything measured before was server-side processing over loopback. The harness's
1440
+ remote mode is real: it reports the edge it reached, the transit reference, the
1441
+ cold-connection cost (a caller's *first* call pays DNS + TCP + TLS — measured at
1442
+ +52.6ms, which is 71% of the 125ms budget), and a per-origin verdict that
1443
+ distinguishes a measurement from a bound from a genuine unknown. Results live in
1444
+ `scripts/spike-parity-origins.json` and generate the table in the rollout doc;
1445
+ `npm run check:parity-origins` fails if the doc drifts from the record, so a number
1446
+ in a markdown table can no longer be true only on the day it was typed.
1447
+ - **…and those measurements now expire.** Proving the doc matches the record proves
1448
+ nothing about the record still matching reality: a deployment can change region, gain
1449
+ a replica or move behind a different edge without one line of this repo changing,
1450
+ while the rollout doc keeps quoting numbers nobody has re-checked. Every origin row
1451
+ carries a **90-day shelf life**, and a measurement past it — or a declared-but-never
1452
+ -measured origin past its `dueBy` — fails `check:parity-origins` and a blocking-lane
1453
+ test until it is re-taken. The remedy is one command that needs no credential and
1454
+ writes nothing, which is what stops this becoming a gate someone deletes. A stale row
1455
+ reports `ok: null` rather than `false`, because an expired measurement is *unknown*,
1456
+ not *bad*; and the rendered table carries dates rather than ages, so the
1457
+ byte-compared doc cannot drift a little every night and red the gate having detected
1458
+ only the passage of time.
1459
+ - **The pre-flight's coverage set is now derived from the code that evaluates, not
1460
+ declared beside it.** `PREFLIGHT_COVERED_PRIMITIVES` was a hand-written array, and
1461
+ `coveredPrimitivesFor()` a second hand-written copy of the same predicate — so the
1462
+ invariant guarding hosted customers ("the pre-flight covers every primitive the
1463
+ hosted plane excludes") compared one hand-maintained list against another. That
1464
+ proves *"it appears in an array someone maintains"*, never *"it is actually
1465
+ evaluated"*, and the two come apart silently in the direction that matters: add an
1466
+ entry without wiring the evaluation and the tripwire stays green while the gap it
1467
+ exists to detect is wide open. Since hosted structurally refuses to execute customer
1468
+ code (a threat-model decision, not a deferral), the pre-flight is the only thing
1469
+ between "hosted excludes it" and "it is enforced nowhere", with the dashboard still
1470
+ rendering the rule as active. There is now one table — `CUSTOMER_CODE_SURFACES` in
1471
+ `src/policy.ts` — that `evaluateCustomRuleCodeOnly()` iterates to decide what to run,
1472
+ and the covered set, the per-call coverage report and `policyDeclaresCustomRuleCode()`
1473
+ are all read off it. Deleting a surface's evaluation turns the invariant red with the
1474
+ primitive named. Ten deliberate regressions were run against the new suite (hand-written
1475
+ literal, gutted evaluation, deleted surface, lost `continue`, lost ghost demotion,
1476
+ hand-written coverage report, lost ghost observation, hosted claiming customer code,
1477
+ and hosted no longer stripping either surface) and all ten fail loudly.
1478
+ - **The latency harness measures under concurrency, times the block path, and reports a
1479
+ delta.** Three narrowings, each of which made the number mean less than it looked.
1480
+ It fired **serially**, so a single event loop and a small pg pool were never contended
1481
+ and the reported p99 was a floor rather than a customer experience — the queuing and
1482
+ pool saturation that appear at 50 in-flight are structurally invisible at 1, and the
1483
+ 40ms budget exists to make hosted enforcement viable on a *payment* path, which is
1484
+ concurrent by definition. It measured only the **allow** path, while `handleGuard`'s
1485
+ block path does strictly more work (a blocked receipt written, a block counter observed)
1486
+ and is the branch a customer hits during an incident. And it **compared nothing**: a PR
1487
+ that doubled guard latency printed `p95 2.7ms → 5.4ms`, still said INSIDE BUDGET, and
1488
+ nobody looked — the artifact moved the archaeology from a commit message to a JSON file
1489
+ without removing it. `--concurrency N` (default 1, so every prior number stays
1490
+ comparable) warms up through the same scheduler so the pool warms under the shape being
1491
+ measured; the block path gets its own row and is never averaged in; and a committed
1492
+ `scripts/spike-parity-baseline.json` drives a printed delta that flags a p99 at ≥1.5×,
1493
+ on the tail with headroom and still non-blocking. A missing baseline reports **not
1494
+ compared**, never `1.0×`; a baseline from a different concurrency or mode is refused
1495
+ rather than compared against a different experiment; and `--update-baseline` is explicit,
1496
+ so moving the reference is a reviewable line in a PR rather than CI silently ratcheting
1497
+ it to whatever the last merge did. The scheduler and the comparison are unit-tested in
1498
+ the blocking lane against an in-process HTTP stub — real sockets and a real
1499
+ `Server-Timing` parse, no Postgres, no Redis, no api-server.
1500
+ - **…and the measurement it enabled, which found something.** Run against a real
1501
+ api-server + Redis + Postgres: server-side p50 tracks concurrency almost exactly
1502
+ linearly (`≈0.55ms × N`) and **p95 crosses the 40ms budget between 25 and 50 in-flight
1503
+ requests** — the signature of a serialized resource rather than spare capacity, and the
1504
+ condition the parity spec said to watch for. Recorded with its caveats (one box ran both
1505
+ the load generator and the server, so it is a lower bound on capacity) in
1506
+ `docs/HOSTED_ENFORCEMENT_PARITY_V1_SPEC.md` §Step 1, next to the rollout gate that has
1507
+ to argue from it. The block path turns out to be consistently *faster* than allow,
1508
+ because an enforce block refuses before claiming the idempotency key.
1509
+ - **The regression flag it shipped with was wrong, and the measurement proved it.** Three
1510
+ passes of one unchanged commit produced p95 = 5.85 / 2.04 / 14.17ms — a 7× spread from
1511
+ nothing, because the box was still settling from an unrelated test run. A `p99 ≥ 1.5×`
1512
+ threshold on that fires constantly, which the spec warns gets a latency gate disabled
1513
+ inside a week; it also set a threshold before having any variance data, which the same
1514
+ spec explicitly says not to do. `--update-baseline` now records the **median of N passes
1515
+ plus the observed spread**, and a run is flagged only when it lands outside that spread
1516
+ *and* past the factor. A baseline with no variance data reports the delta and flags
1517
+ nothing. The baseline lives at `scripts/spike-parity-baseline.json`,
1518
+ beside the script that owns it and following `scripts/egress-perf-baseline.json` —
1519
+ NOT under `artifacts/`, which is runtime output that `check:clean-state` correctly
1520
+ refuses to let anyone commit. The baseline also records a stable, non-identifying HOST
1521
+ fingerprint (platform / arch / cores / CPU model / Node major) and refuses a comparison
1522
+ across machines — a CI runner and a laptop are both `concurrency=1, mode=local`, so
1523
+ without it the first CI delta would report different silicon as a code regression.
1524
+ - **The local evaluator now runs the same customer-code dispatch as the hosted pre-flight.**
1525
+ Deriving the coverage set from a table is only worth something if that table is the one
1526
+ everybody uses, and it was not: `evaluatePolicyWithLatency` called the two customer-code
1527
+ helpers by hand at two more sites — the rules branch and the legacy-limits branch — each
1528
+ followed by its own copy of "carry the audit evidence forward on the allow path". Three
1529
+ copies of one ordering, one short-circuit and one evidence-merge, so a surface added to
1530
+ the table would have evaluated on the hosted transport and silently done nothing locally.
1531
+ The second branch was also unreachable for any policy that came off disk (the loader
1532
+ requires a `limits` entry per allowed action), i.e. dead code nothing would have noticed
1533
+ rotting. There is now one loop, `evaluateCustomCodeIfDeclared` and `runCustomPolicyRule`
1534
+ have exactly one call site each, and that is pinned structurally. One behaviour was
1535
+ unified on purpose: the two paths short-circuited on different facts — the evaluator on
1536
+ the mode-demoted `blocked`, the pre-flight on the pre-demotion `wouldBlock` — which agree
1537
+ in enforce but diverge in ghost, where the local path fell through to the legacy handler
1538
+ after the sandbox had already would-blocked and reported a rule enforce would never have
1539
+ reached. Both stop at `wouldBlock` now. No call changes outcome (ghost blocks nothing
1540
+ either way; enforce is byte-identical); only the observation gets truer.
1541
+ - **A hosted tenant is no longer told their working custom rule is inert.** The dashboard
1542
+ drove the custom-rule row off `enforced_on_your_runtime`, which asks only about the
1543
+ BACKING runtime — and for customer code the honest hosted answer is permanently `false`,
1544
+ because the hosted plane strips it from every snapshot by design. So a rule that was
1545
+ blocking calls on every request read "compiles clean · runs when enforcement is live".
1546
+ That is the mirror of the bug the runtime-truth contract exists to prevent: an underclaim
1547
+ rather than an overclaim, and the more corrosive direction, because a customer who
1548
+ believes a control is inert either turns it off or stops trusting every other badge
1549
+ beside it. Closed as a SECOND fact rather than a widened first one — the api-server
1550
+ genuinely does not evaluate customer code, so `enforcedPrimitives` must not claim it.
1551
+ `RuntimeTruth.sdkEvaluatedPrimitives` is supplied from the derived surface table (not a
1552
+ re-typed list; `runtime-truth.ts` stays a dependency-free leaf), `whereEnforced()` answers
1553
+ `runtime | sdk | nowhere`, and `isPrimitiveEnforced()` keeps its exact original meaning so
1554
+ no existing caller moves. And the claim is corroborated rather than asserted:
1555
+ `enforced_where` is architectural and stays true for a customer running an SDK too old to
1556
+ have the pre-flight, so `/api/custom-rules/health` also reports `sdk_preflight_observed`,
1557
+ read off the `locallyEvaluatedPrimitives` the SDK itself wrote onto a receipt — which
1558
+ cannot exist unless the pre-flight actually ran. Present tense only when a receipt backs
1559
+ it; three-valued, so "no receipts yet" renders as neither claim. That evidence scan reads
1560
+ a **bounded tail** (512KB) rather than the whole audit log: the dashboard polls this
1561
+ endpoint every 10 seconds and an audit log is append-only, so a whole-file read gets
1562
+ slower and hungrier every day a deploy runs — the same unbounded-journal-read defect the
1563
+ receipt store already had to fix. The first version of this shipped the unbounded read and
1564
+ a timing assertion that failed to catch it (12MB reads in ~50ms, so no threshold a test
1565
+ can afford discriminates); the property is now pinned at the source, with the test saying
1566
+ plainly why it cannot be pinned behaviourally.
1567
+ - **…and the two other surfaces that carried the same half-answer.** The calm
1568
+ not-enforcing banner said "Observing, not enforcing. … Nothing is blocked yet." — a
1569
+ claim about the whole product that stops being true on a hosted backing, where the SDK
1570
+ pre-flight is blocking calls on the customer's own machine. It now amends that sentence
1571
+ when the SDK covers something, from the same derived set the rule row uses, and keeps the
1572
+ original wording on a backing we cannot place (so the fix is not a blanket claim). And
1573
+ the per-rule chip rendered "observed · not blocking here" for anything the runtime does
1574
+ not cover — correct for an approval rule on hosted, wrong for customer code — so it gains
1575
+ a `sdkEvaluatesPrimitive()` sibling mirroring `whereEnforced()`, with the runtime
1576
+ predicate untouched so no existing badge changed meaning. Both are pinned by a jsdom test
1577
+ that runs the shipping functions; the first version of the chip check was a
1578
+ source-substring assertion that a rename walked straight through, and the mutation pass
1579
+ caught it.
1580
+ - **The "no gap between hosted and the pre-flight" tripwire was inert on this branch,
1581
+ and now is not.** It read a hosted DENYLIST that does not exist yet (Step 3 has not
1582
+ landed), found none, and asserted only that the module was still an array. Restated as
1583
+ a partition that is checkable on the current allowlist: no customer-code primitive may
1584
+ appear in the hosted enforced set, and `stripUnsupportedForHosted()` must physically
1585
+ delete both customer-code surfaces from every snapshot. Adding `custom_code_rule` to
1586
+ the hosted list — which would put "Enforcing" on a dashboard row for a rule the runtime
1587
+ strips — now fails the suite.
1588
+ - **`Server-Timing: app;dur` on every api-server response.** The hosted-parity budget is
1589
+ two numbers because only one of them is ours: server-side processing is what this code
1590
+ controls, and the rest of a customer's end-to-end latency is transit. Without the header
1591
+ the same 300ms reads as "the evaluator got slow" and as "the caller is a continent
1592
+ away", and only one is a bug to fix here. Stamped once at the socket edge — before
1593
+ routing, before auth — so it covers the auth hop and the policy-snapshot read, which are
1594
+ the two places a regression would hide, and emitted on the unauthenticated surfaces and
1595
+ error paths too, so `curl -i` verifies the split without a key.
1596
+ - **`npm run spike:parity` — the Step-1 latency measurement is repeatable and recorded.**
1597
+ The harness that produced the numbers the parity spec turns on was a script someone ran
1598
+ once, referenced by no `package.json` entry and no workflow, on a branch this one is not.
1599
+ It now runs from `package.json` and from a **non-blocking** `spike-parity` CI job on the
1600
+ same Postgres + Redis containers the blocking lane provisions, writing p50/p95/p99 to the
1601
+ job summary and a JSON report as an artifact. Non-blocking is deliberate: a latency gate
1602
+ that flakes on shared runners gets disabled within a week, which is worse than no gate.
1603
+ Three things make the number honest rather than merely present — the fixture is run
1604
+ through the REAL policy and control-config validators before it is used (a rejected
1605
+ policy makes the api-server degrade to idempotency-only, and an abbreviated control
1606
+ config is coerced to ghost, either of which reports a beautiful latency for an evaluator
1607
+ that never ran); the presence of the stateful primitives is asserted so the fixture
1608
+ cannot be quietly trimmed; and enforcement expectations are derived from
1609
+ `src/hosted-primitives.ts` rather than hardcoded, so a primitive the runtime *claims* but
1610
+ does not hold is reported as an OVERCLAIM and exits non-zero.
1611
+
1612
+ - **A receipt now proves its amount at the currency's own exponent.**
1613
+ `buildReceiptValueProof` — the evidence surface behind `anvil verify` and the
1614
+ exported `ReceiptValueProof`, the thing an operator shows someone else — took the
1615
+ receipt's currency, handed it to `Intl` with `style: 'currency'`, and then divided
1616
+ the MINOR amount by a hardcoded 100. Right for USD, wrong for every other
1617
+ exponent: a 500-sen JPY charge proved itself as "¥5" and a 5,000-fils BHD one as
1618
+ "BHD 5.00" instead of "BHD 5.000". The currency was already in hand; only the
1619
+ exponent was missing. Routed through the shared formatter with the rest.
1620
+ - **`check:money-format` now catches the shape that produced it.** A new rule fails
1621
+ the build when a function ACCEPTS a currency and still divides by a literal 100 —
1622
+ the caller has said the amount might not be dollars, so ignoring the exponent is
1623
+ a bug rather than a simplification. Deliberately narrow: a blanket "/100 near
1624
+ money" rule matches 13 places in this tree, every one a correct USD-only
1625
+ formatter over a `*_cents` field with no currency in scope, and a gate that cries
1626
+ wolf gets bypassed. Both instances the narrow rule caught (`moneyShort` in the
1627
+ api-server, `formatAmountInCurrency` in proof.ts) are fixed, so it enforces at
1628
+ zero false positives.
1629
+
1630
+ - **A looser rule can no longer switch a configured legacy ceiling off.** With the
1631
+ rule-vs-rule ordering defect closed, one path was left where *adding* a rule
1632
+ still widened a money policy: `limits[action].max_amount` went inert the moment
1633
+ any `amount_cap` rule applied, so a legacy $50 ceiling that gained a looser
1634
+ $5,000 rule started allowing $5,000 charges — 100x wider, one rule, no ordering
1635
+ required. Legacy is now a candidate in the same strictest-wins fold: it always
1636
+ enforces, and `EffectiveConfig.amountCap` reports whichever ceiling actually
1637
+ decides, so the displayed number stays the enforced one. Precedence still means
1638
+ what it should — a rule replaces the legacy field as the thing the dashboard
1639
+ names and the operator edits, and the loader's warning now points at
1640
+ `scripts/migrate-legacy-policies.mjs` instead of telling operators to delete one
1641
+ of the two (advice that could delete the stricter one). `workflow_limits.max_spend`
1642
+ gets the projection half of the same fix: it already enforced unconditionally
1643
+ (guard.ts turns on spend accounting from it alone), so the dashboard could show a
1644
+ looser rule's budget while the runtime stopped the workflow at the legacy one.
1645
+ Verified against the differential parity corpus: 33 expected-red divergences
1646
+ before and after, none new — hosted and local agree by construction, since hosted
1647
+ keeps `limits[].max_amount` through `stripUnsupportedForHosted` and calls the
1648
+ same `evaluatePolicy`.
1649
+ - **`npm run smoke:pack` now proves the shipped scripts can reach their siblings.**
1650
+ `scripts/policy-diff.mjs` — which the control plane imports to build the
1651
+ activation-consent diff — has a hard top-level import of
1652
+ `scripts/anvil-money-format.browser.js`. A sibling reached by relative import is
1653
+ invisible to every other probe: no entry point pulls it in, the export map never
1654
+ mentions it, and `npm run build` does not touch it. Drop it from package.json
1655
+ `files` and policy ACTIVATION dies with `ERR_MODULE_NOT_FOUND` for every
1656
+ installed consumer, from a green build. Pack-smoke now imports each such script
1657
+ from the installed tarball and asserts the helper renders 100000 USD minor as
1658
+ `$1,000.00`.
1659
+
1660
+ - **Money units and rule composition: three unconditional fail-open defects on the
1661
+ money path are closed.** None needed an outage, a misconfiguration or an attacker —
1662
+ only a customer writing two rules in the natural order.
1663
+ - **Rule order no longer drops the stricter cap.** `amount_cap` is declared
1664
+ `composable`, but the resolver took the first match with `.find()` and the runtime
1665
+ let any unscoped rule re-use that single resolved cap. A policy of
1666
+ `[$5,000 cap, $500 cap]` **allowed a $4,000 charge**; reversed, it blocked — and
1667
+ unscoped-first is exactly what the prose importer emits. `computeEffectiveConfig`
1668
+ now folds every applicable rule into `EffectiveConfig.amountCaps` and reports the
1669
+ **strictest** as `amountCap`; `evalAmountCap` looks its own rule up by id, so each
1670
+ cap enforces its own ceiling and the verdict composes as "all must pass". The same
1671
+ strictest-wins fold now covers every composable primitive. This makes the docs'
1672
+ long-standing promise — "adding a rule can only tighten a policy, never quietly
1673
+ weaken it" — true.
1674
+ - **A workflow spend cap no longer permits 100× its ceiling.** `evalWorkflowSpendCap`
1675
+ divided the caller's `spendCents` by 100 and compared the result against a
1676
+ minor-unit cap, on the branch `anvil.guard()` reaches whenever `spendByCurrency`
1677
+ is absent — the default. A $1,000-per-run cap allowed $100,000. Both spend
1678
+ counters are now compared minor-against-minor, and `WorkflowExecutionState`'s doc
1679
+ comment (which claimed `spendByCurrency` was *major*) matches the runtime.
1680
+ - **The dashboard no longer displays money 100× too large.** Every served page
1681
+ rendered an `amount_currency` object as `$` plus the raw minor integer — including
1682
+ the **"Activate these policy changes?" consent diff**, so an operator approved
1683
+ `$100,000` and was protected at `$1,000`. All money now routes through one
1684
+ exponent-aware helper: `src/primitives/money-format.ts` for the TypeScript tree
1685
+ (replacing five separate copies of the ISO-4217 exponent table) and a generated
1686
+ twin inlined into every served page. New `npm run check:money-format` gate fails
1687
+ the build on drift, on a page that hand-rolls a formatter, or on a second exponent
1688
+ table; `npm run fix:money-format` re-inlines the canonical helper.
1689
+ - **Also fixed while in here:** a `unit: 'major'` cap of `20.15` refused a `$20.15`
1690
+ charge (IEEE-754: `20.15 * 100` is `2014.9999999999998`); the redundancy modal ranked
1691
+ a `unit:'major'` rule above an equally strict minor-authored one and offered to delete
1692
+ the rule that was actually enforcing, and could mark a cap "dead" against a rule in a
1693
+ currency it does not enforce against; `confirmation_gate.amount_over` rendered raw
1694
+ minor units in the policy API, the ops dashboard, the approval webhook and the
1695
+ approval card; and `workflow_spend_cap` went silently dormant when it had no spend
1696
+ counter to read, while its sibling workflow primitives already announced it.
1697
+
1698
+ - **Forgetting the tenant boundary entirely is now caught too, not just a wrong id.**
1699
+ A code path that never opens a workspace context still resolved every per-tenant key
1700
+ to the shared `ws_default` namespace — the same cross-tenant pooling as a wrong id,
1701
+ reached by a different mistake. `namespaceKey()` now refuses that in production
1702
+ (`AnvilWorkspaceContextMissingError`, `code: 'WORKSPACE_CONTEXT_MISSING'`, exported)
1703
+ and warns once per store family in dev — but **only after this process has opened a
1704
+ real tenant context**, so a single-tenant self-host, the SDK's own `guard()` path, the
1705
+ CLI and readiness/boot probes (all of which read tenant stores with no context by
1706
+ design) are never affected. New `runOutsideWorkspace('why', …)` is the explicit escape
1707
+ hatch for genuinely fleet-wide work (a cross-tenant sweep, a boot read). The error
1708
+ names the store family only — never the caller-supplied key, which can carry a
1709
+ customer id.
1710
+ - **A workspace id Anvil does not recognise is now refused in production, not shared.**
1711
+ `runInWorkspace()` used to coerce an unrecognised tenant id to the reserved
1712
+ `ws_default` namespace — silently, with no error and no log. That is the wrong
1713
+ polarity for a tenancy boundary: the coerced request still returns 200 while every
1714
+ tenant's spend counters, approval queue and counterparty trust pool into one
1715
+ namespace. Under `NODE_ENV=production` it now throws `AnvilWorkspaceBoundaryError`
1716
+ (exported from the package, `code: 'WORKSPACE_BOUNDARY'`), naming the *shape* of the
1717
+ id it received rather than echoing the value. Dev and test keep the old coercion, so
1718
+ local single-tenant runs and un-wrapped SDK paths degrade instead of crashing.
1719
+ **Only reachable if a caller skips validation:** both shipped entry points already
1720
+ validate first, so no supported configuration changes behaviour.
1721
+ - **`runInWorkspace(undefined)` no longer throws a raw `TypeError`.** A nullish context
1722
+ is now just another unrecognised id — coerced in dev/test, refused in production —
1723
+ so the fail-safe half of the contract actually holds where it was meant to.
1724
+ - **The custom-rules health endpoint asked the wrong question.**
1725
+ `/api/custom-rules/health` reported `enforced_on_your_runtime` by asking whether the
1726
+ runtime enforces `custom_code` — the *authoring* primitive id — against lists built
1727
+ from *runtime* ids (`custom_code_rule`). It answered correctly only by accident. It
1728
+ now asks with the runtime id, so it cannot start over-claiming that customer code
1729
+ runs on a runtime that strips it.
1730
+ - **A hand-edited Anvil export no longer 500s the importer.** The `anvil_rules_json`
1731
+ round-trip carrier is the one place a rules array enters the importer without the
1732
+ parser producing it, and a malformed entry (missing `source`, unknown primitive,
1733
+ `null`) crashed policy import with an opaque error. Unusable entries are now refused
1734
+ individually and surfaced as visible notes — good rules in the same file still
1735
+ import, and nothing is dropped without a trace.
1736
+
1737
+ ## [0.3.4] (continued) — Operability and legal floor
1738
+
1739
+ The instrument panel, the paperwork, and a backup you can prove. None of this fixes a
1740
+ specific defect, which is why it was last — but without it you cannot *detect* an
1741
+ incident, *recover* from one, or *sell* around either.
1742
+
1743
+ - **The package has a license.** `npm view @useanvil/sdk` returned nothing for `license`,
1744
+ `repository`, `bugs`, `author`, or `homepage`, so npm rendered it all-rights-reserved
1745
+ and every serious design partner's legal review stopped there. Added a `LICENSE`
1746
+ (**BUSL-1.1**, with a production-use grant that has no seat or volume limit and a
1747
+ Change Date of 2030-07-29 to MPL-2.0) plus all five metadata fields. Chosen
1748
+ deliberately and reversibly: the npm tarball already ships the full `src/**/*.ts`
1749
+ (the control plane runs from source under `tsx`), so a permissive license would have
1750
+ irrevocably open-sourced the hosted product, while BUSL is a published, SCA-resolvable
1751
+ license that can be relaxed later and never tightened. `LICENSE` and `SECURITY.md` now
1752
+ ship in the tarball and count as publish-affecting in `check:release`.
1753
+ - **There is somewhere to report a vulnerability.** New `SECURITY.md`: a monitored
1754
+ address, per-stage response commitments (1 business day to acknowledge, 3 to triage,
1755
+ 7 days for anything that moves money incorrectly), safe harbour, and an explicit scope
1756
+ that names the anonymous ghost intake as the highest-value target. It says out loud
1757
+ that there is no paid bounty and that redaction is pattern-based, not DLP.
1758
+ - **The money path has telemetry.** `/metrics` exposed four `anvil_replay_*` families —
1759
+ the dashboard *sandbox* — and not one counter for `/v1/guard`. You could not answer,
1760
+ ever, after the fact: *how many guard calls executed money unguarded today?* New
1761
+ `anvil_guard_*` families cover requests, verdicts, blocks by primitive **and mode**
1762
+ (so a ghost fleet stops reporting zero blocks while catching plenty), dedup claims —
1763
+ with `duplicate_unresolved` separated from `duplicate_executed`, the only place the
1764
+ difference between "we stopped a re-execution" and "nobody proved the first one ran"
1765
+ survives — policy-eval outcomes, and **fail-opens**. The per-workspace rate limiter and
1766
+ hosted policy evaluation both degrade open by design; both were completely silent.
1767
+ Workspace labels are a `sha256` digest with bounded cardinality and a visible overflow
1768
+ counter, because `/metrics` is unauthenticated and sits outside the tenant boundary.
1769
+ - **Readiness is watchable.** The api-server — the box that moves money — had no
1770
+ readiness probe at all. Added unauthenticated `GET|HEAD /v1/ready` + `/readyz`: 503
1771
+ when Redis (probed with a real SET/GET/DEL, because the money path *writes*
1772
+ idempotency claims) or Postgres is unreachable, with a posture-only body carrying no
1773
+ hostname, port, or driver text. `npm run monitor` now probes readiness alongside
1774
+ liveness and raises a distinct critical alert for "UP but NOT READY". `railway.toml`
1775
+ still health-checks the shallow `/v1/health` **on purpose** — readiness-gating a
1776
+ single-replica deploy would block the deploy that fixes the outage — and
1777
+ `docs/DEPLOY.md`, which claimed otherwise, now says what the code does.
1778
+ - **Backup is no longer a markdown file.** `preflight:golive`'s backup gate passed when
1779
+ `ANVIL_POSTGRES_URL` was set **and `docs/BACKUP_AND_RECOVERY.md` existed on disk** —
1780
+ both true on a box that had never taken a dump. `npm run backup:pg` now writes a
1781
+ receipt to `anvil_backup_runs` (migration 013) on every run, **failures included**,
1782
+ and the gate reads *that*: it blocks unless a dump succeeded in the last 48 h and a
1783
+ restore drill passed in the last 100 days. Added `npm run backup:pg:if-due` for a
1784
+ cheap frequent cron and `npm run drill:restore`, which restores into a scratch
1785
+ database, times it, compares row counts against the live source, and computes the
1786
+ concrete **RESTORE GRACE** deadline (`hold ANVIL_FAIL_MODE=graceful until <ts>`)
1787
+ instead of leaving the one unskippable step to a human's memory at 3am. It refuses any
1788
+ target that is not obviously scratch, with no override flag. A real drill has been run
1789
+ and timed; the number is in `docs/BACKUP_AND_RECOVERY.md`.
1790
+ - **The wire is versioned.** `makeAuthHeaders` sent only `Authorization` and
1791
+ `Content-Type`, so a guard call could not be attributed to a client build — which
1792
+ mattered the day `0.3.3` shipped broken and the only move was to publish and hope
1793
+ people read a changelog. Every hosted call now carries `x-anvil-sdk-version`, counted
1794
+ per workspace. Two opt-in floors, both unset by default: `ANVIL_SDK_WARN_BELOW` adds a
1795
+ `Warning` header, `ANVIL_SDK_MIN_VERSION` returns `426` on `/v1/guard` — never on
1796
+ `/v1/complete`, where refusing would strand an executed action's key `pending`. An
1797
+ absent or unparseable version is never refused, and the two stay distinguishable in
1798
+ the counters (`absent` vs `invalid`).
1799
+ - **The ghost intake says what it does with your logs.** The anonymous intake accepts
1800
+ pasted production logs plus live third-party credentials, and the only thing the screen
1801
+ said about any of it was "No training by default. Deletion guarantees for uploaded
1802
+ logs." — vague, and an overclaim, since nothing implements a deletion guarantee because
1803
+ nothing writes the log down. Replaced with a real disclosure rendered from the running
1804
+ config (`src/ghost/data-disclosure.ts`): what is collected, that redaction is
1805
+ best-effort and not DLP, whether **this** deployment forwards a redacted excerpt to a
1806
+ model provider — reading *both* gates, since the ghost server's `GHOST_ENABLE_AI`
1807
+ overrides `GHOST_AI_ENABLED` — and how long anything lives. The in-page default is the
1808
+ broader wording, so a failed injection over-discloses rather than under-discloses.
1809
+
1810
+ ## [0.3.4] (continued) — Custom rules on hosted
1811
+
1812
+ - **Your custom rules now run when `ANVIL_API_KEY` is set.** They used to be
1813
+ silently discarded on the hosted transport: the guard call went to Anvil, which
1814
+ never evaluates custom rule code, so the rule you wrote never got a say. The SDK
1815
+ now evaluates them **in your own process, before the hosted call** — same engine,
1816
+ same sandbox, same fail-closed behavior, reading the files already in your repo.
1817
+ If a rule blocks, the call stops locally and no network request is made at all.
1818
+ Hosted gets all fifteen primitives; this one just runs on your side of the wire,
1819
+ and your rule code never leaves your machine.
1820
+ - **Blocks show up in your dashboard.** A locally-decided block is reported to Anvil
1821
+ so it appears in Decisions and Impact alongside every other verdict, instead of
1822
+ only existing in your process. Ghost-mode would-blocks are reported too — that is
1823
+ the whole point of a ghost rollout. Reporting is best-effort and never gates a
1824
+ call: if it fails, the verdict still stands and your local audit log still has it.
1825
+ - **The dashboard decides whether a custom rule blocks**, not your `.env`. The
1826
+ per-action mode you flipped in Anvil governs the custom rule exactly as it governs
1827
+ your amount caps, so you can no longer end up with fourteen primitives enforcing
1828
+ and your custom rule quietly observing. If Anvil is unreachable, it falls back to
1829
+ this process's `ANVIL_MODE` — the previous behavior, never worse.
1830
+ - **Fails closed, in enforce.** A declared rule whose file is missing, a rule the
1831
+ sandbox validator rejects, a policy that declares rules but will not load, or a
1832
+ custom-rule engine that will not import all HOLD the call. Ghost observes and
1833
+ never blocks anything.
1834
+ - **Costs effectively nothing.** Measured p95 for a workspace with no local policy —
1835
+ the common hosted case — is 0.006ms; with one custom rule, 0.9ms. A benchmark in
1836
+ the suite keeps it that way.
1837
+ - Set `ANVIL_CUSTOM_RULE_PREFLIGHT=off` to disable the local evaluation. It says so
1838
+ loudly in your logs while it is off, because nothing else evaluates custom rules.
1839
+
1840
+ ## [0.3.3] — Withdrawn: a broken release
1841
+
1842
+ **Do not use this version.** It shipped a codemod that emitted an ESM `import` into CommonJS files
1843
+ unconditionally — a hard `SyntaxError` in the project shape `npm init -y` produces — so it corrupted
1844
+ the first file it touched and then reported success. It also shipped a double-wrap that broke
1845
+ `safe.protect`. Both were fixed in 0.3.4.
1846
+
1847
+ It was published from a commit that is not in this repository, which is why there is no tag for it
1848
+ and no fuller account here. Two things exist because of it: `x-anvil-sdk-version` on every hosted
1849
+ call, so "which tenants are still on the broken one?" has an answer; and a release check that
1850
+ refuses to publish at or below the current `latest`.
1851
+
1852
+ ---
1853
+
1854
+ ## [0.3.2] — Slimmer install
1855
+
1856
+ - **Excluded source maps from the published package** (`!dist/**/*.map`). Maps are
1857
+ debug-only and never loaded at runtime; dropping them cuts the unpacked package
1858
+ from ~80 MB to ~33 MB, so `npx @useanvil/sdk protect …` downloads and starts
1859
+ noticeably faster. No behavior change — the build still emits maps locally.
1860
+
1861
+ ## [0.3.1] — First-run polish
1862
+
1863
+ - **Get Access page:** back to one clean command — removed the action-name and
1864
+ beta-code input boxes; the command shows a real example (`payment.charge`) the
1865
+ CLI recognizes and routes into the call picker. Clearer escape hatch: *"Rather
1866
+ explore without installing? Try Ghost mode →"*. Professional spacing.
1867
+ - **protect welcome menu** reads as a here/there pair: *Wrap `charge` in the CLI*
1868
+ or *Protect `charge` in your control plane (recommended)*, with your action
1869
+ interpolated into both.
1870
+ - **Placeholder paste always animates.** Pasting the featured command (the
1871
+ `<your.action>` / `payment.charge` placeholder) always plays the full
1872
+ spinning-anvil cinematic, then routes into the call picker to replace it with
1873
+ your real call — no longer rate-limited on a repeat paste.
1874
+
1875
+ ## [0.3.0] — CLI first-run
1876
+
1877
+ A new user can paste one command and be guided all the way into their control
1878
+ plane; a returning user is recognized on any machine. This release makes the CLI
1879
+ onboarding, help, and returning-user experience work end to end.
1880
+
1881
+ ### Added
1882
+
1883
+ - **One-command onboarding.** `npx @useanvil/sdk protect <your.action>` plays the
1884
+ spinning-anvil intro, shows a two-choice menu (wrap here / open control plane),
1885
+ scans your project for the risky call, wraps it, and opens the browser to a
1886
+ guided tour of Actions → Policy → Impact that ends on your dashboard.
1887
+ - **Returning-user identity.** `anvil open` now shows `✓ Signed in as <you> ·
1888
+ workspace <name>`, and a bare `anvil` prints a status stripe instead of the
1889
+ first-run card once you have a key — even on a new machine (identity is derived
1890
+ from a cached/hosted key, not a per-machine marker). Honors `ANVIL_HIDE_IDENTITY`.
1891
+ - **`GET /v1/whoami`** on the hosted API — the CLI's bounded, degrade-gracefully
1892
+ identity check behind the returning-user surfaces.
1893
+ - **Cross-platform project auto-scan.** `anvil protect` finds your project under
1894
+ locale-translated Desktop/Documents folders, OneDrive (personal + business),
1895
+ macOS iCloud Drive, and WSL — not just English `~/Desktop`.
1896
+ - **Help discoverability.** `anvil --help` and every command's `--help` print to
1897
+ stdout (pipeable); `anvil help <command>` (git-style) works; `anvil status` and
1898
+ the full command list are visible.
1899
+
1900
+ ### Changed
1901
+
1902
+ - Bare `anvil` opens your control plane for a returning user (was a static card).
1903
+ - The featured protect welcome + its two-choice menu replay on every interactive
1904
+ paste of the website command (only the heavy animation is rate-limited).
1905
+ - The browser tour is personalized to the action you wrapped.
1906
+
1907
+ ### Fixed
1908
+
1909
+ - **`anvil serve` boots from the published tarball.** `scripts/policy-import-server.mjs`
1910
+ imported `docs-pii-scrub.mjs` / `docs-dead-end-rotate.mjs` that were missing from
1911
+ the package `files` allowlist, so the installed dashboard crashed on boot; both
1912
+ are now shipped (guarded by `npm run smoke:pack`).
1913
+ - `anvil open` reliably boots a local control plane when one isn't running, and
1914
+ says plainly when it falls through to hosted.
1915
+ - `anvil protect --json` / `--yes` are script-safe: never hang on a prompt, always
1916
+ emit a valid envelope, and honor an explicit project directory.
1917
+ - `anvil --help` no longer prints the first-run splash ahead of the reference.
1918
+
1919
+ ## [0.2.0] — Money-path hardening
1920
+
1921
+ This release tightens the money path so the "wrap a charge, never double-charge"
1922
+ promise holds by default. It contains a **breaking change** to enforce mode.
1923
+
1924
+ ### Changed (BREAKING)
1925
+
1926
+ - **Enforce mode now fails CLOSED on a money action guarded without an `amount`.**
1927
+ A money-named action (`payment.charge`, `payment.refund`, `payout.*`, …, per
1928
+ `isPaymentActionName`) guarded in `enforce` mode **without** an `amount` now throws
1929
+ `AnvilMoneyAmountRequiredError` instead of only warning. Spend-cap reservation and the
1930
+ money-moving durability signal both key off the amount, so without it a payment runs
1931
+ half-protected — a silent gap in a money guarantee is worse than a loud error.
1932
+
1933
+ - **Migration:** pass `amount` (integer cents) on money actions. This is almost always
1934
+ what you want and unblocks spend caps.
1935
+ - **Opt out** for a *legitimately* amount-less money call (a full refund, a capture-all):
1936
+ `guard({ …, allowAmountless: true })` per call, or `ANVIL_ALLOW_AMOUNTLESS_MONEY=1`
1937
+ globally. Both downgrade the throw to a warning.
1938
+ - **Unaffected:** `ghost` mode (never throws — it observes and warns), dry runs, calls
1939
+ that already pass an `amount`, and non-money actions.
1940
+ - **"Enforce" means the RESOLVED mode the action actually runs in**, not just the process
1941
+ `ANVIL_MODE`. A per-action **ghost** override (from the control config / dashboard) or an
1942
+ active **kill switch** resolves the action to observe-only, so this check downgrades to a
1943
+ warning there — an action you've deliberately set to ghost is never walled by the
1944
+ amount requirement, and enforcement still fails closed wherever the action truly enforces.
1945
+ (On the hosted-API transport the per-tenant mode is resolved server-side; the client
1946
+ fails fast on its own declared `ANVIL_MODE` before dispatch.)
1947
+ - The old opt-in `ANVIL_REQUIRE_MONEY_AMOUNT` is removed — its behavior is now the default.
1948
+ - Run `anvil doctor` to see your current money-amount posture.
1949
+
1950
+ - **Ghost mode no longer throws on non-durable money; it degrades to a labeled
1951
+ observation.** A money-moving action guarded in `ghost` mode with an `amount` but no
1952
+ durable (Postgres) receipts used to throw `AnvilSetupError`. It now **executes and is
1953
+ recorded**, with `response.nonDurable === true` and a one-time warning — honestly labeled
1954
+ as *not double-charge-safe until Postgres*. Enforce mode still fails closed on non-durable
1955
+ money (unchanged). This lets a first-run, Redis-only developer see their observations
1956
+ instead of hitting a wall.
1957
+
1958
+ - **Enforce mode now fails CLOSED on a money movement routed through `safe.data.egress`.**
1959
+ The egress gate is a PII/data-classification layer that deliberately has **no** idempotency
1960
+ engine and no spend cap, so a money-moving call through it (a payment-named action, or any
1961
+ call carrying an `amount`) is not double-charge-safe even with Postgres — a retry re-executes
1962
+ the side effect. In `enforce` mode it now throws the new `AnvilMoneyViaEgressError` instead
1963
+ of warning-and-running, closing a gap where the WS1 fail-closed guarantees above were
1964
+ silently void on the egress path.
1965
+
1966
+ - **Migration:** route the money movement through `guard()` (idempotency engine + spend
1967
+ caps) and run the egress classification as a separate step.
1968
+ - **Unaffected:** `ghost` mode (observes and labels the receipt `nonDurable: true`), and
1969
+ non-money egress calls (`data.egress` with no `amount`) — the common case — are untouched.
1970
+
1971
+ ### Added
1972
+
1973
+ - `AnvilResponse.nonDurable?: boolean` — set on a ghost-mode money observation recorded
1974
+ without durable receipts.
1975
+ - **The non-durable observation is now surfaced honestly.** `nonDurable` rides into the
1976
+ durable audit record (`AuditRecord.nonDurable`, JSONL/Redis — no Postgres migration),
1977
+ so it is tamper-evident when audit signing is enabled (it is inside the HMAC hash). The
1978
+ Actions decision log renders a quiet grey chip — *"recorded · not double-charge-safe until
1979
+ Postgres"* — on those rows, and "Copy JSON" carries a matching `non_durable: true`. The
1980
+ label appears only on genuine ghost non-durable money observations; it never overclaims.
1981
+ - `GuardOptions.allowAmountless?: boolean` — per-call opt-out of the enforce-mode
1982
+ amount requirement (see above).
1983
+ - `AnvilMoneyViaEgressError` (code `MONEY_VIA_EGRESS`) — thrown when a money movement is
1984
+ routed through `safe.data.egress` in enforce mode (see BREAKING above). Exported from the
1985
+ package root; catchable by type or `err.code`.
1986
+ - **A malformed `amount` is now a typed, catchable error on `guard()` too.** A non-finite,
1987
+ negative, or non-integer `amount` throws `AnvilInvalidProtectionInputError`
1988
+ (`field: 'amount'`, code `INVALID_PROTECTION_INPUT`) instead of a bare `Error`, matching the
1989
+ `safe.protect()` path — so a caller's input-error handling catches both money entrypoints by
1990
+ type, and a client 400 stays distinguishable from a server 500. `safe.protect()` now also
1991
+ rejects a non-integer amount (e.g. `49.99` for `$49.99`), which it previously accepted —
1992
+ keeping the two money entrypoints in exact agreement on what a valid amount is.