Skip to content

feat(#298): Add test tautology detector to QA quality gates - #310

Merged
admarble merged 4 commits into
mainfrom
feature/298-feat-add-test-tautology-detector-to-qa-quality-gat
Feb 21, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/298-feat-add-test-tautology-detector-to-qa-quality-gat

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Add automated detection of tautological tests — tests that pass but don't call any production code, providing zero regression protection
  • Integrate into QA quality gates with blocking threshold (>50% tautological = blocks merge)
  • Support both it() and test() styles with skip/only variants

Changes

File Purpose
src/lib/test-tautology-detector.ts Core detection logic with types
src/lib/test-tautology-detector.test.ts 43 unit tests covering all AC items
scripts/qa/tautology-detector-cli.ts CLI for shell script integration
.claude/skills/qa/scripts/quality-checks.sh QA integration (section 10)
src/lib/workflow/qa-cache.ts Add test-quality check type
.claude/skills/qa/references/quality-gates.md Verdict mapping documentation
.claude/skills/qa/references/test-quality-checklist.md Anti-pattern examples

Detection Heuristic

  1. Extract imports from source modules (relative paths ./, ../)
  2. Exclude test libraries (vitest, jest, @testing-library, etc.)
  3. Exclude mock/fixture modules (paths containing mock, fixture, etc.)
  4. For each it()/test() block, check if any imported function is called
  5. Flag blocks with zero production function calls

Verdict Impact

Result QA Verdict
>50% tautological BLOCKING - AC_NOT_MET
1-50% tautological Warning - AC_MET_BUT_NOT_A_PLUS
0% tautological No impact

Test Plan

  • 43 unit tests pass covering:
    • Import extraction (named, default, namespace, aliased)
    • Test block extraction (it, test, .skip, .only)
    • Tautology detection logic
    • Verdict impact calculation
    • Output formatting
  • Build passes (npm run build)
  • Lint passes (npm run lint)

AC Coverage

AC Status Evidence
AC-1: Test files in diff scanned ✅ detectTautologicalTests() processes file list
AC-2: Flag zero production calls ✅ testBlockCallsProductionCode() checks imports
AC-3: Report in Test Quality Review ✅ formatTautologyResults() generates markdown
AC-4: >50% blocks READY_FOR_MERGE ✅ exceedsBlockingThreshold in results
AC-5: Both it() and test() detected ✅ Pattern `/\b(it

Closes #298

🤖 Generated with Claude Code

Add automated detection of tautological tests — tests that pass but
don't call any production code, providing zero regression protection.

Changes:
- Create src/lib/test-tautology-detector.ts with detection logic
- Add 43 unit tests for tautology detection
- Add CLI at scripts/qa/tautology-detector-cli.ts
- Integrate into quality-checks.sh (section 10)
- Add test-quality to QA cache types
- Update quality-gates.md with verdict mapping
- Update test-quality-checklist.md with examples

Detection heuristic:
- Extract imports from source modules (relative paths ./,../)
- Exclude test libraries (vitest, jest, @testing-library, etc.)
- Exclude mock/fixture modules
- For each it()/test() block, check if imported function is called
- Flag blocks with zero production function calls

Verdict impact:
- >50% tautological: BLOCKING (AC_NOT_MET)
- 1-50% tautological: Warning (AC_MET_BUT_NOT_A_PLUS)
- 0% tautological: No impact
… CLI tests

- Fix JSDoc @example to match actual API signature (array-based, not string)
- Add isInsideString() to skip test blocks inside template literals/strings,
  eliminating false positives when test data contains embedded it()/test()
- Extend testBlockCallsProductionCode() with bare reference detection
  (catches callback patterns like items.map(validator))
- Add CLI integration tests (scripts/qa/tautology-detector-cli.test.ts)
- Add 5 new unit tests for string filtering and reference detection
…ndaries

- Rewrite isInsideString() to handle nested template literals via
  expression depth stack: `outer ${`inner`} outer` now parses correctly
- Add comment filtering: // and /* */ blocks are skipped, preventing
  commented-out test blocks from being detected
- Replace triple regex (direct call + method + reference) with single
  identifier-boundary pattern using (?<![\w$]) lookbehind
- Add escapeRegex() for identifiers with special chars (e.g., $ in jQuery)
- Add 4 new tests: nested templates, line comments, block comments, $ identifier
@admarble
admarble merged commit 5025e55 into main Feb 21, 2026
6 checks passed
@admarble
admarble deleted the feature/298-feat-add-test-tautology-detector-to-qa-quality-gat branch February 21, 2026 06:48
admarble added a commit that referenced this pull request Jun 23, 2026
…ng) + CI gate (#742)

* chore(#738): reconcile skill-mirror divergences + CI gate

Skill files live in three mirrored roots (.claude/skills/ canonical,
templates/skills/ consumed by sequant init/sync, skills/ published as
the plugin). check-skill-sync.ts reported 8 diverged, 10 missing — so
downstream installs could receive stale or missing skill content.

- AC-2/AC-3: reconciled all 18 in the canonical direction
  (.claude/skills/ -> mirrors) after per-file review. quality-checks.sh
  needed a MERGE not a blind copy: .claude had test-tautology detection
  (#310), the mirrors had the #278/#303 cache-metrics JSON writer that
  worktree-manager.ts reads for PhaseLog.cacheMetrics. Both features now
  live in all three roots, restoring cache-metrics observability that had
  silently broken here. Dropped the vestigial `- Task` tool grant from the
  security-review mirror (canonical has no Task usage).
- AC-5: check-skill-sync.ts now skips dotfiles/dot-dirs (kills the
  .sequant/.token-usage-*.json false-positive "missing") + documented
  EXCLUDE allowlist escape hatch. collectFiles/EXCLUDE exported and main()
  guarded so the module is importable for tests.
- AC-1: documented the canonical direction in CONTRIBUTING.md
  ("Skill mirror sync") and strengthened the script header.
- AC-4: added `npm run lint:skill-sync` + a CI step (alongside
  lint:skill-calls) that fails the build on any future drift.

Tests: unit (collectFiles dotfile/dot-dir/allowlist skip) + integration
(whole-repo 0 diverged / 0 missing, exit 0).

Entire-Checkpoint: 00964ffb6426

* fix(#738): skip references/ shared dir in skill validation jobs

Reconciling the mirrors (AC-3) propagated references/shared/framework-gotchas.md
into skills/ and templates/skills/, creating a new top-level references/ dir in
each. .claude/skills/ has had this non-skill dir since #43, but the mirrors never
did, so the gap was hidden. Both CI validators (Plugin Structure Validation,
validate-skills) treat every top-level dir except _shared/ as a skill and failed
because references/ has no SKILL.md.

Skip references/ alongside _shared/ in both jobs and in the validate:skills npm
script (POSIX case so it runs under npm's sh). The framework-gotchas.md content
stays propagated — AC-3 still satisfied.

Entire-Checkpoint: c8b3aebfa756

* fix(#738): repoint sync:skills at canonical fixer (was reversed)

`npm run sync:skills` ran `cp -r templates/skills/* .claude/skills/` —
mirror -> canonical, the reverse of the direction this PR establishes and
documents in CONTRIBUTING. A contributor editing the canonical copy and
running the obvious-named `sync:skills` to "sync" would silently revert
their edits to stale mirror content: the exact drift bug #738 fixes,
re-armed under a misleading name. Repoint it at `check-skill-sync.ts --fix`,
which propagates canonical -> mirrors (same logic CONTRIBUTING documents).
Only CHANGELOG referenced the old script (historical #30 entry, left as-is).
Idempotent no-op when already synced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add test tautology detector to QA quality gates

1 participant