Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions scripts/gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ assert_floor_not_lowered() {
local file="$1" target="${CK_GATE_FLOOR_TARGET:-origin/master}"
local ours theirs target_file

# NAME THE RESOLVED SHA, NOT JUST THE REF. `origin/master` means a DIFFERENT COMMIT
# depending on who runs this: a fork contributor's `origin` is their own fork, whose
# master can lag the real merge target arbitrarily. The comparison then runs against a
# stale number and PASSES -- a false green rather than a refusal, which is the worse
# direction. Printing the resolved SHA does not fix the staleness, but it makes it
# legible: a four-week-old commit beside today's is visible where a bare ref name is
# not. Set CK_GATE_FLOOR_TARGET to compare against the real upstream ref instead.
local target_sha
target_sha=$(git rev-parse --short "$target" 2>/dev/null || echo 'unresolved')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The SHA the log names is not guaranteed to be the commit that was actually compared, because $target_sha comes from a separate git rev-parse run before git show "$target:scripts/gate.sh" re-resolves the same ref. A ref that moves between the two calls gets logged under a SHA that was never the comparison input, and the UNCHECKED "cannot resolve" message can even print a valid SHA: git show exits 128 when it fails for any reason besides an unresolvable ref (path absent from the target commit, missing blob in a partial clone), so "cannot resolve $target ($target_sha)" can pair a real resolved SHA with the literal (unresolved) marker, which only reflects the earlier rev-parse call. Since the PR's whole purpose is making the compared commit legible, resolve once and feed that SHA to git show (falling back to $target when unresolved) so the printed commit is exactly the one compared, and keep the "cannot resolve"/(unresolved) wording for the case where resolution actually failed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/gate.sh, line 267:

<comment>The SHA the log names is not guaranteed to be the commit that was actually compared, because `$target_sha` comes from a separate `git rev-parse` run before `git show "$target:scripts/gate.sh"` re-resolves the same ref. A ref that moves between the two calls gets logged under a SHA that was never the comparison input, and the UNCHECKED "cannot resolve" message can even print a valid SHA: `git show` exits 128 when it fails for any reason besides an unresolvable ref (path absent from the target commit, missing blob in a partial clone), so "cannot resolve $target ($target_sha)" can pair a real resolved SHA with the literal `(unresolved)` marker, which only reflects the earlier rev-parse call. Since the PR's whole purpose is making the compared commit legible, resolve once and feed that SHA to `git show` (falling back to `$target` when unresolved) so the printed commit is exactly the one compared, and keep the "cannot resolve"/`(unresolved)` wording for the case where resolution actually failed.</comment>

<file context>
@@ -256,6 +256,16 @@ assert_floor_not_lowered() {
+  # legible: a four-week-old commit beside today's is visible where a bare ref name is
+  # not. Set CK_GATE_FLOOR_TARGET to compare against the real upstream ref instead.
+  local target_sha
+  target_sha=$(git rev-parse --short "$target" 2>/dev/null || echo 'unresolved')
+
   ours=$(grep -m1 -oE 'run_expect [0-9]+ "workspace' "$file" | grep -oE '[0-9]+')
</file context>


ours=$(grep -m1 -oE 'run_expect [0-9]+ "workspace' "$file" | grep -oE '[0-9]+')
if [ -z "$ours" ]; then
fail "floor ratchet: cannot read this tree's workspace floor from $file"
Expand All @@ -265,15 +275,15 @@ assert_floor_not_lowered() {
if ! target_file=$(git show "$target:scripts/gate.sh" 2>/dev/null); then
GATE_UNCHECKED="${GATE_UNCHECKED:-}floor ratchet (cannot resolve $target) "
printf '\n=== floor ratchet: UNCHECKED ===\n'
printf 'cannot resolve %s — no comparison made (this is not a pass)\n' "$target"
printf 'cannot resolve %s (%s) — no comparison made (this is not a pass)\n' "$target" "$target_sha"
return
fi

theirs=$(printf '%s\n' "$target_file" | grep -m1 -oE 'run_expect [0-9]+ "workspace' | grep -oE '[0-9]+')
if [ -z "$theirs" ]; then
GATE_UNCHECKED="${GATE_UNCHECKED:-}floor ratchet (no floor in $target) "
printf '\n=== floor ratchet: UNCHECKED ===\n'
printf 'cannot read a workspace floor from %s — no comparison made (this is not a pass)\n' "$target"
printf 'cannot read a workspace floor from %s (%s) — no comparison made (this is not a pass)\n' "$target" "$target_sha"
return
fi

Expand All @@ -283,12 +293,12 @@ assert_floor_not_lowered() {
printf 'this tree %s < %s %s — reason: %s\n' "$ours" "$target" "$theirs" "$CK_GATE_FLOOR_LOWER_REASON"
return
fi
fail "floor ratchet: this tree's workspace floor is $ours but $target carries $theirs — a branch forked before a raise lowers it silently and every gate still passes; rebase and re-measure on the merged tree, or set CK_GATE_FLOOR_LOWER_REASON"
fail "floor ratchet: this tree's workspace floor is $ours but $target ($target_sha) carries $theirs — a branch forked before a raise lowers it silently and every gate still passes; rebase and re-measure on the merged tree, or set CK_GATE_FLOOR_LOWER_REASON"
return
fi

printf '\n=== floor ratchet ===\n'
printf 'workspace floor %s >= %s %s\n' "$ours" "$target" "$theirs"
printf 'workspace floor %s >= %s %s at %s\n' "$ours" "$target" "$theirs" "$target_sha"
}

# The floor is the MEASURED total, not a round number below it. A floor with slack
Expand Down