openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

pre-push hook: ungated workspace clippy blocks every push when main is red, and lint:commands-tokens cannot fail

Open M3gA-Mind opened this issue 2 months ago • 3 comments

Summary

Two independent defects in .husky/pre-push:

  1. pnpm rust:clippy runs ungated on every push, so any clippy error anywhere in openhuman / openhuman-cli / openhuman-tinyhumans blocks every push from the repo — a README edit, a frontend-only change, all of it. main currently carries such an error, so this is live right now.
  2. lint:commands-tokens is a vacuous gate — its exit code is discarded, so it cannot fail the hook.

1. rust:clippy is ungated, so main's breakage blocks everyone

.husky/pre-push:108 runs it unconditionally. There is no changed-file gating anywhere in the file — every conditional is Windows PATH recovery (:38-70), an auto-fix retry (:83, :95), or the final aggregate (:120).

package.json:59:

"rust:clippy": "cargo clippy -p openhuman -p openhuman-cli -p openhuman-tinyhumans -- -D warnings && pnpm --filter openhuman-app rust:clippy"

With -D warnings, one unused import anywhere in those three crates trips :120 for everybody. On main today:

error: unused import: `TranscriptCodec`
  --> crates/openhuman-core/src/agent/session_host/runtime_session.rs:13:39
   = note: `-D unused-imports` implied by `-D warnings`

(That specific import is removed by #6528, which fixes today's instance but not the structure.)

The failure mode is misattribution. The person pushing sees:

Fix the remaining errors above (TypeScript / Rust / cmd-tokens) before re-pushing — these have no auto-fix path.

addressed to them, about a defect in a crate their diff does not touch. There is no way to satisfy it from their own change.

Why this has gone unnoticed: --no-verify is the habitual push. Everyone bypasses the hook by default, so a hook that has been failing on someone else's defect produces no complaints. It imposes its full cost — a whole-workspace clippy on every push — while providing no protection, because the people it would protect are routing around it. A gate that is always bypassed is not a gate.

2. lint:commands-tokens cannot fail the hook

.husky/pre-push:112-117:

set +e
run_check pnpm --dir app run lint:commands-tokens
run_check pnpm --dir app run lint:ui-tokens
CMD_TOKENS_EXIT=$?
set -e

$? is read after the second command, so the first's exit is discarded. CMD_TOKENS_EXIT reflects lint:ui-tokens alone, and :120 tests only that variable. A lint:commands-tokens failure passes silently whenever lint:ui-tokens succeeds.

Runnable proof of the shape:

$ sh -c 'f(){ "$@"; return $?; }; set +e; f false; f true; E=$?; echo "captured: $E"'
captured: 0

This is separate from (1) and survives #6528.

Solution (optional)

For (1), any of:

  • Gate on changed files — skip rust:clippy when the push contains no Rust changes. Matches CI's own changed-area gating and is the smallest change.
  • Scope to the crates touched, rather than the fixed three-crate list.
  • Drop rust:clippy from pre-push entirely and let CI own it. Given that the standing practice is --no-verify, this loses no real coverage and removes a whole-workspace compile from every push.

For (2), capture each exit separately:

run_check pnpm --dir app run lint:commands-tokens
CMD_TOKENS_EXIT=$?
run_check pnpm --dir app run lint:ui-tokens
UI_TOKENS_EXIT=$?

and add $UI_TOKENS_EXIT to the :120 test.

Acceptance criteria

  • [ ] A push containing no Rust changes is not blocked by a pre-existing clippy error elsewhere in the workspace.
  • [ ] A clippy error in the pushed diff still blocks the push.
  • [ ] lint:commands-tokens failing fails the hook — covered by a check that fails today and passes after the fix.
  • [ ] A decision recorded on whether rust:clippy belongs in pre-push at all, given --no-verify is the habitual push.

Related

Found while pushing #6532, when the hook blocked a test-only, single-file change on an error in a crate that PR does not touch. #6528 removes today's offending import. Same family as #6525 and #6526 — breakage on main that main's own CI did not exercise, surfacing on the next contributor as though it were theirs — but the first instance that blocks work rather than misreporting it.

M3gA-Mind avatar Sep 23 '26 09:09 M3gA-Mind

Pre-push hook runs ungated workspace clippy, blocking all pushes when main has a clippy error, and lint:commands-tokens exit code is discarded, making that gate vacuous. Both defects prevent the hook from functioning correctly.

Labelled priority: p1.

tinysweeper avatar Sep 23 '26 09:09 tinysweeper

Third defect: the auto-fix stage rewrites your working tree with other people's fixes

Separate from the two above, and the one most likely to cause damage rather than delay.

When pnpm format:check or pnpm lint fails, the hook runs pnpm format / pnpm lint:fix (:84-85, :96-97) against the whole workspace, then tells you:

Formatting and/or lint auto-fixes have been applied to your working tree. Please re-commit and push again: git add -A && git commit -m 'chore: apply auto-fixes' git push

Because the fix stage is workspace-wide and ungated, what it 'fixes' is whatever is broken on main — not what you changed. Pushing a single-file Rust test change left four unrelated files modified in my tree:

 M app/src/AppRoutes.tsx                                              # prettier; from #6492, owned by #6526
 M app/src/components/assistant-ui/thread-list.tsx                    # prettier; same
 M crates/openhuman-core/.../tool_result_artifacts/mod_tests.rs       # cargo fmt; pre-existing on main
 M crates/openhuman-core/.../session_host/runtime_adapter_tests.rs    # cargo fmt; pre-existing on main

All four are formatting-only and correct in isolation. The problem is the instruction: git add -A sweeps every one of them into your commit, so a PR about something else silently acquires another PR's fixes — colliding with #6526, which already owns two of them.

The failure mode is quiet. The diff looks like formatting, it reviews as harmless, and the conflict only surfaces when both PRs touch the same lines.

Suggested fix

Scope the auto-fix to the files being pushed, or drop the git add -A guidance in favour of naming the files it changed so the author can decide. If the fix stage stays workspace-wide, it should at minimum not recommend a command that commits unrelated work.

Acceptance criteria

  • [ ] A push whose diff is clean does not leave unrelated files modified in the working tree.
  • [ ] The hook never instructs git add -A.

Found while pushing #6542 (frontend-only) and #6532 (a single Rust test file) — neither of which touches any of the four files above.

M3gA-Mind avatar Sep 23 '26 11:09 M3gA-Mind

Picking this up. Plan is to gate the clippy step on whether the push actually carries Rust, and capture both token-lint exits so the commands one can fail again. Leaving the bigger question of whether clippy belongs in pre-push at all for you to call.

obchain avatar Sep 25 '26 07:09 obchain