| 1 | # shellcheck shell=bash |
| 2 | # Paths and fixtures come from the derivation environment. |
| 3 | # shellcheck disable=SC2154 |
| 4 | export HOME="$TMPDIR" |
| 5 | export XDG_STATE_HOME="$TMPDIR/state" |
| 6 | export GIT_CONFIG_NOSYSTEM=1 |
| 7 | # What this check writes down, kept out of the repository under test: an |
| 8 | # answer file or a captured stream sitting in the working tree would be |
| 9 | # committed by the next `git add -A` and change the tree being attested. |
| 10 | w="$TMPDIR/scratch" |
| 11 | mkdir -p "$w" |
| 12 | git config --global user.name valley-check |
| 13 | git config --global user.email valley-check@localhost |
| 14 | git config --global init.defaultBranch main |
| 15 | git config --global advice.detachedHead false |
| 16 | |
| 17 | # The operator's signing key. Provisioning one is deployment, so the verb |
| 18 | # takes it as a parameter and this check supplies a throwaway. |
| 19 | ssh-keygen -q -t ed25519 -N "" -C valley-check -f "$TMPDIR/host" |
| 20 | export VALLEY_ATTEST_KEY="$TMPDIR/host" |
| 21 | export VALLEY_ATTEST_NAME=laddie.valley.invalid/attestations |
| 22 | keyhash="$(attest key --key "$TMPDIR/host" --name "$VALLEY_ATTEST_NAME" | cut -d+ -f2)" |
| 23 | |
| 24 | origin="$TMPDIR/project.git" |
| 25 | git init --quiet --bare "$origin" |
| 26 | |
| 27 | # Every push the bare repo receives, as its hook sees it. The claim [a]sk |
| 28 | # makes is that ONE push carries the evidence and the request together, and |
| 29 | # that claim is only observable from the receiving side. |
| 30 | pushlog="$TMPDIR/pushlog" |
| 31 | cat > "$origin/hooks/pre-receive" <<EOF |
| 32 | #!/bin/sh |
| 33 | echo '--- push' >> $pushlog |
| 34 | cat >> $pushlog |
| 35 | EOF |
| 36 | chmod +x "$origin/hooks/pre-receive" |
| 37 | |
| 38 | # ---------------------------------------------------------------------- |
| 39 | # The owning valley's repository, carrying the floor at policy/instance. |
| 40 | # The floor is read from here and never from the project, which is the |
| 41 | # tree under judgment: what governs a change has to come from outside it. |
| 42 | # Fetching is all the deriver does to this repository, which is what |
| 43 | # anyone the valley governs necessarily holds. |
| 44 | valley="$TMPDIR/valley.git" |
| 45 | git init --quiet --bare "$valley" |
| 46 | valleywork="$TMPDIR/valley-work" |
| 47 | git init --quiet "$valleywork" |
| 48 | mkdir -p "$valleywork/policy/instance" |
| 49 | cat > "$valleywork/policy/instance/floor.cue" <<'EOF' |
| 50 | package verification |
| 51 | |
| 52 | floor: { |
| 53 | checks: "tree-ok": { |
| 54 | runner: "command" |
| 55 | command: "test -f docs/readme.md" |
| 56 | } |
| 57 | classes: prose: { |
| 58 | paths: "docs/**": true |
| 59 | requires: "tree-ok": true |
| 60 | } |
| 61 | // A class that covers paths and asks nothing of them. Owing no check |
| 62 | // is an ordinary outcome, not a hole: the policy has read these paths |
| 63 | // and has nothing to require of them. |
| 64 | classes: quiet: { |
| 65 | paths: "quiet/**": true |
| 66 | requires: {} |
| 67 | } |
| 68 | unclassified: "tree-ok": true |
| 69 | } |
| 70 | EOF |
| 71 | git -C "$valleywork" add -A |
| 72 | git -C "$valleywork" commit --quiet -m floor |
| 73 | git -C "$valleywork" push --quiet "$valley" main |
| 74 | |
| 75 | # ---------------------------------------------------------------------- |
| 76 | # The project, laid out the way the deriver reads one without being told: |
| 77 | # its own layer at policy/project, and its owning valley named at |
| 78 | # policy/valley. Both checks use the command runner: the nix runner cannot |
| 79 | # be exercised from inside a nix build, since the sandbox has no daemon to |
| 80 | # call, and what is under test here is the sequencing rather than the |
| 81 | # runner. |
| 82 | # |
| 83 | # examples/policy/ holds a second, contradictory pair of layers, and every |
| 84 | # check they require is named `phantom`. Nothing may derive it: a gate that |
| 85 | # came from a worked example is a gate nobody wrote, and the name is here |
| 86 | # so that the failure would be visible rather than plausible. |
| 87 | repo="$TMPDIR/project" |
| 88 | git init --quiet "$repo" |
| 89 | cd "$repo" || exit 1 |
| 90 | git remote add origin "$origin" |
| 91 | |
| 92 | mkdir -p docs src schema policy/project examples/policy/instance examples/policy/project |
| 93 | cp "$schemaFile" schema/verification.cue |
| 94 | echo "the readme" > docs/readme.md |
| 95 | echo "$valley" > policy/valley |
| 96 | cat > policy/project/policy.cue <<'EOF' |
| 97 | package verification |
| 98 | |
| 99 | project: { |
| 100 | checks: "no-secrets": { |
| 101 | runner: "command" |
| 102 | command: "! grep -rqF SECRET src" |
| 103 | } |
| 104 | classes: source: { |
| 105 | paths: "src/**": true |
| 106 | requires: "no-secrets": true |
| 107 | } |
| 108 | } |
| 109 | EOF |
| 110 | cat > examples/policy/instance/floor.cue <<'EOF' |
| 111 | package verification |
| 112 | |
| 113 | floor: { |
| 114 | checks: phantom: { |
| 115 | runner: "command" |
| 116 | command: "false" |
| 117 | } |
| 118 | classes: everything: { |
| 119 | paths: "**": true |
| 120 | requires: phantom: true |
| 121 | } |
| 122 | unclassified: phantom: true |
| 123 | } |
| 124 | EOF |
| 125 | cat > examples/policy/project/policy.cue <<'EOF' |
| 126 | package verification |
| 127 | |
| 128 | project: {} |
| 129 | EOF |
| 130 | git add -A |
| 131 | git commit --quiet -m base |
| 132 | git push --quiet -u origin main |
| 133 | first="$(git rev-parse main)" |
| 134 | |
| 135 | # ---------------------------------------------------------------------- |
| 136 | # 1. A branch whose required check passes: the evidence and the request |
| 137 | # reach origin in one push, and main does not move. |
| 138 | git checkout --quiet -b topic/one |
| 139 | echo "a better readme" > docs/readme.md |
| 140 | git commit --quiet -am "improve the readme" |
| 141 | git push --quiet origin topic/one |
| 142 | digest="$(attest digest --rev topic/one | cut -d: -f2)" |
| 143 | |
| 144 | : > "$pushlog" |
| 145 | printf 'a\n' > "$w/answers" |
| 146 | valley review topic/one < "$w/answers" > "$w/ask.out" 2> "$w/ask.err" |
| 147 | |
| 148 | grep -q '^checking topic/one at .*: tree-ok$' "$w/ask.out" |
| 149 | grep -qE '^check tree-ok +command passed$' "$w/ask.out" |
| 150 | grep -qx 'requested topic/one -> refs/heads/main' "$w/ask.out" |
| 151 | grep -qx " request refs/the-valley/integration-requests/main/topic-one -> $(git rev-parse --short topic/one)" "$w/ask.out" |
| 152 | grep -qx " evidence refs/the-valley/attestations/$digest/$keyhash" "$w/ask.out" |
| 153 | grep -qx ' checks tree-ok' "$w/ask.out" |
| 154 | grep -q 'main is untouched' "$w/ask.out" |
| 155 | |
| 156 | # What origin holds now. The attestation is keyed by the digest of the |
| 157 | # BRANCH's tree, which is what says the checks ran over the right tree and |
| 158 | # not over the operator's working copy. |
| 159 | git -C "$origin" for-each-ref --format='%(refname)' refs/the-valley > "$w/published.txt" |
| 160 | grep -qx "refs/the-valley/integration-requests/main/topic-one" "$w/published.txt" |
| 161 | grep -qx "refs/the-valley/attestations/$digest/$keyhash" "$w/published.txt" |
| 162 | if [ "$(git -C "$origin" rev-parse refs/the-valley/integration-requests/main/topic-one)" \ |
| 163 | != "$(git rev-parse topic/one)" ]; then |
| 164 | echo "valley-request: the request ref does not name the branch's head" >&2 |
| 165 | exit 1 |
| 166 | fi |
| 167 | if [ "$(git -C "$origin" rev-parse refs/heads/main)" != "$first" ]; then |
| 168 | echo "valley-request: [a]sk moved main" >&2 |
| 169 | exit 1 |
| 170 | fi |
| 171 | |
| 172 | # One push carried both. This is the friction the verb exists to remove: |
| 173 | # `attest run --push` publishes the branch and the evidence and knows |
| 174 | # nothing about a request ref, so doing this by hand is two beats. |
| 175 | pushes="$(grep -c '^--- push' "$pushlog" || true)" |
| 176 | if [ "$pushes" != 1 ]; then |
| 177 | echo "valley-request: the evidence and the request took $pushes pushes, not 1" >&2 |
| 178 | cat "$pushlog" >&2 |
| 179 | exit 1 |
| 180 | fi |
| 181 | grep -q "refs/the-valley/attestations/$digest/$keyhash" "$pushlog" |
| 182 | grep -q 'refs/the-valley/integration-requests/main/topic-one' "$pushlog" |
| 183 | |
| 184 | # The note origin holds is the one the operator signed, over that tree. |
| 185 | git cat-file -p "refs/the-valley/attestations/$digest/$keyhash:tree-ok/statement.note" \ |
| 186 | > "$w/statement.note" |
| 187 | attest key --key "$TMPDIR/host" --name "$VALLEY_ATTEST_NAME" > "$w/known_keys" |
| 188 | attest verify --note "$w/statement.note" --repo "$repo" --rev topic/one \ |
| 189 | --known-keys "$w/known_keys" --signer "$VALLEY_ATTEST_NAME" > "$w/verify.out" |
| 190 | grep -q 'matches the recorded subject digest' "$w/verify.out" |
| 191 | |
| 192 | # ---------------------------------------------------------------------- |
| 193 | # 2. The layers the derivation used are the ones that govern, and it says |
| 194 | # which they were: the floor fetched from the owning valley, and the |
| 195 | # project's own layer at policy/project in the TARGET's tip. |
| 196 | # examples/policy/ is in this tree and requires `phantom` of every path, |
| 197 | # and no default reaches it — it is derivable only by naming it, which |
| 198 | # is what the options are for. |
| 199 | valley checks "$first" topic/one > "$w/checks.out" 2> "$w/checks.err" |
| 200 | grep -qx "policy: $valley policy/instance@refs/heads/main + policy/project@origin/main $(git rev-parse --short origin/main)" "$w/checks.out" |
| 201 | grep -qx 'classes matched: prose' "$w/checks.out" |
| 202 | grep -qE '^ tree-ok +mandatory +prose$' "$w/checks.out" |
| 203 | if grep -q phantom "$w/checks.out" "$w/checks.err"; then |
| 204 | echo "valley-request: a default derived a check from examples/policy/" >&2 |
| 205 | cat "$w/checks.out" "$w/checks.err" >&2 |
| 206 | exit 1 |
| 207 | fi |
| 208 | |
| 209 | # Named, the example layers derive exactly what they declare. This is the |
| 210 | # other half of the claim above: examples/policy/ is readable, and reading |
| 211 | # it is something a person asks for. |
| 212 | valley checks --instance examples/policy/instance --project examples/policy/project \ |
| 213 | "$first" topic/one > "$w/example.out" |
| 214 | grep -qE '^ phantom +mandatory' "$w/example.out" |
| 215 | grep -qx 'policy: examples/policy/instance + examples/policy/project' "$w/example.out" |
| 216 | |
| 217 | # ---------------------------------------------------------------------- |
| 218 | # 3. main moves on, so the next branch is stale. [a]sk is offered there |
| 219 | # too — the integrator applies a delta to the tip rather than |
| 220 | # fast-forwarding — and a branch whose check fails publishes nothing |
| 221 | # and leaves the review loop usable. |
| 222 | git checkout --quiet main |
| 223 | echo "a note" > docs/notes.md |
| 224 | git add -A |
| 225 | git commit --quiet -m "a landing that moves main" |
| 226 | git push --quiet origin main |
| 227 | moved="$(git rev-parse main)" |
| 228 | |
| 229 | git checkout --quiet -b topic/two "$first" |
| 230 | printf 'SECRET\n' > src/leak.txt |
| 231 | git add -A |
| 232 | git commit --quiet -m "a leak" |
| 233 | git push --quiet origin topic/two |
| 234 | |
| 235 | : > "$pushlog" |
| 236 | printf 'a\ns\n' > "$w/answers" |
| 237 | valley review topic/two < "$w/answers" > "$w/fail.out" 2> "$w/fail.err" |
| 238 | |
| 239 | # The prompt is the whole of what the operator is offered, so it is pinned |
| 240 | # character for character: a verb that stops being offered, or one that |
| 241 | # starts, is a change to the review loop and not an incidental one. |
| 242 | grep -qF 'topic/two does not fast-forward from main: [a]sk, [b]ase onto main, [r]eject, [s]kip? ' "$w/fail.out" |
| 243 | grep -q '^checking topic/two at .*: no-secrets$' "$w/fail.out" |
| 244 | grep -qE '^check no-secrets +command failed$' "$w/fail.out" |
| 245 | grep -q 'the checks did not pass; nothing published, main untouched' "$w/fail.err" |
| 246 | # The prompt is printed without a newline, so what follows a refusal shares |
| 247 | # its line — the answer to it is not anchored. |
| 248 | grep -q 'skipped topic/two; nothing done' "$w/fail.out" |
| 249 | if [ -s "$pushlog" ]; then |
| 250 | echo "valley-request: a failing check pushed something" >&2 |
| 251 | cat "$pushlog" >&2 |
| 252 | exit 1 |
| 253 | fi |
| 254 | git -C "$origin" for-each-ref --format='%(refname)' refs/the-valley > "$w/after.txt" |
| 255 | if grep -q 'topic-two' "$w/after.txt"; then |
| 256 | echo "valley-request: a failing check left a ref on origin" >&2 |
| 257 | cat "$w/after.txt" >&2 |
| 258 | exit 1 |
| 259 | fi |
| 260 | |
| 261 | # ---------------------------------------------------------------------- |
| 262 | # 4. No signing key, with a check owed: refused before any check is run, |
| 263 | # and the prompt still comes back. The host signs, and there is no |
| 264 | # unsigned mode. |
| 265 | : > "$pushlog" |
| 266 | printf 'a\ns\n' > "$w/answers" |
| 267 | env -u VALLEY_ATTEST_KEY valley review topic/two < "$w/answers" > "$w/nokey.out" 2> "$w/nokey.err" |
| 268 | grep -q 'no signing key: set VALLEY_ATTEST_KEY' "$w/nokey.err" |
| 269 | grep -q 'skipped topic/two; nothing done' "$w/nokey.out" |
| 270 | if [ -s "$pushlog" ]; then |
| 271 | echo "valley-request: a run with no signing key pushed something" >&2 |
| 272 | exit 1 |
| 273 | fi |
| 274 | |
| 275 | # ---------------------------------------------------------------------- |
| 276 | # 5. A branch the policy requires no check of is filed as a request with |
| 277 | # no evidence. The integrator lands one and records it as a landing |
| 278 | # that required nothing, so refusing to file it here would strand |
| 279 | # exactly the changes a policy leaves unrequired. Nothing is owed, so |
| 280 | # nothing is signed: this runs with no signing key at all. |
| 281 | git checkout --quiet main |
| 282 | git checkout --quiet -b topic/quiet |
| 283 | mkdir -p quiet |
| 284 | echo "a quiet note" > quiet/note.md |
| 285 | git add -A |
| 286 | git commit --quiet -m "a change under a class that asks nothing" |
| 287 | git push --quiet origin topic/quiet |
| 288 | quiethead="$(git rev-parse --short topic/quiet)" |
| 289 | |
| 290 | : > "$pushlog" |
| 291 | printf 'a\n' > "$w/answers" |
| 292 | env -u VALLEY_ATTEST_KEY valley review topic/quiet < "$w/answers" \ |
| 293 | > "$w/quiet.out" 2> "$w/quiet.err" |
| 294 | |
| 295 | grep -q 'owes no check under .* + policy/project@origin/main .*; filing the request with no evidence' "$w/quiet.out" |
| 296 | grep -qF "$valley policy/instance@refs/heads/main" "$w/quiet.out" |
| 297 | grep -qx 'requested topic/quiet -> refs/heads/main' "$w/quiet.out" |
| 298 | grep -qx " request refs/the-valley/integration-requests/main/topic-quiet -> $quiethead" "$w/quiet.out" |
| 299 | grep -qx ' evidence none — nothing was owed, so nothing was signed' "$w/quiet.out" |
| 300 | grep -qx ' checks none — the policy requires no check of this change' "$w/quiet.out" |
| 301 | |
| 302 | # One push, carrying the request and nothing else. |
| 303 | pushes="$(grep -c '^--- push' "$pushlog" || true)" |
| 304 | if [ "$pushes" != 1 ]; then |
| 305 | echo "valley-request: the bare request took $pushes pushes, not 1" >&2 |
| 306 | cat "$pushlog" >&2 |
| 307 | exit 1 |
| 308 | fi |
| 309 | if grep -q 'refs/the-valley/attestations/' "$pushlog"; then |
| 310 | echo "valley-request: a request owing nothing published evidence" >&2 |
| 311 | cat "$pushlog" >&2 |
| 312 | exit 1 |
| 313 | fi |
| 314 | if [ "$(git -C "$origin" rev-parse refs/the-valley/integration-requests/main/topic-quiet)" \ |
| 315 | != "$(git rev-parse topic/quiet)" ]; then |
| 316 | echo "valley-request: the bare request does not name the branch's head" >&2 |
| 317 | exit 1 |
| 318 | fi |
| 319 | |
| 320 | # ---------------------------------------------------------------------- |
| 321 | # 6. [i]ntegrate is untouched: both paths coexist until the writers change |
| 322 | # lands, and neither verb knows which one the operator may use. |
| 323 | git checkout --quiet main |
| 324 | git checkout --quiet -b topic/three |
| 325 | echo "another readme" > docs/readme.md |
| 326 | git commit --quiet -am "another readme" |
| 327 | git push --quiet origin topic/three |
| 328 | |
| 329 | printf 'i\n' > "$w/answers" |
| 330 | valley review topic/three < "$w/answers" > "$w/integrate.out" 2>&1 |
| 331 | grep -qF 'topic/three: [a]sk, [i]ntegrate, [r]eject, [s]kip? ' "$w/integrate.out" |
| 332 | grep -q 'integrated topic/three: main is now' "$w/integrate.out" |
| 333 | if [ "$(git -C "$origin" rev-parse refs/heads/main)" = "$moved" ]; then |
| 334 | echo "valley-request: [i]ntegrate did not move main" >&2 |
| 335 | exit 1 |
| 336 | fi |
| 337 | |
| 338 | # The request filed in 1 is still pending: nothing here consumes it, which |
| 339 | # is the integrator's own step. |
| 340 | git -C "$origin" rev-parse --verify --quiet \ |
| 341 | refs/the-valley/integration-requests/main/topic-one > /dev/null |
| 342 | |
| 343 | # ---------------------------------------------------------------------- |
| 344 | # 7. A change does not supply the policy that gates it. This branch |
| 345 | # deletes its own policy/project and repoints policy/valley at a |
| 346 | # repository that does not exist. Both layers come from the target's |
| 347 | # tip, so neither edit reaches the derivation: it composes the same two |
| 348 | # layers it would for any other branch, and the fetch that a branch-read |
| 349 | # pointer would have attempted never happens. |
| 350 | git checkout --quiet -b topic/nolayer |
| 351 | git rm --quiet -r policy/project |
| 352 | echo "$TMPDIR/there-is-no-such-valley.git" > policy/valley |
| 353 | git add -A |
| 354 | git commit --quiet -m "delete the project layer and repoint the valley" |
| 355 | git push --quiet origin topic/nolayer |
| 356 | |
| 357 | valley checks "$first" topic/nolayer > "$w/nolayer.out" 2> "$w/nolayer.err" |
| 358 | grep -qx "policy: $valley policy/instance@refs/heads/main + policy/project@origin/main $(git rev-parse --short origin/main)" "$w/nolayer.out" |
| 359 | if grep -q 'there-is-no-such-valley' "$w/nolayer.out" "$w/nolayer.err"; then |
| 360 | echo "valley-request: the deriver followed the branch's own valley pointer" >&2 |
| 361 | cat "$w/nolayer.out" "$w/nolayer.err" >&2 |
| 362 | exit 1 |
| 363 | fi |
| 364 | |
| 365 | : > "$pushlog" |
| 366 | printf 'a\n' > "$w/answers" |
| 367 | valley review topic/nolayer < "$w/answers" \ |
| 368 | > "$w/nolayer.review.out" 2> "$w/nolayer.review.err" |
| 369 | grep -qx 'requested topic/nolayer -> refs/heads/main' "$w/nolayer.review.out" |
| 370 | |
| 371 | # ---------------------------------------------------------------------- |
| 372 | # 8. The reviewer's checkout contributes nothing. This is the case that |
| 373 | # failed in live use: the operator's checkout was an older branch |
| 374 | # without the landed policy layer, and the deriver read the working |
| 375 | # tree and refused. topic/nolayer is exactly such a checkout — no |
| 376 | # policy/project in it, and a policy/valley naming nowhere — so every |
| 377 | # derivation below runs from it. |
| 378 | # |
| 379 | # Byte-identical output is the claim, not merely a successful one: |
| 380 | # review works the same from any branch, however stale. |
| 381 | git checkout --quiet main |
| 382 | valley checks "$first" topic/one > "$w/from-main.out" |
| 383 | git checkout --quiet topic/nolayer |
| 384 | valley checks "$first" topic/one > "$w/from-stale.out" |
| 385 | if ! cmp -s "$w/from-main.out" "$w/from-stale.out"; then |
| 386 | echo "valley-request: the checkout changed what the derivation said" >&2 |
| 387 | diff -u "$w/from-main.out" "$w/from-stale.out" >&2 || true |
| 388 | exit 1 |
| 389 | fi |
| 390 | |
| 391 | # And [a]sk, which is where it failed: a request filed from that same |
| 392 | # checkout, over a branch the stale tree knows nothing about. |
| 393 | git checkout --quiet -b topic/four origin/main |
| 394 | echo "one more readme" > docs/readme.md |
| 395 | git commit --quiet -am "one more readme" |
| 396 | git push --quiet origin topic/four |
| 397 | git checkout --quiet topic/nolayer |
| 398 | |
| 399 | : > "$pushlog" |
| 400 | printf 'a\n' > "$w/answers" |
| 401 | valley review topic/four < "$w/answers" > "$w/stale.out" 2> "$w/stale.err" |
| 402 | grep -q '^checking topic/four at .*: tree-ok$' "$w/stale.out" |
| 403 | grep -qx 'requested topic/four -> refs/heads/main' "$w/stale.out" |
| 404 | grep -qx ' checks tree-ok' "$w/stale.out" |
| 405 | |
| 406 | # ---------------------------------------------------------------------- |
| 407 | # 9. A target carrying no project layer at all is derived under the floor |
| 408 | # alone, and says so. The project layer only ever adds, so the identity |
| 409 | # of "adds" is "adds nothing"; refusing instead would make a repository |
| 410 | # underivable until its first policy commit, and that commit could not |
| 411 | # derive either. This is the integrator's own reading of an absent |
| 412 | # layer (integrator/policy.go), and the two have to agree. |
| 413 | bare2="$TMPDIR/floorless.git" |
| 414 | git init --quiet --bare "$bare2" |
| 415 | repo2="$TMPDIR/floorless" |
| 416 | git init --quiet "$repo2" |
| 417 | cd "$repo2" || exit 1 |
| 418 | git remote add origin "$bare2" |
| 419 | mkdir -p docs schema policy |
| 420 | cp "$schemaFile" schema/verification.cue |
| 421 | echo "the readme" > docs/readme.md |
| 422 | echo "$valley" > policy/valley |
| 423 | git add -A |
| 424 | git commit --quiet -m base |
| 425 | git push --quiet -u origin main |
| 426 | base2="$(git rev-parse main)" |
| 427 | echo "a second readme" > docs/readme.md |
| 428 | git commit --quiet -am "a second readme" |
| 429 | |
| 430 | valley checks "$base2" HEAD > "$w/floorless.out" 2> "$w/floorless.err" |
| 431 | grep -qx "policy: $valley policy/instance@refs/heads/main + no policy/project@origin/main $(git rev-parse --short origin/main) — the floor alone" "$w/floorless.out" |
| 432 | grep -qE '^ tree-ok +mandatory +prose$' "$w/floorless.out" |
| 433 | if grep -q no-secrets "$w/floorless.out"; then |
| 434 | echo "valley-request: the floor-alone derivation saw another project's layer" >&2 |
| 435 | exit 1 |
| 436 | fi |
| 437 | cd "$repo" || exit 1 |
| 438 | git checkout --quiet main |
| 439 | |
| 440 | # No throwaway worktree outlived any of it: only the checkout is left. |
| 441 | worktrees="$(git worktree list --porcelain | grep -c '^worktree ' || true)" |
| 442 | if [ "$worktrees" != 1 ]; then |
| 443 | echo "valley-request: a throwaway worktree was left behind" >&2 |
| 444 | git worktree list >&2 |
| 445 | exit 1 |
| 446 | fi |
| 447 | |
| 448 | echo "every scenario held" |
| 449 | { |
| 450 | cat "$w/ask.out" |
| 451 | printf '\n--- the scratch origin, after all of it ---\n' |
| 452 | git -C "$origin" for-each-ref --format='%(objectname) %(refname)' |
| 453 | } > "$out" |