The operator, 2026-10-18: "a coherent structure and simple language, to make what the-valley is understandable and approachable to new users."
Process: Gemini 4 Argon, as product manager, proposes the readers, a diagnosis, an information architecture, plain drafts of the core concepts, a glossary, a style guide and a phased migration plan (brief: ~/hack/the-valley-reset-2026-10/docs-pm-brief.md, consult thread docs-pm). The coordinator checks it against the code and Astra reviews it; the operator decides the open questions; then Argon writes the slices, one reviewable change each, the newcomer path first.
Comments
contributor2026-10-18 14:05 UTCedited2026-10-29 01:09 UTC by contributor
Revision 1 (docs-pm-argon.md) reviewed by Astra (review-docs-pm-astra.md): structure accepted, drafts overstate guarantees. The operator, 2026-10-18: purpose.md stays the operator's and the README links to concepts until they write it; roadmap deferred work moves to knots, then the file goes; a reference-deployment note names the deployment project, klaus, the valley host and the instance repository; valley help becomes a one-screen summary plus per-verb help. Every slice carries a claim-to-code checklist (implemented, deployment choice, not built), checked by Astra before the operator sees it. Revision 2 in progress (docs-pm-rev2-prompt.md).
contributor2026-10-18 14:20 UTC
Revision 2 (docs-pm-argon-rev2.md): seven documents, six slices each with a claim-to-code checklist; link check folded into prose-format. Slice 1 (link check, README overview, docs/concepts.md) is change rmyw, run 20261018-1420-0e061b08, by Argon via agy; brief docs-slice-1-brief.md. Roadmap items to check against knots before slice 5: section 3.4 of revision 2.
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 3 of 11:
- **CLI reference is maintained twice:** `bin/valley:57-695` and `docs/architecture.md:700-1393` duplicate the description of every CLI verb, flag, and exit code.
- **Deployment status and deferred work are maintained in three places:** `docs/architecture.md:1695-1815`, `docs/security.md:221-265`, and `docs/roadmap.md:11-155`.
---
## 3. Information architecture
We organize the documentation into **seven documents** with distinct altitudes and readers, retire `docs/roadmap.md`, and split `valley help` into a one-screen summary plus `valley help <verb>`.
### 3.1 The document set and reader flow
```mermaid
flowchart LR
README["README.md<br/>(One-screen overview)"]
PURPOSE["docs/purpose.md<br/>(Operator's premise)"]
CONCEPTS["docs/concepts.md<br/>(Domain model & glossary)"]
GUIDE["docs/guide.md<br/>(Role-based journeys)"]
REF["docs/reference.md<br/>(CLI, schemas & wire formats)"]
ARCH["docs/architecture.md<br/>(Design, rationale & checks)"]
SEC["docs/security.md<br/>(Threat model & trust gates)"]
README --> PURPOSE
README --> CONCEPTS
CONCEPTS --> GUIDE
GUIDE --> REF
CONCEPTS --> ARCH
ARCH --> SEC
ARCH --> REF
```
| Document | Primary reader | Purpose |
| :--- | :--- | :--- |
| **`README.md`** | Everyone (Evaluator first) | One-screen overview: what the-valley is, the lifecycle of a change, prerequisites, current limitations, how to view the live plan (`valley plan`), and where to read next. |
| **`docs/purpose.md`** | Evaluator, Operator, Contributor | The operator's goals, governing principles, and ownership boundaries. Left untouched for the operator to write; until written, `README.md` links to `docs/concepts.md` for "why". |
| **`docs/concepts.md`** *(new)* | Evaluator, Newcomer | Plain-language explanation of the five core concept groups (meaning first, git/Nix realization second; code guarantees vs. deployment choices vs. unbuilt features separated) plus the full glossary. |
| **`docs/guide.md`** *(new)* | Author, Operator, Host Admin, Contributor | Step-by-step journeys: client setup, authoring a change, reviewing and approving, planning with knots, recovering from failure, setting up a host from scratch, and contributing to the-valley. |
| **`docs/reference.md`** *(new)* | Author, Operator, Contributor | Exact lookup tables: CLI verbs/flags/exit codes, environment and git config variables, ref namespace rules and size limits, JSON output schemas, record/attestation/transfer schemas, and CUE schemas. |
| **`docs/architecture.md`** | Contributor, Security Auditor | Component design (`valleyhook`, `integrator`, `attest`, `identity`, `status`, `rebase`, `knot`), design rationale, security caveats, invariants, executable flake checks, reference deployment state, and what is not yet wired. |
| **`docs/security.md`** | Operator, Host Admin, Security Auditor | Trust boundaries, threat analysis across the path of a change, rollout gates, and current reference deployment posture. |
*Why combine Getting Started and How-To Guides into one `docs/guide.md`?* For a CLI tool with five distinct roles, splitting "getting started" from "how-to" forces readers to jump between two task documents for the same workflow. A single role-indexed `docs/guide.md` starts with a 2-minute client setup and then gives each role a self-contained section.
### 3.2 Section-level outlines
#### 1. `README.md`
- **What is the-valley** (plain definition + the four steps of a change: propose, mark ready, approve, integrate)
- **A quick tour** (five commands showing the author and operator loop)
- **Prerequisites and current limitations** (Nix, git, SSH, NixOS host; what is not built yet; how to read the live plan with `valley plan` and why a GitHub mirror does not carry it)
- **Where to go next** (links by role)
#### 2. `docs/purpose.md`
- Reserved for the operator. Untouched by this migration.
#### 3. `docs/concepts.md`
- **Why the-valley exists** (coordinating fast authors and deliberate operators without giving every author direct write access to `main`)
- **What the code enforces vs. what a deployment configures** (explicit three-way key: code-enforced, deployment choice, not built)
- **Changes: ready, approved, submitted** (meaning first; then git realization via topic branches, `refs/the-valley/changes/<id>`, and `refs/the-valley/requests/<change>`)
- **Checks and evidence** (policy floor + project narrowing, path classes and `unclassified`, pure vs. effectful checks, signed attestations, evidence transfer and transfer statements)
- **The host, the hook, and the integrator** (how `services.valley` receives pushes, what `valleyhook` enforces, and how the integrator lands approved changes and writes outcome records)
- **Records, project storage, the plan graph, and knots** (why project metadata lives outside `main` under `refs/the-valley/*`, why mirrors and plain clones do not fetch it by default, and how knots form the plan graph)
- **Principals and grants** (SSH identities, static vs. compiled identity configuration, `request` and `restack` grants, and boundaries)
- **Glossary** (alphabetical table of every domain term, one-line plain definition, and link to deeper reference)
#### 4. `docs/guide.md`
- **Client setup** (running `valley` via `nix run`, `valley self-update`, configuring `VALLEY_KNOWN_SIGNERS` and `VALLEY_INTEGRATOR_SIGNER`, shell completions)
- **Authoring a change**
- Creating a change and running required checks locally (`valley checks`)
- Pushing and marking a change ready (`valley ready`, `--stamp` for a brand-new unpushed local commit, or `jj` `change-id` headers)
- Inspecting status and check evidence (`valley status`)
- Revising a change while keeping its Change ID (`Change-Id` trailer, `jj` header, or `--change <id>`)
- Pausing (`valley unready`) and abandoning (`valley withdraw`, including how to immediately revoke an already-approved request vs. waiting for the integrator's next pass)
- Restacking onto a newer `main` (`valley rebase --check`, `valley rebase`)
- **Reviewing and approving changes (Operator)**
- Listing changes awaiting review (`valley pending`) and browsing all recorded changes (`valley changes`)
- Reviewing a change or stack (`valley review <change>`, and incremental review with `--since approved`)
- Approving a change (`valley approve <change>`)
- Watching the integrator (`valley tail`) and auditing past landings (`valley replay`)
- **Planning work with knots**
- Reading the live plan (`valley plan`, `--focus`, `--all`)
- Creating, updating, linking, and closing knots (`valley knot create`, `update`, `show`, `list`, `check`)
- **Recovering from failure**
- Recovering from a `stale` request (base moved; restacking with `valley rebase` and getting re-approval)
- Recovering from a `reject` outcome (merge conflict with `main` or missing/expired check evidence)
- Recovering from a refused push (`valleyhook` errors: protected ref, `.valley-hold`, non-fast-forward or non-owner record push, oversize or malformed record/knot)
- Investigating an `uncertain` landing (`failed` outcome record, consumed request ref without a verified landing on `main`, or unset `VALLEY_KNOWN_SIGNERS` / `VALLEY_INTEGRATOR_SIGNER`)
- **Running a valley host (Administrator)**
- Minimal `valley.cue` and `services.valley` NixOS configuration (and why `examples/hosts/protected.cue` is a test fixture, not a production recipe)
- Initializing repositories (`valley-init`) and bootstrap-seeding the initial `main` commit (`policy/instance/*.cue`, `identity/*.cue`, `policy/valley`, `policy/project/*.cue`)
- Enabling the integrator: provisioning the Ed25519 signing key (`signingKeyFile`), `signingName`, and `instanceProject` vs. `instancePolicy`
- Configuring principals, grants, and trusted signers: identity compilation (`services.valley.identity.enable`) vs. static `authorizedKeys`, `grants`, and `integrator.knownSignersFile`
- Configuring push mirrors: `git` user SSH key, `known_hosts`, and cleaning pre-existing refs before cutover
- Configuring offsite backups (`restic` secrets) and verifying backup and restore (`restic restore` + `git fsck`)
- Using the operator push hold (`${dataDir}/.valley-hold`)
- **Contributing to the-valley**
- Entering the dev shell (`nix develop`)
- Running fast Go unit tests (`go test ./...`)
- Running single Nix flake checks (`nix build .#checks.x86_64-linux.<check>`) and the full suite (`nix flake check`)
- Checking documentation formatting and links (`prose-format`)
#### 5. `docs/reference.md`
- **CLI reference** (every `valley` subcommand, synopsis, flags, arguments, exit codes, and naming rules for Change IDs, handles, branch names, and request names)
- **Environment variables and git config** (`VALLEY_KNOWN_SIGNERS`, `VALLEY_INTEGRATOR_SIGNER`, `VALLEY_FLAKE`, `valley.knownSignersFile`, `valley.integratorSigner`, `SSH_ORIGINAL_COMMAND`)
- **Project storage ref layout and bounds** (table of `refs/heads/*`, `refs/tags/*`, `refs/the-valley/*`, who may write each, object types, and size limits)
- **Wire formats and JSON schemas**
- Change record (`valley-change-record/v1`) and parent-history rules
- Restack report (`valley-restack-report/v1`)
- Attestation note and statement (`the-valley/attestation/v1`) and canonical digest manifests (`valley-tree-v1`, `valley-inputs-v1`, `valley-delta-v1`)
- Integrator transfer statement (`the-valley/integration/transfer/v1`)
- Integrator outcome record (`refs/the-valley/outcomes/<change>`)
- CLI JSON outputs (`valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, `valley knot --json`)
- **CUE configuration schemas** (`schema/valley.cue`, `schema/verification.cue`, `schema/attestation.cue`, `schema/identity.cue`)
#### 6. `docs/architecture.md`
- **Reference deployment note** (the deployment project, klaus, the valley host, the instance repository)
- **System overview** (end-to-end component diagram and trust boundaries)
- **The Git host and `valleyhook`** (SSH forced command, push hold, ref-by-ref enforcement invariants, record/report/knot validation, post-receive mirror trigger, offsite backup service)
- **Verification policy and attestations** (two-layer CUE unification, monotonic narrowing, path classification and `unclassified`, `attest` binary, pure vs. effectful check execution, content-addressed note storage)
- **The integrator** (reconciliation loop, fast-forward vs. `git merge-tree` single-parent commit landing, evidence transfer rules, transfer statements and countersignatures, pre-commit readiness re-check and its narrow race window, outcome records, withdrawn-change request cleanup)
- **Change lifecycle and review invariants** (`status/`, `rebase/`, `change/`: landing states `landed` / `landed-recorded` / `uncertain` / `not-landed`, `approvedVersion` resolution and non-fallback rule, restack safety gate, self-update integrity)
- **The plan graph (`knot/`)** (data model, independent cycle checks on local `parent` and local `blocked_by` edges, syntax-only cross-project `blocked_by`, CAS retry loop)
- **Identity compilation (`identity/`)** (two-stage CUE + Go pipeline, governance orphan check on `registry` boundaries, atomic output publishing)
- **Executable verification table** (mapping every architectural guarantee to its Nix flake check in `nix/checks/`)
- **How the deployment project deploys it** (current reference deployment state)
- **What is in the repo vs. not yet wired** (honest inventory of built components vs. unbuilt automation)
#### 7. `docs/security.md`
- **Reference deployment note** (the deployment project, klaus, the valley host, the instance repository)
- Unchanged in structure: threat model along the path of a change, rollout gates, and current deployment posture, with its retired `roadmap.md` link removed.
### 3.3 Where existing `docs/architecture.md` content goes and anchor audit
Every section of `docs/architecture.md` is accounted for. Design rationale and security caveats stay in `docs/architecture.md`:
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 1 of 11:
# Proposal: Product-Managing the-valley's Documentation (Revision 2)
the-valley's documentation serves five readers: evaluators deciding whether to adopt it, authors (human or agent) proposing changes, operators reviewing and approving work, administrators running a valley host, and contributors changing the platform itself.
Today, one 1,815-line file (`architecture.md`) and one 639-line `usage()` block (`bin/valley`) carry concepts, CLI usage, wire schemas, host administration, and component internals together. A newcomer encounters git ref namespaces and cryptographic note formats before learning what a change is or how to run one command.
This proposal restructures the documentation into **seven documents**: `README.md` (overview), `docs/purpose.md` (the operator's premise), `docs/concepts.md` (domain model and glossary), `docs/guide.md` (role-based journeys), `docs/reference.md` (CLI, schemas, and wire contracts), `docs/architecture.md` (component design, rationale, and executable checks), and `docs/security.md` (threat model and rollout gates). `docs/roadmap.md` is retired after verifying its open items in the plan graph.
Migration happens in six self-contained slices. Slice 1 adds a Markdown link-and-anchor check, rewrites `README.md` as a one-screen overview, and creates `docs/concepts.md`.
---
## Changes from revision 1
- **Verified and applied all 22 points in Astra's code review** across the overview, concept drafts, glossary, and slice checklists. Every point in Astra's review held up against HEAD.
- **Separated three kinds of claim everywhere:** (1) what the-valley's code enforces (`implemented`), (2) what a deployment chooses through configuration (`deployment choice`), and (3) what is not built yet (`not built`).
- **Reframed concepts by meaning first,** followed by how git and Nix realize them today, and removed all comparisons to GitHub or other platforms from the overview and concept drafts.
- **Rewrote the `README.md` draft to fit on one screen,** adding prerequisites, current limitations, a link to `docs/concepts.md` until `docs/purpose.md` is written, and a note explaining that the live plan lives in `valley plan` and is not carried by push mirrors.
- **Fixed the document count to seven** and added the three missing journeys to `docs/guide.md`: setting up a host from scratch (bootstrap seeding, integrator keys, trusted signers, mirrors, backup/restore verification), contributor setup and testing, and recovering from failure (stale requests, refused pushes, uncertain landings, conflicts).
- **Made every slice self-contained** so each links only to files and anchors that exist when it lands; split reference extraction (Slice 3) from slimming `docs/architecture.md` (Slice 4) with a full anchor audit; added a Markdown link-and-anchor check in Slice 1; added a `valley help <verb>` split in Slice 6; and added a Claim-to-Code Checklist to the style guide and every slice.
- **Applied the operator's decisions** on `docs/purpose.md`, the item-by-item `docs/roadmap.md` knot inventory, and the reference deployment framing note (the deployment project, klaus, the valley host, the instance repository).
---
## 1. Who the docs are for
Five readers use these docs. Each arrives with a different first job.
### 1.1 The evaluator
- **Who they are:** An engineer or team lead deciding whether to adopt the-valley for human-and-agent software delivery.
- **What they need first:** A plain statement of what the-valley does, what it requires (Nix, git, SSH, and a NixOS host for the server), what is built vs. not yet built, and how to inspect the project's live plan (`valley plan`, and why a GitHub push mirror does not carry it).
- **First journey:** Read `README.md` in two minutes, then read `docs/concepts.md` (and `docs/purpose.md` once written) to see how changes, readiness, approvals, checks, and the plan graph fit together.
### 1.2 The author (person or agent)
- **Who they are:** A developer or autonomous agent writing code, running checks, proposing changes, and updating the plan graph.
- **What they need first:** How to install or run the `valley` CLI, push a topic branch, mark a change ready (`valley ready`), check its state (`valley status`), restack when `main` moves (`valley rebase`), recover from a stale request or refused push, and record knots (`valley knot`).
- **First journey:** Follow **"Client setup"** and **"Authoring a change"** in `docs/guide.md` to take one change from a local commit to `ready`, inspect its required checks with `valley status`, and recover cleanly when a request goes stale or conflicts (`docs/guide.md#recovering-from-failure`).
### 1.3 The operator (approver)
- **Who they are:** A principal holding the `request` grant (in a typical deployment, the human operator) who reviews ready changes, approves them to land on `main`, and curates the plan graph.
- **What they need first:** How to list changes awaiting review (`valley pending`), inspect a diff (`valley review <change>` — including incremental review against a previously approved version when a change is revised), approve a change (`valley approve <change>`), watch the integrator (`valley tail` / `valley replay`), and handle an uncertain or rejected landing.
- **First journey:** Follow **"Reviewing and approving changes"** in `docs/guide.md`: run `valley pending`, review a ready change with `valley review <handle>`, approve it with `valley approve <handle>`, and watch it land with `valley tail`.
### 1.4 The host administrator
- **Who they are:** A systems engineer deploying `services.valley` on a NixOS machine, configuring repositories, keys, grants, the integrator, push mirrors, and offsite backups.
- **What they need first:** A complete recipe for standing up a real host from scratch: writing `valley.cue` and the `services.valley` NixOS configuration, seeding the initial `main` commit before or around protection, provisioning the integrator's Ed25519 signing key and trusted signers (`identity.enable` or static `knownSignersFile`), configuring push mirror SSH credentials, and verifying offsite `restic` backups and restores.
- **First journey:** Follow **"Running a valley host"** in `docs/guide.md` to bootstrap an instance repository and a protected project repository on NixOS, enable the integrator, and verify that a test change lands and backs up cleanly.
### 1.5 The contributor to the-valley
- **Who they are:** An engineer or agent modifying `valleyhook/`, `integrator/`, `status/`, `rebase/`, `knot/`, `attest/`, `identity/`, `bin/valley`, or `nix/valley-host.nix`.
- **What they need first:** How to enter the dev shell (`nix develop`), run fast Go package tests (`go test ./...`), run single VM or sandbox checks (`nix build .#checks.<system>.<name>`), run the full check suite (`nix flake check`), verify documentation formatting and links (`prose-format`), and look up wire schemas and component invariants.
- **First journey:** Follow **"Contributing to the-valley"** in `docs/guide.md`, look up wire contracts in `docs/reference.md`, and check design rationale and test coverage in `docs/architecture.md` and `AGENTS.md`.
---
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 2 of 11:
## 2. Diagnosis of the current docset
The existing documentation is accurate and well-tested against the code. Its core problem is **altitude compression**: almost everything lives in `docs/architecture.md` (1,815 lines) and `bin/valley` (639 lines of help output), written from the perspective of the builders who implemented the system.
### 2.1 Structure and order
- **`README.md` skips what a user does.** Lines 1–75 explain the motivation for agent-first software engineering, and lines 77–93 list links. It never states what commands exist, what prerequisites are needed, what limitations apply today, or how a change moves from an author's commit to `main`.
- **`docs/purpose.md` is a three-line placeholder** (`# Purpose`, `What is the purpose of the-valley?`), yet `README.md` sends newcomers there first for "goals, governing principles, and ownership boundaries."
- **`docs/architecture.md` mixes four altitudes in one file:**
1. Host internals and ref layout (`lines 20–423`, `1394–1694`).
2. Wire schemas and JSON contracts (`lines 424–699`, `829–883`, `903–929`, `942–989`, `1027–1119`, `1216–1294`).
3. End-user CLI manual (`lines 700–1393`).
4. Fleet-specific operational state (`lines 1695–1815`).
A reader looking for how to propose or review a change must scroll past 700 lines of pre-receive hook rules, CUE policy evaluation, and knot JSON schemas before reaching `## The valley CLI` at `docs/architecture.md:700`.
- **`docs/roadmap.md` contradicts the project's own rule.** `docs/architecture.md:652` states that a project's live plan lives in `refs/the-valley/knots` (`valley plan`), yet `docs/roadmap.md` maintains a parallel prose tracker of milestones (`M0-H`, `M1`–`M7`) and open questions (`lines 144–155`).
### 2.2 Jargon used before it is defined
Across `docs/architecture.md` and `docs/security.md`, domain terms appear hundreds of lines before their definitions:
| Term | First used | Defined at | Gap |
| :--- | :--- | :--- | :--- |
| **Instance** / **instance floor** | `docs/architecture.md:7` ("instance floor (the instance repository)") | `docs/architecture.md:190` | 183 lines; The instance repository is named at line 7 before "instance" is defined |
| **Project storage** | `docs/architecture.md:31` (diagram) | `docs/architecture.md:77-90` | Shown as git ref namespaces before explaining why metadata lives outside the source tree |
| **Principal** & **grants** (`request`, `restack`) | `docs/architecture.md:57-74` | `docs/architecture.md:107-122`, `1394-1534` | Used in the ref table before explaining how SSH keys map to principals |
| **Change record**, **active version**, **ready / draft / withdrawn** | `docs/architecture.md:61` | `docs/architecture.md:424-510` | 363 lines; introduced as a ref path and JSON schema rather than a user concept |
| **Integration request** & **outcome record** | `docs/architecture.md:64-68` | `docs/architecture.md:332-406`, `807-828` | Readers meet `refs/the-valley/requests/<change>` at line 64 and only learn at line 807 that `valley approve` writes it |
| **Attestation**, `valley-tree-v1`, **transfer statement** | `docs/architecture.md:62` | `docs/architecture.md:274-330`, `367-379` | `valley-tree-v1` is used at lines 62 and 279; its canonical manifest format lives only in `attest/digest.go:5-18` |
| **Knot** (`work`, `gate`, `question`, `finding`, `direction`, `milestone`) | `docs/architecture.md:63` | `docs/architecture.md:650-698` | 587 lines between first mention in the ref table and definition |
| **Handle** vs. **Change ID** | `docs/architecture.md:721` | `docs/architecture.md:1306-1312` | 585 lines between first CLI example using `<change>` and the rule for shortest unique prefixes (`k`–`z`, at least 4 letters) |
| **Approved version** (`approvedVersion`) | `docs/architecture.md:505` | `docs/architecture.md:1005-1025` | Referenced at line 505 and explained 500 lines later |
| **Fleet hostnames** (the deployment project, the instance repository, the valley host, klaus, a workstation) | `docs/architecture.md:6-10`, `docs/security.md:7-16` | `docs/architecture.md:1695-1715` | External readers meet four internal machine/repo names in the first paragraph before learning they belong to the reference deployment |
### 2.3 Mechanism shown before purpose
- **Changes are introduced as JSON blobs under git refs.** At `docs/architecture.md:424-465`, a change is introduced as `refs/the-valley/changes/<id>` with its JSON schema (`valley-change-record/v1`) and parent-history rules (`P = [h]`, `P = [old]`) before the reader is told what a change is or why `valley ready` exists.
- **Approval is introduced as a git ref write.** At `docs/architecture.md:64-66`, the reader learns about `refs/the-valley/requests/<change>` as a hook-guarded ref rather than learning that approval binds a specific reviewed commit so the integrator can verify and land it.
- **`bin/valley help` is a 639-line wall of text.** Running `valley help` prints every flag, JSON schema note, and knot subcommand (`bin/valley:57-695`). Only `valley help knot` (`bin/valley:698-714`) has per-verb help.
### 2.4 Missing tasks
A newcomer cannot find step-by-step instructions for:
1. **End-to-end authoring:** Creating a topic branch, running `valley checks`, pushing, marking `ready` (with or without `--stamp` or `jj`), revising after review while preserving the Change ID, and seeing when a change has landed.
2. **End-to-end reviewing and approving:** Listing ready changes (`valley pending`), reviewing a change or stack (`valley review`), incremental review after a revision (`--since approved`), approving (`valley approve`), and tailing the integrator (`valley tail`).
3. **Recovering from failure:** What to do when an integration request goes `stale` (`valley rebase`), when `valleyhook` refuses a push, when `valley status` or `valley rebase` reports an `uncertain` landing (`failed` outcome or missing signer env vars), or when a change is `reject`ed on a merge conflict or failed check.
4. **Standing up a valley host from scratch:** `examples/hosts/protected.cue` is a test fixture for `protect-e2e` exercising four protection configurations (`sealed`, `guarded`, `released`, `open`), not a minimal host setup. No doc walks through bootstrap-seeding `main` in a freshly initialized bare repo (`valley-init`), provisioning the integrator's Ed25519 key and trusted signers, wiring push mirror SSH credentials, and verifying offsite `restic` backups and restores.
5. **Contributor setup and local testing:** Entering `nix develop`, running fast Go unit tests vs. Nix sandbox checks, and checking documentation formatting and links.
### 2.5 Duplication
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 7 of 11:
Knots connect through `parent` edges, `blocked_by` edges (within the project or `<project>:<id>` across projects), `related` links, and `changes` links. Local `parent` edges and local `blocked_by` edges are each checked separately for cycles — so a milestone may be `blocked_by` one of its own child knots — while cross-project `blocked_by` references are checked for syntax only (`knot/graph.go:376-470`).
*How git realizes this today:* Project storage lives under `refs/the-valley/*`, and knots live as `<id>.json` files in a commit tree at `refs/the-valley/knots`. Because a plain `git clone` fetches only `refs/heads/*` and `refs/tags/*`, and push mirrors (such as GitHub) receive only `main` and tags (`nix/valley-host.nix:252-260`), a mirror does not carry the plan graph or change records; running `valley plan` or `valley status` against a valley host clone fetches `refs/the-valley/*` directly.
#### Principals and grants
A **principal** is a named actor — a human or an agent — authenticated by an SSH key when pushing over SSH, or identified by a cryptographic signing key when verifying check attestations. When an SSH key is tagged with a principal name in `authorized_keys`, the host passes that name to `valleyhook`; an untagged key in `services.valley.authorizedKeys` can still push to open topic branches and attestations as an anonymous pusher, but cannot write change records, restack reports, or requests (`nix/valley-host.nix:506-507`, `valleyhook/record.go:160-163`). A **grant** is a capability assigned to a principal at a named **boundary**. Two grants govern `valleyhook` today:
- **`request`** — allows a principal to write or delete integration requests (`refs/the-valley/requests/*`), update any change record, and delete change records (`valleyhook/policy.go:151-158`, `valleyhook/record.go:194-198`). Who holds `request` is a **deployment choice** (for example, in the reference deployment only the human operator holds `request`).
- **`restack`** — allows a principal to push restack reports (`refs/the-valley/restack-reports/*`) and add a single restacked version to another owner's `ready` change while keeping its active branch and title (`valleyhook/policy.go:165-169`, `valleyhook/record.go:268-272`). (The restack report schema, hook validation, and CLI display are implemented; the automatic restacker service itself is **not built yet**.)
*How Nix and CUE realize this today:* A host can declare keys, grants, and trusted signers statically in NixOS (`services.valley.authorizedKeys`, `services.valley.grants`, `services.valley.integrator.knownSignersFile`), or enable `services.valley.identity.enable` to compile them on a timer from `identity/*.cue` in the instance repository into `/var/lib/valley-identity/` alongside any static entries (`nix/valley-host.nix:624-635`, `1449-1455`). In `identity/*.cue`, a third boundary kind (`registry`) is checked at compile time only to ensure at least one unexpired principal holds a grant there (`governanceOrphaned`; `identity/render.go:104`, `138-143`); neither `valleyhook` nor the integrator enforces `registry` grants on pushes or landings.
---
### 4.2 Draft: One-screen `README.md` overview
```markdown
# the-valley
the-valley is a software change, verification, and planning system for teams where humans and autonomous agents build together. Like a valley, it is the low place where streams of work meet and settle into `main`.
## How a change moves
1. **Author** — A person or agent commits work on a topic branch, runs the checks the change requires (`valley checks`), and marks the change **ready** (`valley ready`).
2. **Review** — An operator inspects ready changes (`valley pending`, `valley review <change>`). If a change was revised after an earlier approval, `valley review` can show only the delta since the approved version (`--since approved`).
3. **Approve** — A principal holding the `request` grant approves the change (`valley approve <change>`), binding that exact commit for integration.
4. **Integrate** — When the host's integrator is enabled and `main` is protected, the integrator verifies signed check evidence against the two-layer CUE policy (instance floor + optional project policy), merges the change into `main`, countersigns the evidence with a transfer statement, and writes an outcome record (`land`, `stale`, `reject`, or `failed`).
## Quick tour
```sh
valley plan # view the live plan graph (knots)
valley checks # list or run checks required for your diff
valley ready --stamp # stamp a Change-Id, push, and mark v1 ready
valley pending # list ready changes and what each awaits
valley review kqxm # inspect the diff (and interactively approve)
```
## Prerequisites and current limitations
- **Prerequisites:** `git`, `ssh`, and `nix` (with flakes enabled) on the client; a NixOS host running `services.valley` on the server.
- **Configuration vs. guarantees:** Sealing `main` against direct SSH pushes, restricting who holds the `request` grant, and enabling the integrator or identity compiler are host configuration choices in `valley.cue` and `services.valley`.
- **Not built yet:** Automatic host restacking (`restack` reports are validated and displayed, but authors restack manually with `valley rebase`), automatic approval carry across restacks, hardware-key (`sk-*`) touch-bound approval envelopes, and crash-safe atomic multi-ref landing transactions.
- **Finding the live plan:** The project's roadmap and open questions live in the plan graph (`refs/the-valley/knots`), viewed by running `valley plan` against a clone of the valley host. Push mirrors (such as GitHub) receive only `main` and tags, so a mirror clone does not carry the plan graph or change records.
## Documentation
- **[Concepts and glossary](./docs/concepts.md)** — Why the-valley is shaped this way, core concepts, and every term defined.
- **[Architecture](./docs/architecture.md)** — Component design, verification policy, identity compilation, and executable checks.
- **[Security](./docs/security.md)** — Threat model, trust boundaries, and rollout gates.
- **[Archive](./archive/)** and **[Research](./research/)** — Historical design exploration (`dcr-*`, `ida-*`, `bd-*`, `oc-*`) and foundational notes.
```
*(Note: In Slice 1, `README.md` links only to files that exist when Slice 1 lands. Slices 2 and 3 add links to `docs/guide.md` and `docs/reference.md`, and once the operator writes `docs/purpose.md`, a link to `docs/purpose.md` is added at the top of the Documentation list.)*
---
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 5 of 11:
1. **M0-H residual — Credential rotation** (`docs/roadmap.md:31-32`, `129-130`): Rotate secrets whose old ciphertext remains in the deployment project's git history, starting with the integrator's signing key.
2. **M1-B / M1-C — Signed release promotion (`sigverify` wiring)** (`docs/roadmap.md:18`, `73-76`): Wire `sigverify` into the pull tool so converging hosts verify hardware-key-signed (`ssh:<project>-release`) sequenced release tags against their running trust root, refuse replays/downgrades, ignore unsigned `main`, and cover or retire `system.autoUpgrade` (on two hosts) and work profiles.
3. **M1-C — Touch-gated human approvals** (`docs/roadmap.md:18`, `77-86`): Extend `schema/identity.cue` and `identity/` for hardware-backed (`sk-*`) keys, move the `request` grant to `ssh:valley-approve` hardware keys, build a Go `valley approve` signing `{repo, change, candidate commit, target, policy snapshot}` with batching and withdraw-generation binding, and enforce per-path-class approvals in the integrator.
4. **M5 — the deployment project on the valley** (`docs/roadmap.md:17`, `56-67`; blocks closing an agent account's GitHub merge path to the deployment project): Host the deployment project on the-valley with GitHub as a push mirror, addressing GitHub bots on a mirror (`ida-62a7a3b`) and per-repo GitHub deploy keys (`ida-a0e5d03`).
5. **M6 — `klaus` on the valley** (`docs/roadmap.md:19`, `88-98`; depends on M5 and M1-C): Move the `klaus` pipeline out of the dashboard into a persistent daemon with per-change/session/backend budgets, a valley backend filing changes with `Change-Id` and `Klaus-Run` trailers and checkpointing paused runs to valley refs, and event instrumentation.
6. **M7 — Throughput and research** (`docs/roadmap.md:20`, `100-108`; depends on M6 instrumentation): Measure wall-clock stage timings first, then test a hybrid speculative queue with evidence reuse and run land-then-verify (with automatic revert) and stacked-change experiments on low-risk path classes.
7. **M2 — Real builds, binary cache, promotion, and canaries** (`docs/roadmap.md:22`, `112-115`): Isolate CI runners with CPU/memory caps, build every converging host in CI (including `aarch64` Pis), serve a Harmonia binary cache on the valley host, run the promotion tool in the release environment, add role canaries/soak periods, and place `/srv/git` on its own dataset of a snapshotting filesystem with snapshots.
8. **M4 — the-valley's refocus** (`docs/roadmap.md:22`, `116-125`): Make landings crash-safe via a single ref transaction with write-ahead intent and an append-only ledger ref; include instance policy and registry snapshot in the reconciliation memo; move check execution out of the integrator into workers; produce check evidence before human review; drop effectful validity windows and closure-transfer machinery; consolidate `bin/valley`, `integrator/`, `identity/`, and `attest/` into one Go binary; and replace custom `sumdb/note` attestations with SSHSIG verified by `sigverify`.
9. **Valley identity follow-ups** (`docs/roadmap.md:126-128`): Bump the instance repository's `the-valley` pin, trigger identity compilation immediately when the instance repository lands a change (in addition to the 5-minute timer), and stop the static bootstrap key for a principal from outliving its registry expiry.
10. **Deliberately deferred directions** (`docs/roadmap.md:132-143`): Capability-style delegation chains (`ida-a8243d2`), approving broad intent as a delegation contract, speculative integration before measurement, custom non-git/"no `main`" change API, self-hosted web forge, and agent-environment fulfillment engine.
11. **Five open decisions (`question` knots)** (`docs/roadmap.md:144-155`):
- *Release environment (`146-148`):* Where release builds are verified and signed outside the valley host's root authority (a workstation without agents, a dedicated small machine, or a release-only laptop).
- *Touch budget (`149-150`):* Which path classes in the deployment project and `the-valley` require human approval, and how approvals batch across integration and promotion.
- *Work-profile switch (`151`):* Whether to keep the work-profile switch paused or bring it under signed promotion.
- *Phase 2 release manifests (`152-153`):* When releases pin exact closures signed off the valley host so the binary cache becomes untrusted transport.
- *Agent guest memory size (`154-155`):* Raising or offloading the 10–12 GiB agent guest limit so agents can run `nix flake check` on the deployment project.
---
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 4 of 11:
| `docs/architecture.md` lines | Current section | Destination |
| :--- | :--- | :--- |
| `1–19` | Intro & reference deployment framing | **`docs/architecture.md`** (with explicit reference deployment note) |
| `20–53` | `## The Git host` & component diagram | **`docs/architecture.md`** (overview diagram also adapted for `docs/concepts.md`) |
| `54–76` | Ref namespace table | **`docs/reference.md`** (full table); summarized in **`docs/architecture.md`** |
| `77–90` | `### The source and project storage` | **`docs/concepts.md`** (concept) + **`docs/architecture.md#the-source-and-project-storage`** (architectural rationale kept with anchor intact) |
| `91–187` | `### What a push may write` & `### valley-init and the push hold` | **`docs/architecture.md`** (invariants, rationale, and checks stay; operational commands also covered in `docs/guide.md`) |
| `188–331` | `## Verification policy` & `## Check attestations` | **`docs/concepts.md`** (high-level model), **`docs/reference.md`** (statement/note schemas & `valley-tree-v1`), **`docs/architecture.md`** (CUE unification, monotonic narrowing rationale, check table) |
| `332–406` | `## The integrator` | **`docs/architecture.md#the-integrator`** (all reconciliation, transfer, race-window caveats, and check tables stay) |
| `407–423` | `## Push mirrors` & `## Offsite backup` | **`docs/architecture.md`** (design & caveats) + **`docs/guide.md`** (admin setup & restore verification) |
| `424–649` | `## Change records` & `## Restack reports` | **`docs/reference.md`** (JSON schemas & field tables); **`docs/architecture.md#change-records`** and **`#restack-reports`** keep the hook validation invariants, lineage rationale, and flake checks |
| `650–699` | `## The plan graph` | **`docs/concepts.md`** (overview), **`docs/reference.md`** (knot schema), **`docs/architecture.md#the-plan-graph`** (validation, cycle rules, CAS design) |
| `700–719` | `## The valley CLI` & `### Version and self-update` | **`docs/guide.md`** (usage), **`docs/reference.md`** (flags), **`docs/architecture.md#version-and-self-update`** (pinned store-path / `--no-write-lock-file` security invariant kept so `docs/security.md:62` resolves) |
| `720–1393` | CLI subcommand sections (`plan`, `knot`, `approve`, `status`, `changes`, `pending`, `review`, `ready`, `rebase`, `checks`, `tail`, `replay`) | **`docs/guide.md`** (workflows & failure recovery) and **`docs/reference.md`** (flags, exit codes, JSON schemas); **`docs/architecture.md`** keeps concise invariant subsections for `#the-plan-view`, `#listing-changes`, and `#review-against-the-approved-version` (preserving the security caveat and `docs/security.md:112` anchor) |
| `1394–1694` | `## Identity and authority` & `## Bootstrap and steady-state` | **`docs/concepts.md`** (principals/grants), **`docs/guide.md`** (host setup & bootstrap seeding), **`docs/architecture.md`** (compiler pipeline, governance orphan check, VM test coverage) |
| `1695–1815` | `## How the deployment project deploys it` & `## What is in the repo but not yet wired` | **`docs/architecture.md`** (kept with reference deployment framing note at the top of the section) |
#### Audit of every incoming and internal anchor in `docs/architecture.md`
Every existing heading anchor in `docs/architecture.md` that is linked from another file or within `docs/architecture.md` remains a valid heading in `docs/architecture.md` after Slice 4:
| Anchor in `docs/architecture.md` | Linked from | How Slice 4 preserves it |
| :--- | :--- | :--- |
| `#version-and-self-update` | `docs/security.md:62`, `docs/architecture.md:709` | Kept in `docs/architecture.md` with the self-update store-path and lockfile security invariant; links to `docs/reference.md` for CLI syntax. |
| `#review-against-the-approved-version` | `docs/security.md:112` | Kept in `docs/architecture.md` with the `approvedVersion` security rationale, ambiguity refusal rule, and `base` movement caveat; links to `docs/guide.md` and `docs/reference.md`. |
| `#change-records` | `docs/architecture.md:61`, `160`, `514`, `1000` | Kept in `docs/architecture.md` for hook validation and lineage invariants; links to `docs/reference.md#change-record-schema` for the JSON field table. |
| `#the-integrator` | `docs/architecture.md:68`, `159`, `186`, `1012` | Kept in full in `docs/architecture.md`. |
| `#what-a-push-may-write` | `docs/architecture.md:83` | Kept in full in `docs/architecture.md`. |
| `#the-plan-graph` | `docs/architecture.md:84`, `162`, `723` | Kept in `docs/architecture.md` for graph invariants, cycle rules, and CAS design; links to `docs/reference.md#knot-schema` for field tables. |
| `#restack-reports` | `docs/architecture.md:161`, `1164`, `1166` | Kept in `docs/architecture.md` for hook validation invariants; links to `docs/reference.md#restack-report-schema`. |
| `#valley-init-and-the-push-hold` | `docs/architecture.md:163` | Kept in full in `docs/architecture.md`. |
| `#the-source-and-project-storage` | `docs/architecture.md:170`, `1455` | Kept in `docs/architecture.md`. |
| `#the-plan-view` & `#listing-changes` | `docs/architecture.md:724`, `821`, `1160` | Kept as brief architectural invariant subsections in `docs/architecture.md` linking to `docs/reference.md` and `docs/guide.md`. |
*(Note: Relative links inside `archive/design/*.md` pointing to `./architecture.md#...` and `./roadmap.md#...` resolve to `archive/design/architecture.md` and `archive/design/roadmap.md`, not to `docs/`.)*
### 3.4 Inventory of `docs/roadmap.md` items to verify in the plan graph before deletion
Per the operator's decision, `docs/roadmap.md` is deleted in Slice 5 once the coordinator verifies that every item carrying deferred work, a dependency, or an open decision is represented in `refs/the-valley/knots`:
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 6 of 11:
## 4. Core concepts, explained plainly
Below are the newcomer explanations for `docs/concepts.md` and the one-screen overview for `README.md`. Every explanation states what a concept means first, then how git and Nix realize it today, and separates what the code enforces from what a deployment configures and what is not yet built.
### 4.1 Concept drafts (for `docs/concepts.md`)
#### A change: ready, approve, submitted
A **change** is one unit of proposed work with a stable identity across revisions. An author creates a change, revises it until it is complete, and marks it **ready** (`valley ready`) to put a specific version up for review. Each revision is a numbered version (`v1`, `v2`, …) that records the proposed source state and the `main` base it was built on; the latest version is the **active version**. If the author needs to revise further before the change lands, they can pause it back to `draft` (`valley unready`), or mark it `withdrawn` (`valley withdraw`) to abandon it; readying a `draft` or `withdrawn` change again at its active version's head re-readies that same version number without creating a new version (`status/ready.go:223-232`). An operator inspects the change (`valley review <change>`, which pages the diff and offers an interactive prompt) and approves it (`valley approve <change>`, or selecting `[a]pprove` in `valley review`). Approval binds one exact commit of the change. Once the integrator verifies that commit's required checks and merges it into `main`, the change version is **submitted** (`landed` when its commit is directly on `main`'s first-parent history with no merge commit above it, or `landed-recorded` when the integrator merged it onto a newer `main` and recorded a signed transfer statement; `rebase/snapshot.go:10-34`). If an outcome record says `failed`, or says `land` after the request was consumed without a verifiable commit on `main`, the CLI reports the state as **uncertain** so no tooling acts on a guess (`rebase/snapshot.go:250-255`).
*How git realizes this today:* Each change has a 32-letter **Change ID** drawn from `k`–`z` and a short CLI **handle** — the shortest prefix (at least 4 letters) unique among changes currently recorded on `origin`, which can lengthen if a colliding Change ID is recorded later (`change/id.go:92-112`). Without `--stamp` or `--head`, `valley ready [<branch>]` records the remote branch tip (`origin/<branch>`), which must already be pushed to `origin` (`status/ready.go:146-165`). For a brand-new change whose local head commit is not yet on `origin`, `valley ready --stamp` amends the local commit with a `Change-Id: <id>` trailer and pushes the branch before writing `v1` (`status/ready.go:192-204`). Across later revisions or rebases, `valley ready` keeps the same Change ID if the commit carries a `change-id` header (written by `jj`) or `Change-Id` trailer, or if you pass `--change <id>` (`status/ready.go:386-415`). Change records live at `refs/the-valley/changes/<id>`, and approvals write an **integration request** ref at `refs/the-valley/requests/c-<id>` (or `<branch>` for an unrecorded branch).
#### Checks and evidence
Every change **requires** a set of checks determined by the files it modifies. Two CUE policy layers govern a repository: an **instance floor** required of every project on the host, and an optional **project policy** (`policy/project/`) that can only add checks or tighten rules, never weaken the floor (`integrator/policy.go:161-193`). If a project has no `policy/project/` directory, the instance floor governs it alone (`integrator/policy.go:21-23`). Policy maps file globs to path classes, and any changed path that matches no declared class falls under `unclassified` and requires its checks (`schema/verification.cue:62-67`, `integrator/policy.go:345-348`). Checks come in two kinds: **pure checks** (`runner: "nix"`), which are sandboxed Nix flake checks whose results depend only on their input closure, and **effectful checks** (`runner: "command"`), which run commands that may touch external state and carry a policy-defined `validity` time window. Running a check produces **evidence**: a cryptographic **attestation** signed by a trusted key over the content digest of the source tree (`valley-tree-v1`). When `main` has moved ahead of a change's base, the integrator can still reuse existing evidence if the check transfers: a pure check transfers if the landed tree is identical (`unmoved`) or if recomputing the check on the landed tree yields both the same input-closure digest (`valley-inputs-v1`) and the same Nix derivation digest (`closure`, `integrator/verdict/verdict.go:406-417`); an effectful check transfers (`untouched`) only if no intervening change on `main` touched any path class that requires that check, the policy sets a non-zero `validity` window, and the attestation age is strictly within that window (`integrator/verdict/verdict.go:425-440`).
*How git realizes this today:* Signed notes live under `refs/the-valley/attestations/<tree-digest>/<key-hash>`. On every landing — whether fast-forward or merged onto a newer `main` — the integrator countersigns the contributor's notes and writes a signed **transfer statement** (`the-valley/integration/transfer/v1`) recording the landed tree, the attested base tree, the policy digest, and the per-check verdicts (`integrator/refs.go:465-473`, `integrator/transfer.go:43-97`).
#### The host, the hook, and the integrator
A **valley host** is a server (configured on NixOS via `services.valley`) that stores repositories and enforces project rules. Like a valley, the host is the low place where streams of work meet. Two components guard it:
- **The pre-receive hook (`valleyhook`)** inspects every SSH push before git accepts it (`valleyhook/policy.go:88-221`). Whether a branch such as `refs/heads/main` is protected is a **deployment choice** in `valley.cue`: if a project declares a `protection` block, `protection.refs` defaults to `["refs/heads/main"]` and only principals listed in `protection.writers` may push to those refs over SSH; if `protection.writers` is empty, no SSH push may update `main`, whereas a project with no `protection` block leaves all branches open (`valleyhook/policy.go:12-16`, `186-188`). Unprotected topic branches (`refs/heads/*`) are open to any authorized key. On `refs/the-valley/*`, the hook enforces schema and permission rules: any named principal may create a change record (becoming its `owner`); only the change's `owner` or a `request` grant holder may update a change record, except that a `restack` grant holder may add a single version to a `ready` change keeping its active branch and title (`valleyhook/record.go:160-185`, `264-272`); only a `request` holder may delete a change record or write/delete integration requests (`valleyhook/policy.go:151-158`); and nobody may push to `outcomes` or `projects` (`valleyhook/policy.go:147-150`).
- **The integrator** is an optional host service (`services.valley.integrator.enable`) that runs on a configurable timer (`services.valley.integrator.interval`, default `15s`; `nix/valley-host.nix:1220-1230`). On each pass, it deletes pending requests for changes that are currently `withdrawn` (if a withdrawn change is readied again before that pass runs, the old request remains standing and can land; to revoke an approval immediately, a `request` holder must delete the request ref; `status/ready.go:350-355`). For each remaining request whose change is `ready` at the requested commit, it evaluates policy, checks or runs pure Nix checks, and lands the change on `main` via local `git update-ref` (which runs on the host and bypasses `pre-receive`). If `main` has not moved since the change's base, it advances `main` directly to the approved commit; if `main` has moved, it merges the tree via `git merge-tree` and creates a **new single-parent commit** on top of `main` (`integrator/refs.go:399-439`). It re-reads the change record right before advancing `main`, though an `unready` or `withdraw` push arriving in the narrow instant between that final read and `update-ref` will not stop the landing (`integrator/refs.go:475-490`). Finally, it writes an **outcome record** (`land`, `stale`, `reject`, or `failed`) at `refs/the-valley/outcomes/<change>`.
#### Records, project storage, the plan graph, and knots
A repository has two parts: **the source** (`main` and release tags) and **project storage** (the operational records around the source: change records, check attestations, integration requests, outcomes, restack reports, and the plan graph). Keeping project storage outside `main` means updating a plan item, recording a check attestation, or marking a change ready never dirties `main` or triggers source-level rebuilds.
Within project storage, the **plan graph** tracks what the project intends to do and why. Each item in the graph is a **knot** — named after the knotted cords used to keep records before writing. A knot has one of six types:
- **`work`** — a task to complete (`open`, `in_progress`, `done`, `cancelled`).
- **`gate`** — a condition that must hold before dependent work proceeds (`closed`, `open`).
- **`question`** — an open decision (`open`, `answered`, `discarded`); `owner` is optional on all knot types (`knot/model.go:125-126`).
- **`finding`** — an observation or bug discovered during work (`recorded`, `addressed`, `dismissed`).
- **`direction`** — a guiding principle (`active`, `retired`).
- **`milestone`** — a target outcome grouping child work (`open`, `reached`, `abandoned`).
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 9 of 11:
## 7. Migration plan
Migration is broken into **six self-contained slices**, ordered so the newcomer's path lands first.
**Invariants across all slices:**
- **Self-contained linking:** Every slice links only to documents and heading anchors that exist when that slice lands. Each subsequent slice updates earlier documents to add links to the newly created document.
- **Automated link and anchor checking:** Slice 1 extends `nix/checks/prose-format.sh` (which is required by the instance floor for `docs/**` and `*.md`, keeping `nix/checks/own-policy.sh:84-89` green without renaming the floor check) to verify every relative Markdown link and GitHub-slugged `#heading-anchor` across `README.md`, `AGENTS.md`, and `docs/*.md`, reusing the `check_link` and `anchors` logic already in `nix/knowledge-lint.py:129-150` and `334-364`.
- **Claim-to-Code Checklist:** Every slice includes its checklist below so Astra can verify every claim against `file:line` at HEAD before the operator sees it.
---
### Slice 1: Link check, `README.md`, and `docs/concepts.md`
- **Goal:** Give evaluators and newcomers a one-screen entry point, a plain-language conceptual model, and the glossary, guarded by automated link and anchor checking.
- **What is created / rewritten / deleted:**
- **Modified:** `nix/checks/prose-format.sh` and `nix/checks/knowledge.nix` — after `prettier --check`, run a Python link-and-anchor check over `README.md`, `AGENTS.md`, and `docs/*.md` verifying that every relative link target exists and every `#anchor` matches a GitHub-slugged heading in the target file.
- **Rewritten:** `README.md` using the Section 4.2 one-screen draft. Links only to `docs/concepts.md`, `docs/architecture.md`, `docs/security.md`, `archive/`, and `research/`.
- **Created:** `docs/concepts.md` using the Section 4.1 concept drafts and the Section 5 glossary (with glossary links pointing only to `docs/concepts.md`, `docs/architecture.md`, and `docs/security.md` until Slices 2 and 3 land).
- **Deleted:** Nothing. `docs/purpose.md` is untouched.
- **How links stay working:** Verified by the updated `prose-format` check.
#### Slice 1 Claim-to-Code Checklist
| Claim | Kind | Code citation |
| :--- | :--- | :--- |
| Change ID is 32 letters from `k`–`z`; handle is shortest unique prefix (`>= 4` letters) on `origin` and can lengthen on future collisions | `implemented` | `change/id.go:19-46`, `92-112` |
| `valley ready [<branch>]` without `--stamp`/`--head` records `origin/<branch>` (must already be pushed); `--stamp` works only for a new change (`before == nil`) whose local head is not on `origin` | `implemented` | `status/ready.go:146-165`, `192-204`, `451-453` |
| Re-readying a `draft` or `withdrawn` change at its active version's head re-readies the same version number (`P = [old]`) | `implemented` | `status/ready.go:223-232`, `valleyhook/record.go:281-319` |
| Retaining a Change ID across revisions requires `--change <id>`, a `change-id` commit header (`jj`), or a `Change-Id` trailer | `implemented` | `status/ready.go:386-415` |
| Any named principal can create a change record (`owner`); updates require `owner` or `request` grant, except `restack` grant may add one version to a `ready` change keeping active branch/title; only `request` holder may delete a change record | `implemented` | `valleyhook/record.go:160-198`, `264-272`, `361-370` |
| Integrator deletes pending requests for a `withdrawn` change on its next pass while still withdrawn; re-readying before that pass leaves the old request standing | `implemented` | `status/ready.go:350-355`, `integrator/refs.go:117` |
| Landing states: `landed` (on `main` first-parent history with no merge commit above it), `landed-recorded` (single-parent commit on `main` with verified transfer statement, `land` outcome, and matching `merge-tree`), `uncertain` (`failed` outcome, or `land` outcome with consumed request ref without verified landing) | `implemented` | `rebase/snapshot.go:10-34`, `164-191`, `242-299` |
| Instance policy floor is mandatory; project policy (`policy/project/`) is optional; unmatched paths fall under `unclassified` | `implemented` | `integrator/policy.go:21-23`, `84`, `345-348`, `schema/verification.cue:62-67` |
| Evidence transfer: pure check (`runner: "nix"`) transfers on `unmoved` or matching `Inputs` + `Derivation` (`closure`); effectful check (`runner: "command"`) transfers (`untouched`) only if no intervening change touched a path class requiring the check and age `< Validity` | `implemented` | `integrator/verdict/verdict.go:390-440` |
| Integrator writes a transfer statement and countersigns attestations on every landing (including fast-forwards); non-FF landing creates a new single-parent commit on `main` via `git merge-tree` | `implemented` | `integrator/refs.go:399-439`, `465-473` |
| Integrator re-reads change record before `update-ref`, with a narrow race window between that read and `update-ref` | `implemented` | `integrator/refs.go:475-490` |
| Plan graph checks local `parent` cycles and local `blocked_by` cycles separately; cross-project `blocked_by` is syntax-checked only; `owner` is optional on all knot types | `implemented` | `knot/graph.go:376-470`, `knot/model.go:125-126` |
| `registry` boundary kind is checked only by the identity compiler's `governanceOrphaned` rule, not enforced by `valleyhook` or `integrator` | `implemented` | `identity/render.go:104`, `138-143` |
| Protected refs (`protection.refs`), direct writers (`protection.writers`), who holds `request`/`restack`, static `authorizedKeys`/`grants`, `integrator.enable` + `interval` (default `15s`), and `identity.enable` | `deployment choice` | `valleyhook/policy.go:12-16`, `186-188`, `nix/valley-host.nix:624-635`, `988-1010`, `1220-1280` |
| Automatic host restacker service and automatic approval carry across restacks | `not built` | `docs/architecture.md:591-592`, `1808` |
---
### Slice 2: `docs/guide.md` (All role journeys: author, operator, planner, recovery, host setup, contributor)
- **Goal:** Give every reader role a step-by-step guide, including host setup from scratch, failure recovery, and contributor testing.
- **What is created / rewritten / deleted:**
- **Created:** `docs/guide.md` covering all seven sections from the Section 3.2 outline.
- **Modified:** `README.md` and `docs/concepts.md` — add links to `docs/guide.md` now that it exists.
- **Deleted:** Nothing.
- **How links stay working:** Verified by `prose-format`.
#### Slice 2 Claim-to-Code Checklist
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 8 of 11:
## 5. Glossary
This table lives at the end of `docs/concepts.md`. Every term has a one-line plain definition and a pointer to its full explanation.
| Term | Plain definition | Full explanation |
| :--- | :--- | :--- |
| **Active version** | The highest-numbered version (`vN`) in a change record (`versions[len-1]`). | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/reference.md#change-record-schema` |
| **Approved version** | In `valley status` and `valley review`, the greatest prior version of a revised change whose exact head commit carries an unambiguous integration request or `land`, `stale`, or `reject` outcome record on `origin` (never falling back to an older version if the greatest version with evidence is ambiguous). | `docs/guide.md#reviewing-and-approving-changes`, `docs/architecture.md#review-against-the-approved-version` |
| **Attestation** | A signed statement (`the-valley/attestation/v1`) stored under `refs/the-valley/attestations/<tree-digest>/<key-hash>` recording that a check passed on a specific content tree (`valley-tree-v1`). | `docs/concepts.md#checks-and-evidence`, `docs/reference.md#attestation-schema` |
| **Base** | The `main` commit (`versions[i].base`) a change version was branched or rebased from (`git merge-base origin/main <head>`). | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/reference.md#change-record-schema` |
| **Boundary** | A named scope in the identity registry (`kind: "request"`, `"restack"`, or `"registry"`) where a principal holds a grant. | `docs/concepts.md#principals-and-grants`, `docs/reference.md#cue-configuration-schemas` |
| **Change** | A tracked unit of proposed work with a stable 32-letter Change ID (`k`–`z`), moving through `draft`, `ready`, or `withdrawn` states across numbered versions (`v1`, `v2`, …) until submitted to `main`. | `docs/concepts.md#a-change-ready-approve-submitted` |
| **Change ID** | A 32-character identifier drawn from letters `k` through `z` (`[k-z]{32}`) that uniquely names a change across revisions and rebases. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/reference.md#naming-rules` |
| **Change record** | The JSON document (`valley-change-record/v1`) stored at `refs/the-valley/changes/<id>` tracking a change's owner, state, and version history. | `docs/reference.md#change-record-schema`, `docs/architecture.md#change-records` |
| **Check** | An executable verification step that a change requires based on the path classes its diff touches (including `unclassified` for paths matching no declared class). | `docs/concepts.md#checks-and-evidence` |
| **Draft** | A change state meaning work is in progress or paused (`valley unready`) and not currently up for integration. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#authoring-a-change` |
| **Effectful check** | A check (`runner: "command"`) that may depend on external state; its evidence transfers across `main` movement (`untouched`) only if no intervening change touched a path class requiring the check and the observation age is within the policy's `validity` window. | `docs/concepts.md#checks-and-evidence`, `docs/architecture.md#verification-policy-and-attestations` |
| **Evidence** | Signed check attestations stored in project storage that prove a change's required checks passed. | `docs/concepts.md#checks-and-evidence` |
| **Grant** | A capability (`request` or `restack` in `valleyhook`, or `registry` for the identity compiler's orphan check) assigned to a principal statically in NixOS or compiled from the identity registry. | `docs/concepts.md#principals-and-grants`, `docs/architecture.md#identity-compilation` |
| **Handle** | The shortest prefix of a Change ID (at least 4 letters, or `<repo>:<prefix>` across repos) unique among changes currently recorded on `origin`; it can lengthen if a colliding Change ID is recorded later. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/reference.md#naming-rules` |
| **Identity registry** | The directory of CUE files (`identity/*.cue`) in the instance repository that an instance can compile (`services.valley.identity.enable`) into SSH `authorized_keys`, `known-signers`, and `grants`. | `docs/concepts.md#principals-and-grants`, `docs/architecture.md#identity-compilation` |
| **Instance** | A deployment of one or more projects governed by a shared floor verification policy and identity configuration (in the reference deployment, the instance repository). | `docs/concepts.md#checks-and-evidence`, `docs/architecture.md#verification-policy-and-attestations` |
| **Instance floor** | The mandatory baseline verification policy (`policy/instance/`) that every project in an instance must satisfy; project policy is optional and can only narrow (strengthen) the floor. | `docs/concepts.md#checks-and-evidence`, `docs/architecture.md#verification-policy-and-attestations` |
| **Integration request** | A commit ref at `refs/the-valley/requests/<change>` written by a `request` grant holder (`valley approve`) authorizing the integrator to verify and land that exact commit onto `main`. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#reviewing-and-approving-changes` |
| **Integrator** | The optional host service (`services.valley.integrator.enable`) that polls integration requests (default every `15s`), verifies policy and check evidence, lands passing ready changes onto `main`, writes transfer statements, and records outcomes. | `docs/concepts.md#the-host-the-hook-and-the-integrator`, `docs/architecture.md#the-integrator` |
| **Knot** | A single record (`<id>.json` under `refs/the-valley/knots`) in a project's plan graph, typed as `work`, `gate`, `question`, `finding`, `direction`, or `milestone`. | `docs/concepts.md#records-project-storage-the-plan-graph-and-knots`, `docs/reference.md#knot-schema` |
| **Landed / Landed-recorded** | The two states of a submitted change version: `landed` when its commit is on `main`'s first-parent history with no merge commit above it; `landed-recorded` when a single-parent commit on `main` carries a verified transfer statement and `land` outcome record for that version's head and merges to the same tree. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/architecture.md#change-lifecycle-and-review-invariants` |
| **Outcome record** | A single-line blob written by the integrator at `refs/the-valley/outcomes/<change>` recording `land`, `stale`, `reject`, or `failed` for an integration request. | `docs/concepts.md#the-host-the-hook-and-the-integrator`, `docs/reference.md#outcome-record-schema` |
| **Path class** | A named group of file glob patterns in verification policy mapped to the checks required when a change modifies matching files (with unmatched paths falling into `unclassified`). | `docs/concepts.md#checks-and-evidence`, `docs/reference.md#cue-configuration-schemas` |
| **Plan graph** | The directed graph of knots stored at `refs/the-valley/knots` and viewed with `valley plan`; local `parent` and local `blocked_by` edges are each checked separately for cycles. | `docs/concepts.md#records-project-storage-the-plan-graph-and-knots`, `docs/guide.md#planning-work-with-knots` |
| **Principal** | A named human or agent identity associated with SSH public keys or attestation signing keys. | `docs/concepts.md#principals-and-grants` |
| **Project storage** | The `refs/the-valley/*` namespace on a valley host holding change records, attestations, requests, outcomes, restack reports, and knots outside `main` (not pushed to mirrors or fetched by a plain `git clone`). | `docs/concepts.md#records-project-storage-the-plan-graph-and-knots`, `docs/reference.md#project-storage-ref-layout-and-bounds` |
| **Pure check** | A hermetically sandboxed Nix flake check (`runner: "nix"`) whose evidence never expires with time and transfers across `main` movement if the tree is `unmoved` or if both its input-closure digest (`valley-inputs-v1`) and derivation digest match (`closure`). | `docs/concepts.md#checks-and-evidence`, `docs/architecture.md#verification-policy-and-attestations` |
| **Push hold** | The sentinel file (`${dataDir}/.valley-hold`, default `/srv/git/.valley-hold`) on a valley host that pauses all incoming SSH pushes across all projects while present. | `docs/guide.md#running-a-valley-host`, `docs/architecture.md#valley-init-and-the-push-hold` |
| **Ready** | The change state set by `valley ready`, declaring that the active version is complete and awaiting operator review and approval. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#authoring-a-change` |
| **Restack report** | A JSON record (`valley-restack-report/v1`) under `refs/the-valley/restack-reports/<id>` validated by `valleyhook` and displayed by `valley status`/`valley pending` to report an automated restack outcome (the automatic restacker service itself is not built yet). | `docs/reference.md#restack-report-schema`, `docs/architecture.md#restack-reports` |
| **Submitted** | A change version that has been integrated into `main` (either `landed` or `landed-recorded`). | `docs/concepts.md#a-change-ready-approve-submitted` |
| **Transfer statement** | A signed attestation (`the-valley/integration/transfer/v1`) written by the integrator on every landing (both fast-forward and merged), binding the landed tree and commit to the attested base tree, policy digest, and per-check verdicts. | `docs/concepts.md#checks-and-evidence`, `docs/reference.md#transfer-statement-schema` |
| **Uncertain** | The landing state reported when neither `landed` nor `landed-recorded` holds and either the outcome record says `failed`, or it says `land` while the request ref was consumed (or signer verification env vars are unset for a merged landing). | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#recovering-from-failure` |
| **`valley-tree-v1`** | The SHA-256 content-addressing scheme over a canonical manifest of a tree's files, executable bits, and symlinks (`<mode> <sha256> <path-len> <path>`), independent of git commit metadata. | `docs/reference.md#attestation-schema`, `attest/digest.go:5-18` |
| **`valleyhook`** | The Go pre-receive hook binary that validates every SSH push to a valley host against ref protection, grants, and record/knot schemas. | `docs/concepts.md#the-host-the-hook-and-the-integrator`, `docs/architecture.md#what-a-push-may-write` |
| **Withdrawn** | A change state set by `valley withdraw`, taking a change off the review queue; the integrator deletes pending requests for a withdrawn change on its next pass if the change is still withdrawn. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#authoring-a-change` |
---
## 6. Style guide
Add these rules to `AGENTS.md` so every future doc change follows the same standard:
1. **Simple language, one new idea per sentence.** Lead every section with a plain statement of what the thing is in ordinary words before qualifying it. If a sentence stacks abstractions, split it in two.
2. **Meaning before mechanism.** State what a concept or command accomplishes for the user before explaining how git refs, CUE unification, or Nix derivations implement it today.
3. **Example before abstraction.** In guides and reference material, show a concrete command or 5-line snippet before listing edge-case rules or schema tables.
4. **Separate three kinds of claim everywhere.** Never let a reader mistake a deployment choice or an unbuilt plan for a code guarantee:
- **Code-enforced (`implemented`):** What `valleyhook`, `integrator`, `attest`, `identity`, or `valley` always enforces.
- **Deployment configuration (`deployment choice`):** What an instance configures in `valley.cue`, `services.valley`, `policy/`, or `identity/` (such as whether `main` is protected, whether `protection.writers` is empty, who holds `request`, and whether the integrator or identity compiler is enabled).
- **Not built yet (`not built`):** Mechanisms planned or partially scaffolded (such as the automatic restacker service or approval carry across restacks).
5. **Mandatory Claim-to-Code Checklist in every doc change.** Every doc slice brief and change description must carry a checklist of each factual claim added or modified, labelled `implemented`, `deployment choice`, or `not built`, with an exact `file:line` citation verified against HEAD before review.
6. **Present tense, no transition narration.** Describe what the code at HEAD does today. Do not write "previously we used X" or "soon this will do Y." Live plans and open questions belong in `valley plan` (`refs/the-valley/knots`), not in prose docs. Do not compare the-valley to other platforms; positioning is the operator's to write.
7. **Strict vocabulary:**
- A change is `draft`, `ready`, `approved`, or `submitted` (never call a valley change a "PR", "pull request", or "branch").
- A change **requires** checks (never "owes" checks).
- A plan item is a **knot** in the **plan graph** (never "issue", "ticket", or "knowledgebase").
- Operational metadata refs (`refs/the-valley/*`) are **project storage**, distinct from **the source** (`main` and release tags).
8. **The Taoist wink.** Keep the wink at threshold moments — introducing the valley as the low place where streams of work converge, or explaining why a plan record is called a knot (from knotted cords before writing). One light sentence at the start of a concept is enough; never use metaphor inside procedural instructions, error messages, or security invariants.
---
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 10 of 11:
| Claim | Kind | Code citation |
| :--- | :--- | :--- |
| `valley self-update` builds `#valley` with `--no-write-lock-file` from `VALLEY_FLAKE` (when invoked from `/nix/store/`), `git rev-parse --show-toplevel` (when in a checkout carrying `bin/valley`), or `$HOME/the-valley` | `implemented` | `bin/valley:1252-1305` |
| `valley review <change>` pages the diff and interactively offers `[a]pprove` only when the change is `ready` (and not above a non-ready stack layer); `--since approved` diffs against `approvedVersion` | `implemented` | `bin/valley:137-209`, `status/compare.go:6-27`, `260-289` |
| `valley approve <change>` pushes `refs/the-valley/requests/c-<id>` (for a recorded `ready` change) or `refs/the-valley/requests/<branch>` (when `--head <sha>` is given for an unrecorded branch) | `implemented` | `bin/valley:1012-1135` |
| `valley rebase` safety gate: refuses if any branch in the stack is `uncertain`, or if `VALLEY_KNOWN_SIGNERS` / `VALLEY_INTEGRATOR_SIGNER` are only partially set; if unset, merged landings cannot verify transfer statements | `implemented` | `rebase/snapshot.go:64-68`, `250-255`, `440-444` |
| `examples/hosts/protected.cue` is a 4-repo test fixture for `protect-e2e`, not a production host config | `implemented` | `examples/hosts/protected.cue:1-33` |
| `valley-init` initializes bare git repos (`--initial-branch=main`) and publishes `refs/the-valley/projects`, but creates no initial `main` commits; bootstrap seeding must happen via local host write (which bypasses `pre-receive`) or before sealing `protection.writers` | `implemented` / `deployment choice` | `nix/valley-host.nix:509-584`, `690-693` |
| Host assertions: `services.valley.authorizedKeys` must be non-empty; enabling `integrator` requires `signingKeyFile` + `signingName`, either `instanceProject` (whose `refs/heads/main` is protected) or `instancePolicy`, and either `identity.enable = true` or `integrator.knownSignersFile` | `implemented` | `nix/valley-host.nix:1335-1425` |
| Push mirrors (`valley-publish@<project>`) push `refs/heads/main` and `refs/tags/*` as the `git` Unix user using its SSH key and `known_hosts`; offsite backup (`restic-backups-valley`) snapshots `services.valley.dataDir` using `repositoryFile`, `passwordFile`, `sshKeyFile`, and `knownHostsFile` | `implemented` / `deployment choice` | `nix/valley-host.nix:252-260`, `1288-1330`, `1797-1867` |
| Push hold sentinel path is `${services.valley.dataDir}/.valley-hold` (`/srv/git/.valley-hold` by default) | `implemented` | `nix/valley-host.nix:602`, `885-895` |
---
### Slice 3: Create `docs/reference.md` (Wire contracts, CLI reference, and schemas)
- **Goal:** Establish a single reference manual for CLI flags, ref tables, wire schemas, and JSON contracts before slimming `docs/architecture.md`.
- **What is created / rewritten / deleted:**
- **Created:** `docs/reference.md`, consolidating the ref table, wire schemas (`valley-change-record/v1`, `valley-restack-report/v1`, `the-valley/attestation/v1`, `the-valley/integration/transfer/v1`, `valley-tree-v1`, `valley-inputs-v1`, `valley-delta-v1`, outcome records), CLI flags/exit codes/JSON contracts (`valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, `valley knot --json`), and CUE schema references.
- **Modified:** `README.md`, `docs/concepts.md` (including glossary links), and `docs/guide.md` — add links to `docs/reference.md`.
- **Untouched in Slice 3:** `docs/architecture.md` (slimmed in Slice 4 so `docs/reference.md` is reviewed cleanly on its own).
#### Slice 3 Claim-to-Code Checklist
| Claim | Kind | Code citation |
| :--- | :--- | :--- |
| Ref layout, object types, and size bounds: change record (`<= 64 KiB` `change.json`), restack report (`<= 64 KiB` `report.json`), attestation note (`<= 64 KiB` per blob, `<= 64` blobs), knot (`<= 64 KiB` per `<id>.json`, `<= 4,096` files) | `implemented` | `valleyhook/policy.go:88-221`, `valleyhook/record.go:19-36`, `valleyhook/report.go:18-30`, `knot/graph.go:24-31` |
| `valley-tree-v1` manifest (`"valley-tree-v1\n"` + `<mode> <sha256> <len> <path>\n` sorted by path bytes) and `valley-inputs-v1` manifest (`"valley-inputs-v1\n"` + `<len> <name>\n` sorted and deduplicated) | `implemented` | `attest/digest.go:5-25`, `57-98` |
| Transfer statement (`the-valley/integration/transfer/v1`, stored at `transfer.note` under `refs/the-valley/attestations/<landed-tree>/<integrator-key-hash>`), carrying `change`, `target`, `base.valley-tree-v1`, `policy.{sha256,git-sha1}`, and either `checks` or `required: "none"` | `implemented` | `integrator/transfer.go:31`, `43-97`, `schema/attestation.cue:1-130` |
| CLI JSON output schemas: `valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, and `valley knot --json` | `implemented` | `status/status.go:25-115`, `status/list.go:22-75`, `status/pending.go:24-85`, `knot/plan.go:20-70` |
---
### Slice 4: Slim `docs/architecture.md` and add reference deployment note
- **Goal:** Focus `docs/architecture.md` on component design, rationale, security caveats, invariants, and executable checks while preserving every linked heading anchor.
- **What is created / rewritten / deleted:**
- **Modified:** `docs/architecture.md` — replace duplicated wire field tables and end-user CLI flag manuals with links to `docs/reference.md` and `docs/guide.md`. Keep all design rationale, security caveats (such as the pre-commit readiness race window, `approvedVersion` ambiguity refusal and `base`-movement caveat, and self-update lockfile/store-path integrity), component invariants, flake check tables, and all 11 audited heading anchors (Section 3.3). Add the reference deployment framing note (the deployment project, klaus, the valley host, the instance repository) at the top and before `## How the deployment project deploys it`.
#### Slice 4 Claim-to-Code Checklist
| Claim | Kind | Code citation |
| :--- | :--- | :--- |
| All 11 audited heading anchors in `docs/architecture.md` (`#version-and-self-update`, `#review-against-the-approved-version`, `#change-records`, `#the-integrator`, `#what-a-push-may-write`, `#the-plan-graph`, `#restack-reports`, `#valley-init-and-the-push-hold`, `#the-source-and-project-storage`, `#the-plan-view`, `#listing-changes`) resolve cleanly | `implemented` | Verified by `prose-format` link-and-anchor check against `docs/security.md:62`, `112` and internal links |
| Every flake check named in `docs/architecture.md` matches an attribute in `flake.nix` / `nix/checks/` | `implemented` | `nix/checks/cli.nix`, `nix/checks/knowledge.nix` |
| Reference deployment framing note names the deployment project (reference NixOS fleet), klaus (agent runner), the valley host (primary valley host), and the instance repository | `deployment choice` | `docs/architecture.md:1695-1786` |
---
### Slice 5: Retire `docs/roadmap.md`, update `docs/security.md`, and update `AGENTS.md`
contributor2026-10-18 14:45 UTC
From the coordinator's working file `review-docs-pm-astra.md` (moved here 2026-10-18), part 1 of 1:
The seven-document split gives all five readers sensible routes and preserves architecture and security as homes for rationale and guarantees. Starting with the overview and concepts addresses the main accessibility problem without requiring a platform redesign.
(1) The drafts turn configuration into security guarantees. “No push may write main” is false: unprotected branches accept pushes, and protected refs admit declared writers (valleyhook/policy.go:140,186). “Only the operator holds request” is deployment policy; the hook checks the grant, not whether its holder is human (valleyhook/policy.go:151). “Every actor” being registered is also false: static keys and grants coexist with compiled identity (nix/valley-host.nix:633). The registry grant checks that governance exists during compilation; it is not an implemented authorization check on registry changes (identity/render.go:104,138). Correct these throughout the overview, concepts and glossary.
(2) Withdrawal and readiness are overstated. Withdrawal deletes requests only when the integrator observes the withdrawn state; readying again first can preserve the old request (status/ready.go:312,352). A pause after the final readiness read can still land (integrator/refs.go:475). Also, named principals may create records, but ordinary updates require ownership or request authority; restack permits one restricted transition (valleyhook/record.go:166). Replace unconditional promises with these boundaries.
(3) The author journey misdescribes ready. Without --stamp, it normally records the remote branch head, not the current local commit (status/ready.go:146). --stamp rewrites and pushes the first version only (status/ready.go:192). Revisions retain identity only through --change or the head’s embedded ID (status/ready.go:386). Re-readying the same head can retain its version (status/ready.go:223). Handles are unique prefixes of at least four letters and may lengthen as collisions appear; only the full ID is stable (change/id.go:92). Running review alone does not approve; the author must select the approval action (bin/valley:112).
(4) Landing and evidence need more precise definitions. A divergent change lands as a newly constructed single-parent commit, not necessarily “that commit” (integrator/refs.go:353,399). Transfer statements accompany every landing, including fast-forwards (integrator/refs.go:465). The submitted glossary omits the no-intervening-merge condition and the verified statement, outcome and tree checks behind landed-recorded; uncertain is a necessary user-facing result (rebase/snapshot.go:10). “Approved version” must not fall back past a newer ambiguous candidate, and only land/stale/reject outcomes qualify (status/compare.go:6). Pure evidence transfer compares both input and derivation digests; effectful evidence also requires untouched classes, not merely an unexpired window (integrator/verdict/verdict.go:406,425).
(5) Policy and graph claims need qualification. A project’s policy layer is optional; the floor alone can govern it (integrator/policy.go:21). Unmatched paths require the policy’s unclassified checks, missing from the concept explanation (schema/verification.cue:62). The whole plan graph is not guaranteed acyclic: local parent and blocked_by edges are checked separately, and external dependencies are outside that cycle walk (knot/graph.go:410). Question ownership is optional in code (knot/model.go:125). Restack-report validation exists; the absent component is the automatic restacker (valleyhook/report.go:57). Fifteen seconds is a configurable delay between passes (nix/valley-host.nix:1220).
(6) Host setup is the largest structural omission. protected.cue is a four-case test fixture, including open and writer-exception projects, not a minimal installation recipe (examples/hosts/protected.cue:1). valley-init creates empty repositories and hooks, not initial source, policy or registry commits (nix/valley-host.nix:509). Specify bootstrap seeding, integrator enablement, signing-key provisioning, trusted signers, mirror credentials, backup initialization and restore verification. Identity compilation and the integrator are optional; known signers may be supplied directly (nix/valley-host.nix:1089,1125). The hold path follows dataDir, rather than always being /srv/git (nix/valley-host.nix:602).
(7) The slices are not independently complete. Slice 1 links to guide/reference before they exist. Slice 3 combines several large contracts with an architectural rewrite; split it and audit all anchors. Formatting does not check links (nix/checks/prose-format.sh:8). Preserve rationale and security caveats explicitly, rather than targeting 550 lines. Roadmap migration must include deferred work and dependencies, not just named milestones and five questions. Add contributor setup/testing, failure recovery, and evaluator access to plans unavailable on mirrors.
(8) Constraint compliance is mixed. purpose.md remains untouched; its open question is permitted. Vocabulary is largely compliant. Concepts still define changes through main, commits and refs before explaining their independent meaning. Remove unsupported GitHub speed/agent-opacity claims. The overview lacks prerequisites and current limitations and exceeds a screen. The proposed “six” documents are seven.
The single most valuable change is to require a claim-to-code acceptance checklist for every slice, distinguishing implemented behavior, configurable deployment policy and unfinished mechanisms before polishing prose.
contributor2026-10-18 14:45 UTCedited2026-10-29 01:16 UTC by contributor
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 11 of 11:
- **Goal:** Remove the duplicate prose roadmap once the coordinator confirms the Section 3.4 knot inventory in `refs/the-valley/knots`, add the reference deployment note to `docs/security.md`, and codify the seven-document altitude list and style guide in `AGENTS.md`.
- **What is created / rewritten / deleted:**
- **Deleted:** `docs/roadmap.md`.
- **Modified:** `docs/security.md` — add the reference deployment note (the deployment project, klaus, the valley host, the instance repository) at the top and replace the `[roadmap.md](./roadmap.md)` link at line 5 with `valley plan` (`docs/concepts.md#records-project-storage-the-plan-graph-and-knots`).
- **Modified:** `AGENTS.md` — update `## Document altitudes` to list the seven documents (`README.md`, `docs/purpose.md`, `docs/concepts.md`, `docs/guide.md`, `docs/reference.md`, `docs/architecture.md`, `docs/security.md`) plus `archive/`, remove references to `docs/roadmap.md` (`lines 32, 48`), and add the Section 6 style guide rules including the mandatory Claim-to-Code Checklist.
#### Slice 5 Claim-to-Code Checklist
| Claim | Kind | Code citation |
| :--- | :--- | :--- |
| Live plan and open `question` knots live in `refs/the-valley/knots` (`valley plan`), validated by `knot/` | `implemented` | `knot/model.go:10-48`, `knot/plan.go:1-120` |
| Zero remaining links to `docs/roadmap.md` across `README.md`, `AGENTS.md`, and `docs/*.md` | `implemented` | Verified by `prose-format` link-and-anchor check |
---
### Slice 6: Split `valley help` into a one-screen summary plus `valley help <verb>`
- **Goal:** Make `valley help` readable on a single terminal screen (~40 lines) while preserving every detail of the existing help text under `valley help <verb>` for all 15 verbs.
- **What is created / rewritten / deleted:**
- **Modified:** `bin/valley:57-720` — replace the 639-line `usage()` with a one-screen command summary grouped by role (keeping `usage: valley <command> [args]` as the first line so `nix/checks/valley-cli.sh:31` passes), and dispatch `valley help <verb>` (and `valley <verb> --help` / `-h` where not already handled) for every verb: `pending`, `changes`, `review`, `approve`, `rebase`, `status`, `ready`, `unready`, `withdraw`, `knot`, `plan`, `checks`, `tail`, `replay`, `self-update`.
- **Modified:** `completions/valley.bash:64-65` and `completions/_valley:34-36` — complete all 15 verbs after `valley help` (today they only complete `knot`).
- **Modified:** `nix/checks/valley-cli.sh` — add assertions that `valley help <verb>` exits 0 for every verb and `valley help unknown-verb` exits non-zero.
#### Slice 6 Claim-to-Code Checklist
| Claim | Kind | Code citation |
| :--- | :--- | :--- |
| `valley help`, `valley --help`, `-h`, and no-arg `valley` output matches `^usage: valley` | `implemented` | `bin/valley:1311-1315`, `nix/checks/valley-cli.sh:29-42` |
| `valley help <verb>` covers all 15 CLI verbs and bash/zsh completions complete all 15 verbs after `help` | `implemented` | `bin/valley:698-714`, `completions/valley.bash:64-65`, `completions/_valley:34-36` |
---
## 8. Open question for the operator
All four decisions from revision 1 are settled. One question remains:
1. **Should the new Markdown link-and-anchor check run inside the existing `prose-format` check or as a separate flake check?**
- *Context:* The instance floor requires `prose-format` for `docs/**`, and `nix/checks/own-policy.sh:84-89` asserts that a change touching only `docs/architecture.md` requires `prose-format` alone. Adding a second check name to `docs/` in `policy/project/policy.cue` would require updating `own-policy.sh` and running a second Nix derivation on every docs change, whereas running the link-and-anchor check inside `nix/checks/prose-format.sh` enforces links automatically under the existing floor check.
- *Recommendation:* Fold relative link and `#heading-anchor` verification of `README.md`, `AGENTS.md`, and `docs/*.md` directly into `prose-format` in Slice 1.
contributor2026-10-19 10:46 UTC
Slice 1 landed 2026-10-19 (rmyw, 789346c): README, docs/concepts.md, link check in prose-format; the operator review led to a simpler first page and bug bd-751047b (rename the request grant). Slice 2 (docs/guide.md) is change rzmx, run 20261019-1046-c8157e5f, by Argon via agy with the full brief as the prompt (klaus #332).
contributor2026-10-19 10:55 UTCedited2026-10-29 01:09 UTC by contributor
Argon (agy) hit its individual quota on 2026-10-19, resetting Sat 24 Oct about 22:20 UTC. The operator: switch the doc writing to Codex with the same style guide, keeping Argon simplicity. Slice 2 is change wstq, run 20261019-1055-11d98d90, Codex gpt-6-astra writing and Claude reviewing (cross-family).
contributor2026-10-19 11:47 UTC
Slice 3 brief (for Argon via agy), prepared 2026-10-19; launch once wstq lands:
# the-valley docs, slice 3: docs/reference.md, the CLI and wire reference
You are writing the third slice of the-valley's new documentation, from the docs proposal (revision 2) that you, Gemini 4 Argon, wrote as product manager and the operator accepted. Slices 1 and 2 have landed: `README.md`, `docs/concepts.md`, `docs/guide.md`, a link check inside `prose-format`, and a "Documentation style and verification" section in `AGENTS.md`. That section is the binding style guide; read it first. **The code at HEAD is the authority**: where the proposal and the code disagree, the code wins, and you say so in your report.
## What the operator asked for
- **The voice of slice 1:** the operator liked your simplicity in `README.md` and `docs/concepts.md`. A reference is necessarily precise, but each entry still leads with what the thing is for, in one plain sentence, then its exact contract. An example comes before the rules.
- **The approval grant is named `request` in code** (a rename to `approve` is filed as bug `bd-751047b`). Document the name the code uses, and say once that it is the grant that lets a principal approve.
- **This slice creates the reference only.** Slimming `docs/architecture.md` is slice 4. Where reference material duplicates `architecture.md` today, write the reference entry and leave `architecture.md` alone; slice 4 replaces its copy with a link.
## How you work
1. Write `docs/reference.md` from the outline and slice section below, and link to it from `README.md`'s Documentation list and from `docs/concepts.md` and `docs/guide.md` where a reader looks something up. Every link must resolve (the link check enforces it).
2. Derive every flag, field, ref path and limit from the code, not from the existing docs: `bin/valley`'s usage block and dispatch, `status/` (valley-go), `change/`, `knot/`, `valleyhook/`, `integrator/`, `schema/`, `nix/valley-host.nix`.
3. Walk the slice's claim-to-code checklist below, labelling each claim implemented, deployment choice or not built, with `file:line`. Put the completed checklist in your report.
4. Before you commit, have Astra review:
`klaus consult --backend codex --model gpt-6-astra --effort high --role critic --thread docs-slice-3 --timeout 30m --dir . "Review the uncommitted docs diff (git diff, plus new files) in this the-valley checkout against the code at HEAD. List every flag, field, ref, limit or behaviour the code contradicts, anything missing that a reader would look up, every deployment choice stated as a guarantee, broken links, transition narration, and vocabulary breaks. file:line and the fix. Under 600 words."`
Fix every factual error; for anything you decline, say why. Then reread each entry's first sentence as a newcomer would.
5. `nix run .#fmt`, but commit only the docs you changed. Build `prose-format` and `own-policy` one at a time with `nix build --no-link .#checks.x86_64-linux.<name> -L`. Never `nix flake check`. Never run a tmux command. Don't leave `go build` output anywhere.
6. One commit: `docs: a reference for the CLI, records and refs`. No attribution lines. Push your topic branch to origin; never push main.
Report: the reference's outline, the completed checklist, Astra's findings and what you did with each, and each check's result.
## From the proposal: the outline of docs/reference.md
#### 5. `docs/reference.md`
- **CLI reference** (every `valley` subcommand, synopsis, flags, arguments, exit codes, and naming rules for Change IDs, handles, branch names, and request names)
- **Environment variables and git config** (`VALLEY_KNOWN_SIGNERS`, `VALLEY_INTEGRATOR_SIGNER`, `VALLEY_FLAKE`, `valley.knownSignersFile`, `valley.integratorSigner`, `SSH_ORIGINAL_COMMAND`)
- **Project storage ref layout and bounds** (table of `refs/heads/*`, `refs/tags/*`, `refs/the-valley/*`, who may write each, object types, and size limits)
- **Wire formats and JSON schemas**
- Change record (`valley-change-record/v1`) and parent-history rules
- Restack report (`valley-restack-report/v1`)
- Attestation note and statement (`the-valley/attestation/v1`) and canonical digest manifests (`valley-tree-v1`, `valley-inputs-v1`, `valley-delta-v1`)
- Integrator transfer statement (`the-valley/integration/transfer/v1`)
- Integrator outcome record (`refs/the-valley/outcomes/<change>`)
- CLI JSON outputs (`valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, `valley knot --json`)
- **CUE configuration schemas** (`schema/valley.cue`, `schema/verification.cue`, `schema/attestation.cue`, `schema/identity.cue`)
## From the proposal: slice 3 and its checklist
### Slice 3: Create `docs/reference.md` (Wire contracts, CLI reference, and schemas)
- **Goal:** Establish a single reference manual for CLI flags, ref tables, wire schemas, and JSON contracts before slimming `docs/architecture.md`.
- **What is created / rewritten / deleted:**
- **Created:** `docs/reference.md`, consolidating the ref table, wire schemas (`valley-change-record/v1`, `valley-restack-report/v1`, `the-valley/attestation/v1`, `the-valley/integration/transfer/v1`, `valley-tree-v1`, `valley-inputs-v1`, `valley-delta-v1`, outcome records), CLI flags/exit codes/JSON contracts (`valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, `valley knot --json`), and CUE schema references.
- **Modified:** [README.md](README.md), `docs/concepts.md` (including glossary links), and `docs/guide.md` — add links to `docs/reference.md`.
- **Untouched in Slice 3:** [docs/architecture.md](docs/architecture.md) (slimmed in Slice 4 so `docs/reference.md` is reviewed cleanly on its own).
#### Slice 3 Claim-to-Code Checklist
| Claim | Kind | Code citation |
| :--- | :--- | :--- |
| Ref layout, object types, and size bounds: change record (`<= 64 KiB` `change.json`), restack report (`<= 64 KiB` `report.json`), attestation note (`<= 64 KiB` per blob, `<= 64` blobs), knot (`<= 64 KiB` per `<id>.json`, `<= 4,096` files) | `implemented` | [valleyhook/policy.go:88-221](valleyhook/policy.go), [valleyhook/record.go:19-36](valleyhook/record.go), [valleyhook/report.go:18-30](valleyhook/report.go), [knot/graph.go:24-31](knot/graph.go) |
| `valley-tree-v1` manifest (`"valley-tree-v1\n"` + `<mode> <sha256> <len> <path>\n` sorted by path bytes) and `valley-inputs-v1` manifest (`"valley-inputs-v1\n"` + `<len> <name>\n` sorted and deduplicated) | `implemented` | [attest/digest.go:5-25](attest/digest.go), [57-98](attest/digest.go) |
| Transfer statement (`the-valley/integration/transfer/v1`, stored at `transfer.note` under `refs/the-valley/attestations/<landed-tree>/<integrator-key-hash>`), carrying `change`, `target`, `base.valley-tree-v1`, `policy.{sha256,git-sha1}`, and either `checks` or `required: "none"` | `implemented` | [integrator/transfer.go:31](integrator/transfer.go), [43-97](integrator/transfer.go), [schema/attestation.cue:1-130](schema/attestation.cue) |
| CLI JSON output schemas: `valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, and `valley knot --json` | `implemented` | [status/status.go:25-115](status/status.go), [status/list.go:22-75](status/list.go), [status/pending.go:24-85](status/pending.go), [knot/plan.go:20-70](knot/plan.go) |
---
contributor2026-10-19 11:48 UTC
Slice 2 landed 2026-10-19 (wstq, cd00211): docs/guide.md by Codex, reviewed by Claude; the style guide now lives in AGENTS.md. Slice 3 (docs/reference.md) is change nxkn, run 20261019-1148-4ab56e8d, Argon writing and Astra reviewing.
contributor2026-10-19 13:04 UTC
Slice 3 landed 2026-10-19 (nxkn, 25cb784): docs/reference.md by Argon, reviewed by Astra; line-number citations removed and AGENTS.md rule 5 now says the checklist lives in the brief and change description. Follow-up ylnv (run 20261019-1304-d648019a) removes the line citations left in docs/concepts.md from slice 1. Next: slices 4 (slim architecture.md; hold until feature work is quiet), 5 (retire roadmap.md after checking the inventory against knots) and 6 (valley help).
contributor2026-10-20 11:58 UTC
2026-10-20: landed ylnv (concepts without line numbers), nqzq (prose-format lints vocabulary, line-number citations and narration phrases) and the first scheduled docs pass usxp (through 25cb784). Next: slices 4 to 6; agent reviews (oc-5b0e87c) will add a docs-style review.
contributor2026-10-24 12:01 UTC
Operator, 2026-10-24: Gemini (the top model via agy, chosen as the docs pass chooses it) writes or rewrites the-valley's user-facing prose: docs/, README.md, valley help text and user-facing messages. Astra fact-checks every claim against the code. Implementing agents keep code comments and commit messages. Process for now: after a change touches user-facing prose, the coordinator runs a Gemini rewrite pass on that change, then Astra's check, before readying it. Policy-driven automatic reviews (oc-5b0e87c) replace the manual step later.
From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 3 of 11: - **CLI reference is maintained twice:** `bin/valley:57-695` and `docs/architecture.md:700-1393` duplicate the description of every CLI verb, flag, and exit code. - **Deployment status and deferred work are maintained in three places:** `docs/architecture.md:1695-1815`, `docs/security.md:221-265`, and `docs/roadmap.md:11-155`. --- ## 3. Information architecture We organize the documentation into **seven documents** with distinct altitudes and readers, retire `docs/roadmap.md`, and split `valley help` into a one-screen summary plus `valley help <verb>`. ### 3.1 The document set and reader flow ```mermaid flowchart LR README["README.md<br/>(One-screen overview)"] PURPOSE["docs/purpose.md<br/>(Operator's premise)"] CONCEPTS["docs/concepts.md<br/>(Domain model & glossary)"] GUIDE["docs/guide.md<br/>(Role-based journeys)"] REF["docs/reference.md<br/>(CLI, schemas & wire formats)"] ARCH["docs/architecture.md<br/>(Design, rationale & checks)"] SEC["docs/security.md<br/>(Threat model & trust gates)"] README --> PURPOSE README --> CONCEPTS CONCEPTS --> GUIDE GUIDE --> REF CONCEPTS --> ARCH ARCH --> SEC ARCH --> REF ``` | Document | Primary reader | Purpose | | :--- | :--- | :--- | | **`README.md`** | Everyone (Evaluator first) | One-screen overview: what the-valley is, the lifecycle of a change, prerequisites, current limitations, how to view the live plan (`valley plan`), and where to read next. | | **`docs/purpose.md`** | Evaluator, Operator, Contributor | The operator's goals, governing principles, and ownership boundaries. Left untouched for the operator to write; until written, `README.md` links to `docs/concepts.md` for "why". | | **`docs/concepts.md`** *(new)* | Evaluator, Newcomer | Plain-language explanation of the five core concept groups (meaning first, git/Nix realization second; code guarantees vs. deployment choices vs. unbuilt features separated) plus the full glossary. | | **`docs/guide.md`** *(new)* | Author, Operator, Host Admin, Contributor | Step-by-step journeys: client setup, authoring a change, reviewing and approving, planning with knots, recovering from failure, setting up a host from scratch, and contributing to the-valley. | | **`docs/reference.md`** *(new)* | Author, Operator, Contributor | Exact lookup tables: CLI verbs/flags/exit codes, environment and git config variables, ref namespace rules and size limits, JSON output schemas, record/attestation/transfer schemas, and CUE schemas. | | **`docs/architecture.md`** | Contributor, Security Auditor | Component design (`valleyhook`, `integrator`, `attest`, `identity`, `status`, `rebase`, `knot`), design rationale, security caveats, invariants, executable flake checks, reference deployment state, and what is not yet wired. | | **`docs/security.md`** | Operator, Host Admin, Security Auditor | Trust boundaries, threat analysis across the path of a change, rollout gates, and current reference deployment posture. | *Why combine Getting Started and How-To Guides into one `docs/guide.md`?* For a CLI tool with five distinct roles, splitting "getting started" from "how-to" forces readers to jump between two task documents for the same workflow. A single role-indexed `docs/guide.md` starts with a 2-minute client setup and then gives each role a self-contained section. ### 3.2 Section-level outlines #### 1. `README.md` - **What is the-valley** (plain definition + the four steps of a change: propose, mark ready, approve, integrate) - **A quick tour** (five commands showing the author and operator loop) - **Prerequisites and current limitations** (Nix, git, SSH, NixOS host; what is not built yet; how to read the live plan with `valley plan` and why a GitHub mirror does not carry it) - **Where to go next** (links by role) #### 2. `docs/purpose.md` - Reserved for the operator. Untouched by this migration. #### 3. `docs/concepts.md` - **Why the-valley exists** (coordinating fast authors and deliberate operators without giving every author direct write access to `main`) - **What the code enforces vs. what a deployment configures** (explicit three-way key: code-enforced, deployment choice, not built) - **Changes: ready, approved, submitted** (meaning first; then git realization via topic branches, `refs/the-valley/changes/<id>`, and `refs/the-valley/requests/<change>`) - **Checks and evidence** (policy floor + project narrowing, path classes and `unclassified`, pure vs. effectful checks, signed attestations, evidence transfer and transfer statements) - **The host, the hook, and the integrator** (how `services.valley` receives pushes, what `valleyhook` enforces, and how the integrator lands approved changes and writes outcome records) - **Records, project storage, the plan graph, and knots** (why project metadata lives outside `main` under `refs/the-valley/*`, why mirrors and plain clones do not fetch it by default, and how knots form the plan graph) - **Principals and grants** (SSH identities, static vs. compiled identity configuration, `request` and `restack` grants, and boundaries) - **Glossary** (alphabetical table of every domain term, one-line plain definition, and link to deeper reference) #### 4. `docs/guide.md` - **Client setup** (running `valley` via `nix run`, `valley self-update`, configuring `VALLEY_KNOWN_SIGNERS` and `VALLEY_INTEGRATOR_SIGNER`, shell completions) - **Authoring a change** - Creating a change and running required checks locally (`valley checks`) - Pushing and marking a change ready (`valley ready`, `--stamp` for a brand-new unpushed local commit, or `jj` `change-id` headers) - Inspecting status and check evidence (`valley status`) - Revising a change while keeping its Change ID (`Change-Id` trailer, `jj` header, or `--change <id>`) - Pausing (`valley unready`) and abandoning (`valley withdraw`, including how to immediately revoke an already-approved request vs. waiting for the integrator's next pass) - Restacking onto a newer `main` (`valley rebase --check`, `valley rebase`) - **Reviewing and approving changes (Operator)** - Listing changes awaiting review (`valley pending`) and browsing all recorded changes (`valley changes`) - Reviewing a change or stack (`valley review <change>`, and incremental review with `--since approved`) - Approving a change (`valley approve <change>`) - Watching the integrator (`valley tail`) and auditing past landings (`valley replay`) - **Planning work with knots** - Reading the live plan (`valley plan`, `--focus`, `--all`) - Creating, updating, linking, and closing knots (`valley knot create`, `update`, `show`, `list`, `check`) - **Recovering from failure** - Recovering from a `stale` request (base moved; restacking with `valley rebase` and getting re-approval) - Recovering from a `reject` outcome (merge conflict with `main` or missing/expired check evidence) - Recovering from a refused push (`valleyhook` errors: protected ref, `.valley-hold`, non-fast-forward or non-owner record push, oversize or malformed record/knot) - Investigating an `uncertain` landing (`failed` outcome record, consumed request ref without a verified landing on `main`, or unset `VALLEY_KNOWN_SIGNERS` / `VALLEY_INTEGRATOR_SIGNER`) - **Running a valley host (Administrator)** - Minimal `valley.cue` and `services.valley` NixOS configuration (and why `examples/hosts/protected.cue` is a test fixture, not a production recipe) - Initializing repositories (`valley-init`) and bootstrap-seeding the initial `main` commit (`policy/instance/*.cue`, `identity/*.cue`, `policy/valley`, `policy/project/*.cue`) - Enabling the integrator: provisioning the Ed25519 signing key (`signingKeyFile`), `signingName`, and `instanceProject` vs. `instancePolicy` - Configuring principals, grants, and trusted signers: identity compilation (`services.valley.identity.enable`) vs. static `authorizedKeys`, `grants`, and `integrator.knownSignersFile` - Configuring push mirrors: `git` user SSH key, `known_hosts`, and cleaning pre-existing refs before cutover - Configuring offsite backups (`restic` secrets) and verifying backup and restore (`restic restore` + `git fsck`) - Using the operator push hold (`${dataDir}/.valley-hold`) - **Contributing to the-valley** - Entering the dev shell (`nix develop`) - Running fast Go unit tests (`go test ./...`) - Running single Nix flake checks (`nix build .#checks.x86_64-linux.<check>`) and the full suite (`nix flake check`) - Checking documentation formatting and links (`prose-format`) #### 5. `docs/reference.md` - **CLI reference** (every `valley` subcommand, synopsis, flags, arguments, exit codes, and naming rules for Change IDs, handles, branch names, and request names) - **Environment variables and git config** (`VALLEY_KNOWN_SIGNERS`, `VALLEY_INTEGRATOR_SIGNER`, `VALLEY_FLAKE`, `valley.knownSignersFile`, `valley.integratorSigner`, `SSH_ORIGINAL_COMMAND`) - **Project storage ref layout and bounds** (table of `refs/heads/*`, `refs/tags/*`, `refs/the-valley/*`, who may write each, object types, and size limits) - **Wire formats and JSON schemas** - Change record (`valley-change-record/v1`) and parent-history rules - Restack report (`valley-restack-report/v1`) - Attestation note and statement (`the-valley/attestation/v1`) and canonical digest manifests (`valley-tree-v1`, `valley-inputs-v1`, `valley-delta-v1`) - Integrator transfer statement (`the-valley/integration/transfer/v1`) - Integrator outcome record (`refs/the-valley/outcomes/<change>`) - CLI JSON outputs (`valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, `valley knot --json`) - **CUE configuration schemas** (`schema/valley.cue`, `schema/verification.cue`, `schema/attestation.cue`, `schema/identity.cue`) #### 6. `docs/architecture.md` - **Reference deployment note** (the deployment project, klaus, the valley host, the instance repository) - **System overview** (end-to-end component diagram and trust boundaries) - **The Git host and `valleyhook`** (SSH forced command, push hold, ref-by-ref enforcement invariants, record/report/knot validation, post-receive mirror trigger, offsite backup service) - **Verification policy and attestations** (two-layer CUE unification, monotonic narrowing, path classification and `unclassified`, `attest` binary, pure vs. effectful check execution, content-addressed note storage) - **The integrator** (reconciliation loop, fast-forward vs. `git merge-tree` single-parent commit landing, evidence transfer rules, transfer statements and countersignatures, pre-commit readiness re-check and its narrow race window, outcome records, withdrawn-change request cleanup) - **Change lifecycle and review invariants** (`status/`, `rebase/`, `change/`: landing states `landed` / `landed-recorded` / `uncertain` / `not-landed`, `approvedVersion` resolution and non-fallback rule, restack safety gate, self-update integrity) - **The plan graph (`knot/`)** (data model, independent cycle checks on local `parent` and local `blocked_by` edges, syntax-only cross-project `blocked_by`, CAS retry loop) - **Identity compilation (`identity/`)** (two-stage CUE + Go pipeline, governance orphan check on `registry` boundaries, atomic output publishing) - **Executable verification table** (mapping every architectural guarantee to its Nix flake check in `nix/checks/`) - **How the deployment project deploys it** (current reference deployment state) - **What is in the repo vs. not yet wired** (honest inventory of built components vs. unbuilt automation) #### 7. `docs/security.md` - **Reference deployment note** (the deployment project, klaus, the valley host, the instance repository) - Unchanged in structure: threat model along the path of a change, rollout gates, and current deployment posture, with its retired `roadmap.md` link removed. ### 3.3 Where existing `docs/architecture.md` content goes and anchor audit Every section of `docs/architecture.md` is accounted for. Design rationale and security caveats stay in `docs/architecture.md`:From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 2 of 11: ## 2. Diagnosis of the current docset The existing documentation is accurate and well-tested against the code. Its core problem is **altitude compression**: almost everything lives in `docs/architecture.md` (1,815 lines) and `bin/valley` (639 lines of help output), written from the perspective of the builders who implemented the system. ### 2.1 Structure and order - **`README.md` skips what a user does.** Lines 1–75 explain the motivation for agent-first software engineering, and lines 77–93 list links. It never states what commands exist, what prerequisites are needed, what limitations apply today, or how a change moves from an author's commit to `main`. - **`docs/purpose.md` is a three-line placeholder** (`# Purpose`, `What is the purpose of the-valley?`), yet `README.md` sends newcomers there first for "goals, governing principles, and ownership boundaries." - **`docs/architecture.md` mixes four altitudes in one file:** 1. Host internals and ref layout (`lines 20–423`, `1394–1694`). 2. Wire schemas and JSON contracts (`lines 424–699`, `829–883`, `903–929`, `942–989`, `1027–1119`, `1216–1294`). 3. End-user CLI manual (`lines 700–1393`). 4. Fleet-specific operational state (`lines 1695–1815`). A reader looking for how to propose or review a change must scroll past 700 lines of pre-receive hook rules, CUE policy evaluation, and knot JSON schemas before reaching `## The valley CLI` at `docs/architecture.md:700`. - **`docs/roadmap.md` contradicts the project's own rule.** `docs/architecture.md:652` states that a project's live plan lives in `refs/the-valley/knots` (`valley plan`), yet `docs/roadmap.md` maintains a parallel prose tracker of milestones (`M0-H`, `M1`–`M7`) and open questions (`lines 144–155`). ### 2.2 Jargon used before it is defined Across `docs/architecture.md` and `docs/security.md`, domain terms appear hundreds of lines before their definitions: | Term | First used | Defined at | Gap | | :--- | :--- | :--- | :--- | | **Instance** / **instance floor** | `docs/architecture.md:7` ("instance floor (the instance repository)") | `docs/architecture.md:190` | 183 lines; The instance repository is named at line 7 before "instance" is defined | | **Project storage** | `docs/architecture.md:31` (diagram) | `docs/architecture.md:77-90` | Shown as git ref namespaces before explaining why metadata lives outside the source tree | | **Principal** & **grants** (`request`, `restack`) | `docs/architecture.md:57-74` | `docs/architecture.md:107-122`, `1394-1534` | Used in the ref table before explaining how SSH keys map to principals | | **Change record**, **active version**, **ready / draft / withdrawn** | `docs/architecture.md:61` | `docs/architecture.md:424-510` | 363 lines; introduced as a ref path and JSON schema rather than a user concept | | **Integration request** & **outcome record** | `docs/architecture.md:64-68` | `docs/architecture.md:332-406`, `807-828` | Readers meet `refs/the-valley/requests/<change>` at line 64 and only learn at line 807 that `valley approve` writes it | | **Attestation**, `valley-tree-v1`, **transfer statement** | `docs/architecture.md:62` | `docs/architecture.md:274-330`, `367-379` | `valley-tree-v1` is used at lines 62 and 279; its canonical manifest format lives only in `attest/digest.go:5-18` | | **Knot** (`work`, `gate`, `question`, `finding`, `direction`, `milestone`) | `docs/architecture.md:63` | `docs/architecture.md:650-698` | 587 lines between first mention in the ref table and definition | | **Handle** vs. **Change ID** | `docs/architecture.md:721` | `docs/architecture.md:1306-1312` | 585 lines between first CLI example using `<change>` and the rule for shortest unique prefixes (`k`–`z`, at least 4 letters) | | **Approved version** (`approvedVersion`) | `docs/architecture.md:505` | `docs/architecture.md:1005-1025` | Referenced at line 505 and explained 500 lines later | | **Fleet hostnames** (the deployment project, the instance repository, the valley host, klaus, a workstation) | `docs/architecture.md:6-10`, `docs/security.md:7-16` | `docs/architecture.md:1695-1715` | External readers meet four internal machine/repo names in the first paragraph before learning they belong to the reference deployment | ### 2.3 Mechanism shown before purpose - **Changes are introduced as JSON blobs under git refs.** At `docs/architecture.md:424-465`, a change is introduced as `refs/the-valley/changes/<id>` with its JSON schema (`valley-change-record/v1`) and parent-history rules (`P = [h]`, `P = [old]`) before the reader is told what a change is or why `valley ready` exists. - **Approval is introduced as a git ref write.** At `docs/architecture.md:64-66`, the reader learns about `refs/the-valley/requests/<change>` as a hook-guarded ref rather than learning that approval binds a specific reviewed commit so the integrator can verify and land it. - **`bin/valley help` is a 639-line wall of text.** Running `valley help` prints every flag, JSON schema note, and knot subcommand (`bin/valley:57-695`). Only `valley help knot` (`bin/valley:698-714`) has per-verb help. ### 2.4 Missing tasks A newcomer cannot find step-by-step instructions for: 1. **End-to-end authoring:** Creating a topic branch, running `valley checks`, pushing, marking `ready` (with or without `--stamp` or `jj`), revising after review while preserving the Change ID, and seeing when a change has landed. 2. **End-to-end reviewing and approving:** Listing ready changes (`valley pending`), reviewing a change or stack (`valley review`), incremental review after a revision (`--since approved`), approving (`valley approve`), and tailing the integrator (`valley tail`). 3. **Recovering from failure:** What to do when an integration request goes `stale` (`valley rebase`), when `valleyhook` refuses a push, when `valley status` or `valley rebase` reports an `uncertain` landing (`failed` outcome or missing signer env vars), or when a change is `reject`ed on a merge conflict or failed check. 4. **Standing up a valley host from scratch:** `examples/hosts/protected.cue` is a test fixture for `protect-e2e` exercising four protection configurations (`sealed`, `guarded`, `released`, `open`), not a minimal host setup. No doc walks through bootstrap-seeding `main` in a freshly initialized bare repo (`valley-init`), provisioning the integrator's Ed25519 key and trusted signers, wiring push mirror SSH credentials, and verifying offsite `restic` backups and restores. 5. **Contributor setup and local testing:** Entering `nix develop`, running fast Go unit tests vs. Nix sandbox checks, and checking documentation formatting and links. ### 2.5 DuplicationFrom the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 5 of 11: 1. **M0-H residual — Credential rotation** (`docs/roadmap.md:31-32`, `129-130`): Rotate secrets whose old ciphertext remains in the deployment project's git history, starting with the integrator's signing key. 2. **M1-B / M1-C — Signed release promotion (`sigverify` wiring)** (`docs/roadmap.md:18`, `73-76`): Wire `sigverify` into the pull tool so converging hosts verify hardware-key-signed (`ssh:<project>-release`) sequenced release tags against their running trust root, refuse replays/downgrades, ignore unsigned `main`, and cover or retire `system.autoUpgrade` (on two hosts) and work profiles. 3. **M1-C — Touch-gated human approvals** (`docs/roadmap.md:18`, `77-86`): Extend `schema/identity.cue` and `identity/` for hardware-backed (`sk-*`) keys, move the `request` grant to `ssh:valley-approve` hardware keys, build a Go `valley approve` signing `{repo, change, candidate commit, target, policy snapshot}` with batching and withdraw-generation binding, and enforce per-path-class approvals in the integrator. 4. **M5 — the deployment project on the valley** (`docs/roadmap.md:17`, `56-67`; blocks closing an agent account's GitHub merge path to the deployment project): Host the deployment project on the-valley with GitHub as a push mirror, addressing GitHub bots on a mirror (`ida-62a7a3b`) and per-repo GitHub deploy keys (`ida-a0e5d03`). 5. **M6 — `klaus` on the valley** (`docs/roadmap.md:19`, `88-98`; depends on M5 and M1-C): Move the `klaus` pipeline out of the dashboard into a persistent daemon with per-change/session/backend budgets, a valley backend filing changes with `Change-Id` and `Klaus-Run` trailers and checkpointing paused runs to valley refs, and event instrumentation. 6. **M7 — Throughput and research** (`docs/roadmap.md:20`, `100-108`; depends on M6 instrumentation): Measure wall-clock stage timings first, then test a hybrid speculative queue with evidence reuse and run land-then-verify (with automatic revert) and stacked-change experiments on low-risk path classes. 7. **M2 — Real builds, binary cache, promotion, and canaries** (`docs/roadmap.md:22`, `112-115`): Isolate CI runners with CPU/memory caps, build every converging host in CI (including `aarch64` Pis), serve a Harmonia binary cache on the valley host, run the promotion tool in the release environment, add role canaries/soak periods, and place `/srv/git` on its own dataset of a snapshotting filesystem with snapshots. 8. **M4 — the-valley's refocus** (`docs/roadmap.md:22`, `116-125`): Make landings crash-safe via a single ref transaction with write-ahead intent and an append-only ledger ref; include instance policy and registry snapshot in the reconciliation memo; move check execution out of the integrator into workers; produce check evidence before human review; drop effectful validity windows and closure-transfer machinery; consolidate `bin/valley`, `integrator/`, `identity/`, and `attest/` into one Go binary; and replace custom `sumdb/note` attestations with SSHSIG verified by `sigverify`. 9. **Valley identity follow-ups** (`docs/roadmap.md:126-128`): Bump the instance repository's `the-valley` pin, trigger identity compilation immediately when the instance repository lands a change (in addition to the 5-minute timer), and stop the static bootstrap key for a principal from outliving its registry expiry. 10. **Deliberately deferred directions** (`docs/roadmap.md:132-143`): Capability-style delegation chains (`ida-a8243d2`), approving broad intent as a delegation contract, speculative integration before measurement, custom non-git/"no `main`" change API, self-hosted web forge, and agent-environment fulfillment engine. 11. **Five open decisions (`question` knots)** (`docs/roadmap.md:144-155`): - *Release environment (`146-148`):* Where release builds are verified and signed outside the valley host's root authority (a workstation without agents, a dedicated small machine, or a release-only laptop). - *Touch budget (`149-150`):* Which path classes in the deployment project and `the-valley` require human approval, and how approvals batch across integration and promotion. - *Work-profile switch (`151`):* Whether to keep the work-profile switch paused or bring it under signed promotion. - *Phase 2 release manifests (`152-153`):* When releases pin exact closures signed off the valley host so the binary cache becomes untrusted transport. - *Agent guest memory size (`154-155`):* Raising or offloading the 10–12 GiB agent guest limit so agents can run `nix flake check` on the deployment project. ---From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 8 of 11: ## 5. Glossary This table lives at the end of `docs/concepts.md`. Every term has a one-line plain definition and a pointer to its full explanation. | Term | Plain definition | Full explanation | | :--- | :--- | :--- | | **Active version** | The highest-numbered version (`vN`) in a change record (`versions[len-1]`). | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/reference.md#change-record-schema` | | **Approved version** | In `valley status` and `valley review`, the greatest prior version of a revised change whose exact head commit carries an unambiguous integration request or `land`, `stale`, or `reject` outcome record on `origin` (never falling back to an older version if the greatest version with evidence is ambiguous). | `docs/guide.md#reviewing-and-approving-changes`, `docs/architecture.md#review-against-the-approved-version` | | **Attestation** | A signed statement (`the-valley/attestation/v1`) stored under `refs/the-valley/attestations/<tree-digest>/<key-hash>` recording that a check passed on a specific content tree (`valley-tree-v1`). | `docs/concepts.md#checks-and-evidence`, `docs/reference.md#attestation-schema` | | **Base** | The `main` commit (`versions[i].base`) a change version was branched or rebased from (`git merge-base origin/main <head>`). | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/reference.md#change-record-schema` | | **Boundary** | A named scope in the identity registry (`kind: "request"`, `"restack"`, or `"registry"`) where a principal holds a grant. | `docs/concepts.md#principals-and-grants`, `docs/reference.md#cue-configuration-schemas` | | **Change** | A tracked unit of proposed work with a stable 32-letter Change ID (`k`–`z`), moving through `draft`, `ready`, or `withdrawn` states across numbered versions (`v1`, `v2`, …) until submitted to `main`. | `docs/concepts.md#a-change-ready-approve-submitted` | | **Change ID** | A 32-character identifier drawn from letters `k` through `z` (`[k-z]{32}`) that uniquely names a change across revisions and rebases. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/reference.md#naming-rules` | | **Change record** | The JSON document (`valley-change-record/v1`) stored at `refs/the-valley/changes/<id>` tracking a change's owner, state, and version history. | `docs/reference.md#change-record-schema`, `docs/architecture.md#change-records` | | **Check** | An executable verification step that a change requires based on the path classes its diff touches (including `unclassified` for paths matching no declared class). | `docs/concepts.md#checks-and-evidence` | | **Draft** | A change state meaning work is in progress or paused (`valley unready`) and not currently up for integration. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#authoring-a-change` | | **Effectful check** | A check (`runner: "command"`) that may depend on external state; its evidence transfers across `main` movement (`untouched`) only if no intervening change touched a path class requiring the check and the observation age is within the policy's `validity` window. | `docs/concepts.md#checks-and-evidence`, `docs/architecture.md#verification-policy-and-attestations` | | **Evidence** | Signed check attestations stored in project storage that prove a change's required checks passed. | `docs/concepts.md#checks-and-evidence` | | **Grant** | A capability (`request` or `restack` in `valleyhook`, or `registry` for the identity compiler's orphan check) assigned to a principal statically in NixOS or compiled from the identity registry. | `docs/concepts.md#principals-and-grants`, `docs/architecture.md#identity-compilation` | | **Handle** | The shortest prefix of a Change ID (at least 4 letters, or `<repo>:<prefix>` across repos) unique among changes currently recorded on `origin`; it can lengthen if a colliding Change ID is recorded later. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/reference.md#naming-rules` | | **Identity registry** | The directory of CUE files (`identity/*.cue`) in the instance repository that an instance can compile (`services.valley.identity.enable`) into SSH `authorized_keys`, `known-signers`, and `grants`. | `docs/concepts.md#principals-and-grants`, `docs/architecture.md#identity-compilation` | | **Instance** | A deployment of one or more projects governed by a shared floor verification policy and identity configuration (in the reference deployment, the instance repository). | `docs/concepts.md#checks-and-evidence`, `docs/architecture.md#verification-policy-and-attestations` | | **Instance floor** | The mandatory baseline verification policy (`policy/instance/`) that every project in an instance must satisfy; project policy is optional and can only narrow (strengthen) the floor. | `docs/concepts.md#checks-and-evidence`, `docs/architecture.md#verification-policy-and-attestations` | | **Integration request** | A commit ref at `refs/the-valley/requests/<change>` written by a `request` grant holder (`valley approve`) authorizing the integrator to verify and land that exact commit onto `main`. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#reviewing-and-approving-changes` | | **Integrator** | The optional host service (`services.valley.integrator.enable`) that polls integration requests (default every `15s`), verifies policy and check evidence, lands passing ready changes onto `main`, writes transfer statements, and records outcomes. | `docs/concepts.md#the-host-the-hook-and-the-integrator`, `docs/architecture.md#the-integrator` | | **Knot** | A single record (`<id>.json` under `refs/the-valley/knots`) in a project's plan graph, typed as `work`, `gate`, `question`, `finding`, `direction`, or `milestone`. | `docs/concepts.md#records-project-storage-the-plan-graph-and-knots`, `docs/reference.md#knot-schema` | | **Landed / Landed-recorded** | The two states of a submitted change version: `landed` when its commit is on `main`'s first-parent history with no merge commit above it; `landed-recorded` when a single-parent commit on `main` carries a verified transfer statement and `land` outcome record for that version's head and merges to the same tree. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/architecture.md#change-lifecycle-and-review-invariants` | | **Outcome record** | A single-line blob written by the integrator at `refs/the-valley/outcomes/<change>` recording `land`, `stale`, `reject`, or `failed` for an integration request. | `docs/concepts.md#the-host-the-hook-and-the-integrator`, `docs/reference.md#outcome-record-schema` | | **Path class** | A named group of file glob patterns in verification policy mapped to the checks required when a change modifies matching files (with unmatched paths falling into `unclassified`). | `docs/concepts.md#checks-and-evidence`, `docs/reference.md#cue-configuration-schemas` | | **Plan graph** | The directed graph of knots stored at `refs/the-valley/knots` and viewed with `valley plan`; local `parent` and local `blocked_by` edges are each checked separately for cycles. | `docs/concepts.md#records-project-storage-the-plan-graph-and-knots`, `docs/guide.md#planning-work-with-knots` | | **Principal** | A named human or agent identity associated with SSH public keys or attestation signing keys. | `docs/concepts.md#principals-and-grants` | | **Project storage** | The `refs/the-valley/*` namespace on a valley host holding change records, attestations, requests, outcomes, restack reports, and knots outside `main` (not pushed to mirrors or fetched by a plain `git clone`). | `docs/concepts.md#records-project-storage-the-plan-graph-and-knots`, `docs/reference.md#project-storage-ref-layout-and-bounds` | | **Pure check** | A hermetically sandboxed Nix flake check (`runner: "nix"`) whose evidence never expires with time and transfers across `main` movement if the tree is `unmoved` or if both its input-closure digest (`valley-inputs-v1`) and derivation digest match (`closure`). | `docs/concepts.md#checks-and-evidence`, `docs/architecture.md#verification-policy-and-attestations` | | **Push hold** | The sentinel file (`${dataDir}/.valley-hold`, default `/srv/git/.valley-hold`) on a valley host that pauses all incoming SSH pushes across all projects while present. | `docs/guide.md#running-a-valley-host`, `docs/architecture.md#valley-init-and-the-push-hold` | | **Ready** | The change state set by `valley ready`, declaring that the active version is complete and awaiting operator review and approval. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#authoring-a-change` | | **Restack report** | A JSON record (`valley-restack-report/v1`) under `refs/the-valley/restack-reports/<id>` validated by `valleyhook` and displayed by `valley status`/`valley pending` to report an automated restack outcome (the automatic restacker service itself is not built yet). | `docs/reference.md#restack-report-schema`, `docs/architecture.md#restack-reports` | | **Submitted** | A change version that has been integrated into `main` (either `landed` or `landed-recorded`). | `docs/concepts.md#a-change-ready-approve-submitted` | | **Transfer statement** | A signed attestation (`the-valley/integration/transfer/v1`) written by the integrator on every landing (both fast-forward and merged), binding the landed tree and commit to the attested base tree, policy digest, and per-check verdicts. | `docs/concepts.md#checks-and-evidence`, `docs/reference.md#transfer-statement-schema` | | **Uncertain** | The landing state reported when neither `landed` nor `landed-recorded` holds and either the outcome record says `failed`, or it says `land` while the request ref was consumed (or signer verification env vars are unset for a merged landing). | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#recovering-from-failure` | | **`valley-tree-v1`** | The SHA-256 content-addressing scheme over a canonical manifest of a tree's files, executable bits, and symlinks (`<mode> <sha256> <path-len> <path>`), independent of git commit metadata. | `docs/reference.md#attestation-schema`, `attest/digest.go:5-18` | | **`valleyhook`** | The Go pre-receive hook binary that validates every SSH push to a valley host against ref protection, grants, and record/knot schemas. | `docs/concepts.md#the-host-the-hook-and-the-integrator`, `docs/architecture.md#what-a-push-may-write` | | **Withdrawn** | A change state set by `valley withdraw`, taking a change off the review queue; the integrator deletes pending requests for a withdrawn change on its next pass if the change is still withdrawn. | `docs/concepts.md#a-change-ready-approve-submitted`, `docs/guide.md#authoring-a-change` | --- ## 6. Style guide Add these rules to `AGENTS.md` so every future doc change follows the same standard: 1. **Simple language, one new idea per sentence.** Lead every section with a plain statement of what the thing is in ordinary words before qualifying it. If a sentence stacks abstractions, split it in two. 2. **Meaning before mechanism.** State what a concept or command accomplishes for the user before explaining how git refs, CUE unification, or Nix derivations implement it today. 3. **Example before abstraction.** In guides and reference material, show a concrete command or 5-line snippet before listing edge-case rules or schema tables. 4. **Separate three kinds of claim everywhere.** Never let a reader mistake a deployment choice or an unbuilt plan for a code guarantee: - **Code-enforced (`implemented`):** What `valleyhook`, `integrator`, `attest`, `identity`, or `valley` always enforces. - **Deployment configuration (`deployment choice`):** What an instance configures in `valley.cue`, `services.valley`, `policy/`, or `identity/` (such as whether `main` is protected, whether `protection.writers` is empty, who holds `request`, and whether the integrator or identity compiler is enabled). - **Not built yet (`not built`):** Mechanisms planned or partially scaffolded (such as the automatic restacker service or approval carry across restacks). 5. **Mandatory Claim-to-Code Checklist in every doc change.** Every doc slice brief and change description must carry a checklist of each factual claim added or modified, labelled `implemented`, `deployment choice`, or `not built`, with an exact `file:line` citation verified against HEAD before review. 6. **Present tense, no transition narration.** Describe what the code at HEAD does today. Do not write "previously we used X" or "soon this will do Y." Live plans and open questions belong in `valley plan` (`refs/the-valley/knots`), not in prose docs. Do not compare the-valley to other platforms; positioning is the operator's to write. 7. **Strict vocabulary:** - A change is `draft`, `ready`, `approved`, or `submitted` (never call a valley change a "PR", "pull request", or "branch"). - A change **requires** checks (never "owes" checks). - A plan item is a **knot** in the **plan graph** (never "issue", "ticket", or "knowledgebase"). - Operational metadata refs (`refs/the-valley/*`) are **project storage**, distinct from **the source** (`main` and release tags). 8. **The Taoist wink.** Keep the wink at threshold moments — introducing the valley as the low place where streams of work converge, or explaining why a plan record is called a knot (from knotted cords before writing). One light sentence at the start of a concept is enough; never use metaphor inside procedural instructions, error messages, or security invariants. ---From the coordinator's working file `docs-pm-argon-rev2.md` (moved here 2026-10-18), part 10 of 11: | Claim | Kind | Code citation | | :--- | :--- | :--- | | `valley self-update` builds `#valley` with `--no-write-lock-file` from `VALLEY_FLAKE` (when invoked from `/nix/store/`), `git rev-parse --show-toplevel` (when in a checkout carrying `bin/valley`), or `$HOME/the-valley` | `implemented` | `bin/valley:1252-1305` | | `valley review <change>` pages the diff and interactively offers `[a]pprove` only when the change is `ready` (and not above a non-ready stack layer); `--since approved` diffs against `approvedVersion` | `implemented` | `bin/valley:137-209`, `status/compare.go:6-27`, `260-289` | | `valley approve <change>` pushes `refs/the-valley/requests/c-<id>` (for a recorded `ready` change) or `refs/the-valley/requests/<branch>` (when `--head <sha>` is given for an unrecorded branch) | `implemented` | `bin/valley:1012-1135` | | `valley rebase` safety gate: refuses if any branch in the stack is `uncertain`, or if `VALLEY_KNOWN_SIGNERS` / `VALLEY_INTEGRATOR_SIGNER` are only partially set; if unset, merged landings cannot verify transfer statements | `implemented` | `rebase/snapshot.go:64-68`, `250-255`, `440-444` | | `examples/hosts/protected.cue` is a 4-repo test fixture for `protect-e2e`, not a production host config | `implemented` | `examples/hosts/protected.cue:1-33` | | `valley-init` initializes bare git repos (`--initial-branch=main`) and publishes `refs/the-valley/projects`, but creates no initial `main` commits; bootstrap seeding must happen via local host write (which bypasses `pre-receive`) or before sealing `protection.writers` | `implemented` / `deployment choice` | `nix/valley-host.nix:509-584`, `690-693` | | Host assertions: `services.valley.authorizedKeys` must be non-empty; enabling `integrator` requires `signingKeyFile` + `signingName`, either `instanceProject` (whose `refs/heads/main` is protected) or `instancePolicy`, and either `identity.enable = true` or `integrator.knownSignersFile` | `implemented` | `nix/valley-host.nix:1335-1425` | | Push mirrors (`valley-publish@<project>`) push `refs/heads/main` and `refs/tags/*` as the `git` Unix user using its SSH key and `known_hosts`; offsite backup (`restic-backups-valley`) snapshots `services.valley.dataDir` using `repositoryFile`, `passwordFile`, `sshKeyFile`, and `knownHostsFile` | `implemented` / `deployment choice` | `nix/valley-host.nix:252-260`, `1288-1330`, `1797-1867` | | Push hold sentinel path is `${services.valley.dataDir}/.valley-hold` (`/srv/git/.valley-hold` by default) | `implemented` | `nix/valley-host.nix:602`, `885-895` | --- ### Slice 3: Create `docs/reference.md` (Wire contracts, CLI reference, and schemas) - **Goal:** Establish a single reference manual for CLI flags, ref tables, wire schemas, and JSON contracts before slimming `docs/architecture.md`. - **What is created / rewritten / deleted:** - **Created:** `docs/reference.md`, consolidating the ref table, wire schemas (`valley-change-record/v1`, `valley-restack-report/v1`, `the-valley/attestation/v1`, `the-valley/integration/transfer/v1`, `valley-tree-v1`, `valley-inputs-v1`, `valley-delta-v1`, outcome records), CLI flags/exit codes/JSON contracts (`valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, `valley knot --json`), and CUE schema references. - **Modified:** `README.md`, `docs/concepts.md` (including glossary links), and `docs/guide.md` — add links to `docs/reference.md`. - **Untouched in Slice 3:** `docs/architecture.md` (slimmed in Slice 4 so `docs/reference.md` is reviewed cleanly on its own). #### Slice 3 Claim-to-Code Checklist | Claim | Kind | Code citation | | :--- | :--- | :--- | | Ref layout, object types, and size bounds: change record (`<= 64 KiB` `change.json`), restack report (`<= 64 KiB` `report.json`), attestation note (`<= 64 KiB` per blob, `<= 64` blobs), knot (`<= 64 KiB` per `<id>.json`, `<= 4,096` files) | `implemented` | `valleyhook/policy.go:88-221`, `valleyhook/record.go:19-36`, `valleyhook/report.go:18-30`, `knot/graph.go:24-31` | | `valley-tree-v1` manifest (`"valley-tree-v1\n"` + `<mode> <sha256> <len> <path>\n` sorted by path bytes) and `valley-inputs-v1` manifest (`"valley-inputs-v1\n"` + `<len> <name>\n` sorted and deduplicated) | `implemented` | `attest/digest.go:5-25`, `57-98` | | Transfer statement (`the-valley/integration/transfer/v1`, stored at `transfer.note` under `refs/the-valley/attestations/<landed-tree>/<integrator-key-hash>`), carrying `change`, `target`, `base.valley-tree-v1`, `policy.{sha256,git-sha1}`, and either `checks` or `required: "none"` | `implemented` | `integrator/transfer.go:31`, `43-97`, `schema/attestation.cue:1-130` | | CLI JSON output schemas: `valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, and `valley knot --json` | `implemented` | `status/status.go:25-115`, `status/list.go:22-75`, `status/pending.go:24-85`, `knot/plan.go:20-70` | --- ### Slice 4: Slim `docs/architecture.md` and add reference deployment note - **Goal:** Focus `docs/architecture.md` on component design, rationale, security caveats, invariants, and executable checks while preserving every linked heading anchor. - **What is created / rewritten / deleted:** - **Modified:** `docs/architecture.md` — replace duplicated wire field tables and end-user CLI flag manuals with links to `docs/reference.md` and `docs/guide.md`. Keep all design rationale, security caveats (such as the pre-commit readiness race window, `approvedVersion` ambiguity refusal and `base`-movement caveat, and self-update lockfile/store-path integrity), component invariants, flake check tables, and all 11 audited heading anchors (Section 3.3). Add the reference deployment framing note (the deployment project, klaus, the valley host, the instance repository) at the top and before `## How the deployment project deploys it`. #### Slice 4 Claim-to-Code Checklist | Claim | Kind | Code citation | | :--- | :--- | :--- | | All 11 audited heading anchors in `docs/architecture.md` (`#version-and-self-update`, `#review-against-the-approved-version`, `#change-records`, `#the-integrator`, `#what-a-push-may-write`, `#the-plan-graph`, `#restack-reports`, `#valley-init-and-the-push-hold`, `#the-source-and-project-storage`, `#the-plan-view`, `#listing-changes`) resolve cleanly | `implemented` | Verified by `prose-format` link-and-anchor check against `docs/security.md:62`, `112` and internal links | | Every flake check named in `docs/architecture.md` matches an attribute in `flake.nix` / `nix/checks/` | `implemented` | `nix/checks/cli.nix`, `nix/checks/knowledge.nix` | | Reference deployment framing note names the deployment project (reference NixOS fleet), klaus (agent runner), the valley host (primary valley host), and the instance repository | `deployment choice` | `docs/architecture.md:1695-1786` | --- ### Slice 5: Retire `docs/roadmap.md`, update `docs/security.md`, and update `AGENTS.md`Slice 3 brief (for Argon via agy), prepared 2026-10-19; launch once wstq lands: # the-valley docs, slice 3: docs/reference.md, the CLI and wire reference You are writing the third slice of the-valley's new documentation, from the docs proposal (revision 2) that you, Gemini 4 Argon, wrote as product manager and the operator accepted. Slices 1 and 2 have landed: `README.md`, `docs/concepts.md`, `docs/guide.md`, a link check inside `prose-format`, and a "Documentation style and verification" section in `AGENTS.md`. That section is the binding style guide; read it first. **The code at HEAD is the authority**: where the proposal and the code disagree, the code wins, and you say so in your report. ## What the operator asked for - **The voice of slice 1:** the operator liked your simplicity in `README.md` and `docs/concepts.md`. A reference is necessarily precise, but each entry still leads with what the thing is for, in one plain sentence, then its exact contract. An example comes before the rules. - **The approval grant is named `request` in code** (a rename to `approve` is filed as bug `bd-751047b`). Document the name the code uses, and say once that it is the grant that lets a principal approve. - **This slice creates the reference only.** Slimming `docs/architecture.md` is slice 4. Where reference material duplicates `architecture.md` today, write the reference entry and leave `architecture.md` alone; slice 4 replaces its copy with a link. ## How you work 1. Write `docs/reference.md` from the outline and slice section below, and link to it from `README.md`'s Documentation list and from `docs/concepts.md` and `docs/guide.md` where a reader looks something up. Every link must resolve (the link check enforces it). 2. Derive every flag, field, ref path and limit from the code, not from the existing docs: `bin/valley`'s usage block and dispatch, `status/` (valley-go), `change/`, `knot/`, `valleyhook/`, `integrator/`, `schema/`, `nix/valley-host.nix`. 3. Walk the slice's claim-to-code checklist below, labelling each claim implemented, deployment choice or not built, with `file:line`. Put the completed checklist in your report. 4. Before you commit, have Astra review: `klaus consult --backend codex --model gpt-6-astra --effort high --role critic --thread docs-slice-3 --timeout 30m --dir . "Review the uncommitted docs diff (git diff, plus new files) in this the-valley checkout against the code at HEAD. List every flag, field, ref, limit or behaviour the code contradicts, anything missing that a reader would look up, every deployment choice stated as a guarantee, broken links, transition narration, and vocabulary breaks. file:line and the fix. Under 600 words."` Fix every factual error; for anything you decline, say why. Then reread each entry's first sentence as a newcomer would. 5. `nix run .#fmt`, but commit only the docs you changed. Build `prose-format` and `own-policy` one at a time with `nix build --no-link .#checks.x86_64-linux.<name> -L`. Never `nix flake check`. Never run a tmux command. Don't leave `go build` output anywhere. 6. One commit: `docs: a reference for the CLI, records and refs`. No attribution lines. Push your topic branch to origin; never push main. Report: the reference's outline, the completed checklist, Astra's findings and what you did with each, and each check's result. ## From the proposal: the outline of docs/reference.md #### 5. `docs/reference.md` - **CLI reference** (every `valley` subcommand, synopsis, flags, arguments, exit codes, and naming rules for Change IDs, handles, branch names, and request names) - **Environment variables and git config** (`VALLEY_KNOWN_SIGNERS`, `VALLEY_INTEGRATOR_SIGNER`, `VALLEY_FLAKE`, `valley.knownSignersFile`, `valley.integratorSigner`, `SSH_ORIGINAL_COMMAND`) - **Project storage ref layout and bounds** (table of `refs/heads/*`, `refs/tags/*`, `refs/the-valley/*`, who may write each, object types, and size limits) - **Wire formats and JSON schemas** - Change record (`valley-change-record/v1`) and parent-history rules - Restack report (`valley-restack-report/v1`) - Attestation note and statement (`the-valley/attestation/v1`) and canonical digest manifests (`valley-tree-v1`, `valley-inputs-v1`, `valley-delta-v1`) - Integrator transfer statement (`the-valley/integration/transfer/v1`) - Integrator outcome record (`refs/the-valley/outcomes/<change>`) - CLI JSON outputs (`valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, `valley knot --json`) - **CUE configuration schemas** (`schema/valley.cue`, `schema/verification.cue`, `schema/attestation.cue`, `schema/identity.cue`) ## From the proposal: slice 3 and its checklist ### Slice 3: Create `docs/reference.md` (Wire contracts, CLI reference, and schemas) - **Goal:** Establish a single reference manual for CLI flags, ref tables, wire schemas, and JSON contracts before slimming `docs/architecture.md`. - **What is created / rewritten / deleted:** - **Created:** `docs/reference.md`, consolidating the ref table, wire schemas (`valley-change-record/v1`, `valley-restack-report/v1`, `the-valley/attestation/v1`, `the-valley/integration/transfer/v1`, `valley-tree-v1`, `valley-inputs-v1`, `valley-delta-v1`, outcome records), CLI flags/exit codes/JSON contracts (`valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, `valley knot --json`), and CUE schema references. - **Modified:** [README.md](README.md), `docs/concepts.md` (including glossary links), and `docs/guide.md` — add links to `docs/reference.md`. - **Untouched in Slice 3:** [docs/architecture.md](docs/architecture.md) (slimmed in Slice 4 so `docs/reference.md` is reviewed cleanly on its own). #### Slice 3 Claim-to-Code Checklist | Claim | Kind | Code citation | | :--- | :--- | :--- | | Ref layout, object types, and size bounds: change record (`<= 64 KiB` `change.json`), restack report (`<= 64 KiB` `report.json`), attestation note (`<= 64 KiB` per blob, `<= 64` blobs), knot (`<= 64 KiB` per `<id>.json`, `<= 4,096` files) | `implemented` | [valleyhook/policy.go:88-221](valleyhook/policy.go), [valleyhook/record.go:19-36](valleyhook/record.go), [valleyhook/report.go:18-30](valleyhook/report.go), [knot/graph.go:24-31](knot/graph.go) | | `valley-tree-v1` manifest (`"valley-tree-v1\n"` + `<mode> <sha256> <len> <path>\n` sorted by path bytes) and `valley-inputs-v1` manifest (`"valley-inputs-v1\n"` + `<len> <name>\n` sorted and deduplicated) | `implemented` | [attest/digest.go:5-25](attest/digest.go), [57-98](attest/digest.go) | | Transfer statement (`the-valley/integration/transfer/v1`, stored at `transfer.note` under `refs/the-valley/attestations/<landed-tree>/<integrator-key-hash>`), carrying `change`, `target`, `base.valley-tree-v1`, `policy.{sha256,git-sha1}`, and either `checks` or `required: "none"` | `implemented` | [integrator/transfer.go:31](integrator/transfer.go), [43-97](integrator/transfer.go), [schema/attestation.cue:1-130](schema/attestation.cue) | | CLI JSON output schemas: `valley-status/v1`, `valley-changes/v1`, `valley-pending/v1`, `valley-plan/v1`, and `valley knot --json` | `implemented` | [status/status.go:25-115](status/status.go), [status/list.go:22-75](status/list.go), [status/pending.go:24-85](status/pending.go), [knot/plan.go:20-70](knot/plan.go) | ---