Skip to content

disk-hygiene: the PowerShell belt flags 2>&1 stream merges as file-overwriting redirection #2615

Description

@kyle-sexton

Problem

_POWERSHELL_OUTPUT_REDIRECT matches the > in 2>&1 and prompts with "disk-hygiene flagged shell output redirection (may overwrite a file)." A stream merge has no file target and cannot overwrite anything.

skills/clean/scripts/destructive_guard.py:971:

_POWERSHELL_OUTPUT_REDIRECT = re.compile(r"(?<![<>])>(?![=>])")

For 2>&1 the > is preceded by 2 (the lookbehind only excludes < and >) and followed by & (the lookahead only excludes = and >), so it matches. destructive_guard.py:1027 then returns the mutation verdict.

Reproduction

Any PowerShell command capturing stderr while the clean skill's belt is armed:

bash plugins/disk-hygiene/skills/clean/scripts/hygiene.test.sh 2>&1 | Select-Object -Last 8

Prompts. Nothing in it writes a file — it runs the plugin's own test suite and reads the tail.

Why it matters more than a single stray prompt

2>&1 is the standard way to capture combined output in PowerShell, so this fires on a large share of ordinary diagnostic commands. Combined with #2591 (the belt stays armed for the rest of the session, not only while cleanup is the active work), an operator who ran /disk-hygiene:clean once gets prompted on routine 2>&1 commands for the remainder of that session.

The operational damage is not the individual prompt — it is approval-fatigue habituation. In the session that produced this report the operator described "just hitting approve, approve, approve", and genuine deletion prompts were approved unnoticed in that stream (see the correction posted on #2595). A guard that cries wolf on 2>&1 measurably degrades the guard's real signal.

Suggested fix

Exclude the stream-merge form. In PowerShell >& is only ever a stream merge (2>&1, 1>&2, *>&1) and never designates a file:

_POWERSHELL_OUTPUT_REDIRECT = re.compile(r"(?<![<>])>(?![=>&])")

2>file still matches and still prompts, correctly.

Test coverage to add

skills/clean/scripts/test_hygiene.py — assert that 2>&1, 1>&2 and *>&1 produce no mutation verdict, and that 2>out.txt still does.

Environment

disk-hygiene 0.17.9, Windows 11 26200, PowerShell 7, marketplace install melodic-software.

Found during a /plugin-quality:audit pass over a real /disk-hygiene:clean run. Evidence packet retained locally at plugin-quality-melodic-software/evidence/2399d619-.../disk-hygiene-clean/20260814T182356Z/.

Activity

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-triageNot yet classified. Floor until a type and one priority tier are set.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions