This document describes how the-valley protects the hosts it runs on and the hosts that deploy what
lands on it. It follows the path a change takes, and names the gate at each step and its status. The
components are described in architecture.md, and the planned gates live in
the plan graph (valley plan).
The document makes three kinds of statement:
implemented
where needed. A guarantee names the executable check that demonstrates it. A statement with no
named check is unchecked, and says so.The main threat is an AI agent acting as the operator. So the gates must hold even when an agent ignores its instructions. The human act of authority is a touch on a hardware key. An approval gate that the gated agent can administer is only a setting that agent controls (ida-b7025b5). A gate counts as done only when a check has shown it refusing what it should refuse (oc-9949561).
| Step | Gate | Status |
|---|---|---|
| 1 | Agents are not the operator | Deployment choice |
| 2 | Only the operator can file an integration request | Implemented |
| 3 | Filing takes a touch | Not built |
| 4 | Hosts deploy only what the operator signed | Not built |
| 5 | A failed rollout rolls back or holds | Deployment choice |
Agents must never act with the operator's identity or keys. The-valley names every pusher by its key, so each agent can have an identity of its own. The deployment keeps the agents apart from the operator's account, keys and secrets (deployment choice).
approve grant (deployment choice). The hook takes the principal from the key
that logged in (valleyhook/shell.go). Like any admitted key, an agent's key can push topic
branches and create attestation refs. No key can create or update a ref named like another ref,
such as a branch whose name begins with refs/, because git reads, fetches and pushes to such a
ref in place of a missing one (implemented, valleyhook/policy.go; checked by protect-e2e and
valleyhook-unit). The hook accepts an attestation ref only when every note in it verifies under
a known signer (valleyhook/policy.go, valleyhook/attestation.go). An agent's key can also
create change records, which makes the agent's principal the owner of those changes, and add
versions to them (valleyhook/record.go). A record never makes anything land. The integrator
reads records only to refuse a request or to void a withdrawn change's requests
(integrator/records.go). Any principal that can create a record can hold back a head by
recording it in a change and unreadying that change. Only an approve holder may delete that
record, and deleting it releases the head.Match User git block turns off TCP, agent and
X11 forwarding and tunnels, and leaves stream-local forwarding on (nix/valley-host.nix). The
deployment adds DisableForwarding yes and PermitTTY no to close the rest (see
Repositories and the git user).main. valley self-update can keep an agent's valley at the tip of
main, through the flake's home-manager module (see
Version and self-update). It installs only a commit
that has landed, built from the exact commit git ls-remote named, once it passes a smoke test.
The valley host and the machine the operator approves from must not run it. Their valley stays
at the version their system configuration pins, so a landing never changes the tool that approves
or admits the next change.Checks: ssh-e2e runs the git user's sshd block behind a real sshd. No check in this repository
exercises a deployment's boundary, caps or egress. A deployment that runs agents needs its own
checks for them, with negative controls that show each forbidden connection refused.
The push hook refuses an integration-request ref unless the pushing principal holds the approve
grant (valleyhook/policy.go). The grant is also accepted as request: a principal holding either
name holds it (valleyhook/grants.go). The principal comes from the key that logged in, and a
client cannot set it (valleyhook/shell.go). Checks: protect-e2e, identity-e2e, and ssh-e2e,
which uses test identities, a grant holder and a non-holder, behind a real sshd.
Who holds the grant is a deployment choice. A deployment that gives it to the operator's principal alone makes the operator the only one who can file. Every key of that principal then holds the grant.
The security invariant is the operator's approval: only content the operator approved lands. The
request names the exact head that was approved, and the integrator lands only what a request names
(integrator/refs.go). Checks: integrator-e2e and valley-ready.
The restack grant is the host restacker's, and it files nothing. The hook lets a holder that
neither owns a change nor holds approve add exactly one version to the change's record, while the
change is ready. The version keeps the branch and title of the active one, and names the holder as
its uploader. A holder may also write restack reports (refs/the-valley/restack/main/*). The grant
authorises no other record write, no record delete, and nothing on integration requests
(valleyhook/record.go, valleyhook/report.go). Checks: protect-e2e and identity-e2e.
A restack holder is still a named principal, and keeps every ordinary power of one. So a
compromised restacker key can:
It cannot write a protected main, file, replace or withdraw a request, write an integrator
outcome, or forge a check signature. It can relay evidence someone else signed, as any key can. The
hook proves who uploaded a version and nothing about its content: not that it is a rebase of the old
head, holds only the change's content, keeps its message and author, or sits on main. What
protects the operator is approval. A request names the exact head the operator approved, so a
version the restacker added lands only once the operator approves that head. Review compares a
version with its approved version from git objects, and never trusts a report's account of it (see
the architecture's
Review against the approved version).
On a host, the restacker runs as the Unix user valley-restacker in its own group
valley-restacker (nix/valley-host.nix). That user has no filesystem access to the served
repositories. It connects to them only over local SSH as its principal, so every write it makes goes
through the hook. It holds no integrator key, no worker key, and no signing name, so it cannot sign
evidence or a landing. Its own private key is provisioned outside the Nix store and passed to the
service by systemd as a credential (LoadCredential). Enrolling the principal, granting it
restack, and provisioning the private key are a deployment choice. Check: restack-host-e2e.
Readiness is different. A change record's state is the author's workflow signal, and the integrator enforces it as closely as refs allow. It does not enforce it atomically. A record written between the integrator's last read of the records and its move of the target can be missed. That can land a head the operator approved and the author has since paused. It can never land content the operator did not approve. The race-free design binds each approval to the record's withdraw generation in a signed approval statement (not built).
This gate is not built. Its design gives the approve grant to hardware keys that need a touch
for every signature, and verifies each filing with sigverify. Until it is built, filing a request
needs the operator's principal and no touch. sigverify itself is checked by sigverify-unit and
sigverify-e2e, including a touchless-signature negative test. Enrolling a hardware-backed key is
implemented: the registry schema accepts bound: "hardware" with an attestation, the identity
renderer verifies the attestation, and it lists qualifying keys in the hardware approval-signers
output. Enforcing a touch when an approval is filed is not built.
A host that deploys what lands on the valley should activate only a release the operator signed. The
design has each such host verify a signed, sequenced release tag before it activates anything, and
never track main. sigverify verifies such a tag (implemented, checked by sigverify-unit and
sigverify-e2e). Nothing calls it yet. The deployment supplies the host-side caller, which must
meet sigverify's caller's contract (not built).
Until a host verifies signed releases, a host that builds and activates the tip of main deploys
whatever lands, without checking who made it (deployment choice). Nothing bounds the delay
between a landing and its activation.
The-valley does not deploy the hosts that use what lands. A deployment's own activation step does, and it must roll back or hold when a rollout fails (deployment choice):
On the valley host itself, the-valley holds pushes while its own configuration settles.
valley-init deletes its converged record before it links the hooks, and valleyhook shell refuses
a push while that record does not match the running configuration (nix/valley-host.nix,
valleyhook/shell.go). The operator can also hold every push with a hold file. Checked by
init-e2e and ssh-e2e (see
valley-init and the push hold).
| Threat | Response |
|---|---|
| An agent acting as the operator | Agents run with their own principals and no operator keys (step 1). The push hook scopes refs by principal (step 2). |
| An interactive coordinator | An agent that directs other agents runs with them, under an agent's principal. Only a verified touch stops an agent that holds a grant, and that gate is not built (step 3). |
| A compromised restacker | Its restack grant adds versions to ready changes and writes reports, never requests. What it adds lands only once the operator approves that head (step 2). Its Unix user reaches the repositories only through the hook. |
| A compromised agent | Assume it runs arbitrary commands inside its boundary. The boundary holds no production secrets and no signing sockets, and its egress is limited (step 1). |
| A broken but honest change | A landing needs a signed statement that each required check passed. A failed activation rolls back or holds (step 5). A human signature does not prove correctness. |
| A lost hardware key | An offline backup hardware key holds every role (see Trust roots). |
| The valley host compromised or down | Hosts that deploy from it keep their current systems. A compromised valley host can move main, so recovery that does not depend on it needs signed releases (step 4). |
| A reader of the edge | Reads from an export only the projects that both consents in that pass authorize anyone to read. A pass omits every other project from the export and bundles it builds (see Who can read a project). |
| A stranger reaching the receiver | The receiver refuses the request as unauthenticated before reading the request body, without taking a request slot. A connection flood can still delay uploads while valley-web keeps serving (see The edge's receiver). |
| A stolen receiver token | The holder can spend the receiver's capacity up to its caps. Serving a new export still requires a manifest signed by the export key (see The edge's receiver). |
Each program listed below reads a ref by its exact name (implemented). git rev-parse, and every
git command given a ref name, does not stop at the name it is given. For a missing ref, git tries
other names in turn, among them refs/tags/<name> and refs/heads/<name>. A branch named
refs/heads/registry is stored as refs/heads/refs/heads/registry. A program that asked git for a
missing refs/heads/registry would read that branch.
The valley host's hook refuses to create or update a ref named like another ref (implemented,
valleyhook/policy.go). A host repository can hold one made before the hook refused them, and a
repository the hook does not guard, such as a local clone, can hold one at any time.
So each of these programs reads a ref once, by its exact name, and from then on reads the object the
ref held. It reads a local ref with git show-ref, and a remote one from the git ls-remote line
that names it. A missing ref is missing:
identity/registry.go).integrator/).--instance-ref (composed/composed.go). The restacker takes
only the git ls-remote line that names that ref exactly (restack/main.go). An instance
repository with no such ref has no floor, and the pass is refused.main, its project list and its registry ref
with readaccess.ResolveRef. It refuses an instance repository with no main or no project list.
It reads a project's main the same way, at the object it staged
(web/cmd/valley-web-publish/valley.go).valley-read-coverage reads the registry ref, the project list and each project's main with
readaccess.ResolveRef (readaccess/cmd/valley-read-coverage/main.go).refs/heads/main names (status/worker.go). valley ready --stamp finds no
local branch when the one it names is missing (status/ready.go).valley review, valley approve and valley checks read origin/main and the change's branch
by their exact names (bin/valley). approve reads origin/main once, and reads the merge base
and both policy layers at that commit. The floor is fetched at the commit the owning valley's
refs/heads/main names. A request ref missing on origin is missing, whatever a branch named like
it holds.The identity compiler, the integrator and the restacker refuse a configured ref that is not a full
ref name, such as main.
git push matches the ref it writes the same way. With <ref> missing on origin, a push to <ref>
writes a branch named <ref> instead, and with both present git refuses the push as ambiguous.
valley approve reads origin before it pushes. While origin holds a ref whose name ends in the
request ref's or an evidence ref's name, approve pushes nothing and names that ref (implemented).
On the valley host, the hook refuses such a push rather than writing it, because the ref it would
write is named like another ref (implemented, valleyhook/policy.go). The other programs that
push do not check origin for such a ref before they push (not built).
Checks: identity-e2e compiles with refs/heads/registry missing and a forged registry at
refs/heads/refs/heads/registry, and the compilation fails with the files unchanged.
integrator-unit, restack-unit, web-unit, readaccess-unit, valley-ready and
valley-request each make the ref git would read in place of a missing one, and show that the
program ignores it. integrator-unit deletes an evidence ref after the integrator lists it.
valley-request approves with a branch on origin named like the request, with a tag named like the
remote-tracking ref of main or of a branch that origin lacks, and with an owning valley whose
main is missing. It also runs the check worker with a tag named like the worker's own evidence
ref. protect-e2e and valleyhook-unit check the hook's refusal.
The operator's trust roots are hardware keys that the deployment supplies (deployment choice):
sigverify has a
tkey-signer class for it (implemented). Nothing uses one for trust-root changes yet (not
built).A client decides that a version landed through an integrator merge (landed-recorded) by verifying
the integrator's transfer statement. It verifies the statement with a known-signers file and the
integrator's signing name. By default it reads both from the host's publication at
refs/the-valley/signers in the instance repository (implemented; see
the signers publication).
That publication is project storage, not source. No change, review or check governs it. The client
trusts it for a different reason: only the host's machinery writes it, never a push. The push hook
refuses every push to it (implemented, checked by signers-e2e and publish-e2e). On the host,
the publisher writes it from the file and the name the controllers use (implemented, checked by
signers-e2e). The integrator can write it too, because the instance repository is group-writable
and the integrator is in that group to land code there (implemented, nix/valley-host.nix). So a
client that reads it trusts the host's disk, the host's configuration and the integrator. It already
trusts the same host to serve main, and the same integrator to decide what lands on it.
A revocation reaches clients through the publication. Once the registry lets no key sign, the
compiler writes a known-signers file with no key in it, and the host publishes that file. A client
then verifies no transfer statement with the revoked keys (implemented, checked by signers-e2e).
Two runs of the publisher take turns under a lock, so a run that read the file before a rotation
cannot publish it over a run that read it after (implemented, checked by signers-e2e).
The client finds the instance repository through policy/valley at main's tip on origin, which is
integrated source. A change that lands a new policy/valley points clients at another repository's
publication. A flag or a variable set on the client replaces the publication for the value it gives.
The restacker reads neither the publication nor the variables, only its own flags.
A wrong publication cannot by itself make a version read landed-recorded. That also takes the
integrator's outcome record for the version, saying it landed at the version's head, and no push may
write an outcome record. A wrong publication can make a real landing read uncertain.
Read access to a project requires two consents (Read access). A
project's own policy/read names the principals allowed to read it. The instance's identity
registry grants principals read access at an edge-read boundary, for named projects or for all
projects. Both consents must match, so the project's policy and the instance's registry each hold a
key (implemented, readaccess/access.go).
anyone, the reader who presents no credential, is authorized at an edge for the projects
whose policy/read names anyone and which a read grant to anyone covers at that destination
(implemented).readaccess/. However, named grants publish nothing and valley-web authenticates no reader
(not built), so at the edge a named principal can read only what anyone may read.Which principals each project's policy names and which grants the registry declares are a deployment choice.
What reaches the edge. A publisher pass includes in its export and bundles only the projects
that both consents captured in that pass authorize anyone to read at the destination
(implemented, web/cmd/valley-web-publish/valley.go). Projects not authorized for anyone in
that pass are omitted from the export and bundles it builds. For each exported project, the export
and bundle hold the project's reader view in plaintext: every knot and comment in its plan graph,
its ready changes, and main with its history. Once an export is sent to an edge, that edge is the
security boundary for what it holds: its administrators, and any process with access to its storage,
can read all of it. Activating a newer export changes which generation the edge serves. It does not
guarantee that an older generation is deleted: the edge's store keeps a generation that a reader
still holds, or whose deletion failed, until a later sweep removes it (implemented,
web/export/store.go). So withdrawing a project from what the edge serves is not deleting it from
the edge's storage. A read grant at an edge-read boundary is consent to send a project's reader
view to the destination that boundary names.
A group places a project; it grants nothing. A project reaches the edge only when the host
declaration also places it in a group, because a project in no group has no web URL. Being in a
group is not a third consent: it can keep a project off the edge, never put one there. The export
carries only the groups of public projects, and only public projects' short aliases, so a group's or
an alias's name says nothing of a private project (implemented, web/export/project.go). The
server knows only what the export holds. A hidden project's URL, under its group, under another
group or under the alias the instance gave it, answers with the same 404 page as a missing one,
byte for byte (implemented, web/server/server.go). A group's alias redirects whatever follows
it, so a URL through the alias redirects alike for a hidden and a missing project, and the target
then answers 404.
A grant is bound to a project. A grant that names a specific project binds both its name and its
publication identity, so a new project that reuses an old project's name with a new identity is not
covered by the old grant. A policy is valid only for the project repository it is read from. A
policy or registry that is missing, fails schema validation, or exceeds its size bounds consents to
nothing (implemented, readaccess/read.go).
The registry is read at its ref by that exact name. The publisher and valley-read-coverage
resolve the registry ref with git show-ref, which checks that exact full ref name (implemented,
readaccess/read.go). git rev-parse is not used to resolve ref names, because when a ref such as
refs/heads/registry is missing it falls back to refs/heads/refs/heads/registry, a branch any
pusher can create. Instead, git show-ref resolves the ref name to an object ID, git rev-parse
peels that object ID to a commit, and all subsequent reads use that commit ID. When the configured
registry ref is not refs/heads/main, an instance repository without it has no registry, so every
project is private. An instance repository without refs/heads/main is not an instance repository,
so the publisher aborts the pass instead of building an empty export (implemented,
web/cmd/valley-web-publish/valley.go). The host module rejects a services.valley.identity.ref
that is not a full ref name (implemented, nix/valley-host.nix).
SSH fetches ignore read grants. Read grants govern only web exports. On the valley host, every
SSH key admitted for the git user can fetch every repository (valleyhook/shell.go). The git user's
shell gates pushes and leaves fetching open. An admitted key without a principal tag runs as no
principal: its session leaves VALLEY_PRINCIPAL unset. It is not anyone, which applies only to
unauthenticated edge reads.
Withdrawal. When either consent for anyone is withdrawn, the next publisher pass omits the
project from the export it builds. valley-web-publish uploads that export, and
valley-web-receive activates it with Store.Activate, which replaces the active generation
(implemented, web/cmd/valley-web-receive/, web/export/store.go). valley-web then serves the
new generation, without the project (implemented, checked by TestPublishesToTheRealReceiver in
web-unit). A pass reads the instance repository and every project selected by a read grant to
anyone; if any of those cannot be read, the pass sends nothing, so a withdrawal waits until they
can be read. Projects not selected by a grant to anyone are not read and do not block publication
or withdrawal (implemented, web/cmd/valley-web-publish/read_test.go). There is no serving
expiry: while the valley host cannot reach the edge, the edge keeps serving what it has. Reaching
the edge again does not by itself complete a withdrawal. A withdrawal takes effect at the edge only
when the edge activates an export that reflects it. An upload can still fail after the host reaches
the edge again. The pass then fails, and the withdrawal waits for a later pass whose export the edge
activates (web/cmd/valley-web-publish/upload.go). Unbuilt parts of read access are listed in
Not deployed or not wired yet.
Checks: readaccess-unit reads both consents from real commits under the real schemas, including
policies that redeclare a schema definition and trees with malformed entry names. web-unit
verifies that the publisher requires both consents (TestVisibilityNeedsBothConsents) and that no
private sentinel appears in any export or bundle (TestPrivateSentinelsNeverLeave). Both web-unit
(TestTheRegistryIsReadAtItsRef) and readaccess-unit (TestRegistryRef) verify that every
project stays private when the registry ref is missing even if refs/heads/refs/heads/registry
grants anyone read. module-eval rejects a short registry ref. cue-vet and identity-schema
test both schemas against their rejected examples.
valley-web-receive accepts uploads from the publisher on the edge, and valley-web serves the
active generation (see The receiver). Two independent checks guard
an upload.
The manifest's signature decides what the edge serves. The receiver stages a manifest only when
it opens under a pinned verifier, names the receiver's instance and destination, and carries a
sequence newer than any accepted sequence (implemented, web/export/manifest.go). It keeps only
bodies whose size and SHA-256 the manifest declares, and activates a generation only when every
bundle passes acceptance (implemented, web/export/body.go, web/export/bundle.go). Only a
holder of the publisher's export key can authorize content for the edge to serve. The bearer token
grants upload access alone.
The token decides who may use the receiver. Every request must carry the bearer token in its
Authorization header. The receiver checks the header before reading the request body and refuses
an unauthenticated request as unauthenticated (implemented,
web/cmd/valley-web-receive/receive.go). A stranger who reaches the receiver cannot trigger
manifest verification, stream a body into staging, or start a commit. A holder of the token without
the export key can spend the receiver's staging and request capacity up to its caps, while what the
edge serves stays signed by the publisher.
The token stays out of the Nix store and out of valley-web's reach. On NixOS, both modules
load the token file as a systemd credential for their own unit from a path outside the Nix store,
and both refuse a store path at evaluation time (implemented, nix/web-publisher.nix,
nix/web-receiver.nix). valley-web runs as a separate user without that credential. The publisher
refuses HTTP redirects, so it sends the token only to the configured receiver URL (implemented,
web/cmd/valley-web-publish/upload.go). Neither program prints the token. Where a container host
stores the token file, and who can read it there, is a deployment choice.
The token stays secret only on an encrypted or private network path. Every upload request carries the token. Whether the publisher reaches the receiver over HTTPS, through a TLS-terminating reverse proxy, or over a private network is a deployment choice. Sending requests over plain HTTP across an untrusted network exposes the token to anyone who can read that network.
valley-web has read-only access to the state directory. It opens the state directory read-only
and writes nothing there (implemented, web/export/store.go). On NixOS its unit mounts the state
directory read-only (implemented, nix/web-receiver.nix). The unit's only writable paths are
temporary: its private /tmp and /var/tmp from PrivateTmp (hidden from other units and removed
when the unit stops) and /dev/shm from PrivateDevices (implemented, nix/web-receiver.nix).
Those temporary paths are separate from the state directory, and the receiver ignores them. A fault
in valley-web, which handles requests from arbitrary readers, reaches neither the staging area nor
the token.
Checks: web-receiver-unit verifies that the receiver refuses requests with no token, a wrong
token, a non-Bearer scheme, or two Authorization headers before staging anything
(TestAnUnauthenticatedRequestIsRefused), answers OPTIONS * with a withheld body immediately on
every connection without reading the body (TestOptionsStarHoldsNoConnection), and refuses stale,
future-dated, foreign-key, and foreign-destination manifests
(TestAManifestIsAdmittedOnlyWhenFresh). web-unit (TestPublishesToTheRealReceiver) verifies
that a pass with a wrong token is refused while the edge keeps serving the active export.
module-eval verifies the credentials and users both modules render and rejects a token path in the
Nix store. web-publisher-e2e verifies in a NixOS VM that the publisher's unit receives the token
as a credential while the token file on disk stays readable by root alone.
The valley host needs a few secrets, and the deployment provisions each one as a file outside the Nix store (deployment choice; see What a deployment supplies). They are the integrator's signing key, the git user's ssh key for mirror pushes, and the backup's credentials.
A deployment must keep these secrets, and every key that decrypts them, out of agents' reach. Two properties of encrypted secrets bear on that:
[a]pprove in valley review or with valley approve. Approving a change
files its integration request. This is the only act on this list that a check enforces (step 2).Automation grows in deterministic forms, under policy the operator signs. Agents never decide for themselves when to deploy.
main is the gate. A host that deploys from main deploys it
on its next run.approve. Filing needs no touch until step 3 is
built.anyone sends no export.integrator in protection.writers opens a push path to main. The integrator moves
main on disk and needs no place in protection.writers. A deployment that lists integrator
there lets any key tagged integrator push main directly. No declared or registry key may carry
that tag.