| 1 | # Security and rollouts |
| 2 | |
| 3 | This document describes how the-valley protects the hosts it runs on and the hosts that deploy what |
| 4 | lands on it. It follows the path a change takes, and names the gate at each step and its status. The |
| 5 | components are described in [architecture.md](./architecture.md), and the planned gates live in |
| 6 | [the plan graph](./concepts.md#records-project-storage-the-plan-graph-and-knots) (`valley plan`). |
| 7 | |
| 8 | The document makes three kinds of statement: |
| 9 | |
| 10 | - **Behaviour** is what the code does, cited to the files that do it. It is labelled `implemented` |
| 11 | where needed. A guarantee names the executable check that demonstrates it. A statement with no |
| 12 | named check is unchecked, and says so. |
| 13 | - **A deployment choice** is what a deployment configures or must supply. It is labelled |
| 14 | **deployment choice**, and the code does not enforce it. |
| 15 | - **A gate that is not built** has a design but does not work yet. It is labelled **not built**. |
| 16 | |
| 17 | The main threat is an AI agent acting as the operator. So the gates must hold even when an agent |
| 18 | ignores its instructions. The human act of authority is a touch on a hardware key. An approval gate |
| 19 | that the gated agent can administer is only a setting that agent controls |
| 20 | ([ida-b7025b5](../archive/.the-valley/ideas/ida-b7025b5-human-decisions-are-signed-acts.md)). A gate |
| 21 | counts as done only when a check has shown it refusing what it should refuse |
| 22 | ([oc-9949561](../archive/.the-valley/outcomes/oc-9949561-push-replication.md)). |
| 23 | |
| 24 | ## The path a change takes |
| 25 | |
| 26 | | Step | Gate | Status | |
| 27 | | ---- | ------------------------------------------------- | ----------------- | |
| 28 | | 1 | Agents are not the operator | Deployment choice | |
| 29 | | 2 | Only the operator can file an integration request | Implemented | |
| 30 | | 3 | Filing takes a touch | Not built | |
| 31 | | 4 | Hosts deploy only what the operator signed | Not built | |
| 32 | | 5 | A failed rollout rolls back or holds | Deployment choice | |
| 33 | |
| 34 | ### 1. Agents are not the operator |
| 35 | |
| 36 | Agents must never act with the operator's identity or keys. The-valley names every pusher by its |
| 37 | key, so each agent can have an identity of its own. The deployment keeps the agents apart from the |
| 38 | operator's account, keys and secrets (**deployment choice**). |
| 39 | |
| 40 | - **The boundary.** A deployment runs its agents outside the operator's Unix account, in a boundary |
| 41 | such as a VM with its own kernel. The boundary has no host directory shares and no operator |
| 42 | secrets. An agent is assumed to have root inside the boundary. |
| 43 | - **Their own identities.** Agents push with their own keys under their own principal, with a push |
| 44 | grant and no `approve` grant (**deployment choice**). The hook takes the principal from the key |
| 45 | that logged in (`valleyhook/shell.go`). Like any admitted key, an agent's key can push topic |
| 46 | branches and create attestation refs. No key can create or update a ref named like another ref, |
| 47 | such as a branch whose name begins with `refs/`, because git reads, fetches and pushes to such a |
| 48 | ref in place of a missing one (`implemented`, `valleyhook/policy.go`; checked by `protect-e2e` and |
| 49 | `valleyhook-unit`). The hook accepts an attestation ref only when every note in it verifies under |
| 50 | a known signer (`valleyhook/policy.go`, `valleyhook/attestation.go`). An agent's key can also |
| 51 | create change records, which makes the agent's principal the owner of those changes, and add |
| 52 | versions to them (`valleyhook/record.go`). A record never makes anything land. The integrator |
| 53 | reads records only to refuse a request or to void a withdrawn change's requests |
| 54 | (`integrator/records.go`). Any principal that can create a record can hold back a head by |
| 55 | recording it in a change and unreadying that change. Only an `approve` holder may delete that |
| 56 | record, and deleting it releases the head. |
| 57 | - **Caps.** The deployment caps the boundary's CPU, memory and I/O, so agents cannot starve the |
| 58 | valley host. |
| 59 | - **Egress.** The boundary reaches only what agents need, such as name resolution, ssh to the valley |
| 60 | host and HTTPS to the public internet. Everything else is dropped: private and other |
| 61 | special-purpose address ranges, other ports on the host, and spoofed sources. |
| 62 | - **ssh into the valley host.** From the agents' network, sshd admits only the valley git user, with |
| 63 | no forwarding, TTY or tunnel. The host module's `Match User git` block turns off TCP, agent and |
| 64 | X11 forwarding and tunnels, and leaves stream-local forwarding on (`nix/valley-host.nix`). The |
| 65 | deployment adds `DisableForwarding yes` and `PermitTTY no` to close the rest (see |
| 66 | [Repositories and the git user](./architecture.md#repositories-and-the-git-user)). |
| 67 | - **Tools that follow `main`.** `valley self-update` can keep an agent's `valley` at the tip of |
| 68 | `main`, through the flake's home-manager module (see |
| 69 | [Version and self-update](./architecture.md#version-and-self-update)). It installs only a commit |
| 70 | that has landed, built from the exact commit `git ls-remote` named, once it passes a smoke test. |
| 71 | The valley host and the machine the operator approves from must not run it. Their `valley` stays |
| 72 | at the version their system configuration pins, so a landing never changes the tool that approves |
| 73 | or admits the next change. |
| 74 | |
| 75 | Checks: `ssh-e2e` runs the git user's sshd block behind a real sshd. No check in this repository |
| 76 | exercises a deployment's boundary, caps or egress. A deployment that runs agents needs its own |
| 77 | checks for them, with negative controls that show each forbidden connection refused. |
| 78 | |
| 79 | ### 2. Only the operator can file an integration request |
| 80 | |
| 81 | The push hook refuses an integration-request ref unless the pushing principal holds the `approve` |
| 82 | grant (`valleyhook/policy.go`). The grant is also accepted as `request`: a principal holding either |
| 83 | name holds it (`valleyhook/grants.go`). The principal comes from the key that logged in, and a |
| 84 | client cannot set it (`valleyhook/shell.go`). Checks: `protect-e2e`, `identity-e2e`, and `ssh-e2e`, |
| 85 | which uses test identities, a grant holder and a non-holder, behind a real sshd. |
| 86 | |
| 87 | Who holds the grant is a **deployment choice**. A deployment that gives it to the operator's |
| 88 | principal alone makes the operator the only one who can file. Every key of that principal then holds |
| 89 | the grant. |
| 90 | |
| 91 | The security invariant is the operator's approval: only content the operator approved lands. The |
| 92 | request names the exact head that was approved, and the integrator lands only what a request names |
| 93 | (`integrator/refs.go`). Checks: `integrator-e2e` and `valley-ready`. |
| 94 | |
| 95 | The `restack` grant is the host restacker's, and it files nothing. The hook lets a holder that |
| 96 | neither owns a change nor holds `approve` add exactly one version to the change's record, while the |
| 97 | change is `ready`. The version keeps the branch and title of the active one, and names the holder as |
| 98 | its uploader. A holder may also write restack reports (`refs/the-valley/restack/main/*`). The grant |
| 99 | authorises no other record write, no record delete, and nothing on integration requests |
| 100 | (`valleyhook/record.go`, `valleyhook/report.go`). Checks: `protect-e2e` and `identity-e2e`. |
| 101 | |
| 102 | A `restack` holder is still a named principal, and keeps every ordinary power of one. So a |
| 103 | compromised restacker key can: |
| 104 | |
| 105 | - rewrite or delete unprotected branches; |
| 106 | - add arbitrary versions to other owners' ready changes; |
| 107 | - create and manage its own records, and write valid plan-graph updates; |
| 108 | - publish misleading reports, consume storage, exhaust a record's capacity, or withhold work. |
| 109 | |
| 110 | It cannot write a protected `main`, file, replace or withdraw a request, write an integrator |
| 111 | outcome, or forge a check signature. It can relay evidence someone else signed, as any key can. The |
| 112 | hook proves who uploaded a version and nothing about its content: not that it is a rebase of the old |
| 113 | head, holds only the change's content, keeps its message and author, or sits on `main`. What |
| 114 | protects the operator is approval. A request names the exact head the operator approved, so a |
| 115 | version the restacker added lands only once the operator approves that head. Review compares a |
| 116 | version with its approved version from git objects, and never trusts a report's account of it (see |
| 117 | the architecture's |
| 118 | [Review against the approved version](./architecture.md#review-against-the-approved-version)). |
| 119 | |
| 120 | On a host, the restacker runs as the Unix user `valley-restacker`, whose group is its own |
| 121 | (`nix/valley-host.nix`). That user cannot read or write the served repositories on disk, so it |
| 122 | reaches them only through sshd, as its principal, and every write it makes passes the hook. It holds |
| 123 | no integrator key, no worker key and no signing name, so it cannot sign evidence or a landing. Its |
| 124 | own private key is provisioned outside the Nix store, and systemd hands it to the controller as a |
| 125 | credential. Registering the principal, granting it `restack`, and provisioning the key are the |
| 126 | operator's (**deployment choice**). Check: `restack-host-e2e`. |
| 127 | |
| 128 | Readiness is different. A change record's state is the author's workflow signal, and the integrator |
| 129 | enforces it as closely as refs allow. It does not enforce it atomically. A record written between |
| 130 | the integrator's last read of the records and its move of the target can be missed. That can land a |
| 131 | head the operator approved and the author has since paused. It can never land content the operator |
| 132 | did not approve. The race-free design binds each approval to the record's withdraw generation in a |
| 133 | signed approval statement (**not built**). |
| 134 | |
| 135 | ### 3. Filing takes a touch (not built) |
| 136 | |
| 137 | This gate is **not built**. Its design gives the `approve` grant to hardware keys that need a touch |
| 138 | for every signature, and verifies each filing with `sigverify`. Until it is built, filing a request |
| 139 | needs the operator's principal and no touch. `sigverify` itself is checked by `sigverify-unit` and |
| 140 | `sigverify-e2e`, including a touchless-signature negative test. Enrolling a hardware-backed key is |
| 141 | `implemented`: the registry schema accepts `bound: "hardware"` with an attestation, the identity |
| 142 | renderer verifies the attestation, and it lists qualifying keys in the hardware approval-signers |
| 143 | output. Enforcing a touch when an approval is filed is **not built**. |
| 144 | |
| 145 | ### 4. Hosts deploy only what the operator signed (not built) |
| 146 | |
| 147 | A host that deploys what lands on the valley should activate only a release the operator signed. The |
| 148 | design has each such host verify a signed, sequenced release tag before it activates anything, and |
| 149 | never track `main`. `sigverify` verifies such a tag (`implemented`, checked by `sigverify-unit` and |
| 150 | `sigverify-e2e`). Nothing calls it yet. The deployment supplies the host-side caller, which must |
| 151 | meet [sigverify's caller's contract](../sigverify/README.md#the-callers-contract) (**not built**). |
| 152 | |
| 153 | Until a host verifies signed releases, a host that builds and activates the tip of `main` deploys |
| 154 | whatever lands, without checking who made it (**deployment choice**). Nothing bounds the delay |
| 155 | between a landing and its activation. |
| 156 | |
| 157 | ### 5. A failed rollout rolls back or holds |
| 158 | |
| 159 | The-valley does not deploy the hosts that use what lands. A deployment's own activation step does, |
| 160 | and it must roll back or hold when a rollout fails (**deployment choice**): |
| 161 | |
| 162 | - It checks a new system's health before it keeps the system. |
| 163 | - On a failure, it switches back to the running system. It does not apply the failed revision again |
| 164 | until the operator clears it. |
| 165 | - When it cannot switch back, or a run is interrupted, it holds for the operator. |
| 166 | - A change that needs a reboot is checked after the reboot. When that check fails, the last good |
| 167 | system is staged back for the next boot. |
| 168 | |
| 169 | On the valley host itself, the-valley holds pushes while its own configuration settles. |
| 170 | `valley-init` deletes its converged record before it links the hooks, and `valleyhook shell` refuses |
| 171 | a push while that record does not match the running configuration (`nix/valley-host.nix`, |
| 172 | `valleyhook/shell.go`). The operator can also hold every push with a hold file. Checked by |
| 173 | `init-e2e` and `ssh-e2e` (see |
| 174 | [valley-init and the push hold](./architecture.md#valley-init-and-the-push-hold)). |
| 175 | |
| 176 | ## Threat model |
| 177 | |
| 178 | | Threat | Response | |
| 179 | | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 180 | | 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). | |
| 181 | | 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). | |
| 182 | | 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. | |
| 183 | | 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). | |
| 184 | | 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. | |
| 185 | | A lost hardware key | An offline backup hardware key holds every role (see [Trust roots](#trust-roots)). | |
| 186 | | 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). | |
| 187 | | 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](#who-can-read-a-project)). | |
| 188 | |
| 189 | ## Refs are read by their exact names |
| 190 | |
| 191 | Each program listed below reads a ref by its exact name (`implemented`). `git rev-parse`, and every |
| 192 | git command given a ref name, does not stop at the name it is given. For a missing ref, git tries |
| 193 | other names in turn, among them `refs/tags/<name>` and `refs/heads/<name>`. A branch named |
| 194 | `refs/heads/registry` is stored as `refs/heads/refs/heads/registry`. A program that asked git for a |
| 195 | missing `refs/heads/registry` would read that branch. |
| 196 | |
| 197 | The valley host's hook refuses to create or update a ref named like another ref (`implemented`, |
| 198 | `valleyhook/policy.go`). A host repository can hold one made before the hook refused them, and a |
| 199 | repository the hook does not guard, such as a local clone, can hold one at any time. |
| 200 | |
| 201 | So each of these programs reads a ref once, by its exact name, and from then on reads the object the |
| 202 | ref held. It reads a local ref with `git show-ref`, and a remote one from the `git ls-remote` line |
| 203 | that names it. A missing ref is missing: |
| 204 | |
| 205 | - The identity compiler fails when the instance repository has no registry ref, and the last good |
| 206 | files stay in place (`identity/registry.go`). |
| 207 | - The integrator refuses a request named for a change that has no record. It does not judge a |
| 208 | request whose target is missing, and a withdrawn change does not void such a request. A request |
| 209 | with no memo has none, and the signers publication is written when there is none yet. It reads |
| 210 | evidence through the objects its refs held when it listed them. A request that is gone when the |
| 211 | integrator consumes it is not reported as moved (`integrator/`). |
| 212 | - The integrator reads the floor at `--instance-ref` (`composed/composed.go`). The restacker takes |
| 213 | only the `git ls-remote` line that names that ref exactly (`restack/main.go`). An instance |
| 214 | repository with no such ref has no floor, and the pass is refused. |
| 215 | - The web publisher reads the instance repository's `main`, its project list and its registry ref |
| 216 | with `readaccess.ResolveRef`. It refuses an instance repository with no `main` or no project list. |
| 217 | It reads a project's `main` the same way, at the object it staged |
| 218 | (`web/cmd/valley-web-publish/valley.go`). |
| 219 | - `valley-read-coverage` reads the registry ref, the project list and each project's `main` with |
| 220 | `readaccess.ResolveRef` (`readaccess/cmd/valley-read-coverage/main.go`). |
| 221 | - The check worker reads its own evidence ref exactly, and fetches the floor at the commit the |
| 222 | owning valley's `refs/heads/main` names (`status/worker.go`). `valley ready --stamp` finds no |
| 223 | local branch when the one it names is missing (`status/ready.go`). |
| 224 | - `valley review`, `valley approve` and `valley checks` read `origin/main` and the change's branch |
| 225 | by their exact names (`bin/valley`). approve reads `origin/main` once, and reads the merge base |
| 226 | and both policy layers at that commit. The floor is fetched at the commit the owning valley's |
| 227 | `refs/heads/main` names. A request ref missing on origin is missing, whatever a branch named like |
| 228 | it holds. |
| 229 | |
| 230 | The identity compiler, the integrator and the restacker refuse a configured ref that is not a full |
| 231 | ref name, such as `main`. |
| 232 | |
| 233 | `git push` matches the ref it writes the same way. With `<ref>` missing on origin, a push to `<ref>` |
| 234 | writes a branch named `<ref>` instead, and with both present git refuses the push as ambiguous. |
| 235 | `valley approve` reads origin before it pushes. While origin holds a ref whose name ends in the |
| 236 | request ref's or an evidence ref's name, approve pushes nothing and names that ref (`implemented`). |
| 237 | On the valley host, the hook refuses such a push rather than writing it, because the ref it would |
| 238 | write is named like another ref (`implemented`, `valleyhook/policy.go`). The other programs that |
| 239 | push do not check origin for such a ref before they push (**not built**). |
| 240 | |
| 241 | Checks: `identity-e2e` compiles with `refs/heads/registry` missing and a forged registry at |
| 242 | `refs/heads/refs/heads/registry`, and the compilation fails with the files unchanged. |
| 243 | `integrator-unit`, `restack-unit`, `web-unit`, `readaccess-unit`, `valley-ready` and |
| 244 | `valley-request` each make the ref git would read in place of a missing one, and show that the |
| 245 | program ignores it. `integrator-unit` deletes an evidence ref after the integrator lists it. |
| 246 | `valley-request` approves with a branch on origin named like the request, with a tag named like the |
| 247 | remote-tracking ref of `main` or of a branch that origin lacks, and with an owning valley whose |
| 248 | `main` is missing. It also runs the check worker with a tag named like the worker's own evidence |
| 249 | ref. `protect-e2e` and `valleyhook-unit` check the hook's refusal. |
| 250 | |
| 251 | ## Trust roots |
| 252 | |
| 253 | The operator's trust roots are hardware keys that the deployment supplies (**deployment choice**): |
| 254 | |
| 255 | - **Two hardware keys**, a primary and an offline backup. Each holds every role: an approve key that |
| 256 | needs a touch, and a release signing key that needs a PIN and a touch. No gate uses these keys |
| 257 | yet, because the gates of steps 3 and 4 are **not built**. |
| 258 | - **An offline root for trust-root changes**, such as a Tillitis TKey. `sigverify` has a |
| 259 | `tkey-signer` class for it (`implemented`). Nothing uses one for trust-root changes yet (**not |
| 260 | built**). |
| 261 | |
| 262 | ## What a client trusts to read a landing |
| 263 | |
| 264 | A client decides that a version landed through an integrator merge (`landed-recorded`) by verifying |
| 265 | the integrator's transfer statement. It verifies the statement with a known-signers file and the |
| 266 | integrator's signing name. By default it reads both from the host's publication at |
| 267 | `refs/the-valley/signers` in the instance repository (`implemented`; see |
| 268 | [the signers publication](./architecture.md#the-signers-publication)). |
| 269 | |
| 270 | That publication is project storage, not source. No change, review or check governs it. The client |
| 271 | trusts it for a different reason: only the host's machinery writes it, never a push. The push hook |
| 272 | refuses every push to it (`implemented`, checked by `signers-e2e` and `publish-e2e`). On the host, |
| 273 | the publisher writes it from the file and the name the controllers use (`implemented`, checked by |
| 274 | `signers-e2e`). The integrator can write it too, because the instance repository is group-writable |
| 275 | and the integrator is in that group to land code there (`implemented`, `nix/valley-host.nix`). So a |
| 276 | client that reads it trusts the host's disk, the host's configuration and the integrator. It already |
| 277 | trusts the same host to serve `main`, and the same integrator to decide what lands on it. |
| 278 | |
| 279 | A revocation reaches clients through the publication. Once the registry lets no key sign, the |
| 280 | compiler writes a known-signers file with no key in it, and the host publishes that file. A client |
| 281 | then verifies no transfer statement with the revoked keys (`implemented`, checked by `signers-e2e`). |
| 282 | Two runs of the publisher take turns under a lock, so a run that read the file before a rotation |
| 283 | cannot publish it over a run that read it after (`implemented`, checked by `signers-e2e`). |
| 284 | |
| 285 | The client finds the instance repository through `policy/valley` at `main`'s tip on origin, which is |
| 286 | integrated source. A change that lands a new `policy/valley` points clients at another repository's |
| 287 | publication. A flag or a variable set on the client replaces the publication for the value it gives. |
| 288 | The restacker reads neither the publication nor the variables, only its own flags. |
| 289 | |
| 290 | A wrong publication cannot by itself make a version read `landed-recorded`. That also takes the |
| 291 | integrator's outcome record for the version, saying it landed at the version's head, and no push may |
| 292 | write an outcome record. A wrong publication can make a real landing read `uncertain`. |
| 293 | |
| 294 | ## Who can read a project |
| 295 | |
| 296 | Read access to a project requires two consents ([Read access](./architecture.md#read-access)). A |
| 297 | project's own `policy/read` names the principals allowed to read it. The instance's identity |
| 298 | registry grants principals read access at an `edge-read` boundary, for named projects or for all |
| 299 | projects. Both consents must match, so the project's policy and the instance's registry each hold a |
| 300 | key (`implemented`, `readaccess/access.go`). |
| 301 | |
| 302 | - **`anyone`**, the reader who presents no credential, is authorized at an edge for the projects |
| 303 | whose `policy/read` names `anyone` and which a read grant to `anyone` covers at that destination |
| 304 | (`implemented`). |
| 305 | - **A named principal**, including the operator, is evaluated by the same two-consent rule in |
| 306 | `readaccess/`. However, named grants publish nothing and `valley-web` authenticates no reader |
| 307 | (**not built**), so at the edge a named principal can read only what `anyone` may read. |
| 308 | - **Membership, push access, approval and restacking** grant no read access at the edge. |
| 309 | |
| 310 | Which principals each project's policy names and which grants the registry declares are a |
| 311 | **deployment choice**. |
| 312 | |
| 313 | **What reaches the edge.** A publisher pass includes in its export and bundles only the projects |
| 314 | that both consents captured in that pass authorize `anyone` to read at the destination |
| 315 | (`implemented`, `web/cmd/valley-web-publish/valley.go`). Projects not authorized for `anyone` in |
| 316 | that pass are omitted from the export and bundles it builds. For each exported project, the export |
| 317 | and bundle hold the project's reader view in plaintext: every knot and comment in its plan graph, |
| 318 | its ready changes, and `main` with its history. Once an export is sent to an edge, that edge is the |
| 319 | security boundary for what it holds: its administrators, and any process with access to its storage, |
| 320 | can read all of it. Activating a newer export changes which generation the edge serves. It does not |
| 321 | guarantee that an older generation is deleted: the edge's store keeps a generation that a reader |
| 322 | still holds, or whose deletion failed, until a later sweep removes it (`implemented`, |
| 323 | `web/export/store.go`). So withdrawing a project from what the edge serves is not deleting it from |
| 324 | the edge's storage. A read grant at an `edge-read` boundary is consent to send a project's reader |
| 325 | view to the destination that boundary names. |
| 326 | |
| 327 | **A grant is bound to a project.** A grant that names a specific project binds both its name and its |
| 328 | publication identity, so a new project that reuses an old project's name with a new identity is not |
| 329 | covered by the old grant. A policy is valid only for the project repository it is read from. A |
| 330 | policy or registry that is missing, fails schema validation, or exceeds its size bounds consents to |
| 331 | nothing (`implemented`, `readaccess/read.go`). |
| 332 | |
| 333 | **The registry is read at its ref by that exact name.** The publisher and `valley-read-coverage` |
| 334 | resolve the registry ref with `git show-ref`, which checks that exact full ref name (`implemented`, |
| 335 | `readaccess/read.go`). `git rev-parse` is not used to resolve ref names, because when a ref such as |
| 336 | `refs/heads/registry` is missing it falls back to `refs/heads/refs/heads/registry`, a branch any |
| 337 | pusher can create. Instead, `git show-ref` resolves the ref name to an object ID, `git rev-parse` |
| 338 | peels that object ID to a commit, and all subsequent reads use that commit ID. When the configured |
| 339 | registry ref is not `refs/heads/main`, an instance repository without it has no registry, so every |
| 340 | project is private. An instance repository without `refs/heads/main` is not an instance repository, |
| 341 | so the publisher aborts the pass instead of building an empty export (`implemented`, |
| 342 | `web/cmd/valley-web-publish/valley.go`). The host module rejects a `services.valley.identity.ref` |
| 343 | that is not a full ref name (`implemented`, `nix/valley-host.nix`). |
| 344 | |
| 345 | **SSH fetches ignore read grants.** Read grants govern only web exports. On the valley host, every |
| 346 | SSH key admitted for the git user can fetch every repository (`valleyhook/shell.go`). The git user's |
| 347 | shell gates pushes and leaves fetching open. An admitted key without a principal tag runs as no |
| 348 | principal: its session leaves `VALLEY_PRINCIPAL` unset. It is not `anyone`, which applies only to |
| 349 | unauthenticated edge reads. |
| 350 | |
| 351 | **Withdrawal.** When either consent for `anyone` is withdrawn, the next publisher pass omits the |
| 352 | project from the export it builds. `valley-web-publish` includes the HTTP upload client and |
| 353 | `web/export` includes `Store.Activate` to replace the active generation in a state directory |
| 354 | (`implemented`, `web/export/store.go`), while `valley-web` serves only `GET` and `HEAD` |
| 355 | (`web/server/server.go`) and the receiver's HTTP upload handlers are **not built** (publisher tests |
| 356 | use an `httptest` receiver in `web/cmd/valley-web-publish/publish_test.go`). A pass reads the |
| 357 | instance repository and every project selected by a read grant to `anyone`; if any of those cannot |
| 358 | be read, the pass sends nothing, so a withdrawal waits until they can be read. Projects not selected |
| 359 | by a grant to `anyone` are not read and do not block publication or withdrawal (`implemented`, |
| 360 | `web/cmd/valley-web-publish/read_test.go`). There is no serving expiry: while the valley host cannot |
| 361 | reach the edge, the edge keeps serving what it has. Reaching the edge again does not by itself |
| 362 | complete a withdrawal. A withdrawal takes effect at the edge only when the edge activates an export |
| 363 | that reflects it. The receiver that accepts an upload over HTTP and activates it is **not built**. |
| 364 | An upload can still fail after the host reaches the edge again. The pass then fails, and the |
| 365 | withdrawal waits for a later pass whose export the edge activates |
| 366 | (`web/cmd/valley-web-publish/upload.go`). Unbuilt parts of read access are listed in |
| 367 | [Not deployed or not wired yet](./architecture.md#not-deployed-or-not-wired-yet). |
| 368 | |
| 369 | Checks: `readaccess-unit` reads both consents from real commits under the real schemas, including |
| 370 | policies that redeclare a schema definition and trees with malformed entry names. `web-unit` |
| 371 | verifies that the publisher requires both consents (`TestVisibilityNeedsBothConsents`) and that no |
| 372 | private sentinel appears in any export or bundle (`TestPrivateSentinelsNeverLeave`). Both `web-unit` |
| 373 | (`TestTheRegistryIsReadAtItsRef`) and `readaccess-unit` (`TestRegistryRef`) verify that every |
| 374 | project stays private when the registry ref is missing even if `refs/heads/refs/heads/registry` |
| 375 | grants `anyone` read. `module-eval` rejects a short registry ref. `cue-vet` and `identity-schema` |
| 376 | test both schemas against their rejected examples. |
| 377 | |
| 378 | ## Secrets |
| 379 | |
| 380 | The valley host needs a few secrets, and the deployment provisions each one as a file outside the |
| 381 | Nix store (**deployment choice**; see |
| 382 | [What a deployment supplies](./architecture.md#what-a-deployment-supplies)). They are the |
| 383 | integrator's signing key, the git user's ssh key for mirror pushes, and the backup's credentials. |
| 384 | |
| 385 | A deployment must keep these secrets, and every key that decrypts them, out of agents' reach. Two |
| 386 | properties of encrypted secrets bear on that: |
| 387 | |
| 388 | - A copy of any recipient's private key decrypts every secret encrypted to it, on any machine. When |
| 389 | secrets are encrypted to host keys, each host's key is a software private key that can decrypt |
| 390 | them. |
| 391 | - Old ciphertext stays decryptable by every key it was encrypted to. A secret once encrypted to a |
| 392 | key that agents could read must be replaced with a new secret, not only re-encrypted. |
| 393 | |
| 394 | ## What the operator does |
| 395 | |
| 396 | - Approves changes, with `[a]pprove` in `valley review` or with `valley approve`. Approving a change |
| 397 | files its integration request. This is the only act on this list that a check enforces (step 2). |
| 398 | - Holds the hardware keys and manages the deployment's secrets. |
| 399 | - Signs releases and approves protected path classes, once those gates exist (**not built**). |
| 400 | |
| 401 | ## The autonomy ladder |
| 402 | |
| 403 | Automation grows in deterministic forms, under policy the operator signs. Agents never decide for |
| 404 | themselves when to deploy. |
| 405 | |
| 406 | 1. **Today.** An approved landing on `main` is the gate. A host that deploys from `main` deploys it |
| 407 | on its next run. |
| 408 | 2. **Signed releases** (**not built**). A signed release is the gate, and a landing does not deploy. |
| 409 | One touch and PIN signs a batch. Rollout through canaries, soak and rollback runs unattended. |
| 410 | 3. **A batched cadence.** A scheduled release promotes everything accumulated, and one touch signs |
| 411 | it. |
| 412 | 4. **Approved upstreams.** When a deployment's inputs, the-valley among them, land through |
| 413 | approval-gated integration, a change that only updates those inputs can land when its checks |
| 414 | pass. Those updates still ship through releases. |
| 415 | 5. **A delegated release signer.** A machine key in the release environment, out of agents' reach, |
| 416 | signs releases that touch only declared low-risk path classes. The operator signs that policy |
| 417 | with a touch. Entry criterion: a record of health-gated rollback catching real failures in |
| 418 | production, and a measured count of touches per week. |
| 419 | |
| 420 | ## Residual risks |
| 421 | |
| 422 | - **Agents must not be able to land outside the valley.** If a host deploys from a repository on a |
| 423 | forge, an agent with merge rights there can deploy without an approval. A deployment gives agents' |
| 424 | accounts no merge rights on such a repository. |
| 425 | - **Old secret ciphertext stays decryptable.** A secret encrypted to a key that agents could once |
| 426 | read stays readable with that key, in every copy of the ciphertext, until the secret is rotated. |
| 427 | - **An escape from an agent VM on the valley host reaches the host.** The VM has its own kernel, and |
| 428 | an escape through KVM or the hypervisor reaches the host that runs the valley. |
| 429 | - **Every key of the operator's principal holds `approve`.** Filing needs no touch until step 3 is |
| 430 | built. |
| 431 | - **Check definitions come from the change.** A change can edit the flake check it is judged by |
| 432 | ([bd-eaefe82](../archive/.the-valley/bugs/bd-eaefe82-check-definitions-come-from-the-branch.md)). |
| 433 | - **Hosts must not update from an unsigned branch.** A host that upgrades itself from a branch |
| 434 | without a signature check deploys whatever reaches that branch. When the branch is on a forge |
| 435 | rather than on the valley, no gate in this document applies to it. |
| 436 | - **Readiness is not enforced atomically.** A change paused in the moment before the integrator |
| 437 | moves the target can still land, at the head the operator approved (step 2). |
| 438 | - **Every admitted key can fetch every repository.** Read grants govern web exports alone. Any SSH |
| 439 | key sshd admits for the git user, including an agent's key, can fetch any project on the valley |
| 440 | host. |
| 441 | - **A withdrawal waits on reading the instance and every selected project.** A project leaves the |
| 442 | edge only when a new export is built and activated. A pass that cannot read the instance |
| 443 | repository or any project selected by a read grant to `anyone` sends no export. |
| 444 | - **The bus has no authentication.** Any local process on the valley host can publish events. |
| 445 | Nothing treats an event as authoritative. |
| 446 | - **Listing `integrator` in `protection.writers` opens a push path to `main`.** The integrator moves |
| 447 | `main` on disk and needs no place in `protection.writers`. A deployment that lists `integrator` |
| 448 | there lets any key tagged `integrator` push `main` directly. No declared or registry key may carry |
| 449 | that tag. |