gunk-dev/the-valley

guide.md

source826ad0ddebbcmain's published tip history
29.1 KiB · Rendered
1# A guide to working in the valley
2
3This guide follows the jobs people do in a valley. Start with the [README](../README.md) for a short
4tour, [Concepts and glossary](./concepts.md) for the terms used here, and
5[Reference](./reference.md) for every command flag, environment variable, ref rule, and schema.
6
7- [Client setup](#client-setup) gets an author or reviewer connected.
8- [Authoring a change](#authoring-a-change) takes a local commit to review.
9- [Reviewing and approving changes](#reviewing-and-approving-changes) takes a ready change to
10 `main`.
11- [Planning work with knots](#planning-work-with-knots) records and connects work.
12- [Recovering from failure](#recovering-from-failure) explains what to do when work stops.
13- [Running a valley host](#running-a-valley-host) sets up a NixOS deployment.
14- [Contributing to the-valley](#contributing-to-the-valley) runs the project's development checks.
15
16The commands below describe implemented behavior. Host names, principals, verification policy, and
17service settings are deployment choices. Replace the example values with those your administrator
18provides. The [README's current status](../README.md#configuration-and-current-status) lists what is
19not built.
20
21## Client setup
22
23The client lets you propose work, review changes, and read the live plan. You need git, SSH access
24to the valley host, and Nix with flakes enabled.
25
261. Clone the-valley's source from the URL your administrator provides. From that checkout, run:
27
28 ```sh
29 nix run .#valley -- help
30 nix shell .#valley
31 valley --version
32 ```
33
34 `nix run` runs one command. `nix shell` puts the packaged `valley` on your path for the rest of
35 this guide. The package supplies the helpers its commands need.
36
372. Clone the project you will work on and name the principal associated with your SSH key:
38
39 ```sh
40 git clone git@valley.example:demo
41 cd demo
42 git config valley.principal operator
43 git config user.name "Your name"
44 git config user.email you@example.com
45 ```
46
47 Use your own git author name and email. `valley.principal` names you in change records and knots.
48 It does not grant permission. The host checks the principal associated with the key you actually
49 use.
50
513. Get the trusted signers file and the integrator's signing name from your administrator:
52
53 ```sh
54 export VALLEY_KNOWN_SIGNERS="$HOME/.config/valley/known-signers"
55 export VALLEY_INTEGRATOR_SIGNER=integrator
56 ```
57
58 These let the client verify merged landings. Set both together. Without them, some submitted
59 versions appear `uncertain`; see [recovery](#an-uncertain-landing).
60
614. If you approve changes, configure your Ed25519 attestation key and its registered signing name:
62
63 ```sh
64 export VALLEY_ATTEST_KEY="$HOME/.ssh/valley-attest"
65 export VALLEY_ATTEST_NAME=operator
66 ```
67
68 The host must trust that signing key. Your SSH principal must also be allowed to approve. These
69 are separate parts of [identity](./concepts.md#principals-and-grants); see
70 [Environment variables and configuration](./reference.md#environment-variables-and-configuration)
71 for every client setting.
72
73To install updates into your user Nix profile, name the-valley's source repository:
74
75```sh
76valley self-update --repo git@valley.example:the-valley --branch main
77```
78
79It builds the selected commit, tests the new client, and installs it. For repeated use, save the
80repository with `git config --global valley.selfUpdate.repo git@valley.example:the-valley`, then run
81`valley self-update`. Without a configured repository, self-update is off. Run
82`valley self-update --help` for rollback and pinning.
83
84The installed package includes Bash and Zsh completions. For a shell using the checkout directly,
85source `completions/valley.bash` in Bash. In Zsh, add the checkout's `completions` directory to
86`fpath` before running `autoload -Uz compinit; compinit`.
87
88## Authoring a change
89
90A change starts with a local commit. This example uses a new git branch called `greeting` to carry
91it. Run it in a project with an initial `main` and verification policy already set up.
92
93### Create and ready the first version
94
95```sh
96git fetch origin
97git switch -c greeting origin/main
98printf 'Hello from the valley.\n' > greeting.txt
99git add greeting.txt
100git commit -m 'Add a greeting'
101valley checks
102```
103
104`valley checks` lists what this diff requires. It does not run the checks. Run the commands named by
105your project's policy before asking for review. For a Nix check named `prose-format` in this
106repository, for example:
107
108```sh
109nix build --no-link .#checks.x86_64-linux.prose-format -L
110```
111
112For this new, unpushed commit, stamp a stable Change ID and publish the first version:
113
114```sh
115valley ready --stamp
116valley status greeting
117```
118
119`ready` prints a handle and version, such as `demo kqxm v1 ready`. Use the handle it actually prints
120in later commands. The handle identifies the change even when its commit changes. `status` reports
121readiness, any request, and the latest integration result. To see the required checks alongside
122pending changes, run `valley pending --checks`.
123
124If the commit already carries a `Change-Id` trailer or a jj `change-id` header, push it first and
125run `valley ready` without `--stamp`:
126
127```sh
128git push -u origin HEAD
129valley ready
130```
131
132Without `--stamp`, `ready` uses the pushed tip by default. Keep the full Change ID when recording a
133new revision. The [change concept](./concepts.md#a-change-ready-approve-submitted) explains how
134headers, trailers, and `--change <id>` preserve it.
135
136### Revise or pause
137
138Pause a ready change before editing it:
139
140```sh
141valley unready kqxm
142```
143
144It becomes a draft. If it has an approval, ask a principal allowed to approve to
145[delete the outstanding request](#withdraw-or-revoke-an-approval) before you ready a replacement.
146Otherwise, readying the edited change can let the old version land: its request still names the old
147head.
148
149Edit the files, then amend the commit while keeping its `Change-Id` trailer:
150
151```sh
152git add greeting.txt
153git commit --amend --no-edit
154git push --force-with-lease origin HEAD
155valley ready
156valley status kqxm
157```
158
159The new head becomes the next version of the same change. If you make a new commit without its
160trailer or header, use `valley ready --change <full-change-id>` after pushing it.
161
162### Withdraw or revoke an approval
163
164To abandon the change, run `valley withdraw kqxm`. This marks it withdrawn. The integrator removes
165outstanding requests on its next pass while the change is still withdrawn. Do not ready a withdrawn
166change again until that removal is confirmed. For immediate revocation, a principal allowed to
167approve can delete its request:
168
169```sh
170git push origin :refs/the-valley/integration-requests/main/c-<full-change-id>
171```
172
173Replace the whole `<full-change-id>` placeholder before running this command. If an older request
174uses a branch name, delete that request too. Use
175`git ls-remote origin 'refs/the-valley/integration-requests/main/*'` to list them. Neither pausing
176nor withdrawing undoes a completed landing. See the
177[integrator's final readiness check](./concepts.md#the-host-the-hook-and-the-integrator) for the
178limit when a landing is already in progress.
179
180### Restack onto main
181
182Rebase a ready change when it needs the latest `main`. Before replacing an approved version,
183[revoke its outstanding request](#withdraw-or-revoke-an-approval).
184
185```sh
186valley rebase kqxm
187valley status kqxm
188```
189
190This rebases the whole stack beneath the named change, pushes the new heads, and records new
191versions. It leaves your local checkout in place. Read its output before editing locally again;
192fetch the remote updates and reconcile your local branch with them. If a record update fails, finish
193with the exact `valley ready` command it prints.
194
195Get the rebased version reviewed and approved again. Automatic restacking and automatic approval
196carry are not built. For conflicts or an uncertain landing, use
197[recovery](#recovering-from-failure).
198
199## Reviewing and approving changes
200
201A principal allowed to approve can turn a ready change into an integration request. Start in a clone
202of the project with the [client signing settings](#client-setup).
203
204```sh
205valley pending
206valley review kqxm
207```
208
209Use a handle from `pending`. Review pages the diff and offers actions at the terminal. Choose
210`[s]kip` to leave it alone or `[a]pprove` to run its required checks and approve the head you saw. A
211draft or withdrawn layer stops review from offering approval for that layer or anything above it. A
212stack is shown from the bottom up; approving its top includes the layers below.
213
214For a revised change, review automatically compares it with an earlier approved version when one can
215be identified. A clean restack gets a short summary. Use `[v]iew full diff` to see the whole change.
216The [comparison rules](./architecture.md#review-against-the-approved-version) explain what can be
217compared.
218
219You can also approve from the command line:
220
221```sh
222valley approve kqxm
223valley status kqxm
224```
225
226On a terminal, `approve` asks you to confirm the head and title. For automation, pass the exact
227reviewed commit with `valley approve --head <sha> kqxm`. Approval runs and signs every required
228check, then publishes the evidence and request together. It does not wait for landing. An enabled
229integrator processes the request; `status` tells you what happened.
230
231After a successful landing, update your local `main`:
232
233```sh
234git fetch origin
235git switch main
236git merge --ff-only origin/main
237```
238
239To inspect all recorded changes, including submitted and withdrawn ones, use
240`valley changes --json`. For changes across the instance, use `valley pending --all` or
241`valley changes --json --all`; see [CLI JSON outputs](./reference.md#cli-json-outputs) for their
242output schemas. These need access to the instance and project repositories.
243
244### Watch activity and inspect results
245
246`status` and `changes --json` read the records on the host. Use them to inspect landing results. If
247your deployment provides access to its NATS bus, configure a NATS context for that endpoint and run:
248
249```sh
250valley tail
251```
252
253It streams events until you interrupt it. Bus access is a deployment choice; the default host bus
254listens on loopback. An administrator can use `journalctl -u valley-integrator@demo` on the host for
255service logs.
256
257An administrator can republish the host's current refs with `replay`. On a host with
258`services.valley.bus.enable = true` at its default address, enter `nix shell .#valley` from a
259checkout of the-valley, then run:
260
261```sh
262sudo -u git env NATS_URL=nats://127.0.0.1:4222 "$(command -v valley)" replay /srv/git/demo.git
263```
264
265Use the deployment's bus address and credentials if they differ. This writes current-state events to
266the bus; it is not a history viewer. See
267[events and mirrors](./architecture.md#after-a-push-events-and-mirrors).
268
269## Planning work with knots
270
271The plan graph records work and the relationships between its knots. Read it from a clone of the
272primary valley repository:
273
274```sh
275valley plan
276valley plan --all
277```
278
279The first command shows this project's plan. The second reads projects published by the serving
280host. A source mirror does not carry the plan graph. See
281[project storage](./concepts.md#records-project-storage-the-plan-graph-and-knots).
282
283Create an outcome and inspect the ID it prints:
284
285```sh
286valley knot new outcome 'Greeting reaches readers' --owner operator
287valley knot list --status active
288```
289
290Use that ID in place of `oc-1234567` below:
291
292```sh
293valley knot show oc-1234567
294valley knot set oc-1234567 status=in-progress
295valley knot new bug 'Greeting needs an example' --parent oc-1234567
296valley knot link oc-1234567 --change valley:demo/<full-change-id>
297```
298
299Replace `<full-change-id>` with the change's full ID. The link connects the plan to the work that
300fulfills it. A dependency uses `--blocked-by <knot-id>` instead. When the outcome is complete:
301
302```sh
303valley knot set oc-1234567 status=done
304valley plan
305```
306
307Use `valley knot schema` to see each type's fields and allowed statuses. Knot writes validate the
308resulting graph and push it directly; they do not go through change approval. See
309[`valley knot`](./reference.md#valley-knot) for every subcommand and flag, and
310[the plan graph](./architecture.md#the-plan-graph) for validation and concurrent edits.
311
312## Recovering from failure
313
314Start with `valley status <handle>`. It distinguishes work waiting for an integrator from a request
315that the integrator has judged. Keep the command's full output when asking your administrator for
316help.
317
318### A stale or rejected request
319
320A `stale` result means the change conflicts with `main` or required evidence is missing or does not
321transfer across `main` movement. Read the reason in `status`. If the base moved,
322[revoke the outstanding request](#withdraw-or-revoke-an-approval), restack the ready change, then
323ask for a fresh review and approval:
324
325```sh
326valley rebase kqxm
327valley status kqxm
328```
329
330For missing or expired evidence, the approver must rerun approval with trusted signing settings. If
331approval reports that evidence from this signer already exists for the tree, follow its recovery
332message; retrying the same head does not replace that evidence.
333
334A `reject` result means the evidence is invalid, such as a signature or statement that does not
335match what it claims. Keep the reason and ask the administrator to inspect the evidence and signing
336configuration before trying again. See [checks and evidence](./concepts.md#checks-and-evidence).
337
338If `valley rebase` reports a conflict, it pushes nothing. For a single change, start from its remote
339head on a clean local branch, run `git fetch origin` and `git rebase origin/main`, resolve the
340reported files, and use `git add <resolved-files>` followed by `git rebase --continue`. Use
341`git rebase --abort` to abandon that local attempt. Push with `--force-with-lease`, then run
342`valley ready --change <full-change-id>`. For a stack, resolve each layer in order; do not publish
343only the top while lower change records still name old heads.
344
345### A refused push
346
347A refusal means the host did not accept that ref update. The message identifies the boundary:
348
349- **Protected ref:** push the work to a topic branch and use readiness and approval. A deployment
350 may seal `main` against every SSH principal.
351- **Push hold:** ask the administrator to finish maintenance and remove the hold. Client settings
352 cannot bypass it.
353- **Record ownership or non-fast-forward record update:** fetch again and use `valley ready`,
354 `unready`, or `withdraw` as the owner or a principal allowed to approve. Do not force a
355 hand-edited record over someone else's update.
356- **Malformed or oversized record or knot:** read the named validation error. Use the CLI to make
357 valid records and `valley knot schema` to inspect the knot model. Reduce oversized content before
358 retrying.
359
360The [push rules](./architecture.md#what-a-push-may-write) and
361[ref layout table](./reference.md#project-storage-ref-layout-and-bounds) explain each boundary.
362
363### An uncertain landing
364
365An `uncertain` result means the client cannot prove whether the version was submitted. It can follow
366a `failed` outcome, incomplete landing evidence, or missing signer settings. Set both
367`VALLEY_KNOWN_SIGNERS` and `VALLEY_INTEGRATOR_SIGNER` to the administrator's values, then rerun
368`valley status <handle>`.
369
370If it remains uncertain, ask the administrator to inspect `main`, the outcome record, and the
371integrator logs together. Do not assume that a consumed request means a successful landing. Resolve
372the uncertainty before rebasing or approving again. The
373[landing definitions](./concepts.md#a-change-ready-approve-submitted) describe the evidence needed
374to resolve this state.
375
376## Running a valley host
377
378A valley host serves repositories over SSH and runs the integrator on NixOS. This recipe creates an
379instance repository named `instance` and a project named `demo`. It uses static keys and grants
380first. All names, keys, checks, mirrors, and backup destinations are deployment choices; see
381[NixOS host options](./reference.md#nixos-host-options) and
382[CUE configuration schemas](./reference.md#cue-configuration-schemas) for the full option tables.
383
384### Declare the host
385
386In your NixOS configuration directory, create `valley.cue`:
387
388```cue
389package valley
390projects: {
391 instance: protection: {refs: ["refs/heads/main"], writers: []}
392 demo: protection: {refs: ["refs/heads/main"], writers: []}
393}
394```
395
396Both projects seal `main` against SSH pushes. The integrator writes locally on the host.
397[`examples/hosts/protected.cue`](../examples/hosts/protected.cue) exercises four protection modes
398for tests; it is not a production recipe.
399
400Add the-valley as an input named `valley` to your NixOS flake, using your administrator's source
401URL. Import `valley.nixosModules.valley-host` in the host's modules. In a module that receives that
402input, start with:
403
404```nix
405{ valley, ... }: {
406 imports = [ valley.nixosModules.valley-host ];
407 services.openssh.enable = true;
408 services.valley = {
409 enable = true;
410 config = ./valley.cue;
411 authorizedKeys = [{
412 principal = "operator";
413 key = "ssh-ed25519 REPLACE_WITH_OPERATOR_PUBLIC_KEY";
414 }];
415 grants.approve = [ "operator" ];
416 };
417}
418```
419
420Pass the input through `specialArgs = { inherit valley; };` in `nixpkgs.lib.nixosSystem` if using
421this module's argument. Replace the key with the public SSH key that the operator uses to push. The
422`approve` grant is the grant that lets a principal approve. It is also accepted as `request`, and
423`grants.request` declares the same grant as `grants.approve`. Keep administrative SSH access
424separate from this git account.
425
426Apply your configuration using your normal NixOS deployment command. For a local flake with a host
427named `valley-host`, run this on the host from that configuration directory:
428
429```sh
430sudo nixos-rebuild switch --flake .#valley-host
431sudo systemctl start valley-init
432sudo systemctl status valley-init --no-pager
433```
434
435`valley-init` creates `/srv/git/instance.git` and `/srv/git/demo.git`, installs hooks, and creates
436no initial commit. It publishes the project list once `instanceProject` is configured. Keep the
437integrator disabled until both repositories have a `main`.
438
439### Seed the initial source
440
441Create the initial source on the host in `/var/tmp/valley-seed`. Use an ordinary administrator
442account with git's author name and email configured:
443
444```sh
445mkdir -p /var/tmp/valley-seed/instance/policy/instance
446mkdir -p /var/tmp/valley-seed/demo/policy
447cd /var/tmp/valley-seed/instance
448git init --initial-branch=main
449printf '# Instance\n' > README.md
450cat > policy/instance/floor.cue <<'CUE'
451package verification
452floor: {
453 checks: readme: {runner: "command", command: "test -s README.md", validity: "1h"}
454 classes: source: {paths: {"**": true}, requires: {readme: true}}
455 unclassified: readme: true
456}
457CUE
458git add README.md policy
459git commit -m 'Seed instance policy'
460cd /var/tmp/valley-seed/demo
461git init --initial-branch=main
462printf '# Demo\n' > README.md
463printf 'git@valley.example:instance\n' > policy/valley
464git add README.md policy
465git commit -m 'Seed demo'
466```
467
468Replace `valley.example` before committing. `policy/valley` names the instance repository whose
469`policy/instance/` supplies this project's floor. The floor here requires only a nonempty README. It
470is a smoke check to prove the approval path works. Choose checks that verify your actual projects
471before admitting production work. A project's optional `policy/project/*.cue` can add requirements;
472it cannot weaken the floor. See [policy](./architecture.md#policy).
473
474Seed these commits through a local host write. The following commands are for the empty repositories
475just created:
476
477```sh
478sudo chown -R git:git /var/tmp/valley-seed
479sudo -u git git -C /srv/git/instance.git fetch /var/tmp/valley-seed/instance main:refs/heads/main
480sudo -u git git -C /srv/git/demo.git fetch /var/tmp/valley-seed/demo main:refs/heads/main
481```
482
483Local writes bypass `pre-receive`, so this works while SSH writes to `main` are sealed. Keep these
484seed directories free of private keys. Another bootstrap choice is to allow a temporary writer and
485remove it after seeding; this recipe keeps the sealed configuration throughout.
486
487### Provision signing and enable integration
488
489On the approver's machine, create its attestation key if it does not have one. From the-valley's
490checkout, export its public verifier entry:
491
492```sh
493ssh-keygen -t ed25519 -N '' -f "$HOME/.ssh/valley-attest"
494nix run .#attest -- key --key "$HOME/.ssh/valley-attest" --name operator > operator.signer
495```
496
497Keep the private key on that machine. Copy only `operator.signer` to the administrator on the host.
498On the host, create the integrator's separate key at a runtime path:
499
500```sh
501sudo install -d -m 0750 -o root -g git /var/lib/valley-secrets
502sudo ssh-keygen -t ed25519 -N '' -f /var/lib/valley-secrets/integrator
503sudo chgrp git /var/lib/valley-secrets/integrator
504sudo chmod 0640 /var/lib/valley-secrets/integrator
505```
506
507On the host, clone the-valley's source from the URL your administrator provides. From that checkout,
508enter `nix shell .#attest`. Export the integrator entry and combine the two public entries:
509
510```sh
511sudo "$(command -v attest)" key --key /var/lib/valley-secrets/integrator --name integrator > integrator.signer
512cat operator.signer integrator.signer > known-signers
513sudo install -m 0644 known-signers /var/lib/valley-secrets/known-signers
514```
515
516Add this to `services.valley` and apply the NixOS configuration again:
517
518```nix
519integrator = {
520 enable = true;
521 instanceProject = "instance";
522 signingKeyFile = "/var/lib/valley-secrets/integrator";
523 signingName = "integrator";
524 knownSignersFile = "/var/lib/valley-secrets/known-signers";
525};
526```
527
528The integrator runs as `valley-integrator` in the `git` group. Its key and signers file must be
529readable by that account. Private keys belong at runtime paths, never in the Nix store.
530
531The module requires a nonempty `authorizedKeys`, a signing key, a source for trusted signers, and
532exactly one of `instanceProject` or `instancePolicy`. With `instanceProject`, it also requires the
533instance's `main` to be protected. `instancePolicy` instead names a directory of floor CUE files on
534a host that does not serve the instance repository. Set `signingName` explicitly to the name
535published in the signers file.
536
537Distribute the public `known-signers` file to clients and configure their signer settings. Follow
538[Authoring a change](#authoring-a-change) in a clone of `demo`, then approve it as `operator`.
539Verify that `valley status <handle>` reports the landing. On the host, inspect:
540
541```sh
542sudo systemctl status valley-integrator@demo --no-pager
543sudo journalctl -u valley-integrator@demo -n 50 --no-pager
544```
545
546### Use a governed identity registry
547
548A deployment can maintain principals and keys in the instance source instead of listing all of them
549in NixOS. Start with the [registry example](../examples/identity/registry/registry.cue) and
550[schema](../schema/identity.cue). Write your own `identity/*.cue` in the instance repository, with
551your public keys, signing names, boundaries, and grants. Do not deploy the example's keys.
552
553Include a registry governor, the operator's push and approval grants, and a signing entry whose
554`signs` value matches the integrator's `signingName`. Land the registry through the static setup
555above. Then set `services.valley.identity.enable = true` and remove `integrator.knownSignersFile`
556from the NixOS configuration. Apply it and inspect the compilation:
557
558```sh
559sudo systemctl start valley-identity
560sudo journalctl -u valley-identity -n 50 --no-pager
561```
562
563It reads the integrated registry and writes `/var/lib/valley-identity/known-signers`, authorized
564keys, and grants. Distribute that public signers file to clients. Keep a nonempty static
565`authorizedKeys` list for bootstrap access. Static grants remain effective alongside compiled
566grants; remove a static approval grant if the registry should be its sole source. See
567[identity](./architecture.md#identity) for expiry and validation rules.
568
569### Publish source mirrors
570
571A mirror lets readers fetch the source without accessing the primary host. Add a mirror URL to the
572project's declaration and apply the host configuration:
573
574```cue
575projects: demo: mirrors: ["git@mirror.example:team/demo.git"]
576```
577
578Provision the `git` Unix user's SSH private key and pinned `known_hosts` under `/srv/git/.ssh`. The
579directory should be owned by `git` with mode `0700`; the private key should have mode `0600`. Verify
580the mirror's host key through its administrator. The publisher runs as `git` and uses that account's
581SSH configuration.
582
583For an existing mirror, inspect its refs before cutover. Remove unwanted old refs explicitly; the
584publisher does not clean up old topic branches or project storage. Start with an empty mirror when
585possible. See [mirror cutover](./architecture.md#after-a-push-events-and-mirrors).
586
587After a test landing, inspect the publisher:
588
589```sh
590sudo systemctl start valley-publish@demo
591sudo journalctl -u valley-publish@demo -n 50 --no-pager
592git ls-remote git@mirror.example:team/demo.git
593```
594
595Its `main` should match the primary. The publisher sends `main` and tags, not the plan graph or
596other project storage. A mirror is not a backup of the valley.
597
598### Back up and test a restore
599
600Backups preserve the whole data directory. Add an offsite policy to `valley.cue`:
601
602```cue
603backup: {
604 target: "restic-sftp"
605 cadence: "nightly"
606 retention: {daily: 7, weekly: 4, monthly: 6}
607}
608```
609
610Provision four files outside the Nix store: the restic repository URL, its encryption password, the
611SFTP private key, and pinned SSH host keys. Keep a recoverable copy of the password away from this
612host. Point the module at those runtime files:
613
614```nix
615backup = {
616 repositoryFile = "/var/lib/valley-secrets/restic-repository";
617 passwordFile = "/var/lib/valley-secrets/restic-password";
618 sshKeyFile = "/var/lib/valley-secrets/restic-ssh";
619 knownHostsFile = "/var/lib/valley-secrets/restic-known-hosts";
620};
621```
622
623After applying the configuration, take a backup and inspect its result:
624
625```sh
626sudo systemctl start restic-backups-valley
627sudo journalctl -u restic-backups-valley -n 50 --no-pager
628```
629
630The service runs as root and snapshots `services.valley.dataDir`, `/srv/git` by default. Test a
631restore into a separate empty directory. With `restic` available, run these in a root shell:
632
633```sh
634export RESTIC_REPOSITORY_FILE=/var/lib/valley-secrets/restic-repository
635export RESTIC_PASSWORD_FILE=/var/lib/valley-secrets/restic-password
636restic -o 'sftp.args=-i /var/lib/valley-secrets/restic-ssh -o UserKnownHostsFile=/var/lib/valley-secrets/restic-known-hosts -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes' snapshots
637restic -o 'sftp.args=-i /var/lib/valley-secrets/restic-ssh -o UserKnownHostsFile=/var/lib/valley-secrets/restic-known-hosts -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes' restore latest --target /var/tmp/valley-restore
638git -c safe.directory=/var/tmp/valley-restore/srv/git/demo.git -C /var/tmp/valley-restore/srv/git/demo.git fsck --full
639git -c safe.directory=/var/tmp/valley-restore/srv/git/instance.git -C /var/tmp/valley-restore/srv/git/instance.git fsck --full
640```
641
642Expect a snapshot, a completed restore, and no corrupt or missing objects. Git may report dangling
643objects; those alone do not indicate corruption. Inspect the restored `main` and `refs/the-valley/*`
644as well. This verifies the restored repository, not a transaction across every ref written while the
645backup ran.
646
647### Hold pushes for maintenance
648
649To refuse incoming pushes across every project, create the hold on the host:
650
651```sh
652sudo touch /srv/git/.valley-hold
653```
654
655Remove it after maintenance with `sudo rm /srv/git/.valley-hold`. Use your configured `dataDir` if
656it differs. The hold stops SSH pushes; stop the relevant integrator services separately if
657maintenance also requires local integration writes to stop.
658
659## Contributing to the-valley
660
661Contributors work in a checkout of this repository. Read [AGENTS.md](../AGENTS.md) before editing.
662You can enter the default package's build environment:
663
664```sh
665nix develop
666```
667
668This flake defines no dedicated development shell. `nix develop` does not supply the full toolchain.
669For the CLI and Go work, use an explicit tool shell from the repository root:
670
671```sh
672nix shell .#valley .#attest --inputs-from . nixpkgs#go nixpkgs#cue
673```
674
675Each Go component has its own module. Run fast tests from the component you changed, for example:
676
677```sh
678(cd status && go test ./...)
679```
680
681There is no root Go module. To test every Go module from the repository root:
682
683```sh
684for module in attest change composed delta identity integrator knot note rebase restack selfupdate sigverify status valleyhook; do
685 (cd "$module" && go test ./...) || exit 1
686done
687```
688
689Run a single Nix check by name. For documentation, format first, then check formatting, links, and
690the style rules, then the policy that selects checks:
691
692```sh
693nix run .#fmt
694nix build --no-link .#checks.x86_64-linux.prose-format -L
695nix build --no-link .#checks.x86_64-linux.own-policy -L
696```
697
698Stage new Markdown files before formatting so the formatter sees them. Review the diff afterward.
699Use [nix/checks](../nix/checks/) to find the integration checks for the component you changed. Run
700them one at a time; VM checks need the virtualization facilities their definitions specify. The full
701flake suite is invoked with `nix flake check` when your task permits it and the machine can run all
702its checks.
703
704The [architecture](./architecture.md) explains component invariants and the checks that cover them.
705The [reference](./reference.md) documents CLI flags, ref bounds, wire formats, JSON outputs, and
706[schema](../schema/) definitions alongside the [concept glossary](./concepts.md#glossary).