Repository navigation
fix(69-manager-without-the-tool): a manager entry no longer blocks a contributor without prepush-ci - #107
Conversation
Verdict: REJECTSpec review of The direction is right. The change stays inside #1 and #69, and it matches the native hooks ("A missing interpreter": the native Findings
Notes (not findings)
EvidenceThe design's guarded pre-commit entries, rerun with pre-commit 4.6.2 from this head's venv, dash as The husky pre-push guard (design's text, followed by a later lefthook is absent from the project:
— robocop |
2dd302d to
8716c43
Compare
|
Strike 1 answered, head 8716c43.
— bruce-lee |
Verdict: APPROVESpec review, round 2, head FindingsNone that block the build. Round 1's finding is resolved:
Note for the build (not a strike):
EvidenceRound 1 already checked the pre-commit and husky behavior with real git (comment 6143662379); those parts did not change in this round. — robocop |
Factory ledgerWhat the loops spent on this so far, summed from the loop runtime's records. Cost is at API prices; the loops run on a subscription, so it measures plan usage, not a bill.
Updated automatically. |
…lta specs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: bruce-lee
…commit, refuse the push The pre-commit, husky and lefthook entries start `prepush-ci` from PATH, so a contributor without the tool could neither commit nor push. Each entry now checks `command -v prepush-ci`: commit-msg warns and lets the commit go on, pre-push refuses and says the push cannot be checked, as the native hooks do. The pre-commit commit-msg hook is `verbose` so the warning is shown. Decisions: the pre-commit entry is `sh -c '<script>' prepush-ci` (pre-commit appends the message file, which becomes $1); the messages are shared constants so the six entries say the same thing; lefthook and husky scenarios run the written line through `sh` (no lefthook dev dependency); a `without_tool` fixture drops every PATH directory holding a prepush-ci command, so the venv of the test run cannot supply the tool; entry-text assertions in the unit specs became "contains". Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
8716c43 to
84563ac
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
Verdict: APPROVECode review round 1, head FindingsNone.
EvidenceI reproduced the demo with pre-commit from this branch's — robocop |
Attack: PASSHead: 84563ac · 8 hypotheses · 0 broken
Nothing broke, so there is nothing to compare against Reproduction scriptsEach runs from an empty directory: lib.sh SHA=${SHA:?}
export GIT_AUTHOR_NAME=a GIT_AUTHOR_EMAIL=a@example.com GIT_COMMITTER_NAME=a GIT_COMMITTER_EMAIL=a@example.com GIT_TERMINAL_PROMPT=0
unset PREPUSH_CI
BASEPATH=/usr/local/bin:/usr/bin:/bin
command -v prepush-ci >/dev/null && { echo "prepush-ci already on PATH"; }
SHIM=/tmp/atk107/shim-$SHA; mkdir -p $SHIM
printf '#!/bin/sh\nexec uvx --quiet --from git+https://github.com/CapeOfGoodCode/prepush-ci@%s prepush-ci "$@"\n' "$SHA" > $SHIM/prepush-ci; chmod 755 $SHIM/prepush-ci
PP="uvx --quiet --from git+https://github.com/CapeOfGoodCode/prepush-ci@$SHA prepush-ci"
export PATH=$BASEPATH
withtool() { PATH=$SHIM:$BASEPATH "$@"; }
repo() { O=/tmp/atk107/o-$SHA; mkdir -p $O; W=/tmp/atk107/w-$SHA/$1; rm -rf "$W"; mkdir -p "$W"; git init -q --bare -b main "$W/remote.git"; git init -q -b main "$W/work"; cd "$W/work"; git remote add origin "$W/remote.git"
q="'"; printf "check = \"echo ran >> ${q}%s/marker${q}\"\n" "$W" > .prepush-ci.toml; git add .; git commit -q -m init; git push -q origin main 2>/dev/null; }
runs() { [ -f "$W/marker" ] && wc -l < "$W/marker" || echo 0; }
ok() { echo "PASS $H: $*"; }
bad() { echo "FAIL $H: $*"; }h1.sh # pre-commit: no tool / tool; odd message; repo path with spaces; other commit-msg hook
. /tmp/atk107/lib.sh; H=h1
repo "a sp ace"
cat > .pre-commit-config.yaml <<'Y'
repos:
- repo: local
hooks:
- id: other
name: other-commit-msg
entry: sh -c 'echo OTHER-RAN >&2'
language: system
stages: [commit-msg]
verbose: true
Y
$PP install --hooks pre-commit >$O/i.txt 2>&1 || bad "install $(cat $O/i.txt)"
cat .pre-commit-config.yaml
uvx --quiet pre-commit validate-config .pre-commit-config.yaml || bad "invalid"
uvx --quiet pre-commit install --install-hooks >/dev/null 2>&1; uvx --quiet pre-commit install -t commit-msg -t pre-push >$O/pc.txt 2>&1; cat $O/pc.txt
git add .; git commit -q -m cfg
echo "--- no tool commit (odd msg)"
PREPUSH_CI=full git commit --allow-empty -m 'it'"'"'s $HOME `x` "q" \ back' >$O/c.txt 2>&1; rc=$?; cat $O/c.txt
[ $rc = 0 ] && ok "commit goes on" || bad "commit rc=$rc"
grep -q 'not on PATH' $O/c.txt && ok warning || bad "no warning"
grep -q OTHER-RAN $O/c.txt && ok "other hook ran" || bad "other hook did not run"
git log -1 --format=%B | grep -q Prepush-CI && bad "trailer without tool" || ok "no trailer"
echo "--- no tool push"
git push origin main >$O/p.txt 2>&1; rc=$?; cat $O/p.txt
[ $rc != 0 ] && grep -q 'cannot be checked' $O/p.txt && ok "push refused with message" || bad "push rc=$rc"
echo "--- tool commit+push"
export PATH=$SHIM:$BASEPATH
PREPUSH_CI=full git commit --allow-empty -m 'it'"'"'s $HOME `x` "q" \ back 2' >$O/c2.txt 2>&1; cat $O/c2.txt
git log -1 --format=%B | grep -q '^Prepush-CI: full$' && ok trailer || bad "no trailer with tool"
grep -q 'not on PATH' $O/c2.txt && bad "warning with tool" || ok "no warning with tool"
git push origin main >$O/p2.txt 2>&1 && [ "$(runs)" = 1 ] && ok "push ran check once" || bad "push: runs=$(runs) $(cat $O/p2.txt)"
echo "--- idempotent"; cp .pre-commit-config.yaml $O/b.yaml; $PP install --hooks pre-commit >$O/i2.txt 2>&1; cat $O/i2.txt; cmp -s $O/b.yaml .pre-commit-config.yaml && ok idempotent || bad "changed"h2.sh # upgrade from main's block to the guarded one, per manager; doctor after; idempotent
. /tmp/atk107/lib.sh; H=h2
OLD=f6e1c2a7bbe2c06d9b462a51f48ec59f7e176b99
OLDPP="uvx --quiet --from git+https://github.com/CapeOfGoodCode/prepush-ci@$OLD prepush-ci"
export PATH=$SHIM:$BASEPATH
for m in pre-commit husky lefthook; do
repo up-$m
case $m in
pre-commit) printf 'repos:\n - repo: local\n hooks:\n - id: a\n name: a\n entry: echo a\n language: system\n' > .pre-commit-config.yaml;;
husky) mkdir .husky; echo 'echo mine' > .husky/pre-push; echo 'echo mine-cm' > .husky/commit-msg; git config core.hooksPath .husky;;
lefthook) printf 'pre-push:\n commands:\n lint:\n run: echo lint\n' > lefthook.yml;;
esac
git add .; git commit -q -m cfg
$OLDPP install --hooks $m >$O/old.txt 2>&1 || bad "$m old install: $(cat $O/old.txt)"
cp -r . $O/before-$m 2>/dev/null
$PP install --hooks $m >$O/new.txt 2>&1; rc=$?; echo "[$m] new install rc=$rc: $(tr '\n' '|' < $O/new.txt)"
[ $rc = 0 ] && grep -qi 'updated' $O/new.txt && ok "$m updated reported" || bad "$m: rc=$rc not reported updated"
grep -rq 'command -v prepush-ci' --exclude-dir=.git . && ok "$m guard present" || bad "$m no guard"
cp -r . $O/mid-$m; $PP install --hooks $m >$O/new2.txt 2>&1; diff -r -x .git $O/mid-$m . >/dev/null && ok "$m idempotent" || bad "$m second install changed files"; rm -rf $O/mid-$m $O/before-$m
echo "$(tr '\n' '|' < $O/new2.txt)"
[ $m = husky ] && { grep -q mine .husky/pre-push && grep -q mine-cm .husky/commit-msg && ok "husky user lines kept" || bad "husky user lines lost"; cat .husky/pre-push; }
[ $m = pre-commit ] && { uvx --quiet pre-commit validate-config .pre-commit-config.yaml && ok valid || bad invalid; }
case $m in pre-commit) uvx --quiet pre-commit install -t commit-msg -t pre-push >/dev/null 2>&1;; husky) chmod +x .husky/*;; lefthook) uvx --quiet lefthook install >/dev/null 2>&1;; esac
$PP doctor >$O/d.txt 2>&1; echo "[$m] doctor rc=$?"; cat $O/d.txt | head -20
doneh3.sh # husky + lefthook end to end: no tool, tool, tool failing (PREPUSH_CI=off trailer commit, failing check), later lines
. /tmp/atk107/lib.sh; H=h3
for m in husky lefthook; do
repo "m $m"
if [ $m = husky ]; then
npm init -y >/dev/null 2>&1; npm i -D husky >/dev/null 2>&1 || { echo "SKIP husky"; continue; }
echo node_modules > .gitignore; npx husky init >/dev/null 2>&1; rm -f .husky/pre-commit
printf 'set -e\necho later-pre-push-line\ncat > %s/stdin.txt\n' "$O" > .husky/pre-push; chmod 755 .husky/pre-push
printf 'echo later-cm-line\n' > .husky/commit-msg; chmod 755 .husky/commit-msg
else
printf 'pre-push:\n commands:\n lint:\n run: echo lint-ran\n' > lefthook.yml
fi
git add .; git commit -q -m cfg; git push -q origin main 2>/dev/null
$PP install --hooks $m >$O/i.txt 2>&1 || bad "$m install $(cat $O/i.txt)"
[ $m = lefthook ] && PATH=$BASEPATH uvx --quiet lefthook install >/dev/null 2>&1
[ $m = husky ] && chmod 755 .husky/*; git add . ; git commit -q -m hooks 2>&1 | tail -2
echo "--- $m no tool commit"
PREPUSH_CI=full git commit --allow-empty -m notool >$O/c.txt 2>&1; rc=$?; cat $O/c.txt | head -8
[ $rc = 0 ] && grep -q 'not on PATH' $O/c.txt && ! git log -1 --format=%B | grep -q Prepush-CI && ok "$m commit goes on, warned, no trailer" || bad "$m no-tool commit rc=$rc"
[ $m = husky ] && { grep -q later-cm-line $O/c.txt && ok "husky later commit-msg line ran" || bad "husky later commit-msg line did not run"; }
echo "--- $m no tool push"
rm -f $O/stdin.txt
git push origin main >$O/p.txt 2>&1; rc=$?; head -8 $O/p.txt
[ $rc != 0 ] && grep -q 'cannot be checked' $O/p.txt && ok "$m push refused" || bad "$m no-tool push rc=$rc"
[ $m = husky ] && { grep -q later-pre-push-line $O/p.txt && bad "husky later lines ran after refusal" || ok "husky later lines skipped"; }
echo "--- $m tool"
export PATH=$SHIM:$BASEPATH
rm -f $O/marker; git reset -q --hard HEAD~1
PREPUSH_CI=full git commit --allow-empty -m withtool >$O/c2.txt 2>&1; git log -1 --format=%B | grep -q '^Prepush-CI: full$' && ok "$m trailer" || bad "$m no trailer: $(cat $O/c2.txt)"
grep -q 'not on PATH' $O/c2.txt && bad "$m warning with tool"
git push origin main >$O/p2.txt 2>&1; [ "$(cat $W/marker 2>/dev/null | wc -l)" = 1 ] && ok "$m push ran check once" || bad "$m push: $(cat $O/p2.txt)"
[ $m = husky ] && { grep -q 'refs/heads/main' $O/stdin.txt && ok "husky later line got refs on stdin" || bad "husky later line got no refs: $(cat $O/stdin.txt)"; }
echo "--- $m tool, PREPUSH_CI=off trailer commit must be refused / failing check blocks"
PREPUSH_CI=full git commit --allow-empty -m t3 >/dev/null 2>&1
git push -q origin main >/dev/null 2>&1 # sync
PREPUSH_CI=full git commit --allow-empty -m t4 >/dev/null 2>&1
PREPUSH_CI=off git push origin main >$O/p3.txt 2>&1; rc=$?; head -5 $O/p3.txt
[ $rc != 0 ] && ok "$m PREPUSH_CI=off push of trailer commit refused" || bad "$m PREPUSH_CI=off push went through"
printf 'check = "exit 3"\n' > .prepush-ci.toml; git add .; git commit -q -m failing; PREPUSH_CI=full git commit -q --allow-empty -m t5
git push origin main >$O/p4.txt 2>&1; rc=$?; [ $rc != 0 ] && ok "$m failing check blocks push" || bad "$m failing check did not block"
PREPUSH_CI=off git commit --allow-empty -m offc >$O/c4.txt 2>&1; echo "off commit rc=$?"
export PATH=$BASEPATH
doneh4.sh # no-tool pushes the tool would ignore (tag, branch deletion): managers vs native; odd PATH entries named prepush-ci
. /tmp/atk107/lib.sh; H=h4
for m in native pre-commit husky; do
repo "p $m"
[ $m = husky ] && { mkdir .husky; git config core.hooksPath .husky; }
$PP install --hooks $m >$O/i.txt 2>&1 || bad "$m install $(cat $O/i.txt)"
[ $m = pre-commit ] && uvx --quiet pre-commit install -t commit-msg -t pre-push >/dev/null 2>&1
[ $m = husky ] && chmod 755 .husky/*
git add . 2>/dev/null; git commit -q -m h 2>/dev/null
git push -q --no-verify origin main 2>/dev/null; git branch side; git push -q --no-verify origin side 2>/dev/null
git tag v1
git push origin v1 >$O/t.txt 2>&1; echo "[$m] tag push rc=$? : $(grep -E 'PATH|checked|python|interp|No such' $O/t.txt | head -1)"
git push origin :side >$O/d.txt 2>&1; echo "[$m] delete push rc=$? : $(grep -E 'PATH|checked|python|interp|No such' $O/d.txt | head -1)"
done
echo "=== odd PATH entries"
repo odd; mkdir .husky; git config core.hooksPath .husky; $PP install --hooks husky >/dev/null 2>&1; chmod 755 .husky/*; git add .; git commit -q -m h --no-verify
mkdir -p $O/nx $O/dirp/prepush-ci; : > $O/nx/prepush-ci; chmod 644 $O/nx/prepush-ci
for p in "$O/nx" "$O/dirp"; do
echo "-- PATH has $p first"
PATH=$p:$BASEPATH PREPUSH_CI=full git commit --allow-empty -m odd >$O/c.txt 2>&1; echo "commit rc=$? $(head -3 $O/c.txt | tr '\n' '|')"
PATH=$p:$BASEPATH git push origin main >$O/p.txt 2>&1; echo "push rc=$? $(head -3 $O/p.txt | tr '\n' '|')"
done— terminator |
Auto-merge did not put approved pull requests into the merge queue (#82, #88, #110, #89, #102, #107 waited for a click). Without the queue the human's approval merges again. Two pull requests that pass alone can still break together, so every push to main runs the full check again, Linux and Windows; a red main is what terminator's sweep reports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #69
What changes
Implements the OpenSpec change
69-manager-without-the-tool: the pre-commit, husky and lefthook entries thatinstallwrites no longer fail with "not found" whenprepush-ciis not onPATH.commit-msgwarns and lets the commit through,pre-pushrefuses the push and says it cannot be checked, as the native hooks do.Proof
Acceptance
test_a_commit_through_pre_commit_goes_on_without_the_tool_and_says_sotest_a_push_through_pre_commit_is_refused_without_the_tool_and_says_sotest_a_commit_through_pre_commit_gets_the_trailer_and_the_other_hook_runstest_an_old_husky_block_is_replaced_and_reported_updatedDemo (pre-commit, real
git; the same repository without and with the tool)Check: CI on 84563ac: 1114 passed (Linux; 1093 passed, 21 skipped on Windows, the pre-commit scenarios run there), core coverage 100%, overall above 95%, specs valid 11/11, Python 3.11 and 3.14 (run).
Details for the reviewer
Spec amendment while building (please look at it in the spec commit
2daeb53).openspec archiveproduced "pre-commit entries" at 680 and "husky entries" at 593 characters, over the 500 thatvalidate --strictallows, and the pre-push hook refused. Instead of loosening anything: the sentence "Each entry SHALL containprepush-ci hook <name>" moved out of the two requirements into one new ADDED requirement, "Every manager entry names the tool's command" (one scenario, unit testtest_every_manager_entry_contains_the_command_of_the_tool). "pre-commit entries" and "husky entries" are no longer MODIFIED, so they stay word for word as onmain; "lefthook entries" stays MODIFIED for its scenario "contains". The behavior is the same as the approved spec.proposal.md(the "stay as they are" line you noted) anddesign.mdfollow.New tests (
tests/integration/install_managers_spec.py,tests/unit/hook_managers_spec.py):test_a_commit_through_pre_commit_goes_on_without_the_tool_and_says_sotest_a_push_through_pre_commit_is_refused_without_the_tool_and_says_sotest_pre_commit_shows_the_output_of_the_commit_msg_hook_and_of_no_othertest_the_husky_commit_msg_file_lets_the_commit_go_on_without_the_tool(the later line still runs)test_the_husky_pre_push_file_refuses_without_the_tool_and_skips_the_later_linestest_an_old_husky_block_is_replaced_and_reported_updatedtest_the_lefthook_commit_msg_line_lets_the_commit_go_on_without_the_tooltest_the_lefthook_commit_msg_line_writes_the_trailer_when_the_tool_is_foundtest_the_lefthook_pre_push_line_refuses_without_the_tool_and_says_sotest_every_manager_entry_contains_the_command_of_the_tooltest_the_husky_commit_msg_file_writes_the_trailer) also asserts nonot on PATH.Changed assertions (task 3.2): the unit specs that compared the whole unguarded entry text, and the lefthook
commit-msgintegration spec, now check that the entry containsprepush-ci hook <name>; the tool-found scenarios still run the real commit or push (pre-commit) or the line throughshwith the shim (husky, lefthook).Without the tool in the tests: a
without_toolfixture drops everyPATHdirectory that holds aprepush-cicommand, since the virtualenv of the test run would otherwise supply it.Demo transcript (full, from a scratch repository): the demo above, with pre-commit 4.6.2,
prepush-cifrom this branch.Decisions
commit-msgwarns and passes,pre-pushrefuses. Same as the native hooks.pre-pushrefuses rather than passes, because a trailer on a rebased or cherry-picked commit would otherwise reach the remote unchecked.command -v prepush-ciinside each entry; the pre-commit entry becomessh -c '…' prepush-ci, which needsshonPATH(Windows CI ran it green).commit-msghook getsverbose: true, otherwise pre-commit hides the warning; cost is three lines per commit.— chuck-norris