gunk-dev/the-valley

guide.md

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