Skip to content

fix(guardrails): decide whether a literal '/' in allowed roots counts as a root under Git Bash #8414

Closed

Description

@kyle-sexton

Problem

block-root-delete-target drops an allowed root that is a filesystem root, so a / entry in block_root_delete_target_allowed_roots allows nothing on Linux. Under Git Bash the same entry is kept. The guard maps each entry with cygpath before the root check (plugins/guardrails/hooks/block-root-delete-target.sh:2164-2167), and under MSYS / maps to the Git install directory (cygpath -m / prints C:/Program Files/Git/). rdt_root_like (:1374-1376) does not see a root in that path, so the entry survives, and every path the guard maps under it, such as /opt/..., can be deleted recursively.

The owner decided on 2026-10-19 to drop a literal / entry on every host (Decision recorded comment on this issue).

Fix

In plugins/guardrails/hooks/block-root-delete-target.sh, judge the root before the Windows mapping as well as after it:

  1. In the allowed-roots loop (:2164-2167), also drop the entry when its resolved path before mapping, ${RDT_RES[$c]}, is /. Keep the existing checks on the mapped path.
  2. Apply the same check in the name-prefix directory loop (:2168-2173), on ${RDT_RES[${pdir[k]}]}.
  3. Add no OSTYPE gate. The file's header (:40-46) forbids one, and the check is host-independent: on Linux the resolved path is / and is already dropped.
  4. Update the comment above the loops (:2156-2157) to say a / entry is dropped on every host, including where / maps to the Git install directory.

In plugins/guardrails/hooks/block-root-delete-target.test.sh:

  1. Replace the conditional at :1581-1586 with the one unconditional case rdt_ar "the root '/' does not allow a top-level path" 2 'rm -rf /opt/rdt-allowed-x/y' /, and change the comment at :1580 to say the guard drops / even where it maps to the Git install directory.

Changelog: a guardrails fragment with scripts/new-changelog-fragment.sh.

Verification

  • scripts/check-changelog-fragments.sh --check and scripts/check-affected.sh --uncommitted pass. The PR's CI runs block-root-delete-target.test.sh on Linux, where the changed case passes before and after the fix.
  • Merger check, outside the lane (this is a plugins/*/hooks/** change, so a human merges it): run bash plugins/guardrails/hooks/block-root-delete-target.test.sh on a Git Bash host and confirm the case that replaces :1581-1586 passes. Before the fix it fails there. pr-test-windows.yml does not run this file today.

Refs: #6627 (the test fixtures, done by #8127).

Activity

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

    @github-actions
    Contributor

    Proposed work class: work-class: scoped
    Basis: automated intake triage; the lanes App applied this class.

    Size: Small
    Complexity: Low
    Uncertainty: Known
    Flags: none
    Blocked by: none

    Understood: under Git Bash, a literal / allowed-root maps to the Git install directory and so survives the root check. The guard should drop it on every host by also checking the pre-mapping resolved path. The test and a guardrails changelog fragment need matching updates.

    The recorded decision, "go w/ recommendations" (drop it), is at #8414 (comment). It settles the open question, so nothing further is asked.

    The Git Bash test run is a check after merge on a Git Bash host. It does not block triage.

    No duplicates found.

    Automated triage, applied by the lanes App.

  3. added
    needs-human
    on Oct 19, 2026
  4. removed
    needs-triage
    on Oct 19, 2026
  5. added
    needs-owner-decision
    on Oct 19, 2026
  6. kyle-sexton commented on Oct 19, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded.

    Question: Should the literal / be dropped from the allowed roots under Git Bash? Options: drop it, keep it, or make it per-platform.

    Owner's answer (2026-10-19): "go w/ recommendations", which was: drop it.

  7. added
    status: confirmed
    and removed
    needs-owner-decision
    needs-human
    on Oct 19, 2026
  8. kyle-sexton commented on Oct 31, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded.

    The owner chose to drop a literal / entry on every host on 2026-10-19 (decision), and at origin/main the guard still judges only the mapped path (plugins/guardrails/hooks/block-root-delete-target.sh:2694-2702) while the test still branches on cygpath -m / (block-root-delete-target.test.sh:1598-1604; these line numbers replace the body's). The body's Git Bash run stays a check after merge on a Git Bash host, outside the list below, and its "a human merges it" note does not apply. Agents decided this on evidence under standing direction §1.

    Done when

    • In the allowed-roots loop (block-root-delete-target.sh:2694-2697), an entry is also dropped when its resolved path before mapping, ${RDT_RES[$c]}, is /; the existing checks on the mapped path stay.
    • The name-prefix directory loop (:2698-2702) applies the same check to ${RDT_RES[${pdir[k]}]}.
    • No OSTYPE gate is added.
    • The comment above the loops (:2686-2687) says a / entry is dropped on every host, including where / maps to the Git install directory.
    • In block-root-delete-target.test.sh, the conditional at :1598-1604 becomes the one unconditional case rdt_ar "the root '/' does not allow a top-level path" 2 'rm -rf /opt/rdt-allowed-x/y' /, and its comment says the guard drops / even where it maps to the Git install directory.
    • A guardrails changelog fragment exists, and scripts/check-changelog-fragments.sh --check and scripts/check-affected.sh --uncommitted pass.
  9. removed
    status: confirmed
    on Oct 31, 2026
  10. added
    status: ready
    admission-deferred
    needs-triage
    on Oct 31, 2026
  11. melodic-automation-lanes commented on Oct 31, 2026

    @melodic-automation-lanes
    Contributor

    Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.

    Intended outcome: The guard drops a literal '/' allowed-root and name-prefix directory entry on every host by also judging the pre-mapping resolved path, with the test and a changelog fragment updated.

    Acceptance criteria

    • plugins/guardrails/hooks/block-root-delete-target.sh allowed-roots loop (near :2694-2697) also skips an entry whose ${RDT_RES[$c]} equals '/', keeping the existing rdt_root_like, rdt_is_root and HOME checks on the mapped path
    • The name-prefix directory loop (near :2698-2702) also skips an entry whose ${RDT_RES[${pdir[k]}]} equals '/'
    • grep finds no new OSTYPE reference in block-root-delete-target.sh
    • The comment above the loops (near :2686-2687) says a '/' entry is dropped on every host, including where '/' maps to the Git install directory
    • block-root-delete-target.test.sh no longer has the cygpath -m / conditional or the rdt_skip near :1598-1604 and holds the unconditional case rdt_ar "the root '/' does not allow a top-level path" 2 'rm -rf /opt/rdt-allowed-x/y' /
    • The comment above that case says the guard drops '/' even where it maps to the Git install directory
    • bash plugins/guardrails/hooks/block-root-delete-target.test.sh passes on Linux
    • A guardrails changelog fragment made with scripts/new-changelog-fragment.sh exists
    • scripts/check-changelog-fragments.sh --check passes
    • scripts/check-affected.sh --uncommitted passes

    External state: none

    Related work

    Sources read

    • plugins/guardrails/hooks/block-root-delete-target.sh:2686-2703: the comment and both loops judge only the mapped path RDT_WMAP[RDT_RES[...]] via rdt_root_like and rdt_is_root, so there is no pre-mapping '/' check
    • plugins/guardrails/hooks/block-root-delete-target.test.sh:1597-1604: the '/' case is conditional on cygpath -m / and otherwise calls rdt_skip

    Automated refinement by the lanes App. Intake triages the issue again with it.

  12. removed
    needs-triage
    on Oct 31, 2026
  13. added
    agent-ready
    and removed
    admission-deferred
    on Oct 31, 2026
  14. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor
    No description provided.
  15. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor
    No description provided.
  16. melodic-automation-lanes commented on Oct 31, 2026

    @melodic-automation-lanes
    Contributor

    This records a re-fire of an earlier refusal, not a new refusal. The lanes kill switch stopped run 41174105023, the work-resolve-issue run that agent-ready started, before it did any work; that run ended at 2026-10-31T06:07:35Z. work-unblock has now removed and added agent-ready back to start a fresh run. A kill-switch refusal is no fault in this issue or the lanes, so it never counts against later re-fires; after limits.limit-stops-per-issue of them since a person last added agent-ready or a run last reported, work-unblock waits longer before each one, up to 24 hours.

  17. added
    agent-ready
    and removed
    agent-ready
    on Oct 31, 2026
  18. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor
    No description provided.
  19. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor
    No description provided.
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

    agent-readystatus: ready

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions