Skip to content

test(guardrails): 4 block-root-delete-target allowed-roots assertions fail on Windows Git Bash #6627

Closed

Description

@kyle-sexton

Problem

On Windows Git Bash, four assertions in plugins/guardrails/hooks/block-root-delete-target.test.sh (section 2d, allowed roots) fail. They fail the same way on origin/main (a1a8368) as on the #6542 branch, so the suite cannot go fully green locally on Windows. CI is Linux, and the Windows lane does not run this suite.

Failing assertions and output

FAIL: allowed roots: a relative root grants nothing (direct): expected exit 2, got 0
FAIL: allowed roots: a relative root grants nothing (dispatched): expected exit 2, got 0
FAIL: allowed roots: the root '/' does not allow a top-level path (direct): expected exit 2, got 0
FAIL: allowed roots: the root '/' does not allow a top-level path (dispatched): expected exit 2, got 0

Root-cause hypotheses (test fixtures, not the hook)

  1. a relative root grants nothing passes "${RDT_AR#/}" as a "relative" entry. On Windows, RDT_TOP comes from git rev-parse --show-toplevel, which returns the drive form (D:/worktrees/...). #/ therefore strips nothing, and the entry is a valid absolute root that correctly allows $RDT_AR/child. The test does not build a relative entry on this host. Evidence: git rev-parse --show-toplevel printed D:/worktrees/melodic-software-claude-code-plugins-fix-6542-allowed-roots-prefix.
  2. the root '/' does not allow a top-level path lists / and expects rm -rf /opt/rdt-allowed-x/y to stay refused. Under MSYS, / is the Git install directory (cygpath -m / prints C:/Program Files/Git/). That is not a filesystem root, so rdt_root_like does not drop the entry, and /opt/... lies strictly under it, so the delete is allowed.

Suggested fix

  • Build the relative entry from a path that is certainly relative on every host, e.g. strip the drive or leading slash with a host-aware helper.
  • Skip or re-target the / case on MSYS, where / is not the volume root.
  • Decide whether the hook should also refuse an entry spelled / on Windows. It names the Git install directory, which is probably never what a user means.

Related: #6020. Found while working #6542 (PR #6624).

Activity

  1. added
    needs-triage
    on Oct 8, 2026
  2. github-actions commented on Oct 8, 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 8, 2026
  4. kyle-sexton commented on Oct 11, 2026

    @kyle-sexton
    MemberAuthor

    Owner decision (2026-10-11): Fix the Windows Git Bash fixtures only (guard behavior unchanged), and file a separate issue for whether a literal '/' in allowed roots should count as a root under Git Bash. Lands after #7186 and #7071.

    Recorded by the coordinating agent session with the owner's approval. Removing needs-human; implementation is queued and will link its branch here.

  5. added and removed
    needs-human
    needs-triage
    on Oct 11, 2026
  6. added theissue type on Oct 15, 2026
  7. kyle-sexton commented on Oct 18, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded.

    Question: How should the four block-root-delete-target allowed-roots assertions that fail on Windows Git Bash be fixed?

    Owner's answer: Fix only the Windows Git Bash test fixtures and leave guard behavior unchanged; whether a literal / in allowed roots counts as a root under Git Bash goes to a separate issue. It lands after #7186 and #7071, both merged.

    The owner confirmed this decision, first recorded at #6627 (comment), in an attended backlog-shaping session on 2026-10-18. The question was "Confirm the 10 decisions, #7287's kill-switch hardening included, and admit them to the paced queue?" and the owner answered "Yes, all 10 (Recommended)".

    Posted by AI from the owner's answer in that session.

  8. kyle-sexton commented on Oct 18, 2026

    @kyle-sexton
    MemberAuthor

    Agent Brief

    Type: Bug
    Summary: Make the block-root-delete-target allowed-roots test fixtures host-aware so the suite passes on Windows Git Bash, with no change to the guard.

    Current behavior:
    In the allowed-roots section of the block-root-delete-target test suite, two cases (four assertions, direct and dispatched) fail on Windows Git Bash. a relative root grants nothing builds its relative entry by stripping a leading / from the allowed-root path, but on Windows the repository top level comes back in drive form (D:/...), so nothing is stripped and the entry is a valid absolute root. the root '/' does not allow a top-level path lists /, which under MSYS is the Git install directory rather than a volume root, so /opt/... sits under it and the delete is allowed.

    Desired behavior:
    The relative-root case always passes an entry that is relative on every host (no drive prefix and no leading slash). The / case runs where / is the volume root and is skipped, with a printed skip reason, under MSYS/Git Bash where / is not. The guard's own behavior is unchanged. On Linux every case in the suite still passes.

    Key interfaces:

    • The allowed-roots test helper (rdt_ar) and its fixtures: inputs change, the guard under test does not.
    • Host detection in the test suite (for example cygpath presence or uname), used only to choose or skip a fixture.

    Acceptance criteria:

    • The diff touches only the block-root-delete-target test suite (and a guardrails changelog fragment), not the hook.
    • The relative-root fixture is built without relying on the top-level path starting with /.
    • The / case is skipped with a printed reason when / is not a volume root (MSYS), and still runs elsewhere.
    • scripts/run-test-file.sh plugins/guardrails/hooks/block-root-delete-target.test.sh passes.
    • A guardrails changelog fragment is added and scripts/check-changelog-fragments.sh passes.

    Out of scope:

    • Changing whether the hook treats a literal / in allowed roots as a root under Git Bash: that question is a separate issue, filed outside this PR.
    • Running the suite on Windows Git Bash (done after merge by someone with a Windows host).
    • Any other guardrails guard or test section.

    This was generated by AI during backlog shaping. The owner approved its admission in an attended backlog-shaping session on 2026-10-18.

  9. added
    agent-ready
    on Oct 18, 2026
  10. added
    needs-human
    on Oct 18, 2026
  11. melodic-automation-lanes commented on Oct 18, 2026

    @melodic-automation-lanes
    Contributor

    The lanes App's pull request #8127 links this issue with Refs:, not Closes, so the merge lane never merges it. report-outcome added needs-human so a person merges or closes it. When it merges, work-unblock removes this needs-human and agent-ready and adds needs-triage, so triage decides what work is left. To keep the issue held after the merge, add needs-owner-decision.

  12. melodic-automation-lanes commented on Oct 18, 2026

    @melodic-automation-lanes
    Contributor

    The lanes App's pull request #8127 merged with Refs:, so this issue stays open and nothing starts the lane on it again. work-unblock added needs-triage and removed agent-ready, so triage decides what work is left.

  13. added
    needs-triage
    and removed
    needs-human
    agent-ready
    on Oct 18, 2026
  14. kyle-sexton commented on Oct 19, 2026

    @kyle-sexton
    MemberAuthor

    Fixtures fixed by #8127. The separate '/' allowed-root question is now #8414.

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-triage

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions