gunk-dev/the-valley
the-valley:bd-8b308f9bugclosed

valley pending starts a thousand processes and takes six seconds with nothing ready

State
done
Created
2026-11-08 by contributor
Changes
  • valley:the-valley/outwzvkszvvoxxplklroqprtvsnnrusl

Body

With nothing ready, `valley pending` in the-valley takes 6.0 s in a session and 7.0 s in the operator's shell on the host (4.6 s user, 3.7 s system). It starts 1,060 processes: 811 `git`, 188 `attest`, 50 `cue` and 7 `ssh` (traced with `strace -f -e trace=execve`).
- 94 `attest verify --note` calls each verify one transfer note, with about nine `git` calls apiece (`rev-parse`, `ls-tree`, `cat-file`), plus 149 `rev-list --parents` and 47 `merge-tree --write-tree`.
- 47 `cue vet -c` calls look like the requirement probing in bd-030ddda.

A transfer note never changes once written, so verifying the same notes on every run buys nothing after the first.

Fixed when `pending` with nothing ready runs in under a second on a project with a few hundred landings, verifies each transfer note at most once per signer set (in process, or cached by note), reads git objects in batches, and a check bounds the processes it starts.

Related: bd-030ddda (a full policy read probes each requirement), oc-6a17c9d (the valley's tools become one Go binary).

Comments

  1. contributor2026-11-12 01:45 UTC
    A proposal to make the client trust `main` and the integrator's records on its own origin, and stop verifying transfer statements on reads, was reviewed by two model families at their highest settings (2026-11-12). Both advised against it, and their claims below were checked against the source.
    
    What the proposal got right: keys the client fetches from the serving host give no independent defense against a compromise of that host.
    
    Why it is the wrong fix:
    - The time is not signature checking. For each candidate landing the client starts about twelve processes: `attest digest` hashes every blob at the head; `attest verify` starts `cue vet` cold and hashes every blob at the landing commit again; four git commands recompute the merge (`rebase/snapshot.go` `digest`, `verified`, `mergesTo`; `attest/statement.go:131`). It also reads every attestation ref, not only the integrator's. An Ed25519 check in-process (`note.Open`) costs microseconds.
    - A wrong "landed" is not display only: `rebase` and the restacker drop commits read as landed and publish the result (`rebase/family.go` `commits`), and `approve` leaves them out of what it says an approval brings.
    - The predicate is shared with the host's restacker (`restack/main.go` `planned`), so changing it changes a controller.
    - Landings made before landing records exist name their landing commit only in the statement; an outcome record holds the tip before the landing.
    - Removing a revoked key from the publication stops its statements counting today; unsigned records would outlive a revocation.
    - The record match, base digest and merge checks catch honest mix-ups (two heads with one tree) and stay whatever happens to signatures.
    
    Direction both reviewers recommend, keeping the trust model:
    1. Read only the attestation refs under the integrator's key hash.
    2. Verify the statement in-process with `note.Open` and parse it in Go, instead of starting `attest verify` and `cue vet`.
    3. Cache each verified binding outside the checkout, keyed by the exact note bytes, landing commit, head, request name and the signer's key; on a hit, still check the key is currently accepted, the record match, and that the landing commit is on `main`. Never cache "this version has landed".
    
    For a later transparency log, noted: statements do not sign the exact head or a repository identity; signing a candidate is not proof the target moved; a log detects a compromised host only with its identity and checkpoints held off the host, and an unauthorized landing only if entries also bind an off-host approval.
  2. contributor2026-11-12 03:42 UTC
    Review of the first version (d8561f0), by another model family at high effort, plus a comparison on real data.
    
    Real data: the released CLI and this change's CLI give byte-identical `valley changes --json --all` over three projects (241 changes, 606 versions, 109 landed-recorded), with an empty cache and a warm one. The listing took 12.5 to 13.0 s before, 8.9 s cold and 2.0 s warm; `pending` in one project went from 14.6 s to 7.3 s warm.
    
    No wrong landing on ordinary input. Sent back for a fix round:
    - a cache entry that is a FIFO or a symlink to one blocks the command;
    - `mergesTo` reads replacement refs while the tree digest does not, so a remembered merge is not a function of objects alone where the reader does not turn replacements off (the restacker);
    - a directory mode written `040000` is skipped where `ls-tree` walked it;
    - a change to `note/statement/**` alone no longer requires `restack-e2e`;
    - two tests pass on broken code (damaged tree entry; head in the landing entry's key);
    - stale text that still says the client runs `attest`.
    
    Accepted as designed, and the "identical for every input" claim is narrower by these:
    - A statement the integrator's key signed that fails the full schema, but whose landing fields are well formed, now counts. The integrator vets before signing; `attest sign` does not, so this rests on the key's holder.
    - A statement signed by the integrator but stored only under another signer's key-hash ref is no longer read. The integrator always writes under its own.
    - The verifier's keys are read once per snapshot, not once per statement.
    - The remembered merge was computed under the git attributes of the repository that first verified it. A clone with other local attributes reads the remembered answer.
    - A missing object under another signer's ref no longer stops statements being read.
  3. contributor2026-11-12 22:26 UTC
    Change valley:the-valley/outwzvkszvvoxxplklroqprtvsnnrusl landed: v3 as ddfdc45c1aa22c784f6b50bda7152f02fb121c6e.
    
    Every change the knot links has landed and it has no active children, so klaus set it closed.