Repository navigation
Conversation
5 tasks
…reference-vs-call asymmetry (#956)
…utology-detector-still-flags-a-subprocess # Conflicts: # CHANGELOG.md
admarble
deleted the
feature/956-fix-qa-tautology-detector-still-flags-a-subprocess
branch
September 8, 2026 01:34
This was referenced Sep 8, 2026
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
Teaches the tautology detector to resolve constructed spawn paths and to see through the indirection layers a purely textual scan cannot. The build-output heuristic recognized a spawn as production only when the source held a contiguous
dist/,hooks/*.shorscripts/**substring. Two idiomatic constructions leave no such substring:Path expressions are now resolved to an absolute path (from the analyzed file's own location, never
process.cwd()) and checked against the repository.Four adjacent "one indirection layer" misses are fixed alongside, because the corpus classification would otherwise be unexplained noise (spec OQ-1): expression-bodied arrow helpers, dynamic destructured
await import(), call-site argument binding into helper parameters, and — the last residual class — a suite handle instantiated in abeforeEach/beforeAllhook and driven in the blocks.Corpus flags drop 132 → 25; repo-wide 600 → 201 across 288 test files.
Guardrails against over-permissiveness
Widening the exemption is the real risk, so each widening is bounded:
node_modules/, and name an executable extension. AmkdtempSync(...)sandbox,process.env.X, or an interpolated template resolves tonulland is never production.client.callTool(...)), not merely read as a value. The second gate was added after measurement, not by design instinct — see below.False-negative sweep (repo-wide, 288 test files): flagged
600 → 201; newly-clean = 399, newly-flagged = 0. Every legitimately-flagged block held its count exactly: the sixfile-content-legitgate files (8/4/4/3/3/2) andpre-tool-hook.integration.test.ts's harness-sanity block (1).Why the call-shape gate exists
The first version of the hook rule gated only on "the hook body reaches production." Measured, it silenced
pre-tool-hook.integration.test.ts:1529— a harness sanity check (confirms jq is actually unavailable on the filtered PATH) that spawns only a system binary but reads a hook-assignednoJqPathstring. Repo-wide newly-clean jumped to 408. Adding the call-shape gate restored that block to flagged and is pinned by a regression test.AC verification
scripts/qa/tautology-detector-cli.test.tsscores 0 tautological-t "956 target"passes; row 6 → 0__dirnameidiom still flagged-t "956 negative"passes; mutation-verified belowpre-tool-hook.integration.test.tsrecognized-t "956 segments"asserts≤ 1; row 4 → 1 (L1529 only)subprocess-fp-fixedrow readsafter = 0Mutation records
Mutation-verified: AC-2 — removed the
__dirnamerecognition (THIS_DIR_EXPRESSIONSbranch inresolvePathExpressionreplaced with a deadif (false));src/lib/test-tautology-detector.corpus.test.ts > 956 negativefailed on thespawns the resolved CLIassertion; restored.Mutation-verified: AC-4 — dropped the
calledAsHandlecall-shape gate on hook-assigned handles (replaced withif (true));src/lib/test-tautology-detector.test.ts > still flags a block that only reads a value the hook computedfailed; restored.AC-4 — corpus classification (33 files)
__tests__/cleanup-worktree-branch-resolution.integration.test.ts__tests__/cleanup-worktree-checkout-guard.integration.test.ts__tests__/integration/behavior-rule-qa-wiring.integration.test.ts__tests__/integration/behavior-rule-skill-sync.integration.test.ts__tests__/integration/behavior-rule-spec-wiring.integration.test.ts__tests__/integration/mcp-e2e.integration.test.ts__tests__/integration/mcp-serve-multi-client.integration.test.ts__tests__/integration/mcp-serve.integration.test.ts__tests__/integration/qa-markdown-only-ci-snippet.integration.test.ts__tests__/integration/skill-sync.integration.test.ts__tests__/integration/spec-marker-skill-sync.integration.test.ts__tests__/new-feature-checkout-guard.integration.test.ts__tests__/new-feature-frozen-install.integration.test.ts__tests__/plugin-staleness-warning.integration.test.ts__tests__/pre-tool-hook.integration.test.tsscripts/qa/precheck-cli.integration.test.tsscripts/qa/tautology-detector-cli.test.tsscripts/spec/ground-check-cli.integration.test.tssrc/commands/__tests__/locks-cli.integration.test.tssrc/commands/cli.integration.test.tssrc/commands/doctor.integration.test.tssrc/commands/numeric-flags.integration.test.tssrc/commands/run-tui.integration.test.tssrc/commands/serve.integration.test.tssrc/commands/sync-source-invocation.integration.test.tssrc/lib/__tests__/merger-release-checkout-lock.integration.test.tssrc/lib/locks/checkout-lock.integration.test.tssrc/lib/locks/lock-manager.integration.test.tssrc/lib/test-tautology-detector.test.tssrc/lib/workflow/abort-logging.integration.test.tssrc/lib/workflow/phase-registry.integration.test.tssrc/lib/workflow/state-update-cli.test.tssrc/mcp/server-extended.test.tsTOTALS before=132 after=25 files=33
Class definitions
subprocess-fp-fixed— false positive of this issue's class; all readafter = 0.file-content-legit— gate tests thatreadFileSynca skill/hook/template and assert on its text. Tautological by the detector's definition and legitimately so: they call no production code by design.harness-sanity-legit—pre-tool-hook.integration.test.ts:~1529, correctly flagged per the fix(#963): pre-tool.sh No-Changes Guard resolves cd targets instead of silently checking the wrong directory #966 comment.Every row sits inside the three-value enum AC-4 specifies. The previous revision of this PR used a fourth class,
deferred-fp, forsrc/mcp/server-extended.test.ts(27 → 21); that file is now0and the fourth class is gone.Test plan
npx vitest run src/lib/test-tautology-detector.corpus.test.ts -t "956 target"→ passes… -t "956 negative"→ passes… -t "956 segments"→ passesnpx vitest run src/lib/test-tautology-detector.test.ts→ 85 passednpm run build→ cleannpm run lint→ clean (0 warnings)npm test— not run locally (see Known gaps)Known gaps
npm test, one losing the worktree. Targeted tests plus build/lint were run instead; CI is the backstop.Refs #956
🤖 Generated with Claude Code
A+ pass (runner, 2026-09-07, commit 3d913f3)
Addresses the QA round-2 notes so this PR can reach READY_FOR_MERGE:
buildPathContextnow has direct unit tests (test-tautology-detector.test.ts, describebuildPathContext (#956)):thisDiris anchored on the analyzed file; the repo root is found by walking up to.git(asserted against this checkout), falls back to the nearestpackage.jsonin a temp tree, and isnullwhen neither exists;varsstarts empty.productionHandlesreference-vs-call asymmetry documented at the use site (testBlockCallsProductionCode, step 3) with the QA's measurement — pre-existing onmain; tightening to call shape moves the repo-wide flagged count 201 → 204 and newly flags a legitimate block (config-resolver.model-roles.test.ts:249) — so the next reader does not redo the analysis. Deliberately not changed (the naive fix regresses).90/90 detector + corpus tests pass; typecheck clean.