Repository navigation
feat(ci): run the tautology detector in CI — advisory, measured (#940) - #955
Merged
admarble merged 3 commits intoAug 21, 2026
Merged
Conversation
Phase A rollout: a new tautology-advisory CI job runs the existing test-tautology detector on every PR's changed test files and always exits 0. Findings surface as ::warning PR annotations and a job-summary table, plus a machine-readable TAUTOLOGY_SUMMARY line for accumulating a false-positive rate ahead of a Phase B enforcement decision. - scripts/qa/tautology-detector-cli.ts: new --base, --advisory, --github flags; selectChangedTestFiles exported and unit-testable; an unresolvable base ref is reported explicitly rather than silently scanning zero files, so Phase A data isn't polluted. - .github/workflows/ci.yml: tautology-advisory job, PR-only, fetches the base ref explicitly (default checkout is fetch-depth: 1). - /qa's existing invocation via quality-checks.sh is unaffected — no new flags passed, same default behavior. Closes #940
… merge-base failure) QA found the job's first live CI run silently degraded to skip mode: fetch-depth: 1 + a separate depth=1 fetch of the base ref leaves HEAD (the PR merge commit) and origin/<base> with no shared history, so `git diff origin/<base>...HEAD` throws "fatal: ...: no merge base" even though origin/<base> itself resolves. Confirmed by pulling the job's own log, then reproduced locally with a real shallow clone against GitHub and verified fixed with a full clone. - ci.yml: checkout uses fetch-depth: 0 (full history), which both resolves the merge-base and removes the need for the separate "Fetch base branch" step. Also hoists github.base_ref into env (BASE_REF) instead of interpolating it directly into run: shell blocks, per the security-scan finding on this PR. - tautology-detector-cli.ts: selectChangedTestFiles now distinguishes "ref does not exist" from "ref exists but the diff failed" (e.g. no merge base) via a new `error` field, and prefers execFileSync's stderr over the generic "Command failed" message wrapper. The old code collapsed both cases into an inaccurate "not found" message. - New regression test locks in the shallow-clone failure mode.
…-output test The build (22.x) CI job's own checkout is shallow (fetch-depth: 1, unchanged) and hits the same merge-base-less diff as the tautology-advisory job did before its fix. The prior CLI code collapsed every diff failure into "No test files changed in diff"; after b4d153f's fix, an unresolvable-diff case correctly prints "Cannot diff against base ref ..." instead. Widen the assertion to accept both skip messages.
5 tasks
admarble
deleted the
feature/940-feat-ci-run-the-tautology-detector-in-ci-advis
branch
August 21, 2026 06:04
5 tasks
This was referenced Aug 21, 2026
admarble
added a commit
that referenced
this pull request
Aug 21, 2026
…rker shape (#940 follow-up) (#957) #940/#955 shipped the tautology-advisory CI job, but nothing pinned the ::warning annotation format, the TAUTOLOGY_SUMMARY marker's JSON shape, or the --github + zero-changed-test-files combination — only live CI runs and manual verification covered them, so a future refactor of any of the three could silently break Phase A's FP-rate accounting with no test going red. - Export emitGithubAnnotations, emitGithubStepSummary, and summaryMarker (previously private) so their output can be asserted on directly. - New unit tests (tautology-github-output.test.ts): annotation format for tautological vs. non-tautological blocks, marker JSON shape including the reason field, step-summary file writing, and the stdout fallback when $GITHUB_STEP_SUMMARY is unset. - New subprocess integration test in tautology-detector-cli.test.ts: runs the real CLI with --base HEAD --advisory --github (deterministic zero-files diff) and asserts the skip message + marker land in a real $GITHUB_STEP_SUMMARY file — closes the "never exercised on a real CLI invocation" gap for that flag combination. Mutation-verified: AC-2 (annotation format) — removed the isTautological guard in emitGithubAnnotations (`if (true) continue`); "emits one ::warning line per tautological block" failed as expected, no other tests affected; restored. Mutation-verified: AC-3 (summary marker) — dropped the marker from emitGithubStepSummary's body; both step-summary unit tests and the new integration test failed as expected, no other tests affected; restored. <!-- SEQUANT_MUTATION: {"ac":"AC-2","mutation":"emitGithubAnnotations: if (!block.isTautological) continue -> if (true) continue","failedTest":"emits one ::warning line per tautological block, in workflow-command format"} --> <!-- SEQUANT_MUTATION: {"ac":"AC-3","mutation":"emitGithubStepSummary: body includes marker -> body omits marker","failedTest":"--github with zero changed test files writes the skip summary and marker to $GITHUB_STEP_SUMMARY"} -->
This was referenced Aug 21, 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
tautology-advisoryCI job (.github/workflows/ci.yml) that runs the existing test-tautology detector on every PR's changed test files, comparing against the base branch. It always exits 0 — Phase A of the feat(ci): run the tautology detector in CI — advisory, measured, with a scheduled enforcement decision #940 rollout is advisory only, so nothing here can block a merge.::warningPR annotations, a job-summary markdown table, and a machine-readable<!-- TAUTOLOGY_SUMMARY {...} -->line so a false-positive rate can be measured across real PRs ahead of a Phase B enforcement decision.scripts/qa/tautology-detector-cli.tsgains--base,--advisory,--githubflags.selectChangedTestFilesis exported and unit-tested directly; an unresolvable base ref is now reported explicitly (not silently scanned as zero files), so Phase A data isn't polluted by vacuous zeros./qa's existing invocation viaquality-checks.shis unaffected — no new flags passed there.Bugs found and fixed during self-review (before merge)
The first live CI run on this PR caught two real defects that manual/local testing had missed:
fetch-depth: 1+ a separategit fetch --depth=1 origin mainleaves HEAD (the PR merge commit) andorigin/mainwith no shared history, sogit diff origin/main...HEADthrowsfatal: ...: no merge baseeven thoughorigin/mainitself resolves. The job silently degraded to its "skip" path on every run. Reproduced locally with a real shallow clone against GitHub, fixed by switching the checkout tofetch-depth: 0(full history — also removes the need for the separate fetch step), and verified fixed with a full clone.selectChangedTestFilesnow also distinguishes "ref doesn't exist" from "ref exists but the diff failed" via a newerrorfield, since the old code's blanket try/catch reported both identically.${{ github.base_ref }}was interpolated directly into tworun:shell blocks instead of viaenv:. Low exploitability (base_refis repo-controlled, not fork-controlled) but fixed for consistency with the pattern already used forPR_NUMBERin the same job. Hoisted toenv: BASE_REF: ${{ github.base_ref }}.A third, smaller fix: the pre-existing
tautology-detector-cli.test.ts's "default markdown output" test asserted on the old, less-accurate skip message; after fix #1 it correctly asserts on either skip message.Pre-PR AC Verification
ci.ymljob runs the detector vsorigin/<base>on every PR, always exits 0 in Phase Atautology-advisorypassed on this PR's actual CI run (job log) after the fetch-depth fix — it correctly diffed againstorigin/mainand scanned this PR's own changed test files.tautology-detector-cli.test.ts(a subprocess-driven integration test — see note below) and rendered them as 5::warning file=...,line=N,title=Tautological test::...annotations plus a### Test Quality Reviewmarkdown table, both visible in the real job log — no fixture needed.filesScanned,findings) for FP-rate accountingemitGithubStepSummaryappends the table and theTAUTOLOGY_SUMMARYmarker to$GITHUB_STEP_SUMMARYin one call, verified locally against a simulated summary file ({"pr":940,"filesScanned":2,"totalTests":4,"findings":1,"skipped":0,"score":0.25}); same code path ran on the live CI job above.scripts/qa/select-changed-test-files.test.ts(4 unit tests, mockedchild_process) covers: unresolvable base ref, zero test files, a mixed diff, and (added after the CI-caught bug) the "ref exists but diff throws — no merge base" case specifically.Note on the AC-2 finding itself (not a bug in this PR):
tautology-detector-cli.test.tsspawns the CLI as a subprocess and asserts on stdout/exit code rather than importing named production functions, so the detector's import-tracking heuristic flags all 5 of its blocks — the same subprocess-driven-test false-positive class #885 addressed for a different file. This is exactly the kind of noise Phase A exists to measure, not something to fix here (issue #940's Non-Goals explicitly rule out detector-quality rework in this issue) — it's now real data for the eventual Phase B FP-rate decision.Test plan
npm run build— passesnpm run lint— passes (0 warnings)npm test— full suite: 269 files / 5516 tests passed (1 pre-existing expected fail, 2 pre-existing skips, unrelated to this change)scripts/qa/select-changed-test-files.test.ts(4 tests, unit project) — includes a regression test locking in the shallow-clone/no-merge-base failure modescripts/qa/tautology-detector-cli.test.ts(5 subprocess integration tests) — 1 assertion updated to accept the more accurate skip message (see "Bugs found" above); still verifies default (no-flag) CLI behavior used by/qais unaffectedPre-PR Confidence Check
--githubannotation/summary-writing code paths are now proven end-to-end on real CI (not just local simulation), but only for the "findings present" and "unresolvable base" cases — the "zero changed test files" case with--githubset has only local/unit coverage, not a live CI run, since every commit on this PR touched test files.Closes #940
🤖 Generated with Claude Code
Mutation-verified (recorded post-merge — should have shipped with the original commit): AC-4 — mutated
selectChangedTestFiles's catch-block return frombaseResolved: falsetobaseResolved: true(the exact "silently report success on a real diff failure" regression AC-4 exists to prevent);select-changed-test-files.test.ts's "reports a diff failure explicitly when the ref exists but shares no history with HEAD" test failed as expected, no other tests affected; mutation restored and suite re-confirmed green.