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