Skip to content

fix(pre-tool-enforcer): reduce SLOP fallback-language false positives on instruction text #2927

@devseunggwan

Description

@devseunggwan

Summary

The PreToolUse SLOP fallback-language detector at
scripts/pre-tool-enforcer.mjs:172 uses a purely lexical regex:

const SLOP_FALLBACK_LANGUAGE_PATTERN =
  /\b(?:fallback|fall\s+back|workaround|work\s+around)\b/i;

This fires on instruction-style text where the trigger words appear as
nouns being described, not as actions being taken. The hook is
warning-only (additionalContext), so it doesn't block, but it
generates noise on routine documentation edits.

Repro

The hook fires on inputs like:

  • "workaround for a specific bug" — explanation in instruction text
  • Editing a file that itself documents the rule (self-referential — the
    file describing the pattern fires the pattern)

In one observed session, editing instruction docs and writing a memo
about this exact hook fired the warning multiple times in succession,
all on text that described the trigger words in the third person.

Proposed change

Reduce false positives without losing the original detection signal.
Options (most conservative first):

  1. Tool-input-shape filter — when the input matches
    documentation/instruction text (long form, Markdown headers, .md
    target file), suppress the warning OR raise the bar (require multiple
    signals).
  2. Verb-phrase context — fire only when the trigger word is
    preceded by an action verb (use a workaround, fall back to X,
    add a fallback) rather than as a bare noun.
  3. Self-reference suppression — if the file path matches
    *pre-tool-enforcer* or files clearly documenting the rule,
    suppress.

Even option 3 alone would eliminate the most jarring self-referential
fires.

Files

  • scripts/pre-tool-enforcer.mjs:161-208
    (SLOP_RISK_TOOL_NAMES, SLOP_FALLBACK_LANGUAGE_PATTERN,
    appendSlopFallbackWarning)
  • src/__tests__/pre-tool-enforcer.test.ts:440-480 (existing tests)

Why this matters

The hook is a useful signal when fired on real fallback narration.
False positives on instruction text dilute that signal. Even a single
context filter would help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions