gunk-dev/the-valley

run.sh

source20b79cbd2afcmain's published tip history
48.4 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 asks for integration
149# 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[ "$(tip)" != "$before" ] || die "the protected ref did not move"
192[ "$(tip)" = "$(git rev-parse c1)" ] || die "main is not at the change's head"
193git -C "$origin" rev-parse --verify --quiet refs/the-valley/integration-requests/main/c1 > /dev/null \
194 && die "the request ref outlived the landing"
195holds "main moved $(git rev-parse --short "$before") -> $(git -C "$origin" rev-parse --short refs/heads/main)"
196
197# The landed note carries both signatures, under one text, and verifies.
198# The integrator writes under its own key hash, so its ref never races the
199# contributor's over the same subject.
200landed="refs/the-valley/attestations/$(attest digest --repo "$repo" --rev c1 | cut -d: -f2)/$ihash"
201git -C "$origin" rev-parse --verify --quiet "$landed" > /dev/null \
202 || die "no attestation ref by the integrator for the landed tree"
203git -C "$origin" cat-file blob "$landed:prose-format/statement.note" > "$work/landed.note"
204siblings="$(grep -c '^— ' "$work/landed.note")"
205[ "$siblings" -eq 2 ] || die "the landed note carries $siblings signatures, not two"
206attest verify --note "$work/landed.note" --known-keys "$work/reader_keys" \
207 --schema "$SCHEMA_ATTESTATION" --repo "$repo" --rev c1 \
208 --signer "$contributor" --signer "$integrator_name" > "$work/landed.verify"
209grep -q 'matches the recorded subject digest' "$work/landed.verify" || die "the landed note does not bind to the tree"
210holds "the landed note carries contributor and integrator sibling signatures and verifies"
211
212# And the integrator's own transfer statement sits beside it.
213git -C "$origin" cat-file blob "$landed:transfer.note" > "$work/transfer.note"
214head -n1 "$work/transfer.note" | grep -qx 'the-valley/attestation/v1' || die "the transfer note is not a statement"
215grep -qx 'predicateType the-valley/integration/transfer/v1' "$work/transfer.note" || die "wrong predicate type"
216grep -qx 'predicate.change c1' "$work/transfer.note" || die "the transfer statement names no change"
217grep -q '^predicate.policy.sha256 ' "$work/transfer.note" || die "the transfer statement names no policy"
218attest verify --note "$work/transfer.note" --known-keys "$work/reader_keys" \
219 --schema "$SCHEMA_ATTESTATION" --signer "$integrator_name" > /dev/null
220holds "the transfer statement records the verdict and the policy it was derived under"
221
222# ----------------------------------------------------------------------
223say "2. an intervening landing invalidates one check's closure"
224
225git checkout --quiet main
226git pull --quiet --ff-only origin main
227
228# c2 is authored against the current tip and reads both classes.
229git checkout --quiet -b c2
230echo "a readme with more in it" > docs/readme.md
231echo "the source, revised" > src/main.txt
232git add -A
233git commit --quiet -m "revise the readme and the source"
234attest_change c2 "" "" --check prose-format --check code-build
235c2="$(git rev-parse c2)"
236
237# Meanwhile another change lands, touching only what code-build reads.
238git checkout --quiet main
239git checkout --quiet -b intervening
240echo "a second source file" > src/other.txt
241git add -A
242git commit --quiet -m "add a second source file"
243attest_change intervening "" "" --check code-build
244request intervening main "$(git rev-parse intervening)"
245integrate
246grep -q "^intervening -> refs/heads/main .*: land$" "$work/last.out" || die "the intervening change did not land"
247holds "the intervening change landed first; c2's base has moved"
248
249request c2 main "$c2"
250integrate
251grep -q "^c2 -> refs/heads/main .*: stale$" "$work/last.out" || die "c2 was not stale"
252grep -q "check prose-format .*transferred (closure)" "$work/last.out" \
253 || die "prose-format should have transferred by closure equality"
254grep -q "check code-build .*input closure changed" "$work/last.out" \
255 || die "code-build's closure should have moved"
256grep -q '"event":"request-stale"' "$work/last.out" || die "no request-stale event"
257grep -q '"checks":\["code-build"\]' "$work/last.out" || die "the event does not name exactly code-build"
258git -C "$origin" rev-parse --verify --quiet refs/the-valley/integration-requests/main/c2 > /dev/null \
259 || die "the request ref was dropped; there is nothing to resubmit"
260holds "one request-stale naming exactly code-build; prose-format reported transferred"
261forget c2
262
263# ----------------------------------------------------------------------
264say "2b. evidence that survives the rebase lands on the moved tip"
265
266# The same shape as 2, with the intervening landing outside what the
267# change's checks read. The tree that lands is not the tree that was
268# attested, and the evidence stands anyway — which is the whole of what
269# content-addressed evidence buys.
270git checkout --quiet main
271git pull --quiet --ff-only origin main
272git checkout --quiet -b c2b
273echo "a readme revised again" > docs/readme.md
274git add -A
275git commit --quiet -m "revise the readme once more"
276attest_change c2b "" "" --check prose-format
277c2b="$(git rev-parse c2b)"
278attested="$(attest digest --repo "$repo" --rev c2b | cut -d: -f2)"
279
280git checkout --quiet main
281git checkout --quiet -b elsewhere
282echo "a third source file" > src/third.txt
283git add -A
284git commit --quiet -m "add a third source file"
285attest_change elsewhere "" "" --check code-build
286request elsewhere main "$(git rev-parse elsewhere)"
287integrate
288grep -q "^elsewhere -> refs/heads/main .*: land$" "$work/last.out" || die "the intervening change did not land"
289
290request c2b main "$c2b"
291integrate
292grep -q "^c2b -> refs/heads/main .*: land$" "$work/last.out" || die "c2b did not land"
293grep -q "check prose-format .*transferred (closure)" "$work/last.out" \
294 || die "the evidence did not transfer by closure equality"
295landedtree="$(git -C "$origin" rev-parse refs/heads/main^{tree})"
296[ "$(git -C "$origin" rev-parse "refs/heads/main^")" = "$(git rev-parse elsewhere)" ] \
297 || die "the landing is not a fast-forward from the tip it was judged against"
298[ "$(git -C "$origin" rev-parse refs/heads/main^{tree})" != "$(git rev-parse "$c2b^{tree}")" ] \
299 || die "the tree did not actually move; the scenario proves nothing"
300holds "the delta landed on a tree it was never attested over, and no check re-ran"
301
302# Two attestation refs now, because the two statements are about two
303# different trees: the contributor's is keyed by the tree it was made over,
304# and the integrator's transfer statement by the tree that landed.
305git fetch --quiet origin main
306landed_digest="$(attest digest --repo "$repo" --rev "$(git -C "$origin" rev-parse refs/heads/main)" | cut -d: -f2)"
307[ "$landed_digest" != "$attested" ] || die "the landed tree is the attested tree; the scenario proves nothing"
308git -C "$origin" cat-file blob \
309 "refs/the-valley/attestations/$attested/$ihash:prose-format/statement.note" > "$work/rebased.note"
310[ "$(grep -c '^— ' "$work/rebased.note")" -eq 2 ] \
311 || die "the countersigned note lost a sibling signature"
312grep -qx "subject.digest.valley-tree-v1 $attested" "$work/rebased.note" \
313 || die "the countersigned statement is not about the tree it was made over"
314git -C "$origin" cat-file blob \
315 "refs/the-valley/attestations/$landed_digest/$ihash:transfer.note" > "$work/rebased.transfer"
316grep -qx "subject.digest.valley-tree-v1 $landed_digest" "$work/rebased.transfer" \
317 || die "the transfer statement is not about the landed tree"
318grep -qx "predicate.base.valley-tree-v1 $attested" "$work/rebased.transfer" \
319 || die "the transfer statement does not cite the base the evidence was produced over"
320grep -qx "predicate.checks.0.rule closure" "$work/rebased.transfer" \
321 || die "the transfer statement does not record the rule that carried the evidence"
322holds "the contributor's statement stays about its own tree; the transfer statement names the landed one"
323
324# ----------------------------------------------------------------------
325say "2c. a re-parenting landing states its own committer, and needs none from the environment"
326
327# Re-parenting is the one landing that makes a commit of the integrator's
328# own, so it is the one that needs a committer. Under the unit there is
329# nothing to take one from: no git config the service can read, no GIT_* in
330# its environment, and a hostname git will not guess an address from. So the
331# integrator states both identities itself — the asker authored the change,
332# the integrator committed the commit that carries it onto the tip — and the
333# pass below runs with everything git could have fallen back to taken away.
334
335# A scrubbed environment: no global or system config, no GIT_* identity, and
336# auto-detection refused outright, so that a host whose own hostname does
337# resolve cannot hide a dependency on it.
338scrubbed() {
339 env -u GIT_AUTHOR_NAME -u GIT_AUTHOR_EMAIL -u GIT_AUTHOR_DATE \
340 -u GIT_COMMITTER_NAME -u GIT_COMMITTER_EMAIL -u GIT_COMMITTER_DATE -u EMAIL \
341 GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 \
342 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=user.useConfigOnly GIT_CONFIG_VALUE_0=true \
343 "$@"
344}
345scrubbed git -C "$origin" var GIT_COMMITTER_IDENT > /dev/null 2>&1 \
346 && die "the scrub left an identity for git to find; the scenario proves nothing"
347
348git checkout --quiet main
349git pull --quiet --ff-only origin main
350git checkout --quiet -b c2c
351echo "a readme revised by a stated author" > docs/readme.md
352git add -A
353# A distinct author, so that what the landed commit carries over from the
354# head and what it states of its own are told apart by reading it.
355GIT_AUTHOR_NAME="a contributor" GIT_AUTHOR_EMAIL="contributor@valley.invalid" \
356 git commit --quiet -m "revise the readme under an author of its own"
357attest_change c2c "" "" --check prose-format
358c2c="$(git rev-parse c2c)"
359
360# The intervening landing, outside what prose-format reads, is what moves
361# c2c's base and makes the landing below a re-parent rather than a
362# fast-forward.
363git checkout --quiet main
364git checkout --quiet -b under-c2c
365echo "a fifth source file" > src/fifth.txt
366git add -A
367git commit --quiet -m "add a fifth source file"
368attest_change under-c2c "" "" --check code-build
369request under-c2c main "$(git rev-parse under-c2c)"
370integrate
371grep -q "^under-c2c -> refs/heads/main .*: land$" "$work/last.out" || die "the intervening change did not land"
372
373request c2c main "$c2c"
374scrubbed integrator reconcile \
375 --repo "$origin" \
376 --key "$work/integrator" --name "$integrator_name" \
377 --known-signers "$work/known_signers" \
378 --instance-repo "$instance_repo" \
379 --schema "$SCHEMA_VERIFICATION" \
380 --attest-schema "$SCHEMA_ATTESTATION" \
381 --event-schema "$SCHEMA_EVENTS" \
382 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
383 2>&1 | tee "$work/last.out"
384grep -q "^c2c -> refs/heads/main .*: land$" "$work/last.out" \
385 || die "a landing with no git identity in the environment did not land: $(cat "$work/last.out")"
386
387landed_commit="$(git -C "$origin" rev-parse refs/heads/main)"
388[ "$landed_commit" != "$c2c" ] || die "the landing was a fast-forward; the scenario proves nothing"
389[ "$(git -C "$origin" log -1 --format='%an <%ae>' "$landed_commit")" = "a contributor <contributor@valley.invalid>" ] \
390 || die "the landed commit is not authored by the asker: $(git -C "$origin" log -1 --format='%an <%ae>' "$landed_commit")"
391[ "$(git -C "$origin" log -1 --format='%cn <%ce>' "$landed_commit")" = "$integrator_name <integrator@the-valley.invalid>" ] \
392 || die "the landed commit is not committed by the integrator: $(git -C "$origin" log -1 --format='%cn <%ce>' "$landed_commit")"
393# The commit id is a function of what the pass decided from and nothing
394# else, so a pass that dies before the ref write recomputes this same
395# commit rather than leaving another behind.
396[ "$(git -C "$origin" log -1 --format=%aI "$landed_commit")" = "$(git -C "$origin" log -1 --format=%cI "$landed_commit")" ] \
397 || die "the committer date is not the author's, so the landed commit id is not reproducible"
398holds "the integrator committed under its own name with nothing in the environment to take one from"
399
400# ----------------------------------------------------------------------
401say "3. a conflicting delta is stale, and demands full re-attestation"
402
403git checkout --quiet main
404git pull --quiet --ff-only origin main
405git checkout --quiet -b c3
406echo "the readme, as c3 would have it" > docs/readme.md
407git add -A
408git commit --quiet -m "rewrite the readme one way"
409attest_change c3 "" "" --check prose-format
410c3="$(git rev-parse c3)"
411
412git checkout --quiet main
413git checkout --quiet -b conflicting
414echo "the readme, as the other change would have it" > docs/readme.md
415git add -A
416git commit --quiet -m "rewrite the readme another way"
417attest_change conflicting "" "" --check prose-format
418request conflicting main "$(git rev-parse conflicting)"
419integrate
420grep -q "^conflicting -> refs/heads/main .*: land$" "$work/last.out" || die "the conflicting change did not land"
421
422request c3 main "$c3"
423integrate
424grep -q "^c3 -> refs/heads/main .*: stale$" "$work/last.out" || die "c3 was not stale"
425grep -q 'resolving it is new authorship' "$work/last.out" || die "the conflict was not reported as new authorship"
426grep -q 'CONFLICT (content): Merge conflict in docs/readme.md' "$work/last.out" \
427 || die "the conflict does not name what could not be merged"
428grep -q '"reason":"conflict"' "$work/last.out" || die "the event does not say conflict"
429grep -q '"checks":\["prose-format"\]' "$work/last.out" || die "a conflict must re-demand every required check"
430holds "a conflict is stale, and every required check is re-demanded"
431forget c3
432
433# ----------------------------------------------------------------------
434say "4. an unknown signer's attestation does not transfer"
435
436git checkout --quiet main
437git pull --quiet --ff-only origin main
438git checkout --quiet -b c4
439echo "a readme signed by a stranger" > docs/readme.md
440git add -A
441git commit --quiet -m "a change a stranger attested"
442attest_change c4 "$work/stranger" "$stranger" --check prose-format
443request c4 main "$(git rev-parse c4)"
444integrate
445grep -q "^c4 -> refs/heads/main .*: stale$" "$work/last.out" || die "c4 was not stale"
446grep -q 'no signer the integrator holds' "$work/last.out" || die "the unknown signer was not reported"
447grep -q '"checks":\["prose-format"\]' "$work/last.out" || die "the event does not name prose-format"
448[ "$(tip)" = "$(git -C "$origin" rev-parse refs/heads/main)" ] || die "main moved"
449holds "evidence from a signer the integrator does not hold does not transfer"
450forget c4
451
452# ----------------------------------------------------------------------
453say "5. a tampered statement is rejected, not called stale"
454
455git checkout --quiet main
456git checkout --quiet -b c5
457echo "an honest readme" > docs/readme.md
458git add -A
459git commit --quiet -m "an honest change"
460attest_change c5 "" "" --check prose-format
461c5="$(git rev-parse c5)"
462c5digest="$(attest digest --repo "$repo" --rev c5 | cut -d: -f2)"
463
464# Edit one value in the signed text and store the result where the real
465# note was. Everything else about the note is untouched.
466c5ref="$(git -C "$origin" for-each-ref --format='%(refname)' \
467 "refs/the-valley/attestations/$c5digest" | head -n1)"
468git -C "$origin" cat-file blob "$c5ref:prose-format/statement.note" \
469 | sed 's/^predicate.result passed$/predicate.result failed/' > "$work/tampered.note"
470cmp -s "$work/tampered.note" <(git -C "$origin" cat-file blob "$c5ref:prose-format/statement.note") \
471 && die "the tamper changed nothing; the test proves nothing"
472blob="$(git -C "$origin" hash-object -w --stdin < "$work/tampered.note")"
473sub="$(printf '100644 blob %s\tstatement.note\n' "$blob" | git -C "$origin" mktree)"
474top="$(printf '040000 tree %s\tprose-format\n' "$sub" | git -C "$origin" mktree)"
475git -C "$origin" update-ref "$c5ref" "$top"
476
477request c5 main "$c5"
478integrate
479grep -q "^c5 -> refs/heads/main .*: reject$" "$work/last.out" || die "a tampered statement was not rejected"
480grep -q 'does not verify as the statement it claims to be' "$work/last.out" || die "the refusal was not reported"
481grep -q 'request-stale' "$work/last.out" && die "a forgery was announced as staleness"
482holds "a tampered statement is a rejection, and no outcome event claims otherwise"
483forget c5
484
485# ----------------------------------------------------------------------
486say "6. an attestation about a different tree is rejected"
487
488git checkout --quiet main
489git checkout --quiet -b c6
490echo "the tree that was actually attested" > docs/readme.md
491git add -A
492git commit --quiet -m "the attested change"
493attest_change c6 "" "" --check prose-format
494c6ref="$(git -C "$origin" for-each-ref --format='%(refname)' \
495 "refs/the-valley/attestations/$(attest digest --repo "$repo" --rev c6 | cut -d: -f2)" | head -n1)"
496
497# A second, different tree — with no attestation of its own — and the
498# first tree's valid, correctly signed note filed under its digest.
499git checkout --quiet -b c6-lifted
500echo "the tree that was not" > docs/readme.md
501git add -A
502git commit --quiet -m "the change the evidence was lifted onto"
503git push --quiet origin c6-lifted
504lifted="$(attest digest --repo "$repo" --rev c6-lifted | cut -d: -f2)"
505git -C "$origin" update-ref \
506 "refs/the-valley/attestations/$lifted/${c6ref##*/}" \
507 "$(git -C "$origin" rev-parse "$c6ref^{tree}")"
508
509request c6 main "$(git rev-parse c6-lifted)"
510integrate
511grep -q "^c6 -> refs/heads/main .*: reject$" "$work/last.out" || die "a lifted attestation was not rejected"
512grep -q 'tree digest mismatch' "$work/last.out" || die "the refusal does not name the tree digest"
513holds "a signature cannot be lifted onto a tree it was not made about"
514forget c6
515
516# ----------------------------------------------------------------------
517say "7. an attestation lying about its kind is rejected"
518
519# The policy runs prose-format with nix, so its evidence is content-
520# addressed. This attestation claims a notarization instead, and its class
521# was untouched by the intervening landing — so under the rule it nominated
522# for itself it would sail onto a base it was never produced over.
523git checkout --quiet main
524git pull --quiet --ff-only origin main
525git checkout --quiet -b c7
526echo "a readme attested as a notarization" > docs/readme.md
527git add -A
528git commit --quiet -m "a change whose attestation lies about its kind"
529attest_change c7 "" "" --command prose-format=true
530c7="$(git rev-parse c7)"
531
532git checkout --quiet main
533git checkout --quiet -b under-c7
534echo "a fourth source file" > src/fourth.txt
535git add -A
536git commit --quiet -m "add a fourth source file"
537attest_change under-c7 "" "" --check code-build
538request under-c7 main "$(git rev-parse under-c7)"
539integrate
540grep -q "^under-c7 -> refs/heads/main .*: land$" "$work/last.out" || die "the intervening change did not land"
541
542request c7 main "$c7"
543integrate
544grep -q "^c7 -> refs/heads/main .*: reject$" "$work/last.out" || die "a lie about the kind was not rejected"
545grep -q 'requires a pure check and the attestation claims an effectful check' "$work/last.out" \
546 || die "the refusal does not say the policy decides the rule"
547holds "the transfer rule follows the policy's runner, never the attestation's own claim"
548forget c7
549
550# ----------------------------------------------------------------------
551say "8. evidence pushed after a no-evidence verdict re-judges and lands"
552
553git checkout --quiet main
554git pull --quiet --ff-only origin main
555git checkout --quiet -b c8
556echo "a readme with no evidence yet" > docs/readme.md
557git add -A
558git commit --quiet -m "a change submitted before its checks ran"
559git push --quiet origin c8
560request c8 main "$(git rev-parse c8)"
561integrate
562grep -q "^c8 -> refs/heads/main .*: stale$" "$work/last.out" || die "a change with no evidence was not stale"
563grep -q 'no attestation for this check accompanies the change' "$work/last.out" \
564 || die "the absent attestation was not reported"
565
566# Nothing about the request or the tip moves; only the evidence arrives.
567attest_change c8 "" "" --check prose-format
568integrate
569grep -q "^c8 -> refs/heads/main .*: land$" "$work/last.out" \
570 || die "the request was not re-judged after its evidence arrived"
571[ "$(tip)" = "$(git rev-parse c8)" ] || die "main is not at the change's head"
572holds "a pass re-judges when evidence arrives, with the request and the tip unmoved"
573
574# ----------------------------------------------------------------------
575say "9. a ref that is not a request does not hold up one that is"
576
577git checkout --quiet main
578git pull --quiet --ff-only origin main
579git checkout --quiet -b c9
580echo "a readme beside a garbage ref" > docs/readme.md
581git add -A
582git commit --quiet -m "a change beside a malformed request"
583attest_change c9 "" "" --check prose-format
584# A name with no target segment at all, and one with a segment too many.
585# This repository is served with no pre-receive hook, so the namespace takes
586# whatever is pushed; on a host only a holder of the request grant writes
587# it, and a holder can still write a name that is not a request.
588git push --quiet origin "$(git rev-parse c9):refs/the-valley/integration-requests/garbage"
589git push --quiet origin "$(git rev-parse c9):refs/the-valley/integration-requests/main/too/deep"
590request c9 main "$(git rev-parse c9)"
591integrate
592grep -q 'refs/the-valley/integration-requests/garbage: not a request ref' "$work/last.out" \
593 || die "the malformed ref was not reported"
594grep -q 'refs/the-valley/integration-requests/main/too/deep: not a request ref' "$work/last.out" \
595 || die "the over-deep ref was not reported"
596grep -q "^c9 -> refs/heads/main .*: land$" "$work/last.out" \
597 || die "a malformed ref stopped the pass reaching a valid request"
598holds "malformed refs are reported and skipped; the valid request beside them landed"
599git -C "$origin" update-ref -d refs/the-valley/integration-requests/garbage
600git -C "$origin" update-ref -d refs/the-valley/integration-requests/main/too/deep
601
602# ----------------------------------------------------------------------
603say "10. a pass leaves no scratch behind, and a leaked worktree is swept"
604
605# Nine scenarios of real passes, landings and rejections alike, and the
606# scratch root is empty: every worktree a pass takes is given back on the
607# way out, on the failure path as much as the success one.
608leftover="$(find "$TMPDIR" -maxdepth 1 -name 'valley-integrator-wt*')"
609[ -z "$leftover" ] || die "nine passes left scratch behind: $leftover"
610[ "$(git -C "$origin" worktree list --porcelain | grep -c '^worktree ')" -eq 1 ] \
611 || die "nine passes left a worktree attached to the repository"
612holds "no pass left a worktree or a scratch directory behind"
613
614# What a crash leaves: the checkout and its administrative entry, both
615# still valid, so nothing prunes them. Beside it, a worktree of the kind
616# an operator might attach by hand, which is not the integrator's to
617# remove.
618leak="$TMPDIR/valley-integrator-wt-crashed"
619mine="$work/an-operators-own-worktree"
620git -C "$origin" worktree add --quiet --detach "$leak" refs/heads/main
621git -C "$origin" worktree add --quiet --detach "$mine" refs/heads/main
622timeout 5 integrator watch --interval 1s \
623 --repo "$origin" \
624 --key "$work/integrator" --name "$integrator_name" \
625 --known-signers "$work/known_signers" \
626 --instance "$instance" \
627 --schema "$SCHEMA_VERIFICATION" \
628 --attest-schema "$SCHEMA_ATTESTATION" \
629 --event-schema "$SCHEMA_EVENTS" \
630 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
631 > "$work/watch.out" 2>&1 || true
632[ ! -e "$leak" ] || die "a leaked scratch worktree survived the sweep"
633if git -C "$origin" worktree list --porcelain | grep -q "^worktree $leak$"; then
634 die "the leaked worktree is gone from disk and still registered"
635fi
636[ -e "$mine" ] || die "the sweep removed a worktree the integrator did not make"
637git -C "$origin" worktree remove --force "$mine"
638holds "a crash-leaked scratch worktree is swept at watch start; another hand's is not"
639
640# ----------------------------------------------------------------------
641say "11. a scratch root it may not write is reported as that, and nothing else"
642
643# The deployment failure this guards is a sandbox failure: the root TMPDIR
644# names is not writable. That is a statement about the unit, not about the
645# change being judged, and it has to arrive as one — with the path and where
646# the path came from — rather than as git complaining about the leading
647# directories of a .git file.
648refused="$work/refused"
649mkdir -p "$refused"
650chmod a-w "$refused"
651git checkout --quiet main
652git pull --quiet --ff-only origin main
653git checkout --quiet -b c10
654echo "a change that never gets a worktree" > docs/readme.md
655git add -A
656git commit --quiet -m "a change the integrator cannot make scratch for"
657attest_change c10 "" "" --check prose-format
658request c10 main "$(git rev-parse c10)"
659export TMPDIR="$refused"
660integrate || true
661export TMPDIR="$work/tmp"
662chmod u+w "$refused"
663grep -q "scratch directory under $refused, which TMPDIR names" "$work/last.out" \
664 || die "an unwritable scratch root was not reported as one: $(cat "$work/last.out")"
665forget c10
666holds "an unwritable scratch root names the path and where it came from"
667
668# ----------------------------------------------------------------------
669say "12. a floor the instance repository does not carry names the directory looked in"
670
671# The deployment failure this guards is a controller pointed at the wrong
672# directory: the floor is somewhere, and not where this controller looked.
673# The report has to name the repository, the directory and the ref, because
674# those three are what the operator compares against the repository in front
675# of them. A floor is either not there at all, or there under a name that
676# holds no documents, and both arrive that way.
677#
678# A missing floor is refused rather than read as requiring nothing, which is
679# the direction the other layer's absence defaults in (dcr-f41f718). The
680# refusal says why in its own sentence, because the operator reading it is
681# being told that the deployment is not one that can land anything.
682git checkout --quiet main
683git pull --quiet --ff-only origin main
684git checkout --quiet -b c11
685echo "a change judged under no floor" > docs/readme.md
686git add -A
687git commit --quiet -m "a change whose floor the controller cannot find"
688attest_change c11 "" "" --check prose-format
689request c11 main "$(git rev-parse c11)"
690
691# The sentence every refusal to find a floor ends with.
692unwritten="a valley without a written floor is not a valley whose changes land"
693
694floorless() {
695 integrator reconcile \
696 --repo "$origin" \
697 --key "$work/integrator" --name "$integrator_name" \
698 --known-signers "$work/known_signers" "$@" \
699 --schema "$SCHEMA_VERIFICATION" \
700 --attest-schema "$SCHEMA_ATTESTATION" \
701 --event-schema "$SCHEMA_EVENTS" \
702 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
703 2>&1 | tee "$work/last.out"
704}
705
706# The project's own repository carries policy/project and no policy/instance,
707# so the default directory is not there.
708floorless --instance-repo "$origin" || true
709grep -qF "no instance policy layer: $origin has no policy/instance/ at refs/heads/main: $unwritten" "$work/last.out" \
710 || die "a missing floor did not name the directory looked in, and why that is refused: $(cat "$work/last.out")"
711
712# And the flat layout, which is a directory that exists and holds no
713# documents of its own: policy/ has the two layers under it and no *.cue in
714# it. Said as that, rather than as an empty composition further on.
715#
716# Under a second request name, because the refusal above is now this
717# controller's recorded answer to c11 and it stands until the request, the
718# tip or the evidence moves — which is scenario 14's whole subject. A
719# request is what an answer is remembered against, so a second one asks the
720# question again.
721request c11-flat main "$(git rev-parse c11)"
722floorless --instance-repo "$origin" --instance-policy policy || true
723grep -qF "no instance policy layer: $origin holds no *.cue in policy/ at refs/heads/main: $unwritten" "$work/last.out" \
724 || die "a floor directory holding no documents did not say so: $(cat "$work/last.out")"
725
726# And the materialized layer, which is how a host that serves no instance
727# repository is given the floor. A directory with nothing in it is the same
728# absence and is refused the same way.
729request c11-bare main "$(git rev-parse c11)"
730nofloor="$work/no-floor-here"
731mkdir -p "$nofloor"
732floorless --instance "$nofloor" || true
733grep -qF "no instance policy layer: $nofloor holds no *.cue: $unwritten" "$work/last.out" \
734 || die "an empty materialized floor was not refused: $(cat "$work/last.out")"
735forget c11
736forget c11-flat
737forget c11-bare
738holds "a floor that is not where the controller looked names the repository, the directory and the ref"
739
740# ----------------------------------------------------------------------
741say "13. a change the policy requires no check of lands, and says so"
742
743# Requiring nothing is an ordinary outcome, not an edge: this project's
744# classes cover docs/, src/ and deploy/, and its `unclassified` set is
745# empty, so a path outside all three is answered with nothing owed. The
746# landing still writes a transfer statement — a commit point that records
747# nothing is a landing nothing attests to — and that statement says the
748# required set was empty rather than carrying a list with nothing in it,
749# which has no written form at all.
750git checkout --quiet main
751git pull --quiet --ff-only origin main
752git checkout --quiet -b c12
753echo "outside every class this policy covers" > notes.txt
754git add -A
755git commit --quiet -m "a change no class covers"
756request c12 main "$(git rev-parse c12)"
757integrate
758grep -q '^c12 -> refs/heads/main .*: land$' "$work/last.out" \
759 || die "a change with nothing required did not land: $(cat "$work/last.out")"
760grep -q 'the policy requires no check of the paths this change touches' "$work/last.out" \
761 || die "the verdict did not say the policy required nothing"
762[ "$(tip)" = "$(git rev-parse c12)" ] || die "c12 did not land"
763git -C "$origin" rev-parse --verify --quiet "refs/the-valley/integration-requests/main/c12" > /dev/null \
764 && die "the request ref survived the landing"
765
766nothing="refs/the-valley/attestations/$(attest digest --repo "$repo" --rev c12 | cut -d: -f2)/$ihash"
767git -C "$origin" cat-file blob "$nothing:transfer.note" > "$work/nothing.note"
768grep -qx 'predicate.required none' "$work/nothing.note" \
769 || die "the transfer statement does not say the required set was empty: $(cat "$work/nothing.note")"
770grep -q '^predicate.checks' "$work/nothing.note" \
771 && die "the transfer statement carries a check list beside the empty-set line"
772attest verify --note "$work/nothing.note" --known-keys "$work/reader_keys" \
773 --repo "$repo" --rev c12 --signer "$integrator_name" > /dev/null \
774 || die "the transfer statement for a landing with nothing required does not verify"
775holds "a landing with no required checks is signed, stored, and consumed its request"
776
777# ----------------------------------------------------------------------
778say "14. a request the controller cannot judge is reported once, not every tick"
779
780# The failure this guards is the one that turns a broken deployment into a
781# broken deployment nobody can read: a pass that cannot act on its verdict,
782# retried at tick rate, filling the journal with one refusal per interval
783# forever. The same request, tip and evidence produce the same failure, so
784# repeating it says nothing new. It is reported once and then the answer
785# stands, exactly as an outcome stands.
786git checkout --quiet main
787git pull --quiet --ff-only origin main
788git checkout --quiet -b c13
789echo "a change judged under no floor, repeatedly" > docs/readme.md
790git add -A
791git commit --quiet -m "a change whose floor the controller cannot find, under watch"
792attest_change c13 "" "" --check prose-format
793request c13 main "$(git rev-parse c13)"
794
795# Five seconds at a one-second tick: five passes over one request the
796# controller cannot judge.
797timeout 5 integrator watch --interval 1s \
798 --repo "$origin" \
799 --key "$work/integrator" --name "$integrator_name" \
800 --known-signers "$work/known_signers" \
801 --instance-repo "$origin" --instance-policy policy \
802 --schema "$SCHEMA_VERIFICATION" \
803 --attest-schema "$SCHEMA_ATTESTATION" \
804 --event-schema "$SCHEMA_EVENTS" \
805 ${VALLEY_E2E_NOW:+--now "$VALLEY_E2E_NOW"} \
806 > "$work/repeat.out" 2>&1 || true
807reports="$(grep -c 'no instance policy layer' "$work/repeat.out" || true)"
808[ "$reports" -eq 1 ] \
809 || die "the same refusal was reported $reports times over five ticks: $(cat "$work/repeat.out")"
810forget c13
811holds "a failure a pass cannot get past is reported once and then backs off"
812
813# ----------------------------------------------------------------------
814say "15. a target that carries no project layer of its own is judged under the floor alone"
815
816# The bootstrap this guards is the first policy commit: a project that has
817# not written a layer yet cannot land the commit that writes one, because a
818# change never supplies the policy that gates it. The project layer only
819# ever adds (dcr-f41f718), so its absence adds nothing, and what is left is
820# the floor — which still governs, and is observed governing here.
821
822# The floor grows a requirement of its own first, so that what remains after
823# the project layer goes away is something rather than nothing.
824cat > "$floor/policy/instance/floor.cue" <<'EOF'
825package verification
826
827floor: {
828 checks: "prose-format": {runner: "nix", attribute: "prose-format"}
829 classes: prose: {paths: "docs/**": true, requires: "prose-format": true}
830 unclassified: {}
831}
832EOF
833git -C "$floor" commit --quiet -am "the floor requires prose-format of docs/"
834git -C "$floor" push --quiet "$instance_repo" main
835
836# The project stops carrying a layer. Nothing classifies policy/project
837# itself, so this lands with nothing owed — which is how a project could
838# have arrived without one in the first place.
839git checkout --quiet main
840git pull --quiet --ff-only origin main
841git checkout --quiet -b c14
842git rm --quiet -r policy/project
843git commit --quiet -m "stop carrying a project policy layer"
844request c14 main "$(git rev-parse c14)"
845integrate
846grep -q "^c14 -> refs/heads/main .*: land$" "$work/last.out" \
847 || die "dropping the project layer did not land: $(cat "$work/last.out")"
848
849git checkout --quiet main
850git pull --quiet --ff-only origin main
851[ ! -e policy/project ] || die "the project layer is still at the tip; the scenario proves nothing"
852git checkout --quiet -b c15
853echo "a readme judged under the floor alone" > docs/readme.md
854git add -A
855git commit --quiet -m "a change to a project that declares no policy of its own"
856attest_change c15 "" "" --check prose-format
857request c15 main "$(git rev-parse c15)"
858integrate
859grep -q "^c15 -> refs/heads/main .*: land$" "$work/last.out" \
860 || die "a change to a project with no layer of its own did not land: $(cat "$work/last.out")"
861grep -qF "policy no project layer at policy/project; the floor alone" "$work/last.out" \
862 || die "the pass did not say it composed the floor alone"
863grep -q "check prose-format .*transferred" "$work/last.out" \
864 || die "the floor's own requirement did not govern a project with no layer"
865[ "$(tip)" = "$(git rev-parse c15)" ] || die "main is not at the change's head"
866holds "no project layer is no addition; the floor alone required prose-format and the change landed"
867
868# ----------------------------------------------------------------------
869say "16. a floor that requires nothing, written down, composes and judges"
870
871# Emptiness a floor states is not the same thing as a floor nobody wrote.
872# The document is there, somebody landed it, and what it composes to is a
873# policy that requires nothing — so a change under it lands owing nothing,
874# rather than being refused the way scenario 12's missing floor is.
875cat > "$floor/policy/instance/floor.cue" <<'EOF'
876package verification
877
878floor: {
879 checks: {}
880 classes: {}
881 unclassified: {}
882}
883EOF
884git -C "$floor" commit --quiet -am "the floor requires nothing, and says so"
885git -C "$floor" push --quiet "$instance_repo" main
886
887git checkout --quiet main
888git pull --quiet --ff-only origin main
889git checkout --quiet -b c16
890echo "a readme under a floor that requires nothing" > docs/readme.md
891git add -A
892git commit --quiet -m "a change under an empty floor and no project layer"
893request c16 main "$(git rev-parse c16)"
894integrate
895grep -q "^c16 -> refs/heads/main .*: land$" "$work/last.out" \
896 || die "a change under an explicitly empty floor did not land: $(cat "$work/last.out")"
897grep -q 'the policy requires no check of the paths this change touches' "$work/last.out" \
898 || die "the verdict did not say the policy required nothing"
899grep -qF "policy no project layer at policy/project; the floor alone" "$work/last.out" \
900 || die "the pass did not say it composed the floor alone"
901[ "$(tip)" = "$(git rev-parse c16)" ] || die "main is not at the change's head"
902holds "a floor that states it requires nothing composes, judges, and lands the change owing nothing"
903
904# ----------------------------------------------------------------------
905say "17. a planted replacement ref changes nothing the controller reads"
906
907# refs/replace/<id> makes git read another object wherever it looks <id> up.
908# Two are planted here, and each alone would land a change that owes
909# evidence and carries none. One swaps the floor's blob in the instance
910# repository for a floor that requires nothing. The other swaps the change's
911# head in the served repository for a commit that touches no class. Neither
912# moves a ref the controller watches. A controller that left replacement
913# refs on would read both and land the change; this one reads the objects
914# the refs actually name, and holds the change stale.
915cat > "$floor/policy/instance/floor.cue" <<'EOF'
916package verification
917
918floor: {
919 checks: "prose-format": {runner: "nix", attribute: "prose-format"}
920 classes: prose: {paths: "docs/**": true, requires: "prose-format": true}
921 unclassified: {}
922}
923EOF
924git -C "$floor" commit --quiet -am "the floor requires prose-format of docs/ again"
925git -C "$floor" push --quiet "$instance_repo" main
926landed_floor="$(git -C "$instance_repo" rev-parse main:policy/instance/floor.cue)"
927empty_floor="$(git -C "$instance_repo" rev-parse main~1:policy/instance/floor.cue)"
928git -C "$instance_repo" update-ref "refs/replace/$landed_floor" "$empty_floor"
929git -C "$instance_repo" show main:policy/instance/floor.cue | grep 'checks: {}' > /dev/null \
930 || die "the floor's replacement did not take, so this scenario proves nothing"
931
932git checkout --quiet main
933git pull --quiet --ff-only origin main
934git checkout --quiet -b c17-decoy
935echo "a note no class covers" > notes.txt
936git commit --quiet -am "a decoy that touches no class"
937git checkout --quiet main
938git checkout --quiet -b c17
939echo "a readme no evidence covers" > docs/readme.md
940git commit --quiet -am "a change that owes prose-format and carries no evidence"
941git push --quiet origin c17 c17-decoy
942git -C "$origin" update-ref "refs/replace/$(git rev-parse c17)" "$(git rev-parse c17-decoy)"
943git -C "$origin" diff --name-only main c17 | grep -x notes.txt > /dev/null \
944 || die "the head's replacement did not take, so this scenario proves nothing"
945request c17 main "$(git rev-parse c17)"
946
947# The environment asks for replacement refs too, and is not listened to.
948before="$(tip)"
949GIT_CONFIG_PARAMETERS="'core.usereplacerefs'='true'" integrate
950grep -q "^c17 -> refs/heads/main .*: stale$" "$work/last.out" \
951 || die "a planted replacement ref decided the verdict: $(cat "$work/last.out")"
952grep -q "check prose-format" "$work/last.out" \
953 || die "the landed floor's requirement was not what the controller read"
954grep -q 'no attestation for this check accompanies the change' "$work/last.out" \
955 || die "the missing evidence was not reported"
956[ "$(tip)" = "$before" ] || die "main moved under a change that owes evidence"
957git -C "$instance_repo" update-ref -d "refs/replace/$landed_floor"
958git -C "$origin" update-ref -d "refs/replace/$(git rev-parse c17)"
959forget c17
960holds "the floor and the change were read as landed and as pushed, past both replacements"
961
962# ----------------------------------------------------------------------
963say "18. a request resubmitted while its previous head lands stands for the next pass"
964
965# The asker's resubmission is leased against the request it read, and
966# nothing stops it reading the head this pass is about to land. So the
967# request can move between the pass reading it and the pass consuming it.
968# The landing is still the old head's, and the request that moved is a new
969# request: consuming it would drop a change nobody judged.
970git checkout --quiet main
971git pull --quiet --ff-only origin main
972git checkout --quiet -b c18
973echo "a readme asked for once" > docs/readme.md
974git commit --quiet -am "the first ask"
975attest_change c18 "" "" --check prose-format
976request c18 main "$(git rev-parse c18)"
977# main moves under the request, outside anything the check reads. The pass
978# then recomputes the check's closure over the landed tree, and that
979# evaluation is where the resubmission happens.
980git checkout --quiet main
981echo "a note landed in between" > notes.txt
982git commit --quiet -am "a note landed in between"
983git push --quiet origin main
984git checkout --quiet c18
985git checkout --quiet -b c18-again
986echo "a readme asked for again" > docs/readme.md
987git commit --quiet -am "the second ask"
988git push --quiet origin c18-again
989again="$(git rev-parse c18-again)"
990moving="refs/the-valley/integration-requests/main/c18"
991before="$(tip)"
992VALLEY_E2E_DURING_PASS="git -C '$origin' update-ref '$moving' '$again'" integrate
993grep -q "^c18 -> refs/heads/main .*: land$" "$work/last.out" \
994 || die "the first ask did not land: $(cat "$work/last.out")"
995[ "$(tip)" != "$before" ] || die "main did not move for the first ask"
996[ "$(git -C "$origin" rev-parse --verify --quiet "$moving")" = "$again" ] \
997 || die "the resubmitted request 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")"
998grep -q "request $moving moved to .* while .* landed; it stands for the next pass" "$work/last.out" \
999 || die "the moved request was not reported: $(cat "$work/last.out")"
1000forget c18
1001holds "a request that moved while its previous head landed was left standing, and said so"
1002
1003printf '\nintegrator-e2e: every scenario held\n'