Skip to content

guardrails: cli-flag-verify PostToolUse hook flags pre-existing unrelated lines (not diff-scoped) #544

Closed as not planned

Description

@kyle-sexton

Category

behavioral / improvement

Observed during

PR babysitting on #528. Edited plugins/toolchain/skills/check/SKILL.md at line 65 (replacing a sed prefix-strip with ${DEFAULT_BRANCH#"$REMOTE/"} parameter expansion). The PostToolUse cli-flag-verify hook fired and reported:

UNKNOWN_FLAG: dotnet test --project (not found in 'dotnet test --help')

Problem

The flagged token lives on line 108 — unrelated prose about ecosystem gotchas (For ecosystem-specific gotchas (xUnit --nologo trap, dotnet test --project, etc.)...), 43 lines away from the actual edit. The hook scans the whole edited file, not the diff, so any edit to a file that already contains a flag the DB doesn't recognize surfaces a "possible hallucination" warning about a line the agent never touched.

Impact

  • Noise on every unrelated edit to any file containing a pre-existing (real or false-positive) flag hit.
  • Pressure to "fix" out-of-scope lines to silence the warning, or to add skip-list entries, neither of which the current edit warrants.
  • Erodes signal: a genuine hallucinated flag introduced by the edit is harder to spot amid pre-existing-line noise.

Suggested direction

Scope the cli-flag-verify check to tokens introduced/changed by the edit's hunk (diff-scoped), rather than re-scanning the entire file body on each PostToolUse. Separately, triage may want to confirm whether dotnet test --project is a genuine false positive in the flag DB (it is documented for dotnet test), but the diff-scoping behavior is the primary report.

Related

Filed per babysit self-observation. Not refiling known: #484, #465, #473, #499, #504, #511, #512, #524.

Activity

  1. added
    needs-triage
    on Jul 19, 2026
  2. kyle-sexton commented on Jul 19, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI during triage. · Category: behavioral (duplicate)

    status: needs-decision — recommend close: duplicate of #543.

    Same hook (cli-flag-verify PostToolUse), same root cause (whole-file scan instead of diff-scoped → warns on pre-existing untouched lines), same suggested fix (scope to the edit's hunk). This report and #543 were filed ~3 seconds apart by two separate babysit workers on different PRs (#528 here, #529 there) — a concurrent-duplicate, exactly the class that motivates a shared dogfood-filing dedupe path (#540).

    This report's distinct data point (toolchain check/SKILL.md line 65 edit firing on line 108) has been preserved as a second example on #543, so nothing is lost on close. The dotnet test --project flag-DB false-positive question is captured on #543 as the secondary item.

    Recommend the human close this as a duplicate of #543 (the lower-numbered primary). Not routed ready to avoid two lanes implementing the same diff-scoping fix.

  3. added
    needs-owner-decision
    and removed
    needs-triage
    on Jul 19, 2026
  4. kyle-sexton commented on Jul 19, 2026

    @kyle-sexton
    MemberAuthor

    Decision brief (2-minute read)

    Prepared by an AI agent from a read-only checkout at 789ec6c — verify before acting. This complements, and does not override, the existing triage recommendation on this issue to close as a duplicate of #543.

    Problem. cli-flag-verify (PostToolUse advisory) warns on CLI-flag tokens anywhere in the edited file, not just in the lines the edit touched, so an unrelated edit surfaces a "possible hallucination" about a pre-existing line the agent never wrote (here: a line-65 edit flagged dotnet test --project on line 108). This is one member of the #547 over-fire class.

    Today (verified). The over-fire is real and structural, not a tuning issue. plugins/guardrails/hooks/cli-flag-verify.sh reads only tool_input.file_path (line 50, via hook::read_file_path) and never reads old_string/new_string; emit_fragments() (lines 97-117) then scans the entire file — grep over all inline-code spans and awk over all fenced blocks for .md, or grep over all non-comment lines for shell. There is no hunk restriction, so every pre-existing flag is re-verified on every edit. The hook is already code-span-scoped and subcommand-aware (its false-positive suite has ~31 stay-quiet cases) — the missing dimension is edit-scope. The Edit payload does carry new_string (the test helper's edit_json builds it), so diff-scoping is feasible without new inputs.

    Options.

    Related.

  5. kyle-sexton commented on Jul 20, 2026

    @kyle-sexton
    MemberAuthor

    Control-tower close (closure audit 2026-07-20, Class B). Duplicate of #543 — both the triage comment and the decision brief on this issue recommend close-as-duplicate; the distinct data point is already preserved on #543. Two independent audit verdicts HIGH.

  6. added a commit that references this issue on Jul 21, 2026
    c87a263
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-owner-decision

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions