Skip to content

fix(guardrails): tighten bash mut regex to reduce false review_state resets #141

@terisuke

Description

@terisuke

Background

PR #139 review finding [WARN-2]: The mut array regex />/ matches any command containing >, including benign uses like echo "version > 2" or commands with > inside quoted strings.

PR #139 amplified this by adding review_state reset on mutating bash commands (line 1024). Now harmless commands can falsely invalidate review state.

Fix

Tighten the > pattern to only match file redirects, not > inside quotes:

  • Option A: />(?!\s*&)(?!\s*\/)(?!.*['"].*>.*['"])/ — exclude fd redirects and quoted strings
  • Option B: Use a simple heuristic — split on unquoted |/&&/; first, then check each segment

Acceptance Criteria

  • echo "version > 2" does NOT trigger mut detection
  • gcloud list --format=json 2>&1 does NOT trigger mut detection
  • echo test > file.txt DOES trigger mut detection
  • sed -i 's/old/new/' file DOES trigger mut detection
  • Tests for false positive and true positive cases

Source

PR #139 review comment [WARN-2], pre-existing amplified by review_state reset

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions