Skip to content

The Husky Snippet's Prose Gate Skips Silently When Its Second git diff Fails #4122

Closed

Description

@ptr727

Finding

catalog/snippets/husky/pre-commit runs git diff --cached --name-only --diff-filter=ACMRT -z twice. The first run is a preflight, >/dev/null || exit 1. The second is the producer piped into xargs -0 sh -c '... exec uv run ... prose_lint.py ...'.

The snippet's own comment gives the reason for the preflight: "a pipeline hides a failure of its first command". But the preflight only proves the first invocation succeeded. The hook is POSIX sh with no pipefail, so a failure of the second invocation is still hidden. That second invocation is the one whose output the gate actually reads. If it fails after the preflight passes, it emits nothing. xargs then gets empty input, the inner sh sees $# -eq 0 and exits 0, and the commit proceeds with the prose gate never run.

GitHub Copilot raised it on ptr727/LanguageTags#503 against .husky/pre-commit, whose lines from the hook header on are the snippet byte for byte at hub 009d3e5e. So the fix belongs here at the source.

Expected

The path list is produced once and its exit status checked before the gate reads it. For example, capture it NUL-safely to a temporary file under the hook's control and feed that file to xargs -0. Or have the inner sh refuse when the producer failed, so a failed producer refuses the commit rather than skipping the gate.

Actual

The preflight checks a different invocation from the one feeding the gate, so a producer failure skips the prose gate silently. Per GOVERNANCE.md "Trust Boundaries and Hardening Effort" the input is trusted and the failure unlikely. It is silent, though, which is the case that section says earns a fix.

Activity

  1. ptr727 commented on Nov 13, 2026

    @ptr727
    OwnerAuthor

    Backlog burndown claim, round 1 (2026-11-13), away run, scope develop. Branch burndown/husky-snippet-gate, group: #4122, #4104, #4121. Tier: frontier (carried catalog hook snippets and the gate they run).

    Predicted files:

    • catalog/snippets/husky/pre-commit
    • catalog/snippets/husky/README.md
    • catalog/snippets/pre-commit/.pre-commit-config.yaml
    • catalog/snippets/pre-commit/README.md
    • .husky/pre-commit
    • tests/test_pre_commit_hook.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions