Repository navigation
feat(#552): detect behavior-rule implementations across skill+runtime touchpoints - #607
Merged
admarble merged 6 commits intoMay 9, 2026
Conversation
… touchpoints Adds shared heuristic at src/lib/heuristics/behavior-rule-detector.ts: - detectBehaviorRule(ac) — cheap keyword gate (>=2 from default|always| never|rule|behavior|skip OR explicit pattern like "always X unless Y") - findTouchpoints(ac, repoRoot) — proactive enumeration for /spec - findSurvivingInverseSymbols(ac, repoRoot, diffPaths) — reactive scan for OLD-rule survivors inside the diff blast radius for /qa Wires into: - /spec SKILL.md: new "Rule Touchpoints (Conditional)" subsection under Context Gathering, plus a "## Rule Touchpoints" plan output section. - /qa SKILL.md: new section 6e "Behavior-Rule Survival Check" between 6d (Adversarial Re-Read) and section 7 (Verdict). Wired into the section 7 verdict algorithm via behavior_rule_survival_status gate (Survivors Found -> AC_NOT_MET). Shared reference doc at _shared/references/behavior-rule-detection.md documents trigger keywords, threshold, symbol categories, inverse-keyword map, false-positive guards, and the performance budget. Both /spec and /qa SKILL.md files link it via ../_shared/references/. Mirrored across .claude/skills/, templates/skills/, and skills/ — sync script reports 3/3 for all touched files. Tests: 19 unit cases (verbatim #533 AC text, no synthetic markers, per feedback_synthetic_test_fixture_trap.md) + integration suites for /spec wiring, /qa wiring, and 3-dir sync (42 tests total, all passing). Motivated by miss in #533 ("default /assess spec phase ON, remove bug/docs auto-skip"), where /spec scoped the work to a single SKILL.md, /exec implemented it, and /qa returned READY_FOR_MERGE while the runtime CLI's BUG_LABELS/DOCS_LABELS short-circuit in phase-mapper.ts and batch-executor.ts survived — caught only by manual user follow-up. Closes #552
6 tasks
Gap 1: AC-5 literal "Always include Y" did not trigger.
The ≥2-keyword threshold rejected the literal AC-5 example strings from
the issue body. The unit test silently augmented the fixture to "Always
include Y in response payload behavior" to pass — a literal AC violation
per feedback_qa_ac_literal.md. Add three case-sensitive imperative-opener
patterns to EXPLICIT_PATTERNS so capitalized "Always|Never|Default <verb>"
at the start of an AC triggers with a single keyword. Add verbatim-string
unit tests covering all three AC-5 examples plus a guard that lowercase
prose ("the system always includes Y") does NOT self-trigger.
Gap 2: TOUCHPOINT_ROOTS missed the recurring CLI-wiring drift site.
Scope was limited to src/lib + .claude/skills. From CLAUDE.md memory:
"CLI wiring gap: Adding a field to RunOptions + runtime check is NOT
enough — must also register in bin/cli.ts." A behavior rule about a CLI
default would land in skill code while .option() registrations in
bin/cli.ts went stale — exactly the failure mode #533 surfaced. Add bin
and src/commands to TOUCHPOINT_ROOTS and add a tmp-dir test that builds
a fixture with bin/cli.ts + src/commands/run.ts + a backticked symbol in
the AC, then asserts both paths appear in findTouchpoints output.
Bonus: fix JSDoc cap drift on findTouchpoints — comment said "capped at
50" but TOTAL_CAP = 200.
Reference doc updated across all 3 mirrors (.claude/skills, templates/
skills, skills) to document the new explicit patterns and expanded scan
scope. check-skill-sync.ts reports synced 3/3 for behavior-rule-
detection.md.
Tests: 47/47 passing (was 42/42; +5 new). Build clean. Lint clean.
…-qa-detect-behavior-rule-implementations- # Conflicts: # .claude/skills/qa/SKILL.md # CHANGELOG.md # skills/qa/SKILL.md # templates/skills/qa/SKILL.md
…st, meta-recursion docs Round 2 of the adversarial review on PR #607. Round 1 (bf8a4fc) closed the literal AC-5 divergence, the CLI-wiring scope gap, and the JSDoc cap drift; this round closes the remaining material gaps surfaced in the same review. Gap 3: Inflection-blind keyword regex. `\bdefault\b` missed `defaults`/`defaulted`/`defaulting`; `\bskip\b` missed `skipping`/`skipped`; `\bbehavior\b` missed `behaviors`/`behavioral`. Real ACs use these forms — empirical: "The system defaults to true" → triggered: false. Add `KEYWORD_REGEXES` map mirroring the stem-aware pattern landed by #597 in `ac-linter.ts`. Word boundaries preserved so the camelCase identifier `defaultValue` does NOT trigger. Three new unit tests cover the positive cases and the boundary guard. Gap 5: Common-word noise in INVERSE_KEYWORDS. QA's self-dogfood pass on #607 returned 50 survivors entirely from definitional documentation because `INVERSE_KEYWORDS["skip"]` and `["never"]` listed `include`, `run`, `auto`, `old`, `previous` — words that appear in any English prose. Two complementary fixes: (1) prune those high-noise words from the map; (2) add a runtime guard in `deriveInverseTerms` that drops any term in COMMON_WORDS (defense for future tuners). New unit test asserts a fixture line containing all five pruned words yields zero survivors. Polish: - Promote hardcoded `50` cap on `findSurvivingInverseSymbols` to named const `SURVIVOR_TOTAL_CAP` with documented rationale. - Reference doc updated across 3 mirrors: keyword table now includes inflection columns, inverse-keyword table reflects pruned values, performance-budget section documents both caps, new "Known limitations" subsection captures the meta-recursion edge case QA flagged in its self-dogfood pass. - Tuning checklist in reference doc now lists `KEYWORD_REGEXES` and `SURVIVOR_TOTAL_CAP` as tunable surfaces. Tests: 51/51 passing (was 47/47; +4). Build clean. Lint clean. check-skill-sync.ts reports synced 3/3 for behavior-rule-detection.md.
Add a one-line breadcrumb under "Known limitations" in the behavior-rule detection reference doc (3 mirrors). Captures the inverse-English-phrase fallback that the issue body's AC-2 risk callout flagged as a future layer, without committing to build it. If a real /qa miss surfaces where the inverse-keyword pass isn't enough, file a follow-up issue with the concrete fixture rather than pre-emptively building NL-phrase derivation.
…-qa-detect-behavior-rule-implementations- # Conflicts: # .claude/skills/qa/SKILL.md # skills/qa/SKILL.md # templates/skills/qa/SKILL.md
admarble
deleted the
feature/552-feat-spec-qa-detect-behavior-rule-implementations-
branch
May 9, 2026 16:38
Closed
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/lib/heuristics/behavior-rule-detector.tsexportingdetectBehaviorRule,findTouchpoints, andfindSurvivingInverseSymbols— gates expensive grep passes on a cheap keyword check (>=2 fromdefault | always | never | rule | behavior | skipOR explicit pattern likealways X unless Y)./spec(proactive Rule Touchpoints under Context Gathering) and/qa(reactive section 6e survival check, gated through section 7 verdict via newbehavior_rule_survival_status)._shared/references/behavior-rule-detection.md, mirrored across.claude/skills/,templates/skills/, andskills/(sync script reports 3/3 for touched files).Motivation
Issue #533 ("default /assess spec phase ON, remove bug/docs auto-skip") was the motivating miss:
/specscoped the work to a singleassess/SKILL.mdfile,/execimplemented it, and/qareturnedREADY_FOR_MERGE— but the runtime CLI'sBUG_LABELS/DOCS_LABELSshort-circuit inphase-mapper.tsandbatch-executor.tssurvived and was caught only by manual user follow-up. This PR adds the cross-touchpoint detection that would have surfaced 90% of those misses in one pass.AC Verification
/specsurfaces touchpoints proactively.claude/skills/spec/SKILL.md:154-195(Rule Touchpoints subsection + plan output template)/qaverifies behavior at all touchpoints.claude/skills/qa/SKILL.md:2026-2080(section 6e) + section 7 wiring at lines 2114, 2137_shared/references/behavior-rule-detection.md, linked from both SKILL.md files via../_shared/references/behavior-rule-detection.mdnpx tsx scripts/check-skill-sync.tsreportssynced 3/3 matchforspec/SKILL.md,qa/SKILL.md,_shared/references/behavior-rule-detection.mdsrc/lib/heuristics/__tests__/behavior-rule-detector.test.ts(uses verbatim #533 AC text perfeedback_synthetic_test_fixture_trap.md+feedback_motivating_example_regression.md) + 23 integration tests in__tests__/integration/behavior-rule-*.integration.test.ts. 42 tests total, all passing.CHANGELOG.md[Unreleased] / Added, references both #552 and #533Quality Plan Alignment
detectBehaviorRulereturnstriggered: false;/qascope bounded to diff blast radiusBEHAVIOR_KEYWORDSconst; doc cites the source of truthTest plan
npm run build— passesnpm run lint— passesnpx vitest run src/lib/heuristics __tests__/integration/behavior-rule-— 42/42 passingnpx tsx scripts/check-skill-sync.ts— touched files reportsynced 3/3 match/specon a behavior-rule issue and verify the new "Rule Touchpoints" section appears in the plan output/qaon a feature branch where the OLD-rule symbol survives in the diff and verify section 6e flags ACNOT_METCloses #552