This guide follows the jobs people do in a valley. Start with the README for a short tour, Concepts and glossary for the terms used here, and Reference for every command flag, environment variable, ref rule, and schema.
main.The commands below describe implemented behavior. Host names, principals, verification policy, and service settings are deployment choices. Replace the example values with those your administrator provides. The README's current status lists what is not built.
The client lets you propose work, review changes, and read the live plan. You need git, SSH access to the valley host, and Nix with flakes enabled.
Clone the-valley's source from the URL your administrator provides. From that checkout, run:
nix run .#valley -- help
nix shell .#valley
valley --version
nix run runs one command. nix shell puts the packaged valley on your path for the rest of
this guide. valley help prints a command summary; valley help <verb> prints help for one
verb. The package supplies the helpers its commands need.
Clone the project you will work on and name the principal associated with your SSH key:
git clone git@valley.example:demo
cd demo
git config valley.principal operator
git config user.name "Your name"
git config user.email you@example.com
Use your own git author name and email. valley.principal names you in change records and knots.
It does not grant permission. The host checks the principal associated with the key you actually
use.
Check that the client can verify merged landings. You do not need to configure anything. The host publishes its trusted signers file and the integrator's signing name in the instance repository, and the client reads them when it needs them. This command shows the publication:
git ls-remote git@valley.example:instance refs/the-valley/signers
Use the instance repository your project's policy/valley names. If it prints nothing, the host
publishes nothing, and some submitted versions appear uncertain; see
recovery. To use other values than the host's, set them yourself. A
setting wins over the publication:
export VALLEY_KNOWN_SIGNERS="$HOME/.config/valley/known-signers"
export VALLEY_INTEGRATOR_SIGNER=integrator
If you approve changes, configure your Ed25519 attestation key and its registered signing name:
export VALLEY_ATTEST_KEY="$HOME/.ssh/valley-attest"
export VALLEY_ATTEST_NAME=operator
The host must trust that signing key. Your SSH principal must also be allowed to approve. These are separate parts of identity; see Environment variables and configuration for every client setting.
To install updates into your user Nix profile, name the-valley's source repository:
valley self-update --repo git@valley.example:the-valley --branch main
It builds the selected commit, tests the new client, and installs it. For repeated use, save the
repository with git config --global valley.selfUpdate.repo git@valley.example:the-valley, then run
valley self-update. Without a configured repository, self-update is off. Run
valley self-update --help for rollback and pinning.
The installed package includes Bash and Zsh completions. For a shell using the checkout directly,
source completions/valley.bash in Bash. In Zsh, add the checkout's completions directory to
fpath before running autoload -Uz compinit; compinit.
A change starts with a local commit. This example uses a new git branch called greeting to carry
it. Run it in a project with an initial main and verification policy already set up.
git fetch origin
git switch -c greeting origin/main
printf 'Hello from the valley.\n' > greeting.txt
git add greeting.txt
git commit -m 'Add a greeting'
valley checks
valley checks lists what this diff requires. It does not run the checks. Run the commands named by
your project's policy before asking for review. For a Nix check named prose-format in this
repository, for example:
nix build --no-link .#checks.x86_64-linux.prose-format -L
For this new, unpushed commit, stamp a stable Change ID and publish the first version:
valley ready --stamp
valley status greeting
ready prints a handle and version, such as demo kqxm v1 ready. Use the handle it actually prints
in later commands. The handle identifies the change even when its commit changes. status reports
readiness, any request, and the latest integration result. To see the required checks alongside
pending changes, run valley pending --checks.
If the commit already carries a Change-Id trailer or a jj change-id header, push it first and
run valley ready without --stamp:
git push -u origin HEAD
valley ready
Without --stamp, ready uses the pushed tip by default. Keep the full Change ID when recording a
new revision. The change concept explains how
headers, trailers, and --change <id> preserve it.
Pause a ready change before editing it:
valley unready kqxm
It becomes a draft. If it has an approval, ask a principal allowed to approve to delete the outstanding request before you ready a replacement. Otherwise, readying the edited change can let the old version land: its request still names the old head.
Edit the files, then amend the commit while keeping its Change-Id trailer:
git add greeting.txt
git commit --amend --no-edit
git push --force-with-lease origin HEAD
valley ready
valley status kqxm
The new head becomes the next version of the same change. If you make a new commit without its
trailer or header, use valley ready --change <full-change-id> after pushing it.
To abandon the change, run valley withdraw kqxm. This marks it withdrawn. The integrator removes
outstanding requests on its next pass while the change is still withdrawn. Do not ready a withdrawn
change again until that removal is confirmed. For immediate revocation, a principal allowed to
approve can delete its request:
git push origin :refs/the-valley/integration-requests/main/c-<full-change-id>
Replace the whole <full-change-id> placeholder before running this command. If an older request
uses a branch name, delete that request too. Use
git ls-remote origin 'refs/the-valley/integration-requests/main/*' to list them. Neither pausing
nor withdrawing undoes a completed landing. See the
integrator's final readiness check for the
limit when a landing is already in progress.
Rebase a ready change when it needs the latest main. Before replacing an approved version,
revoke its outstanding request.
valley rebase kqxm
valley status kqxm
This rebases the whole stack beneath the named change, pushes the new heads, and records new
versions. It leaves your local checkout in place. Read its output before editing locally again;
fetch the remote updates and reconcile your local branch with them. If a record update fails, finish
with the exact valley ready command it prints.
Get the rebased version reviewed and approved again. Automatic restacking and automatic approval carry are not built. For conflicts or an uncertain landing, use recovery.
A principal allowed to approve can turn a ready change into an integration request. Start in a clone of the project with the client signing settings.
valley pending
valley review kqxm
Use a handle from pending. Review pages the diff and offers actions at the terminal. Choose
[s]kip to leave it alone or [a]pprove to run its required checks and approve the head you saw. A
draft or withdrawn layer stops review from offering approval for that layer or anything above it. A
stack is shown from the bottom up; approving its top includes the layers below.
For a revised change, review automatically compares it with an earlier approved version when one can
be identified. A clean restack gets a short summary. Use [v]iew full diff to see the whole change.
The comparison rules explain what can be
compared.
You can also approve from the command line:
valley approve kqxm
valley status kqxm
On a terminal, approve asks you to confirm the head and title. For automation, pass the exact
reviewed commit with valley approve --head <sha> kqxm. Approval runs and signs every required
check, then publishes the evidence and request together. It does not wait for landing. An enabled
integrator processes the request; status tells you what happened.
After a successful landing, update your local main:
git fetch origin
git switch main
git merge --ff-only origin/main
To inspect all recorded changes, including submitted and withdrawn ones, use
valley changes --json. For changes across the instance, use valley pending --all or
valley changes --json --all; see CLI JSON outputs for their
output schemas. These need access to the instance and project repositories.
status and changes --json read the records on the host. Use them to inspect landing results. If
your deployment provides access to its NATS bus, configure a NATS context for that endpoint and run:
valley tail
It streams events until you interrupt it. Bus access is a deployment choice; the default host bus
listens on loopback. An administrator can use journalctl -u valley-integrator@demo on the host for
service logs.
An administrator can republish the host's current refs with replay. On a host with
services.valley.bus.enable = true at its default address, enter nix shell .#valley from a
checkout of the-valley, then run:
sudo -u git env NATS_URL=nats://127.0.0.1:4222 "$(command -v valley)" replay /srv/git/demo.git
Use the deployment's bus address and credentials if they differ. This writes current-state events to the bus; it is not a history viewer. See events and mirrors.
The plan graph records work and the relationships between its knots. Read it from a clone of the primary valley repository:
valley plan
valley plan --all
The first command shows this project's plan. The second reads projects published by the serving host. A source mirror does not carry the plan graph. See project storage.
Create an outcome and inspect the ID it prints:
valley knot new outcome 'Greeting reaches readers' --owner operator
valley knot list --status active
Use that ID in place of oc-1234567 below:
valley knot show oc-1234567
valley knot set oc-1234567 status=in-progress
valley knot new bug 'Greeting needs an example' --parent oc-1234567
valley knot link oc-1234567 --change valley:demo/<full-change-id>
Replace <full-change-id> with the change's full ID. The link connects the plan to the work that
fulfills it. A dependency uses --blocked-by <knot-id> instead. When the outcome is complete:
valley knot set oc-1234567 status=done
valley plan
Use valley knot schema to see each type's fields and allowed statuses. Knot writes validate the
resulting graph and push it directly; they do not go through change approval. See
valley knot for every subcommand and flag, and
the plan graph for validation and concurrent edits.
Start with valley status <handle>. It distinguishes work waiting for an integrator from a request
that the integrator has judged. Keep the command's full output when asking your administrator for
help.
A stale result means the change conflicts with main or required evidence is missing or does not
transfer across main movement. Read the reason in status. If the base moved,
revoke the outstanding request, restack the ready change, then
ask for a fresh review and approval:
valley rebase kqxm
valley status kqxm
For missing or expired evidence, the approver must rerun approval with trusted signing settings. If approval reports that evidence from this signer already exists for the tree, follow its recovery message; retrying the same head does not replace that evidence.
A reject result means the evidence is invalid, such as a signature or statement that does not
match what it claims. Keep the reason and ask the administrator to inspect the evidence and signing
configuration before trying again. See checks and evidence.
If valley rebase reports a conflict, it pushes nothing. For a single change, start from its remote
head on a clean local branch, run git fetch origin and git rebase origin/main, resolve the
reported files, and use git add <resolved-files> followed by git rebase --continue. Use
git rebase --abort to abandon that local attempt. Push with --force-with-lease, then run
valley ready --change <full-change-id>. For a stack, resolve each layer in order; do not publish
only the top while lower change records still name old heads.
A refusal means the host did not accept that ref update. The message identifies the boundary:
main against every SSH principal.valley ready,
unready, or withdraw as the owner or a principal allowed to approve. Do not force a
hand-edited record over someone else's update.valley knot schema to inspect the knot model. Reduce oversized content before
retrying.The push rules and ref layout table explain each boundary.
An uncertain result means the client cannot prove whether the version was submitted. It can follow
a failed outcome or incomplete landing evidence. It can also mean the client had no signers to
verify the landing with. In that case the command says on stderr that a transfer statement could not
be verified, and why. Check that the host publishes its signers (step 3 of
Client setup). If it does not, ask the administrator for the signers file and the
integrator's signing name, set VALLEY_KNOWN_SIGNERS and VALLEY_INTEGRATOR_SIGNER to them, and
rerun valley status <handle>.
If it remains uncertain, ask the administrator to inspect main, the outcome record, and the
integrator logs together. Do not assume that a consumed request means a successful landing. Resolve
the uncertainty before rebasing or approving again. The
landing definitions describe the evidence needed
to resolve this state.
A valley host serves repositories over SSH and runs the integrator on NixOS. This recipe creates an
instance repository named instance and a project named demo. It uses static keys and grants
first. All names, keys, checks, mirrors, and backup destinations are deployment choices; see
NixOS host options and
CUE configuration schemas for the full option tables.
In your NixOS configuration directory, create valley.cue:
package valley
projects: {
instance: protection: {refs: ["refs/heads/main"], writers: []}
demo: protection: {refs: ["refs/heads/main"], writers: []}
}
Both projects seal main against SSH pushes. The integrator writes locally on the host.
examples/hosts/protected.cue exercises four protection modes
for tests; it is not a production recipe.
Add the-valley as an input named valley to your NixOS flake, using your administrator's source
URL. Import valley.nixosModules.valley-host in the host's modules. In a module that receives that
input, start with:
{ valley, ... }: {
imports = [ valley.nixosModules.valley-host ];
services.openssh.enable = true;
services.valley = {
enable = true;
config = ./valley.cue;
authorizedKeys = [{
principal = "operator";
key = "ssh-ed25519 REPLACE_WITH_OPERATOR_PUBLIC_KEY";
}];
grants.approve = [ "operator" ];
};
}
Pass the input through specialArgs = { inherit valley; }; in nixpkgs.lib.nixosSystem if using
this module's argument. Replace the key with the public SSH key that the operator uses to push. The
approve grant is the grant that lets a principal approve. It is also accepted as request, and
grants.request declares the same grant as grants.approve. Keep administrative SSH access
separate from this git account.
Apply your configuration using your normal NixOS deployment command. For a local flake with a host
named valley-host, run this on the host from that configuration directory:
sudo nixos-rebuild switch --flake .#valley-host
sudo systemctl start valley-init
sudo systemctl status valley-init --no-pager
valley-init creates /srv/git/instance.git and /srv/git/demo.git, installs hooks, and creates
no initial commit. It publishes the project list once instanceProject is configured. Keep the
integrator disabled until both repositories have a main.
Create the initial source on the host in /var/tmp/valley-seed. Use an ordinary administrator
account with git's author name and email configured:
mkdir -p /var/tmp/valley-seed/instance/policy/instance
mkdir -p /var/tmp/valley-seed/demo/policy
cd /var/tmp/valley-seed/instance
git init --initial-branch=main
printf '# Instance\n' > README.md
cat > policy/instance/floor.cue <<'CUE'
package verification
floor: {
checks: readme: {runner: "command", command: "test -s README.md", validity: "1h"}
classes: source: {paths: {"**": true}, requires: {readme: true}}
unclassified: readme: true
}
CUE
git add README.md policy
git commit -m 'Seed instance policy'
cd /var/tmp/valley-seed/demo
git init --initial-branch=main
printf '# Demo\n' > README.md
printf 'git@valley.example:instance\n' > policy/valley
git add README.md policy
git commit -m 'Seed demo'
Replace valley.example before committing. policy/valley names the instance repository whose
policy/instance/ supplies this project's floor. The floor here requires only a nonempty README. It
is a smoke check to prove the approval path works. Choose checks that verify your actual projects
before admitting production work. A project's optional policy/project/*.cue can add requirements;
it cannot weaken the floor. See policy.
Seed these commits through a local host write. The following commands are for the empty repositories just created:
sudo chown -R git:git /var/tmp/valley-seed
sudo -u git git -C /srv/git/instance.git fetch /var/tmp/valley-seed/instance main:refs/heads/main
sudo -u git git -C /srv/git/demo.git fetch /var/tmp/valley-seed/demo main:refs/heads/main
Local writes bypass pre-receive, so this works while SSH writes to main are sealed. Keep these
seed directories free of private keys. Another bootstrap choice is to allow a temporary writer and
remove it after seeding; this recipe keeps the sealed configuration throughout.
On the approver's machine, create its attestation key if it does not have one. From the-valley's checkout, export its public verifier entry:
ssh-keygen -t ed25519 -N '' -f "$HOME/.ssh/valley-attest"
nix run .#attest -- key --key "$HOME/.ssh/valley-attest" --name operator > operator.signer
Keep the private key on that machine. Copy only operator.signer to the administrator on the host.
On the host, create the integrator's separate key at a runtime path:
sudo install -d -m 0750 -o root -g git /var/lib/valley-secrets
sudo ssh-keygen -t ed25519 -N '' -f /var/lib/valley-secrets/integrator
sudo chgrp git /var/lib/valley-secrets/integrator
sudo chmod 0640 /var/lib/valley-secrets/integrator
On the host, clone the-valley's source from the URL your administrator provides. From that checkout,
enter nix shell .#attest. Export the integrator entry and combine the two public entries:
sudo "$(command -v attest)" key --key /var/lib/valley-secrets/integrator --name integrator > integrator.signer
cat operator.signer integrator.signer > known-signers
sudo install -m 0644 known-signers /var/lib/valley-secrets/known-signers
Add this to services.valley and apply the NixOS configuration again:
integrator = {
enable = true;
instanceProject = "instance";
signingKeyFile = "/var/lib/valley-secrets/integrator";
signingName = "integrator";
knownSignersFile = "/var/lib/valley-secrets/known-signers";
};
The integrator runs as valley-integrator in the git group. Its key and signers file must be
readable by that account. Private keys belong at runtime paths, never in the Nix store.
The module requires a nonempty authorizedKeys, a signing key, a source for trusted signers, and
exactly one of instanceProject or instancePolicy. With instanceProject, it also requires the
instance's main to be protected. instancePolicy instead names a directory of floor CUE files on
a host that does not serve the instance repository. Set signingName explicitly to the name
published in the signers file.
The host publishes the known-signers file and the integrator's signing name for clients, at
refs/the-valley/signers in the instance repository. valley-signers writes it at boot, on
activation, and whenever the file changes, so clients need no signer settings. Follow
Authoring a change in a clone of demo, then approve it as operator.
Verify that valley status <handle> reports the landing. On the host, inspect:
sudo systemctl status valley-integrator@demo --no-pager
sudo journalctl -u valley-integrator@demo -n 50 --no-pager
sudo journalctl -u valley-signers -n 20 --no-pager
A deployment can maintain principals and keys in the instance source instead of listing all of them
in NixOS. Start with the registry example and
schema. Write your own identity/*.cue in the instance repository, with
your public keys, signing names, boundaries, and grants. Do not deploy the example's keys.
Include a registry governor, the operator's push and approval grants, and a signing entry whose
signs value matches the integrator's signingName. Land the registry through the static setup
above. Then set services.valley.identity.enable = true and remove integrator.knownSignersFile
from the NixOS configuration. Apply it and inspect the compilation:
sudo systemctl start valley-identity
sudo journalctl -u valley-identity -n 50 --no-pager
It reads the integrated registry and writes /var/lib/valley-identity/known-signers, authorized
keys, and grants. Distribute that public signers file to clients. Keep a nonempty static
authorizedKeys list for bootstrap access. Static grants remain effective alongside compiled
grants; remove a static approval grant if the registry should be its sole source. See
identity for expiry and validation rules.
A mirror lets readers fetch the source without accessing the primary host. Add a mirror URL to the project's declaration and apply the host configuration:
projects: demo: mirrors: ["git@mirror.example:team/demo.git"]
Provision the git Unix user's SSH private key and pinned known_hosts under /srv/git/.ssh. The
directory should be owned by git with mode 0700; the private key should have mode 0600. Verify
the mirror's host key through its administrator. The publisher runs as git and uses that account's
SSH configuration.
For an existing mirror, inspect its refs before cutover. Remove unwanted old refs explicitly; the publisher does not clean up old topic branches or project storage. Start with an empty mirror when possible. See mirror cutover.
After a test landing, inspect the publisher:
sudo systemctl start valley-publish@demo
sudo journalctl -u valley-publish@demo -n 50 --no-pager
git ls-remote git@mirror.example:team/demo.git
Its main should match the primary. The publisher sends main and tags, not the plan graph or
other project storage. A mirror is not a backup of the valley.
Backups preserve the whole data directory. Add an offsite policy to valley.cue:
backup: {
target: "restic-sftp"
cadence: "nightly"
retention: {daily: 7, weekly: 4, monthly: 6}
}
Provision four files outside the Nix store: the restic repository URL, its encryption password, the SFTP private key, and pinned SSH host keys. Keep a recoverable copy of the password away from this host. Point the module at those runtime files:
backup = {
repositoryFile = "/var/lib/valley-secrets/restic-repository";
passwordFile = "/var/lib/valley-secrets/restic-password";
sshKeyFile = "/var/lib/valley-secrets/restic-ssh";
knownHostsFile = "/var/lib/valley-secrets/restic-known-hosts";
};
After applying the configuration, take a backup and inspect its result:
sudo systemctl start restic-backups-valley
sudo journalctl -u restic-backups-valley -n 50 --no-pager
The service runs as root and snapshots services.valley.dataDir, /srv/git by default. Test a
restore into a separate empty directory. With restic available, run these in a root shell:
export RESTIC_REPOSITORY_FILE=/var/lib/valley-secrets/restic-repository
export RESTIC_PASSWORD_FILE=/var/lib/valley-secrets/restic-password
restic -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
restic -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
git -c safe.directory=/var/tmp/valley-restore/srv/git/demo.git -C /var/tmp/valley-restore/srv/git/demo.git fsck --full
git -c safe.directory=/var/tmp/valley-restore/srv/git/instance.git -C /var/tmp/valley-restore/srv/git/instance.git fsck --full
Expect a snapshot, a completed restore, and no corrupt or missing objects. Git may report dangling
objects; those alone do not indicate corruption. Inspect the restored main and refs/the-valley/*
as well. This verifies the restored repository, not a transaction across every ref written while the
backup ran.
To refuse incoming pushes across every project, create the hold on the host:
sudo touch /srv/git/.valley-hold
Remove it after maintenance with sudo rm /srv/git/.valley-hold. Use your configured dataDir if
it differs. The hold stops SSH pushes; stop the relevant integrator services separately if
maintenance also requires local integration writes to stop.
Contributors work in a checkout of this repository. Read AGENTS.md before editing. You can enter the default package's build environment:
nix develop
This flake defines no dedicated development shell. nix develop does not supply the full toolchain.
For the CLI and Go work, use an explicit tool shell from the repository root:
nix shell .#valley .#attest --inputs-from . nixpkgs#go nixpkgs#cue
Each Go component has its own module. Run fast tests from the component you changed, for example:
(cd status && go test ./...)
There is no root Go module. To test every Go module from the repository root:
for module in attest change composed delta identity integrator knot note rebase restack selfupdate sigverify status valleyhook; do
(cd "$module" && go test ./...) || exit 1
done
Run a single Nix check by name. For documentation, format first, then check formatting, links, and the style rules, then the policy that selects checks:
nix run .#fmt
nix build --no-link .#checks.x86_64-linux.prose-format -L
nix build --no-link .#checks.x86_64-linux.own-policy -L
Stage new Markdown files before formatting so the formatter sees them. Review the diff afterward.
Use nix/checks to find the integration checks for the component you changed. Run
them one at a time; VM checks need the virtualization facilities their definitions specify. The full
flake suite is invoked with nix flake check when your task permits it and the machine can run all
its checks.
The architecture explains component invariants and the checks that cover them. The reference documents CLI flags, ref bounds, wire formats, JSON outputs, and schema definitions alongside the concept glossary.