Repository navigation
Description
Summary
When an issue's AC describes a behavior rule (e.g. "default becomes X", "always include Y", "never skip Z"), the rule is often implemented at multiple touchpoints — typically a skill prompt (LLM-interpreted) and runtime TypeScript code that duplicates the rule. Today, neither /spec nor /qa surfaces this duplication, so PRs frequently land with the skill updated and the runtime stale (or vice versa).
This issue adds a shared detection heuristic used in both phases:
/specruns it proactively to surface all touchpoints in the plan, so the user can scope the work upfront./qaruns it reactively to verify no old-rule code survives anywhere in the diff's blast radius.
Motivation — concrete recent miss
Issue #533 ("default /assess spec phase ON, remove bug/docs auto-skip") is the motivating example.
The AC text mentioned .claude/skills/assess/SKILL.md explicitly. /spec scoped the work to that skill file + CHANGELOG. /exec implemented it. /qa gave READY_FOR_MERGE. All while the runtime CLI (phase-mapper.ts detectPhasesFromLabels + batch-executor.ts auto-detect branch) still short-circuited bug/docs issues to exec → qa, directly contradicting the new "spec by default" behavior.
The gap was caught only by manual user follow-up ("any other gaps?"), and required:
- Three rounds of adversarial sweeps to find all stale references
- Two additional commits on top of the original PR (2e79778 + e7632d8)
- Updates to runtime code, 4 test files, 4 docs (
docs-pipeline.md,exact-label-matching.md,workflow-phases.md,state-schema.ts), and a CHANGELOG rewrite
A pre-flight grep for BUG_LABELS/DOCS_LABELS/"skip spec" at /spec time would have surfaced 90% of these in one pass.
See the post-mortem in issue #533 comments: #533
Acceptance Criteria
-
AC-1:
/specsurfaces touchpoints proactively. When/specparses an AC containing behavior-rule keywords (default,always,never,rule,behavior,skip), it greps the codebase for related symbols/keywords and lists all touchpoints under a new "Rule Touchpoints" section in the plan. -
AC-2:
/qaverifies behavior at all touchpoints. When/qareviews a behavior-rule AC, it greps for inverse keywords/symbols (the OLD rule's implementation) across the repo. Any survival → AC markedNOT_METwith the file paths/line numbers listed under the AC explanation. -
AC-3: Shared heuristic documented. Both detectors reference a single
references/behavior-rule-detection.mdpage describing: trigger keywords, grep patterns, common symbol categories (constants, function names, comment patterns), and false-positive guards. Both/specand/qaSKILL.md files link to it. -
AC-4: 3-dir sync. Edits applied identically across
.claude/skills/,templates/skills/,skills/for bothspec/SKILL.mdandqa/SKILL.md(and the newreferences/behavior-rule-detection.md). `scripts/check-skill-sync.ts` reports synced 3/3 for all touched files. -
AC-5: Tests verify trigger conditions. Unit/integration tests assert:
- Triggers fire on behavior-style AC text: "Default rule becomes X", "Always include Y", "Never skip Z"
- Triggers do NOT fire on file-specific AC text: "Update line 42 of foo.ts", "Add field to interface X"
- Touchpoint detection finds duplicate implementations across skill+TypeScript layers (use feat(assess): default spec phase ON, remove bug/docs auto-skip #533's BUG_LABELS/DOCS_LABELS as a fixture)
-
AC-6: CHANGELOG entry under `[Unreleased] / ### Added` referencing this issue and feat(assess): default spec phase ON, remove bug/docs auto-skip #533 as the motivating miss.
Non-Goals
- Not auto-fixing detected drift — surfacing is enough; user/exec applies the fix.
- Not a generic "behavior change linter" outside the spec/qa flow — scope is the AC-driven workflow only.
- Not modifying the AC linter or scope-assessment logic — this is additive detection, not validation.
Risks / Open Questions
- False positive rate on AC-1 trigger keywords. "Default" appears in many ACs that aren't behavior rules (e.g. "set default value to 5"). Mitigation: require ≥2 behavior keywords OR an explicit pattern ("always X unless Y"). Tunable in
references/behavior-rule-detection.md. - Symbol enumeration is heuristic. Detection relies on grepping for constants/function names that implement the OLD rule. Some rules are inline conditionals with no named symbol. AC-2 should include a fallback: when no symbols match the AC's keywords, search for the inverse English phrasing of the rule.
- /qa runtime cost. Adding another grep pass per behavior-AC is cheap (<1s) but compounds in large QA runs. Cache or short-circuit when no behavior-rule ACs are present.
Complexity
medium — shared heuristic + 2 skill updates + 3-dir sync + tests + docs. Estimated 1–2 days. Single PR.
Self-assessed workflow
spec → exec → qa with -q (skill changes + 3-dir sync + new reference doc + CHANGELOG)
Activity
admarble commentedon Apr 26, 2026
→ PROCEED — Behavior-rule cross-touchpoint detection (skill+runtime), 6 ACs
Workflow:
spec → testgen → exec → qawith-qtestgentriggered by AC-5 ("Unit/integration tests assert...").-qfor multi-file scope: 2 skill files × 3-dir sync + new reference doc + tests + CHANGELOG.⚠ #551 also modifies
qa/SKILL.md; land sequentially to avoid 3-dir-sync merge conflicts.fix(#556): normalize skill-mirror paths to canonical bare form
feat(#556): predict file-collision between PROCEED issues from body c…
admarble commentedon May 8, 2026
Complexity: Standard (6 ACs, ~3 directories:
.claude/skills/{spec,qa},src/lib/heuristics/,tests/)AC Quality Check
All 6 ACs pass
lintAcceptanceCriteria— no vague/unmeasurable/open-ended flags. AC-5 has nested bullets describing trigger conditions; the parser treats those as part of the AC body which is fine for execution. No title/body tension.Scope Assessment
Non-Goals: Found in issue body (3 items: no auto-fix, not a generic linter, not modifying ac-linter/scope).
/specproactive +/qareactive sharing one heuristic)Verdict:⚠️ SCOPE_WARNING — auto-enables quality loop. Splitting into
/spec-only and/qa-only issues was considered but rejected: AC-3 mandates a shared reference doc, so the heuristic must land atomically.Acceptance Criteria
AC-1:
/specsurfaces touchpoints proactivelyVerification: Integration Test
Scenario: Given an AC with behavior-rule keywords (≥2 of
default|always|never|rule|behavior|skip) → When/specruns context gathering → Then the plan output includes a "Rule Touchpoints" section listing all grep'd symbols and their file:line locations.Assumptions: Trigger keyword set is finalized in
references/behavior-rule-detection.md; ≥2-keyword threshold catches #533-style ACs without flagging "set default value to 5".AC-2:
/qaverifies behavior at all touchpointsVerification: Integration Test
Scenario: Given a feature branch where the OLD rule's symbol (e.g.
BUG_LABELSshort-circuit) survives → When/qareviews the behavior-rule AC → Then that AC is markedNOT_METand the comment listspath:linefor every survival.Assumptions: "Inverse keyword" set can be derived from the AC text (e.g. AC says "spec on by default" → search for
skip spec/SKIP_PHASES); fallback to inverse English phrasing when no symbol matches.AC-3: Shared heuristic documented
Verification: Manual Test (doc inspection + link grep)
Scenario: Given
references/behavior-rule-detection.mdexists in all 3 skill mirrors → When grep'ingspec/SKILL.mdandqa/SKILL.md→ Then both link to the doc with relative path. Doc covers: trigger keywords, grep patterns, symbol categories, false-positive guards, fixtures from #533.AC-4: 3-dir sync
Verification: Integration Test
Scenario: Given edits to
spec/SKILL.md,qa/SKILL.md, andreferences/behavior-rule-detection.md→ When runningnpx tsx scripts/check-skill-sync.ts→ Then the script reportssynced 3/3for every touched file (nodivergedormissingentries).AC-5: Tests verify trigger conditions
Verification: Unit Test + Integration Test
Scenario:
detectBehaviorRule(ac)runs → Then returnstriggered: true.triggered: false.BUG_LABELS/DOCS_LABELSconstants) → WhenfindTouchpoints(ac, repoRoot)runs → Then it returns paths forphase-mapper.tsandbatch-executor.ts.Assumptions: Detection logic exposed as a callable TS module (not pure prompt) so it's unit-testable.
AC-6: CHANGELOG entry
Verification: Manual Test
Scenario:
CHANGELOG.mdhas a bullet under[Unreleased] / ### Addedreferencing both #552 (this) and #533 (motivating miss).Implementation Plan
Phase 1: Shared heuristic + runtime module
src/lib/heuristics/behavior-rule-detector.tsexporting:detectBehaviorRule(ac: AcceptanceCriterion): { triggered: boolean; keywords: string[] }(≥2 keywords OR explicit pattern).findTouchpoints(ac, repoRoot): TouchpointHit[](greps symbols + comment patterns; returns{ path, line, snippet }).findSurvivingInverseSymbols(ac, repoRoot, diffPaths): TouchpointHit[](for /qa — searches blast radius for OLD-rule survivors).references/behavior-rule-detection.md(source of truth:.claude/skills/) covering trigger keywords, symbol categories (constants like*_LABELS, function names, comment patterns), false-positive guards, and the feat(assess): default spec phase ON, remove bug/docs auto-skip #533 fixture.Phase 2: Wire /spec (proactive)
.claude/skills/spec/SKILL.md, add a new "Rule Touchpoints" subsection under Context Gathering (after the existing "Sibling-site Scan" block). It callsdetectBehaviorRuleper AC; on hit, runsfindTouchpointsand appends results to the plan output template under a new## Rule Touchpointssection.references/behavior-rule-detection.mdfrom the new subsection.Phase 3: Wire /qa (reactive)
.claude/skills/qa/SKILL.md, add### 6e. Behavior-Rule Survival Checkafter### 6d. Adversarial Re-Read. Trigger: any AC for whichdetectBehaviorRulereturnstriggered: true. On survival → AC markedNOT_MET, file paths/line numbers listed.READY_FOR_MERGE. Coordinate with feat(qa): wire CHANGELOG gate into §7 verdict algorithm so it actually blocks READY_FOR_MERGE #585 (also touching §7) — likely sequential.references/behavior-rule-detection.md.Phase 4: 3-dir sync, tests, CHANGELOG
.claude/skills/,templates/skills/,skills/(3 files × 3 dirs = 9 file touchpoints). Runnpx tsx scripts/check-skill-sync.tsand verify 3/3.src/lib/heuristics/__tests__/behavior-rule-detector.test.tscovering AC-5 trigger/non-trigger fixtures + the feat(assess): default spec phase ON, remove bug/docs auto-skip #533 integration fixture. Note: tests must use the verbatim feat(assess): default spec phase ON, remove bug/docs auto-skip #533 AC text, not synthetic — seefeedback_motivating_example_regression.mdandfeedback_synthetic_test_fixture_trap.md.[Unreleased] / ### Added: "Behavior-rule cross-touchpoint detection in/specand/qa(feat(spec,qa): detect behavior-rule implementations across skill+runtime touchpoints #552, motivated by miss in feat(assess): default spec phase ON, remove bug/docs auto-skip #533)."Design Review
src/lib/heuristics/module, not insideac-linter.tsorscope/. Per Non-Goals, this is additive detection, not validation. Heuristics is the right neighborhood for "warns about likely problems without blocking."detectBehaviorRule,findTouchpoints) + a third for/qainverse-symbol survival. Reject (a) a class wrapper — no state to encapsulate; (b) auto-fix — explicitly out of scope per Non-Goals; (c) pure prompt-only — fails AC-5's unit-test requirement.src/lib/scope/analyzer.ts(pure analysis returning structuredmetrics+recommendation). SKILL.md calls the module vianpx tsxexactly like it already callsextractAcceptanceCriteria/lintAcceptanceCriteria/performScopeAssessment.findTouchpointsandfindSurvivingInverseSymbolssolve different problems. Touchpoints surfaces all implementations (helpful even when none are stale). Survival check filters to the inverse only and runs against the diff blast radius. Collapsing them obscures intent. Keep separate; share helpers.Conflict Risk Analysis
Three live worktrees touch overlapping files (none have committed work yet, but coordination still matters):
qa/SKILL.md§7 verdict algorithmqa/SKILL.md+spec/SKILL.md(Skill() namespace fix)spec/SKILL.mdac-linter title-body#551 (also flagged by /assess) is CLOSED — no conflict.
Feature Quality Planning
All standard checks pass. Notable:
/qaruntime adds one grep pass per behavior-rule AC. Short-circuit whendetectBehaviorRulereturns 0 hits across all ACs. Document the budget inreferences/behavior-rule-detection.md.Open Questions
behavior-rule-detector.tsis the source of truth; the reference doc cites it. Reason: AC-5 unit-tests need them stable; doc can drift. Impact if wrong: keyword tuning becomes a code change instead of a doc change.findSurvivingInverseSymbolsscan the whole repo or just the diff blast radius? Recommendation: diff blast radius (changed files + their importers, 1 hop). Reason: cheaper and matches the AC-2 "diff's blast radius" wording. Impact if wrong: false positives from unrelated pre-existing legacy code.references/behavior-rule-detection.md(relative) — match how existing skills linkverification-criteria.md. Impact if wrong: cosmetic.Recommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: enabled (forced by SCOPE_WARNING; aligns with
-qfrom /assess)Reasoning: AC-5 has Unit Test + Integration Test verification → testgen recommended (matches /assess). SCOPE_WARNING auto-enables
-q. No UI/browser changes → notestphase.Label Review
Current:
enhancementRecommended:
enhancement,plannedReason: Plan approved — add
plannedper skill convention. Quality Loop will auto-enable from SCOPE_WARNING (no need for an explicitquality-looplabel).→
gh issue edit 552 --add-label plannedadmarble commentedon May 8, 2026
Test Stubs Generated
Counts explained
Unit + Integration Test Stubs (AC-5, plus AC-1/AC-2 underlying coverage)
File:
src/lib/heuristics/__tests__/behavior-rule-detector.test.tsdetectBehaviorRuletriggers onDefault rule becomes X,Always include Y,Never skip Z; does NOT trigger onUpdate line 42 of foo.ts,Add field to interface X, orset default value to 5(single-keyword false-positive guard); explicitalways X unless Ypattern overrides the ≥2-keyword threshold.findTouchpointsfinds thephase-mapper.ts+batch-executor.tsshort-circuit sites against the feat(assess): default spec phase ON, remove bug/docs auto-skip #533 verbatim AC text, with{ path, line, snippet }shape.findSurvivingInverseSymbolsflags survival inside diff blast radius, returns empty on clean diffs, scopes to changed-files + 1-hop importers, falls back to inverse English phrasing when no symbol matches.⚠ Fixture rule (per
feedback_motivating_example_regression.mdandfeedback_synthetic_test_fixture_trap.md): the #533 fixture must use the verbatim AC text from issue #533 and a real repo snapshot containing the actualBUG_LABELS/DOCS_LABELSshort-circuit. Synthetic fixtures combining markers will hide false negatives.Integration Test Stubs
File:
__tests__/integration/behavior-rule-spec-wiring.integration.test.ts— AC-1qa-markdown-only-ci-snippet.integration.test.tspattern: extracts thenpx tsx -esnippet from.claude/skills/spec/SKILL.mdverbatim and runs it. Catches drift between SKILL.md prose and the underlying TS module.references/behavior-rule-detection.md; SKILL.md invokesfindTouchpointsvianpx tsx -e.Rule Touchpointssection),set default value to 5does not trigger.File:
__tests__/integration/behavior-rule-qa-wiring.integration.test.ts— AC-2NOT_METwithpath:linelist.File:
__tests__/integration/behavior-rule-skill-sync.integration.test.ts— AC-4npx tsx scripts/check-skill-sync.tsand assertssynced 3/3forspec/SKILL.md,qa/SKILL.md, and the newbehavior-rule-detection.mdreference doc.Manual Test Checklist — AC-3 (Shared heuristic documented)
Prerequisites
references/behavior-rule-detection.mdexists in all 3 skill mirrors (.claude/skills/,templates/skills/,skills/)Verification
default,always,never,rule,behavior,skip)*_LABELS, function names, comment patterns)always X unless Ypattern).claude/skills/spec/SKILL.mdlinks the doc with relative path.claude/skills/qa/SKILL.mdlinks the doc with relative pathManual Test Checklist — AC-6 (CHANGELOG entry)
Prerequisites
CHANGELOG.mdis on the feature branch with the new entryVerification
## [Unreleased]and### Added/specand/qa" (or equivalent wording)Files created
src/lib/heuristics/__tests__/behavior-rule-detector.test.ts__tests__/integration/behavior-rule-spec-wiring.integration.test.ts__tests__/integration/behavior-rule-qa-wiring.integration.test.ts__tests__/integration/behavior-rule-skill-sync.integration.test.tsNext steps
/exec 552to implementsrc/lib/heuristics/behavior-rule-detector.tsand the SKILL.md wiring.throw new Error(...)and the commentedimportline with real assertions as the implementation lands.npx vitest run src/lib/heuristics __tests__/integration/behavior-rule-*.Generated with Claude Code
admarble commentedon May 8, 2026
Progress Update —
/execcompletePR: #607
AC Coverage
/specsurfaces touchpoints proactively.claude/skills/spec/SKILL.md:154-195(### Rule Touchpoints (Conditional)+## Rule Touchpointsplan-output section)/qaverifies behavior at all touchpoints.claude/skills/qa/SKILL.md:2026-2080(section 6e) wired into section 7 verdict viabehavior_rule_survival_status(Survivors Found → AC_NOT_MET) at lines 2114, 2137_shared/references/behavior-rule-detection.md(158 lines: trigger keywords, threshold, symbol categories, inverse-keyword map, false-positive guards, performance budget, #533 fixture); both SKILL.md files link via../_shared/references/behavior-rule-detection.mdnpx tsx scripts/check-skill-sync.tsreportssynced spec/SKILL.md — 3/3 match,synced qa/SKILL.md — 3/3 match,synced _shared/references/behavior-rule-detection.md — 3/3 matchfeedback_synthetic_test_fixture_trap.md) + 23 integration tests; 42/42 passing[Unreleased] / ### Addedreferences both #552 and #533Files Changed
src/lib/heuristics/behavior-rule-detector.ts(446 lines) —detectBehaviorRule,findTouchpoints,findSurvivingInverseSymbolssrc/lib/heuristics/__tests__/behavior-rule-detector.test.ts— 19 unit tests__tests__/integration/behavior-rule-spec-wiring.integration.test.ts— AC-1 wiring__tests__/integration/behavior-rule-qa-wiring.integration.test.ts— AC-2 wiring with real-shape feat(assess): default spec phase ON, remove bug/docs auto-skip #533 fixture__tests__/integration/behavior-rule-skill-sync.integration.test.ts— AC-4{.claude,templates,skills}/skills/spec/SKILL.md— Rule Touchpoints subsection (3 mirrors){.claude,templates,skills}/skills/qa/SKILL.md— section 6e + section 7 verdict gate (3 mirrors){.claude,templates,skills}/skills/_shared/references/behavior-rule-detection.md— new reference doc (3 mirrors)CHANGELOG.md—[Unreleased] / ### AddedentryQuality Plan Alignment
detectBehaviorRuleis a cheap regex pass;findTouchpoints/findSurvivingInverseSymbolsshort-circuit to[]when not triggered;/qascope bounded to diff blast radiusBEHAVIOR_KEYWORDSconst in TS (source of truth); doc cites it; explicitalways X unless Ypattern overrides single-keyword guardTest/Build/Lint Results
npm run build: ✅ Passes (tsc)npm run lint: ✅ Passes (eslint --max-warnings 0)npx vitest run src/lib/heuristics __tests__/integration/behavior-rule-: ✅ 42 passed (4 test files)Pre-PR Confidence Check
findSurvivingInverseSymbolsheuristic is intentionally simple — it greps the diff blast radius for inverse keywords from theINVERSE_KEYWORDSmap. False positives are possible when an unrelated comment mentions an inverse term inside a changed file; the doc calls this out and the per-file cap mitigates noise. Tuning is a doc/const change, not a code refactor.npx tsx -einvocation that production runs.Conflict Coordination
Per /spec Conflict Risk Analysis, #585 was flagged as also touching qa/SKILL.md section 7. #585 has not yet landed; this PR adds
behavior_rule_survival_statusto the section 7 algorithm in a way that is additive (newELSE IFbranch) and should rebase cleanly when #585 lands.Next Steps
/qa 552once PR CI is greenadmarble commentedon May 8, 2026
QA Review for Issue #552
AC Coverage
/specsurfaces touchpoints proactivelyRule Touchpoints (Conditional)subsection added in.claude/skills/spec/SKILL.md:154-195; emits a## Rule Touchpointsplan section when triggered. Mirrored 3/3./qaverifies behavior at all touchpoints### 6e. Behavior-Rule Survival Checkadded in.claude/skills/qa/SKILL.md:2026-2080, wired into §7 verdict algorithm via newbehavior_rule_survival_statusgate (Survivors Found → AC_NOT_MET). Mirrored 3/3._shared/references/behavior-rule-detection.md(158 lines): trigger keywords, threshold rationale, symbol categories, inverse-keyword map, false-positive guards, performance budget, #533 fixture. Both SKILL.md files link via../_shared/references/behavior-rule-detection.md.npx tsx scripts/check-skill-sync.tsreportssynced 3/3 matchforspec/SKILL.md,qa/SKILL.md, and_shared/references/behavior-rule-detection.md(verified live).feedback_synthetic_test_fixture_trap.md. Triggers:Default rule becomes X,Always include Y in response payload behavior,Never skip Z. Non-triggers:Update line 42 of foo.ts,Add field to interface X,set default value to 5(single-keyword guard). Explicit-pattern override (always X unless Y) covered.CHANGELOG.md[Unreleased] / ### Addedreferences both #552 and #533 as motivating miss.Coverage: 6/6 AC items fully met
Original ACs: 6/6 met
Derived ACs: N/A (no derived ACs in spec plan)
Quality Plan Verification
detectBehaviorRulecheap regex pass;findTouchpoints/findSurvivingInverseSymbolsshort-circuit ontriggered: false;/qascope bounded to diff blast radius)always X unless Yoverride;BEHAVIOR_KEYWORDSconst is source of truth, doc cites it)Quality Plan Status: Complete
CI Status
typecheckvalidate-skillsvalidate-pluginSetup Directory CreationHooks ValidationPlugin Structure Validationbuild (20.x)build (22.x)CI Summary: 6 passed, 2 pending, 0 failed
CI-related AC items: None (no AC asserts "CI passes"); build matrix pending does not gate verdict
Markdown-only relaxation: N/A (diff includes TS source + integration tests)
Quality Metrics
any)unknown as stringin test for undefined-defense)Build Verification
npm run build✅ Passed (tscclean exit, no output)Test Coverage Analysis
src/lib/heuristics/behavior-rule-detector.tssrc/lib/heuristics/__tests__/behavior-rule-detector.test.ts(19 unit) + 3 integration suites.claude/skills/spec/SKILL.md(3 mirrors)__tests__/integration/behavior-rule-spec-wiring.integration.test.ts.claude/skills/qa/SKILL.md(3 mirrors)__tests__/integration/behavior-rule-qa-wiring.integration.test.ts_shared/references/behavior-rule-detection.md(3 mirrors)Coverage: 1/1 source file has direct unit coverage; SKILL.md prompt-shell boundaries covered by 3 integration suites (AC-1 wiring, AC-2 wiring, AC-4 sync). Test corpus uses verbatim #533 AC text per
feedback_synthetic_test_fixture_trap.md.Code Review
Strengths:
detectBehaviorRule,findTouchpoints,findSurvivingInverseSymbols) with each function responsible for one phase concern; rejecting the "one parameterized function" alternative is justified in the spec design review.safeReadFile/statSync, walk-skip set for noisy dirs.findTouchpoints, 50 infindSurvivingInverseSymbols) prevents one chatty file from drowning out the rest.BEHAVIOR_KEYWORDSexported as the TS source of truth, doc cites it (matches the spec Open Question recommendation).INVERSE_KEYWORDSmap asymmetric on purpose (asserted "always" → search "skip"/"never"/etc., not "always" itself).findTouchpointswalk (*.test.ts,*.spec.ts) — they implement checks, not rules.qa-wiringsuite uses real-shape fixture (BUG_LABELSshort-circuit inphase-mapper.ts).Issues:
Suggestions (non-blocking):
findSurvivingInverseSymbolstotal cap is50(line 300) but documented as200in the reference doc's "Per-file cap (3) + total cap (200) onfindTouchpointsresults" — the reference doc only documentsfindTouchpointscaps, notfindSurvivingInverseSymbols. Consider documenting the 50-survivor cap and rationale (keeps QA output readable).INVERSE_KEYWORDSmap could be expressed as a typed constant that the doc parses, rather than duplicating the table in markdown — current setup is readable but two sources can drift.Test Quality Review
{path, line, snippet}shape and verbatim AC text matches; no internal state probed.Anti-Pattern Detection
Code Patterns
src/lib/heuristics/behavior-rule-detector.ts:120description: undefined as unknown as stringCritical Issues: 0
Warnings: 0
Dependency Audit
N/A - No
package.jsonchanges.Call-Site Review
New exported functions detected: 3 (
detectBehaviorRule,findTouchpoints,findSurvivingInverseSymbols)detectBehaviorRulefindTouchpoints(gate),findSurvivingInverseSymbols(gate); SKILL.mdnpx tsx -esnippets in spec/SKILL.md and qa/SKILL.mdfindTouchpointsnpx tsx -esnippetdetectBehaviorRule.triggered === truefindSurvivingInverseSymbolsnpx tsx -esnippetdetectBehaviorRule.triggered === trueFindings:
detectBehaviorRule.triggeredfirst (cheap short-circuit per performance budget). No unconditional calls observed.process.cwd()asrepoRoot. Correct under/specand/qainvocation contexts.Execution Evidence
npm run buildnpx vitest run src/lib/heuristics __tests__/integration/behavior-rule-npx tsx scripts/check-skill-sync.tssynced 3/3 matchfor all 3 newly-touched filesnpx tsx -e ...per qa/SKILL.md §6eEvidence status: Complete
Skill Command Verification
Skill files changed: 2 SKILL.md (× 3 mirrors)
.claude/skills/spec/SKILL.mdnpx tsx -esnippet)behavior-rule-spec-wiring.integration.test.ts— runs the verbatim snippet).claude/skills/qa/SKILL.mdnpx tsx -esnippet)behavior-rule-qa-wiring.integration.test.ts— uses parallel snippet shape)Verification Status: Passed (snippets are not just syntactically valid but are run end-to-end by integration tests)
Detection Pattern Verification
N/A — The skill markdown changes do not add raw
grep/awk/jq/sedcommands or freestanding regex literals. They invoke the typed TS module vianpx tsx -e, and the regex/pattern logic lives insrc/lib/heuristics/behavior-rule-detector.tscovered by 19 unit tests against verbatim #533 fixture. (The keyword regex\bdefault\betc. is in TS, not in markdown.)CLI Registration Verification
N/A — No
RunOptionsinterface orbin/cli.tschanges.Skill Change Review
npx tsx -esnippets are exercised by their respective integration test files.detection.triggered,detection.keywords,detection.matchedPattern,survivors[].{path,line,snippet}— all asserted in tests.npx tsx(already a sequant runtime dep).Smoke Test
detectBehaviorRuleon #533 verbatim texttriggered: true, keywords includedefault,always,skip,ruledetectBehaviorRuleonUpdate line 42 of foo.tstriggered: falsefindTouchpointson #533 verbatimphase-mapper.tsandbatch-executor.tshitsfindSurvivingInverseSymbolson tmp fixture w/ legacyBUG_LABELSshortcutpath:line[]Smoke Test Status: Complete
Manual Test ACs
../_shared/references/behavior-rule-detection.mdlink; sync check confirms 3/3 mirroring.[Unreleased] / ### Addedentry references #552 + #533, includes feature description, motivation, and test reference.Manual Test Enforcement: 2/2 manual-test ACs verified.
CHANGELOG Verification
[Unreleased]entry### AddedResult: CHANGELOG requirements met
Risk Assessment
findSurvivingInverseSymbolsheuristic can false-positive on definitional documentation that mentions inverse keywords (e.g., this PR's ownbehavior-rule-detection.mdlistsskip/exclude/bypassas inverse keywords fordefault/always). This isn't a regression on the feat(assess): default spec phase ON, remove bug/docs auto-skip #533-style use case (the primary motivation), but it's a real edge case for "feature-add ACs that describe the detector itself." The reference doc's per-file/total caps mitigate noise.#533-style rule-flips. Would be a 5-minute test to add as a follow-up.src/lib/scope/analyzer.tsis the closest analogue (cited in spec design review as the pattern followed).src/lib/heuristics/have the same root-cause pattern (this is a new directory).Adversarial Re-Read
behavior-rule-detector.test.ts) and structurally in the qa-wiring integration test (real-shapeBUG_LABELSshort-circuit inphase-mapper.ts). Both run on every test pass.npm run build,vitest,check-skill-sync.ts, self-dogfood QA snippet) are post-fix validations, not bug reproductions. Build was clean before AND after; tests pass after; sync check confirms 3/3 mirroring.dfa3740; no uncommitted changes; PR #607 open and mergeable; build matrix pending in CI but lint/typecheck/validate-skills/validate-plugin/Hooks Validation/Plugin Structure Validation already SUCCESS.src/lib/heuristics/) with no prior detector to drift with. Intra-file: each function is single-call-site within itself; spec/qa SKILL.md snippets are independent invocations with the same gate logic.ac-linter.tsorscope/).Findings:
_shared/references/behavior-rule-detection.md: 30 hits,qa/SKILL.md: 20 hits). These are definitional mentions of inverse keywords, not stale OLD-rule code. The reference doc already documents per-file caps and false-positive guards but does not specifically call out this "AC describes the detector" recursion case. Recommend: small note inreferences/behavior-rule-detection.mdflagging that ACs describing the detector itself will trip survival on the new feature's own docs (acceptable; humans can override). Track as follow-up if anyone hits it; not blocking this PR since the primary use case (feat(assess): default spec phase ON, remove bug/docs auto-skip #533-style rule-flips on additive PRs) is unaffected.Status: Gaps Found (recommendation only — meta-recursion edge case)
Behavior-Rule Survival Check
Self-dogfood note: I ran §6e against #552's own AC-1 (which describes the trigger keywords). The detector triggered (all 6 keywords present); 50 survivors returned, all in this PR's own definitional documentation (
_shared/references/behavior-rule-detection.md× 30,qa/SKILL.md× 20). These are not OLD-rule survivors — they're definitional content of the new feature.Status: N/A (this PR is a feature-add, not a rule-flip; no OLD rule to survive). Recorded as a gap in Adversarial Re-Read for follow-up tuning.
Verdict: AC_MET_BUT_NOT_A_PLUS
All 6 ACs literally MET with strong evidence: 42/42 tests passing (verbatim #533 fixture per
feedback_synthetic_test_fixture_trap.md),tscclean, 3-dir syncsynced 3/3 match, CHANGELOG entry comprehensive and well-formatted, both SKILL.md prompt-shell boundaries covered by integration tests. The implementation respects all 3 stated Non-Goals (detection-only, scoped to spec/qa, additive) and follows the spec plan's design review (3-function API,BEHAVIOR_KEYWORDSas TS source of truth, asymmetricINVERSE_KEYWORDSmap).Why not READY_FOR_MERGE: Adversarial re-read surfaced a non-blocking meta-recursion edge case — when the survival check is run against #552's own AC-1/AC-2 (which list the 6 trigger keywords as the keyword definition), it self-fires with 50 survivors, all in the new feature's own definitional documentation. The reference doc's existing per-file/total caps mitigate noise but don't specifically call out this case. Recommend a small follow-up note in
references/behavior-rule-detection.mdflagging that ACs describing the detector itself will trip survival on its own docs. Not blocking — the primary use case (#533-style rule-flips on additive PRs) is unaffected and the cap of 50 prevents runaway output.Pending build matrix CI:
build (20.x)andbuild (22.x)are still IN_PROGRESS at QA time. Localtscpasses clean. No AC asserts "CI passes," so this does not gate the verdict.Documentation
[Unreleased] / ### Added(issue feat(spec,qa): detect behavior-rule implementations across skill+runtime touchpoints #552, feat(assess): default spec phase ON, remove bug/docs auto-skip #533)_shared/references/behavior-rule-detection.md(3-dir mirrored)Next Steps
references/behavior-rule-detection.mddocumenting the meta-recursion limitation — when an AC enumerates the 6 trigger keywords as part of describing the detector trigger condition, the survival check self-fires on the new feature's own definitional documentation. The per-file/total caps already mitigate noise, but a docs callout would prevent confusion if anyone re-runs/qaagainst this PR./docs 552if any user-facing skill behavior change requires admin-facing documentation updates beyond CHANGELOG (likely N/A — skill-internal change).fix(#552): close two adversarial-review gaps in behavior-rule detector
fix(#552): close remaining gaps — inflections, inverse noise, cap con…
docs(#552): note inverse-phrase fallback as deferred follow-up
feat(#552): detect behavior-rule implementations across skill+runtime…
admarble commentedon May 11, 2026
Documentation Generated
File:
docs/features/behavior-rule-detection.mdSections Included
/specoutput — new "Rule Touchpoints" table inserted between Implementation Plan and Design Review/qaoutput — new "Behavior-Rule Survival Check" section + status semantics (Clean / Survivors Found / N/A) + verdict floor atAC_NOT_METbehavior-rule-detector.tsAPI and the shared reference docNext Steps
Ready to merge.
docs: backfill user-facing docs for issues since v2.2.0
fix(#769): section-aware path extraction; drop background-only citati…
fix(#819): wire §6f into the verdict algorithm, narrow the danger cla…
feat(#819): shared trust-model block — issue/PR text is data, not age…
fix(#769): section-aware path extraction; drop background-only citations
fix(#1265): check-skill-sync.ts's N/N denominator follows MIRROR_DIRS…
fix(#1265): ship a slim plugin/ folder instead of the whole dev repo (#…