Skip to content

guardrails, disk-hygiene: narrow three destructive-guard matchers to their measured false positives #9779

Closed

Description

@kyle-sexton

Refs #5683. Slice 2 of 2 (parallel with slice 1).

Problem

The 2026-10-20 overengineering audit (comment on #5683) measured three destructive-operation guards whose blocks are mostly false positives:

  • disk-hygiene destructive guard. Its Bash registration is "if": "Bash(*hygiene.py*)" (plugins/disk-hygiene/hooks/hooks.json). 648 of 649 recorded denies are rule not-exact-engine-command, mostly reads of the plugin's own source: grep, sed, gh pr diff, or a heredoc whose text names the engine script. The filter matches any command line that contains the file name.
  • guardrails block-dangerous-git. 24 blocks, mostly git reset --hard and git clean -f inside disposable scratch repositories an agent created.
  • guardrails block-root-delete-target. 192 blocks, mostly rm -rf "$S" where S was assigned a literal scratch path earlier in the same command line. No sampled block prevented a harmful delete.

Fix

Narrow each matcher; never widen what it allows outside the cases named here.

  • disk-hygiene: make the guard act only on a command that invokes the engine (an interpreter followed by the engine script path as its program argument), and stay quiet for commands that only read or mention the file.
  • block-dangerous-git: allow reset --hard and clean -f when the target repository's top level resolves under the system temp directory ($TMPDIR or /tmp). Everything else stays blocked.
  • block-root-delete-target: resolve a variable assigned a literal path earlier in the same command line before judging the delete target. An assignment that is not a literal, or one the command can change before the delete, stays unresolved and blocks as today.

Each change follows the hook-precision convention (docs/conventions/hook-precision/README.md): a stay-quiet test that fails before the fix, plus a still-blocks test for the dangerous neighbour of each shape.

Done when

  • A stay-quiet test for each shape above fails on origin/main and passes on the PR branch (show both runs in the PR body)
  • Still-blocks tests pass: an engine invocation without the exact shape, git reset --hard in a repository outside the temp directory, and rm -rf "$X" where X is not a same-command literal
  • bash plugins/guardrails/hooks/block-dangerous-git.test.sh and bash plugins/guardrails/hooks/block-root-delete-target.test.sh exit 0
  • python3 -m pytest plugins/disk-hygiene/skills/clean/scripts exits 0
  • ci-status is green on the PR head

Activity

  1. added
    status: ready
    on Oct 24, 2026
  2. added
    needs-triage
    on Oct 24, 2026
  3. github-actions commented on Oct 24, 2026

    @github-actions
    Contributor

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

    Size: Medium
    Complexity: Medium
    Uncertainty: Known
    Flags: none
    Blocked by: none

    Decision recorded. The owner answered in the Issue Triage session (2026-10-26), on the question "Narrow the three destructive-command guards (disk-hygiene's destructive guard, guardrails block-dangerous-git and block-root-delete-target) to their measured false positives, as this issue scopes it?" (recommended: yes, as scoped):

    go with whatever the facts/data/metrics + /discovery:research says and ensure we're aligned with SOLID, DRY/SSOT principles

    Decided: yes, as the body scopes it. The facts are the body's measurements (disk-hygiene: 648 of 649 recorded denies were rule not-exact-engine-command, mostly reads of the plugin's own source; block-root-delete-target: 192 blocks, no sampled block prevented a harmful delete). Each guard narrows only to the shapes named under "Fix" and never widens what it allows outside them, per docs/conventions/hook-precision/README.md: a stay-quiet test that fails before the fix, plus a still-blocks test for each dangerous neighbour.

    The body's "Done when" criteria stand as written.

    #9779 (comment)

    This decision settles the open questions. I read this as a bounded change that narrows three hook matchers and adds stay-quiet and still-blocks tests. I found no likely duplicates.

    Automated triage, applied by the lanes App.

  4. added and removed
    needs-triage
    on Oct 24, 2026
  5. added
    needs-owner-decision
    and removed
    status: ready
    on Oct 24, 2026
  6. removed
    needs-owner-decision
    on Oct 26, 2026
  7. kyle-sexton commented on Oct 26, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded. The owner answered in the Issue Triage session (2026-10-26), on the question "Narrow the three destructive-command guards (disk-hygiene's destructive guard, guardrails block-dangerous-git and block-root-delete-target) to their measured false positives, as this issue scopes it?" (recommended: yes, as scoped):

    go with whatever the facts/data/metrics + /discovery:research says and ensure we're aligned with SOLID, DRY/SSOT principles

    Decided: yes, as the body scopes it. The facts are the body's measurements (disk-hygiene: 648 of 649 recorded denies were rule not-exact-engine-command, mostly reads of the plugin's own source; block-root-delete-target: 192 blocks, no sampled block prevented a harmful delete). Each guard narrows only to the shapes named under "Fix" and never widens what it allows outside them, per docs/conventions/hook-precision/README.md: a stay-quiet test that fails before the fix, plus a still-blocks test for each dangerous neighbour.

    The body's "Done when" criteria stand as written.

  8. added
    status: ready
    on Oct 26, 2026
  9. added
    admission-deferred
    agent-ready
    and removed
    admission-deferred
    on Oct 29, 2026
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