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 recorded landings. No client configuration is needed: the client reads the host's trusted signers file and integrator signing name from the instance repository (implemented). Show the host's 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 approval runs checks on your machine, configure your Ed25519 attestation key and its registered signing name:
export VALLEY_ATTEST_KEY="$HOME/.ssh/valley-attest"
export VALLEY_ATTEST_NAME=operator
When every required check already has eligible evidence on origin (for example, from a check
worker), approval needs no signing key. Approval runs command checks locally, and builds nix
checks only when you pass --build-here. When a check runs locally, 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. valley pending counts each ready
change's checks; valley pending --checks names the ones that failed and what they cost.
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. A host that runs the restacker rebases ready changes for you after each landing, and its versions need approval in the same way. Automatic approval carry is 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
A change can land on its fast checks while slower ones follow it: the host's worker runs those on
main when nothing waits, one run covering every landing since their last pass. pending opens
with whether main is clear, clearing while they run, or muddy when one failed, with the
landings it covers.
pending lists the changes waiting on your approval under needs you, one row each, numbered in
the order they would land, with their checks and how long they have been ready. A stack is one row,
its top's, since approving the top lands every layer. Changes that need nothing from you are under
moving: approved ones waiting on their checks and the integrator, and those whose check failed or
whose restack stopped, which their author fixes. A last line counts the drafts and stray branches;
--drafts and --branches list them, and -v shows each row's commits and diff.
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 approve the head you saw. [r]eject deletes the
change's branch once you confirm, then withdraws the change, so it leaves needs you; if the
withdrawal fails, review names the valley withdraw command to run. 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. Review lists a layer below the top that is
already approved but does not page it. Name that layer to review it.
Run valley review with no handle to review everything under needs you, across every project the
host serves, in landing order. Each change gets the same prompt, and the walk ends with what you did
to each and what still needs you.
A change behind main is approved as it is. The integrator applies the change onto main as main
stands, and a host that runs the restacker rebases ready changes itself. The prompt's header says
so, as in kqxm v3 · behind main (integrator merges). When the restacker reports a conflict, it
says conflicts with main (owner resolving) instead. Review offers no rebase; an author rebases
their own change with valley rebase.
A change can move while you read it: its owner may return it to draft, ready a new version, or
withdraw it, and it may land. Review reads the change again before [a]pprove or [r]eject acts.
When the change has moved, review says what changed in one line and does nothing. For a new version
it says why your answer does not carry, offers what changed since the version you read, and offers
to approve the new version: at once when only main moved under its commits, after you view what
changed when a commit changed. A restack that brings the same changes keeps your answer instead:
kqxm moved to v4 while you were reviewing. v4 is v3 rebased onto the new main with no other changes, so your approval covers it.
Approving then lands v4, and the verdict names it with its checks, such as
◐ kqxm v4 approved · 19 checks running · lands when they pass.
For a revised change, review automatically compares it with an earlier approved version when one can
be identified. Its first line says whether the change's own commits changed: rebased, with the same
file changes, gets a short summary; rebased onto files main also edited names the landings that
edited them; edited adds the range-diff. Use [v]iew 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 reuses eligible evidence already
on origin for the commit's content tree (see valley approve).
It runs and signs the required command checks, and publishes the new evidence and request
together. When every required check is covered, nothing runs and no signing key is needed. Approval
does not wait for landing. An enabled integrator processes the request; status tells you what
happened. Approval ends in one line that says what happened and what comes next:
✓ kqxm v3 approved · checks passed · landing on main
A refusal says what stands in the way, and what to run about it:
⊘ kqxm v3 not approved · change is a draft
run: valley ready --change <id> kqxm
valley approve -v also prints the refs, evidence and signers behind that line.
When a required nix check has no evidence on origin yet, approval still files the request at
once, after the required command checks pass. Your approval is recorded, and no nix check is
built on your machine. The integrator keeps the request, and approval says how many checks it is
waiting for, such as ◐ kqxm v3 approved · lands when 3 checks pass (1/4 passed). When evidence is
published, an enabled integrator considers the request again, and you do not need to approve again.
Landing still requires the change to apply cleanly and carry acceptable evidence for every required
check.
An enabled worker that serves the project attempts the missing nix checks of a ready change's
unlanded active version. It cannot add checks to its own existing evidence ref for the same tree,
and a failed build publishes nothing. No worker builds a branch no record is on, or a version that
is not the active one. Waiting does not ensure that the missing evidence will be published.
Use --build-here on the initial approval if you need to build missing nix checks on your own
machine. Once this signer has published evidence for the tree, another approval cannot add checks to
that ref.
valley approve --build-here kqxm
valley review --build-here kqxm
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.
Telemetry lets a session see what the host's components are doing without a shell on the host: the
check worker and the builds it runs, the integrators, the registry compiler, the signers publisher,
the publish queues, the bus, the web publisher, backups, valley-init and the build slice. It is
diagnostics. It never approves anything and never stands in for evidence.
An observer reads it with the same SSH key it pushes with:
valley telemetry sources # what the host runs, and each source's state
valley telemetry snapshot # the worker's pass, its failures and open runs
valley telemetry read --source=worker # the worker's records and its systemd lifecycle
valley telemetry read --source=worker --logs # with the build output, marked untrusted
valley telemetry follow --seconds=300 --logs # what happens next, for five minutes
valley telemetry --remote git@valley-host:app.git sources # outside a checkout
follow and read end with a cursor. Pass it to --since to carry on where the last one stopped.
A gap in what the host still holds, an error, or an answer that broke off is said, so silence always
means nothing happened. Each answer is bounded: a read returns at most 1000 records and 4 MiB, and a
follow lasts at most 300 seconds.
--logs shows what checks and services printed. That text comes from whoever wrote the check, so it
is marked untrusted and its control characters are escaped. Leave --logs off unless the output is
what you need.
To publish a workstation's commands, approvals and check runs to the host, so a session can see them while they run:
git config --global valley.telemetry true
Every valley command then records its verb, flag names, project, exit status, and wall time (plus
each phase's time and processes for valley pending and valley status), never an argument's
value, path, title, or body. Each approval attempt from valley approve or valley review also
records its steps and check progress. Records wait in a local spool and go in the background to the
valley named by the checkout's telemetry remote, and to no other. An unreachable host never slows,
fails, or alters a command's output; valley telemetry flush sends what is left later.
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
Comments record findings on a knot. valley knot show prints each comment's ID in brackets. A
comment's author or a holder of the approve grant can replace a comment's text with --edit:
valley knot comment oc-1234567 -m 'Waiting on the example.'
valley knot show oc-1234567
valley knot comment oc-1234567 --edit <comment-id> -m 'The example landed.'
The plan graph keeps every earlier text in its commit history. valley knot log lists the commits
that touched a knot or its comments, and valley knot show --at <commit> shows the knot at that
commit:
valley knot log oc-1234567
valley knot show oc-1234567 --at <commit>
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. Right after an approval that named
missing nix checks, stale for missing evidence is expected: the integrator keeps the request and
considers it again when evidence is published. 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
Missing evidence can be published independently of approval. Rerun approval when you need it to
produce local evidence, with trusted signing settings, using --build-here for uncovered nix
checks, and observing the same-tree signer restriction. 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.refs/.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.
To publish a project on the web, place it in a group. Declare the group under a permanent
identifier, and set group on the project to that identifier:
groups: demos: name: "demos"
projects: demo: group: "demos"
The web publisher exports only projects that belong to a group. The group's name is the first URL
segment and the project's web name is the second, giving /demos/demo/… here. A project's web name
defaults to its identifier unless the project sets name. When a group changes its name, keep the
old name in aliases. When a project changes its web name, keep the old name in formerNames so
existing links redirect (see Groups and web URLs).
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.
A host serves telemetry once the administrator enables the collector and names who may read and who
may report (deployment choice):
services.valley.telemetry = {
enable = true;
observers = [ "operator" ]; # read every source on the host
reporters = [ "alice" ]; # send records about their own approvals and checks
};
A principal is named by its key's tag, as for a push. observe is host-wide: the shared units' logs
span every project, so give it only to principals that may see every project's activity. report
grants no reading. A workstation that should read its own reports back needs observe too.
A unit of the host's own, such as the service that converges or deploys it, can be a source too:
services.valley.telemetry.localSources = [
{ name = "converge"; description = "the service that converges this host"; units = [ "converge.service" ]; }
];
valley telemetry sources then reports it with the state of its units, and
read --source converge --logs shows what they printed, as for the valley's own services. A name
that another source already uses is refused when the host is evaluated.
A component on another machine, such as a web receiver, can report with a principal of its own:
services.valley.telemetry.reporters = [ "receiver" ];
services.valley.telemetry.remoteSources = [
{ name = "remote-receiver"; description = "the web receiver at example.org"; principal = "receiver"; }
];
The source reads as unavailable until that principal reports and as stale after an hour of
silence. No component of the-valley reports this way by itself yet; see
Not deployed or not wired yet.
The collector reads the journal, so how far back unit lifecycle and output reach is the host's
journal retention, which each source line reports as journal_since.
The push hook refuses to create or update a ref named like another ref: refs/, refs/heads/,
refs/tags/ or refs/remotes/ followed by a full ref name. When the ref it is named for is
missing, git reads, fetches and pushes to such a ref in its place. A host may hold some already,
made before the hook refused them. List them once, in every repository the host serves:
for repo in /srv/git/*.git; do
sudo -u git git -C "$repo" for-each-ref --format="$repo %(refname)" \
refs/refs/ refs/heads/refs/ refs/tags/refs/ refs/remotes/refs/
done
Each line names a repository and a ref. Once any work on a ref has been pushed under another name, delete the ref on the host:
sudo -u git git -C /srv/git/demo.git update-ref -d refs/heads/refs/heads/main
Use your configured dataDir if it differs.
The web edge is a read-only web server for the valley's projects. The publisher on the valley host
pushes signed exports to the edge over HTTP, and the edge never connects back to the valley host. A
project reaches the edge when a reader's grant and the project's policy/read both allow that
reader — anyone or a named principal — to read it there. The edge serves each project only to the
readers its authorization names, and readers can sign in at the edge with read links. On the edge,
valley-web-receive receives uploads into a state directory and valley-web serves them. They run
as two processes under two Unix users over that shared state directory (see
The receiver).
Generate a shared bearer token and install the same file on both hosts outside the Nix store, readable by root alone:
head -c 32 /dev/urandom | base64 | sudo install -m 0400 /dev/stdin /run/keys/valley-web-receiver-token
On the valley host, enable the publisher with the receiver URL and token file:
imports = [ the-valley.nixosModules.default the-valley.nixosModules.web-publisher ];
services.valley.webPublisher = {
enable = true;
destination = "example.org";
receiver = "https://example.org";
receiverTokenFile = "/run/keys/valley-web-receiver-token";
allowedAddresses = [ "192.0.2.10" ];
};
Set allowedAddresses to the receiver's IP addresses. The unit allows connections only to addresses
on that list, permits any port on a listed address, and checks only the destination IP address. When
the receiver changes to a new address, passes fail until allowedAddresses includes it. The
publisher connects to the receiver directly and ignores HTTP_PROXY and HTTPS_PROXY.
On NixOS, name lookups go through the C library to nscd (services.nscd.enable, enabled by
default), which queries DNS outside the unit. If nscd is disabled, add the resolver address from
/etc/resolv.conf to allowedAddresses as well.
Before each pass, valley-web-publish-egress-check verifies that the IP filter is active by sending
a UDP datagram to 198.51.100.1 and starting the pass only when the filter blocks it. Leave
198.51.100.1 out of allowedAddresses, and ensure the host has a route to it, such as a default
route. If the check stops the pass, journalctl -u valley-web-publish logs the reason from
valley-web-publish-egress-check.
Run the publisher once to generate the export signing key and read its verifier line:
sudo systemctl start valley-web-publish
sudo cat /var/lib/valley-web-publish/verifier
Until the receiver pins that verifier line, it refuses every upload with bad-signature and the
publisher pass fails.
On an edge host running NixOS, enable services.valley.webReceiver. Configure listen on the
address the publisher reaches and webListen behind the reverse proxy that serves the edge's public
domain:
imports = [ the-valley.nixosModules.web-receiver ];
services.valley.webReceiver = {
enable = true;
instance = "valley-host";
destination = "example.org";
verifiers = [ "valley-host/web-export+1a2b3c4d+AQ..." ];
tokenFile = "/run/keys/valley-web-receiver-token";
listen = "192.0.2.10:8081";
webListen = "127.0.0.1:8080";
origin = "https://example.org";
};
Set origin to the public HTTPS origin that browsers send for the edge: https:// and a lowercase
host, plus a port when the port is not 443. When origin is set, readers can sign in with read
links (see Issue and revoke read links), and valley-web stores
their sessions in /var/lib/valley-web/browser. The module creates that directory with owner
valley-web and mode 0700, and valley-web cannot write anywhere else. When origin is unset,
valley-web serves every request as anyone. Serve the origin over HTTPS, because the session
cookie has the Secure attribute and browsers store it only over HTTPS.
On an edge host that does not run NixOS, build and load the container image from a checkout of the-valley:
nix build .#valley-web-image
docker load < result
docker load prints the image name and tag. Install the verifier line and a copy of the token where
the receiver's user (uid 990) can read them, then run two containers sharing one volume — writable
in valley-web-receive and read-only in valley-web:
sudo install -d -m 0750 -o 990 -g 990 /etc/valley-web
sudo install -m 0400 -o 990 -g 990 /run/keys/valley-web-receiver-token /etc/valley-web/token
echo 'valley-host/web-export+1a2b3c4d+AQ...' | sudo install -m 0444 -o 990 /dev/stdin /etc/valley-web/verifiers
docker run -d --name valley-web-receive --user valley-web-receive \
--memory 2g --memory-swap 2g \
-v valley-web:/var/lib/valley-web -v /etc/valley-web:/etc/valley-web:ro \
-p 192.0.2.10:8081:8081 valley-web:<tag> \
valley-web-receive --state /var/lib/valley-web/store --listen :8081 \
--instance valley-host --destination example.org \
--verifiers /etc/valley-web/verifiers --token-file /etc/valley-web/token
docker run -d --name valley-web --user valley-web \
--memory 1g --memory-swap 1g --ulimit core=0 \
-v valley-web:/var/lib/valley-web:ro -v valley-web-browser:/var/lib/valley-web/browser \
-p 127.0.0.1:8080:8080 valley-web:<tag> \
valley-web --state /var/lib/valley-web/store --listen :8080 --origin https://example.org
A new valley-web volume inherits the owner and permissions of /var/lib/valley-web from the
image: the receiver's user with mode 0750. valley-web reads that volume through the shared
group. The second volume, valley-web-browser, holds the browser state and is the only directory
valley-web writes. A new volume mounted at /var/lib/valley-web/browser inherits its owner and
permissions from the image: valley-web's user (uid 991, gid 990) with mode 0700. The receiver's
container does not mount valley-web-browser. valley-web holds link secrets and session tokens in
memory; it marks its own process non-dumpable, and --ulimit core=0 disables core dumps for the
container as well. If an existing valley-web volume lacks a browser/ directory for the mount
point, create it once on the host before starting valley-web:
sudo install -d -m 0700 -o 991 -g 990 "$(docker volume inspect -f '{{.Mountpoint}}' valley-web)/browser"
A bind mount used in place of either volume needs the same owner and mode. Omit
-v valley-web-browser:… and --origin to serve anyone alone. Both containers take the store
descriptor /var/lib/valley-web/store, which the receiver creates on its first start. When
upgrading from a release where --state was a directory, stop the old receiver, start the new one,
and upgrade the host after the edge (see
Upgrading the edge and the host). Then delete the
first layout's state from the volume by hand: active, high-water, exports/, staging/,
trash/ and lock, beside the descriptor. Leaving them is harmless, because the first layout held
public projects only.
Give each container its own memory limit. When a container reaches --memory, the kernel reclaims
memory or kills a process inside that container alone. Setting --memory-swap equal to --memory
disables swap for the container, matching the NixOS module's units. A limit keeps a spike in one
container from taking the other's memory or the host's only when the host has room for both limits
and for its own work. So keep the sum of both limits below the host's physical memory, with explicit
headroom left for the host's own work. The 2g and 1g limits above match the module's defaults
for receiverMemoryMax and webMemoryMax; sizing them for the edge's uploads and readers is a
deployment choice.
The receiver caps the state directory at --max-storage (8 GiB by default). Because --max-storage
is best effort, place the state directory on a fixed-size filesystem or under a disk quota slightly
larger than --max-storage (see Bounds). For containers, apply that
bound to the filesystem backing the volume. On NixOS, mount a bounded filesystem at the receiver's
state directory (/var/lib/valley-web by default).
Because every upload request carries the token, reach the receiver over HTTPS, through a reverse
proxy that terminates TLS, or over a private network. On the next pass, the publisher prints
the receiver stored authorization <n>, then the receiver activated sequence <n>, and
valley-web serves the export.
To take a project off the web at once, withdraw every reader's grant for it, or remove every reader
from its policy/read, and start a pass: sudo systemctl start valley-web-publish. A project stays
on the edge while any reader may still read it, so removing one reader keeps the project for the
others. The pass sends its authorization before doing any content work, and the edge stops serving
the project at the next request, even if the content work stalls or fails. Running
valley-web-publish --policy-only with the unit's other flags sends only the authorization.
A read link lets one person read, at the edge, what one registry principal may read there. The
principal needs an edge-read grant in the registry and a project whose policy/read names it. A
reader who signs nothing may hold no keys, as long as every grant it holds is an edge read. Run
these commands as root on the valley host:
valley-web-link issue --principal alice --note laptop
The command refuses a principal who may read no project at the destination. Otherwise, it prints the
link once, such as https://example.org/-/redeem#lk-0123456789abcdef.<secret>. Send it to its
holder over a private channel. The host keeps no copy of the secret.
After the next pass delivers the link to the edge, the holder opens it in a browser and clicks
Continue as reader. That redeems the link once and starts a session in the browser. To switch to
a new link in a browser that is already signed in, open the new link and click Sign out and
continue with this link. Clicking Sign out in the navigation ends the session, and signing in
again requires a new link. If the page cannot tell whether the server used the link, click the
button again to retry. If the earlier attempt started a session, the retry continues to /; if the
server reports that the link cannot be used, issue a new link.
After signing in, the browser goes to /. A reader who may read more than one project lands on the
projects page, /-/projects, which lists each project they may read under its group. Each entry
links to the project's source and to its knots. A reader who may read exactly one project lands on
that project's source instead. Every page of a project has a header that names it as
<group>/<project>, with two tabs: source and knots. The projects link at the top of
every project page and every listing page returns to the list. The list's all knots link shows
the knots of every project the reader may read (see
Web server (valley-web) for the routes).
valley-web-link list
valley-web-link revoke lk-0123456789abcdef
valley-web-link revoke --principal alice
valley-web-link revoke --all
After every issue or revoke, the command starts a policy pass and reports every link whose delivery
is still pending. If a link is pending after that pass, it starts the pass once more. enforced
means the receiver acknowledged an authorization that reflects the link's current state. If a link
is still pending, the command exits 1. A revoked link still works at the edge until a pass
delivers the revocation. Check journalctl -u valley-web-publish-policy, then run the same command
again: a repeated revoke retries the delivery.
A command that changes links waits for a policy pass that is reading the links and signing, for up to a minute, and says so while it waits. If the wait runs out, the command exits 1 having changed nothing. Run it again.
Restoring the valley host from a backup restores the read links as they were at the backup. A link revoked after the backup works again once the next pass delivers it. To cut off every link after a restore, revoke them all, then issue new links to the people who should keep access:
valley-web-link revoke --all
valley-web-link issue --principal alice --note laptop
valley-web creates browser/state only when the stored authorization has no link bindings. Any
link issued before browser/state exists cannot be redeemed. Follow these steps when enabling
reader sign-in for the first time, or after the edge loses browser/state or its whole state
directory:
valley-web-link revoke --all to revoke every link and deliver an authorization with no
bindings.browser/state exists in the edge's state directory. valley-web creates it when
it starts or on the first request after that authorization arrives.If valley-web logs that the browser state is unavailable, it serves requests without a session
cookie as anyone and answers 503 to requests that carry the session cookie. valley-web never
overwrites an unreadable browser/state. To recover, run valley-web-link revoke --all, stop
valley-web, remove browser/state, start valley-web again, and issue new links.
Revoked links stay in the credential file until you prune them:
valley-web-link prune
prune removes every revoked link whose revocation is enforced, and keeps those still pending.
It starts no policy pass, since the edge already refuses every link it removes. The file holds at
most 1 MiB. issue refuses once the file would come within 64 KiB of that, and says to prune.
revoke is never refused for the file's size.
To pause a principal's access without revoking links, set or shorten its expires in the registry.
Its links stop working after the next policy pass past that day, and extending the date restores
them.
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
In Nix, building a Go package does not run its unit tests. Those tests run only in the module's
*-unit check, such as valleyhook-unit for valleyhook/ or valley-go-unit for status/:
nix build --no-link .#checks.x86_64-linux.valleyhook-unit -L
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.
Each check is given only the files it reads. nix/checks.nix and
nix/packages.nix narrow each source to those files with lib.fileset. An
edit to any other file leaves the check's derivation unchanged, so the check's evidence transfers to
the edited tree. When a check starts to read a new file, give the check that file. The sandbox fails
a check that reads a file it was not given.
Editing a Go test changes only that module's *-unit check, not the other checks that use the
package. A Go package's source leaves out test files, and its *-unit check adds them back.
The NixOS host module uses three of the flake's programs: the integrator, the identity compiler, and
valleyhook. Four checks test what the module renders without running those programs:
module-eval, mirror-e2e, bus-e2e, and init-e2e. Those checks render the module with stand-in
scripts in place of the three programs (nix/checks/hosts.nix), so editing
one of the programs leaves those four checks unchanged. Checks that run one of the programs use the
real package.
To see which checks an edit gives a new derivation, run the measurement script on a commit:
nix/tools/drv-churn.sh --expect nix/tools/drv-churn.expected
It applies a fixed list of representative edits to the commit's tree, one at a time, and evaluates
every check's derivation after each. The first edit, commit only, commits the same tree twice and
evaluates each commit. Only the checks that read the commit may change: valley-cli,
valley-self-update and valley-darwin-eval. With --expect, it fails if any edit changes other
checks than the recorded table says. When a change means to alter the table, write the new one with
--write. To measure only some edits, name each with --edit:
nix/tools/drv-churn.sh --edit 'commit only' --edit 'help text' --expect nix/tools/drv-churn.expected
Every check is still evaluated, and --expect and --write compare or replace only the rows of the
edits named. With --history origin/main~20..origin/main instead, it replays the paths each of
those commits touched. Run nix/tools/drv-churn.sh --help for every option.
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.