fix(scripts): row 211 R3 push guard tags, installer hooks dir, busy check errors (#1709)
This commit is contained in:
1 parent
3a121885cf
commit
7d03f212db
9 files changed
+378
-25
No files matched your search
@@ -149,3 +149,176 @@ happened. The suite, the mutants and every other `scripts/test-*.sh` run in a CL
|
||||
- The hook doesn't check tags differently from branches: a moved tag is refused like a rewritten branch.
|
||||
- `slot-busy.sh` can call a process BUSY that isn't a run, for example an editor with a `test-*.sh` open.
|
||||
It never reads files under a seat's directory, so it can't tell.
|
||||
|
||||
## R3, the GPT review (2026-11-02)
|
||||
|
||||
The lead's implementation sub-agent (Claude Opus 5.5, a child of Sage's T3 c5c1e8ba) wrote this round from
|
||||
the brief `/mnt/storage/scratch/mosaic-lead/briefs/row211-r3-fix.md` and the review
|
||||
`/mnt/storage/scratch/mosaic-lead/reviews/batch1-a-gpt.md` (F1 to F5 and the edge-case table). Base
|
||||
09a847eda, branch `t3/row211-push-guard-r3-fix`: dca5f10cc and 3e39689c1 picked clean as 5734c1a80 and
|
||||
c8f2cb70c, then one R3 commit. The suite goes from 61 cases to 85 and the mutants from 13 to 21. The
|
||||
sections above stay as written; where R3 changes them, it says so here.
|
||||
|
||||
### F1: a failed read counted as a vanished process
|
||||
|
||||
What: `slot-busy.sh` skipped any process whose cmdline read failed, so a live process it couldn't read (a
|
||||
mode-000 cmdline of a `node --test`, say) could end in CLEAR. Its own status read was unchecked too: it put
|
||||
`$$` in the skip set first, and a failed read only ended the ancestor walk.
|
||||
|
||||
Fix: after a failed read the scan checks the pid directory. Gone means the process exited, and it's
|
||||
skipped. Still there is an error: the scan names that cmdline, counts it and goes on, so BUSY lines still
|
||||
print, then exits 2 and never prints CLEAR. Its own status must read and give a numeric PPid, or it exits 2
|
||||
before the scan. A failed read further up the walk still only ends the walk, which can give a false BUSY but
|
||||
never a false CLEAR.
|
||||
|
||||
Tests, section "slot-busy, read errors" (fake `/proc`): "a pid directory with no cmdline: exit 2", "it
|
||||
names that cmdline and never says CLEAR", "a cmdline that can't be read (a directory): exit 2, no CLEAR", "a
|
||||
read error beside a BUSY process: exit 2, the BUSY line kept, no CLEAR", "a node --test process whose
|
||||
cmdline is unreadable (mode 000) is never CLEAR", "a failing read (tr exits 1) with every pid directory
|
||||
still there: exit 2, no CLEAR", "a process that vanishes during its read isn't an error: exit 0 and CLEAR"
|
||||
(a `tr` shim on PATH removes the pid directory, then fails) and "its own process unreadable (awk exits 1):
|
||||
exit 2, no CLEAR" (an `awk` shim).
|
||||
|
||||
Mutants: `unreadable-read-clear` (every failed read skipped), `vanished-is-error` (no directory check, so
|
||||
an exited process is an error), `read-errors-ignored` (no final error exit) and `self-read-unchecked` (its
|
||||
own failed read ends the walk, as before).
|
||||
|
||||
### F2: the snapshot exclusion matched a substring
|
||||
|
||||
What: any command line holding `/shell-snapshots/snapshot-` was skipped, so a real `node --test` of a file
|
||||
under a `shell-snapshots` directory read as CLEAR.
|
||||
|
||||
Fix: `RE_SNAPSHOT` matches only the wrapper's shape: a shell (`sh`, `bash` or `zsh`, with or without a
|
||||
path), options that include `-c`, then `source` or `.` of a `shell-snapshots/snapshot-*.sh` file as the
|
||||
first command. Any other command line that names such a path goes through the rules.
|
||||
|
||||
Tests: "busy on: node --test /seat/tests/shell-snapshots/snapshot-guard.test.mjs (node --test)" and "busy
|
||||
on: bash /seat/shell-snapshots/snapshot-gate.sh (gate)".
|
||||
|
||||
Mutant: `snapshot-substring` (the old substring test put back).
|
||||
|
||||
### F3: an existing tag could be replaced or moved
|
||||
|
||||
What: tags went through the ancestor check, and `git merge-base --is-ancestor` peels a tag. A new annotated
|
||||
tag object on the same commit, or a lightweight tag moved to a descendant, passed as a fast-forward.
|
||||
|
||||
Fix: after the delete and new-ref checks and before the object and ancestor checks, a `refs/tags/*` ref
|
||||
whose remote object name isn't zero and differs from the local one is refused ("an existing tag can't be
|
||||
moved or replaced"). A new tag still passes, and a tag delete is still refused as a delete. This corrects
|
||||
the tag line in "Known limits" above: a moved tag was refused only when it left its line, not when
|
||||
it moved to a descendant or was re-made on the same commit.
|
||||
|
||||
Tests, section "tags": "a new annotated tag passes", "push --force of a new tag object on the same commit
|
||||
is refused", "the remote tag is still the first tag object", "a new lightweight tag passes", "push --force
|
||||
of a lightweight tag moved to a descendant is refused", "the remote lightweight tag hasn't moved" and "a
|
||||
tag delete is refused, and the tag stays".
|
||||
|
||||
Mutant: `tag-replace-passes`.
|
||||
|
||||
### F4: a symlinked hooks directory
|
||||
|
||||
What: the installer wrote through `.git/hooks` even when it was a symlink, so an install could set the hook
|
||||
of every repository sharing that directory, or write outside the repository.
|
||||
|
||||
Fix: `own_hooks` refuses (exit 2) when `<common>/hooks` is a symlink, or when it exists and its physical
|
||||
path isn't the common directory's physical path plus `/hooks`. It runs before the pre-push symlink check
|
||||
and again after `mkdir -p`, so both checks come before the temporary file and any install write. The
|
||||
existing refusals (`core.hooksPath`, a different hook without `--force-install`, a symlinked `pre-push`)
|
||||
are unchanged.
|
||||
|
||||
Tests: "the install refuses a symlinked hooks directory (exit 2)", "it refuses it with --force-install too"
|
||||
and "nothing was written in the directory the symlink names".
|
||||
|
||||
Mutant: `hooks-dir-symlink-followed` (`own_hooks` returns at once).
|
||||
|
||||
### F5: the snapshot fixture proved nothing
|
||||
|
||||
What: the fixture wrapper ran `eval 'node --test x.test.mjs'`. There `node` follows a quote, and the node
|
||||
rule needs a space or `/` before it, so the fixture wasn't BUSY even without the exclusion and the
|
||||
`snapshot-matched` mutant survived.
|
||||
|
||||
Fix: two wrappers whose text matches a rule without the exclusion. Pid 4194403 runs `node --test
|
||||
x.test.mjs` straight after the `source ... &&`. Pid 4194405 has the harness's real shape: `source ...
|
||||
2>/dev/null || true && eval 'bash scripts/test-x.sh > x.log' && pwd -P >| ...`. The paired BUSY case is the
|
||||
same node command under `/bin/bash -c` with no snapshot source. The F2 cases are above.
|
||||
|
||||
Tests: "an agent's shell-snapshot wrapper isn't a match" (now neither 4194403 nor 4194405) and "busy on:
|
||||
/bin/bash -c node --test x.test.mjs (node --test)".
|
||||
|
||||
Mutant: `snapshot-matched`, whose site is now the `RE_SNAPSHOT` test. It is killed (3 FAIL). The suite
|
||||
alone can't fail before this fix, because the old substring exclusion skips these wrappers too; the killed
|
||||
mutant is the before-and-after evidence.
|
||||
|
||||
### Object names of the wrong length (the review's table)
|
||||
|
||||
What: the hook took any hex string as an object name, so a remote field of `0` read as a new ref.
|
||||
|
||||
Fix: after the non-hex check, each field must be exactly 40 or 64 characters, or the ref is refused.
|
||||
|
||||
Tests: "a remote object name of 0 is refused, not read as a new ref", "a 39-character local object name is
|
||||
refused" and the control "a 64-character object name passes the length check (64 zeros refuse as a
|
||||
delete)".
|
||||
|
||||
Mutant: `short-sha-accepted`.
|
||||
|
||||
### What didn't change
|
||||
|
||||
The earlier cases all still pass: an empty push, a new branch and a fast-forward pass; a delete, `--force`,
|
||||
`+refspec` and `--force-with-lease` rewrites are refused; a remote tip missing locally is refused with
|
||||
"fetch first", and nothing is fetched.
|
||||
|
||||
### R3 runs
|
||||
|
||||
`TMPDIR` was a fresh `mktemp -d /mnt/storage/scratch/tmp/XXXXXX`. Every run was in the foreground, with
|
||||
output to files there.
|
||||
|
||||
- RED, all 24 new cases in place and no fix: 67 passed, 18 failed, 2026-11-02 19:27:01Z to 19:27:06Z. The
|
||||
six new cases that pass there are controls that must hold before and after: both new tags pass, the tag
|
||||
delete is refused, the 64-character control, the bare `bash -c` node case and the vanished process.
|
||||
- GREEN: 85 passed, 0 failed, 19:28:58Z to 19:29:04Z. The run before it gave 80 passed, 5 failed: the new
|
||||
closing error said "not CLEAR", which the "no CLEAR" assertions caught. It now says "the host isn't
|
||||
known to be idle".
|
||||
- Mutants: 19:30:11Z to 19:33:22Z, base green (85/0), runner exit 0, 21 of 21 killed, none survived, no
|
||||
NO MATCH. Every kill exited 1.
|
||||
|
||||
| Mutant | FAIL | First failing case |
|
||||
|---|---|---|
|
||||
| ancestor-dropped | 8 | push --force of a rewritten branch is refused |
|
||||
| unknown-object-passes | 2 | a push over a remote tip missing locally is refused, saying fetch first |
|
||||
| delete-passes | 12 | the install into a clean clone exits 0 |
|
||||
| install-over-hookspath | 2 | it says core.hooksPath is set |
|
||||
| busy-exits-0 | 14 | a node --test process: exit 1 |
|
||||
| differing-hook-replaced | 3 | the install refuses a different installed pre-push (exit 2) |
|
||||
| replace-in-place | 1 | the replacement was a rename: the old file keeps its bytes |
|
||||
| symlink-followed | 1 | the install refuses a symlinked pre-push, even with --force-install |
|
||||
| ancestor-error-passes | 1 | a failed ancestor check (an unknown local object) is refused |
|
||||
| snapshot-matched | 3 | no matching process: exit 0 and CLEAR |
|
||||
| ancestors-matched | 1 | this suite, an ancestor, has no BUSY line |
|
||||
| no-node-rule | 9 | a node --test process: exit 1 |
|
||||
| no-compose-rule | 2 | busy on: docker compose -p x up -d (docker compose) |
|
||||
| unreadable-read-clear | 6 | a pid directory with no cmdline: exit 2 |
|
||||
| vanished-is-error | 1 | a process that vanishes during its read isn't an error: exit 0 and CLEAR |
|
||||
| read-errors-ignored | 6 | a pid directory with no cmdline: exit 2 |
|
||||
| self-read-unchecked | 1 | its own process unreadable (awk exits 1): exit 2, no CLEAR |
|
||||
| snapshot-substring | 2 | busy on: node --test /seat/tests/shell-snapshots/snapshot-guard.test.mjs (node --test) |
|
||||
| tag-replace-passes | 4 | push --force of a new tag object on the same commit is refused |
|
||||
| hooks-dir-symlink-followed | 3 | the install refuses a symlinked hooks directory (exit 2) |
|
||||
| short-sha-accepted | 2 | a remote object name of 0 is refused, not read as a new ref |
|
||||
|
||||
- Real host: `bash scripts/slot-busy.sh` on the real `/proc` exited 1 on other seats' gate and `node
|
||||
--test` runs, with no error line. Both live shell-snapshot wrappers on the host matched `RE_SNAPSHOT`.
|
||||
- Pins: `git grep -nE '[0-9a-f]{64}' -- 'packages/*/tests/*' 'scripts/test-*.sh'` gives 33 lines (the
|
||||
positive control). None names a path this round changes. The only test that names one is
|
||||
`scripts/test-git-guard.sh` itself, and no test reads `docs/TOOLS.md`.
|
||||
|
||||
### Known limits after R3
|
||||
|
||||
- The tag line in "Known limits" above is superseded by F3. The other two lines still hold.
|
||||
- The resolved-path refusal in `own_hooks` has no test of its own. A hooks directory that isn't a symlink
|
||||
but resolves elsewhere needs a bind mount, so root, and the symlink check catches the symlink case first.
|
||||
`hooks-dir-symlink-followed` turns off both checks together.
|
||||
- A wrapper that sources a test script into its own shell, with no child process, is still skipped, as
|
||||
before R3. That script's children are still matched.
|
||||
- The installer's temporary file is named by pid (`.pre-push.install-git-hooks.$$`). R3 leaves it alone.
|
||||
- The "Runs" section above was written before any run. The R3 runs here are the ones on record for this
|
||||
round.
|
||||
@@ -68,7 +68,16 @@ run differing-hook-replaced $I '[ "$FORCE" = 1 ] || die 2 "refused: a different'
|
||||
run replace-in-place $I 'mv -f -- "$tmp" "$HOOK" ||' 'cat -- "$tmp" > "$HOOK" && rm -f -- "$tmp" ||'
|
||||
run symlink-followed $I 'if [ -L "$HOOK" ]; then die 2' 'if false; then die 2'
|
||||
run ancestor-error-passes $H ' *) refuse "$rref: the ancestor check failed' ' *) : "$rref: the ancestor check failed'
|
||||
run snapshot-matched $S $' if [[ "$c" == *"/shell-snapshots/snapshot-"* ]]; then return 1; fi\n' ''
|
||||
run snapshot-matched $S $' if [[ "$c" =~ $RE_SNAPSHOT ]]; then return 1; fi\n' ''
|
||||
run ancestors-matched $S ' [ -z "${SKIP[$pid]:-}" ] || continue' ' :'
|
||||
run no-node-rule $S 'if [[ "$c" =~ $RE_NODE ]]; then echo "node --test"; return 0; fi' ':'
|
||||
run no-compose-rule $S 'if [[ "$c" =~ $RE_COMPOSE ]]; then echo "docker compose"; return 0; fi' ':'
|
||||
# R3, the GPT review (F1 to F5 and the object-name length check).
|
||||
run unreadable-read-clear $S ' [ -e "$d" ] || continue' ' continue'
|
||||
run vanished-is-error $S $' [ -e "$d" ] || continue\n' ''
|
||||
run read-errors-ignored $S '[ "$errors" = 0 ] || {' 'true || {'
|
||||
run self-read-unchecked $S ' || { echo "slot-busy: error: cannot read its own process" >&2; exit 2; }' ' || p=""'
|
||||
run snapshot-substring $S '[[ "$c" =~ $RE_SNAPSHOT ]]' '[[ "$c" == *"/shell-snapshots/snapshot-"* ]]'
|
||||
run tag-replace-passes $H 'if [ "${rref#refs/tags/}" != "$rref" ] && [ "$lsha" != "$rsha" ]; then' 'if false; then'
|
||||
run hooks-dir-symlink-followed $I 'own_hooks() {' 'own_hooks() { return 0;'
|
||||
run short-sha-accepted $H ' if ! idlen "$lsha" || ! idlen "$rsha"; then' ' if false; then'
|
||||
Reference in new issue
Block a user