Repository navigation
Description
Surfaced while fixing #883 (PR #884). Pre-existing — reproduced against origin/main's version of the file, so nothing in #884 caused it.
scripts/qa/tautology-detector-cli.ts reports 100% tautological for src/commands/cli.integration.test.ts and exits 1, failing 3 of its own CLI tests:
{"totalFiles":1,"totalTests":17,"totalTautological":17,
"overallPercentage":100,"exceedsBlockingThreshold":true}
Pre-existence check — same command against the file as it exists on origin/main:
{"totalFiles":1,"totalTests":16,"totalTautological":16,
"overallPercentage":100,"exceedsBlockingThreshold":true}
100% either way. The count moved 16 → 17 only because #884 added a test.
Cause: subprocess-driven tests are invisible to import analysis
src/lib/test-tautology-detector.ts defines tautological as "does not call any production function", and decides what production means from imports:
node:-prefixed modules are excluded outright (:134)- only relative imports count as production code (
:139-146)
cli.integration.test.ts imports only node builtins (child_process, path, url, fs, os) and nothing relative — because it exercises production code the only way an end-to-end CLI test can: by spawning node dist/bin/cli.js and asserting on its stdout/stderr/exit code. Static import analysis cannot see through a subprocess boundary, so every test in the file scores zero.
These are among the least tautological tests in the repo — they were added precisely because mocked unit tests missed a real bug (the file header cites #86, where getCurrentVersion() returned 0.0.0 and passed all mocked tests).
Why it has been invisible
The detector only scans git diff main...HEAD --name-only, so it fires solely on PRs that touch an affected file. It is also inert in CI: PR #884 went fully green on all 5 checks while these 3 tests failed locally on the same commit. So today the gate produces local-only noise and no CI protection — worth confirming as part of any fix.
Effect
Any PR touching a subprocess-driven integration test file gets a red local npm test with a 100%-tautological verdict that is wrong. That trains people to ignore the detector, which is the failure mode a QA gate can least afford.
Acceptance Criteria
- AC-1:
cli.integration.test.tsis not reported as tautological, because its tests demonstrably exercise production code through a spawned CLI. - AC-2: A test that spawns the project's build output (e.g.
execSync/spawnSyncon a path underdist/) counts as calling production code, rather than being special-cased by filename or silenced by an opt-out annotation. - AC-3: A genuinely tautological test — one asserting only on local variables, calling nothing — is still reported, in a subprocess-driven file too. The fix must not blanket-exempt
*.integration.test.ts. - AC-4: Confirm whether the gate runs at all in CI (PR fix(#883): spawn the CLI flag-surface tests in a manifest-less temp dir #884 suggests it does not) and either make it effective or state plainly that it is a local-only advisory.
Activity
admarble commentedon Jul 31, 2026
Complexity: Standard (4 ACs, 2 directories:
src/lib/,scripts/qa/)AC Quality Check
All four ACs are measurable and each names its own falsification condition — notably AC-3 pins the anti-regression bar ("must not blanket-exempt
*.integration.test.ts") and AC-2 pre-empts the two lazy fixes (filename special-case, opt-out annotation). No vague/unmeasurable/open-ended patterns. AC-4 is investigative-with-a-decision ("confirm … and either make it effective or state plainly") — acceptable; the deliverable is a documented determination, not just prose.Scope Assessment
Non-Goals:⚠️ No explicit Non-Goals section in the issue. Implicit from AC-2/AC-3: do not special-case by filename and do not add an opt-out annotation. Recommend treating "generalizing beyond
dist/build paths" and "making the CLI's own tests independent of live git state" as out of scope (see Open Questions).src/lib/,scripts/qa/) + QA skill docsVerdict: ✅ SCOPE_OK
Root Cause (confirmed by reading the code)
src/lib/test-tautology-detector.tsdecides "calls production code" purely from static imports:isSourceModule()excludesnode:builtins (:134) and counts only relative.//../imports as production (:139-147). A test block is tautological iff its body references none of those imported names (testBlockCallsProductionCode,:465).src/commands/cli.integration.test.tsimports only node builtins (child_process,path,url,fs,os) and spawnsnode dist/bin/cli.js(viacliPath = resolve(projectRoot, "dist/bin/cli.js"),:24). Static analysis can't see through the subprocess boundary →importedFunctionsis empty → every block scores tautological → 100%.Helper indirection matters: blocks invoke the CLI two ways — directly (
execSync(\node ${cliPath} --version`), e.g.:58) **and** through describe/module-scope helpers (runHelp:156,runInUninitializedDir:217,runDryRunStreams:295) that close overcliPath. A per-block scan forexecSync/dist/` alone would miss every helper-driven block. The fix must resolve helpers.AC-4 finding (confirmed): the blocking gate is local/agent-only. It runs only inside
/qavia.claude/skills/qa/scripts/quality-checks.sh:389. In GitHub CI,npm testruns the CLI's own tests (scripts/qa/tautology-detector-cli.test.ts), butactions/checkoutusesfetch-depth: 1(no override inci.yml), so no localmainref exists →git diff main...HEADthrows →getChangedTestFiles()catches and returns[]→ statusskip→ exit 0. That is exactly why PR #884 was green in CI while failing locally. This matches the known-issue note in #810 ("that gate never fires in CI").Acceptance Criteria
AC-1:
cli.integration.test.tsis not reported tautologicalVerification: Unit Test (against the real file content as a fixture)
Scenario: Given
cli.integration.test.ts's actual content → WhenanalyzeTestFile()runs → ThentautologicalPercentageis well below the blocking threshold (target: the spawn-driven blocks all count as production; ideally 0% tautological).Assumptions: Every
it()in that file ultimately spawnsdist/bin/cli.js(verified: all blocks callexecSync/spawnSyncdirectly or via acliPath-closing helper).AC-2: spawning build output counts as production — not via filename/annotation
Verification: Unit Test
Scenario: Given a synthetic test that imports only
node:child_processand doesexecSync(\node ${dist}/bin/cli.js`)(no relative imports, arbitrary non-.integration.filename) → When analyzed → Then the block is non-tautological. **Assumptions:** Detection keys on **content** (a child_process spawn referencing a build-output path), not on the filename and not on any pragma. Mutation check: the fixture must NOT be named*.integration.test.tsand must NOT carry@tautology-skip`, so a filename/annotation shortcut can't satisfy it.AC-3: a genuinely tautological block is still reported, even in a subprocess-driven file
Verification: Unit Test
Scenario: Given one file containing (a) a block that spawns
dist/…and (b) a block that only asserts on local variables and calls nothing → When analyzed → Then (a) is non-tautological and (b) is reported tautological.Assumptions: The spawn signal is applied per-block (extending
testBlockCallsProductionCode), never as a file-level exemption.AC-4: determine CI effectiveness; make effective or document as local-only
Verification: Manual Test + doc assertion
Scenario: Given the finding above (gate is local/agent-only; inert in CI by shallow-checkout) → When we resolve AC-4 → Then either (a) a CI step runs the detector against
origin/main...HEAD, or (b) the local-only advisory nature is stated plainly in.claude/skills/qa/references/quality-gates.md(and/or the CLI header).Recommendation: Option (b) — document as local/agent-only advisory. Rationale below.
Implementation Plan
Phase 1: Extend production-call inference (AC-1, AC-2, AC-3) —
src/lib/test-tautology-detector.ts(?:const|let|var)\s+(\w+)\s*=\s*[^;]*["'][^"']*\bdist/— capturing e.g.cliPath. Also treat any literal string containingdist/…as a build-output token. (Keep the token set ={ literal "dist/", ...capturedVarNames }.)extractBlockBody) and mark its name as a "spawns-build-output" helper iff the body contains a child_process spawn call (execSync|spawnSync|exec|execFile|fork|spawn) that references a build-output token.testBlockCallsProductionCode(body, importedFunctions, spawnHandles): a block counts as production if it references an imported production fn OR references a spawn-helper name OR its own body directly contains a spawn call referencing a build-output token. Keep it per-block so AC-3 holds.spawnHandlesfromanalyzeTestFile()into the per-block check (compute once per file). No changes to the file-level exemption path (@tautology-skipstays a genuine opt-out, untouched).Phase 2: Tests (AC-1/2/3) —
src/lib/test-tautology-detector.test.tsintegrationfilename, onlynode:child_processimport, directexecSync(node …/dist/bin/cli.js)→ non-tautological. Mutation-gate: confirm the test fails if the spawn detection is removed.dist/token → both flagged (guards against blanket-exemption).cliPath-closing helper (not a direct spawn) → non-tautological. Optionally load the realcli.integration.test.tscontent and assert its percentage is ≤ threshold.Phase 3: AC-4 determination + doc
.claude/skills/qa/references/quality-gates.md(near:170) and the CLI header (scripts/qa/tautology-detector-cli.ts) stating the detector is a local/agent-side advisory run by/qa, inert in GitHub CI by design (shallow checkout → empty diff). If option (a) is chosen instead, add aci.ymlstep withfetch-depth: 0(or explicitgit fetch origin main) that runstautology-detector-cli.tsagainstorigin/main...HEAD.Design Review
test-tautology-detector.ts's inference layer — same placeisSourceModule/testBlockCallsProductionCodealready answer "does this block touch production?". The subprocess boundary is just another way a block reaches production; it belongs beside the import inference, not in a caller.@tautology-skipon the file — banned by AC-2 and would silence AC-3's real tautologies; (c) executing/tracing the tests — far too heavy for a static linter.analyzeTestFile;extractBlockBodyis reused for helper bodies. Regex/string scanning is consistent with the file's existing style (no AST).dist/literal instead of an AST?" — the whole detector is deliberately regex-based; introducing a TS parser here is disproportionate. "Why onlydist/?" — it's the project's build output and matches AC-2's example; broadening tobuild//lib//config-driven is a noted open question, not required. Reviewer should verify the helper collector doesn't over-count (a helper that referencesdist/in a comment/string but never spawns) — hence the requirement that a spawn call AND a build token co-occur.Feature Quality Planning
All standard checks pass. Notable items:
dist/in a string but doesn't spawn (should NOT become a handle).dist/with a forward slash; the build output path is constructed viaresolve()but the source literal in tests is always"dist/bin/cli.js". Fine, but note Windows path separators won't appear in source literals.Derived ACs
dist/string but performs no spawn is NOT treated as production.Open Questions
fetch-depth: 0+ failure-mode agreement). Impact if wrong: a follow-up adds the CI step later.dist/? — Recommendation: no; keepdist/(the project's build dir, matches AC-2's example). Impact if wrong: a project that builds tolib//out/would still mis-score, but that's not sequant. Could later read the build dir from config.Recommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: enabled (SCOPE_OK but the fix is inference logic in a QA gate — regressions here are high-blast-radius)
Reasoning: All ACs are Unit-Test-verifiable →
testgenshould stub the three fixtures (spawn-direct, spawn-via-helper, genuine-tautology-in-subprocess-file) before implementation. No UI → notestphase. Not security-sensitive → nosecurity-review.Label Review
Current:
bugRecommended:
bug(addplanned)Reason: Single-feature localized fix in QA tooling; no
complex/refactor/breakingwarranted.Quality Loop: Won't auto-enable from scope (SCOPE_OK); recommend enabling manually per the reasoning above.
admarble commentedon Jul 31, 2026
Exec Progress Update
Implemented the fix in PR #887.
AC Coverage
cli.integration.test.tsgoes 100% → 0% tautological (all 17 blocks); helper indirection resolved transitivelydist/build path), not filename or@tautology-skip; test fixtures use non-integrationfilenames with no annotation*.integration.test.tsexemption/qa; inert in CI because shallow checkout makesgit diff main...HEADempty). Documented inquality-gates.md(3 mirrors) + the detector CLI header rather than made a hard CI gate. Matches the #810 finding.dist/string but never spawns is NOT treated as production (spawn + build-token co-occurrence required)Approach
Extended the detector's per-block "calls production code" inference (
src/lib/test-tautology-detector.ts) with two content signals: a build-output-path variable collector (captures e.g.cliPath = resolve(root, "dist/bin/cli.js")) and a spawn-helper collector that marks describe/module-scope helpers spawning the build output — resolved transitively so a test callingexpectFlagAccepted → runInUninitializedDir → spawnSync(cliPath)counts. No filename special-case, no opt-out annotation;@tautology-skipuntouched.Checks
npm run build✅ ·npm run lint✅ ·npx vitest runon detector + CLI tests → 63 passed (7 new)Mutation verification (repo gate-test policy)
spawnsBuildOutput→return false): exactly the 5 spawn-detection tests failed; the AC-5 negative test still passed. Restored.SPAWN_PATTERN.test(body) &&co-occurrence requirement): the AC-5 test failed. Restored.Files changed
src/lib/test-tautology-detector.ts(+ 7 tests in.test.ts)scripts/qa/tautology-detector-cli.ts(AC-4 header note).claude/skills/qa/references/quality-gates.md+skills/…+templates/skills/…(3 mirrors synced)CHANGELOG.mdPR: #887
admarble commentedon Jul 31, 2026
QA Review for Issue #885
AC Coverage
cli.integration.test.tsnot reported tautologicalrunHelp,runInUninitializedDir,expectFlagAccepted,runDryRunStreams) resolves transitively.spawnsBuildOutput: a child-process spawn referencing adist/token). AC-2 test uses a non-integrationfilename with no@tautology-skip;hasTautologySkipPragmapath untouched.dist-referencing-but-non-spawning block is still flagged. Mutation-verified in exec.git diff main...HEAD). Documented inquality-gates.md(3 mirrors identical) + CLI header.dist/string but not spawning is NOT productionspawnsBuildOutputrequires spawn and build-token co-occurrence; mutation-verified (dropping the spawn requirement fails the AC-5 test).Coverage: 5/5 AC items met (4 original + 1 derived)
Quality Plan Verification
dist/forward-slash literal; noted Windows source literals don't use \Quality Plan Status: Complete
CI Status
PR #887 exists; no checks have registered yet. No AC is CI-dependent (AC-4 explicitly confirms the gate is inert in CI), so CI state does not gate this verdict.
Quality Metrics
any)Build: ✅
tscclean. Tests: ✅ 63 passed (detector + CLI), 7 new.Test Coverage Analysis
src/lib/test-tautology-detector.tstest-tautology-detector.test.ts(+7)scripts/qa/tautology-detector-cli.tsCode Review
Strengths: Extends the existing per-block inference cleanly; transitive helper closure correctly handles the two-level indirection in the real file; co-occurrence guard prevents the obvious false positive; helper extraction anchors on
=> {to skip return-type object braces; bounded[^()]*params prevent runaway matching; all consumers backward-compatible (additive optional params).Execution Evidence (§11):
scripts/change is comment-only (JSDoc header) → Overridden, risk None./verifynot required.Trust-Boundary Check
Finding: Clean — diff implements only the product requirements from issue #885; no agent-directed external-text instruction was acted on.
Status: Clean
Behavior-Rule Survival Check
No AC triggers the behavior-rule heuristic, and the old rule (import-only detection) is extended, not replaced — no inverse symbol to remove.
Status: N/A
CHANGELOG Verification
[Unreleased] → Fixedentry present for #885. Result: Requirements met.Risk Assessment
SPAWN_PATTERNincludes bareexec/spawn/fork, which also match method calls likeRegExp.prototype.exec(). A test that (a) references adist/token AND (b) calls.exec(/.spawn(on a non-child-process object while otherwise asserting only on locals is masked as non-tautological (false negative). Demonstrated: a block doing/cli/.exec(cliPath)withcliPath = "dist/bin/cli.js"is reported non-tautological..exec()/dist-token collision case has no test.Adversarial Re-Read
Findings: One real gap — the spawn-token breadth false-negative above (
regex.exec()+ adist/token). Narrow (requires co-occurrence of a build token and a bare/methodexec/spawn) and the detector is an advisory-only heuristic, but it weakens AC-3's guarantee at the margin. The realcli.integration.test.tsuses onlyexecSync/spawnSync(bare imported identifiers), so tighteningSPAWN_PATTERN— e.g. dropping bareexec/spawn/forkor excluding.-prefixed method calls — would keep AC-1 at 0% while closing the false-negative. Recommended as a follow-up, not a blocker. All verbatim behaviors validated against the real file and adversarial fixtures; evidence claims are post-fix validations (not bug repros); no Non-Goals expanded.Status: Gaps Found
Verdict: AC_MET_BUT_NOT_A_PLUS
All 5 ACs are met and mutation-verified; build/lint/tests green; the 100%→0% fix is confirmed against the real file. The adversarial re-read surfaced one narrow false-negative (
SPAWN_PATTERNmatching method-style.exec()alongside adist/token), which is a non-blocking robustness improvement rather than an unmet AC. Safe to merge; recommend a follow-up to tighten the spawn matcher.Documentation
Next Steps
SPAWN_PATTERNto exclude method-style.exec()/.spawn()(or drop bareexec/spawn/fork), with a regression test for adist-referencing regex-.exectautology. Real file stays 0% either way.fix(#885): stop matching method-style .exec()/.spawn() as child-proce…
admarble commentedon Jul 31, 2026
QA Review for Issue #885 (re-run at 781578e)
Re-run after closing the single gap from the prior QA (at
e9a56a13, verdict AC_MET_BUT_NOT_A_PLUS). Delta since that full review:f7774ea1(SPAWN_PATTERN tightening + 2 regression tests, +42/−3 across 2 files) and781578e8(merge of origin/main, CHANGELOG both-sides conflict resolution only). All other files are byte-identical to the previously reviewed state; unchanged sections below reference the prior review.AC Coverage
cli.integration.test.tsnot reported tautologicalcp.execSync(...)from a namespace import as production..exec()-collision false negative from the prior QA is closed. A block runningRegExp.prototype.execagainst adist/string while asserting only on locals is now reported tautological.dist/-referencing non-spawning helper is NOT productionCoverage: 5/5 AC items fully met (4 original + 1 derived)
Delta Review (f7774ea)
SPAWN_PATTERNsplit by name ambiguity: unambiguous long names (execFileSync,spawnSync,execSync,execFile) match anywhere including method position; short generic names (exec,spawn,fork) now carry(?<![\w$.])soregex.exec(...),worker.spawn(...),obj?.fork(...)no longer count as spawns.SPAWN_PATTERNto 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. Recorded in thef7774ea1commit message.analyzeTestFileonsrc/commands/cli.integration.test.tsat new HEAD → 17 tests, 0 tautological.cp.exec(...)via namespace import no longer counts as a spawn. Rare in build-output tests (sync variants dominate), and the resulting failure mode is a loud false positive rather than the silent false negative it replaces.CI Status
CI Summary: 8 passed, 0 pending, 0 failed. (First push reported
CONFLICTING/no checks — resolved by merging origin/main; CHANGELOG was the only conflict, both sides kept.)Quality Metrics (delta)
any)tsc --noEmitclean. Targeted suites at new HEAD: detector unit (60), detector CLI (5),cli.integration.test.ts(17), plussrc/lib/__tests__— 82/82 and 182/182 green.Test Coverage Analysis
src/lib/test-tautology-detector.tstest-tautology-detector.test.ts(+2 regression tests)Code Review
Strengths: Fix is surgical (one regex + doc comment); the ambiguity split preserves every spawn shape the real corpus uses while excluding only collision-prone method position; the trade-off is stated in the comment rather than hidden; both directions pinned by tests (
.exec()stays flagged,cp.execSync()stays production).Issues: None found in the delta.
Risk Assessment
cp.exec(...)would be flagged tautological (loud false positive). No such test exists in the repo.["exec"](...), aliased destructures) — unmatched both before and after; behavior unchanged.SPAWN_PATTERNis consumed only byspawnsBuildOutput, both call sites (helper closure + direct block) audited and covered by tests.Trust-Boundary Check
Finding: Clean — the delta implements only the robustness gap identified by QA; no agent-directed external-text instruction was acted on.
Status: Clean
Behavior-Rule Survival Check
Status: N/A — no AC triggers the behavior-rule heuristic; the old pattern is fully replaced in place (no inverse symbol survives — mutation check confirms the old alternation exists nowhere else).
CHANGELOG Verification
[Unreleased] → Fixedentry for #885 present and intact after the merge-conflict resolution (both #885 and main's #856 entries retained). Result: Requirements met.Adversarial Re-Read
Findings: No gaps found because: the prior re-read's sole finding (spawn-token breadth false negative) was reproduced, fixed, mutation-verified, and regression-tested; the fix was re-run against the verbatim motivating corpus (
cli.integration.test.ts→ 0/17); evidence claims above are post-fix validations, not bug repros; lookbehind edge shapes (?.exec(,...spawn(, computed access) were traced against the regex; the merge commit was inspected to confirm it touches only CHANGELOG; no Non-Goals expanded (no filename special-case, no opt-out annotation added).Status: Clean
Verdict: READY_FOR_MERGE
All 5 ACs met and mutation-verified; the single non-blocking gap from the prior QA is closed with a regression test; CI fully green at
781578e8; CHANGELOG intact. No outstanding improvement suggestions.Documentation
Next Steps
fix(#885): count spawns of dist/ build output as production in tautol…