| 1 | # shellcheck shell=bash |
| 2 | # valley changes and valley pending, end to end and unmocked, over the |
| 3 | # repositories one test host serves. The host is made by the integrator |
| 4 | # host's rendered valley-init, relocated as init-e2e relocates it, so the |
| 5 | # project list discovery reads is the one a host publishes, and every |
| 6 | # record is pushed through the hook that host installs. What the |
| 7 | # integrator writes on disk when it lands a change — main, the outcome |
| 8 | # record, the transfer statement — is written here the same way, with a |
| 9 | # key generated for the run. |
| 10 | # Paths and fixtures come from the derivation environment. |
| 11 | # shellcheck disable=SC2154 |
| 12 | set -euo pipefail |
| 13 | |
| 14 | w="$TMPDIR/valley-changes" |
| 15 | mkdir -p "$w" |
| 16 | export HOME="$w" |
| 17 | export XDG_CACHE_HOME="$w/cache" |
| 18 | export GIT_CONFIG_NOSYSTEM=1 |
| 19 | git config --global user.name valley-changes-check |
| 20 | git config --global user.email valley-changes-check@localhost |
| 21 | git config --global init.defaultBranch main |
| 22 | git config --global advice.detachedHead false |
| 23 | unset VALLEY_KNOWN_SIGNERS VALLEY_INTEGRATOR_SIGNER |
| 24 | |
| 25 | fail() { |
| 26 | printf 'valley-changes: %s\n' "$*" >&2 |
| 27 | for f in "$w"/out "$w"/err; do |
| 28 | if [ -s "$f" ]; then cat "$f" >&2; fi |
| 29 | done |
| 30 | exit 1 |
| 31 | } |
| 32 | |
| 33 | # ok <command…>: the command succeeds, and its output is kept. |
| 34 | ok() { |
| 35 | "$@" > "$w/out" 2> "$w/err" || fail "$* failed" |
| 36 | } |
| 37 | |
| 38 | # holds <jq condition…>: the last JSON printed holds each. |
| 39 | holds() { |
| 40 | local cond |
| 41 | for cond in "$@"; do |
| 42 | jq -e "$cond" "$w/out" > /dev/null || fail "$cond does not hold" |
| 43 | done |
| 44 | } |
| 45 | |
| 46 | # line <ERE>: the last output has a line matching it. |
| 47 | line() { |
| 48 | grep -qE -- "$1" "$w/out" || fail "no line matches $1" |
| 49 | } |
| 50 | |
| 51 | no_line() { |
| 52 | if grep -qE -- "$1" "$w/out"; then fail "a line matches $1"; fi |
| 53 | } |
| 54 | |
| 55 | # after <ERE> <ERE…>: the first line of the last output that matches the |
| 56 | # first is followed, line by line, by lines matching the rest. |
| 57 | after() { |
| 58 | local n re |
| 59 | n="$(grep -nE -m 1 -- "$1" "$w/out" | cut -d: -f1 || true)" |
| 60 | [ -n "$n" ] || fail "no line matches $1" |
| 61 | for re in "${@:2}"; do |
| 62 | n=$((n + 1)) |
| 63 | sed -n "${n}p" "$w/out" | grep -qE -- "$re" || fail "line $n, after $1, does not match $re" |
| 64 | done |
| 65 | } |
| 66 | |
| 67 | # The host: guarded, open, released and sealed, with sealed the instance |
| 68 | # repository. valley-init creates them, wires their hooks, and publishes |
| 69 | # the project list in sealed. |
| 70 | data="$w/srv/git" |
| 71 | mkdir -p "$data" |
| 72 | sed "s|/srv/git|$data|g" "$initScriptPath" > "$w/init.sh" |
| 73 | bash "$w/init.sh" 2> "$w/init.err" || fail "valley-init failed: $(cat "$w/init.err")" |
| 74 | instance="$data/sealed.git" |
| 75 | # The integrator's repositories are group-shared, and git then sets the |
| 76 | # setgid bit on every directory it makes, which this sandbox refuses. The |
| 77 | # setting is dropped so the pushes below can write objects; it decides |
| 78 | # nothing this check reads. |
| 79 | for name in guarded open released sealed; do |
| 80 | git -C "$data/$name.git" config --unset core.sharedRepository || true |
| 81 | done |
| 82 | [ "$(git -C "$instance" cat-file blob refs/the-valley/projects)" = "$(printf '%s\n' guarded open released sealed)" ] || |
| 83 | fail "valley-init published another project list" |
| 84 | |
| 85 | # A change's ID, by the letter it repeats. Each is 32 letters from k to z. |
| 86 | id() { printf '%s%s' "$1" "$(printf 'k%.0s' $(seq $((32 - ${#1}))))"; } |
| 87 | A="$(id nxvpwlkm)" B="$(id mmmm)" C="$(id pppp)" D="$(id qqqq)" E="$(id rrrr)" |
| 88 | W="$(id ssss)" F="$(id tttt)" G="$(id uuuu)" U="$(id vvvv)" H="$(id wwww)" |
| 89 | K="$(id kkkk)" X="$(id oooo)" I="$(id zzzz)" J="$(id lmlm)" X2="$(id pqpq)" |
| 90 | R="$(id nxvpwlkz)" D2="$(id xxxx)" E2="$(id yyyy)" |
| 91 | |
| 92 | # A checkout of a project, whose main names sealed as its owning valley. |
| 93 | # Every push carries the principal, as the key sshd authenticated would. |
| 94 | export VALLEY_PRINCIPAL=alice |
| 95 | checkout() { |
| 96 | local name="$1" dir="$w/$1" |
| 97 | git clone --quiet "$data/$name.git" "$dir" 2> /dev/null |
| 98 | git -C "$dir" config valley.principal alice |
| 99 | mkdir -p "$dir/policy" |
| 100 | printf '# the owning valley\n%s\n' "$instance" > "$dir/policy/valley" |
| 101 | git -C "$dir" add policy/valley |
| 102 | git -C "$dir" commit --quiet -m base |
| 103 | VALLEY_PRINCIPAL=integrator git -C "$dir" push --quiet origin main |
| 104 | } |
| 105 | |
| 106 | # branch <name> <from> <subject…>: a branch from a commit, with a commit |
| 107 | # per subject, each adding a file of its own, pushed to origin. |
| 108 | branch() { |
| 109 | local name="$1" from="$2" s |
| 110 | shift 2 |
| 111 | git checkout --quiet -b "$name" "$from" |
| 112 | for s in "$@"; do |
| 113 | echo "$s" > "$s.txt" |
| 114 | git add "$s.txt" |
| 115 | git commit --quiet -m "$s" |
| 116 | done |
| 117 | git push --quiet origin "$name" |
| 118 | } |
| 119 | |
| 120 | # ready <id> <branch>: the branch's head readied as the change. |
| 121 | ready() { |
| 122 | ok valley ready --change "$1" "$2" |
| 123 | } |
| 124 | |
| 125 | # ---------------------------------------------------------------------- |
| 126 | # open: a stack of three, a draft, a withdrawn change with a ready change |
| 127 | # on top of it, a change landed by fast-forward, one landed as a new |
| 128 | # commit with its transfer statement, one whose request was consumed with |
| 129 | # no evidence stored, one whose transfer statement another key signed, |
| 130 | # and a branch no record is on. |
| 131 | checkout open |
| 132 | cd "$w/open" |
| 133 | base="$(git rev-parse HEAD)" |
| 134 | branch stack-a "$base" stack-a |
| 135 | ready "$A" stack-a |
| 136 | branch stack-b stack-a stack-b |
| 137 | ready "$B" stack-b |
| 138 | branch stack-c stack-b stack-c |
| 139 | ready "$C" stack-c |
| 140 | branch paused "$base" paused |
| 141 | ready "$D" paused |
| 142 | ok valley unready "$D" |
| 143 | branch gone "$base" gone |
| 144 | ready "$E" gone |
| 145 | ok valley withdraw "$E" |
| 146 | branch atop-gone gone atop-gone |
| 147 | ready "$W" atop-gone |
| 148 | branch ff "$base" ff |
| 149 | ready "$F" ff |
| 150 | branch reparent "$base" reparent |
| 151 | ready "$G" reparent |
| 152 | branch lost "$base" lost |
| 153 | ready "$U" lost |
| 154 | branch forged "$base" forged |
| 155 | ready "$H" forged |
| 156 | branch loose "$base" loose |
| 157 | |
| 158 | # Before anything lands, ff names its change. |
| 159 | ok valley resolve ff |
| 160 | line "^change"$'\t'"$F"$'\t' |
| 161 | |
| 162 | # The integrator's keys: the integrator's own, and another a known |
| 163 | # signer holds, which may sign evidence and not a landing. |
| 164 | ssh-keygen -q -t ed25519 -N '' -C integrator -f "$w/integrator.key" |
| 165 | ssh-keygen -q -t ed25519 -N '' -C mallory -f "$w/mallory.key" |
| 166 | { |
| 167 | attest key --key "$w/integrator.key" --name integrator |
| 168 | attest key --key "$w/mallory.key" --name mallory |
| 169 | } > "$w/known-signers" |
| 170 | |
| 171 | # F lands by fast-forward. |
| 172 | VALLEY_PRINCIPAL=integrator git push --quiet origin ff:main |
| 173 | fhead="$(git rev-parse ff)" |
| 174 | |
| 175 | # G lands as a new commit on main, and the integrator records it: main |
| 176 | # moves, the outcome record says land, the request is consumed, and the |
| 177 | # transfer statement is stored under the landed tree. |
| 178 | git checkout --quiet -b landing ff |
| 179 | git cherry-pick reparent > /dev/null |
| 180 | landed="$(git rev-parse HEAD)" |
| 181 | VALLEY_PRINCIPAL=integrator git push --quiet origin landing:main |
| 182 | tree_digest() { attest digest --repo "$w/open" --rev "$1" | cut -d: -f2; } |
| 183 | |
| 184 | # memo <name> <head> <decision…>: the integrator's outcome record. |
| 185 | memo() { |
| 186 | local name="$1" head="$2" blob |
| 187 | shift 2 |
| 188 | blob="$(printf '%s %s %s %s\n' "$head" "$fhead" 0123456789abcdef "$*" | git -C "$data/open.git" hash-object -w --stdin)" |
| 189 | git -C "$data/open.git" update-ref "refs/the-valley/integration-outcomes/main/$name" "$blob" |
| 190 | } |
| 191 | |
| 192 | # transfer <change> <head> <landed> <key> <name> [single]: a transfer |
| 193 | # statement, as the integrator composes, signs and stores one under the |
| 194 | # landed tree and its signer's key hash, at |
| 195 | # transfer.d/<2 hex>/<2 hex>/<rest>.note, split from the landed commit's |
| 196 | # ID. With single, it is stored as the one transfer.note at the top of the |
| 197 | # tree, the layout of a ref the integrator wrote before it kept one |
| 198 | # statement per landed commit, which the reader still reads. |
| 199 | transfer() { |
| 200 | local change="$1" head="$2" at="$3" key="$4" name="$5" layout="${6:-}" ldigest blob tree |
| 201 | ldigest="$(tree_digest "$at")" |
| 202 | jq -n --arg change "$change" --arg base "$(tree_digest "$head")" --arg landed "$ldigest" \ |
| 203 | --arg commit "$at" --arg tip "$fhead" '{ |
| 204 | statementType: "the-valley/attestation/v1", |
| 205 | subject: {primary: "valley-tree-v1", digest: {"valley-tree-v1": $landed, "git-sha1": $commit}}, |
| 206 | predicateType: "the-valley/integration/transfer/v1", |
| 207 | predicate: {change: $change, target: "refs/heads/main", base: {"valley-tree-v1": $base}, |
| 208 | policy: {sha256: ("ab" * 32), "git-sha1": $tip}, required: "none"} |
| 209 | }' > "$w/statement.json" |
| 210 | attest render "$w/statement.json" | attest sign --key "$key" --name "$name" > "$w/transfer.note" |
| 211 | blob="$(git -C "$data/open.git" hash-object -w "$w/transfer.note")" |
| 212 | if [ "$layout" = single ]; then |
| 213 | tree="$(printf '100644 blob %s\ttransfer.note\n' "$blob" | git -C "$data/open.git" mktree)" |
| 214 | else |
| 215 | tree="$(printf '100644 blob %s\t%s.note\n' "$blob" "${at:4}" | git -C "$data/open.git" mktree)" |
| 216 | tree="$(printf '040000 tree %s\t%s\n' "$tree" "${at:2:2}" | git -C "$data/open.git" mktree)" |
| 217 | tree="$(printf '040000 tree %s\t%s\n' "$tree" "${at:0:2}" | git -C "$data/open.git" mktree)" |
| 218 | tree="$(printf '040000 tree %s\ttransfer.d\n' "$tree" | git -C "$data/open.git" mktree)" |
| 219 | fi |
| 220 | git -C "$data/open.git" update-ref "refs/the-valley/attestations/$ldigest/$(attest key --key "$key" --name "$name" | cut -d+ -f2)" "$tree" |
| 221 | } |
| 222 | memo reparent "$(git rev-parse reparent)" land |
| 223 | transfer reparent "$(git rev-parse reparent)" "$landed" "$w/integrator.key" integrator single |
| 224 | |
| 225 | # U's request was consumed, and no evidence was stored. |
| 226 | memo lost "$(git rev-parse lost)" land |
| 227 | # H's request was consumed too, and its transfer statement is signed by a |
| 228 | # known key that is not the integrator's: it is no record of a landing. |
| 229 | memo forged "$(git rev-parse forged)" land |
| 230 | git checkout --quiet -b landing-h landing |
| 231 | git cherry-pick forged > /dev/null |
| 232 | VALLEY_PRINCIPAL=integrator git push --quiet origin landing-h:main |
| 233 | transfer forged "$(git rev-parse forged)" "$(git rev-parse HEAD)" "$w/mallory.key" mallory |
| 234 | # A's request is pending. |
| 235 | git -C "$data/open.git" update-ref refs/the-valley/integration-requests/main/stack-a "$(git rev-parse stack-a)" |
| 236 | |
| 237 | # I lands as a new commit, L2, filed as c-<I>, and the integrator records |
| 238 | # it. Then I's next version, H', has H's tree with L2 as its parent. Its |
| 239 | # name and its tree digest match the transfer statement, but it is another |
| 240 | # delta: merged onto L2's parent it does not give L2's tree. I is then made |
| 241 | # a draft. |
| 242 | branch again "$base" again |
| 243 | ready "$I" again |
| 244 | hhead="$(git rev-parse again)" |
| 245 | git checkout --quiet -b landing-i landing-h |
| 246 | git cherry-pick again > /dev/null |
| 247 | landed2="$(git rev-parse HEAD)" |
| 248 | VALLEY_PRINCIPAL=integrator git push --quiet origin landing-i:main |
| 249 | memo "c-$I" "$hhead" land |
| 250 | transfer "c-$I" "$hhead" "$landed2" "$w/integrator.key" integrator |
| 251 | hprime="$(git commit-tree "again^{tree}" -p "$landed2" -m again)" |
| 252 | git push --quiet --force origin "$hprime:refs/heads/again" |
| 253 | ready "$I" again |
| 254 | ok valley unready "$I" |
| 255 | |
| 256 | # J lands by fast-forward, and the integrator records it: its outcome |
| 257 | # record says land at J's head, and its transfer statement is about J's |
| 258 | # tree. Then main moves on to Q, which adds a file, and J's next version, |
| 259 | # J', has J's tree with Q as its parent: it deletes Q's file. J' matches |
| 260 | # the statement's name and tree, and merged onto the parent of the commit |
| 261 | # that landed it gives that commit's tree. But the outcome record names |
| 262 | # J's head, not J', so J' has not landed. J is then made a draft. |
| 263 | branch ffrec landing-i ffrec |
| 264 | ready "$J" ffrec |
| 265 | jhead="$(git rev-parse ffrec)" |
| 266 | VALLEY_PRINCIPAL=integrator git push --quiet origin ffrec:main |
| 267 | memo ffrec "$jhead" land |
| 268 | transfer ffrec "$jhead" "$jhead" "$w/integrator.key" integrator |
| 269 | git checkout --quiet -b moved-on ffrec |
| 270 | echo q > q.txt |
| 271 | git add q.txt |
| 272 | git commit --quiet -m q |
| 273 | VALLEY_PRINCIPAL=integrator git push --quiet origin moved-on:main |
| 274 | jprime="$(git commit-tree "ffrec^{tree}" -p moved-on -m ffrec)" |
| 275 | git push --quiet --force origin "$jprime:refs/heads/ffrec" |
| 276 | ready "$J" ffrec |
| 277 | ok valley unready "$J" |
| 278 | |
| 279 | # K is built on main after F, whose active version landed by ancestry |
| 280 | # while its record is still ready. K's branch starts at main's tip, so F's |
| 281 | # head is below it, and F has landed: K includes nothing. |
| 282 | branch after-landing moved-on after-landing |
| 283 | ready "$K" after-landing |
| 284 | # K's request is pending, so pending lists K as approved, apart from the |
| 285 | # ready changes that wait on an approval. |
| 286 | git -C "$data/open.git" update-ref refs/the-valley/integration-requests/main/after-landing "$(git rev-parse after-landing)" |
| 287 | |
| 288 | # ---------------------------------------------------------------------- |
| 289 | # guarded: a ready change whose ID shares seven letters with A's, a draft |
| 290 | # and a withdrawn change. |
| 291 | checkout guarded |
| 292 | cd "$w/guarded" |
| 293 | gbase="$(git rev-parse HEAD)" |
| 294 | branch g-ready "$gbase" g-ready |
| 295 | ready "$R" g-ready |
| 296 | branch g-draft "$gbase" g-draft |
| 297 | ready "$D2" g-draft |
| 298 | ok valley unready "$D2" |
| 299 | branch g-gone "$gbase" g-gone |
| 300 | ready "$E2" g-gone |
| 301 | ok valley withdraw "$E2" |
| 302 | # B's change ID, recorded here too. |
| 303 | branch g-dup "$gbase" g-dup |
| 304 | ready "$B" g-dup |
| 305 | |
| 306 | # A merge on main can drop the content of either parent, so no head below |
| 307 | # one has landed by ancestry. X is ready, and a merge of it whose tree |
| 308 | # drops its changes lands on main by fast-forward: M = (main, X), with |
| 309 | # main's tree. Then X2, branched from that main, is dropped by a merge with |
| 310 | # its parents reversed: M2 = (X2, main), with main's tree. X2 is on main's |
| 311 | # first-parent history, below the merge that dropped it. |
| 312 | branch dropped "$gbase" dropped |
| 313 | ready "$X" dropped |
| 314 | merge="$(git commit-tree "$gbase^{tree}" -p "$gbase" -p dropped -m 'merge, dropping X')" |
| 315 | VALLEY_PRINCIPAL=integrator git push --quiet origin "$merge:refs/heads/main" |
| 316 | branch reversed "$merge" reversed |
| 317 | ready "$X2" reversed |
| 318 | merge2="$(git commit-tree "$merge^{tree}" -p reversed -p "$merge" -m 'merge, dropping X2')" |
| 319 | VALLEY_PRINCIPAL=integrator git push --quiet origin "$merge2:refs/heads/main" |
| 320 | |
| 321 | # origin: a project named origin, recording B's change ID too. A host that |
| 322 | # declared it would list it, so it is added to the list on disk, as |
| 323 | # valley-init writes the list. |
| 324 | git init --quiet --bare "$data/origin.git" |
| 325 | checkout origin |
| 326 | cd "$w/origin" |
| 327 | branch o-dup "$(git rev-parse HEAD)" o-dup |
| 328 | ready "$B" o-dup |
| 329 | projects="$(printf '%s\n' guarded open origin released sealed | git -C "$instance" hash-object -w --stdin)" |
| 330 | git -C "$instance" update-ref refs/the-valley/projects "$projects" |
| 331 | |
| 332 | # released is listed and cannot be read. |
| 333 | mv "$data/released.git" "$data/released.moved" |
| 334 | |
| 335 | export VALLEY_KNOWN_SIGNERS="$w/known-signers" VALLEY_INTEGRATOR_SIGNER=integrator |
| 336 | |
| 337 | # ---------------------------------------------------------------------- |
| 338 | # One repository: every record in every state, as valley-changes/v1. |
| 339 | cd "$w/open" |
| 340 | ok valley changes --json |
| 341 | [ "$(wc -l < "$w/out")" = 1 ] || fail "changes printed more than one line" |
| 342 | holds '.schema == "valley-changes/v1"' '.host == "localhost"' '(.repos | length) == 1' \ |
| 343 | '.repos[0].repo == "open"' ".repos[0].url == \"$data/open.git\"" '.repos[0].error == null' \ |
| 344 | '(.repos[0].changes | length) == 13' '.repos[0] | has("drafts") | not' |
| 345 | c() { printf '.repos[0].changes[] | select(.change_id == "%s")' "$1"; } |
| 346 | holds "$(c "$A") | .handle == \"nxvp\" and .state == \"ready\" and .owner == \"alice\" and .target == \"main\" and .active == 1 and .seq == 1" \ |
| 347 | "$(c "$A") | .record == \"$(git -C "$data/open.git" rev-parse "refs/the-valley/changes/main/$A")\"" \ |
| 348 | "$(c "$A") | .versions[0] | .n == 1 and .title == \"stack-a\" and .branch == \"stack-a\" and .uploader == \"alice\"" \ |
| 349 | "$(c "$A") | .versions[0] | .head == \"$(git rev-parse stack-a)\" and .landing == \"not-landed\" and .landed_commit == null" \ |
| 350 | "$(c "$A") | .versions[0].request == {ref: \"refs/the-valley/integration-requests/main/stack-a\", commit: \"$(git rev-parse stack-a)\"}" \ |
| 351 | "$(c "$A") | .versions[0].outcome == null" \ |
| 352 | "$(c "$D") | .state == \"draft\" and .seq == 2" \ |
| 353 | "$(c "$E") | .state == \"withdrawn\"" |
| 354 | # Landing evidence, one version each way. |
| 355 | holds "$(c "$F") | .versions[0] | .landing == \"landed\" and .landed_commit == \"$fhead\"" \ |
| 356 | "$(c "$G") | .versions[0] | .landing == \"landed-recorded\" and .landed_commit == \"$landed\"" \ |
| 357 | "$(c "$G") | .versions[0].outcome == {decision: \"land\", head: \"$(git rev-parse reparent)\", tip: \"$fhead\"}" \ |
| 358 | "$(c "$G") | .versions[0].request == null" \ |
| 359 | "$(c "$U") | .versions[0] | .landing == \"uncertain\" and .landed_commit == null" \ |
| 360 | "$(c "$H") | .versions[0].landing == \"uncertain\"" \ |
| 361 | "$(c "$J") | .versions[0] | .landing == \"landed\" and .landed_commit == \"$jhead\"" \ |
| 362 | "$(c "$J") | .versions[1] | .head == \"$jprime\" and .landing == \"not-landed\" and .landed_commit == null" \ |
| 363 | "$(c "$J") | .state == \"draft\" and .active == 2" \ |
| 364 | "$(c "$I") | .versions[0] | .landing == \"landed-recorded\" and .landed_commit == \"$landed2\"" \ |
| 365 | "$(c "$I") | .versions[1] | .head == \"$hprime\" and .landing == \"not-landed\" and .landed_commit == null" \ |
| 366 | "$(c "$I") | .state == \"draft\" and .active == 2" |
| 367 | # Each change says which version it landed as, and as which commit: J and |
| 368 | # I's next rounds, made on the main that holds their landings, have not. |
| 369 | holds "$(c "$F") | .landed_version == 1 and .landed_commit == \"$fhead\"" \ |
| 370 | "$(c "$G") | .landed_version == 1 and .landed_commit == \"$landed\"" \ |
| 371 | "$(c "$U") | .landed_version == null and .landed_commit == null" \ |
| 372 | "$(c "$J") | .landed_version == null and .landed_commit == null" \ |
| 373 | "$(c "$I") | .landed_version == null and .landed_commit == null" |
| 374 | # includes is ancestry, nearest only. |
| 375 | holds "$(c "$A") | .includes == []" "$(c "$B") | .includes == [\"$A\"]" \ |
| 376 | "$(c "$C") | .includes == [\"$B\"]" "$(c "$W") | .includes == [\"$E\"]" \ |
| 377 | "$(c "$F") | .state == \"ready\" and .versions[0].landing == \"landed\"" "$(c "$K") | .includes == []" |
| 378 | # The one branch no record is on, and no branch main reaches. |
| 379 | holds '.repos[0].branches == [{branch: "loose", head: "'"$(git rev-parse loose)"'"}]' |
| 380 | |
| 381 | # Without the registry's keys, the transfer statement is not believed, and |
| 382 | # that is said. |
| 383 | env -u VALLEY_KNOWN_SIGNERS valley changes --json > "$w/out" 2> "$w/err" || fail "changes failed without the keys" |
| 384 | holds "$(c "$G") | .versions[0].landing == \"uncertain\"" |
| 385 | grep -q 'could not be verified' "$w/err" || fail "an unverified transfer statement was not reported" |
| 386 | |
| 387 | # ---------------------------------------------------------------------- |
| 388 | # Every project the host publishes. Handles are unique across both |
| 389 | # repositories, the repository that cannot be read carries its error, and |
| 390 | # the others are listed all the same. |
| 391 | ok valley changes --json --all |
| 392 | holds '[.repos[].repo] == ["guarded", "open", "origin", "released", "sealed"]' \ |
| 393 | '.repos[] | select(.repo == "released") | .error != null and .changes == [] and .url == "'"$data/released.git"'"' \ |
| 394 | '.repos[] | select(.repo != "released") | .error == null' \ |
| 395 | '.repos[] | select(.repo == "sealed") | .changes == []' \ |
| 396 | '[.repos[].changes[].handle] | length == (unique | length)' \ |
| 397 | "[.repos[].changes[] | select(.change_id == \"$A\" or .change_id == \"$R\") | .handle] == [\"nxvpwlkz\", \"nxvpwlkm\"]" \ |
| 398 | "[.repos[].changes[] | select(.change_id == \"$B\") | .handle] == [\"guarded:mmmm\", \"open:mmmm\", \"origin:mmmm\"]" \ |
| 399 | '.repos[] | select(.repo == "guarded") | [.changes[].state] == ["ready", "ready", "ready", "ready", "draft", "withdrawn"]' |
| 400 | # ls-remote matches a ref's tail, so refs whose names end like the |
| 401 | # refs discovery reads must not stand in for them: one in open whose |
| 402 | # policy/valley names another instance, and one in the instance listing |
| 403 | # another project. |
| 404 | git checkout --quiet -b decoy "$base" |
| 405 | printf '%s\n' "$w/elsewhere.git" > policy/valley |
| 406 | git commit --quiet -am decoy |
| 407 | git push --quiet origin decoy:refs/heads/a/refs/heads/main |
| 408 | decoy_list="$(printf 'decoy\n' | git -C "$instance" hash-object -w --stdin)" |
| 409 | git -C "$instance" update-ref refs/tags/a/refs/the-valley/projects "$decoy_list" |
| 410 | git checkout --quiet landing |
| 411 | ok valley changes --json --all |
| 412 | holds '[.repos[].repo] == ["guarded", "open", "origin", "released", "sealed"]' |
| 413 | git push --quiet origin :refs/heads/a/refs/heads/main |
| 414 | git -C "$instance" update-ref -d refs/tags/a/refs/the-valley/projects |
| 415 | # --repo limits the listing to one repository, read through its clone. |
| 416 | ok valley changes --json --repo guarded |
| 417 | holds '[.repos[].repo] == ["guarded"]' "[.repos[0].changes[].change_id] == [\"$B\", \"$R\", \"$X\", \"$X2\", \"$D2\", \"$E2\"]" \ |
| 418 | '[.repos[0].changes[].handle] == ["mmmm", "nxvp", "oooo", "pqpq", "xxxx", "yyyy"]' \ |
| 419 | "[.repos[0].changes[] | select(.change_id == \"$X\" or .change_id == \"$X2\") | .versions[0] | [.landing, .landed_commit]] == [[\"not-landed\", null], [\"not-landed\", null]]" |
| 420 | cd "$w/guarded" |
| 421 | ok valley changes --json |
| 422 | holds '[.repos[].repo] == ["guarded"]' '[.repos[0].changes[].handle] == ["mmmm", "nxvp", "oooo", "pqpq", "xxxx", "yyyy"]' |
| 423 | # A qualified handle names the change in the repository it qualifies, and |
| 424 | # a qualifier naming another repository is refused. |
| 425 | ok valley resolve guarded:mmmm |
| 426 | line "^change"$'\t'"$B"$'\t'"mmmm"$'\t'"1"$'\t'"$(git rev-parse g-dup)"$'\t' |
| 427 | cd "$w/open" |
| 428 | ok valley resolve open:mmmm |
| 429 | line "^change"$'\t'"$B"$'\t'"mmmm"$'\t'"1"$'\t'"$(git rev-parse stack-b)"$'\t' |
| 430 | if valley resolve origin:mmmm > "$w/out" 2> "$w/err"; then fail "open resolved a handle qualified by origin"; fi |
| 431 | grep -q 'origin:mmmm names a change in origin, and this repository is open' "$w/err" || fail "origin:mmmm was refused without saying why" |
| 432 | cd "$w/origin" |
| 433 | ok valley resolve origin:mmmm |
| 434 | line "^change"$'\t'"$B"$'\t'"mmmm"$'\t'"1"$'\t'"$(git rev-parse o-dup)"$'\t' |
| 435 | ok valley status origin:mmmm |
| 436 | cd "$w/guarded" |
| 437 | if valley changes --json --repo nowhere > "$w/out" 2> "$w/err"; then fail "--repo took a project the host does not list"; fi |
| 438 | grep -q 'lists no project nowhere' "$w/err" || fail "--repo nowhere was refused without saying why" |
| 439 | cd "$w/open" |
| 440 | |
| 441 | # A repository whose main names no owning valley lists itself alone, and |
| 442 | # says discovery is unavailable. |
| 443 | git init --quiet --bare "$w/solo.git" |
| 444 | git clone --quiet "$w/solo.git" "$w/solo" 2> /dev/null |
| 445 | git -C "$w/solo" commit --quiet --allow-empty -m solo |
| 446 | git -C "$w/solo" push --quiet origin main |
| 447 | (cd "$w/solo" && valley changes --json --all) > "$w/out" 2> "$w/err" || fail "changes --all failed without discovery" |
| 448 | holds '[.repos[].repo] == ["solo"]' |
| 449 | grep -q 'discovery is unavailable' "$w/err" || fail "changes --all did not say discovery is unavailable" |
| 450 | |
| 451 | # A policy/valley that git would read as an option, or that names a remote |
| 452 | # helper, is refused before git sees it, and nothing it names runs, even |
| 453 | # where the caller's own configuration allows ext::. |
| 454 | for url in "--upload-pack=touch $w/pwned; git-upload-pack" "ext::sh -c touch% $w/pwned"; do |
| 455 | rm -rf "$w/evil.git" "$w/evil" |
| 456 | git init --quiet --bare "$w/evil.git" |
| 457 | git clone --quiet "$w/evil.git" "$w/evil" 2> /dev/null |
| 458 | mkdir -p "$w/evil/policy" |
| 459 | printf '%s\n' "$url" > "$w/evil/policy/valley" |
| 460 | git -C "$w/evil" add policy |
| 461 | git -C "$w/evil" commit --quiet -m evil |
| 462 | git -C "$w/evil" push --quiet origin main |
| 463 | export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=protocol.ext.allow GIT_CONFIG_VALUE_0=always |
| 464 | (cd "$w/evil" && valley changes --json --all) > "$w/out" 2> "$w/err" || fail "changes --all failed over policy/valley $url" |
| 465 | holds '[.repos[].repo] == ["evil"]' |
| 466 | grep -q 'discovery is unavailable' "$w/err" || fail "policy/valley $url was not refused" |
| 467 | if (cd "$w/evil" && valley changes --json --repo other) > "$w/out" 2> "$w/err"; then |
| 468 | fail "--repo read through policy/valley $url" |
| 469 | fi |
| 470 | unset GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0 |
| 471 | [ ! -e "$w/pwned" ] || fail "policy/valley $url ran a command" |
| 472 | done |
| 473 | |
| 474 | # ---------------------------------------------------------------------- |
| 475 | # pending: the ready changes that need the operator, one row each in |
| 476 | # landing order, then those moving without them, then a count of the |
| 477 | # drafts and the branches no change is on. The changes that wait on an |
| 478 | # approval are stacked among themselves, a stack folded into its top's |
| 479 | # row. atop-lost is a branch no record is on, holding U, a ready change. |
| 480 | # a-parked is a branch last committed to eleven days ago. deep-4 tops a |
| 481 | # chain of four branches. fork-left and fork-right are two branches on one |
| 482 | # base, fork-base. The chain and the fork were last committed to twenty |
| 483 | # days ago. W is readied again as v2, dated an hour on, so it became ready |
| 484 | # last: its row is the last, though its change ID sorts before U's and |
| 485 | # H's, and its v1 is listed nowhere. |
| 486 | branch atop-lost lost atop-lost |
| 487 | parked="@$(($(date +%s) - 11 * 86400))" |
| 488 | GIT_AUTHOR_DATE="$parked" GIT_COMMITTER_DATE="$parked" branch a-parked "$base" a-parked |
| 489 | old="@$(($(date +%s) - 20 * 86400))" |
| 490 | export GIT_AUTHOR_DATE="$old" GIT_COMMITTER_DATE="$old" |
| 491 | branch deep-1 "$base" deep-1 |
| 492 | branch deep-2 deep-1 deep-2 |
| 493 | branch deep-3 deep-2 deep-3 |
| 494 | branch deep-4 deep-3 deep-4 |
| 495 | branch fork-base "$base" fork-base |
| 496 | branch fork-left fork-base fork-left |
| 497 | branch fork-right fork-base fork-right |
| 498 | unset GIT_AUTHOR_DATE GIT_COMMITTER_DATE |
| 499 | cd "$w/open" |
| 500 | git checkout --quiet atop-gone |
| 501 | echo atop-gone-v2 > atop-gone-v2.txt |
| 502 | git add atop-gone-v2.txt |
| 503 | git commit --quiet -m atop-gone-v2 |
| 504 | git push --quiet origin atop-gone |
| 505 | GIT_COMMITTER_DATE="@$(($(date +%s) + 3600))" ok valley ready --change "$W" atop-gone |
| 506 | ok valley pending |
| 507 | no_line $'\x1b' |
| 508 | # pending also writes the handle cache completion reads: one line for each |
| 509 | # change not landed or withdrawn, ready changes first. |
| 510 | cache="$(git rev-parse --git-common-dir)/valley/handles" |
| 511 | [ -f "$cache" ] || fail "pending wrote no handle cache at $cache" |
| 512 | cut -f1,2 "$cache" > "$w/out" |
| 513 | [ "$(cat "$w/out")" = "$(printf '%s\t%s\n' kkkk ready mmmm ready nxvp ready pppp ready ssss ready vvvv ready wwww ready lmlm draft qqqq draft zzzz draft)" ] || |
| 514 | fail "the handle cache lists other changes than the ready and the drafts" |
| 515 | grep -qE "^pppp"$'\t'"ready"$'\t'"[^"$'\t'"]*"$'\t'"stack-c$" "$cache" || fail "the handle cache has no line for pppp with its title" |
| 516 | grep -qE "^qqqq"$'\t'"draft"$'\t'"paused"$'\t' "$cache" || fail "the handle cache has no line for qqqq with its branch" |
| 517 | ok valley pending |
| 518 | # pppp folds mmmm, which it is on, into its row. Its approved layer nxvp |
| 519 | # moves on its own, as K does. The rows are in the order their active |
| 520 | # versions became ready. |
| 521 | after '^needs you \(4, in landing order\)$' \ |
| 522 | '^ 1 pppp v1 stack of 2 +[0-9]+[smhd]$' '^ stack-c$' \ |
| 523 | '^ 2 vvvv v1 +[0-9]+[smhd]$' '^ lost$' \ |
| 524 | '^ 3 wwww v1 +[0-9]+[smhd]$' '^ forged$' \ |
| 525 | '^ 4 ssss v2 +0s$' '^ atop-gone-v2$' '^$' '^moving \(2\)$' |
| 526 | line '^ ◐ kkkk v1 approved$' |
| 527 | line '^ ◐ nxvp v1 approved$' |
| 528 | no_line 'mmmm v1|ssss v1|(tttt|uuuu|rrrr) v1|qqqq v1|lmlm v|zzzz v' |
| 529 | no_line ' ago · ' |
| 530 | [ "$(tail -1 "$w/out")" = '3 drafts · 10 branches no change is on · valley pending --drafts --branches' ] || |
| 531 | fail "pending did not end with the counts of the drafts and the branches" |
| 532 | # -v follows each row with its block: the stack in full, each layer |
| 533 | # counted from the one it is on, and what the change includes. |
| 534 | ok valley pending -v |
| 535 | after '^ 1 pppp v1 stack of 2 ' '^ stack-c$' '^ 1 commit · 1 file \+1 −0$' \ |
| 536 | '^ approving it lands the one below too$' '^ └ mmmm v1 +.* ago · valley-changes-check$' \ |
| 537 | '^ stack-b$' '^ 2 commits · 2 files \+2 −0$' '^ 2 vvvv v1 ' |
| 538 | after '^ 3 wwww v1 ' '^ forged$' '^ 1 commit · 1 file \+1 −0$' \ |
| 539 | '^ uncertain: it may have landed without its evidence being stored$' '^ 4 ssss v2 ' |
| 540 | after '^ 4 ssss v2 ' '^ atop-gone-v2$' '^ 3 commits · 3 files \+3 −0$' '^ includes rrrr \(withdrawn\)$' '^$' |
| 541 | after '^ ◐ kkkk v1 approved$' '^ after-landing$' '^ 1 commit · 1 file \+1 −0$' |
| 542 | # --drafts and --branches list them in full, as blocks, in place of their |
| 543 | # counts. Each listing stacks its own entries. |
| 544 | ok valley pending --drafts --branches |
| 545 | no_line ' no change is on' |
| 546 | after '^drafts$' '^lmlm v2 on ffrec +.* ago · valley-changes-check$' '^ ffrec$' '^ 1 commit · 1 file \+0 −1$' |
| 547 | after '^qqqq v1 on paused +.* ago · valley-changes-check$' '^ paused$' '^ 1 commit · 1 file \+1 −0$' |
| 548 | after '^zzzz v2 on again ' '^ again$' '^ 1 commit · ' |
| 549 | # The branches, latest first. atop-lost holds U's commit as well as its |
| 550 | # own, since U is no branch, and so is titled by U's commit. |
| 551 | after '^branches$' '^atop-lost +.* ago · valley-changes-check$' '^ lost$' '^ 2 commits · 2 files \+2 −0$' \ |
| 552 | '^$' '^loose +.* ago · valley-changes-check$' '^ loose$' '^ 1 commit · 1 file \+1 −0$' '^$' \ |
| 553 | '^a-parked +11 days ago · valley-changes-check$' '^ a-parked$' '^ 1 commit · 1 file \+1 −0$' '^$' '^deep-4 ' |
| 554 | [ "$(grep -n '^drafts$' "$w/out" | cut -d: -f1)" -lt "$(grep -n '^branches$' "$w/out" | cut -d: -f1)" ] || |
| 555 | fail "pending listed the branches before the drafts" |
| 556 | # A chain four deep is one flat list, with no on line: each entry is on |
| 557 | # the one listed after it. |
| 558 | after '^deep-4 +3 weeks ago · valley-changes-check$' '^ deep-4$' '^ 1 commit · 1 file \+1 −0$' \ |
| 559 | '^ approving it lands the 3 below too$' \ |
| 560 | '^ ├ deep-3 +3 weeks ago · valley-changes-check$' '^ │ deep-3$' '^ │ 1 commit · 1 file \+1 −0$' \ |
| 561 | '^ ├ deep-2 +3 weeks ago · valley-changes-check$' '^ │ deep-2$' '^ │ 1 commit · 1 file \+1 −0$' \ |
| 562 | '^ └ deep-1 +3 weeks ago · valley-changes-check$' '^ deep-1$' '^ 1 commit · 1 file \+1 −0$' '^$' |
| 563 | no_line '^ *(│ *)?on deep-' |
| 564 | # Of two branches on one base, one lists the base, and the other says it |
| 565 | # is on it. The base is listed once. |
| 566 | [ "$(grep -cE '(^|├ |└ )fork-base ' "$w/out")" = 1 ] || fail "pending did not list fork-base exactly once" |
| 567 | [ "$(grep -cx ' on fork-base' "$w/out")" = 1 ] || fail "not exactly one of the fork says it is on fork-base" |
| 568 | after '^fork-left ' '^ fork-left$' '^ 1 commit · 1 file \+1 −0$' '^ approving it lands the one below too$' \ |
| 569 | '^ └ fork-base ' '^ fork-base$' '^ 1 commit · 1 file \+1 −0$' '^$' |
| 570 | after '^fork-right ' '^ fork-right$' '^ 1 commit · 1 file \+1 −0$' '^ on fork-base$' |
| 571 | # --json is the same listing in valley-changes/v1's shape: the pending |
| 572 | # changes alone in changes, and the drafts in drafts. |
| 573 | ok valley pending --json |
| 574 | holds '.schema == "valley-pending/v1"' \ |
| 575 | '[.repos[0].changes[].handle] == ["kkkk", "mmmm", "nxvp", "pppp", "ssss", "vvvv", "wwww"]' \ |
| 576 | '[.repos[0].changes[] | select(.approved) | .handle] == ["kkkk", "nxvp"]' \ |
| 577 | '[.repos[0].changes[] | select(.approved | not) | .handle] == ["mmmm", "pppp", "ssss", "vvvv", "wwww"]' \ |
| 578 | '[.repos[0].changes[].approved | type] | unique == ["boolean"]' \ |
| 579 | '[.repos[0].changes[].state] | unique == ["ready"]' \ |
| 580 | '[.repos[0].changes[] | .landed_version, .landed_commit] | unique == [null]' \ |
| 581 | '[.repos[0].drafts[] | [.handle, .state]] == [["lmlm", "draft"], ["qqqq", "draft"], ["zzzz", "draft"]]' \ |
| 582 | '[.repos[0].branches[].branch] == ["a-parked", "atop-lost", "deep-1", "deep-2", "deep-3", "deep-4", "fork-base", "fork-left", "fork-right", "loose"]' |
| 583 | # Across the host, one listing: each row names its project, and the rows |
| 584 | # of every project are numbered in one landing order. Handles are |
| 585 | # qualified where a change ID is recorded in more than one project. A |
| 586 | # project that cannot be read says so first. |
| 587 | (cd "$w/origin" && branch atop-dup o-dup atop-dup) |
| 588 | ok valley pending --all |
| 589 | [ "$(head -1 "$w/out" | cut -c1-25)" = 'released: could not read ' ] || fail "pending --all did not open with the project it could not read" |
| 590 | line '^needs you \(8, in landing order\)$' |
| 591 | line '^ [1-8] guarded nxvpwlkz v1 +[0-9]+[smhd]$' |
| 592 | line '^ [1-8] guarded guarded:mmmm v1 +[0-9]+[smhd]$' |
| 593 | line '^ [1-8] guarded pqpq v1 +stack of 2 +[0-9]+[smhd]$' |
| 594 | line '^ [1-8] open pppp v1 +stack of 2 +[0-9]+[smhd]$' |
| 595 | line '^ [1-8] origin origin:mmmm v1 +[0-9]+[smhd]$' |
| 596 | line '^ 8 open ssss v2 +0s$' |
| 597 | line '^ ◐ open nxvpwlkm v1 +approved$' |
| 598 | no_line '^(guarded|open|origin|sealed)$' |
| 599 | no_line 'oooo v1|open:mmmm v1' |
| 600 | [ "$(tail -1 "$w/out")" = '4 drafts · 11 branches no change is on · valley pending --drafts --branches' ] || |
| 601 | fail "pending --all did not count the drafts and the branches of every project" |
| 602 | ok valley pending --all --branches |
| 603 | after '^branches · origin$' '^atop-dup ' '^ o-dup$' '^ 2 commits · ' |
| 604 | |
| 605 | # --checks adds a line to each change with the checks it requires, by |
| 606 | # cost, as valley checks derives them, here and in a repository read |
| 607 | # through its clone. The instance gets a floor for that, written to its |
| 608 | # main on disk as the integrator would. |
| 609 | git init --quiet "$w/floor" |
| 610 | mkdir -p "$w/floor/policy/instance" |
| 611 | cp "$floor"/*.cue "$w/floor/policy/instance/" |
| 612 | git -C "$w/floor" add policy |
| 613 | git -C "$w/floor" commit --quiet -m floor |
| 614 | git -C "$w/floor" push --quiet "$instance" HEAD:refs/heads/floor |
| 615 | git -C "$instance" update-ref refs/heads/main "$(git -C "$w/floor" rev-parse HEAD)" |
| 616 | ok valley pending --checks --all |
| 617 | after '^ [1-8] open pppp v1 +1 check pending · stack of 2 ' '^ stack-c$' \ |
| 618 | '^ requires 1 quick check, 0 slow$' '^ checks: 1 pending$' |
| 619 | after '^ [1-8] guarded nxvpwlkz v1 +1 check pending ' '^ g-ready$' '^ requires 1 quick check, 0 slow$' '^ checks: 1 pending$' |
| 620 | # An approved change's row carries its check state. |
| 621 | after '^ ◐ open (open:)?kkkk v1 +approved · 1 check pending$' '^ requires 1 quick check, 0 slow$' '^ checks: 1 pending$' |
| 622 | # Without --checks, no change lists its checks. |
| 623 | ok valley changes --json --all |
| 624 | holds '[.repos[].changes[].versions[] | select(has("checks"))] == []' |
| 625 | |
| 626 | # ---------------------------------------------------------------------- |
| 627 | # A branch name is used again once its change has landed: ff now names no |
| 628 | # change, and reparent none either, once its transfer statement verifies. |
| 629 | ok valley resolve ff |
| 630 | line "^branch"$'\t'"ff$" |
| 631 | ok valley resolve reparent |
| 632 | line "^branch"$'\t'"reparent$" |
| 633 | env -u VALLEY_KNOWN_SIGNERS valley resolve reparent > "$w/out" 2> "$w/err" || fail "resolve failed" |
| 634 | line "^change"$'\t'"$G"$'\t' |
| 635 | ok valley resolve stack-a |
| 636 | line "^change"$'\t'"$A"$'\t' |
| 637 | |
| 638 | # H' has not landed, so its branch still names I, which is a draft, and |
| 639 | # approving the branch is refused for I's state rather than taken as a |
| 640 | # plain branch. |
| 641 | ok valley resolve again |
| 642 | line "^change"$'\t'"$I"$'\t'"zzzz"$'\t'"2"$'\t'"$hprime"$'\t'"again"$'\t'"draft"$'\t'"alice$" |
| 643 | if valley approve again > "$w/out" 2> "$w/err"; then fail "approve took the branch of a draft"; fi |
| 644 | grep -qx "⊘ zzzz v2 not approved · change is a draft" "$w/err" || fail "approve did not refuse the draft for its state" |
| 645 | |
| 646 | # J' is not J's landing replayed, so its branch names J, a draft, too. |
| 647 | ok valley resolve ffrec |
| 648 | line "^change"$'\t'"$J"$'\t'"lmlm"$'\t'"2"$'\t'"$jprime"$'\t'"ffrec"$'\t'"draft"$'\t'"alice$" |
| 649 | if valley approve ffrec > "$w/out" 2> "$w/err"; then fail "approve took the branch of a replayed landing"; fi |
| 650 | grep -qx "⊘ lmlm v2 not approved · change is a draft" "$w/err" || fail "approve did not refuse J' for its state" |
| 651 | |
| 652 | # A landed change names its branch no more once the branch moves on to new |
| 653 | # work: ff is a branch, free for that work. |
| 654 | git checkout --quiet -b ff-again ff |
| 655 | echo more > more.txt |
| 656 | git add more.txt |
| 657 | git commit --quiet -m more |
| 658 | git push --quiet origin ff-again:ff |
| 659 | ok valley resolve ff |
| 660 | line "^branch"$'\t'"ff$" |
| 661 | |
| 662 | # ---------------------------------------------------------------------- |
| 663 | # The listings name the knots that link each change: every knot in its |
| 664 | # project's plan graph whose changes lists valley:<project>/<change ID>, |
| 665 | # active knots first. The graph is written through the hook. nxvp is |
| 666 | # linked from two knots, one of them closed, mmmm from one, pppp from |
| 667 | # none, and the draft qqqq from the closed one. mmmm's change ID is linked |
| 668 | # in guarded's name too, and guarded has no graph, so its mmmm has none. |
| 669 | ok valley knot new outcome "The stack lands" --json |
| 670 | goal="$(jq -r .knot.id "$w/out")" |
| 671 | ok valley knot new bug "The stack reads the wrong base" --json |
| 672 | bug="$(jq -r .knot.id "$w/out")" |
| 673 | ok valley knot link "$goal" --change "valley:open/$A" --change "valley:open/$B" |
| 674 | ok valley knot link "$bug" --change "valley:open/$A" --change "valley:open/$D" --change "valley:guarded/$B" |
| 675 | ok valley knot set "$bug" status=closed |
| 676 | goal_ref="[\"$goal\", \"outcome\", \"open\", \"The stack lands\"]" |
| 677 | bug_ref="[\"$bug\", \"bug\", \"closed\", \"The stack reads the wrong base\"]" |
| 678 | k() { printf '[.repos[0].%s[] | select(.change_id == "%s") | .knots[] | [.id, .type, .status, .title]]' "$1" "$2"; } |
| 679 | ok valley changes --json |
| 680 | holds "$(k changes "$A") == [$goal_ref, $bug_ref]" "$(k changes "$B") == [$goal_ref]" "$(k changes "$C") == []" \ |
| 681 | "$(k changes "$D") == [$bug_ref]" '[.repos[0].changes[] | .knots | type] | unique == ["array"]' |
| 682 | if grep -q 'plan graph' "$w/err"; then fail 'changes spoke of the plan graph without -v'; fi |
| 683 | ok valley pending --json |
| 684 | holds "$(k changes "$A") == [$goal_ref, $bug_ref]" "$(k changes "$C") == []" "$(k drafts "$D") == [$bug_ref]" |
| 685 | # pending shows the first knot's ID after the title. |
| 686 | ok valley pending -v --drafts |
| 687 | after '^ 1 pppp v1 ' '^ stack-c$' '^ 1 commit · ' '^ checks: 1 pending$' \ |
| 688 | '^ approving it lands the one below too$' '^ └ mmmm v1 ' "^ stack-b · $goal\$" |
| 689 | after '^ ◐ nxvp v1 approved · 1 check pending$' "^ stack-a · $goal\$" |
| 690 | after '^qqqq v1 on paused ' "^ paused · $bug\$" |
| 691 | ok valley status --json nxvp |
| 692 | holds "[.knots[] | [.id, .type, .status, .title]] == [$goal_ref, $bug_ref]" |
| 693 | ok valley status --json pppp |
| 694 | holds '.knots == []' |
| 695 | ok valley status --json loose |
| 696 | holds '.change_id == null and .knots == []' |
| 697 | ok valley changes --json --all |
| 698 | holds "[.repos[] | select(.repo == \"open\") | .changes[] | select(.change_id == \"$B\") | .knots[].id] == [\"$goal\"]" \ |
| 699 | "[.repos[] | select(.repo == \"guarded\") | .changes[] | select(.change_id == \"$B\") | .knots] == [[]]" |
| 700 | if grep -q 'plan graph' "$w/err"; then fail 'changes --all spoke of a missing plan graph without -v'; fi |
| 701 | ok valley changes --json --repo guarded -v |
| 702 | grep -qF 'guarded has no plan graph at refs/the-valley/knots, so no change shows a knot' "$w/err" \ |
| 703 | || fail 'changes -v did not say guarded has no plan graph' |
| 704 | # A graph that does not read links no change, and the listings go on as |
| 705 | # before. Only -v says why. |
| 706 | graph_tip="$(git -C "$data/open.git" rev-parse refs/the-valley/knots)" |
| 707 | junk="$(printf 'junk\n' | git -C "$data/open.git" hash-object -w --stdin)" |
| 708 | junk_tree="$(printf '100644 blob %s\tjunk.txt\n' "$junk" | git -C "$data/open.git" mktree)" |
| 709 | git -C "$data/open.git" update-ref refs/the-valley/knots "$(git -C "$data/open.git" commit-tree "$junk_tree" -m junk)" |
| 710 | ok valley changes --json |
| 711 | holds '(.repos[0].changes | length) == 13' '[.repos[0].changes[].knots] | unique == [[]]' |
| 712 | if grep -q 'plan graph' "$w/err"; then fail 'changes spoke of a broken plan graph without -v'; fi |
| 713 | ok valley pending -v |
| 714 | line '^ stack-a$' |
| 715 | no_line " · ($goal|$bug)\$" |
| 716 | ok valley status --json nxvp |
| 717 | holds '.knots == []' |
| 718 | ok valley changes --json -v |
| 719 | grep -qF "open's plan graph could not be read, so no change shows a knot" "$w/err" \ |
| 720 | || fail 'changes -v did not say why it shows no knot' |
| 721 | git -C "$data/open.git" update-ref refs/the-valley/knots "$graph_tip" |
| 722 | |
| 723 | # ---------------------------------------------------------------------- |
| 724 | # --checks: each ready change's and draft's required checks, passed, |
| 725 | # failed or pending by the note the integrator would judge each by. The host |
| 726 | # publishes its signers in the instance, as its publisher writes them, |
| 727 | # and a check worker's key is among them. The floor requires prose-format |
| 728 | # of each change here. The worker's note for one head's tree records a |
| 729 | # pass, for another a failure, and a third head has none. A note is |
| 730 | # stored on origin as attest run stores one: <check>/statement.note at |
| 731 | # refs/the-valley/attestations/<tree digest>/<key hash>. |
| 732 | cd "$w/open" |
| 733 | ssh-keygen -q -t ed25519 -N '' -C worker -f "$w/worker.key" |
| 734 | workerhash="$(attest key --key "$w/worker.key" --name worker | cut -d+ -f2)" |
| 735 | { |
| 736 | cat "$w/known-signers" |
| 737 | attest key --key "$w/worker.key" --name worker |
| 738 | } > "$w/host-signers" |
| 739 | keysblob="$(git -C "$instance" hash-object -w "$w/host-signers")" |
| 740 | nameblob="$(printf 'integrator\n' | git -C "$instance" hash-object -w --stdin)" |
| 741 | git -C "$instance" update-ref refs/the-valley/signers \ |
| 742 | "$(printf '100644 blob %s\tintegrator-name\n100644 blob %s\tknown-signers\n' "$nameblob" "$keysblob" | git -C "$instance" mktree)" |
| 743 | |
| 744 | # evidence <branch> <result>: the worker's note about prose-format for the |
| 745 | # branch head's tree, stored on origin. |
| 746 | evidence() { |
| 747 | local head digest blob tree |
| 748 | head="$(git rev-parse "$1")" |
| 749 | digest="$(tree_digest "$head")" |
| 750 | jq -n --arg tree "$digest" --arg commit "$head" --arg result "$2" '{ |
| 751 | statementType: "the-valley/attestation/v1", |
| 752 | subject: {primary: "valley-tree-v1", digest: {"valley-tree-v1": $tree, "git-sha1": $commit}}, |
| 753 | predicateType: "the-valley/check/pure/v1", |
| 754 | predicate: {check: {name: "prose-format", runner: "nix", attribute: "prose-format"}, result: $result, |
| 755 | inputs: {"valley-inputs-v1": ("cd" * 32)}, derivation: {sha256: ("ef" * 32)}, output: {sha256: ("01" * 32)}} |
| 756 | }' > "$w/statement.json" |
| 757 | attest render "$w/statement.json" | attest sign --key "$w/worker.key" --name worker > "$w/check.note" |
| 758 | blob="$(git -C "$data/open.git" hash-object -w "$w/check.note")" |
| 759 | tree="$(printf '100644 blob %s\tstatement.note\n' "$blob" | git -C "$data/open.git" mktree)" |
| 760 | tree="$(printf '040000 tree %s\tprose-format\n' "$tree" | git -C "$data/open.git" mktree)" |
| 761 | git -C "$data/open.git" update-ref "refs/the-valley/attestations/$digest/$workerhash" "$tree" |
| 762 | } |
| 763 | K1="$(id klkl)" K2="$(id kmkm)" K3="$(id knkn)" |
| 764 | git fetch --quiet origin |
| 765 | branch chk-pass origin/main chk-pass |
| 766 | ready "$K1" chk-pass |
| 767 | evidence chk-pass passed |
| 768 | branch chk-fail origin/main chk-fail |
| 769 | ready "$K2" chk-fail |
| 770 | evidence chk-fail failed |
| 771 | branch chk-none origin/main chk-none |
| 772 | ready "$K3" chk-none |
| 773 | # Three drafts, read from the same notes: one whose check passed, one |
| 774 | # whose check failed, and one with none. |
| 775 | D3="$(id mkmk)" D4="$(id mlml)" D5="$(id mnmn)" |
| 776 | branch dchk-pass origin/main dchk-pass |
| 777 | ready "$D3" dchk-pass |
| 778 | evidence dchk-pass passed |
| 779 | branch dchk-fail origin/main dchk-fail |
| 780 | ready "$D4" dchk-fail |
| 781 | evidence dchk-fail failed |
| 782 | branch dchk-none origin/main dchk-none |
| 783 | ready "$D5" dchk-none |
| 784 | ok valley unready "$D3" |
| 785 | ok valley unready "$D4" |
| 786 | ok valley unready "$D5" |
| 787 | |
| 788 | ok valley changes --json --checks |
| 789 | checks() { printf '.repos[0].changes[] | select(.change_id == "%s") | .versions[.active-1].checks' "$1"; } |
| 790 | holds "$(checks "$K1") | .state == \"passed\" and .tree == \"$(tree_digest chk-pass)\"" \ |
| 791 | "$(checks "$K1") | .required == [{name: \"prose-format\", state: \"passed\", signer: \"worker+$workerhash\"}]" \ |
| 792 | "$(checks "$K2") | .state == \"failed\" and (.required | length) == 1" \ |
| 793 | "$(checks "$K2") | .required[0] | .name == \"prose-format\" and .state == \"failed\" and .signer == \"worker+$workerhash\"" \ |
| 794 | "$(checks "$K2") | .required[0].why | contains(\"predicate.result\")" \ |
| 795 | "$(checks "$K3") | .state == \"pending\" and .required == [{name: \"prose-format\", state: \"pending\"}]" \ |
| 796 | "$(checks "$D3") | .state == \"passed\" and .required == [{name: \"prose-format\", state: \"passed\", signer: \"worker+$workerhash\"}]" \ |
| 797 | "$(checks "$D4") | .state == \"failed\" and .required[0].name == \"prose-format\" and .required[0].signer == \"worker+$workerhash\"" \ |
| 798 | "$(checks "$D4") | .required[0].why | contains(\"predicate.result\")" \ |
| 799 | "$(checks "$D5") | .state == \"pending\" and .required == [{name: \"prose-format\", state: \"pending\"}]" \ |
| 800 | '[.repos[0].changes[] | select(.state == "withdrawn") | .versions[] | select(has("checks"))] == []' \ |
| 801 | '[.repos[0].changes[] | .versions[] | select(.landing == "landed" or .landing == "landed-recorded") | select(has("checks"))] == []' |
| 802 | ok valley pending --json --checks |
| 803 | holds "$(checks "$K2") | .state == \"failed\"" '[.repos[0].drafts[].versions[] | select(has("checks"))] == []' |
| 804 | ok valley pending --json --drafts --checks |
| 805 | holds "$(checks "$K2") | .state == \"failed\"" \ |
| 806 | "[.repos[0].drafts[] | [.handle, .versions[.active-1].checks.required[0].state]] == [[\"lmlm\", \"pending\"], [\"mkmk\", \"passed\"], [\"mlml\", \"failed\"], [\"mnmn\", \"pending\"], [\"qqqq\", \"pending\"], [\"zzzz\", \"pending\"]]" |
| 807 | # Each row counts its checks, passed out of required when all passed, and |
| 808 | # otherwise how many are pending. A change whose check failed moves, and |
| 809 | # says which. The rows are in landing order: pppp, U and H became ready |
| 810 | # before K1 and K3, and W's v2 last, though K1's and K3's change IDs sort |
| 811 | # first. |
| 812 | ok valley pending |
| 813 | after '^needs you \(6, in landing order\)$' '^ 1 pppp v1 1 check pending · stack of 2 ' '^ stack-c$' \ |
| 814 | '^ 2 vvvv v1 1 check pending ' '^ lost$' '^ 3 wwww v1 1 check pending ' '^ forged$' \ |
| 815 | '^ 4 klkl v1 checks 1/1 +[0-9]+[smhd]$' '^ chk-pass$' '^ 5 knkn v1 1 check pending ' '^ chk-none$' \ |
| 816 | '^ 6 ssss v2 1 check pending +0s$' '^ atop-gone-v2$' '^$' '^moving \(3\)$' |
| 817 | line '^ ✗ kmkm v1 prose-format failed$' |
| 818 | line '^ ◐ kkkk v1 approved · 1 check pending$' |
| 819 | ok valley pending --checks |
| 820 | after '^ 4 klkl v1 ' '^ chk-pass$' '^ requires 1 quick check, 0 slow$' '^ checks: 1 passed$' |
| 821 | after '^ ✗ kmkm v1 prose-format failed$' '^ requires 1 quick check, 0 slow$' '^ checks: 1 failed \(prose-format\)$' |
| 822 | after '^ 5 knkn v1 ' '^ chk-none$' '^ requires 1 quick check, 0 slow$' '^ checks: 1 pending$' |
| 823 | no_line '(mkmk|mlml|mnmn) v1' |
| 824 | # With --drafts, a draft's block says its checks in a ready row's words. |
| 825 | ok valley pending --drafts --checks |
| 826 | after '^mkmk v1 on dchk-pass checks 1/1 ' '^ dchk-pass$' '^ 1 commit · ' \ |
| 827 | '^ requires 1 quick check, 0 slow$' '^ checks: 1 passed$' |
| 828 | after '^mlml v1 on dchk-fail ✗ prose-format failed ' '^ dchk-fail$' '^ 1 commit · ' \ |
| 829 | '^ requires 1 quick check, 0 slow$' '^ checks: 1 failed \(prose-format\)$' |
| 830 | after '^mnmn v1 on dchk-none 1 check pending ' '^ dchk-none$' '^ 1 commit · ' \ |
| 831 | '^ requires 1 quick check, 0 slow$' '^ checks: 1 pending$' |
| 832 | # review shows a draft's checks line, and still offers no approve. |
| 833 | printf 'a\ns\n' | ok env VALLEY_REVIEW_CHECKS_WAIT=120 valley review "$D4" |
| 834 | grep -qx 'mlml v1 · checks: 1 failed (prose-format) · draft (its owner, alice, has not readied it)' "$w/out" \ |
| 835 | || fail "review's prompt did not carry the draft's checks line" |
| 836 | line 'answer v or s$' |
| 837 | no_line '\[a\]pprove' |
| 838 | # Readied at the same head, the draft lists the same check states. |
| 839 | ready "$D4" dchk-fail |
| 840 | ok valley changes --json --checks |
| 841 | holds "$(checks "$D4") | .state == \"failed\" and .tree == \"$(tree_digest dchk-fail)\" and (.required | length) == 1" \ |
| 842 | "$(checks "$D4") | .required[0] | .state == \"failed\" and .signer == \"worker+$workerhash\" and (.why | contains(\"predicate.result\"))" |
| 843 | ok valley pending |
| 844 | line '^ ✗ mlml v1 prose-format failed$' |
| 845 | |
| 846 | # --checks with the host's worker telemetry: each nix check's build time |
| 847 | # for the version, the median of its recent uncached, passing builds in |
| 848 | # the project, the other versions of the change left out, a check grown |
| 849 | # past its baseline, and a check with no history. The host is reached |
| 850 | # over ssh, here a fake ssh that answers the read valley telemetry read |
| 851 | # makes from a file of the worker's records, paged as the collector pages |
| 852 | # them: the newest 1000 without a cursor, else the 1000 after it. It |
| 853 | # refuses while $tel/refuse exists, as a host refuses a principal with no |
| 854 | # observe grant. |
| 855 | tel="$w/telemetry" |
| 856 | mkdir -p "$tel/bin" |
| 857 | { |
| 858 | printf '#!%s\n' "$(command -v bash)" |
| 859 | cat << 'EOF' |
| 860 | set -euo pipefail |
| 861 | command="${*: -1}" |
| 862 | printf '%s\n' "$command" >> "$TELEMETRY_DIR/ssh.log" |
| 863 | if [ -e "$TELEMETRY_DIR/refuse" ]; then |
| 864 | printf '%s\n' '{"kind":"error","error":"alice holds no observe grant"}' |
| 865 | exit 1 |
| 866 | fi |
| 867 | since=-1 |
| 868 | for word in $command; do |
| 869 | case "$word" in --since=worker=*) since="${word##*:}" ;; esac |
| 870 | done |
| 871 | jq -c -s --argjson since "$since" ' |
| 872 | (map(.seq) | max) as $last |
| 873 | | (if $since < 0 then [$last - 1000, 0] | max else $since end) as $after |
| 874 | | [.[] | select(.seq > $after)][:1000] as $page |
| 875 | | {kind: "header", host: "valley-host", format: "valley-telemetry/v1"}, |
| 876 | ($page[] | {kind: "record", stream: "worker"} + .), |
| 877 | {kind: "end", cursor: "worker=0123456789abcdef:\(($page | last | .seq) // $after)", truncated: false} |
| 878 | ' "$TELEMETRY_DIR/worker.jsonl" |
| 879 | EOF |
| 880 | } > "$tel/bin/ssh" |
| 881 | chmod +x "$tel/bin/ssh" |
| 882 | export TELEMETRY_DIR="$tel" PATH="$tel/bin:$PATH" |
| 883 | git config valley.telemetry.remote ssh://git@valley-host/open.git |
| 884 | |
| 885 | # build <seq> <project> <change> <version> <tree> <result> <build ms> <eval ms> <log bytes> [<cached> [<capacity>]]: |
| 886 | # a check.result record of prose-format, as attest stores one. |
| 887 | build() { |
| 888 | jq -n -c --argjson seq "$1" --arg project "$2" --arg change "$3" --argjson version "$4" --arg tree "$5" \ |
| 889 | --arg result "$6" --argjson build "$7" --argjson eval "$8" --argjson log "$9" --arg cached "${10:-}" --arg capacity "${11:-}" ' |
| 890 | {seq: $seq, type: "check.result", time: (1762128000 + $seq | todate), run: "r\($seq)", project: $project, |
| 891 | change: $change, version: $version, tree: $tree, check: "prose-format", |
| 892 | data: ({result: $result, build_ms: $build, eval_ms: $eval, slot_wait_ms: 0, log_bytes: $log} |
| 893 | + (if $cached == "" then {} else {cached: ($cached == "true")} end) |
| 894 | + (if $capacity == "" then {} else {capacity: $capacity} end))}' |
| 895 | } |
| 896 | # filler <from> <to>: the records of passes that built nothing. |
| 897 | filler() { |
| 898 | jq -n -c --argjson from "$1" --argjson to "$2" \ |
| 899 | 'range($from; $to + 1) | {seq: ., type: "pass.start", time: (1762128000 + . | todate), run: "p\(.)"}' |
| 900 | } |
| 901 | O1="$(id lplp)" O2="$(id lqlq)" O3="$(id lrlr)" O4="$(id lsls)" O5="$(id ltlt)" O6="$(id lulu)" |
| 902 | t1="$(tree_digest chk-pass)" t2="$(tree_digest chk-fail)" |
| 903 | { |
| 904 | # The recent builds of prose-format in this project, older than the |
| 905 | # newest 1000 records, so a second page reads them. A cached build, one |
| 906 | # an older attest recorded with no log and so cached, a failed build and |
| 907 | # another project's are no baseline. Another version of K1's is no |
| 908 | # baseline for K1, and is for the other changes. |
| 909 | build 1 open "$O1" 1 "" passed 50000 20000 10 false |
| 910 | build 2 open "$O2" 1 "" passed 60000 20000 10 |
| 911 | build 3 open "$O3" 3 "" passed 70000 20000 10 false |
| 912 | build 4 open "$O4" 1 "" passed 5 20000 0 true |
| 913 | build 5 open "$O5" 1 "" passed 10 20000 0 |
| 914 | build 6 open "$O6" 1 "" failed 1000 20000 10 false |
| 915 | build 7 guarded "$O1" 1 "" passed 1 20000 10 false |
| 916 | build 8 open "$K1" 2 "" passed 900000 20000 10 false |
| 917 | filler 9 1499 |
| 918 | # The versions' own builds. |
| 919 | build 1500 open "$K1" 1 "$t1" passed 100000 24000 20 false |
| 920 | build 1501 open "$K2" 1 "$t2" failed 61000 23000 20 false |
| 921 | } > "$tel/worker.jsonl" |
| 922 | |
| 923 | ok valley changes --json --checks |
| 924 | pf() { printf '%s | .required[] | select(.name == "prose-format")' "$(checks "$1")"; } |
| 925 | holds "$(pf "$K1") | .build_ms == 100000 and .cached == false and .baseline_ms == 60000 and .grown == true and (has(\"new\") | not)" \ |
| 926 | "$(checks "$K1") | .build_ms == 100000 and .eval_ms == 24000 and .state == \"passed\"" \ |
| 927 | "$(pf "$K2") | .build_ms == 61000 and .baseline_ms == 70000 and (has(\"grown\") | not) and .state == \"failed\"" \ |
| 928 | "$(pf "$K3") | (has(\"build_ms\") | not) and .baseline_ms == 70000 and .state == \"pending\"" \ |
| 929 | "$(checks "$K3") | has(\"build_ms\") | not" |
| 930 | [ "$(wc -l < "$tel/ssh.log")" = 2 ] || fail "the listing read the worker's telemetry otherwise than in two pages: $(cat "$tel/ssh.log")" |
| 931 | grep -qx 'valley-telemetry read --source=worker --limit=1000' "$tel/ssh.log" || fail "the first page was not the newest: $(cat "$tel/ssh.log")" |
| 932 | grep -qx 'valley-telemetry read --source=worker --since=worker=0123456789abcdef:0 --limit=1000' "$tel/ssh.log" || |
| 933 | fail "the second page did not read on from the first's cursor: $(cat "$tel/ssh.log")" |
| 934 | rm "$tel/ssh.log" |
| 935 | ok valley pending --checks |
| 936 | after '^ 4 klkl v1 ' '^ chk-pass$' '^ requires 1 quick check, 0 slow$' \ |
| 937 | '^ checks: 1 passed in 1m40s \(eval 24s\); prose-format 100s, \+40s against its…$' |
| 938 | after '^ ✗ kmkm v1 prose-format failed$' '^ requires 1 quick check, 0 slow$' \ |
| 939 | '^ checks: 1 failed \(prose-format\) in 1m1s \(eval 23s\)$' |
| 940 | after '^ 5 knkn v1 ' '^ chk-none$' '^ requires 1 quick check, 0 slow$' '^ checks: 1 pending$' |
| 941 | [ "$(wc -l < "$tel/ssh.log")" = 2 ] || fail "pending read the worker's telemetry otherwise than in two pages: $(cat "$tel/ssh.log")" |
| 942 | # review shows the same line just before its prompt, whole: it is paged, |
| 943 | # not fitted to a terminal. It reads the line while it shows the diff and |
| 944 | # does not wait for it, so this run is told to wait. |
| 945 | printf 's\n' | ok env VALLEY_REVIEW_CHECKS_WAIT=120 valley review "$K1" |
| 946 | [ "$(grep -B1 '^\[a\]pprove' "$w/out" | head -1)" = 'klkl v1 · checks: 1 passed in 1m40s (eval 24s); prose-format 100s, +40s against its recent 60s' ] \ |
| 947 | || fail "review's prompt did not carry the checks line: $(cat "$w/out")" |
| 948 | |
| 949 | # A check with no recent build in the project is new, which is no news: |
| 950 | # the line leaves it out. |
| 951 | { |
| 952 | build 1 guarded "$O1" 1 "" passed 50000 20000 10 false |
| 953 | build 2 open "$K1" 1 "$t1" passed 100000 24000 20 false |
| 954 | } > "$tel/worker.jsonl" |
| 955 | ok valley changes --json --checks |
| 956 | holds "$(pf "$K1") | .build_ms == 100000 and .new == true and (has(\"baseline_ms\") | not) and (has(\"grown\") | not)" |
| 957 | ok valley pending --checks |
| 958 | after '^ 4 klkl v1 ' '^ chk-pass$' '^ requires 1 quick check, 0 slow$' \ |
| 959 | '^ checks: 1 passed in 1m40s \(eval 24s\)$' |
| 960 | |
| 961 | # Builds on another capacity are no baseline: the check of a resized host |
| 962 | # has no comparable history, and has not grown. |
| 963 | { |
| 964 | build 1 open "$O1" 1 "" passed 10000 20000 10 false "slots=1 cpus=4" |
| 965 | build 2 open "$K1" 1 "$t1" passed 100000 24000 20 false "slots=2 cpus=8" |
| 966 | } > "$tel/worker.jsonl" |
| 967 | ok valley changes --json --checks |
| 968 | holds "$(pf "$K1") | .new == true and .other_capacity == true and (has(\"baseline_ms\") | not) and (has(\"grown\") | not)" |
| 969 | ok valley pending --checks |
| 970 | after '^ 4 klkl v1 ' '^ chk-pass$' '^ requires 1 quick check, 0 slow$' \ |
| 971 | '^ checks: 1 passed in 1m40s \(eval 24s\)$' |
| 972 | |
| 973 | # A host that refuses leaves every build time out, says why once, and |
| 974 | # lists the check states all the same. |
| 975 | touch "$tel/refuse" |
| 976 | ok valley changes --json --checks |
| 977 | holds "$(checks "$K1") | .required == [{name: \"prose-format\", state: \"passed\", signer: \"worker+$workerhash\"}] and (has(\"build_ms\") | not)" \ |
| 978 | "$(checks "$K2") | .required == [{name: \"prose-format\", state: \"failed\", signer: \"worker+$workerhash\", why: .required[0].why}]" \ |
| 979 | "$(checks "$K3") | .required == [{name: \"prose-format\", state: \"pending\"}]" |
| 980 | [ "$(grep -c 'no check lists its build times: .*alice holds no observe grant' "$w/err")" = 1 ] || |
| 981 | fail "a refusing host was not said once on stderr: $(cat "$w/err")" |
| 982 | ok valley pending --checks |
| 983 | after '^ 4 klkl v1 ' '^ chk-pass$' '^ requires 1 quick check, 0 slow$' '^ checks: 1 passed$' |
| 984 | |
| 985 | # valley help names the verbs front ends look for. |
| 986 | valley help > "$w/out" |
| 987 | line '^ ready ' |
| 988 | line '^ changes ' |
| 989 | |
| 990 | touch "$out" |