Skip to content

fix(guardrails): apply_patch bypasses tool.execute.before preflight checks #140

Description

@terisuke

Background

PR #139 review finding [1]: apply_patch is handled in tool.execute.after (increments edit counters, resets review_state) but is not handled in tool.execute.before. This means:

  • Secret file deny checks (deny()) don't fire for apply_patch
  • Config file protection (cfg patterns) is bypassed
  • Version baseline regression check is bypassed
  • Context budget gate is bypassed

Fix

Add apply_patch to the tool.execute.before handler alongside edit/write:

  • guardrail.ts:601 — add || item.tool === "apply_patch" to deny check
  • guardrail.ts:608 — add to version baseline check
  • guardrail.ts:615 — add to context budget gate

Acceptance Criteria

  • apply_patch on .env file is blocked by deny()
  • apply_patch on eslint.config.js is blocked
  • apply_patch version downgrade is blocked
  • apply_patch respects context budget
  • Tests added for each case

Source

PR #139 review comment [1], copilot-reviewer inline

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions