gunk-dev/the-valley

run.sh

source5ed515359461main's published tip history
69.3 KiB
1#!/usr/bin/env bash
2# The integrator, driven end to end over scratch repositories and throwaway
3# keys. It runs the real binaries: `attest` produces the evidence, the
4# `valley` deriver composes the policy, and the `integrator` judges and
5# lands. Only the nix evaluator is stood in for (integrator/e2e/nix), and
6# only because a nix build has no daemon to call.
7#
8# Each scenario below is one of the phase's exit criteria, observed rather
9# than asserted about. Nothing here touches a repository outside its own
10# scratch directory, and no ref is ever created anywhere but there.
11set -euo pipefail
12
13work="$(mktemp -d)"
14trap 'rm -rf "$work"' EXIT
15here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
17export HOME="$work"
18export GIT_CONFIG_NOSYSTEM=1
19# Scratch goes where the run puts it, as it does under the unit, so what
20# a pass leaves behind is observable rather than scattered through /tmp.
21export TMPDIR="$work/tmp"
22mkdir -p "$TMPDIR"
23export VALLEY_FAKE_STORE="$work/store"
24export PATH="$here:$PATH" # the nix stand-ins, ahead of anything real
25
26git config --global user.name valley-check
27git config --global user.email valley-check@localhost
28git config --global init.defaultBranch main
29git config --global advice.detachedHead false
30
31say() { printf '\n=== %s\n' "$*"; }
32die() {
33 printf '\nintegrator-e2e: %s\n' "$*" >&2
34 exit 1
35}
36holds() { printf ' ok: %s\n' "$*"; }
37
38# ----------------------------------------------------------------------
39say "keys: a contributor, an integrator, and a stranger"
40
41for who in contributor integrator stranger; do
42 ssh-keygen -q -t ed25519 -N "" -C "$who" -f "$work/$who"
43done
44contributor=contributor.valley.invalid/attestations
45integrator_name=integrator.valley.invalid/attestations
46stranger=stranger.elsewhere.invalid/attestations
47
48# The known-signers file is the registry's interim compilation
49# (dcr-b87f6e8): the integrator accepts the contributor and nobody else.
50attest key --key "$work/contributor" --name "$contributor" > "$work/known_signers"
51# What a reader of a landed note holds: both parties to it.
52cat "$work/known_signers" > "$work/reader_keys"
53attest key --key "$work/integrator" --name "$integrator_name" >> "$work/reader_keys"
54attest key --key "$work/stranger" --name "$stranger" > "$work/stranger_key"
55# The key hash the integrator's own attestation refs are keyed by.
56ihash="$(attest key --key "$work/integrator" --name "$integrator_name" | cut -d+ -f2)"
57holds "the integrator holds one signer: $(cut -d+ -f1 < "$work/known_signers")"
58
59# ----------------------------------------------------------------------
60say "the served repository, and the instance policy layer"
61
62origin="$work/project.git"
63git init --quiet --bare "$origin"
64repo="$work/project"
65git init --quiet "$repo"
66cd "$repo"
67git remote add origin "$origin"
68
69mkdir -p docs src deploy checks policy/project
70echo "the readme" > docs/readme.md
71echo "the source" > src/main.txt
72echo "the deployment" > deploy/target.txt
73# What each check reads, which the nix stand-in turns into its closure.
74echo docs > checks/prose-format.inputs
75echo src > checks/code-build.inputs
76
77# The project layer: it declares its own classes and checks above the
78# floor, and declines nothing. It sits at policy/project, which is where the
79# integrator looks without being told (dcr-f41f718).
80cat > policy/project/policy.cue <<'EOF'
81package verification
82
83project: {
84 checks: {
85 "prose-format": {runner: "nix", attribute: "prose-format"}
86 "code-build": {runner: "nix", attribute: "code-build"}
87 // An effectful check, with the validity window dcr-439b771 calls
88 // Δ. Its observation transfers while nothing in the class that
89 // requires it has landed under it and it is younger than this.
90 reachable: {runner: "command", command: "true", validity: "1h"}
91 }
92 classes: {
93 prose: {paths: "docs/**": true, requires: "prose-format": true}
94 code: {paths: "src/**": true, requires: "code-build": true}
95 deploy: {paths: "deploy/**": true, requires: reachable: true}
96 }
97 unclassified: {}
98}
99EOF
100
101git add -A
102git commit --quiet -m "seed the project"
103git push --quiet origin main
104
105# The instance layer lives outside the project's tree, and the integrator
106# reads it from there: a change never supplies the policy that gates it. The
107# floor is the group's own repository's, read at the tip that has been
108# integrated (dcr-f41f718), and it sits at policy/instance in that tip.
109instance_repo="$work/instance.git"
110git init --quiet --bare "$instance_repo"
111floor="$work/instance-project"
112git init --quiet "$floor"
113mkdir -p "$floor/policy/instance"
114cat > "$floor/policy/instance/floor.cue" <<'EOF'
115package verification
116
117floor: {
118 checks: {}
119 classes: {}
120 unclassified: {}
121}
122EOF
123git -C "$floor" add -A
124git -C "$floor" commit --quiet -m "seed the floor"
125git -C "$floor" push --quiet "$instance_repo" main
126
127# The fallback source, for a host that serves no instance repository: the
128# same documents, materialized as a directory. One scenario below reads the
129# floor that way, and every other reads it from the repository.
130instance="$work/instance"
131mkdir -p "$instance"
132cp "$floor/policy/instance/floor.cue" "$instance/floor.cue"
133
134holds "the floor is policy/instance at $instance_repo's tip, and the project's layer is policy/project at its own"
135
136# ----------------------------------------------------------------------
137# Helpers.
138
139# attest_change <branch> <check spec…> — run the checks over the branch's
140# tip and publish the branch with its attestation ref, atomically.
141attest_change() {
142 local branch="$1" key="${2:-$work/contributor}" name="${3:-$contributor}"
143 shift 3
144 attest run --repo "$repo" --key "$key" --name "$name" \
145 --push origin --branch "$branch" "$@"
146}
147
148# request <change> <target> <commit> — the contributor files an integration
149# request by pushing one ref. That ref is the whole of the request.
150request() {
151 git push --quiet origin "$3:refs/the-valley/integration-requests/$2/$1"
152}
153
154integrate() {
155 # Neither policy path is stated: both layers come from where the
156 # integrator defaults to looking, which is the whole of what a deployment
157 # following the convention says about policy.
158 integrator reconcile \
159 --repo "$origin" \
160 --key "$work/integrator" --name "$integrator_name" \
161 --known-signers "$work/known_signers" \
162 --instance-repo "$instance_repo" \
163 --schema "$SCHEMA_VERIFICATION" \
164 --attest-schema "$SCHEMA_ATTESTATION" \
165 --event-schema "$SCHEMA_EVENTS" \
166 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
167 2>&1 | tee "$work/last.out"
168 grep -q . "$work/last.out" || die "the integrator said nothing"
169}
170
171tip() { git -C "$origin" rev-parse refs/heads/main; }
172forget() { git -C "$origin" update-ref -d "refs/the-valley/integration-requests/main/$1"; }
173
174# ----------------------------------------------------------------------
175say "1. a change with valid transferring evidence lands"
176
177before="$(tip)"
178git checkout --quiet -b c1
179echo "a better readme" > docs/readme.md
180echo "a new target" > deploy/second.txt
181git add -A
182git commit --quiet -m "improve the readme and add a target"
183attest_change c1 "" "" --check prose-format --command reachable=true
184request c1 main "$(git rev-parse c1)"
185integrate
186
187grep -q "^c1 -> refs/heads/main .*: land$" "$work/last.out" || die "c1 did not land"
188grep -q "check prose-format .*transferred" "$work/last.out" || die "prose-format did not transfer"
189grep -q "check reachable .*transferred (untouched)" "$work/last.out" || die "the effectful check did not transfer"
190grep -q '"event":"integration-succeeded"' "$work/last.out" || die "no integration-succeeded event"
191# The landing's own ref-updated event, vetted against #RefUpdated like the rest.
192grep -qF "event ref-updated {\"event\":\"ref-updated\",\"repo\":" "$work/last.out" \
193 || die "no ref-updated event"
194[ "$(tip)" != "$before" ] || die "the protected ref did not move"
195[ "$(tip)" = "$(git rev-parse c1)" ] || die "main is not at the change's head"
196git -C "$origin" rev-parse --verify --quiet refs/the-valley/integration-requests/main/c1 > /dev/null \
197 && die "the request ref outlived the landing"
198holds "main moved $(git rev-parse --short "$before") -> $(git -C "$origin" rev-parse --short refs/heads/main)"
199
200# The decision is followed by one timing line: JSON after a fixed label,
201# naming the request and what was decided, with the time each stage took.
202[ "$(grep -c '^ timing ' "$work/last.out")" = 1 ] || die "one decision did not print exactly one timing line"
203timing="$(sed -n 's/^ timing //p' "$work/last.out")"
204for field in \
205 '"request":"refs/the-valley/integration-requests/main/c1"' '"change":"c1"' \
206 "\"head\":\"$(git rev-parse c1)\"" '"target":"refs/heads/main"' "\"tip\":\"$before\"" \
207 '"outcome":"land"' '"duration_ms":' \
208 '"refusal":' '"checkout":' '"evidence":' '"policy":' '"sign":' '"land":' '"record":' '"publish":'; do
209 case "$timing" in
210 *"$field"*) ;;
211 *) die "c1's timing line has no $field: $timing" ;;
212 esac
213done
214holds "the landing is timed: $timing"
215
216# The landed note carries both signatures, under one text, and verifies.
217# The integrator writes under its own key hash, so its ref never races the
218# contributor's over the same subject.
219landed="refs/the-valley/attestations/$(attest digest --repo "$repo" --rev c1 | cut -d: -f2)/$ihash"
220git -C "$origin" rev-parse --verify --quiet "$landed" > /dev/null \
221 || die "no attestation ref by the integrator for the landed tree"
222git -C "$origin" cat-file blob "$landed:prose-format/statement.note" > "$work/landed.note"
223siblings="$(grep -c '^— ' "$work/landed.note")"
224[ "$siblings" -eq 2 ] || die "the landed note carries $siblings signatures, not two"
225attest verify --note "$work/landed.note" --known-keys "$work/reader_keys" \
226 --schema "$SCHEMA_ATTESTATION" --repo "$repo" --rev c1 \
227 --signer "$contributor" --signer "$integrator_name" > "$work/landed.verify"
228grep -q 'matches the recorded subject digest' "$work/landed.verify" || die "the landed note does not bind to the tree"
229holds "the landed note carries contributor and integrator sibling signatures and verifies"
230
231# And the integrator's own transfer statement sits beside it.
232git -C "$origin" cat-file blob "$landed:transfer.note" > "$work/transfer.note"
233head -n1 "$work/transfer.note" | grep -qx 'the-valley/attestation/v1' || die "the transfer note is not a statement"
234grep -qx 'predicateType the-valley/integration/transfer/v1' "$work/transfer.note" || die "wrong predicate type"
235grep -qx 'predicate.change c1' "$work/transfer.note" || die "the transfer statement names no change"
236grep -q '^predicate.policy.sha256 ' "$work/transfer.note" || die "the transfer statement names no policy"
237attest verify --note "$work/transfer.note" --known-keys "$work/reader_keys" \
238 --schema "$SCHEMA_ATTESTATION" --signer "$integrator_name" > /dev/null
239holds "the transfer statement records the verdict and the policy it was derived under"
240
241# ----------------------------------------------------------------------
242say "2. an intervening landing invalidates one check's closure"
243
244git checkout --quiet main
245git pull --quiet --ff-only origin main
246
247# c2 is authored against the current tip and reads both classes.
248git checkout --quiet -b c2
249echo "a readme with more in it" > docs/readme.md
250echo "the source, revised" > src/main.txt
251git add -A
252git commit --quiet -m "revise the readme and the source"
253attest_change c2 "" "" --check prose-format --check code-build
254c2="$(git rev-parse c2)"
255
256# Meanwhile another change lands, touching only what code-build reads.
257git checkout --quiet main
258git checkout --quiet -b intervening
259echo "a second source file" > src/other.txt
260git add -A
261git commit --quiet -m "add a second source file"
262attest_change intervening "" "" --check code-build
263request intervening main "$(git rev-parse intervening)"
264integrate
265grep -q "^intervening -> refs/heads/main .*: land$" "$work/last.out" || die "the intervening change did not land"
266holds "the intervening change landed first; c2's base has moved"
267
268request c2 main "$c2"
269integrate
270grep -q "^c2 -> refs/heads/main .*: stale$" "$work/last.out" || die "c2 was not stale"
271grep -q "check prose-format .*transferred (closure)" "$work/last.out" \
272 || die "prose-format should have transferred by closure equality"
273grep -q "check code-build .*input closure changed" "$work/last.out" \
274 || die "code-build's closure should have moved"
275grep -q '"event":"request-stale"' "$work/last.out" || die "no request-stale event"
276grep -q '"checks":\["code-build"\]' "$work/last.out" || die "the event does not name exactly code-build"
277git -C "$origin" rev-parse --verify --quiet refs/the-valley/integration-requests/main/c2 > /dev/null \
278 || die "the request ref was dropped; there is nothing to approve again"
279holds "one request-stale naming exactly code-build; prose-format reported transferred"
280forget c2
281
282# ----------------------------------------------------------------------
283say "2b. evidence that survives the rebase lands on the moved tip"
284
285# The same shape as 2, with the intervening landing outside what the
286# change's checks read. The tree that lands is not the tree that was
287# attested, and the evidence stands anyway — which is the whole of what
288# content-addressed evidence buys.
289git checkout --quiet main
290git pull --quiet --ff-only origin main
291git checkout --quiet -b c2b
292echo "a readme revised again" > docs/readme.md
293git add -A
294git commit --quiet -m "revise the readme once more"
295attest_change c2b "" "" --check prose-format
296c2b="$(git rev-parse c2b)"
297attested="$(attest digest --repo "$repo" --rev c2b | cut -d: -f2)"
298
299git checkout --quiet main
300git checkout --quiet -b elsewhere
301echo "a third source file" > src/third.txt
302git add -A
303git commit --quiet -m "add a third source file"
304attest_change elsewhere "" "" --check code-build
305request elsewhere main "$(git rev-parse elsewhere)"
306integrate
307grep -q "^elsewhere -> refs/heads/main .*: land$" "$work/last.out" || die "the intervening change did not land"
308
309request c2b main "$c2b"
310integrate
311grep -q "^c2b -> refs/heads/main .*: land$" "$work/last.out" || die "c2b did not land"
312grep -q "check prose-format .*transferred (closure)" "$work/last.out" \
313 || die "the evidence did not transfer by closure equality"
314landedtree="$(git -C "$origin" rev-parse refs/heads/main^{tree})"
315[ "$(git -C "$origin" rev-parse "refs/heads/main^")" = "$(git rev-parse elsewhere)" ] \
316 || die "the landing is not a fast-forward from the tip it was judged against"
317[ "$(git -C "$origin" rev-parse refs/heads/main^{tree})" != "$(git rev-parse "$c2b^{tree}")" ] \
318 || die "the tree did not actually move; the scenario proves nothing"
319holds "the delta landed on a tree it was never attested over, and no check re-ran"
320
321# Two attestation refs now, because the two statements are about two
322# different trees: the contributor's is keyed by the tree it was made over,
323# and the integrator's transfer statement by the tree that landed.
324git fetch --quiet origin main
325landed_digest="$(attest digest --repo "$repo" --rev "$(git -C "$origin" rev-parse refs/heads/main)" | cut -d: -f2)"
326[ "$landed_digest" != "$attested" ] || die "the landed tree is the attested tree; the scenario proves nothing"
327git -C "$origin" cat-file blob \
328 "refs/the-valley/attestations/$attested/$ihash:prose-format/statement.note" > "$work/rebased.note"
329[ "$(grep -c '^— ' "$work/rebased.note")" -eq 2 ] \
330 || die "the countersigned note lost a sibling signature"
331grep -qx "subject.digest.valley-tree-v1 $attested" "$work/rebased.note" \
332 || die "the countersigned statement is not about the tree it was made over"
333git -C "$origin" cat-file blob \
334 "refs/the-valley/attestations/$landed_digest/$ihash:transfer.note" > "$work/rebased.transfer"
335grep -qx "subject.digest.valley-tree-v1 $landed_digest" "$work/rebased.transfer" \
336 || die "the transfer statement is not about the landed tree"
337grep -qx "predicate.base.valley-tree-v1 $attested" "$work/rebased.transfer" \
338 || die "the transfer statement does not cite the base the evidence was produced over"
339grep -qx "predicate.checks.0.rule closure" "$work/rebased.transfer" \
340 || die "the transfer statement does not record the rule that carried the evidence"
341holds "the contributor's statement stays about its own tree; the transfer statement names the landed one"
342
343# ----------------------------------------------------------------------
344say "2c. a re-parenting landing states its own committer, and needs none from the environment"
345
346# Re-parenting is the one landing that makes a commit of the integrator's
347# own, so it is the one that needs a committer. Under the unit there is
348# nothing to take one from: no git config the service can read, no GIT_* in
349# its environment, and a hostname git will not guess an address from. So the
350# integrator states both identities itself — the asker authored the change,
351# the integrator committed the commit that carries it onto the tip — and the
352# pass below runs with everything git could have fallen back to taken away.
353
354# A scrubbed environment: no global or system config, no GIT_* identity, and
355# auto-detection refused outright, so that a host whose own hostname does
356# resolve cannot hide a dependency on it.
357scrubbed() {
358 env -u GIT_AUTHOR_NAME -u GIT_AUTHOR_EMAIL -u GIT_AUTHOR_DATE \
359 -u GIT_COMMITTER_NAME -u GIT_COMMITTER_EMAIL -u GIT_COMMITTER_DATE -u EMAIL \
360 GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 \
361 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=user.useConfigOnly GIT_CONFIG_VALUE_0=true \
362 "$@"
363}
364scrubbed git -C "$origin" var GIT_COMMITTER_IDENT > /dev/null 2>&1 \
365 && die "the scrub left an identity for git to find; the scenario proves nothing"
366
367git checkout --quiet main
368git pull --quiet --ff-only origin main
369git checkout --quiet -b c2c
370echo "a readme revised by a stated author" > docs/readme.md
371git add -A
372# A distinct author, so that what the landed commit carries over from the
373# head and what it states of its own are told apart by reading it.
374GIT_AUTHOR_NAME="a contributor" GIT_AUTHOR_EMAIL="contributor@valley.invalid" \
375 git commit --quiet -m "revise the readme under an author of its own"
376attest_change c2c "" "" --check prose-format
377c2c="$(git rev-parse c2c)"
378
379# The intervening landing, outside what prose-format reads, is what moves
380# c2c's base and makes the landing below a re-parent rather than a
381# fast-forward.
382git checkout --quiet main
383git checkout --quiet -b under-c2c
384echo "a fifth source file" > src/fifth.txt
385git add -A
386git commit --quiet -m "add a fifth source file"
387attest_change under-c2c "" "" --check code-build
388request under-c2c main "$(git rev-parse under-c2c)"
389integrate
390grep -q "^under-c2c -> refs/heads/main .*: land$" "$work/last.out" || die "the intervening change did not land"
391
392request c2c main "$c2c"
393scrubbed integrator reconcile \
394 --repo "$origin" \
395 --key "$work/integrator" --name "$integrator_name" \
396 --known-signers "$work/known_signers" \
397 --instance-repo "$instance_repo" \
398 --schema "$SCHEMA_VERIFICATION" \
399 --attest-schema "$SCHEMA_ATTESTATION" \
400 --event-schema "$SCHEMA_EVENTS" \
401 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
402 2>&1 | tee "$work/last.out"
403grep -q "^c2c -> refs/heads/main .*: land$" "$work/last.out" \
404 || die "a landing with no git identity in the environment did not land: $(cat "$work/last.out")"
405
406landed_commit="$(git -C "$origin" rev-parse refs/heads/main)"
407[ "$landed_commit" != "$c2c" ] || die "the landing was a fast-forward; the scenario proves nothing"
408[ "$(git -C "$origin" log -1 --format='%an <%ae>' "$landed_commit")" = "a contributor <contributor@valley.invalid>" ] \
409 || die "the landed commit is not authored by the asker: $(git -C "$origin" log -1 --format='%an <%ae>' "$landed_commit")"
410[ "$(git -C "$origin" log -1 --format='%cn <%ce>' "$landed_commit")" = "$integrator_name <integrator@the-valley.invalid>" ] \
411 || die "the landed commit is not committed by the integrator: $(git -C "$origin" log -1 --format='%cn <%ce>' "$landed_commit")"
412# The commit id is a function of what the pass decided from and nothing
413# else, so a pass that dies before the ref write recomputes this same
414# commit rather than leaving another behind.
415[ "$(git -C "$origin" log -1 --format=%aI "$landed_commit")" = "$(git -C "$origin" log -1 --format=%cI "$landed_commit")" ] \
416 || die "the committer date is not the author's, so the landed commit id is not reproducible"
417holds "the integrator committed under its own name with nothing in the environment to take one from"
418
419# ----------------------------------------------------------------------
420say "3. a conflicting delta is stale, and demands full re-attestation"
421
422git checkout --quiet main
423git pull --quiet --ff-only origin main
424git checkout --quiet -b c3
425echo "the readme, as c3 would have it" > docs/readme.md
426git add -A
427git commit --quiet -m "rewrite the readme one way"
428attest_change c3 "" "" --check prose-format
429c3="$(git rev-parse c3)"
430
431git checkout --quiet main
432git checkout --quiet -b conflicting
433echo "the readme, as the other change would have it" > docs/readme.md
434git add -A
435git commit --quiet -m "rewrite the readme another way"
436attest_change conflicting "" "" --check prose-format
437request conflicting main "$(git rev-parse conflicting)"
438integrate
439grep -q "^conflicting -> refs/heads/main .*: land$" "$work/last.out" || die "the conflicting change did not land"
440
441request c3 main "$c3"
442integrate
443grep -q "^c3 -> refs/heads/main .*: stale$" "$work/last.out" || die "c3 was not stale"
444grep -q 'resolving it is new authorship' "$work/last.out" || die "the conflict was not reported as new authorship"
445grep -q 'CONFLICT (content): Merge conflict in docs/readme.md' "$work/last.out" \
446 || die "the conflict does not name what could not be merged"
447grep -q '"reason":"conflict"' "$work/last.out" || die "the event does not say conflict"
448grep -q '"checks":\["prose-format"\]' "$work/last.out" || die "a conflict must re-demand every required check"
449holds "a conflict is stale, and every required check is re-demanded"
450forget c3
451
452# ----------------------------------------------------------------------
453say "4. an unknown signer's attestation does not transfer"
454
455git checkout --quiet main
456git pull --quiet --ff-only origin main
457git checkout --quiet -b c4
458echo "a readme signed by a stranger" > docs/readme.md
459git add -A
460git commit --quiet -m "a change a stranger attested"
461attest_change c4 "$work/stranger" "$stranger" --check prose-format
462request c4 main "$(git rev-parse c4)"
463integrate
464grep -q "^c4 -> refs/heads/main .*: stale$" "$work/last.out" || die "c4 was not stale"
465grep -q 'no signer the integrator holds' "$work/last.out" || die "the unknown signer was not reported"
466grep -q '"checks":\["prose-format"\]' "$work/last.out" || die "the event does not name prose-format"
467[ "$(tip)" = "$(git -C "$origin" rev-parse refs/heads/main)" ] || die "main moved"
468holds "evidence from a signer the integrator does not hold does not transfer"
469forget c4
470
471# ----------------------------------------------------------------------
472say "5. a tampered statement is rejected, not called stale"
473
474git checkout --quiet main
475git checkout --quiet -b c5
476echo "an honest readme" > docs/readme.md
477git add -A
478git commit --quiet -m "an honest change"
479attest_change c5 "" "" --check prose-format
480c5="$(git rev-parse c5)"
481c5digest="$(attest digest --repo "$repo" --rev c5 | cut -d: -f2)"
482
483# Edit one value in the signed text and store the result where the real
484# note was. Everything else about the note is untouched.
485c5ref="$(git -C "$origin" for-each-ref --format='%(refname)' \
486 "refs/the-valley/attestations/$c5digest" | head -n1)"
487git -C "$origin" cat-file blob "$c5ref:prose-format/statement.note" \
488 | sed 's/^predicate.result passed$/predicate.result failed/' > "$work/tampered.note"
489cmp -s "$work/tampered.note" <(git -C "$origin" cat-file blob "$c5ref:prose-format/statement.note") \
490 && die "the tamper changed nothing; the test proves nothing"
491blob="$(git -C "$origin" hash-object -w --stdin < "$work/tampered.note")"
492sub="$(printf '100644 blob %s\tstatement.note\n' "$blob" | git -C "$origin" mktree)"
493top="$(printf '040000 tree %s\tprose-format\n' "$sub" | git -C "$origin" mktree)"
494git -C "$origin" update-ref "$c5ref" "$top"
495
496request c5 main "$c5"
497integrate
498grep -q "^c5 -> refs/heads/main .*: reject$" "$work/last.out" || die "a tampered statement was not rejected"
499grep -q 'does not verify as the statement it claims to be' "$work/last.out" || die "the refusal was not reported"
500grep -q 'request-stale' "$work/last.out" && die "a forgery was announced as staleness"
501holds "a tampered statement is a rejection, and no outcome event claims otherwise"
502forget c5
503
504# ----------------------------------------------------------------------
505say "6. an attestation about a different tree is rejected"
506
507git checkout --quiet main
508git checkout --quiet -b c6
509echo "the tree that was actually attested" > docs/readme.md
510git add -A
511git commit --quiet -m "the attested change"
512attest_change c6 "" "" --check prose-format
513c6ref="$(git -C "$origin" for-each-ref --format='%(refname)' \
514 "refs/the-valley/attestations/$(attest digest --repo "$repo" --rev c6 | cut -d: -f2)" | head -n1)"
515
516# A second, different tree — with no attestation of its own — and the
517# first tree's valid, correctly signed note filed under its digest.
518git checkout --quiet -b c6-lifted
519echo "the tree that was not" > docs/readme.md
520git add -A
521git commit --quiet -m "the change the evidence was lifted onto"
522git push --quiet origin c6-lifted
523lifted="$(attest digest --repo "$repo" --rev c6-lifted | cut -d: -f2)"
524git -C "$origin" update-ref \
525 "refs/the-valley/attestations/$lifted/${c6ref##*/}" \
526 "$(git -C "$origin" rev-parse "$c6ref^{tree}")"
527
528request c6 main "$(git rev-parse c6-lifted)"
529integrate
530grep -q "^c6 -> refs/heads/main .*: reject$" "$work/last.out" || die "a lifted attestation was not rejected"
531grep -q 'tree digest mismatch' "$work/last.out" || die "the refusal does not name the tree digest"
532holds "a signature cannot be lifted onto a tree it was not made about"
533forget c6
534
535# ----------------------------------------------------------------------
536say "7. an attestation lying about its kind is rejected"
537
538# The policy runs prose-format with nix, so its evidence is content-
539# addressed. This attestation claims a notarization instead, and its class
540# was untouched by the intervening landing — so under the rule it nominated
541# for itself it would sail onto a base it was never produced over.
542git checkout --quiet main
543git pull --quiet --ff-only origin main
544git checkout --quiet -b c7
545echo "a readme attested as a notarization" > docs/readme.md
546git add -A
547git commit --quiet -m "a change whose attestation lies about its kind"
548attest_change c7 "" "" --command prose-format=true
549c7="$(git rev-parse c7)"
550
551git checkout --quiet main
552git checkout --quiet -b under-c7
553echo "a fourth source file" > src/fourth.txt
554git add -A
555git commit --quiet -m "add a fourth source file"
556attest_change under-c7 "" "" --check code-build
557request under-c7 main "$(git rev-parse under-c7)"
558integrate
559grep -q "^under-c7 -> refs/heads/main .*: land$" "$work/last.out" || die "the intervening change did not land"
560
561request c7 main "$c7"
562integrate
563grep -q "^c7 -> refs/heads/main .*: reject$" "$work/last.out" || die "a lie about the kind was not rejected"
564grep -q 'requires a pure check and the attestation claims an effectful check' "$work/last.out" \
565 || die "the refusal does not say the policy decides the rule"
566holds "the transfer rule follows the policy's runner, never the attestation's own claim"
567forget c7
568
569# ----------------------------------------------------------------------
570say "8. evidence pushed after a no-evidence verdict re-judges and lands"
571
572git checkout --quiet main
573git pull --quiet --ff-only origin main
574git checkout --quiet -b c8
575echo "a readme with no evidence yet" > docs/readme.md
576git add -A
577git commit --quiet -m "a change submitted before its checks ran"
578git push --quiet origin c8
579request c8 main "$(git rev-parse c8)"
580integrate
581grep -q "^c8 -> refs/heads/main .*: stale$" "$work/last.out" || die "a change with no evidence was not stale"
582grep -q 'no attestation for this check accompanies the change' "$work/last.out" \
583 || die "the absent attestation was not reported"
584
585# Nothing about the request or the tip moves; only the evidence arrives.
586attest_change c8 "" "" --check prose-format
587integrate
588grep -q "^c8 -> refs/heads/main .*: land$" "$work/last.out" \
589 || die "the request was not re-judged after its evidence arrived"
590[ "$(tip)" = "$(git rev-parse c8)" ] || die "main is not at the change's head"
591holds "a pass re-judges when evidence arrives, with the request and the tip unmoved"
592
593# ----------------------------------------------------------------------
594say "9. a ref that is not a request does not hold up one that is"
595
596git checkout --quiet main
597git pull --quiet --ff-only origin main
598git checkout --quiet -b c9
599echo "a readme beside a garbage ref" > docs/readme.md
600git add -A
601git commit --quiet -m "a change beside a malformed request"
602attest_change c9 "" "" --check prose-format
603# A name with no target segment at all, and one with a segment too many.
604# This repository is served with no pre-receive hook, so the namespace takes
605# whatever is pushed; on a host only a holder of the request grant writes
606# it, and a holder can still write a name that is not a request.
607git push --quiet origin "$(git rev-parse c9):refs/the-valley/integration-requests/garbage"
608git push --quiet origin "$(git rev-parse c9):refs/the-valley/integration-requests/main/too/deep"
609request c9 main "$(git rev-parse c9)"
610integrate
611grep -q 'refs/the-valley/integration-requests/garbage: not a request ref' "$work/last.out" \
612 || die "the malformed ref was not reported"
613grep -q 'refs/the-valley/integration-requests/main/too/deep: not a request ref' "$work/last.out" \
614 || die "the over-deep ref was not reported"
615grep -q "^c9 -> refs/heads/main .*: land$" "$work/last.out" \
616 || die "a malformed ref stopped the pass reaching a valid request"
617holds "malformed refs are reported and skipped; the valid request beside them landed"
618git -C "$origin" update-ref -d refs/the-valley/integration-requests/garbage
619git -C "$origin" update-ref -d refs/the-valley/integration-requests/main/too/deep
620
621# ----------------------------------------------------------------------
622say "10. a pass leaves no scratch behind, and a leaked worktree is swept"
623
624# Nine scenarios of real passes, landings and rejections alike, and the
625# scratch root is empty: every worktree a pass takes is given back on the
626# way out, on the failure path as much as the success one.
627leftover="$(find "$TMPDIR" -maxdepth 1 -name 'valley-integrator-wt*')"
628[ -z "$leftover" ] || die "nine passes left scratch behind: $leftover"
629[ "$(git -C "$origin" worktree list --porcelain | grep -c '^worktree ')" -eq 1 ] \
630 || die "nine passes left a worktree attached to the repository"
631holds "no pass left a worktree or a scratch directory behind"
632
633# What a crash leaves: the checkout and its administrative entry, both
634# still valid, so nothing prunes them. Beside it, a worktree of the kind
635# an operator might attach by hand, which is not the integrator's to
636# remove.
637leak="$TMPDIR/valley-integrator-wt-crashed"
638mine="$work/an-operators-own-worktree"
639git -C "$origin" worktree add --quiet --detach "$leak" refs/heads/main
640git -C "$origin" worktree add --quiet --detach "$mine" refs/heads/main
641timeout 5 integrator watch --interval 1s \
642 --repo "$origin" \
643 --key "$work/integrator" --name "$integrator_name" \
644 --known-signers "$work/known_signers" \
645 --instance "$instance" \
646 --schema "$SCHEMA_VERIFICATION" \
647 --attest-schema "$SCHEMA_ATTESTATION" \
648 --event-schema "$SCHEMA_EVENTS" \
649 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
650 > "$work/watch.out" 2>&1 || true
651[ ! -e "$leak" ] || die "a leaked scratch worktree survived the sweep"
652if git -C "$origin" worktree list --porcelain | grep -q "^worktree $leak$"; then
653 die "the leaked worktree is gone from disk and still registered"
654fi
655[ -e "$mine" ] || die "the sweep removed a worktree the integrator did not make"
656git -C "$origin" worktree remove --force "$mine"
657holds "a crash-leaked scratch worktree is swept at watch start; another hand's is not"
658
659# ----------------------------------------------------------------------
660say "11. a scratch root it may not write is reported as that, and nothing else"
661
662# The deployment failure this guards is a sandbox failure: the root TMPDIR
663# names is not writable. That is a statement about the unit, not about the
664# change being judged, and it has to arrive as one — with the path and where
665# the path came from — rather than as git complaining about the leading
666# directories of a .git file.
667refused="$work/refused"
668mkdir -p "$refused"
669chmod a-w "$refused"
670git checkout --quiet main
671git pull --quiet --ff-only origin main
672git checkout --quiet -b c10
673echo "a change that never gets a worktree" > docs/readme.md
674git add -A
675git commit --quiet -m "a change the integrator cannot make scratch for"
676attest_change c10 "" "" --check prose-format
677request c10 main "$(git rev-parse c10)"
678export TMPDIR="$refused"
679integrate || true
680export TMPDIR="$work/tmp"
681chmod u+w "$refused"
682grep -q "scratch directory under $refused, which TMPDIR names" "$work/last.out" \
683 || die "an unwritable scratch root was not reported as one: $(cat "$work/last.out")"
684forget c10
685holds "an unwritable scratch root names the path and where it came from"
686
687# ----------------------------------------------------------------------
688say "12. a floor the instance repository does not carry names the directory looked in"
689
690# The deployment failure this guards is a controller pointed at the wrong
691# directory: the floor is somewhere, and not where this controller looked.
692# The report has to name the repository, the directory and the ref, because
693# those three are what the operator compares against the repository in front
694# of them. A floor is either not there at all, or there under a name that
695# holds no documents, and both arrive that way.
696#
697# A missing floor is refused rather than read as requiring nothing, which is
698# the direction the other layer's absence defaults in (dcr-f41f718). The
699# refusal says why in its own sentence, because the operator reading it is
700# being told that the deployment is not one that can land anything.
701git checkout --quiet main
702git pull --quiet --ff-only origin main
703git checkout --quiet -b c11
704echo "a change judged under no floor" > docs/readme.md
705git add -A
706git commit --quiet -m "a change whose floor the controller cannot find"
707attest_change c11 "" "" --check prose-format
708request c11 main "$(git rev-parse c11)"
709
710# The sentence every refusal to find a floor ends with.
711unwritten="a valley without a written floor is not a valley whose changes land"
712
713floorless() {
714 integrator reconcile \
715 --repo "$origin" \
716 --key "$work/integrator" --name "$integrator_name" \
717 --known-signers "$work/known_signers" "$@" \
718 --schema "$SCHEMA_VERIFICATION" \
719 --attest-schema "$SCHEMA_ATTESTATION" \
720 --event-schema "$SCHEMA_EVENTS" \
721 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
722 2>&1 | tee "$work/last.out"
723}
724
725# The project's own repository carries policy/project and no policy/instance,
726# so the default directory is not there.
727floorless --instance-repo "$origin" || true
728grep -qF "no instance policy layer: $origin has no policy/instance/ at refs/heads/main: $unwritten" "$work/last.out" \
729 || die "a missing floor did not name the directory looked in, and why that is refused: $(cat "$work/last.out")"
730
731# And the flat layout, which is a directory that exists and holds no
732# documents of its own: policy/ has the two layers under it and no *.cue in
733# it. Said as that, rather than as an empty composition further on.
734#
735# Under a second request name, because the refusal above is now this
736# controller's recorded answer to c11 and it stands until the request, the
737# tip or the evidence moves — which is scenario 14's whole subject. A
738# request is what an answer is remembered against, so a second one asks the
739# question again.
740request c11-flat main "$(git rev-parse c11)"
741floorless --instance-repo "$origin" --instance-policy policy || true
742grep -qF "no instance policy layer: $origin holds no *.cue in policy/ at refs/heads/main: $unwritten" "$work/last.out" \
743 || die "a floor directory holding no documents did not say so: $(cat "$work/last.out")"
744
745# And the materialized layer, which is how a host that serves no instance
746# repository is given the floor. A directory with nothing in it is the same
747# absence and is refused the same way.
748request c11-bare main "$(git rev-parse c11)"
749nofloor="$work/no-floor-here"
750mkdir -p "$nofloor"
751floorless --instance "$nofloor" || true
752grep -qF "no instance policy layer: $nofloor holds no *.cue: $unwritten" "$work/last.out" \
753 || die "an empty materialized floor was not refused: $(cat "$work/last.out")"
754forget c11
755forget c11-flat
756forget c11-bare
757holds "a floor that is not where the controller looked names the repository, the directory and the ref"
758
759# ----------------------------------------------------------------------
760say "13. a change the policy requires no check of lands, and says so"
761
762# Requiring nothing is an ordinary outcome, not an edge: this project's
763# classes cover docs/, src/ and deploy/, and its `unclassified` set is
764# empty, so a path outside all three is answered with nothing required. The
765# landing still writes a transfer statement — a commit point that records
766# nothing is a landing nothing attests to — and that statement says the
767# required set was empty rather than carrying a list with nothing in it,
768# which has no written form at all.
769git checkout --quiet main
770git pull --quiet --ff-only origin main
771git checkout --quiet -b c12
772echo "outside every class this policy covers" > notes.txt
773git add -A
774git commit --quiet -m "a change no class covers"
775request c12 main "$(git rev-parse c12)"
776integrate
777grep -q '^c12 -> refs/heads/main .*: land$' "$work/last.out" \
778 || die "a change with nothing required did not land: $(cat "$work/last.out")"
779grep -q 'the policy requires no check of the paths this change touches' "$work/last.out" \
780 || die "the verdict did not say the policy required nothing"
781[ "$(tip)" = "$(git rev-parse c12)" ] || die "c12 did not land"
782git -C "$origin" rev-parse --verify --quiet "refs/the-valley/integration-requests/main/c12" > /dev/null \
783 && die "the request ref survived the landing"
784
785nothing="refs/the-valley/attestations/$(attest digest --repo "$repo" --rev c12 | cut -d: -f2)/$ihash"
786git -C "$origin" cat-file blob "$nothing:transfer.note" > "$work/nothing.note"
787grep -qx 'predicate.required none' "$work/nothing.note" \
788 || die "the transfer statement does not say the required set was empty: $(cat "$work/nothing.note")"
789grep -q '^predicate.checks' "$work/nothing.note" \
790 && die "the transfer statement carries a check list beside the empty-set line"
791attest verify --note "$work/nothing.note" --known-keys "$work/reader_keys" \
792 --repo "$repo" --rev c12 --signer "$integrator_name" > /dev/null \
793 || die "the transfer statement for a landing with nothing required does not verify"
794holds "a landing with no required checks is signed, stored, and consumed its request"
795
796# ----------------------------------------------------------------------
797say "14. a request the controller cannot judge is reported once, not every tick"
798
799# The failure this guards is the one that turns a broken deployment into a
800# broken deployment nobody can read: a pass that cannot act on its verdict,
801# retried at tick rate, filling the journal with one refusal per interval
802# forever. The same request, tip and evidence produce the same failure, so
803# repeating it says nothing new. It is reported once and then the answer
804# stands, exactly as an outcome stands.
805git checkout --quiet main
806git pull --quiet --ff-only origin main
807git checkout --quiet -b c13
808echo "a change judged under no floor, repeatedly" > docs/readme.md
809git add -A
810git commit --quiet -m "a change whose floor the controller cannot find, under watch"
811attest_change c13 "" "" --check prose-format
812request c13 main "$(git rev-parse c13)"
813
814# Five seconds at a one-second tick: five passes over one request the
815# controller cannot judge.
816timeout 5 integrator watch --interval 1s \
817 --repo "$origin" \
818 --key "$work/integrator" --name "$integrator_name" \
819 --known-signers "$work/known_signers" \
820 --instance-repo "$origin" --instance-policy policy \
821 --schema "$SCHEMA_VERIFICATION" \
822 --attest-schema "$SCHEMA_ATTESTATION" \
823 --event-schema "$SCHEMA_EVENTS" \
824 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
825 > "$work/repeat.out" 2>&1 || true
826reports="$(grep -c 'no instance policy layer' "$work/repeat.out" || true)"
827[ "$reports" -eq 1 ] \
828 || die "the same refusal was reported $reports times over five ticks: $(cat "$work/repeat.out")"
829forget c13
830holds "a failure a pass cannot get past is reported once and then backs off"
831
832# ----------------------------------------------------------------------
833say "15. a target that carries no project layer of its own is judged under the floor alone"
834
835# The bootstrap this guards is the first policy commit: a project that has
836# not written a layer yet cannot land the commit that writes one, because a
837# change never supplies the policy that gates it. The project layer only
838# ever adds (dcr-f41f718), so its absence adds nothing, and what is left is
839# the floor — which still governs, and is observed governing here.
840
841# The floor grows a requirement of its own first, so that what remains after
842# the project layer goes away is something rather than nothing.
843cat > "$floor/policy/instance/floor.cue" <<'EOF'
844package verification
845
846floor: {
847 checks: "prose-format": {runner: "nix", attribute: "prose-format"}
848 classes: prose: {paths: "docs/**": true, requires: "prose-format": true}
849 unclassified: {}
850}
851EOF
852git -C "$floor" commit --quiet -am "the floor requires prose-format of docs/"
853git -C "$floor" push --quiet "$instance_repo" main
854
855# The project stops carrying a layer. Nothing classifies policy/project
856# itself, so this lands with nothing required — which is how a project could
857# have arrived without one in the first place.
858git checkout --quiet main
859git pull --quiet --ff-only origin main
860git checkout --quiet -b c14
861git rm --quiet -r policy/project
862git commit --quiet -m "stop carrying a project policy layer"
863request c14 main "$(git rev-parse c14)"
864integrate
865grep -q "^c14 -> refs/heads/main .*: land$" "$work/last.out" \
866 || die "dropping the project layer did not land: $(cat "$work/last.out")"
867
868git checkout --quiet main
869git pull --quiet --ff-only origin main
870[ ! -e policy/project ] || die "the project layer is still at the tip; the scenario proves nothing"
871git checkout --quiet -b c15
872echo "a readme judged under the floor alone" > docs/readme.md
873git add -A
874git commit --quiet -m "a change to a project that declares no policy of its own"
875attest_change c15 "" "" --check prose-format
876request c15 main "$(git rev-parse c15)"
877integrate
878grep -q "^c15 -> refs/heads/main .*: land$" "$work/last.out" \
879 || die "a change to a project with no layer of its own did not land: $(cat "$work/last.out")"
880grep -qF "policy no project layer at policy/project; the floor alone" "$work/last.out" \
881 || die "the pass did not say it composed the floor alone"
882grep -q "check prose-format .*transferred" "$work/last.out" \
883 || die "the floor's own requirement did not govern a project with no layer"
884[ "$(tip)" = "$(git rev-parse c15)" ] || die "main is not at the change's head"
885holds "no project layer is no addition; the floor alone required prose-format and the change landed"
886
887# ----------------------------------------------------------------------
888say "16. a floor that requires nothing, written down, composes and judges"
889
890# Emptiness a floor states is not the same thing as a floor nobody wrote.
891# The document is there, somebody landed it, and what it composes to is a
892# policy that requires nothing — so a change under it lands requiring nothing,
893# rather than being refused the way scenario 12's missing floor is.
894cat > "$floor/policy/instance/floor.cue" <<'EOF'
895package verification
896
897floor: {
898 checks: {}
899 classes: {}
900 unclassified: {}
901}
902EOF
903git -C "$floor" commit --quiet -am "the floor requires nothing, and says so"
904git -C "$floor" push --quiet "$instance_repo" main
905
906git checkout --quiet main
907git pull --quiet --ff-only origin main
908git checkout --quiet -b c16
909echo "a readme under a floor that requires nothing" > docs/readme.md
910git add -A
911git commit --quiet -m "a change under an empty floor and no project layer"
912request c16 main "$(git rev-parse c16)"
913integrate
914grep -q "^c16 -> refs/heads/main .*: land$" "$work/last.out" \
915 || die "a change under an explicitly empty floor did not land: $(cat "$work/last.out")"
916grep -q 'the policy requires no check of the paths this change touches' "$work/last.out" \
917 || die "the verdict did not say the policy required nothing"
918grep -qF "policy no project layer at policy/project; the floor alone" "$work/last.out" \
919 || die "the pass did not say it composed the floor alone"
920[ "$(tip)" = "$(git rev-parse c16)" ] || die "main is not at the change's head"
921holds "a floor that states it requires nothing composes, judges, and lands the change requiring nothing"
922
923# ----------------------------------------------------------------------
924say "17. a planted replacement ref changes nothing the controller reads"
925
926# refs/replace/<id> makes git read another object wherever it looks <id> up.
927# Two are planted here, and each alone would land a change that requires
928# evidence and carries none. One swaps the floor's blob in the instance
929# repository for a floor that requires nothing. The other swaps the change's
930# head in the served repository for a commit that touches no class. Neither
931# moves a ref the controller watches. A controller that left replacement
932# refs on would read both and land the change; this one reads the objects
933# the refs actually name, and holds the change stale.
934cat > "$floor/policy/instance/floor.cue" <<'EOF'
935package verification
936
937floor: {
938 checks: "prose-format": {runner: "nix", attribute: "prose-format"}
939 classes: prose: {paths: "docs/**": true, requires: "prose-format": true}
940 unclassified: {}
941}
942EOF
943git -C "$floor" commit --quiet -am "the floor requires prose-format of docs/ again"
944git -C "$floor" push --quiet "$instance_repo" main
945landed_floor="$(git -C "$instance_repo" rev-parse main:policy/instance/floor.cue)"
946empty_floor="$(git -C "$instance_repo" rev-parse main~1:policy/instance/floor.cue)"
947git -C "$instance_repo" update-ref "refs/replace/$landed_floor" "$empty_floor"
948git -C "$instance_repo" show main:policy/instance/floor.cue | grep 'checks: {}' > /dev/null \
949 || die "the floor's replacement did not take, so this scenario proves nothing"
950
951git checkout --quiet main
952git pull --quiet --ff-only origin main
953git checkout --quiet -b c17-decoy
954echo "a note no class covers" > notes.txt
955git commit --quiet -am "a decoy that touches no class"
956git checkout --quiet main
957git checkout --quiet -b c17
958echo "a readme no evidence covers" > docs/readme.md
959git commit --quiet -am "a change that requires prose-format and carries no evidence"
960git push --quiet origin c17 c17-decoy
961git -C "$origin" update-ref "refs/replace/$(git rev-parse c17)" "$(git rev-parse c17-decoy)"
962git -C "$origin" diff --name-only main c17 | grep -x notes.txt > /dev/null \
963 || die "the head's replacement did not take, so this scenario proves nothing"
964request c17 main "$(git rev-parse c17)"
965
966# The environment asks for replacement refs too, and is not listened to.
967before="$(tip)"
968GIT_CONFIG_PARAMETERS="'core.usereplacerefs'='true'" integrate
969grep -q "^c17 -> refs/heads/main .*: stale$" "$work/last.out" \
970 || die "a planted replacement ref decided the verdict: $(cat "$work/last.out")"
971grep -q "check prose-format" "$work/last.out" \
972 || die "the landed floor's requirement was not what the controller read"
973grep -q 'no attestation for this check accompanies the change' "$work/last.out" \
974 || die "the missing evidence was not reported"
975[ "$(tip)" = "$before" ] || die "main moved under a change that requires evidence"
976git -C "$instance_repo" update-ref -d "refs/replace/$landed_floor"
977git -C "$origin" update-ref -d "refs/replace/$(git rev-parse c17)"
978forget c17
979holds "the floor and the change were read as landed and as pushed, past both replacements"
980
981# ----------------------------------------------------------------------
982say "18. a request approved again while its previous head lands stands for the next pass"
983
984# A second approval is leased against the request it read, and
985# nothing stops it reading the head this pass is about to land. So the
986# request can move between the pass reading it and the pass consuming it.
987# The landing is still the old head's, and the request that moved is a new
988# request: consuming it would drop a change nobody judged.
989git checkout --quiet main
990git pull --quiet --ff-only origin main
991git checkout --quiet -b c18
992echo "a readme requested once" > docs/readme.md
993git commit --quiet -am "the first request"
994attest_change c18 "" "" --check prose-format
995request c18 main "$(git rev-parse c18)"
996# main moves under the request, outside anything the check reads. The pass
997# then recomputes the check's closure over the landed tree, and that
998# evaluation is where the second approval happens.
999git checkout --quiet main
1000echo "a note landed in between" > notes.txt
1001git commit --quiet -am "a note landed in between"
1002git push --quiet origin main
1003git checkout --quiet c18
1004git checkout --quiet -b c18-again
1005echo "a readme requested again" > docs/readme.md
1006git commit --quiet -am "the second request"
1007git push --quiet origin c18-again
1008again="$(git rev-parse c18-again)"
1009moving="refs/the-valley/integration-requests/main/c18"
1010before="$(tip)"
1011VALLEY_E2E_DURING_PASS="git -C '$origin' update-ref '$moving' '$again'" integrate
1012grep -q "^c18 -> refs/heads/main .*: land$" "$work/last.out" \
1013 || die "the first request did not land: $(cat "$work/last.out")"
1014[ "$(tip)" != "$before" ] || die "main did not move for the first request"
1015[ "$(git -C "$origin" rev-parse --verify --quiet "$moving")" = "$again" ] \
1016 || die "the request approved again was consumed with the landing of the one before it: $(git -C "$origin" for-each-ref refs/the-valley/integration-requests) $(cat "$work/last.out")"
1017grep -q "request $moving moved to .* while .* landed; it stands for the next pass" "$work/last.out" \
1018 || die "the moved request was not reported: $(cat "$work/last.out")"
1019forget c18
1020holds "a request that moved while its previous head landed was left standing, and said so"
1021
1022# ----------------------------------------------------------------------
1023say "19. a bus that never answers does not hold up a landing"
1024
1025# The landing's own record comes first: main moves, the move is queued for
1026# the mirrors, the evidence is stored and the request consumed. Only then
1027# does the integrator publish, and each publish is cut off at its deadline.
1028# The shipped wrapper puts the real nats first on the path, so the bare
1029# binary runs here, behind a nats that never exits.
1030mkdir "$work/hung-bus" "$work/queue"
1031cat > "$work/hung-bus/nats" <<EOF
1032#!$(command -v bash)
1033exec sleep 1000
1034EOF
1035chmod +x "$work/hung-bus/nats"
1036git checkout --quiet main
1037git pull --quiet --ff-only origin main
1038git checkout --quiet -b c19
1039echo "landed past a bus that never answers" > docs/bus.md
1040git add -A
1041git commit --quiet -m "past a hung bus"
1042attest_change c19 "" "" --check prose-format
1043request c19 main "$(git rev-parse c19)"
1044before="$(tip)"
1045started=$SECONDS
1046PATH="$work/hung-bus:$PATH" timeout 120 "$INTEGRATOR_UNWRAPPED" reconcile \
1047 --repo "$origin" \
1048 --key "$work/integrator" --name "$integrator_name" \
1049 --known-signers "$work/known_signers" \
1050 --instance-repo "$instance_repo" \
1051 --schema "$SCHEMA_VERIFICATION" \
1052 --attest-schema "$SCHEMA_ATTESTATION" \
1053 --event-schema "$SCHEMA_EVENTS" \
1054 --bus nats://127.0.0.1:1 \
1055 --publish-queue "$work/queue" \
1056 2>&1 | tee "$work/last.out" \
1057 || die "the pass did not finish with a bus that never answers: $(cat "$work/last.out")"
1058elapsed=$((SECONDS - started))
1059grep -q "^c19 -> refs/heads/main .*: land$" "$work/last.out" || die "c19 did not land: $(cat "$work/last.out")"
1060[ "$(tip)" = "$(git rev-parse c19)" ] || die "main is not at c19's head"
1061[ "$(cat "$work"/queue/*)" = "$before $(git rev-parse c19) refs/heads/main" ] \
1062 || die "the move was not queued for the mirrors: $(ls -A "$work/queue")"
1063git -C "$origin" rev-parse --verify --quiet refs/the-valley/integration-requests/main/c19 > /dev/null \
1064 && die "the request outlived the landing"
1065grep -q "^ evidence " "$work/last.out" || die "the evidence was not stored"
1066first_evidence="$(grep -n "^ evidence " "$work/last.out" | head -n1 | cut -d: -f1)"
1067first_bus="$(grep -n "^ bus " "$work/last.out" | head -n1 | cut -d: -f1)"
1068[ "$first_evidence" -lt "$first_bus" ] || die "the integrator asked the bus before it stored the evidence"
1069grep -q "bus publish of valley.git.project.ref-updated FAILED: no answer within 10s" "$work/last.out" \
1070 || die "the hung ref-updated publish was not cut off: $(cat "$work/last.out")"
1071grep -q "bus publish of valley.git.project.integration-succeeded FAILED: no answer within 10s" "$work/last.out" \
1072 || die "the hung integration-succeeded publish was not cut off"
1073[ "$elapsed" -lt 60 ] || die "the pass took ${elapsed}s behind a bus that never answers"
1074holds "c19 landed, queued and consumed its request before a hung bus was asked, and each publish gave up after 10s (${elapsed}s in all)"
1075
1076# ----------------------------------------------------------------------
1077say "20. a cue that never answers a payload's vet does not hold up a landing"
1078
1079# The payload is vetted before it is published, and the vet is bounded the
1080# same way. This cue hangs only when asked to vet against the event schema;
1081# every other use, judging included, goes to the real one.
1082real_cue="$(command -v cue)"
1083mkdir "$work/hung-cue" "$work/queue20"
1084cat > "$work/hung-cue/cue" <<EOF
1085#!$(command -v bash)
1086for arg; do [ "\$arg" = "$SCHEMA_EVENTS" ] && exec sleep 1000; done
1087exec "$real_cue" "\$@"
1088EOF
1089chmod +x "$work/hung-cue/cue"
1090git checkout --quiet main
1091git pull --quiet --ff-only origin main
1092git checkout --quiet -b c20
1093echo "landed past a cue that never answers" > docs/cue.md
1094git add -A
1095git commit --quiet -m "past a hung cue"
1096attest_change c20 "" "" --check prose-format
1097request c20 main "$(git rev-parse c20)"
1098before="$(tip)"
1099started=$SECONDS
1100PATH="$work/hung-cue:$PATH" timeout 120 "$INTEGRATOR_UNWRAPPED" reconcile \
1101 --repo "$origin" \
1102 --key "$work/integrator" --name "$integrator_name" \
1103 --known-signers "$work/known_signers" \
1104 --instance-repo "$instance_repo" \
1105 --schema "$SCHEMA_VERIFICATION" \
1106 --attest-schema "$SCHEMA_ATTESTATION" \
1107 --event-schema "$SCHEMA_EVENTS" \
1108 --publish-queue "$work/queue20" \
1109 2>&1 | tee "$work/last.out" \
1110 || die "the pass did not finish with a cue that never answers: $(cat "$work/last.out")"
1111elapsed=$((SECONDS - started))
1112grep -q "^c20 -> refs/heads/main .*: land$" "$work/last.out" || die "c20 did not land: $(cat "$work/last.out")"
1113[ "$(tip)" = "$(git rev-parse c20)" ] || die "main is not at c20's head"
1114[ "$(cat "$work"/queue20/*)" = "$before $(git rev-parse c20) refs/heads/main" ] \
1115 || die "the move was not queued for the mirrors: $(ls -A "$work/queue20")"
1116git -C "$origin" rev-parse --verify --quiet refs/the-valley/integration-requests/main/c20 > /dev/null \
1117 && die "the request outlived the landing"
1118grep -q "^ evidence " "$work/last.out" || die "the evidence was not stored"
1119grep -q "bus ref-updated not published: cue vet against #RefUpdated gave no answer within 10s" "$work/last.out" \
1120 || die "the hung vet of ref-updated was not cut off: $(cat "$work/last.out")"
1121grep -q "bus integration-succeeded not published: cue vet against #IntegrationSucceeded gave no answer within 10s" "$work/last.out" \
1122 || die "the hung vet of integration-succeeded was not cut off"
1123[ "$elapsed" -lt 60 ] || die "the pass took ${elapsed}s behind a cue that never answers"
1124holds "c20 landed, queued and consumed its request, and each hung vet gave up after 10s and skipped its publish (${elapsed}s in all)"
1125
1126# ----------------------------------------------------------------------
1127say "21. a request named for a change that is ready lands"
1128
1129# A change with a record is requested as c-<change ID>. The records are
1130# written by the valley command itself, as its owner would write them; this
1131# repository is served without the hook that guards them on a host. The
1132# integrator reads them only to refuse.
1133git config valley.principal contributor
1134# ready_change <branch>: the branch's head on origin readied as a new
1135# change, whose ID is left in $readied.
1136ready_change() {
1137 valley ready "$1" > "$work/ready.out" || die "valley ready $1 failed"
1138 readied="$(sed -n 's/^The change ID \([k-z]*\) is new\..*/\1/p' "$work/ready.out")"
1139 [ "${#readied}" = 32 ] || die "valley ready $1 made no change ID: $(cat "$work/ready.out")"
1140}
1141outcome_of() { git -C "$origin" cat-file blob "refs/the-valley/integration-outcomes/main/$1" | cut -d' ' -f4; }
1142
1143git checkout --quiet main
1144git pull --quiet --ff-only origin main
1145git checkout --quiet -b c21
1146echo "a change with a record" > docs/c21.md
1147git add -A
1148git commit --quiet -m "a change with a record"
1149attest_change c21 "" "" --check prose-format
1150ready_change c21
1151id21="$readied"
1152request "c-$id21" main "$(git rev-parse c21)"
1153integrate
1154grep -q "^c-$id21 -> refs/heads/main .*: land$" "$work/last.out" || die "c-$id21 did not land"
1155[ "$(tip)" = "$(git rev-parse c21)" ] || die "main is not at c21's head"
1156landed="refs/the-valley/attestations/$(attest digest --repo "$repo" --rev c21 | cut -d: -f2)/$ihash"
1157git -C "$origin" cat-file blob "$landed:transfer.note" | grep -qx "predicate.change c-$id21" \
1158 || die "the transfer statement does not name the request c-$id21"
1159holds "a ready change's request, named for its ID, landed, and its transfer statement names it so"
1160
1161# ----------------------------------------------------------------------
1162say "22. a change unreadied after its request was filed is refused, and lands once it is ready again"
1163
1164git checkout --quiet main
1165git pull --quiet --ff-only origin main
1166git checkout --quiet -b c22
1167echo "a change paused after it was approved" > docs/c22.md
1168git add -A
1169git commit --quiet -m "a change paused after it was approved"
1170attest_change c22 "" "" --check prose-format
1171ready_change c22
1172id22="$readied"
1173request "c-$id22" main "$(git rev-parse c22)"
1174valley unready "$id22" > /dev/null 2>&1 || die "valley unready failed"
1175before="$(tip)"
1176integrate
1177grep -q "^c-$id22 -> refs/heads/main .*: refused-not-ready$" "$work/last.out" \
1178 || die "a draft's request was not refused: $(cat "$work/last.out")"
1179grep -q "change $id22 is draft, not ready" "$work/last.out" || die "the refusal did not say the change is a draft"
1180[ "$(tip)" = "$before" ] || die "a draft's request moved main"
1181git -C "$origin" rev-parse --verify --quiet "refs/the-valley/integration-requests/main/c-$id22" > /dev/null \
1182 || die "the refused request was dropped"
1183[ "$(outcome_of "c-$id22")" = refused-not-ready ] || die "the outcome record does not say refused-not-ready"
1184
1185# The refusal is decided again on every pass, and said once.
1186timeout 4 integrator watch --interval 1s \
1187 --repo "$origin" \
1188 --key "$work/integrator" --name "$integrator_name" \
1189 --known-signers "$work/known_signers" \
1190 --instance-repo "$instance_repo" \
1191 --schema "$SCHEMA_VERIFICATION" \
1192 --attest-schema "$SCHEMA_ATTESTATION" \
1193 --event-schema "$SCHEMA_EVENTS" \
1194 > "$work/repeat.out" 2>&1 || true
1195[ "$(grep -c "c-$id22 .*refused-not-ready" "$work/repeat.out" || true)" -eq 0 ] \
1196 || die "a standing refusal was reported again: $(cat "$work/repeat.out")"
1197[ "$(tip)" = "$before" ] || die "a draft's request moved main under watch"
1198
1199# Readied again at the same head, the same request lands on the next pass.
1200valley ready --change "$id22" c22 > /dev/null 2>&1 || die "valley ready --change $id22 failed"
1201integrate
1202grep -q "^c-$id22 -> refs/heads/main .*: land$" "$work/last.out" \
1203 || die "the change readied again did not land: $(cat "$work/last.out")"
1204[ "$(tip)" = "$(git rev-parse c22)" ] || die "main is not at c22's head"
1205holds "unready stopped a filed request, the refusal was said once, and ready let the same request land"
1206
1207# ----------------------------------------------------------------------
1208say "23. a request named for a branch, at a draft's head, is refused"
1209
1210# Whatever a request is named, a head that is a version of a change that
1211# is not ready does not land.
1212git checkout --quiet main
1213git pull --quiet --ff-only origin main
1214git checkout --quiet -b c23
1215echo "a draft requested under its branch's name" > docs/c23.md
1216git add -A
1217git commit --quiet -m "a draft requested under its branch's name"
1218attest_change c23 "" "" --check prose-format
1219ready_change c23
1220id23="$readied"
1221valley unready "$id23" > /dev/null 2>&1 || die "valley unready failed"
1222request c23 main "$(git rev-parse c23)"
1223before="$(tip)"
1224integrate
1225grep -q "^c23 -> refs/heads/main .*: refused-not-ready$" "$work/last.out" \
1226 || die "a branch-named request at a draft's head was not refused: $(cat "$work/last.out")"
1227grep -q "is v1 of change $id23, which is draft, not ready" "$work/last.out" \
1228 || die "the refusal did not name the draft"
1229[ "$(tip)" = "$before" ] || die "a draft's head landed under its branch's name"
1230[ "$(outcome_of c23)" = refused-not-ready ] || die "the outcome record does not say refused-not-ready"
1231forget c23
1232holds "a draft's head was refused under a branch's name too"
1233
1234# ----------------------------------------------------------------------
1235say "24. a request whose commits hold a merge is refused"
1236
1237# A merge can make other work look landed by ancestry, so the integrator
1238# lands a line of commits and nothing else.
1239git checkout --quiet main
1240git pull --quiet --ff-only origin main
1241git checkout --quiet -b c24-side
1242echo "a side line" > docs/c24-side.md
1243git add -A
1244git commit --quiet -m "a side line"
1245git checkout --quiet main
1246git checkout --quiet -b c24
1247echo "a line with a merge in it" > docs/c24.md
1248git add -A
1249git commit --quiet -m "a line with a merge in it"
1250git merge --quiet --no-ff --no-edit c24-side
1251git push --quiet origin c24
1252request c24 main "$(git rev-parse c24)"
1253before="$(tip)"
1254integrate
1255grep -q "^c24 -> refs/heads/main .*: refused-merge$" "$work/last.out" \
1256 || die "a request holding a merge was not refused: $(cat "$work/last.out")"
1257grep -q "include the merge $(git rev-parse c24 | cut -c1-12)" "$work/last.out" || die "the refusal did not name the merge"
1258[ "$(tip)" = "$before" ] || die "a request holding a merge moved main"
1259[ "$(outcome_of c24)" = refused-merge ] || die "the outcome record does not say refused-merge"
1260forget c24
1261holds "a request holding a merge was refused, and main did not move"
1262
1263# ----------------------------------------------------------------------
1264say "25. a line of commits above a draft's head is refused, naming the draft"
1265
1266# A request brings every commit from its merge base to its head. So a child
1267# of a draft's head, approved under another name, would land the draft too.
1268git checkout --quiet main
1269git pull --quiet --ff-only origin main
1270git checkout --quiet -b c25-draft
1271echo "a draft below another change" > docs/c25-draft.md
1272git add -A
1273git commit --quiet -m "a draft below another change"
1274git push --quiet origin c25-draft
1275ready_change c25-draft
1276id25="$readied"
1277valley unready "$id25" > /dev/null 2>&1 || die "valley unready failed"
1278git checkout --quiet -b c25
1279echo "a change above a draft" > docs/c25.md
1280git add -A
1281git commit --quiet -m "a change above a draft"
1282git push --quiet origin c25
1283request c25 main "$(git rev-parse c25)"
1284before="$(tip)"
1285integrate
1286grep -q "^c25 -> refs/heads/main .*: refused-not-ready$" "$work/last.out" \
1287 || die "a child of a draft's head was not refused: $(cat "$work/last.out")"
1288grep -q "the commit $(git rev-parse c25-draft | cut -c1-12) it brings is v1 of change $id25, which is draft, not ready" \
1289 "$work/last.out" || die "the refusal did not name the draft"
1290[ "$(tip)" = "$before" ] || die "a child of a draft's head moved main"
1291forget c25
1292holds "a line above a draft's head was refused, and the refusal named the draft"
1293
1294# ----------------------------------------------------------------------
1295say "26. withdrawing a change voids its request, and readying it again needs a fresh approval"
1296
1297# integrate_quiet: a pass that may have nothing to say.
1298integrate_quiet() {
1299 integrator reconcile \
1300 --repo "$origin" \
1301 --key "$work/integrator" --name "$integrator_name" \
1302 --known-signers "$work/known_signers" \
1303 --instance-repo "$instance_repo" \
1304 --schema "$SCHEMA_VERIFICATION" \
1305 --attest-schema "$SCHEMA_ATTESTATION" \
1306 --event-schema "$SCHEMA_EVENTS" \
1307 2>&1 | tee "$work/last.out"
1308}
1309git checkout --quiet main
1310git pull --quiet --ff-only origin main
1311git checkout --quiet -b c26
1312echo "a change withdrawn after it was approved" > docs/c26.md
1313git add -A
1314git commit --quiet -m "a change withdrawn after it was approved"
1315attest_change c26 "" "" --check prose-format
1316ready_change c26
1317id26="$readied"
1318request "c-$id26" main "$(git rev-parse c26)"
1319valley withdraw "$id26" > /dev/null 2>&1 || die "valley withdraw failed"
1320before="$(tip)"
1321integrate
1322grep -q "^c-$id26 -> refs/heads/main .*: voided-withdrawn$" "$work/last.out" \
1323 || die "a withdrawn change's request was not voided: $(cat "$work/last.out")"
1324git -C "$origin" rev-parse --verify --quiet "refs/the-valley/integration-requests/main/c-$id26" > /dev/null \
1325 && die "the voided request is still there"
1326[ "$(outcome_of "c-$id26")" = voided-withdrawn ] || die "the outcome record does not say voided-withdrawn"
1327[ "$(tip)" = "$before" ] || die "a withdrawn change moved main"
1328
1329# Readied again at the same head, the change has no request: the old
1330# approval is gone, and nothing lands.
1331valley ready --change "$id26" c26 > /dev/null 2>&1 || die "valley ready --change $id26 failed"
1332integrate_quiet
1333git -C "$origin" rev-parse --verify --quiet "refs/the-valley/integration-requests/main/c-$id26" > /dev/null \
1334 && die "the old request came back"
1335[ "$(tip)" = "$before" ] || die "a change readied again landed with no fresh approval"
1336
1337# A fresh approval at the same head lands.
1338request "c-$id26" main "$(git rev-parse c26)"
1339integrate
1340grep -q "^c-$id26 -> refs/heads/main .*: land$" "$work/last.out" \
1341 || die "the fresh approval did not land: $(cat "$work/last.out")"
1342[ "$(tip)" = "$(git rev-parse c26)" ] || die "main is not at c26's head"
1343holds "withdraw voided the request on the next pass; readied again, the change landed only on a fresh approval"
1344
1345# ----------------------------------------------------------------------
1346say "27. a stack is rebased whole, a landed change under it drops out, and approving its top lands every layer"
1347
1348# approve reads the floor where the integrator does: the owning valley,
1349# which policy/valley names at main's tip.
1350git checkout --quiet main
1351git pull --quiet --ff-only origin main
1352mkdir -p policy
1353echo "$instance_repo" > policy/valley
1354git add policy/valley
1355git commit --quiet -m "name the owning valley"
1356git push --quiet origin main
1357
1358# A change of two commits, a plain branch on it, and two changes on that.
1359git checkout --quiet -b c27-a
1360echo "the first half of a" > docs/c27-a1.md
1361git add -A
1362git commit --quiet -m "c27: the first half of a"
1363echo "the second half of a" > docs/c27-a2.md
1364git add -A
1365git commit --quiet -m "c27: the second half of a"
1366attest_change c27-a "" "" --check prose-format
1367ready_change c27-a
1368id27a="$readied"
1369for layer in p b c; do
1370 git checkout --quiet -b "c27-$layer"
1371 echo "layer $layer" > "docs/c27-$layer.md"
1372 git add -A
1373 git commit --quiet -m "c27: layer $layer"
1374 git push --quiet origin "c27-$layer"
1375done
1376ready_change c27-b
1377id27b="$readied"
1378ready_change c27-c
1379id27c="$readied"
1380a="$(git rev-parse c27-a)" p="$(git rev-parse c27-p)" b="$(git rev-parse c27-b)" c="$(git rev-parse c27-c)"
1381
1382# main moves under the stack, outside what prose-format reads, and then a
1383# lands through an integrator merge: one new commit, not its own two.
1384git checkout --quiet main
1385git checkout --quiet -b c27-x
1386mkdir -p notes
1387echo "main moves on" > notes/c27-x.txt
1388git add -A
1389git commit --quiet -m "c27: main moves on"
1390git push --quiet origin c27-x
1391request c27-x main "$(git rev-parse c27-x)"
1392integrate
1393grep -q "^c27-x -> refs/heads/main .*: land$" "$work/last.out" || die "c27-x did not land"
1394request "c-$id27a" main "$a"
1395integrate
1396grep -q "^c-$id27a -> refs/heads/main .*: land$" "$work/last.out" || die "c-$id27a did not land"
1397main27="$(tip)"
1398git -C "$origin" merge-base --is-ancestor "$a" "$main27" && die "a landed by fast-forward; the scenario proves nothing"
1399
1400# The rebase reads a's landing from its transfer statement, so a is no
1401# layer, and its two commits under the plain branch drop out. Each layer
1402# keeps its own diff, on the rebased layer below.
1403export VALLEY_KNOWN_SIGNERS="$work/reader_keys" VALLEY_INTEGRATOR_SIGNER="$integrator_name"
1404valley status --json "$id27a" | grep -q '"landing": *"landed-recorded"' || die "a's landing was not read as recorded"
1405valley rebase "$id27c" > "$work/rebase.out" 2>&1 || die "the rebase failed: $(cat "$work/rebase.out")"
1406git fetch --quiet origin
1407np="$(git rev-parse origin/c27-p)" nb="$(git rev-parse origin/c27-b)" nc="$(git rev-parse origin/c27-c)"
1408git merge-base --is-ancestor "$main27" "$np" || die "the bottom is not on main"
1409git merge-base --is-ancestor "$np" "$nb" || die "b is not on the rebased plain branch"
1410git merge-base --is-ancestor "$nb" "$nc" || die "c is not on b"
1411[ "$(git rev-list --count "$main27..$np")" = 1 ] || die "a's commits did not drop out from under the plain branch"
1412[ "$(git diff "$a" "$p")" = "$(git diff "$main27" "$np")" ] || die "the plain branch's diff changed"
1413[ "$(git diff "$p" "$b")" = "$(git diff "$np" "$nb")" ] || die "b's diff changed"
1414[ "$(git diff "$b" "$c")" = "$(git diff "$nb" "$nc")" ] || die "c's diff changed"
1415grep -q "^ c27-p .* origin/c27-p pushed$" "$work/rebase.out" || die "the manifest did not list the plain branch: $(cat "$work/rebase.out")"
1416holds "the stack moved whole onto main, and the landed change's commits dropped out from under it"
1417
1418# Approving the rebased top, and landing it, lands every layer.
1419VALLEY_ATTEST_KEY="$work/contributor" VALLEY_ATTEST_NAME="$contributor" \
1420 valley approve --head "$nc" "$id27c" > "$work/approve.out" 2>&1 \
1421 || die "approving the rebased top failed: $(cat "$work/approve.out")"
1422integrate
1423grep -q "^c-$id27c -> refs/heads/main .*: land$" "$work/last.out" || die "c-$id27c did not land"
1424[ "$(tip)" = "$nc" ] || die "main is not at the top's rebased head"
1425for id in "$id27b" "$id27c"; do
1426 valley status --json "$id" | grep -q '"landing": *"landed"' || die "change $id does not read landed"
1427done
1428git -C "$origin" merge-base --is-ancestor "$np" "$(tip)" || die "the plain branch did not land"
1429unset VALLEY_KNOWN_SIGNERS VALLEY_INTEGRATOR_SIGNER
1430holds "the rebased stack landed as one fast-forward, and every layer reads landed"
1431
1432printf '\nintegrator-e2e: every scenario held\n'