gunk-dev/the-valley
the-valley:oc-13c6bd6outcomedone

Check workers build ready changes: the valley host first, a second worker for overflow

State
done
Created
2026-10-17 by contributor
Source
2026-10-13, plan.md M4 item 5
Progress
7 of 7 done
Blocks
Children

Body

Check workers build the checks a ready change requires before the operator approves it. The valley host is the primary worker and a second check worker takes overflow.

From the plan (2026-10-13):
- Workers pull assignments from the valley; nothing connects in to a worker, which keeps the rule that the agent guest never connects to a worker.
- Each worker builds in an isolated profile, with a trusted runner signing under that worker's own identity.
- The scheduler gives the valley host priority, and hands work to a second check worker only when the host is busy or backed up and the second worker is available.
- Check definitions come from the integrated tip (bd-eaefe82), so a change can't redefine its own checks.
- `approve` stops running checks locally, reuses acceptable evidence already on origin and runs only what is missing. Today a second attestation from the same signer is refused (bd-7b7d58f).
- There is no interim prebuilder: the operator chose to wait for the workers.

Done when a ready version's required checks have evidence on origin before anyone approves it, and `approve` runs nothing that evidence already covers.

Source: 2026-10-13, `plan.md` M4 item 5 and Status ("Trusted-builder latency").



---

Design: the minimal version, revision 2, 2026-10-22. The operator kept the five recommendations and added: keep it simple, and leave no broad mark across the codebase. Astra authored it, and a Claude review cut it down. The full 11-slice design (2026-10-21) is in this knot file's history, and its deferred pieces are listed below.

# Valley check workers: revision 2

A timer on the valley host runs today’s attester for ready changes.  
Workers publish today’s statements through today’s Git hook.  
Approval fetches evidence, skips covered checks, and builds only the remainder locally.  
Worker and local attesters use distinct signing identities.  
The integrator independently verifies evidence before submission.  
The-valley pilots with one slot, four CPUs, and 8 GiB.  
The deployment project follows by configuration once capacity, private inputs, and signer authorization are settled.  
No scheduler, leases, worker endpoint, or evidence-format migration is needed.

Source basis: the-valley HEAD and local `origin/main` are `d8c2e54343602a7dfb560a695157b4f29feff1dc`. Source declarations do not establish running host configuration. All proposed mechanisms below are **not built**; operating settings are **deployment choices**.

## Design

### Worker: a timer around existing commands

**Implemented.** Pending JSON selects ready changes whose active version has not landed. `valley-go checks` already returns structured requirements through the Go deriver, given explicit policy directories and commits. `status/pending.go:79`, `status/checks.go:31`, `status/checks.go:94`.

**Decision.** Add a small worker script. One timer and host lock serialize its work across configured projects:

1. Read `valley pending --json` and pin an active version’s head.
2. Resolve integrated policy inputs and the merge base with the target.
3. Call existing `valley-go checks`.
4. Fetch evidence for the candidate tree and identify uncovered, audited Nix checks.
5. Run that set together through `attest run --rev <head>`.
6. Push only the resulting attestation ref.

Policy comes from the integrated side, following the integrator’s existing rule. Check definitions still come from the candidate. No preparation record or alternative merge calculation is introduced. `integrator/refs.go:345`, `integrator/refs.go:363`, `attest/run.go:84`.

**Adopt the derivation cut.** Approval keeps its Bash derivation; integration keeps invoking `valley checks`. A worker disagreement causes extra or missed background work, which approval’s fallback absorbs. There is no derivation migration or disagreement gate. `bin/valley:1652`, `integrator/policy.go:142`.

**Implemented.** The attester stores all selected checks under one subject-and-signer ref. A failed selected check prevents publication. An empty selection means every flake check, so the worker must stop when nothing is missing. `attest/run.go:153`, `attest/run.go:201`, `attest/run.go:284`.

Use `attest run` without `--push`: that option also pushes a source ref. The worker’s explicit Git push carries evidence alone. The hook already verifies the subject and signer independently of the pusher. `attest/run.go:210`, `valleyhook/attestation.go:38`.

**Adopt the operational cuts.** The local attestation ref is the publication recovery record; no separate receipt is needed. After a lost reply, inspect origin and resend the same object. Do not recheck readiness before publication: the evidence remains an observation about its pinned tree, even if that version is superseded or withdrawn. Approval retains its own record recheck.

**Deployment choice.** Poll once a minute, with one batch at a time. Keep bounded logs and a small local failure/backoff record so failing checks do not run every minute. Origin read failures stop the pass. An occupied worker ref that lacks required checks is reported before building; local approval can supply the remainder under its separate signer.

### Approval: reuse first, then run the remainder

**Adopt P1.** Approval must remain usable during a worker outage, before the deployment project is enabled, and for checks the worker cannot run. It builds only uncovered checks locally using the operator’s existing attestation key.

**Implemented.** Approval currently requires that key whenever any check is required and runs the entire required set. Its ordinary fetch does not explicitly fetch attestation refs. `bin/valley:956`, `bin/valley:1666`, `bin/valley:1689`, `bin/valley:1714`.

**Decision.** Add a small coverage helper in `status/`, using the existing signer reader and `attest verify`. Approval performs these steps:

1. Bind the reviewed head and derive requirements as today.
2. Compute its tree digest.
3. List and explicitly fetch origin’s `refs/the-valley/attestations/<digest>/*`, retaining their advertised object IDs.
4. Verify those fetched notes and divide required checks into covered and missing.
5. Print reused checks and their signers, then run only the missing set.
6. Publish newly produced evidence with the existing integration request.

Only evidence confirmed on origin counts as background coverage. Local-only notes are not mistaken for published evidence. Failed inventory or fetch is an error, not an empty result.

When everything is covered, approval needs no attestation key and starts no check. When something is missing, retain the current local execution path and failure behavior. Preserve the reviewed-head checks, record recheck, request compare-and-swap, and empty-push guard. `bin/valley:1784`, `bin/valley:1804`, `bin/valley:1817`.

**Initial coverage is conservative.** Reuse pure Nix evidence for the exact candidate tree when its statement, signature, subject, result, check name, runner, attribute, and project authorization agree. `attest verify` already checks canonical form, schema, signatures, and subject binding without rerunning the check. `attest/verify.go:11`, `attest/verify.go:55`, `attest/verify.go:111`.

**Adopt finding 8.** Comparing the attribute is stricter than the current integrator’s unchanged-tree rule. That rule checks result and predicate kind, then accepts pure evidence without comparing attributes. Keep the stricter client test without changing that gate. `integrator/verdict/verdict.go:366`, `integrator/verdict/verdict.go:390`.

Effectful evidence reuse and cross-tree client reuse remain outside this pilot. Their checks retain local execution. If the target moves, integration applies its existing merge and transfer rules; changed closures may require rebase and fresh evidence. `integrator/refs.go:376`, `integrator/refs.go:419`.

### The collision avoided—and the collision remaining

**Implemented.** The address is one tree digest plus one signer key hash, and the hook refuses updates. `attest/run.go:201`, `valleyhook/policy.go:149`.

Worker evidence and the operator’s complementary local batch therefore coexist when their signing identities differ. Reusing either batch requires no replacement statement.

**Qualify the review’s absolute claim.** This avoids collision with the worker’s ref; it does not eliminate bd-7b7d58f. An existing partial ref from the same local signer still prevents adding another batch. Renewed effectful observations also remain affected. Approval already diagnoses that condition. `bin/valley:1520`, `bin/valley:1823`.

Check the destination before a local build when it already exists. Report an incompatible occupied ref rather than doing work that cannot be published. Keep the general address fix deferred; do not overwrite evidence or rotate keys merely to obtain another address.

### Trust: restrict workers by project

**Implemented.** Registry recognition alone is broad: keys with `signs` enter known-signers, and the hook and integrators use that file. There is no per-check signer field. `identity/render.go:121`, `nix/valley-host.nix:213`, `nix/valley-host.nix:663`, `schema/verification.cue:179`.

**Adopt the smaller restriction.** Configure a list mapping each restricted worker signer to allowed projects. In `integrator.classify`, a cryptographically verified worker signature outside that list becomes `UnknownSigner`. Unrestricted existing identities retain their current treatment. An empty project list denies the worker everywhere.

Enforcement belongs only in classification. No hook, statement, verdict, or general collection change is needed. The existing collector already lets an admissible note replace one classified as unknown. `integrator/evidence.go:125`, `integrator/evidence.go:78`.

Per-check restrictions are deferred. Both inspected project catalogues declare Nix checks. This permits project-level trust; it does **not** technically restrict a compromised worker to the audited subset. Adding effectful checks requires revisiting that decision. `policy/project/policy.cue:76`.

**Adopt publication; qualify “read only by the integrator.”** Known-signers and the integrator name already travel through `refs/the-valley/signers`. Extend that publication with the project list, including publication triggers when it changes. Coverage must read it too, or approval could skip evidence that classification rejects. This is advisory client filtering; the integrator remains the enforcement boundary. No separately installed client bundle is needed. `integrator/signers.go:15`, `status/signers.go:224`, `nix/valley-host.nix:1765`.

**Adopt the memo cut.** Do not add an authority digest. List-only changes retain today’s memo behavior: widening access may leave a previously refused request waiting until head, tip, or evidence changes. Narrowing access does not make a cached refusal land. `integrator/refs.go:140`.

Deploy classification enforcement on every integrator sharing the registry before enabling the worker key. Use a distinct worker signing identity and a Git transport credential without approval or protected-ref authority. Ordinary Git access still permits unprotected source refs; an evidence-only endpoint is deferred. `valleyhook/policy.go:146`, `valleyhook/policy.go:157`.

A compromised worker can fabricate check results throughout an authorized project. It cannot supply the integrator signature required by transfer readers. `rebase/snapshot.go:448`.

Trusted definitions remain deferred: the candidate can weaken its own checks through files the operator reviews. Building the evaluated derivation preserves execution consistency, not independent assertions. `attest/check.go:118`, `attest/check.go:157`.

### Isolation, caps, and the deployment project

**Deployment choice.** Use the valley host’s Nix daemon with sandboxed builds. Put the worker’s evaluation process and the daemon’s build processes under an aggregate four-CPU, 8 GiB budget. Configure one worker batch, `max-jobs = 1`, `cores = 4`, `CPUQuota = 400%`, and `MemoryMax = 8G`. Bound swap, scratch, logs, and build time.

Verify actual cgroup membership, including QEMU and any build scopes. Capping only the attester client is insufficient. CPU and memory limits apply hierarchically. [systemd resource controls](https://www.freedesktop.org/software/systemd/man/260/systemd.resource-control.html).

Use packaged tools and schema, pure evaluation, fixed Nix configuration, and an unprivileged worker account. Keep signing keys and production credentials outside source exports and build sandboxes. Disable remote builders and candidate flake configuration. Evaluation belongs within the budget because the-valley uses import-from-derivation. `flake.nix:10`, `attest/check.go:69`.

**Adopt the host-daemon recommendation.** Do not add a private daemon or outer microVM. Do not add daemon device restrictions that hide KVM. The deployment’s configuration declares KVM support and an agent guest; those declarations justify testing this path, not assuming it works on the running host.

The daemon cap affects its other clients. The deployment separately documents direct root rebuilds outside the daemon and caps the upgrade unit itself. Unchanged-tree integration performs no closure evaluation. Remove the dedicated-daemon question, while measuring actual contention. `integrator/refs.go:419`.

**Enabling the deployment project is configuration, gated on three results:**

1. **Capacity.** Run the largest relevant multi-node checks under 8 GiB, with the agent guest and inference active. Include `resolver-redundancy`, which starts multiple nodes. Deliberate exhaustion must leave host services healthy.
2. **Private inputs.** Test the pinned inputs with the worker’s actual credential-free environment. The deployment project locks inputs hosted under private accounts, but the lock does not establish their visibility. A lock update requires VM checks. Do not solve access by giving candidate execution a general token. If private sources require preparation, settle that separately; local approval remains available.
3. **Signer authorization.** Add the deployment project to both the worker’s project configuration and the integrator’s signer list.

The DNS tests explicitly expect offline sandboxes, which supports the audit but does not replace it.

Pilot the-valley first. It has a nixpkgs input and VM checks exercising the same execution path. Enable the deployment project after these gates pass, without another valley implementation slice or promised calendar deadline. `flake.nix:4`, `policy/project/policy.cue:83`.

### Review and observation

**Adopt the UI cut.** Keep the existing review interface. Approval prints the checks reused from origin and those it will run locally. Missing evidence has no implied queue or running state.

Worker failures and execution progress stay in bounded local logs. Reuse existing check and integrator timing output. `attest/timing.go:46`, `integrator/timing.go:29`.

## Four slices

Each slice’s cited basis belongs in its claim-to-code checklist and change description, reverified before review.

1. **Restrict worker signers to projects.**  
   Touch `integrator/` classification, flags and signer publication, plus `nix/valley-host.nix`.  
   **Implemented basis:** verification and replacement of refused notes already exist (`integrator/evidence.go:125`, `integrator/evidence.go:78`).  
   **Acceptance:** the same worker note is accepted in an allowed project and classified unknown elsewhere; malformed configured lists fail closed; publication follows list changes.

2. **Fetch coverage and run only missing checks.**  
   Touch `status/` coverage and signer reading, `bin/valley`, and focused CLI checks. Leave derivation and `attest run` unchanged.  
   **Implemented basis:** normal fetch lacks an evidence refspec; approval runs all requirements (`bin/valley:956`, `bin/valley:1689`).  
   **Acceptance:** complete coverage needs no key or Nix execution; partial coverage runs exactly the remainder; origin failures and occupied local refs are diagnosed; approval protections remain intact.

3. **Poll ready changes and publish evidence.**  
   Add a worker script, package wiring, and focused tests.  
   **Implemented basis:** pending inventory, structured requirements, and local attestation storage exist (`status/pending.go:79`, `status/checks.go:94`, `attest/run.go:201`).  
   **Acceptance:** evidence precedes approval; concurrent invocations serialize; failed batches back off; lost replies reuse the local ref; superseded heads may finish harmlessly.

4. **Deploy the capped pilot.**  
   Add a disabled service/timer module and the valley host’s deployment configuration.  
   **Deployment basis:** KVM and existing VM tests are declared above.  
   **Acceptance:** the-valley’s complete required batch succeeds under the cap, secret-access probes fail, and exhaustion leaves host services healthy. The deployment project follows through the three configuration gates.

## Deferred pieces

| Piece | Add it when |
|---|---|
| Scheduler, leases, and second-worker overflow | Measured queue delay justifies another worker. The second worker remains opt-in, on mains, idle five minutes, with a local pause. |
| Evidence-only endpoint | Ordinary Git transport authority is too broad. |
| New statement addresses and selection rules | Same-signer additions, fresh observations, or independent partial publication are needed. |
| Prepared-result storage and cross-tree client reuse | Rebase churn materially wastes work. |
| Trusted check definitions | Candidate-controlled assertions cease to be acceptable. |
| Per-check signer restrictions | Projects need different trust for different checks. |
| Outer VM isolation | The audited Nix sandbox boundary is insufficient. |
| Rich review progress | Approval output and local journals no longer suffice. |

## Open questions

- **Do the deployment project’s pinned inputs fetch without credentials?** Recommend testing this before enabling it; retain local fallback until resolved.
- **Does its largest required batch fit 8 GiB under normal host load?** Recommend measuring peak aggregate memory and exhaustion behavior without raising the initial cap.
- **Which deployed keys serve worker and local attestation?** Recommend distinct registered identities, with project restrictions installed before worker activation.

## Risks

A compromised worker can lie within an authorized project. Candidate-controlled assertions remain an accepted review responsibility.

Shared-daemon limits do not contain evaluator, daemon, kernel, or KVM exploits. Private source confidentiality needs explicit treatment before granting fetch access.

Batch failure delays all evidence in that batch. Same-signer partial histories still encounter bd-7b7d58f.

Worker and local fallback can duplicate computation if approval begins before publication. Target movement can invalidate evidence after it was checked.

Signer-list changes alone do not invalidate existing decision memos. Published configuration can also lag deployment; the integrator’s current configuration remains authoritative.

## Changes from revision 1

Adopt review findings 1, 2, 4, 6, 7, and 8: updated citations, explicit evidence fetching, configuration-only rollout to the deployment project, existing `valley-go checks`, fewer operational records, simpler output, and an explicit stricter coverage test.

Adopt finding 3’s project-level restriction and collection/memo cuts. Qualify it by letting coverage read the published restriction list.

Adopt finding 5’s local fallback. Qualify its collision claim: separate worker and local signers avoid each other’s refs, while existing same-signer collisions remain.

Comments

  1. contributor2026-10-21 01:48 UTCedited2026-10-29 01:08 UTC by contributor
    Coordinator review (2026-10-21): adopt the shape (a scheduler on the valley host granting durable leases to pulling workers, one assignment per prepared result and check, isolated capped builds with signing outside the build, immutable evidence, approve reusing evidence, the integrator verifying independently, dormant tools before policy). Main question for the operator: slice 3 (trusted check definitions separated from the candidate, closing bd-eaefe82) is the largest and least certain piece; recommend deferring it, accepting the residual that a change can weaken its own checks only through paths the operator reviews (test and check files in classes), and starting with candidate-defined checks plus the rest. Other recommendations as in the design: the second worker attests audited isolated Nix checks only at first; one slot, 4 CPU and 8 GiB per worker until measured; the second worker offers capacity only when explicitly enabled, on mains, five minutes idle, with a local pause; pilot on the-valley.
  2. contributor2026-10-22 10:09 UTCedited2026-10-29 01:08 UTC by contributor
    The operator, 2026-10-22: the five recommendations stand (the valley host and the second worker attest only audited, isolated Nix checks at first; one slot, 4 CPU and 8 GiB until measured; the second worker lends capacity only when enabled, idle 5 minutes, on mains, with a local pause and no remote waking; the-valley pilots; trusted check definitions, slice 3, deferred with the residual accepted). And a constraint on the whole design: keep it simple, and don't leave a mark too broadly across the codebase. The 11-slice design touches statement addresses, evidence contracts, a scheduler, a worker endpoint and every evidence reader; a minimal revision follows.
  3. contributor2026-10-22 11:20 UTCedited2026-10-29 01:08 UTC by contributor
    Cross-family review (Claude) of the minimal workers design, revision 1, 2026-10-22. Revision 2 (the body) adopts it.
    
    # Review: workers-min.md (cross-family)
    
    Checked against origin/main `d8c2e54`. The design's basis, `a6cfba3`, is three commits behind: `695d65e` added the signers publication.
    
    ## Citations
    
    1. **P3: accurate but stale.** Twelve spot-checks match at `a6cfba3`. At main, the `bin/valley` approve lines sit 23 lower: 1666 is the key check, 1689 the run list, 1714 `attest run`. `rebase/snapshot.go` sits 6 lower. The core claim holds:
       - The hook admits a create-only ref when every note verifies under the instance known-signers and matches the named tree and key hash. It ignores the pusher (`valleyhook/attestation.go:41-81`, `policy.go:149`).
       - The integrator reads every ref under the head's tree digest on origin and verifies them with the same file (`integrator/evidence.go:51-141`). A fast-forward counts as `unmoved` and transfers without closures (`refs.go:376,419`, `verdict.go:390`).
       - The memo includes an evidence fingerprint, so evidence published later re-triggers judgment (`refs.go:140-147,629`).
    2. **P3: approval must fetch evidence explicitly.** `fetch_origin` is a plain `git fetch --prune origin` (`bin/valley:956`). It brings no `refs/the-valley/attestations/*`.
    
    ## Slice 1: bounded signatures
    
    3. **P2: needed before the key is enabled, but much smaller than drafted.** No existing acceptance can limit what a signer may attest:
       - `#Check` has no signer field.
       - One known-signers file feeds the hook and every `integrator@` instance (`nix/valley-host.nix:213-214,663`).
    
       Once a worker key is in the registry, another project's integrator accepts its claims, so "the-valley pilots" would rest on the worker's own configuration (the design rejects that at line 121).
    
       The smallest safe form is a list of signer and project pairs, read only by the integrator inside `classify` (`evidence.go:125-140`). A listed signer reads as unknown in every other project.
       - Per-check and pure-only rules add nothing. Both pilots declare only `runner: "nix"` checks (the-valley `policy/project/policy.cue:78`, and the deployment project's policy likewise). A forger's harm is per project.
       - No collection change is needed. `evidence.go:78` already lets an admissible note replace a refused one.
       - Cut the memo digest. Narrowing a list cannot land anything, and widening one only delays a landing. Known-signers changes behave the same way today.
       - Cut the client bundle. Since `695d65e`, clients read known-signers from `refs/the-valley/signers`. If drift is a worry, add the list to that tree.
    
    ## The deployment project
    
    4. **P2: what stands between the design and the deployment project.** No valley code is specific to it, so enabling the deployment project is one entry in a list.
       - **Policy.** All 22 of its checks are nix-runner checks. Its VM tests are written for an offline sandbox (in the deployment's configuration), so the isolation audit should be cheap.
       - **KVM.** The valley host loads KVM support and already runs a microVM. NixOS's default system-features include `kvm` and `nixos-test`, and Nix exposes /dev/kvm to builds that need it. Verify one build. Don't add DevicePolicy or PrivateDevices to the daemon.
       - **Cap collateral.** The cap is daemon-wide, but the collateral is small. Root-driven rebuild and converge builds bypass the daemon (per the deployment's configuration), and an `unmoved` integrator pass runs no Nix. Drop the dedicated-daemon question.
    
       Three things actually block the deployment project:
       - **(a) Capacity.** QEMU guest RAM counts against `MemoryMax=8G`. Measure the largest multi-node test, for example resolver-redundancy, under the cap, with the agent guest and inference running beside it.
       - **(b) Private inputs.** it locks inputs hosted under private accounts, and a `flake.lock` bump requires the VM checks (class `flake-inputs`). If any input is private, a worker without credentials cannot fetch it. Giving the worker a token would let a candidate's fixed-output derivation exfiltrate whatever the token reads, before review.
       - **(c) Signer list.** The deployment project must be added to the slice 1 list.
    
       **Recommendation:** the-valley first. Its `ssh-e2e` and `publish-e2e` exercise the same KVM-under-cap path at lower stakes, and its only input is nixpkgs. Add the deployment project by configuration once the exhaustion test passes: days later, not a slice later. Running both from day one is safe only once (b) is answered.
    
       Having a second worker substitute check outputs from the valley host instead is not safer: a substituter is trusted for every path the fetching machine takes.
    
    ## Gaps and cuts
    
    5. **P1: pending-only approval strands everything the worker does not cover.** Line 88 sends unsupported checks to "the existing attestation workflow", but that workflow is approval itself. As written, any of these leaves no path to land:
       - an unaudited check;
       - the deployment project before it is enabled;
       - a deriver divergence;
       - a worker outage;
       - an occupied ref.
    
       The fix is for approval to skip covered checks and build only the remainder locally, as it does today. The remainder is signed with the operator's key, so it lands at a separate ref and cannot hit bd-7b7d58f. This meets the goal exactly: approval builds nothing that evidence covers. The integrator already treats missing evidence as stale and waits, so filing without building is a possible later step.
    6. **P2: drop the derivation migration.** Approval already derives requirements with `valley checks`, the same command the integrator runs (`integrator/policy.go:142`). The worker can call the existing `valley-go checks` (`status/checks.go`). If the two disagree, the cost is wasted or missed work, which finding 5's fallback absorbs. Cut the "status/ requirements helper" and the refuse-on-disagreement rule.
    7. **P3: more cuts.**
       - Publication receipts: the worker's local attestation ref already is the stored object.
       - The recheck before publishing: evidence about a tree that is no longer ready is harmless.
       - Review's four states: approval's printout is enough for the pilot.
    8. **P3: coverage is stricter than the gate.** `unmoved` never compares the check attribute (`verdict.go:390`). That is safe, but the design should say so.
  4. contributor2026-11-08 22:29 UTC
    Done: the host's check worker builds every ready change's checks before approval (oc-24ae62d, oc-d6ce8d3, oc-4a48ff8, oc-5af4248, oc-e092038). A second worker for overflow is an input to qn-94c8817's machine identities.