gunk-dev/the-valley

guide.md

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