The result
Each claim was written down with its bar before any code (CLAIMS.md). A claim that misses its bar is kept and shown as failed. Every number below is read from the committed receipts or computed by your browser while you watch, never typed in. Most claims have two halves: the simulation, which proves the law, and the real ledger on Kar's machine, which proves what happened. The real half is shown separately, and until real calls are made it says so.
| Claim | What it says | Measured | Where | Verdict | Real ledger |
|---|
The settings Kar chose
Simon owns the estate and handed these settings to Kar. They live in one local file; the law refuses a setting that makes no sense, such as a cap above the stop.
The real ledger
Loading…
Watch the wall hold, sixty days at a time
Below are sixty simulated days, each with far more demand than the cap allows. Some requests come without proof that the cheaper tiers were tried. Some calls die halfway, and some answers come back unreadable. Every request goes through the same law the real wire uses. The bars are what each day spent; the dashed line is the cap. The second chart is the running total climbing to Kar's stop, where the tier switches itself off.
Run it yourself
The same file the receipt came from (src/sim.mjs) runs here in your browser. With the settings as they are, your browser re-derives the committed ledger and checks its fingerprint against the receipt; that is claim R, decided on this page when it loads. Change the settings and the same sixty days run again in your browser under your numbers. The receipt check then no longer applies, because that is a different ledger.
Try one call
This is the decision the wall makes before every request, run in your browser by the real law (src/wall.mjs). Say what the cheaper paths did, how big the request is and what has been spent; the wall answers with a reservation or a refusal, and says why. For Kar, tier 1 is its pattern library and tier 2 is its local model; for your job, they are whatever cheap path it has.
…
What this is
A small piece of plumbing between an AI agent and a paid model API. The agent may use the paid model only when the job reports that its free tools and its own local model failed. Before a request goes out, the wall works out the most it could cost and reserves that against the day's cap and a hard stop; a request that would not fit is refused, with the reason, and nothing is sent. After the answer, the call is priced from the usage the API reported and the reservation comes down to that. Nothing is sent that was not reserved first.
Its first job is Kar's pattern library. Every night a local 7-billion-parameter model on the laptop writes rules that sort Kar's repositories into families, and a strict gate keeps only rules that win on data they never saw. When the local model fails a family completely, that family may go to Claude with the very same question, and Claude's rules face the very same gate. Once a rule Claude wrote for a family passes, the library covers that family and it is never sent again.
Who it stops, and who it does not
It stops mistakes and runaway code: a loop that runs all night, a retry storm (code that re-sends a failed call again and again), a prompt that grows without anyone noticing, a job that reaches for the paid model when a free one would do, a process that dies halfway through a call. Those are the ways spend usually gets away from a team, and the wall refuses each one before any request is sent.
It does not stop someone, or something, that can already write to your files. Whoever can read the key file can call the API directly; whoever can edit the settings file can raise the stop; whoever can delete the ledger can start the count again from zero. That is why the provider's own limit stays on as the outer wall (turn auto-reload off, or set a spend limit in the Console), and why the ledger is numbered and re-added: a line deleted from the middle shows; an edited cost, lines cut from the end, or a deleted file do not. Give the wall its own key, and compare its total with the provider's usage page.
Words on this page
- Kar
- The resident AI builder of Simon's software estate: it builds, tests and ships on Simon's own laptop, and uses this wall for the small part of its thinking that needs a large paid model.
- The estate
- Simon's collection of software projects, which share their proven parts (here, the-wallet and kar-tally).
- API
- The paid service a program calls to use a large model, here Anthropic's Claude. It bills by the token.
- Token
- The unit a model reads and writes, a few letters long. The wall assumes a request has no more tokens than bytes, plus a framing allowance, and checks that on every real answer.
- Tier 1, 2, 3
- Who does the work, cheapest first: tier 1 is free deterministic tools; tier 2 is a local model; tier 3 is the paid API. Tiers 1 and 2 are the free tiers. In Kar's estate, anything public, paid or risky then waits for its owner, Simon.
- Mutation gate (witness)
- A test of the tests. witness changes the code in small ways, one at a time (a < becomes <=, a + becomes −), and the tests must fail on each change. A change the tests let through is a gap in them. The counts for each file are in the blueprint.
- Families
- The groups Kar sorts its repositories into, and the pattern library's rules each name one.
- The gate
- The deterministic test every rule must pass to enter the pattern library, whoever wrote it.
- Ceiling
- The most one call can cost, on one assumption: every byte of the request priced as a token at the dearer input price, plus a framing allowance, plus every output token the limit allows, rounded up to a whole cent. The assumption, that a request has no more tokens than bytes plus the allowance, is checked on every real answer.
- Reservation
- The ledger line written, and flushed to disk, before a request goes out. It charges the whole ceiling.
- Settle
- The ledger line written after the answer: the call priced from the reported usage, rounded up to the cent. A failed or unreadable answer is charged the whole ceiling.
- Daily cap
- The most the ledger may be charged in one UTC day (midnight to midnight by the world clock).
- The stop
- The total the ledger will not pass, set a little under the credit so a call that is already running never finds the balance empty. Once a call is refused there, the paid API tier stays off until the stop is raised in the settings file; the free tiers carry on.
- Ledger
- The append-only file of every attempt the wire handles, each with its own number: reservations, settlements and refusals, each with its reason.
- Morning line
- The one line Kar shows Simon at the start of every session: spent today, spent in total, what is left, by job.
- the-wallet
- The estate's proven budget check: it refuses any spend that would pass a total. The wall uses it twice, for the cap and for the stop.
- kar-tally
- A separate checker from the same estate: it re-adds a numbered spend log from the first line, checks the numbering has no gaps and the balance never went below zero. It is used unmodified.
- Mutation gate (witness)
- The estate's own tool, witness: it changes the code one operator at a time and checks the tests catch every change. "Clean" means every change it made was caught.
- .si-didy
- The folder in Kar's home directory where its local, private state lives: the key file, the ledger, the settings. Nothing in it is published.
- Konomi architecture
- The architecture the estate's builds are made on, created by Thomas Frumkin; credited at the foot of the page.
Start here
- Get the code. Clone the repository and run
npm ciwith Node 22 (the version CI tests). There is one dependency, Anthropic's official SDK, pinned to an exact version. - Put the key in a file, not in the environment. Create a key for this wall alone on the Anthropic Console's API keys page, and save it alone in
~/.si-didy/keys/anthropic-api.key, outside every repository, readable only by you. To rotate it, create a new key, replace the file and revoke the old key in the Console; the next call reads the new file. For real calls the wire reads the key from there and the ledger from~/.si-didy/api/, under the home folder the operating system reports, soHOMEorUSERPROFILEcannot move them; everyANTHROPIC_*variable is removed from its process. - Keep the provider's own limit on. Turn auto-reload off in the Anthropic Console, or set a spend limit. That outer wall holds even if this machine is compromised.
- Set your numbers, if you want different ones. Write them to
~/.si-didy/api/settings.json, in cents, for example{"dayCents": 300, "stopCents": 9500}. A stop above the default credit needs the credit too:{"stopCents": 19000, "creditCents": 20000}. - Send a request. Pipe one JSON line to
node tools/ask.mjs, and read one JSON line back:in: {"job": "teacher", "prompt": "...", "system": "(optional)", "evidence": {"tier1": {"asked": true, "answered": false}, "tier2": {"tried": 3, "passed": 0}}} out: {"ok": true, "code": "end_turn", "text": "...", "seq": 12, "costCents": 3, "ceilingCents": 14, "brief": "the morning line"} or {"ok": false, "code": "day", "why": "API budget reached for today ...", ...} - Read the ledger.
node tools/audit.mjsjudges the real ledger by the claims' own bars and has kar-tally re-add it;--writesaves the result as the receipt this page shows; it is run and committed by hand, so the receipt is as fresh as its date.
How it works
One call, traced
This is the wire's own test, and no money is spent. tools/ask.mjs sends a real request through Anthropic's SDK to a stand-in for the API on this machine. Decoy credentials and a decoy address sit in its environment, and the test proves neither was used. The stand-in reports its usage and the law prices it; your browser re-computes every number below from the same law.
Blueprint
| Part | What it does | Proven by |
|---|---|---|
src/wall.mjs | The law: settings, prices, the ceiling, replaying the numbered ledger, the check, the tier order, the reservation, the settlement, the morning line, kar-tally's input. No clock, no disk, no network. | Hand-worked tests, a fuzz, the mutation gate |
src/teach.mjs | The first job's law: which families of the pattern library may go to the API tonight, with the evidence for each. | Tests, the mutation gate |
src/sim.mjs | Sixty days of hostile demand through the law, and the measurements read back from the ledger alone. | Pinned output, every verdict shown able to fail, the mutation gate |
src/audit.mjs | The real ledger judged by the claims' own bars, fair to a cap or stop raised later, and the token bound checked on every answer. | Every violation built by hand and caught, the mutation gate |
tools/ask.mjs | The wire: the lock, the plan, the reservation flushed to disk, one request through the official SDK, the settlement. The only file that touches the key. | End to end against a stand-in API with decoy credentials (not mutation-tested) |
vendor/wallet | the-wallet's budget check, used for both the cap and the stop. | Pinned by SHA-256 |
vendor/kar-tally | The ledger checker, unmodified. | Pinned by SHA-256 |
si-didy/patlib-teach.mjs | On Kar's machine: the teacher step after each night of the pattern library. The library's own gate decides; the night itself still makes no paid call. | End to end with a stand-in wire, on Kar's machine only |
What it will not do
- It will not send a request whose evidence does not say the cheaper tiers were tried and failed. It trusts what the job reports, and keeps that evidence in the ledger for anyone to check. There is one exception, and the agent cannot grant it to itself: a measurement under the owner's written approval (the next line).
- It will not let a measurement skip that rule on the agent's own say-so. A measurement call (claim K7, added on 22 November 2026, in AMENDMENT-1.md) is allowed only when the owner's approval is on file beside the ledger: his name, his own words quoted, and a cap in whole cents. The spend under that approval, plus the next call's whole worst case, may not pass the cap. The daily cap and the stop still apply, and no other job can use an approval. The first use was a frontier comparison run for the Browser Swarm measurement.
- It will not send a request before its whole worst case is reserved on disk.
- It will not retry: a retry would be a second spend under one reservation.
- It will not guess a price. A model with no flat published price is refused.
- For a real call it takes no credential or address from its environment: the key and the ledger are under the home folder the operating system reports, the key goes only to Anthropic's API, and the test mode refuses the real key's path and the real ledger's folder.
- It will not act on an answer. It returns text; the job's own gate decides what it is worth.
- It will not pass the stop, or switch itself back on: that takes raising the stop in the settings file.
- It does one prompt in, text out. No tools, images, streaming or conversations: the first job needs none of them.
Adoption
Any team that lets software call a paid model has the same exposure. Dashboards tell you afterwards. The provider's limits are enforced, but per organisation or workspace and by the month. This wall decides before each call, per ledger and per UTC day, and writes down why.
- Put it in front of one job first. One ledger, one cap; the morning line reports spend by job. Watch it for a week.
- Write the evidence your cheaper path produces. The tier order is only as honest as the evidence passed in; build it from your job's own records, not from anything a model says.
- Keep the provider's own limit as the outer wall. Two walls, one of them outside your machine.
- Audit the real ledger. Run
tools/audit.mjsdaily and compare its total with the provider's usage page now and then: the checker proves the ledger adds up and has no gaps; the usage page shows whether anything was spent outside it, provided the wall has its own key (ideally its own workspace).
A pilot, step by step
- Pick the job. One automated job that calls a paid model today.
- Set the cap from the bill you can live with. The calculator below shows what a runaway loop would cost with the wall and without it.
- Wire the job through
tools/ask.mjs. Pass the evidence of what the cheap path tried. - Run for two weeks. Read the morning line daily; run the audit.
- Compare with the provider's usage page. The wall's total should be at or above the provider's: it rounds every call up to the cent, and charges a failed call its whole ceiling.
- Decide. Keep it, widen it to a second job, or take it out. Nothing else changes.
White paper: reserve before you spend
The problem. A spend control that looks only at what has been spent so far, and refuses once a limit is crossed, is too late by one call, and a model call can be expensive: the output alone can run to tens of thousands of tokens, thinking included. A loop that checks the balance and then makes a large call can overshoot by the size of that call, every day.
The idea. Bound the call before it exists. Take its input as no more tokens than it has bytes, plus an allowance, and its output as the full limit you set; that is the most it can cost. Reserve that whole amount against the cap, on disk, before the request goes out. When the answer comes back, settle it at what it really cost. If the process dies mid-call, the reservation stands, so the ledger never under-counts. A single call too big for any whole day is refused on its own, without touching the stop.
The order. A paid call is the last resort. The request must carry evidence that the free tools and the local model were tried and failed, and the wall refuses it otherwise.
The stop. A hard stop a little under the credit, so a call that is already running never finds the balance empty. When a call is refused there, the tier latches off: it does not drift back on as small calls fit again.
The proof. Every decision lives in one pure file, and the mutation gate caught every change it made to it. Sixty days of hostile demand run through that same file and are re-derived on every push. kar-tally re-adds the numbered ledger. The wire is tested end to end against a stand-in API with decoy credentials in its environment. The real ledger is judged every morning by the same rules.
The honest limits. kar-tally proves the ledger adds up and has no gaps in the middle, not that it is complete or untouched: an edited cost, its last lines removed, or the whole file deleted, do not show, so compare it with the provider's usage page. The one-token-per-byte bound is an assumption about Anthropic's tokenizer; the audit checks it on every real answer, and the simulation, which never breaks it by design, cannot test it. Prices are read from the provider's page by hand, with the date; if they change, the table must be updated.
For business
| Who | What this means for them |
|---|---|
| Chief executive | AI that is allowed to spend, under a limit the code checks before every call rather than a policy someone has to remember. |
| Finance | A daily cap and a hard stop decided before each call, and a numbered ledger a separate checker re-adds. A runaway loop costs at most one day's cap for each UTC day it runs. |
| Operations | A refusal says why in plain words. What the job does instead is up to the job; the cap resets the next UTC day, and a latched stop waits for someone to raise it. |
| Technology and security | One small file of law, mutation-proven, and one wire that alone reads the key and sends it only to Anthropic's API. It stops mistakes and runaway code, not someone who can already write to the machine: the provider's limit is the outer wall. |
| The teams | One command, one line back, one morning line to read. |
The cost case: a runaway loop, with the wall and without
Your numbers in. The worst case of each call is worked out by the law from the published price table for the model shown, and the output limit you set. These are your costs; no price of ours appears.
…
| Route | What happens | The bill |
|---|
Against what you have now
| What you have now | What it does | What this adds |
|---|---|---|
| The provider's spend limit or prepaid credit | A real outer wall, per organisation or workspace, by the month. | A wall per ledger, per UTC day, decided before each call, with the reason written down. |
| Usage dashboards and alerts | Tell you after the money is spent. | Refuses before the money is spent. |
| Rate limits | Bound requests and tokens per minute, not dollars per day. | Bounds dollars per day and in total, counting each call at its worst case before it goes out. |
Security, compliance and data
- For a real call the key is read from one fixed file by one process and sent only to Anthropic's API; it is never written to the ledger, the console or the page. A test proves it with a fake key and decoy credentials; CI scans every tracked file for anything shaped like a key.
- The ledger holds job names, sizes, token counts, costs, the evidence in its fixed shape (yes-or-no answers, counts, and a few short text fields of at most 200 characters each), and the API's error text when a call fails. It never stores the prompt or the answer; only what a job writes into those short evidence fields.
- The page loads only its own files and sends nothing anywhere.
Deployment, support and ownership
It is a folder of plain JavaScript and one pinned dependency, run with Node 22 on your machine. You own it: the code is MIT. Supplied by AI Native Solutions; contact through that site. Support, SLA, warranty and liability are agreed per deployment.
Risks, answered straight
| Can the agent go around the wall? | An agent that can run commands as you can read the key file or edit the settings. The wall stops mistakes and runaway code, not that; the provider's own limit is the wall it cannot touch. |
| What if the price changes? | The price table names its source and the date it was read. Update it the day prices change. Rounding every charge up gives a little slack, not a guarantee. |
| What if a call costs more than its ceiling? | It is still charged in full and flagged as an overrun in the ledger and the morning line. Loading… |
| What if the process dies mid-call? | The reservation is already on disk, so the call counts at its whole ceiling. A lock left behind clears itself after ten minutes. A second call that finds the lock held is turned away before it reaches the ledger. |
| Can the job lie about the evidence? | Yes: the wall trusts what the job reports. The evidence is kept in the ledger with every call, for anyone to check, and Kar's teacher builds it from the night's own records, never from anything a model says. |
| What failed? | Loading… |
| Who uses it? | Loading… |
The case for the board
Letting AI spend money is coming either way. The question is whether the limit is a policy someone has to remember or a check in the code, small enough to read, with every mutant the gate made of it caught by a test, and a ledger that a separate checker re-adds. Keep the provider's limit on as well; this does not replace it, it decides earlier.