Skip to content

fix(#885): count spawns of dist/ build output as production in tautology detector - #887

Merged
admarble merged 3 commits into
mainfrom
feature/885-fix-qa-tautology-detector-scores-subprocess-driven
Aug 2, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/885-fix-qa-tautology-detector-scores-subprocess-driven

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • The tautology detector scored subprocess-driven integration tests (cli.integration.test.ts) 100% tautological because they import only node builtins and exercise production code by spawning node dist/bin/cli.js — a boundary static import analysis can't see through. On any PR touching such a file the local /qa gate produced a wrong 100% verdict, training people to ignore the detector.
  • The detector now counts a block as calling production code when it spawns the project's dist/ build output (execSync/spawnSync/etc.), directly or through a describe/module-scope helper resolved transitively. Detection keys on content (a spawn referencing a build path), never on filename or an opt-out annotation, and stays per-block so genuine tautologies are still flagged.
  • Verified: the real cli.integration.test.ts goes 100% → 0% tautological (all 17 blocks).

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original cli.integration.test.ts not reported tautological ✅ Implemented Real file 100%→0% (all 17 blocks); helper + transitive resolution in collectSpawnHandles (src/lib/test-tautology-detector.ts)
AC-2 Original Spawning build output counts as production, not via filename/annotation ✅ Implemented spawnsBuildOutput keys on a child-process spawn referencing dist/; tests use non-integration filenames and no @tautology-skip
AC-3 Original Genuine tautology still flagged in a subprocess-driven file; no blanket exemption ✅ Implemented Per-block predicate; AC-3 test asserts the local-only block stays tautological while the spawn block does not
AC-4 Original Confirm CI effectiveness; make effective or document local-only ✅ Implemented (option b) Gate is confirmed local/agent-only (CI shallow-checkout → empty git diff main...HEAD); documented in quality-gates.md (×3 mirrors) + CLI header
AC-5 Derived Helper referencing a dist/ string but not spawning is NOT production ✅ Implemented spawnsBuildOutput requires spawn and build-token co-occurrence; AC-5 test

Mutation verification (per repo gate-test policy)

  • Mutation A — spawnsBuildOutput forced to return false: exactly the 5 spawn-detection tests (AC-1 direct, AC-2 direct + inline, AC-1 transitive, AC-3 spawn block) failed; the AC-5 test (asserts a non-spawning helper stays tautological) correctly still passed. Restored.
  • Mutation B — dropped the spawn co-occurrence (SPAWN_PATTERN.test(body) &&) so a dist/ mention alone counts: the AC-5 test failed (expected tautological true, got false). Restored.

Test plan

  • npm run build — passes
  • npm run lint — passes
  • npx vitest run src/lib/test-tautology-detector.test.ts scripts/qa/tautology-detector-cli.test.ts — 63 passed (7 new)
  • Verified real cli.integration.test.ts: 100% → 0% tautological

Files changed

  • src/lib/test-tautology-detector.ts — build-output-var + spawn-helper collectors (transitive), extended per-block predicate
  • src/lib/test-tautology-detector.test.ts — 7 new tests (AC-1/2/3/5)
  • scripts/qa/tautology-detector-cli.ts — AC-4 scope note in header
  • .claude/skills/qa/references/quality-gates.md, skills/…, templates/skills/… — detection rule + local-only advisory scope (3 mirrors synced)
  • CHANGELOG.md — Unreleased → Fixed entry

Closes #885

🤖 Generated with Claude Code

…ogy detector

Subprocess-driven integration tests (cli.integration.test.ts) import only
node builtins and exercise production code by spawning node dist/bin/cli.js.
Static import analysis can't see through the process boundary, so every block
scored 100% tautological and the local /qa gate produced a wrong verdict.

The detector now counts a block as calling production code when it spawns the
project's dist/ build output (execSync/spawnSync/etc.), directly or via a
describe/module-scope helper resolved transitively. Detection keys on content
(a spawn referencing a build path), never on filename or an opt-out annotation,
and stays per-block so genuine tautologies are still reported.

AC-4: documents the gate as a local/agent-only advisory, inert in CI by design.
Entire-Checkpoint: 23c671d114ad
admarble added 2 commits July 31, 2026 17:05
…ss spawns

QA on PR #887 demonstrated a false negative: SPAWN_PATTERN's bare
exec/spawn/fork alternates matched after a dot, so a tautological block
running RegExp.prototype.exec against a dist/ path string was masked as
production-calling. Split the pattern by ambiguity: unambiguous long names
(execFileSync, spawnSync, execSync, execFile) still match anywhere,
including cp.execSync(...); the short generic names now reject a preceding
identifier char or dot.

Mutation-verified: reverting SPAWN_PATTERN to the previous alternation
fails exactly the new regression test ("does not mask a tautology via
method-style .exec() plus a dist/ token"), 59/60 others pass. Real
cli.integration.test.ts stays 0/17 tautological under the new pattern.
…utology-detector-scores-subprocess-driven

# Conflicts:
#	CHANGELOG.md
@admarble
admarble merged commit 579e138 into main Aug 2, 2026
8 checks passed
@admarble
admarble deleted the feature/885-fix-qa-tautology-detector-scores-subprocess-driven branch August 2, 2026 14:06
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.

fix(qa): tautology detector scores subprocess-driven integration tests 100% tautological (cli.integration.test.ts, pre-existing)

1 participant