spec/Contracts/os/v1.
The rule
The model is the shell. Deterministic code is the kernel. The model decides what to try; the kernel decides what happens. The model can propose tool calls but receives no executor authority. These are enforced in code, not in prompts:- Every tool execution passes
checkfirst. Nocheck, no execution. - The model never approves. Only a human session can resolve an approval.
- No secret value reaches model context. The kernel attaches credentials at the call.
- Every decision writes a receipt before the action runs.
- Protected screens are never drawn by a model or an app.
The six calls plus admit
Action classes and autonomy
Each action has a class:read, ui_layout, run_control, file_write, network, app_install, inbox_prepare, money, client_message, deploy, secret_new_host and irreversible. A class the kernel does not know is ask, never allow.
The person picks one of three autonomy levels in onboarding: “Ask me first”, “Ask only for risky actions” or “Full autonomy”. The level changes what is allowed without asking for the first seven classes.
Human-only classes
money, client_message, deploy, secret_new_host and irreversible always need a human approval, at every autonomy level. Policy may allow other classes; it never approves these five.
Where check runs
In allternit-api, check runs inside the functions that execute tools, not in the HTTP routes, because some callers (the routine scheduler, the MCP server) never pass through HTTP. Each tool call gets exactly one check:
A tool that is not in a table is
ask, never allow. Until onboarding records an autonomy level, every account is “Ask me first”.
Every check writes its receipt to the same chain the receipt routes read: your account plus one tenant value, the same on every path. That value is your organization when you are in one, otherwise your account’s tenant, otherwise default (authority::kernel_scope in allternit-api). So a check made from a native tool, an MCP call or a computer member shows up in GET /api/v1/kernel/receipts.
For an ask or human-only class, the call must carry an approval token bound to the sha256: hash of the canonical action {tool, args}. The token goes outside the arguments: approval_token on /tools/execute and on MCP tools/call, kernel_approval_token in a computer member’s input. Without one, the kernel writes a receipt, opens an approval request for that exact action and refuses with code approval_required and the request id (HTTP 202 on /tools/execute). After a person approves, the caller retries the same call with the token. A token for a different payload, a spent token or an expired token is refused with a receipt.
Modes
ALLTERNIT_KERNEL_CHECK picks how hard the check bites:
Shadow mode lets the build ship without breaking live tool calls while the receipts show what enforce would refuse. In shadow mode a kernel failure is logged and the tool runs; in enforce mode it is a denial (
kernel_unavailable). Shadow mode logs a failure as a warning once per process (one for a missing signing key, for example when Desktop has not handed it over yet, and one for any other failure), then counts later ones at debug level, so the log does not fill with one warning per tool call. The older permission policy on /tools/execute still runs first. A tool runs only when both allow it, so a kernel denial always wins.
Approval tokens
A request carries the exact action payload and a deadline. A human session resolves it and the kernel issues a single-use approval token. The kernel rejects any resolve from a run token, bot token, agent credential, MCP client token or model request, and writes a receipt for the rejection. A human cannot approve a request made by a run they control. On Allternit Desktop, approving also needs a user-presence check. Before the approve reaches the kernel, the Desktop app asks for Touch ID on macOS or Windows Hello on Windows. It then attaches a short-lived proof bound to that one request. The kernel refuses a Desktop approve without that proof and writes a receipt. On a computer with neither Touch ID nor Windows Hello (Linux, or a Mac or PC without them), approve from the web or phone app, which use your signed-in session. Deny needs no presence check.The older approval stores
Allternit had approval stores before the kernel. Their tables, routes and responses stay, so existing apps keep working. Each one now writes through the kernel’sapproval_requests table:
- Create. When an older store creates a pending approval, it also opens a kernel request. The request has the same action, owner and deadline. The older row keeps the kernel request id. On the kernel row,
source_storeandsource_refpoint back at the older row. - Approve or deny on an older route. The route first checks that a person is acting. Then the kernel resolves the request and writes one receipt. Then the older row changes.
- Approve or deny in the kernel.
POST /api/v1/kernel/approvals/resolvecloses the older row too. This write-back does not call the kernel again, so a decision cannot loop. - Use. Where an older store spends an approval, the kernel token is spent too.
approval_requests row and one approve or deny receipt. A row the older store closes by itself gets a withdraw receipt. This happens when the row expired, when a phone hold expired or the screen changed, when a vendor answered on its own side, when a card was dismissed or withdrawn by its requester, or when the Floor autopilot answered a coding-session ask.
Approvals from the Factory CLI. gizzi workspace approve (and allternit-factory workspace approve, and the Gizzi factory floor) runs the Factory engine on your computer with the terminal’s device credential. An agent on the same computer holds that same credential, so the CLI has no person proof. The kernel request is therefore withdrawn, not approved. Its withdraw receipt names the CLI: approver_source is factory_cli, with the outcome and who the ledger recorded. To get an approve receipt, approve in an Allternit app instead.
Classes. A gateway approval for an outbound message (a text, post, iMessage or call) has the class
client_message. A phone action in a money app is money. Money phone actions are single use: each open of a money app, each element-less tap there, each Phone Use action and each confirm or submit-like tap (a pay effect) needs its own hold and kernel token, bound to that action. An earlier approved hold never covers a later money action in the same run, and the token is spent when the action runs. The approval names the app and the action, and expires with the kernel token (300 s default, 900 s cap). A send of consequential work to a vendor agent is network. Anything a vendor defines is held to irreversible. A card takes its class from what it asks: file edits are file_write, fetches and subscription tasks are network, and shell commands and unknown tools are irreversible. A grant takes the strictest class among its actions.
Grants are standing approvals. A grant you press is approved at once, so it has one request receipt and one approve receipt. A grant made from your own words in chat is read by an agent. It stays open in the kernel inbox until you approve it there. shadow lets it work meanwhile; enforce does not. A grant counts only while its kernel request is approved and before its deadline (seven days, or when the thread closes).
Team rule asks are resolved in the kernel by the approver the rule names, so they show in the approver’s kernel inbox.
Platform API runtimes have no Allternit person. A decision on a Platform runtime’s approval comes from the developer’s key. cloud-api records it (that store moves onto the kernel in step 11b). The local kernel request is withdrawn with that reason on its receipt.
Who may resolve on an older route. A credential that is never a person is always refused with 403 forbidden_caller. That means an agent or run credential, an API key, an MCP client, the internal service token, or an access or worker token. /beta/approvals used to accept any authenticated caller for any approval id. It now also needs the approval’s owner, and anyone else gets 404. A Factory reply from the owner’s verified channel identity with its one-time code counts as the person. High-risk Factory approvals stay app and push only.
The same ALLTERNIT_KERNEL_CHECK mode applies:
A person proof is a signed-in session token for that account, or the Desktop window’s proof header. A resolve the kernel refuses as a conflict, for example one already resolved the other way, is refused in every mode except
off.
The signing key
The kernel signs approval tokens and receipts with one Ed25519 key. Where it lives depends on the host:
On Desktop the app’s main process keeps the key in the OS keystore and passes it to the local API when the API starts. The key never goes in a file or an environment variable there. When you update from a build that kept the key in a file, Desktop moves the key into the keystore and then deletes the file. If the keystore is locked or turned down, approvals stay off until it unlocks. Desktop does not fall back to a new file.
Desktop also never replaces a lost key with a new one. After the first launch it leaves a marker (no key material) next to the data folder. If the keystore entry later reads as missing or damaged while that marker exists, Desktop starts the API without a key and approvals return
kernel_unavailable, with a clear error in the log. A new key would otherwise leave every old receipt unverifiable without telling you. Restore the entry to turn approvals back on.
The receipt chain
One append-only log,kernel_receipts, kept as a hash chain per principal and tenant (your account in your workspace), not per run and not per kind of receipt. The run a receipt belongs to is a column on the row. Each row holds the previous hash in its chain, its own hash and an Ed25519 signature. The hash covers the previous hash, the kind, the principal, the tenant, a hash of the payload, the decision and the time, so none of them can be edited unnoticed. The row also records which key signed it.
The kernel writes the receipt before it changes anything, in the same database transaction as the change. Request, resolve (approve, deny, expiry), redeem and every denial work this way. If the write fails, the answer is deny (kernel_unavailable). Two writers on one chain are serialized, so the chain stays a line. Before extending a chain the kernel checks the last row, and refuses to extend a chain that fails (chain_broken).
Receipt routes
Both routes need a person’s session (the same check as resolve) and read only your own chain. A run, agent, bot, MCP client or API key is refused.The verify rule
An edited row fails with the first bad row named:payload_hash_mismatch, hash_mismatch, broken_link or bad_signature. A row signed by a different key than the one in use is not tampering: if its signature verifies against the public key stored on that row, it counts under signed_by_previous_key and the chain still passes. A signature that does not verify against its own stored key fails. Deleting or updating a row is refused by database triggers.
Approvals in the inbox
A pending approval request shows in the one inbox (GET /api/v1/inbox?scope=needs_you) as a kernel_approval row with a kernel object: requestId, runId, assignee, actionClass, actionSummary, actionHash, deadline, humanOnly. The row id is kernel:<request_id>. Only open, unexpired requests assigned to you (or to “owner”) appear; a request past its deadline drops out and gets an expired receipt. You decide it only through POST /api/v1/kernel/approvals/resolve, which needs a person’s session and, from Desktop, a presence check. The inbox approve and dismiss verbs on a kernel row answer 409 USE_KERNEL_ROUTE and change nothing; snooze hides the row until a time, and the deadline still applies. GET /api/v1/kernel/approvals?state=pending returns the same list directly (person’s session only).
Approvals on your phone
When a request is for the computer’s owner, the computer also sends it to cloud-api, which pushes it to your phones and lists it for them. The computer reaches cloud-api the same way it sends every other runtime call: a request signed with its device token. Only thekernel object above travels, never the action payload or a token.
Rules:
- A person decides, on the computer. The forwarded request carries your session token as the person proof. The computer checks it again and signs the token with its own key. That key never leaves the computer.
- Never a bot. A request that carries a run, agent, internal-service, MCP-client or computer credential is refused with
forbidden_callerand arelay_refusedreceipt before anything else happens. API keys are refused too. - Expiry. A copy past its deadline reads as expired and drops out of the list, and resolve answers 409
token_expiredwithout contacting the computer. If the computer is offline, resolve answers 503kernel_unavailableand nothing changes. - Receipts on both sides. cloud-api writes
relay_received,relay_forwarded(before the decision is sent) andrelay_resultto its own log. The computer writes its usual resolve receipt.
The kernel in cloud-api
cloud-api has its own copy of the kernel for chats with no computer, plus the relay receipts.-
Key:
ALLTERNIT_KERNEL_SEED(standard base64 of a 32-byte Ed25519 seed), kept in cloud-api’s secret settings on the server, never in the repo. It signs cloud-api’s own receipts and the approval tokens for cloud-api’s own requests (below), never a token for a computer. With no seed set, no receipt can be written: the relay will not send decisions, andcheckanswerskernel_unavailable. -
Receipts: the
kernel_receiptstable (migration 171), one hash chain per person, signed, append-only (database triggers refuse UPDATE and DELETE). -
check: the policy decision for a tool call that cloud-api runs itself. Autonomy isask_first. The mode is set byALLTERNIT_KERNEL_MODE. The default,shadow, records the decision and its receipt but always lets the call run.enforcerefusesaskand human-only classes withapproval_required, theaction_hashof the call and anapproval_request_id, unless the call redeems an approval token for that exact action. With no seed,shadowstill runs and writes no receipt, with one warning in the log (not one per call). -
Where it runs: exactly once per tool call, before the tool runs, in the paths that execute tools on the server.
-
Approvals for chats with no computer (
kernel_approvals.rs): there is no new store. A refused call opens a row inplatform_approvals, the same table as/v1/approvals, withsource = 'kernel'. The row holds the exact action (tool, arguments, a summary of up to 280 characters), theaction_hashand class, the requesting principal and run, the check receipt, and a deadline. The deadline isALLTERNIT_KERNEL_APPROVAL_TTL_SECS: 300 s by default, never more than 900 s. The assignee is the owner (the key’s owner, or the agent’s project owner). Inenforcethe row ispending, pushed once to the owner’s phones (categoryKERNEL_APPROVAL) and reused if the same call is repeated while it is open. Inshadowit is only a dry record (status = 'shadow'): never listed and never pushed.- On the phone:
GET /api/v1/kernel/relay/approvalslists these rows next to the device requests, withruntimeId: "cloud"andresolveRoute: /api/v1/kernel/relay/approvals/cloud/<id>/resolve. The phone resolves them on the same route it uses for device requests, so iOS and Android need no change. The same checks apply: no machine credential, and a person’s Clerk session (API keys are refused). Approve mints a single-useApprovalTokenV1, signed withALLTERNIT_KERNEL_SEEDand bound to the action hash and the principal, and returns it. Deny closes the row.GET /api/v1/approvals?approver=melists the same rows with that resolve route. - Never by API key:
POST /v1/approvals/<id>on a kernel row answers 403forbidden_callerand writes aresolve_refusedreceipt./v1/approvalsnever lists or shows kernel rows, and the expiry sweep sends no project webhook for them. - Redeem: the caller repeats the same call. It may send the token as
kernel_approval_tokenin the tool input. That field is taken out before hashing, and the tool never sees it. If no token is sent, the kernel redeems the one stored on the principal’s approved row for the same action. A token is spent once (approved -> consumed). A second use answersapproval_token_spent, a token for different argumentsapproval_hash_mismatch, and an old tokenapproval_token_expired. - Holds that already exist count: these calls are not asked twice.
phone.sms.sendandphone.call.dialalways wait for the owner on their Desktop phone guard. Phone taps, typing and app opens (phone_tap,phone_type,phone_open_app, and the matchingphone_toolnames) defer to the same device guard and are recorded asapproved_by: phone_hold:device_guard;phone_task,phone_skill_run, payments and messages that leave the device stay under the kernel. A phone tool retried with an approvedhold_idis let through, and the device checks the hold. A platform agent’ssend_textorcallwith an approved twinapproval_idis let through, and the tool re-checks and consumes that hold. Each of these is recorded on the check receipt asapproved_by(phone_hold:…orplatform_approval:<id>). When the Desktop reportsphone.approval.resolved, cloud-api also writes ahold_resolvedreceipt to the owner’s chain.
- On the phone:
-
Classes (
kernel_tools.rs): reads allow. A connector tool whose name says it sends (send, reply, post, message, email, sms, call) isclient_message. A name that pays (pay, charge, refund, invoice, checkout, transfer) ismoney. Both are human-only. A tool in no table isask, never allow.
Secrets
No secret value reaches model context. The kernel attaches credentials at the call and masks every tool result before the model sees it.secret.use
A caller names a secret by handle (vault:github-deploy, computer:vault:github-login), a purpose (http_header, env_for_process, connector_call, sign) and a target host or process. The kernel resolves the value only inside the tool execution and hands it to the code that puts it on the wire. The caller never receives it, and no request, response, receipt or log holds it. A value where a handle belongs is refused with bad_request.
The first use of a secret toward a host it has never been used with is secret_new_host, a human-only class. Without a token, the kernel writes a receipt, opens an approval request for that exact use and refuses with approval_required. After a person approves, the retry binds the secret and the kernel records the pair. Later uses toward the same host are allowed without asking, and each one writes a secret_use receipt. A different host is new again.
Hosts are normalised (https://API.GitHub.com:443/x is api.github.com). Known pairs live in kernel_secret_hosts (migration V300), per account and tenant. Rows are written only after a person’s approval. Shadow mode binds a new host with a shadow_would_ask receipt and records nothing.
Computer use_credential follows the same rule. check classifies it as secret_new_host for a new (credential, domain) pair and read for a known one. After an allowed check, computer_v2::execute_v2 records the pair, but only when that check redeemed a person’s token for the same action.
The same call is reachable over HTTP for callers outside the API process, such as Gizzi’s shell and connector runtimes: POST /api/v1/kernel/secrets/use with a SecretUseV1 body. Run and service callers only; a person’s session is refused. The answer holds use_id, bound, redaction_id and receipt_id, never the value. Handles resolve as vault:<name> from the account’s credential vault. A new host answers approval_required with the receipt id and an open request, and the retry carries approval_token.
The redactor
One redactor masks every tool result in allternit-api before it is returned:execute_tool_internal (HTTP, MCP tools/call, routines), dispatch_call (attached MCP servers), MCP tools/call as a whole, the computer toolset, and ACI run frames (scrub_frame, which it replaced). It masks, in order:
- The exact values the kernel attached during the call. These are the account’s vault secrets, a credential bound by
secret.useoruse_credential(keychain, Bitwarden and 1Password included), an MCP server’s credential headers, and this process’s credential-named environment values. Their base64 form is masked too. - Credential-shaped strings: the
sk-,ghp_,gho_,xox?-,AKIA,AIzaandsk_live_prefixes, PEM private key blocks, JWTs, bearer and basic header values, passwords in URLs, and long or mixed values assigned to a key named like a credential (password=,"api_key":,GITHUB_TOKEN=).
[REDACTED]. An approved read of a .env or credential file also masks every assignment value, so the model sees the names and not the values.
Gizzi
Gizzi Code applies the same rules (shared/util/secret-redactor.ts, a port tested against the same vectors) to:
vault_querynote previews, masked before they are cut.vault_writerefuses to save a note that holds a credential.- Bash stdout and stderr, both foreground and background and both local and VM.
- Approved reads of credential paths (
.env, SSH keys,credentials), where every value is masked.
bash.env_passthrough and GIZZI_BASH_ENV_PASSTHROUGH no longer pass a credential-named variable on their own. The bash tool asks the person once for that exact name (an env_secret ask), and a glob never approves one. Paths with no ask, such as the selfhost worker and environment setup, leave it out. An approved value is still masked in the command’s output.
Test vectors
spec/Contracts/os/v1/conformance/redaction-vectors.json holds the shared cases. Each case lists an input, the attached values, the strings that must disappear and the strings that must stay. The Rust tests (authority::redact) and the TS tests (test/util/secret-redactor.test.ts) both read it. A rule change goes into both redactors, with a vector.
Budget
budget.reserve takes an amount before a run spends it, and budget.commit records what it actually spent. The limit is the one that already exists: a bot’s monthly limit, set in the bot’s spend settings (agents.config.spendLimit.monthlyUsd). The kernel adds no second limits store. Its own table, kernel_budget_reservations (migration V310), holds only the reserve and commit ledger.
- Over the limit. A reserve fails with
budget_exceededand a receipt when committed spend plus live reservations this month plus the new amount pass the limit. The refused call reserves nothing. A principal with no limit set, or a currency other than USD, has no limit to pass: the reservation is still recorded and receipted. - Commit below the reservation. The unused remainder is released at once and counts as free again. Commit above the reservation is allowed only if the extra still fits the limit; otherwise
budget_exceededand the reservation stays open. - Retries. A commit repeated with the same
idempotency_keyreturns the same result. A second commit with another key isconflict. A reservation not committed byexpires_atstops counting and is markedexpired. - Receipts. Every reserve, commit, release and refusal writes a
budgetreceipt before the change. - Money. Amounts are decimal strings with up to six decimals. A reservation is not a charge: sending an invoice or taking a payment is still the human-only
moneyclass, andcheckstill needs a person’s token for it.
Leases
computer_control_lease.rs stays the store for who controls a computer (one controller, 120 second TTL, renewed by a heartbeat, a person can take over from an agent). The kernel shows each live control lease as a LeaseV1 and runs lease.acquire, lease.heartbeat and lease.release on it.
GET /api/v1/kernel/leases lists the live leases for your account: those on computers you own (directly or through a bot) and those you hold. It is read-only and writes no receipt. A person’s session or a run of the same account may call it; service, API-key and MCP callers may not.
Acquire needs check_id to name an allow check receipt of your account, else denied. A scope that is not a single computer:<id> is bad_request. A computer already leased is conflict. A person holds a lease as themselves, a run never holds as user. Compute leases (placement, vCPU, memory) are not in this view yet. The old fabric lease client (fabric/os_client.rs) stays behind its unset configuration until they are.
The four depths
The interface is written once and reused unchanged:- Hosted: in process inside the API server. This gives process separation, not privilege separation.
- PID 1: a Rust init process with separate users.
- Own kernel: kernel IPC.
- Hardware: the same calls on dedicated hardware.
See also
Standing tool policies and routine receipts
- Standing Allow. A person’s per-tool Allow in Customize is a standing human decision. The policy lives in the client only, so the client syncs it with
PUT /api/v1/kernel/standing-grants({ "tools": [{ "tool", "policy" }] };allowrecords,askandblockremove). It needs a person’s session proof; machine credentials getperson_required.checkreads the grants for anaskrule only and recordsapproved_by: standing_grant. Money, client_message, deploy, secret_new_host and irreversible actions never read it and always need a fresh token. - Routine receipts. A scheduled routine resolves its owner’s org (else tenant) before it runs a tool, so its receipts land on the owner’s chain and not on
default.