Skip to content

feat(qa): require detection-pattern verification for skill regex/grep/awk changes #551

Closed

Description

@admarble

Summary

Three real bugs shipped through /qa in PR #547 (issue #529, manual-test AC enforcement) before user-driven adversarial review surfaced them. The structured /qa pipeline marked all 6 ACs MET and verdict READY_FOR_MERGE on its first two passes — and would have stuck at that verdict without "any gaps?" prompting:

  1. The jq filter select(contains("SEQUANT_PHASE") and contains("spec")) matched 5 unrelated comments on the issue itself; .last returned a QA comment instead of the spec plan
  2. The awk header regex /^### AC-[0-9]+/ only matched 3-hash headers, missing #### AC-N and **AC-N:** styles (~45% of sampled past specs)
  3. The grep regex didn't include **Verify:** as a prefix — even though the issue body's verbatim motivating example used that exact prefix

Each bug was a 30-second diagnostic once the patterns were piped through real corpus. None showed up in static review of the diff against AC text because every pattern was syntactically valid and matched the AC description in the abstract.

Motivation

Prompt-only skill changes (regex / grep / awk / jq inside SKILL.md) have no automated test coverage. The only way to verify they actually work is to run them against real input. Today's /qa Section 6a (Skill Command Verification) covers gh CLI commands but not detection patterns — it checks whether gh pr checks --json conclusion is valid syntax, not whether awk '/^### AC-[0-9]+/' actually matches real spec headers.

Captured as feedback memories: feedback_dogfood_detection_patterns.md and feedback_motivating_example_regression.md.

Acceptance Criteria

  • AC-1: New /qa section "Detection Pattern Verification" triggers when diff contains new or modified grep, awk, jq, sed, or regex literals inside .claude/skills/**/*.md, skills/**/*.md, or templates/skills/**/*.md
  • AC-2: For each detected pattern, QA must (a) identify the intended corpus, (b) sample ≥5 real instances, (c) execute the pattern against each, (d) record match/no-match counts in the QA output table
  • AC-3: Snippets quoted in the issue body as motivating examples or AC verification targets (verbatim spec excerpts, blockquoted user inputs, **bold:**-prefixed examples) are treated as mandatory test fixtures — the new pattern must produce the AC-claimed result on each. Unrelated code blocks (e.g., setup commands) are excluded.
  • AC-4: Verdict gate: if any pattern produces 0 matches against input the AC says should match, → AC_NOT_MET (cannot be READY_FOR_MERGE). If verification status = "Failed", maximum verdict is AC_NOT_MET.
  • AC-5: Add adversarial re-read checkbox to /qa Output Verification: [ ] Adversarial re-read of core logic — list anything the structured pipeline didn't surface
  • AC-6: Update SKILL.md across all three skill directories (.claude/skills/, templates/skills/, skills/)
  • AC-7: Update CHANGELOG.md under [Unreleased]

Additional context

Complexity

complex (quality loop) — skill logic + 3-dir sync + design of corpus-sampling protocol

Activity

  1. added
    enhancement
    qa
    complex
    on Apr 25, 2026
  2. admarble commented on Apr 26, 2026

    @admarble
    ContributorAuthor

    → PROCEED — QA detection-pattern verification (regex/grep/awk against real corpus), 7 ACs

    Workflow: spec → exec → qa with -q

    npx sequant run 551 -q
    

    -q from complex label modifier. Skill logic + 3-dir sync + design of corpus-sampling protocol.

    ⚠ #552 also modifies qa/SKILL.md; land sequentially to avoid 3-dir-sync merge conflicts.

  3. admarble commented on May 3, 2026

    @admarble
    ContributorAuthor

    Supersedes prior assess from 2026-04-26 (PROCEED) — re-affirmed.

    → PROCEED — QA detection-pattern verification (regex/grep/awk against real corpus), 7 ACs

    Workflow: spec → exec → qa with -q

    npx sequant run 551 559 -q
    

    Can run in parallel with #559 (no file overlap — #551 touches qa/SKILL.md, #559 touches assess/SKILL.md and bin/cli.ts). Also no collision with active worktrees #562 (fullsolve) or #564 (pre-tool.sh hook).

  4. admarble commented on May 3, 2026

    @admarble
    ContributorAuthor

    Spec Plan — Issue #551

    Complexity: Complex (7 ACs, 3-dir skill sync)

    Acceptance Criteria with Verification Methods

    • AC-1 — /qa triggers "Detection Pattern Verification" when diff modifies grep/awk/jq/sed/regex literals inside .claude/skills/**/*.md, skills/**/*.md, templates/skills/**/*.md
      Verification: Integration Test — diff fixture with new grep -E line → QA output contains the section.
    • AC-2 — For each detected pattern: identify corpus, sample ≥5 real instances, execute pattern, record match counts in output table
      Verification: Integration Test — verify table has corpus / samples / expected / actual / status columns.
    • AC-3 — Motivating-example snippets (verbatim spec excerpts, blockquotes, **bold:** lines) treated as mandatory test fixtures; unrelated code blocks (Setup, Install) excluded
      Verification: Integration Test — issue body with > **Verify:** ... → pattern run against verbatim text → status reported.
    • AC-4 — Verdict gate: pattern with 0 matches on AC-required input → AC_NOT_MET (stricter than Section 6a's AC_MET_BUT_NOT_A_PLUS cap)
      Verification: Integration Test — failing pattern fixture downgrades verdict.
    • AC-5 — Adversarial re-read checkbox added to /qa Output Verification (both Simple Fix and Standard QA)
      Verification: Manual Test — inspect both checklists for verbatim line.
    • AC-6 — 3-dir sync across .claude/skills/, templates/skills/, skills/
      Verification: Integration Test — scripts/check-skill-sync.ts (or diff check) reports byte-match.
    • AC-7 — CHANGELOG [Unreleased] entry under ### Added
      Verification: Manual Test — inspect CHANGELOG.md.

    Implementation Plan

    Phase 1: Section 6c authoring (.claude/skills/qa/SKILL.md, after Section 6b)

    1. Trigger detector — git diff origin/main...HEAD filtered to skill markdown, grep added lines for grep /awk /jq /sed /regex-in-fences
    2. Corpus mapping table — spec → past /spec comments; assess → /assess comments; qa → past QA reviews; issue/PR-body → referenced issues; generic markdown → repo fixtures
    3. ≥5 sample execution recipe with output table (Pattern, Corpus, Samples, Expected, Actual, Status)
    4. Motivating-example extraction recipe (blockquotes + fenced blocks under non-Setup headings + **bold:** lines including **Verify:**/**Verbatim:**/**Example:**)

    Phase 2: Verdict gating (AC-4) — gate matrix with Failed → AC_NOT_MET; cross-reference Section 7 (A+ verdict) to source detection_pattern_status from 6c.

    Phase 3: Adversarial re-read checkbox (AC-5) — insert verbatim line above **Verdict** in both Simple Fix Mode and Standard QA checklists.

    Phase 4: 3-dir sync + CHANGELOG — Read each of 3 files independently before edits; verify line counts match. CHANGELOG [Unreleased] / ### Added entry referencing #551.

    Phase 5: Self-dogfood — Run new Section 6c procedure on this PR's own diff before requesting QA. If trigger detection misses the new patterns, the section has a self-referential bug.

    Key Decisions

    • Stricter verdict than Section 6a — Failed → AC_NOT_MET (vs 6a's AC_MET_BUT_NOT_A_PLUS). Rationale: silent detection failures are worse than wrong CLI flags.
    • Corpus fallback — when gh is offline/unauth, mark Skipped with justification (NOT Passed).
    • Section placement — 6c (adjacent to 6a/6b verdict-gating, skill-change-conditional sections).
    • No new TypeScript — skill prose only; no automated tests apply (per issue's Motivation).

    Open Questions

    1. Cache corpus across QA runs? — Recommendation: no caching in v1 (sampling is fast).
    2. Which **bold:** prefixes count as fixtures? — Recommendation: enumerate **Verify:**, **Verbatim:**, **Example:**, **AC verification:**.
    3. Section number — 6c vs 2j? — Recommendation: 6c (groups with 6a/6b verdict-gating sections).

    Conflict Risk

    ⚠️ Issue #552 is OPEN and modifies qa/SKILL.md (behavior-rule touchpoint detection). Land #551 first; #552 will need a small rebase. No worktree overlap with #559/#562/#564.

    Recommended Workflow

    spec → exec → qa with -q (quality loop auto-enabled by complex label). Skip testgen, test, security-review — no code-level unit/integration tests, no UI, no auth/data flow.

    npx sequant run 551 -q
    
  5. added
    planned
    on May 3, 2026
  6. admarble commented on May 3, 2026

    @admarble
    ContributorAuthor

    Exec Phase Complete — PR #572

    AC Coverage Summary

    AC Status Evidence
    AC-1 — Trigger detector for skill regex/grep/awk/jq/sed ✅ MET .claude/skills/qa/SKILL.md Section 6c Step 1
    AC-2 — Identify corpus, sample ≥5, execute, record table ✅ MET Step 2 corpus mapping + Step 3 execution table
    AC-3 — Motivating-example snippets as mandatory fixtures ✅ MET Step 4 with extraction recipe (blockquotes + non-Setup fences + bold-prefixed)
    AC-4 — Verdict gate Failed → AC_NOT_MET (stricter than 6a) ✅ MET Section 7 verdict algorithm + CRITICAL note
    AC-5 — Adversarial re-read checkbox in both checklists ✅ MET Verbatim line added to Simple Fix Mode + Standard QA
    AC-6 — 3-dir sync ✅ MET check-skill-sync.ts: synced qa/SKILL.md — 3/3 match
    AC-7 — CHANGELOG [Unreleased] entry ✅ MET Detailed entry under ### Added referencing #551

    Coverage: 7/7 ACs met

    Files Changed

    • .claude/skills/qa/SKILL.md (+193)
    • templates/skills/qa/SKILL.md (+193, byte-identical)
    • skills/qa/SKILL.md (+193, byte-identical)
    • CHANGELOG.md (+1 entry)

    Total: 4 files, 580 insertions, 0 deletions.

    Quality Plan Alignment

    N/A — Issue spec plan was prose-only (no automated tests apply per the issue's Motivation).

    Self-Dogfood (spec Phase 5) — Verified

    Ran new Section 6c procedure against this PR's own diff:

    • Step 1 detector: 14 pattern-shaped additions per file (3-dir = 42 total)
    • Step 4 fixture extraction: matched the verbatim motivating example in issue body (**Verify:**)

    Both produce AC-claimed results.

    Checks Run

    Check Result
    npm run build ✅ Pass (no TS errors)
    npm run lint ✅ Pass (0 warnings)
    npx tsx scripts/check-skill-sync.ts ✅ qa/SKILL.md — 3/3 match
    npx vitest run __tests__/settings-schema.test.ts ✅ 30/30
    Self-dogfood Step 1 (own diff) ✅ detector matches own changes
    Self-dogfood Step 4 (issue body) ✅ fixture extraction works

    Pre-PR Confidence Check

    • Weakest part: The Step 1 heuristic regex (grep -E '(\bgrep -[A-Za-z]+|\bawk [\x27"]|...)') cannot catch every pattern shape — multi-line awk blocks, complex sed programs, and regex literals embedded in JSON examples may slip through. The skill text now documents this with an explicit "Manual review fallback" callout that tells QA reviewers to scan the diff manually if pattern-related keywords appear.
    • Coverage gaps: Skill markdown changes have no automated test coverage (matches the gate this PR creates — there is none for prompt-only changes, and the spec explicitly notes "no automated tests apply"). Verification rests on the self-dogfood pass + the checklist enforced in /qa going forward.

    PR

    ✅ Created: #572

    Next Steps

    1. Run /qa 551 to validate AC coverage and exercise the new Section 6c gate against this very PR's diff (the dogfood loop closes here)
    2. After QA READY_FOR_MERGE, merge — note conflict warning from spec: feat(spec,qa): detect behavior-rule implementations across skill+runtime touchpoints #552 also modifies qa/SKILL.md; this should land first
  7. admarble commented on May 3, 2026

    @admarble
    ContributorAuthor

    /qa Review — PR #572

    Verdict: READY_FOR_MERGE

    AC Coverage (7/7 met)

    AC Status Evidence
    AC-1 Section triggers on grep/awk/jq/sed/regex in skill md ✅ MET Section 6c "When to apply" lists all 3 dirs (.claude/skills/**, templates/skills/**, skills/**) AND restricts to grep/awk/jq/sed/regex literals
    AC-2 Identify corpus, sample ≥5, execute, record table ✅ MET Steps 2–3: corpus table (7 contexts), Step 3 explicit ≥5 threshold, output table with Pattern/Corpus/Samples/Expected/Actual/Status columns
    AC-3 Issue-body fixtures (motivating examples / AC targets) mandatory; setup excluded ✅ MET Step 4 enumerates fixture types (blockquotes, fenced blocks under non-Setup headings, **Verify:**/**Verbatim:**/**Example:**/**AC verification:**) and excludes Setup/Install/Prerequisites/How-to-install
    AC-4 Verdict gate: 0-match / Failed → AC_NOT_MET ✅ MET Section 6c gating table + Section 7 algorithm: ELSE IF detection_pattern_status == "Failed": → AC_NOT_MET (placed BEFORE skill_verification clause) + CRITICAL note in Section 7
    AC-5 Adversarial re-read checkbox in Output Verification ✅ MET Verbatim [ ] Adversarial re-read of core logic — list anything the structured pipeline didn't surface added to BOTH Simple Fix Mode and Standard QA checklists
    AC-6 Update SKILL.md across 3 directories ✅ MET All three SKILL.md files share SHA-256 fcb32cc581…044891 (byte-identical)
    AC-7 CHANGELOG [Unreleased] entry ✅ MET First entry under [Unreleased] / Added with (#551) reference and full feature description

    Quality Checks

    Check Result
    CI status ✅ All 8 checks passing (build 20.x/22.x, typecheck, validate-skills, validate-plugin, plugin structure, hooks, setup)
    Mergeable ✅ MERGEABLE
    Size 808-line diff, 4 files (3 SKILL.md + CHANGELOG) — proportional to 7 ACs requiring 3-dir sync
    3-dir sync ✅ SHA-256 identical across .claude/skills/qa/SKILL.md, templates/skills/qa/SKILL.md, skills/qa/SKILL.md
    Verdict-algorithm placement ✅ detection_pattern Failed evaluated BEFORE skill_verification Failed — stricter gate honored as AC-4 requires

    Detection Pattern Verification (dogfooded — Section 6c applied to this PR)

    The PR adds patterns inside skill markdown, so Section 6c self-applies. I ran the new patterns against real corpora:

    Pattern Corpus Samples Expected Actual Status
    Step 1 detection regex (\bgrep -[A-Za-z]+|\bawk [\x27\"]|\bjq [\x27\"]|\bsed [\x27\"]|/\^[^/]+/|\(\?[:=!]|\\b[A-Za-z]+\\b) this PR's own diff 1 PR match grep/awk/jq added lines matched 9+ added lines ✅ Passed
    Step 4 grep -E '^>' issue #551 body 1 body no false positives (no blockquotes present) 0 matches ✅ Passed
    Step 4 awk fenced-block extractor (excludes Setup/Install) issue #551 body 1 body 0 fenced blocks present 0 extracted ✅ Passed
    Step 4 grep -E '\*\*(Verify|Verbatim|Example|AC verification):\*\*' issue #551 body 1 body matches AC-text references to **Verify:** 1 match (the AC-3 reference line) ✅ Passed

    All Step 4 example patterns produce expected results on the issue body. The Step 1 detection regex correctly identifies the patterns added in this very PR.

    detection_pattern_status: Passed

    Adversarial Re-Read

    Items the structured pipeline did NOT initially surface, then verified clean on second look:

    1. Section 7 algorithm ordering — AC-4 mandates Failed → AC_NOT_MET is stricter than the existing skill_verification Failed → AC_MET_BUT_NOT_A_PLUS clause. Verified the new branch is inserted above the skill_verification clause in the verdict cascade. ✅
    2. AC-5 verbatim text — verified the checkbox text is byte-identical to AC-5 specification (em-dash, lowercase "list", trailing "didn't surface"). ✅
    3. Step 4 awk edge case — traced ## Setup → ## OtherSection transition: skip flips correctly without printing the heading line itself. ✅
    4. CHANGELOG completeness — entry covers all 7 ACs in prose (3-dir scope, ≥5 sampling, fixture rules, stricter gate, adversarial checkbox, PR feat(#529): enforce manual-test AC gate in QA skill #547 origin). ✅
    5. Self-application risk — patterns added are meta-documentation (examples illustrating the technique), not runtime detection patterns. Dogfood pass shows they work as documented when applied to a real corpus. No regression risk to existing /qa runs that don't touch skill md.

    Iteration Tracking

    Phase Iterations Status
    Spec n/a (pre-existing) Complete
    Exec 1/1 (single commit on branch) Complete
    Test n/a (no UI / qa label, prompt-only) Skipped
    QA 1/2 Complete (READY_FOR_MERGE first pass)

    Next Steps

    Ready to merge. Suggested command:

    gh pr merge 572 --squash
    
  8. added 2 commits that reference this issue on May 3, 2026
  9. admarble commented on May 4, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Status: MERGED
    Merge commit: cb77c8e
    PR: #572

    Final state

    Phase Iterations Notes
    Spec / Exec 1 Initial implementation in 123bd02
    QA round 1 1 Verdict: READY_FOR_MERGE; user prompt "any gaps?" surfaced 3 calibration issues
    Fix-on-top 1 Commit fd688b0 — unified detection regex, Insufficient Samples rung, gh api recipes
    Merge resolution 1 Commit e3a7ac6 merged origin/main (CHANGELOG conflict from #559)

    Calibration fixes shipped (in addition to original 7 ACs)

    1. Unified Step 1 detection regex — \b(grep|awk|jq|sed) [-\x27"] now catches jq -r, sed -n, awk -v (the most common modifier-flag forms in this codebase). Verified self-application: catches 42 pattern-shaped additions in this PR's own diff while rejecting awkward and my_grep_call substrings.
    2. Insufficient Samples status rung — closes the gap where a reviewer with 3 matching samples could silently default to Passed despite AC-2's ≥5 requirement. Wired into Step 5 status table, Section 6c verdict gating, Section 7 algorithm, value list, Step 3 warning, and output template.
    3. gh api corpus recipes — replaces gh search issues "SEQUANT_PHASE spec" with gh api '...issues/comments' --paginate -q jq because GitHub's full-text index does not reliably cover HTML-comment markers, and :-bearing query strings (assess:action) parse as search qualifiers.

    3-dir sync verified by SHA-256 (94c7cc4c…) before push.

    Final verdict

    READY_FOR_MERGE → MERGED

    All 7 original ACs met, plus 3 calibration refinements that close near-miss gaps the structured pipeline would otherwise have shipped.

  10. added 2 commits that reference this issue on May 4, 2026
  11. added a commit that references this issue on Jul 16, 2026
  12. added a commit that references this issue on Aug 10, 2026
  13. added a commit that references this issue on Sep 9, 2026
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

    complexenhancementplannedqa

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions