An approval becomes an SSHSIG statement signed with the operator's `ssh:valley-approve` hardware key, and the integrator refuses to land a change in an approval-required class without one. What it takes: - the identity schema and compiler accept `sk-ssh-ed25519` keys, and the `request` grant moves from the operator's `id_ed25519` to the hardware approve keys; - a Go `valley approve` signs the statement of `change-identity-design.md` §2: instance, repository, target, the prepared tip and result, the `valley-delta-v1` delta digest, change ID and version, landing message and author fields, policy and registry snapshots, the carry mode, an expiry, and the withdraw generation, so a withdraw voids earlier approvals race-free; - the statement names the principal who approved, so policy can say who must approve; - batches and trains, so one touch covers several changes; - the integrator checks the statement in one landing decision, per path class. Default approval-required classes: governance, policy, identity, check definitions and `docs/`. The `approval/v1` branch on origin is the reference for its tests and UX; close it once this lands. Done when policy and doc changes cannot land without a verified touch, and the negative tests (touchless, wrong namespace, unknown key, replayed statement) are refused. Source: `plan.md` decisions 2, 3 and 10, Status 2026-10-04 (approval rework, identity follow-ups) and 2026-10-14 (withdraw generation); `change-identity-design.md` §2. --- Slice plan, revision 4, 2026-10-22: authored by Astra (Codex gpt-6-astra) after the operator chose ordinary Ed25519 notes with PIV hardware keys, and cut down by a Claude review of revision 3. Earlier revisions are in this knot file's history; the review of revision 3 is a comment. # Touch-approval slice plan — revision 4 The first release supports Ed25519 software keys and attested YubiKey PIV keys. Every gated landing requires an approval note. The operator’s instance additionally requires a key whose verified enrollment establishes touch-always. The implementation adds `approval/` and small integration points. `attest/`, `note/`, `sigverify/`, `restack/` and `review/` remain unchanged. ## Basis **Implemented** citations refer to HEAD `d8c2e543`, equal to local `origin/main`. `Q:` means qvzz at `083846a`. Proposed mechanisms are **not built**; enrollment and activation are **deployment choices**. Acceptance tests below have not been run. The latest available decision requires ordinary Ed25519 notes for both hardware and software approvals (`refs/remotes/origin-knots/knots:comments/oc-3bc80df/20261021T235610Z-9774dd632edeb24f.md:6`). Adopt the review’s spike, seven slices and follow-ups. The two corrections are the PIV signing command and how cutover checks serials: use `--sign`, and match compiled keys to the certificates carrying their serials. ## 0. Device spike **Purpose.** Establish that the actual device and packaged tools support the proposed path before building around it. The operator runs this outside the repository. First inspect slot 9c; do not overwrite an occupied slot or reset the device. Generate an Ed25519 key with touch-always and PIN-always in an available slot. Obtain its slot attestation, f9 certificate and required intermediate certificates. With the selected slot, test: ```sh yubico-piv-tool -a verify-pin --sign -A ED25519 -s 9c \ -i statement.txt -o signature.bin ``` The review’s `-a sign` is incorrect: signing is a separate flag. The implementation sends Ed25519 input without prehashing. Its buffer limit is not proof of the device’s usable message limit. [CLI definition](https://github.com/Yubico/yubico-piv-tool/blob/master/tool/cmdline.ggo#L29), [signing implementation](https://github.com/Yubico/yubico-piv-tool/blob/master/tool/yubico-piv-tool.c#L1641) **Acceptance.** - A 2 KiB text produces a raw signature accepted by Go `ed25519.Verify`. - Two consecutive signatures each require a touch. - No touch, cancelled PIN and unplugging fail without a usable signature. - The attested Ed25519 public key matches the signing key. - Go verifies the actual chain to pinned Yubico Attestation Root 1, including intermediates. - PIN prompting works without putting the PIN in arguments or logs. Yubico documents Root 1 for firmware 5.7.4 onward. Go compatibility remains a test requirement: piv-go contains a special treatment for f9 certificates lacking CA constraints. Any required compatibility treatment must be narrowly justified by the captured chain; do not disable certificate verification generally. [Yubico attestation](https://developers.yubico.com/PIV/Introduction/PIV_attestation.html), [piv-go verification](https://github.com/go-piv/piv-go/blob/master/piv/key.go) **Output.** Public certificates, public key, test text, signature, tool versions and observed results. Slice 1 commits these as fixtures. Repeat the capability check for the spare before cutover. The spike itself changes no repository files. **Independent repair.** Abandon qvzz as an approval implementation. Land its resolved-commit registry read separately: HEAD resolves a commit but reads through the mutable ref (`identity/registry.go:80`, `identity/registry.go:85`); qvzz reads through the resolved commit (`Q:identity/registry.go:83`, `Q:identity/registry.go:88`). Touch only that reader and its regression test. A simulated ref move must never mix registry versions. ## 1. Identity: attested approval keys **Does.** Add one optional `attestation` block to a key entry. Keep its slot certificate and f9 chain inline as PEM. Pin the accepted Yubico root certificates in the compiler. Accept no applicant-supplied trust anchor. Compile the key as hardware only when: 1. The Yubico attestation chain verifies. 2. The attested Ed25519 public key equals `public`. 3. The authenticated touch policy is `always`. A missing attestation gives no hardware assurance. A malformed or unverifiable supplied attestation fails compilation. A valid cached-touch attestation does not qualify for the hardware file. The existing `bound` field cannot substitute for evidence. Keep `class: "ssh-ed25519"` and the existing public-key representation (`schema/identity.cue:66`). The compiler already extracts its Ed25519 bytes and renders note verifier keys (`identity/render.go:117`, `identity/render.go:229`). Emit two plain files, with lines named by principal: - `approval-signers`: keys of unexpired human principals holding the approve grant. - `approval-signers-hardware`: the qualifying hardware subset. Keep both grant spellings and expiry behavior (`identity/render.go:93`, `identity/render.go:109`). Reject one public key assigned to multiple principals. Validate both outputs with `note.ParseVerifierKeys`. There is no metadata reader and no authorization hidden in comments. Report the verified serial, firmware and PIN policy during compilation for enrollment review. The inline PEMs retain the evidence. No separate possession statement or evidence store is introduced. **Files.** `schema/identity.cue`, `identity/`, `examples/identity/`, identity checks, `docs/reference.md`. Copy qvzz’s grant/expiry tests and output-writing pattern by hand; omit its SK parser, sigverify exports, sk-dummy and application filter. **Depends on.** Spike and resolved-commit repair. Grant compatibility is already at HEAD. **Tests.** Real-device fixtures verify. Reject wrong roots, missing intermediates, altered certificates, mismatched public keys and ambiguous ownership. Test touch-always, cached and never; expired/ungranted principals; software keys; empty output files; deterministic rendering. Invalid evidence must not silently downgrade to software. **Ships.** Dormant compiler support. Existing whole-file replacement prevents torn individual files, but does not make several replacements atomic (`identity/compile.go:137`). ## 2. Policy: one hardware requirement **Does.** Add an optional `approval.hardware` boolean to `#Policy` and its Go reader. Absence means hardware is not required. A floor can mandate: ```cue floor: approval: hardware: true ``` Use the existing set-as-struct semantics: concrete `true` cannot be removed by a project. Do not add a predicate language, provenance alternatives, PIN rules or firmware ranges. The schema already explains this composition rule (`schema/verification.cue:125`, `schema/verification.cue:156`). The setting selects the verifier file; it does not decide whether approval is required. Every gated change still requires a note. **Files.** `schema/verification.cue`, `composed/composed.go`, composition tests and policy examples, `docs/reference.md`. **Depends on.** No ledger slice. Develop alongside slice 1. **Tests.** An absent requirement accepts software policy; a project can strengthen it; a project cannot negate floor `true`. Unknown fields and invalid types fail. The exported policy digest changes with the requirement (`composed/composed.go:197`, `composed/composed.go:232`). **Ships.** Reader/schema support only. Deploy tools before any live policy uses the field: schemas travel with tools (`nix/packages.nix:233`). ## 3. Approval: statement, signing, verification and landing computation **Does.** Add a small, flat codec in `approval/`. The first line is `the-valley/approval/v1`; following fields have a fixed order, one separating space, no escapes and a final newline. Reject unknown, duplicate, missing, oversized or noncanonical fields. Follow the existing line-form rules without extracting its JSON machinery (`attest/text.go:25`, `attest/text.go:40`). The statement binds: | Fields | Binding | |---|---| | Project, target | Configured project name and destination ref | | Change, version, `seq` | The recorded version and state approved | | Head H, destination T | Exact source and destination commits | | Result, delta | Landing tree digest and T→result `valley-delta-v1` digest | | Message, author | Effective landing-message digest; author name, email and date | | Policy, carry | Composed-policy digest and derived carry mode | | Principal, issued, expires | Approver and bounded lifetime | No stable IDs, registry generation, preparation service or client-computed signers snapshot is required. Use ordinary notes. For PIV, invoke the pinned `yubico-piv-tool` executable directly from Go, with bounded input/output and a timeout. Feed the full statement, never a prehash. Construct its signature line with exported `note.KeyHash` and `note.Mark`, then self-verify with `note.Open` (`note/note.go:53`, `note/note.go:70`, `note/note.go:315`). Software signing uses the same statement and envelope. Adapt the existing unencrypted OpenSSH Ed25519 key reader locally; encrypted-key support is outside this slice (`attest/sign.go:180`). Keep the Go module standard-library-only. That is an explicit repository choice, not merely an inference from Nix packaging (`attest/sign.go:47`). Export one landing helper for client and integrator use. It implements the existing fast-forward/merge behavior and effective message/author rules (`integrator/refs.go:379`, `integrator/git.go:167`, `integrator/refs.go:446`). Preserve sanitized Git execution (`integrator/main.go:341`). **Files.** New `approval/` package and command, vectors and tests; `nix/packages.nix`; approval format reference. No edits to `note/` or `attest/`. **Depends on.** Spike; composed reader from slice 2. **Tests.** Existing note readers accept generated notes. Test every field mutation, malformed lines, wrong first-line type, unknown key, principal mismatch and clock boundaries. Compare landing results for fast-forward, clean merge, conflict and trailing-newline cases. Verify that signing a digest instead of the text fails. Confirm packaged signing on the device, including no-touch failure. **Ships.** A usable helper and verifier. Fix the text-size bound only after the spike establishes it. ## 4. Hook and refusal readers **Does.** Admit one replaceable approval ref: ```text refs/the-valley/approvals/<target>/<change> ``` Use a bounded tree containing `approval.note`. Require the approve grant for creation, replacement and deletion. Check naming and object shape; leave final authority and freshness checks to the integrator. Add `refused-approval` to existing outcome readers. The current reader maps unrecognized outcomes to `unknown` (`rebase/outcome.go:36`). **Files.** `valleyhook/`, `rebase/outcome.go`, `status/`, their tests and ref-layout documentation. **Depends on.** Slice 3. Deploy before the gate emits the new outcome. **Tests.** Ungranted writes, malformed refs, symbolic refs and oversized objects fail. Granted replacement succeeds. Status recognizes the refusal. No restacker change is needed: its existing default holds refused requests (`restack/plan.go:203`). **Ships.** Live storage and reader support. The rule mirrors requests (`valleyhook/policy.go:157`); other operational namespaces remain closed (`valleyhook/policy.go:135`). ## 5. Client and signer publication **Does.** Publish both approval verifier files beside the existing signers in `refs/the-valley/signers`. Extend the existing publisher, preserving its lock, comparison and leased update (`integrator/signers.go:30`, `integrator/signers.go:84`, `integrator/signers.go:107`). Empty files must publish revocations; they must not preserve old keys. `valley approve` and the review menu call the Go helper. Show the landing, principal, key fingerprint, hardware-file membership and lifetime. After checks succeed, sign and self-verify. Add the approval ref with its own lease to the existing atomic request/evidence push (`bin/valley:1823`). The publication helps review and client checks. The gate uses its configured local files. A stale publication may cause refusal; it cannot authorize a landing. **Files.** `bin/valley`, `approval/`, `integrator/signers.go`, publisher/client tests, Nix publication wiring, `docs/guide.md`. **Depends on.** Slices 1–4 deployed. **Tests.** No touch or signing failure publishes nothing. Lease races and hook rejection publish no partial request/approval update. Preserve same-head request handling: Git omits unchanged refs, so reread them and never recreate a consumed request (`bin/valley:1766`, `bin/valley:1839`). **Ships.** Live signed requests. Enforcement remains off until slice 7. ## 6. Integrator gate **Does.** Add an off-by-default gate. Pin both approval files once per pass. Select only `approval-signers-hardware` when policy requires hardware; otherwise select `approval-signers`. Missing, malformed or empty selected authority never falls back to another file. Verify the note, its principal, every binding, readiness and all existing checks. Require a recorded change. Reject no-op target updates. Use the shared landing helper. Initially T must match exactly, even when the signed carry mode permits more. Use a 24-hour maximum lifetime, at most five minutes of issue-time skew, and a final expiry check immediately before committing. Extend final record validation to return observed record OIDs. Commit through one transaction: ```text start verify <record-ref> <record-oid> verify <other-relevant-record-ref> <record-oid> verify <approval-ref> <approval-oid> update <target-ref> <L> <T> delete <request-ref> <H> prepare commit ``` Use direct canonical refs. Withdrawal cleanup similarly verifies the withdrawn record while deleting the leased request. This replaces existing separate operations (`integrator/records.go:343`, `integrator/refs.go:533`, `integrator/refs.go:556`, `integrator/records.go:436`). No ledger is needed. Re-evaluate gated requests each pass; the current memo omits authority, approval and clock inputs (`integrator/refs.go:140`). Keep announcement deduplication separate. Journal the approval digest, signer fingerprint, selected authority digest and hardware requirement. The host option must assert sealed targets: protection with no declared writers. Include the instance source and host-configuration source. Current protection admits declared writers, and the instance assertion checks protection alone (`valleyhook/policy.go:192`, `nix/valley-host.nix:1414`). **Files.** `integrator/`, `nix/valley-host.nix`, e2e/host checks, architecture/security documentation. **Depends on.** Slices 1–5. No ledger dependency. **Acceptance suite.** | Negative case | Required result | |---|---| | No touch | Device produces no usable approval; nothing lands | | Software or cached-touch key under hardware policy | Refused through hardware-file selection | | Wrong statement type, unknown/ungranted key or wrong principal | Refused | | Altered binding or changed policy | Refused | | Replayed approval after landing | T mismatch; no second landing | | Expired approval, including expiry during checks | Refused | | Approval predating withdraw/re-ready | `seq` mismatch | | Record, approval or request changes before commit | Transaction fails without moving target | | Direct request injection bypassing the hook | Gate independently rejects missing/invalid approval | Also test a valid landing, concurrent landings and the withdrawal-cleanup race. Run a cross-family security review before activation. **Ships.** Dormant enforcement. ## 7. Cutover and recovery **Deployment choice.** Enroll both hardware keys before enabling the gate. This deliberately uses the existing administrative trust path. The hardware guarantee begins at activation; it is not retroactive. 1. Deploy all tools and readers before using new registry or policy fields. 2. Land both inline attestation entries. Configure touch-always and, by enrollment choice, PIN-always. 3. Stop affected integrators. Seal the instance project, host-configuration source and all gated targets. 4. Compile and inspect authority. Match the hardware file’s two public keys to the two verified certificates and observed device serials. Plain verifier files contain keys, not serial numbers (`note/note.go:122`). 5. Set the instance floor’s hardware requirement. Enable the gate on the instance project first; keep other targets stopped. 6. Exercise a hardware-key-approved landing and a software-key refusal. Enable the sealed host-configuration project, then the remaining targets. 7. Re-sign outstanding requests and drill the spare. After activation, enrollment changes require an already-enrolled key under the old authority and current floor. The proposed key cannot authorize its own addition. Until the TKey follow-up, either enrolled hardware key can approve another key’s enrollment. **Outstanding approvals.** No grandfathering. Unsigned requests and experimental SSHSIG approvals cannot land. Leave requests pending for fresh notes or withdraw them. **Lost key.** Use the enrolled spare to revoke and replace it. For suspected compromise or a firmware advisory, stop affected integration, revoke the key, confirm the compiled and published files, and restart with a fresh pass. Losing both keys requires an explicit administrative rebootstrap; there is no unsigned landing switch. **Files.** Instance registry, floor policy, host declarations and deployment pins; `docs/guide.md` recovery procedure and `docs/security.md`. Actual instance paths are deployment inputs (`nix/valley-host.nix:200`). **Depends on.** All slices, both devices tested, security review complete. **Tests.** Exactly the intended hardware keys qualify. Direct target pushes fail. Unsigned outstanding requests remain blocked. The primary and spare each complete a landing. ## Follow-ups, shortest path and risks Follow-ups are the TKey root and identity-change restriction, carry (`same-paths`, then `same-class`), explicit batching, and additional vendors when needed. Ledger integration later retains the approvals and authority snapshots a landing relied on. Agent review records remain a separate input. The shortest path is the spike, isolated registry repair, slices 1–6 deployed, and slice 7. The first landing after activation can be an ordinary recorded change against an unchanged tip. Recommendations for the operator: - Keep touch-always. Cached touch permits additional signing during its 15-second window; a process can use that opportunity. Batch explicit statements later. [Yubico policy values](https://developers.yubico.com/PIV/Introduction/PIV_attestation.html) - Choose PIN-always at enrollment, while acknowledging that this release does not enforce a PIN-policy requirement. - Accept key revocation as the initial firmware-response mechanism and the spare as initial recovery authority. Limits remain: - Enrollment trusts Yubico’s chain and firmware behavior. A note has no per-signature touch flag and proves intent, not correctness. - Failed compilation preserves old authority. Confirm convergence before resuming after urgent revocation (`identity/main.go:75`). - Exact-tip approval requires re-touches. Same-named instances sharing authority retain cross-instance replay risk. - `seq` closes normal withdrawal replay, but record deletion/recreation can reset it; approve holders may delete records (`valleyhook/record.go:172`, `valleyhook/record.go:314`). - One replaceable approval ref does not retain superseded approvals. The transaction does not supply the ledger’s crash-recovery and durable decision guarantees. - Host administrators remain trusted. Sealing Git targets cannot constrain someone who replaces the verifier or writes local refs directly. ## Changes from revision 3 Each review finding is settled as follows: 1. **Adopted:** one compiled hardware fact and one policy bit. Existing boolean composition supplies the floor semantics (`schema/verification.cue:125`). General attribute predicates are deferred. 2. **Adopted:** two plain verifier files. Comment metadata is unsuitable for authority that an ordinary reader would ignore (`note/note.go:173`). 3. **Adopted:** no TKey prerequisite or bootstrap override. Its enrollment remains unfinished (`docs/security.md:189`). The interim authority is the two inspected hardware keys. 4. **Adopted, command corrected:** subprocess signing preserves the standard-library rule (`attest/sign.go:47`). Use `--sign`; §0 cites the upstream definition. 5. **Adopted:** inline PEMs replace the evidence store and possession format. Enrollment grants authority; note verification establishes possession when approving (`note/note.go:328`). 6. **Adopted:** flat codec and external-signature assembly stay in `approval/`; exported primitives suffice (`note/note.go:53`, `note/note.go:70`). 7. **Adopted:** device spike first. Ed25519 attestation, actual message limits and Go chain compatibility remain unconfirmed until it passes. 8. **Adopted:** existing Ed25519 public-key encoding and principal names; verification checks the full public key (`identity/render.go:117`, `note/note.go:328`). 9. **Adopted:** current HEAD, current qvzz and existing signer publication; refusal readers ship with the hook (`integrator/signers.go:30`, `rebase/outcome.go:36`). 10. **Adopted:** share landing computation instead of maintaining two implementations (`integrator/refs.go:446`). 11. **Adopted:** abandon qvzz, extract only its resolved-commit repair, and carry useful test/output patterns into the new work (`Q:identity/registry.go:83`).
From the coordinator's working file `change-identity-design.md` (moved here 2026-10-18), part 1 of 2: # Change identity, and what an approval signs (draft rev 3, 2026-10-13) **The question (the operator):** we talk about signing *changes* rather than branches, closer to jj than to git. Does our signing strategy reflect that? **Rev 2** takes in the Codex critique (`change-identity-review-codex.md`). The coordinator checked its factual corrections against the-valley's source and accepts them. The main change from rev 1: > **Identity follows the change; authority follows the exact result.** A stable change ID tracks a change across rewrites. A human touch authorises one prepared result on one reviewed destination state. Reusing an approval across rebases ("approve the delta") is a later, explicit delegation feature, not M1-C's default. **Rev 3** takes in the operator's decisions of 2026-10-13 (plan decisions 3, 7 and 15): - **An approval carries across a clean rebase** (§4 is rewritten). Authority now follows the approved *delta*, provided it is proven to land unchanged on unchanged ground; a policy class can still demand the exact result. - **The words are change, ready, approve and submitted.** Submitted is the state a change reaches when it lands. `valley submit` in rev 2 is `valley ready` (the author's act) plus `valley approve` (the human's act). - **One change per submission** stays: commit-level IDs are provenance. - **Changes are co-edited:** an owner plus invited collaborators, with every version recording its uploader (lifecycle rev 4). Rev 2 is kept as `change-identity-design-rev2.md`. That is also how jj works. Change IDs thread a change through its rewrites, but signatures cover commits, which are snapshots, and a rewritten commit is signed again. ## Today (the-valley `d42ab89`) | Artifact | Signed? | Bound to | |---|---|---| | Check evidence (`attest`) | Yes, by the host | The `valley-tree-v1` digest of the attested tree; a commit hash is advisory only.<br>• **Pure checks** carry over to a new tree when their inputs and derivation are unchanged.<br>• **Effectful checks** carry over when the classes they cover are untouched and they're still inside their validity window.<br>The integrator countersigns and writes a separate transfer statement. | | Submit (the request ref) | **No.** Push-authorised by the `request` grant in valleyhook. A repository served without the hook accepts request writes from anyone. | `refs/the-valley/integration-requests/<target>/<name>` → the head commit. `<name>` is the branch with `/` → `-`, which is lossy (bd-57f7f9f). | | Landing record (transfer statement) | Yes, by the integrator | `change` = the name. **Its field called `base` holds the attested head-tree digest, not the merge-base.** Any new format must not reuse that word loosely. | | Outcome memo | No | Keyed by target and name. Filing again replaces it, so earlier outcomes are no longer kept as reachable history. | **How landing works:** - The integrator three-way merges `merge-base(tip, head)..head` onto the tip. - If the merge-base is the tip, it fast-forwards and the whole commit range lands. - Otherwise it writes one commit on the tip, copying the head's author and message, with trailing newlines trimmed. Nothing reads `Change-Id` trailers or commit headers. **Correction to rev 1.** Rev 1 said the roadmap's commit-bound approval "can't work". It can: the integrator prepares the result on a fixed tip, the operator approves that prepared result, and the integrator lands exactly that result under compare-and-swap. The cost is throughput, because every move of the tip before landing needs a fresh touch. That trade is deliberate, and it's the right default. ## Proposal ### 1. Change identity: tracking, not authority - **The ID.** Read from the commit's `change-id` header (written by jj since 0.30: a 16-byte ID in reverse hex) or from a `Change-Id:` trailer (plan decision 7: stamped at dispatch by klaus; `valley ready` offers to stamp one for plain-git authors). - Read the actual header, never text in the message that looks like one. - Reject malformed values, duplicates, or a header and trailer that still differ after normalisation. - **One change ID per change.** `valley ready` names it explicitly and records it in the workflow record. The IDs on individual commits are provenance, not the topic's identity, so ordinary jj stacks (one change per commit) are allowed. - v1 rejects topics that contain merges and ambiguous merge-bases. - v1 has no implicit stacks. - **Scope and versions:** - State is keyed by (instance, enrolled repository ID, target, change ID). The branch name is an advisory locator, which retires bd-57f7f9f. - The integrator assigns each submission an immutable, append-only version. - Review shows `git range-diff` between versions. - **Authority over workflow state.** An ID is author-asserted, so it grants nothing. A new version takes the owner or an invited collaborator, and withdrawing takes the owner or the operator (lifecycle rev 4), so copying an ID can't hijack someone else's change. ### 2. What an approval signs (M1-C): a prepared result 1. **Prepare.** When a version is marked ready, the integrator (or the checker on the operator's host) prepares the result: - it pins the destination ref value: the tip commit and its tree; - it merges the change, giving the result tree and the exact landing message (newline handling defined); - it derives classes and owed checks from the **actual tip→result paths**, plus the change's own paths as a conservative union; - it produces evidence over the result tree. The review then shows that prepared diff and its evidence. This is roadmap M4's "the review flow inverts". 2. **Touch.** The operator's hardware key signs an **approval statement**. It's a new statement type in an **SSHSIG envelope**, because the user-presence and user-verification flags live there. dcr-de9d996's raw ed25519 notes can't carry them. The envelope specifies the namespace, an enrolled principal, the signer class and how verification time is handled. **The statement binds:** - instance, repository ID, target; - destination tip commit and tree, as typed identifiers (`git-sha1:<hex>`); - result tree digest; - **the delta digest** (`valley-delta-v1`, §4); - change ID and version; - landing message digest, and the change's author fields (name, email, date); - policy and registry snapshot digests; - the carry mode the policy sets for the change's classes (§4); - an expiry. 3. **Land.** The integrator verifies everything below as one decision: - the request version; - the approval bytes, the signer's current authorisation, the expiry and revocation; - the effective policy; - the destination ref still equal to the signed tip (compare-and-swap); - the materialised result equal to the signed tree; - the evidence. It then commits the target move, request consumption, approval consumption and an append-only decision record together where possible, using the M4 crash-safe landing (decision 5) for the remaining crash boundaries. **If the tip moved, it prepares again.** The approval carries to the new result only under §4's rules; otherwise it needs a fresh touch. ### 3. Keeping touches cheap - **Batches.** - Entries are independent and consumed one at a time by default. - The whole immutable list is displayed and signed before the touch, and the review bytes are frozen before the touch. - **Trains.** - A dependent batch is prepared in order: B on A's result, C on B's. - One touch signs the ordered train, and it lands in order. If the tip moves mid-train, the remaining entries are prepared again. ### 4. Approvals carry across clean rebases The operator, 2026-10-13: an approval binds the change and carries across clean rebases. Rev 2 listed the prerequisites: a delta with a real security definition, output verification, and semantic limits. This section meets them by defining the delta over **whole files**, which needs no textual-diff semantics at all. **The delta** of a prepared result R on tip T is the set of paths whose entries differ between T and R. Each path has: - a **pre-image**: its entry in T, or `absent`; - a **post-image**: its entry in R, or `absent`. An entry is `(mode, SHA-256 of the content)`, exactly as in `valley-tree-v1`; a symlink's content is its target. A rename is a deletion plus an addition. Because whole contents are hashed: - binary content, executable mode, symlink targets, CRLF and final newlines are all bound; - nothing is positional, so there is no "which occurrence" problem. **The encoding,** `valley-delta-v1`, is exact and is parsed strictly: - The digest is SHA-256 over the header line `valley-delta-v1\n`, followed by one line per path. - Each line is `<len> <path> <pre> <post>\n`, where: - `<len>` is the canonical decimal byte length of the path: no sign, no leading zeros; - `<path>` is the raw path bytes as git stores them in the tree, and a parser consumes exactly `<len>` bytes of it; - each image is `-` or `<mode> <sha256>`. The mode is one of `100644`, `100755` or `120000`, and the hash is 64 lowercase hex digits. - Paths are unique and sorted bytewise. - Paths are never cleaned, case-folded or Unicode-normalised before hashing. **Rejected:** - submodules; - other unsupported tree entries; - duplicate or malformed entries; - any tree that can't be materialised faithfully on the supported filesystem (case-sensitive Linux), such as a file/directory alias. A policy may also reject case or Unicode aliases, for checkouts elsewhere. **Scope.** The digest binds git leaf entries. It doesn't bind ownership, ACLs or other filesystem metadata. It ships with conformance vectors for valid input (renames, mode-only changes, symlinks, deletions, CRLF, paths containing spaces and newlines) and for malformed input. **What's signed.** The approval statement (§2) binds: - instance, repository and target; - the change ID; - the delta digest; - the landing-message digest and the change's author fields (name, email, date), which the descriptor gains, because the integrator copies them from the head into the landed commit (`integrator/refs.go:338`); - the tip and result it was prepared on; - the policy and registry snapshots; - the carry mode; - an expiry. The change version is bound for audit only. **The acceptance predicate.** A review recorded on descriptor D₀ (tip T₀, result R₀) counts for the descriptor D₁ being landed (tip T₁, result R₁) only if **all** of these hold. A human approval and an agent review are both reviews. 1. **Only version, tip and result may differ.** Everything else in D₁ equals D₀: instance, repository, target, change ID, delta digest, landing-message digest, and author fields. A version that changes the message or the author needs a new review, however identical its files. 2. **Output verification.** `delta(T₁, R₁)` equals the approved delta digest: - every touched path goes from the approved pre-image to the approved post-image; - nothing else in R₁ differs from T₁. This proves the touched paths read the same at T₁ as at T₀. It says nothing about what happened to them in between. 3. **Linear history.** T₀ is an ancestor of T₁ on the target's landing history. The interval of landings (T₀, T₁] is what rule 4 inspects. 4. **Carry mode.** The mode is the strictest among all the classes the delta's paths fall in, classified by the policy pinned in rule 5: - `exact`: T₁ = T₀. - `same-class`: no landing in the interval touched any path in any of those classes. - `same-paths`: no further condition. 5. **Same authority inputs.** The policy snapshot and the registry snapshot at T₁ equal D₀'s, and the integrator pins the registry generation it decides under. Either one changing voids every carried review. A policy that changed and changed back still voids them, because rule 4 inspects the interval. 6. **Current eligibility, judged against D₁.** - The reviewer is still authorised for the class, and the review hasn't expired or been revoked. - The independence rules hold for D₁'s full, immutable, authenticated upload history. - An agent reviewer must not be the principal behind any version of the change. - In a class that requires an independent human approver, that approver uploaded no version of the change. - So a reviewer who later uploads an identical delta loses their carried review. 7. **Blocking verdicts carry too.** Any request-changes that rules 1–6 would carry to D₁ blocks D₁. Only new content, meaning a different delta, moves past it, and the old verdict stays on record. 8. **Checks are separate.** Checks are owed on R₁ and met by evidence over R₁, with the usual pure-check carry-over. A review never stands in for a check. 9. **Trains.** - A train approval binds the ordered entries: each entry's change ID, delta digest and predecessor entry. - Substitution, skipping and reordering are refused. - Every entry must independently pass rules 1–8 against its predecessor's actual result. - An entry that changes policy or the registry voids carry for every entry after it (rule 5). **Policy decides the mode per class.** Classes that change trust set `exact`: the identity registry and grants, `policy/` itself, and `secrets/`. Everything else defaults to **`same-paths`** (the operator, 2026-10-13). A project can set `same-class` or `exact` on any class it knows is sensitive or tightly coupled. **The semantic limit is stated, not hidden.** An identical delta can acquire a different meaning: - a caller the approver saw can call a function that another landing changed in a different file; - a symlink's unchanged target can point at content that changed elsewhere. `same-class` narrows this within a class. Neither mode protects a dependency that crosses classes. The guards are the checks over R₁, and `exact` where the checks aren't enough. That is a deliberate trade, and the operator has chosen it. **A human approval verifies aligned intent and quality; it is not where bugs are caught.** Checks are. So approvals carry as far as the rules allow, the system favours eventual consistency with fault tolerance, and sensitive areas opt into stricter modes. **Clean is file-level in v1.** A landing that changed a different part of the same file changes that file's pre-image, so the review doesn't carry. Carrying across non-overlapping edits within one file would need hunk identity, and with it the occurrence problem. It is a possible later refinement, not part of v1. **Broad-intent delegation stays deferred.** "Approve whatever this change becomes" remains decision 3's separate delegation contract.Cross-family review (Claude) of the touch-approval plan, revision 3, 2026-10-22. Revision 4 (the body) adopts it. # Review: touch-approval slice plan, revision 3 **Verdict.** The citations hold, and the security reasoning is sound. But rev3 meets the new key model with a general system: provenance kinds, a metadata format, a predicate evaluator, three signer backends and a TKey bootstrap. One vendor, two keys and one policy bit meet the goal. Rev3 is also 35 KB, against a 22 KB brief. ## Findings 1. **P2: the attribute machinery is ahead of need** (1a–1c). It carries five attributes, three provenance kinds, vendor-scoped firmware ranges, PIN predicates and a new evaluator, all for one vendor. - **One compiled fact instead.** A key is *hardware* when its Yubico chain verifies to the pinned root, the attested key equals `public`, and the touch policy is always. - **The evidence stays in the entry.** The slot and f9 certificates are stored as PEM in the key entry, so anyone can re-verify them and review can show the serial, firmware and PIN policy. - **Policy is one boolean**, in the set-as-struct idiom the schema already uses for carry and requires (`schema/verification.cue:133`, `:168`). The floor writes a concrete `true` that no project can drop. - **Risk accepted:** there are no PIN, firmware or vendor rules. A firmware advisory is answered by revoking keys. A second vendor becomes a later schema addition. 2. **P2: metadata in comments fails open.** In 1b, attributes ride in comment records that a new reader interprets. But `note.ParseVerifierKeys` skips comments (`note/note.go:173–180`), so any ordinary load of the file treats software keys as eligible. - **Fix:** compile two plain verifier files, `approval-signers` and `approval-signers-hardware`. The gate opens the note against whichever file the policy selects. - `note.Open` then checks the full key, so there is no 4-byte-hash binding and no new reader. 3. **P2: the TKey bootstrap holds the goal hostage.** Section 6 makes the gate wait on five things: oc-b5b9671, which is open with nothing built (`docs/security.md:189`); a TKey adapter, which must load the device app and speak its protocol; operator-vouched provenance; 1c's trust-root restriction; and a host bootstrap-signers override (§3). **Cut all five.** Land both hardware-key enrollments before any gate is on, and check that the compiled hardware file lists exactly those two serials. Then enable the gate on the sealed instance project. This gives the same trust as a host-pinned key. **Risk accepted:** until a TKey root exists, an enrolled hardware key with its PIN can enroll another key. 4. **P2: YKCS11 breaks the repository's stdlib-only rule.** Every Go module uses the standard library only (`vendorHash = null` throughout `nix/packages.nix`), and nothing uses cgo. A YKCS11 adapter needs both cgo and a PKCS#11 binding. - **Shell out instead:** `yubico-piv-tool -a verify-pin -a sign -A ED25519 -s 9c`, as the tools already do with git and cue. Its `sign_file` passes Ed25519 input to the device without hashing it, and refuses anything of 3072 bytes or more. - **ykman has no data-signing command.** It serves enrollment: generate, attest and export. - **Fold software signing (2c) into the signer slice.** It is about 30 lines. - **Risk accepted:** a subprocess with a PIN prompt, and a tool version that Nix must pin. 5. **P2: enrollment adds formats.** 1b adds two: - a "domain-separated proof of possession", which is a second signed form; - a content-addressed evidence store. The attestation already proves the key is on the device, and the governed enrollment approval proves who vouches for it. Keep the PEMs inline and pin the roots in the tool. **Risk accepted:** someone could enroll an attested key they don't hold. That is harmless: one key under two principals is refused, and a note names its principal. 6. **P2: shared modules are touched for convenience.** 2a extracts line-form code from `attest/text.go`, which is 570 lines of JSON flattening, and it changes `note/`. - Approval fields are flat, so the codec is about 100 lines in `approval/`. - `note.KeyHash` and `note.Mark` are exported (`note/note.go:53`, `:70`), so `approval/` can build the signature line around an external signature. - `attest/` and `note/` stay untouched. 7. **P2: the hardware path is unproven.** - **Documented by Yubico:** - the attestation extensions (`.3.3` firmware, `.3.7` serial, `.3.8` PIN and touch policy, `.3.9` form factor); - Attestation Root 1 for 5.7.4 and later; - Ed25519 PIV keys on 5.7.4. - **Unconfirmed:** - that `attest` works on an Ed25519 slot; - the device's maximum input size; - Go x509 verification of the 5.7.4 chain. piv-go embeds only the pre-2025 roots, and it patches f9 certificates that lack CA constraints. **Run a device spike first.** Generate in slot 9c with touch always, attest it and export f9. Sign a 2 KiB text with yubico-piv-tool, check it with `ed25519.Verify` and the chain to Root 1, and commit the public outputs as fixtures. 8. **P3: storing the key as `ssh-ed25519` is sensible.** It is the same 32 bytes as the attested SPKI, and the compiler already makes note verifiers from it (`identity/render.go:121`, `:229`). - **The verifier needs nothing more** than its name, hash and key. - **Name lines by principal.** Primary and spare can share a name, because `Open` matches name and hash, then verifies the full key. - **SSH logins are harmless.** A pushing key also lands in `authorized_keys`, but SSH auth data opens with control bytes, which note text refuses (`note/note.go:101`). 9. **P3: the base is stale.** - `main` is now `d8c2e54`, and the host publishes signers at `refs/the-valley/signers` (`integrator/signers.go:21`). Publish the approval files there for review to read. - `S:` cites `9476055`, but qvzz is now `083846a`. - The `refused-approval` reader (`rebase/outcome.go:40`) belongs with the hook slice, not the codec. 10. **P3: the client must reproduce the integrator's landing** (`integrator/refs.go:446`). Export that one function from `approval/` for both sides, or tool skew will refuse landings. 11. **P2: in-flight slice qvzz — keep a part, abandon the rest.** - **Keep:** the registry read through the resolved commit (`identity/registry.go:83`, `:88` at `083846a`). It fixes a real race, so land it alone now. - **Carry over by hand:** grant and expiry selection, the duplicate-owner refusal, the `--approval-signers` whole-file write, and the shape of the e2e harness. - **Drop:** the sk class (`schema/identity.cue:90–113`), the sigverify exports, sk-dummy, the allowed-signers output and the `ssh:valley-approve` filter. - **Abandon, don't retarget.** Its record, claims and checks all describe the sk design. ## Footprint **Rev3 touches** `schema/`, `identity/`, `composed/`, `note/`, `attest/`, `rebase/`, `status/`, the restacker tests, `valleyhook/`, `integrator/`, `bin/valley`, `nix/`, `examples/` and `docs/`. It also adds six units: an attributed reader, an enrollment verifier, a policy evaluator, `approval/`, signer adapters and an approve command. **The narrower shape** adds only `approval/`, plus small hooks: one field and two outputs in `identity/`, one boolean in `schema/verification.cue` and `composed/`, one ref rule in `valleyhook/`, one word in `rebase/` and `status/`, the gate in `integrator/`, one ref in `bin/valley`'s push, and the `nix/` wiring. `note/`, `attest/`, `sigverify/`, `restack/` and `review/` stay untouched. ## Citations checked **Repository citations.** I checked 40 of them, and all are accurate to within two lines. They span: - `identity/` and the schemas; - `note/`, `attest/` and `rebase/`; - `valleyhook/`, the host module and `integrator/`; - `composed/`, `sigverify/`, `docs/` and `bin/valley`; - `S:`. **External claims: confirmed.** - piv-go supports Ed25519 only as algorithm 0x22, for SoloKeys. - yubico-piv-tool supports Ed25519 from 2.5.0. - A cached touch lasts 15 seconds. ## Proposed shape 0. **Device spike.** The operator runs it; it changes nothing in the repository. 1. **identity: attested approval keys.** Adds an optional `attestation` (slot and f9 PEM) to `#Key`. The compiler verifies it against the pinned Yubico roots and emits both approval files, with lines named by principal. Dormant. - Touches `schema/identity.cue`, `identity/`, `examples/identity/`, checks and docs. 2. **policy: one requirement.** Adds `approval: hardware: bool` and the reader for it. Deploy before use (bd-5859932). - Touches `schema/verification.cue` and `composed/`. 3. **approval/: the statement, signing and verifying.** Holds the codec, `Verify`, the yubico-piv-tool and OpenSSH-key signers, the landing computation and test vectors. - Touches `approval/` and `nix/packages.nix`. 4. **hook and readers.** The leased `refs/the-valley/approvals/<target>/<change>` ref under the approve grant, and the `refused-approval` word. - Touches `valleyhook/`, `rebase/` and `status/`. 5. **client.** `valley approve` and the review menu show the landing and the key's hardware status, sign, self-verify, and push the approval ref atomically. The approval files are published beside the signers. - Touches `bin/valley`, `approval/` and `integrator/signers.go`. 6. **integrator gate.** Off by default. It pins both files once per pass, verifies against the file the policy selects, and lands in one `update-ref --stdin` transaction. The host option asserts the targets are sealed. - Touches `integrator/` and `nix/valley-host.nix`. 7. **cutover.** Enroll both hardware keys and check their serials. Set `hardware` in the floor and seal the targets. Gate the instance project first, re-touch outstanding requests, and drill the spare key. **Follow-ups:** the TKey root with an `identity/` restriction (oc-b5b9671), carry, batching, and more vendors once one exists.