Security model
Wayglass applies Zero Trust to code changes: trust is decided per change, from what the change is, and never granted to an agent as a standing permission. This page lists the mechanisms that make that hold, and the places where it does not hold yet.
For step-by-step failure scenarios, see the FAQ, especially classification evasion and misuse of a trunk token.
Tokens
Section titled “Tokens”All repo access goes through Artifacts repo tokens that the Worker mints for one repo, with an explicit short lifetime.
| Token | Repo | Scope | Lifetime | Who gets it |
|---|---|---|---|---|
| Init token | The new trunk | write | 900 s | wayglass init, once, to push the first commit |
| Fork token | One intent’s fork | write | 900 s | The agent that declared the intent; refreshed on every push, older ones revoked |
| Land token | The trunk | write | 300 s | wayglass land, only for an approved decision whose fork has not moved; revoked as soon as the land is verified or aborted |
| Session fork token | The new fork made by session fork |
write | 900 s | The person or agent forking the session; the source fork’s token is never handed out |
| Trunk read token | The trunk | read | 60 s | Any key: wayglass doctor, sync, clone, and each plain git fetch after clone (through the credential helper) |
| Fork read token | One intent’s fork | read | 300 s | Any key: wayglass diff, clone --intent, and land from a checkout that lacks the approved commit. Every mint is audited as token.read_minted |
So no agent holds a write token for the trunk except for the few seconds a land takes, a fork token works only on its own fork (the trunk refuses it), and only one land per project can hold a trunk token at a time.
The CLI never writes a token to disk. Tokens reach git through GIT_CONFIG_COUNT, GIT_CONFIG_KEY_n and GIT_CONFIG_VALUE_n environment variables as an http.extraHeader, so they appear neither in the remote URL, nor in argv (where ps would show them), nor in .git/config. A checkout made by wayglass clone keeps no token either: it configures wayglass git-credential as the credential helper for that one remote (and resets inherited helpers such as osxkeychain, so no helper is offered the token to store), and the helper mints a fresh read-only token with your Wayglass key each time git asks. The mirror push in land uses your own git credentials, never an Artifacts token.
The Worker itself holds no Cloudflare API token with access to Artifacts; it reaches Artifacts only through its Workers bindings. The one optional API token, CF_EVENTS_API_TOKEN, is limited to Queues › Edit and is used only to subscribe new trunks to push events.
Server-side policy
Section titled “Server-side policy”The decision that counts is made on the Worker, not on the client:
- The Worker reads the fork head from Artifacts, computes the diff itself, and classifies it. The diff covers only what landing would add to the trunk (the fork head against its merge base with the trunk head), so trunk changes merged in by
wayglass syncdo not count; when the Worker cannot prove the merge base it falls back to the fork’s base commit, which classifies more, never less. - It runs the same Go policy evaluator the CLI uses for its preview, compiled to WebAssembly, so the two cannot drift.
- It reads
.wayglass/policy.yamlfrom the trunk’s current head when the change is proposed, never from the fork. Editing the policy in a fork does not change how that fork is judged. The decision records the policy it was made under (policy_commit,policy_sha256), andlandrefuses withpolicy_changedif the trunk’s policy has changed since; the change is then proposed again under the current rules. - Any change under
.wayglass/goes to a person at minimum (builtin:protect-policy). So does a change too large to read in full, and a change judged against a missing or invalid policy file.
What the Worker never takes from the client
Section titled “What the Worker never takes from the client”| The client sends | The Worker uses instead |
|---|---|
| Tags, matched rule, action, reason from the local preview | Its own classification and decision. The client’s preview is stored only for comparison and is never shown on public routes |
| A claimed commit | The fork head it reads from Artifacts; propose fails if they differ |
| A jurisdiction | The jurisdiction of the namespace the project lives in |
| “I landed it” | A check that the trunk now holds exactly the approved commit, or a merge of it touching only the decided paths. A mismatch is recorded as land.mismatch |
No self-approval
Section titled “No self-approval”The agent that declared an intent cannot approve or reject its decision; the Worker refuses with conflict. multi_approve counts distinct approvers. Every verdict needs a reason, and placeholder or rubber-stamp reasons (TODO, n/a, <what you checked>, LGTM, +1 and similar) are refused, because the audit log keeps them forever.
A change policy routed to a person (pending_human from human_approve or multi_approve, and quarantined) can be decided only by a person: the admin key or a human key. An agent key gets needs_human (403; the CLI exits 4). agent_review decisions stay decidable by agent keys other than the author’s. A rule with reviewer: { different_family: true } also refuses an approval from the author’s declared model family (same_family, or family_required when one side declared none).
Only the agent that declared an intent can get a fresh fork token for it, and only that agent or the admin can land it (not_author otherwise, before any trunk token is minted), re-stack it or abandon it (wayglass intent abandon, with a reason). Abandoning revokes the intent’s live fork tokens and refuses new ones; the fork repo is kept. A decision made before an intent was re-stacked becomes superseded and can neither be decided nor landed; the change is proposed again.
Identity
Section titled “Identity”There are three kinds of key:
- The admin key (the Worker secret
WAYGLASS_ADMIN_KEY). It can do everything, including minting keys, and its caller names itself withX-Wayglass-Agent(WAYGLASS_AGENT). It counts as a person. - Agent keys (
wgk_…), minted by the admin withwayglass keys create --agent <name>. Each is bound to one name. A request made with one is recorded under that name on every route; the Worker ignoresX-Wayglass-Agentand any name in the request body, so an agent key cannot approve its own change under another name. The Worker stores only a SHA-256 of each key;wayglass keys revoketakes effect on the next request. Keys minted before kinds existed are agent keys. - Human keys, bound to a name the same way but allowed to decide changes policy routed to a person. The admin mints one with
wayglass keys create --agent <name> --human, or, when the Worker has Cloudflare Access on, a person signs in and the Worker mints one bound to their email that expires after 12 hours (24 at most). Approvals made with an Access key are recorded withidentity_source: access, whichwhyshows as(Access).
Minting and revoking keys is recorded in an append-only key log (GET /v1/keys/events, admin key only). wayglass doctor shows which kind of key you are logged in with and the name it acts as (from GET /v1/whoami).
The audit log
Section titled “The audit log”Every intent, push, overlap, decision, verdict, token issue, land and abort is appended to a per-project log in a Durable Object. There is no route to edit or delete entries; the only deletion is of a whole throwaway project (wayglass project delete, admin key, names matching demo-test-* or eu-demo-test-* only). The same decision record is written into a git note on the landed commit, and why checks each note against the Worker’s record (verified: worker, mismatch or unchecked), because anyone who can push notes could forge one.
Text written by agents (goals, reasons, paths, handoff notes, commit messages) is treated as data everywhere: the Worker refuses control characters in it, the CLI strips terminal escape sequences and bidirectional controls before printing, and review --json and diff --json list the agent-written fields under untrusted.
Known limits
Section titled “Known limits”- The admin key still names itself. Whoever holds it can act as any agent name. Give it only to the person who runs the Worker, and give every agent an agent key and every other person a human key from
wayglass keys create. The self-approval check is only as strong as the keys you hand out. - Agent keys are long-lived and not scoped to a project. A key works on every project on its Worker until it is revoked. There are no short-lived session tokens exchanged for an agent key yet (human keys from an Access sign-in do expire), and minting a key is recorded in the key log, not in any project’s audit log.
- A declared model family is self-reported. A policy rule can require an approver from another model family; the Worker compares the families the author and the approver declared, not ones it can verify.
- Artifacts has no branch protection. Someone with a trunk write token could push something other than the approved change. The Worker detects that after the fact (
land.mismatch, and trunk push events from the event subscription) but cannot prevent it. - Refused calls are not all audited. A land refused with
not_authoris answered, not logged, and so are refusals before a land is reserved; a land refused withpolicy_changedafter it was reserved is logged asland.cancelled.