Skip to content

fix(guardrails): retarget block-noncanonical-commit at shell interpolation in -m, not at newlines #6464

Closed

Description

@kyle-sexton

Problem

block-noncanonical-commit.sh blocks git commit -m when the message contains a newline. Its stated reason (lines 5-10) is that a multi-line -m "flattens newlines unpredictably across shells." That claim came from the old commit skill's list of anti-patterns (776bdde, #72). It became a block in #736 and was narrowed to messages with real newlines in #2058. No reproduced newline failure is cited anywhere.

Tested on 2026-10-05 by passing the message to python -I -c "import sys; print(repr(sys.argv[1]))", which shows the exact argv a program receives:

Shell Argument Received
Bash tool (Git Bash) multi-line, double-quoted, with escaped " and $ exact: 'subject line\n\nBody … "quotes" and $dollar.\n\nCo-Authored-By: …'
PowerShell tool (pwsh 7.6.6, $PSNativeCommandArgumentPassing = Windows) same exact
PowerShell tool single-line "fix: rename `foo` and `bar` to `new` for `$total" mangled: 'fix: rename \x0coo and \x08ar to \new for $total'

So the guard:

  • blocks a safe case: a multi-line message with no special characters.
  • lets the unsafe case through: a double-quoted message containing a backtick or $.
    • In PowerShell, a backtick is the escape character (`f becomes form feed, `b backspace, `n newline) and $ interpolates.
    • In Bash, backticks and $(…) inside double quotes run as command substitution, and $ interpolates.
    • Commit messages often contain code spans in backticks, so this happens in normal use.

Windows PowerShell 5.1's legacy argument passing strips embedded quotes, but neither Claude tool runs 5.1.

Proposal

  • Block git commit -m / --message whose value sits in an interpolating quote context and contains a backtick or $, single-line or multi-line, in both shells:
    • Bash: double quotes, or no quotes.
    • PowerShell: double quotes, or a double-quoted here-string.
  • Allow single-quoted values, single-line or multi-line: Bash '…', PowerShell '…' and @'…'@. Also allow double-quoted values with neither character.
  • Keep git commit -F - --cleanup=verbatim with a quoted heredoc delimiter (<<'EOF') as the form that is always safe, and name it in the block message.
  • Rewrite the header comment and the block message to state the real hazard, with the table above as evidence.
  • Keep the existing exemptions (--amend, -C/-c, --fixup/--squash, -F, an in-progress sequencer), the allow-list option and the kill switch.

Acceptance

  • Tests in both shells:
    • multi-line single-quoted -m: passes
    • multi-line double-quoted plain text: passes
    • single-line double-quoted with a backtick: blocked
    • double-quoted with $: blocked
    • -F - heredoc: passes
  • The block message shows the safe form.
  • Before merging, an empirical check with real git commit -m in a scratch repo, with the guard disabled through its documented setting, confirms git log --format=%B matches the test table.

Related: #6463 (pre-merge state guard).

Activity

  1. added
    needs-triage
    on Oct 6, 2026
  2. github-actions commented on Oct 6, 2026

    @github-actions
    Contributor

    Thanks for the report. Automated triage handed this issue to a maintainer.

    Automated triage. A maintainer reviews it.

  3. added
    needs-human
    on Oct 6, 2026
  4. kyle-sexton commented on Oct 11, 2026

    @kyle-sexton
    MemberAuthor

    Handoff note for whoever picks this up next. The overnight Claude run has stopped, and Kyle is moving issue work to Cursor.

    • Branch: none
    • PR: none
    • State: Skipped: No owner decision recorded (intake note only; the body is Kyle's own proposal: if he counts it as the decision, say so on the issue). One acceptance item needs a Windows pwsh 7.6 check
    • Next step: Pick this up once the open question on the issue has an owner decision recorded.

    Where a branch is listed it is pushed, so it can be taken over as is. A draft PR shows a red ci-status by design until it is marked ready.


    Generated by Claude Code

  5. removed
    needs-triage
    on Oct 12, 2026
  6. added theissue type on Oct 12, 2026
  7. kyle-sexton commented on Oct 13, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded. The owner approved applying independently verified recommendations (high-risk set, reviewed) on 2026-10-13.

    The guard blocks multi-line git commit -m, which tested safe, and lets through double-quoted messages with a backtick or $, which PowerShell mangles. Work was skipped only because no owner decision was recorded on the owner-written proposal.

    Verification notes:

    • Assumption that a Windows pwsh 7.6 host is reachable through /fleet:reach not tested live; FLEET.md lists windows-shell and claude-remote-control endpoints for melo-desk-001, so it is plausible.

    Verified by an independent fresh-context check (confirmed, risk high): gh issue view 6464 (open; handoff 2026-10-11 says skipped for no recorded owner decision); plugins/guardrails/hooks/block-noncanonical-commit.sh:1-30 on origin/main (newline hazard header at 5-10); git log origin/main for that file (no change since #6303); gh pr list search 6464 (none); ~/.config/fleet/FLEET.md desktop endpoints

    Admission to an agent lane stays with the work-class rules and owner ratification.

  8. kyle-sexton commented on Oct 18, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI during backlog shaping.

    Closing as completed. PR #7627 retargeted block-noncanonical-commit at $ and backticks in interpolating -m values, and the hook header now states that hazard with the 2026-10-05 measurement instead of the newline claim.

    Evidence:

    The owner approved this in an attended backlog-shaping session on 2026-10-17.

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

    needs-human

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions