Repository navigation
Description
Motivation
The behavior-rule (tautology) detector (src/lib/heuristics/behavior-rule-detector.ts) runs in exactly two places, both inside LLM-driven skill phases: /spec and /qa §6e (behavior_rule_survival_status). It is never executed in CI — ci.yml has no invocation. The standing incident note from #810 is blunt: "a failing tautology-detector is usually a REAL finding; that gate never fires in CI." So the one deterministic tool the repo owns for the tests-that-don't-bind defect class only runs when an LLM remembers to run it, inside phases that small diffs can skip entirely (Simple Fix mode omits §6d and more below the 100-line smallDiffThreshold).
The defect class it targets is the most common deterministic-catchable class in the recent gap-prompt audit (#842, #883, #799, #467 — tests passing without binding to behavior). Every catch converted into a deterministic gate ratchets work out of the manual second look permanently (the #834 pattern); this is the cheapest such conversion available because the detector already exists.
Proposal
Two-phase rollout, measurement before enforcement (the #922/#928 pattern — the citation-grounding gate was rejected on an 8:1 noise ratio; this detector must earn enforcement the same way).
Phase A — advisory + measured (this issue):
- New CI job in
ci.yml: on PRs, run the detector against test files changed in the diff (baseorigin/main, per the fix(observability): phase diff stats compare against the local base ref while worktrees branch from origin/<base> — phantom filesModified + base tip logged as the phase commit #878/fix(observability): remaining bare main...HEAD consumers after #878 — qa-cache diff hash, worktree-manager summaries, aider file-context, non-qa skill gates #890 diff-ref lessons). Output a summary to the job log and PR annotation; exit 0 always. - Instrument: each run appends
{pr, filesScanned, findings, score}to the job summary so a false-positive rate over real PRs accumulates in CI history — no new storage. - After ≥20 PRs (or 4 weeks), record measured FP rate in this issue and decide Phase B.
Phase B — enforce (follow-up issue, filed only if the measured FP rate clears a bar the maintainer sets, e.g. <20%):
- The job fails on high-confidence findings; an inline
@tautology-skip <reason>escape hatch already exists in the detector's vocabulary — but note the standing QA rule that skips must be justified, since@tautology-skipwas previously used to defang a measured-metric AC.
Non-Goals
- No enforcement in this issue — Phase A is advisory by design, but unlike a prose section it is measured advisory with a scheduled decision point, which is what distinguishes it from the investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608 dead-section class.
- No detector-quality rework — fix(qa): tautology detector scores subprocess-driven integration tests 100% tautological (cli.integration.test.ts, pre-existing) #885's false-positive class (subprocess-driven integration tests scoring 100% tautological) is already fixed; further tuning waits for Phase A data.
- No scanning of unchanged test files (full-corpus sweeps are a different, noisier tool).
Tailored caveats
- Diff base must be
origin/<base>, not localmain(fix(observability): phase diff stats compare against the local base ref while worktrees branch from origin/<base> — phantom filesModified + base tip logged as the phase commit #878: phantom filesModified from stale local refs). - The runner is a Node script invoked via the built
dist/ornpx tsx— no awk/sed (macOSIGNORECASEis a no-op, the fix(qa): §7 gates must be reachable — lint the skill's own enforcement chain (§2h has been unwired since it shipped) #834 catch); cross-platform paths viapathmodule. - CI job must tolerate zero changed test files (exit 0, "nothing to scan") — no vacuous failure on docs PRs.
scripts/dev/is gitignored and absent in CI — the job must not glob into it (the exact fix(lint): exclude gitignored scripts/dev from the widened lint/typecheck scope #930 regression class).- Subprocess tests in CI need the integration-project timeout semantics if any are added (
.integration.infix rule).
Acceptance Criteria
- AC-1: A
ci.ymljob runs the behavior-rule detector over test files changed vsorigin/<base>on every PR and always exits 0 in Phase A. Evidence: job visible and green on this PR itself, which modifies test files. - AC-2: Findings render as PR annotations or a job-summary table with file, rule, and score — labeled headers, no box-drawing. Evidence: screenshot or job-summary link on a PR with a deliberately tautological fixture test (fixture removed before merge).
- AC-3: The job emits a one-line machine-readable summary (
filesScanned,findings) to the job summary for FP-rate accounting. Evidence: job summary from AC-1's run. - AC-4: Zero changed test files short-circuits cleanly. Evidence: job log from a docs-only test PR or a unit test of the file-selection script.
- AC-5: A dated follow-up checklist item exists in this issue for the Phase B decision with the FP-rate bar stated. Evidence: issue comment after merge.
Human decisions required
- The Phase B FP-rate bar (suggested: <20% over ≥20 PRs; feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan #922's gate was rejected at 8:1 noise — same discipline applies here).
Context
From the 2026-08-13 strategy review. The #810 incident note is the direct motivation; #885 fixed the known FP class; #922/#928 is the measure-first precedent this rollout copies. Complements the mutation-verification gate (that one checks the human performed a red-phase check; this one mechanically screens for tests that cannot fail).
Activity
admarble commentedon Aug 21, 2026
/spec Plan — #940
Complexity: Standard (5 ACs, 3 directories:
.github/workflows/,scripts/qa/,docs/features/)AC Quality Check
All 5 ACs pass the linter (0 flagged). One naming defect worth fixing in the issue body: AC-1 and the Motivation say "behavior-rule detector (
src/lib/heuristics/behavior-rule-detector.ts)", but that module detects behavior-rule ACs (#552) — it takes anAcceptanceCriterion, not a test file, and has no notion of a score. The tool the issue actually describes (tests that don't bind to production code,@tautology-skip, >50% blocking, the #885 FP fix, #810 note) issrc/lib/test-tautology-detector.tswith the CLI wrapperscripts/qa/tautology-detector-cli.ts. Plan below targets the tautology detector; see Open Question 1.Scope Assessment
Non-Goals: present (3 items: no enforcement, no detector rework, no full-corpus sweep).
Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1:
ci.ymljob runs the detector over test files changed vsorigin/<base>on every PR, always exit 0*.test.ts→ When thetautology-advisoryjob runs → Then it diffsorigin/${{ github.base_ref }}...HEAD, scans only those files, and the step exits 0 regardless of findingsfetch-depth: 1, soorigin/<base>does not exist (that is exactly why the CLI header says "inert in CI by design"); the job mustgit fetch origin <base>explicitly. Exit-0 is a CLI flag (--advisory), notcontinue-on-error:— the latter shows a red ✗ on the step and hides real crashes (exit 2) behind the same mask.AC-2: Findings render as annotations / job-summary table with file, rule, score — labeled headers, no box-drawing
::warning file=<path>,line=<n>,title=Tautological test::<description> — no production calland$GITHUB_STEP_SUMMARYgets a markdown table| File | Line | Test | Style |plus per-file scoretautologicalCount/totalTestsformatTautologyResults()already emits markdown tables (no box-drawing) — reuse it for the summary body rather than writing a second renderer.AC-3: One-line machine-readable summary (
filesScanned,findings) in the job summary--json/summary output) + Manual (job summary)<!-- TAUTOLOGY_SUMMARY {"pr":<n>,"filesScanned":N,"totalTests":N,"findings":N,"score":0.xx} -->— HTML-comment-wrapped so it is greppable from CI history (gh api .../jobs→ summary) without cluttering the rendered tableprcomes from${{ github.event.pull_request.number }};score = findings/totalTests(0 when no tests).AC-4: Zero changed test files short-circuits cleanly
\.(test|spec)\.[jt]sx?$paths → Then CLI printsNo test files changed in diff, writesfilesScanned:0, findings:0summary line, exits 0. Also: Givenorigin/<base>unresolvable → Then exit 0 with an explicitError: base ref not foundline (today this path silently reports zero files — it must say it skipped, or the Phase A FP data is polluted with vacuous zeros).getChangedTestFiles()is currently a private function — export it (or move selection into a testable helper) so the unit test binds to production code and the test itself isn't tautological.AC-5: Dated Phase B checklist item in this issue with the FP-rate bar
- [ ] 2026-09-18 (or after 20 PRs): compute FP rate from TAUTOLOGY_SUMMARY lines; if <20%, file Phase B enforcement issue; else tune/retire— include the exactghone-liner that aggregates the summaries so the decision is mechanical.Implementation Plan
Phase 1 — CLI becomes CI-capable (
scripts/qa/tautology-detector-cli.ts)--base <ref>(default:resolveDiffBase(cwd,"main")— unchanged local behavior),--advisory(force exit 0 forblocking; exit 2 on internal error stays — a crashed detector must not read as "clean"),--github(emit::warningannotations + append to$GITHUB_STEP_SUMMARYwhen the env var is set).selectChangedTestFiles(base: string, cwd: string): {files: string[]; baseResolved: boolean}and export it; make the "no base ref" case explicit in output (AC-4). KeepexecFileSyncarray form (fix(observability): phase diff stats compare against the local base ref while worktrees branch from origin/<base> — phantom filesModified + base tip logged as the phase commit #878/fix(observability): remaining bare main...HEAD consumers after #878 — qa-cache diff hash, worktree-manager summaries, aider file-context, non-qa skill gates #890).TAUTOLOGY_SUMMARYline in both--jsonand summary outputs (AC-3). ReuseformatTautologyResults()for the human table (AC-2)./qainvocation inquality-checks.shuntouched (it still uses defaults).Phase 2 — CI job (
.github/workflows/ci.yml)5. New job
tautology-advisory,if: github.event_name == 'pull_request', steps: checkout →git fetch --no-tags origin ${{ github.base_ref }}→ setup-node 22 →npm ci→npx tsx scripts/qa/tautology-detector-cli.ts --base origin/${{ github.base_ref }} --advisory --github. PassPR_NUMBER=${{ github.event.pull_request.number }}. No globbing — file list comes from git, soscripts/dev/(gitignored, #930) can never enter it.6. Do not add it to required checks; it's advisory.
Phase 3 — tests + docs
7. Extend
scripts/qa/tautology-detector-cli.test.ts(already.test.tswith 60s timeout; subprocess tests underscripts/flake per #842 — prefer a unit test of the exportedselectChangedTestFilesagainst a temp git repo over another spawn). Cover: zero test files → skip line + exit 0;--advisorywith a blocking fixture → exit 0; unresolvable base → explicit skip line. These are gate tests → each needs theMutation-verified:marker in the PR body (CLAUDE.md / #939).8.
docs/features/test-tautology-detector.md: add a "CI (Phase A, advisory)" section + the FP-rate aggregation one-liner. Updatedocs/internal/what-weve-built.mdif it lists the #885 "inert in CI" fact.9. Post-merge: AC-5 comment on this issue (dated checklist + bar).
Design Review
/qaand CI should run the same binary so Phase A numbers measure the same detector/qaenforces. The YAML only wires flags.git fetchstep. Rejected:fetch-depth: 0(slower on every PR for one job; a targeted fetch of the base ref suffices); a separatescripts/ci/runner (would fork the file-selection logic and drift from/qa);continue-on-error(masks exit-2 crashes).validate-skillsjob (npx tsx scripts/lint-*.tson Node 22,npm ci). Annotations follow GitHub workflow-command format, same as eslint's problem matcher output.git fetchin the existing build job and append one step?" — because the build job runs onpushtoo and has a matrix; an advisory PR-only job is cheaper to reason about and to delete in Phase B if the data says retire. Also: "Is the@tautology-skippragma counted as a finding or a skip?" — it's a skip today (skippedFiles); report it in the summary line asskipped:Nso the FP analysis can see how often the hatch is used (the fix(test): cli.integration flag-surface tests assert on the not-initialized guard, so they fail on any locally init'd clone #883-class concern in the issue).Feature Quality Planning
All standard checks pass. Notable items:
[]on any git error, which in CI would log as a clean "nothing to scan" — the single most likely way Phase A produces garbage data. AC-4 scenario 2 covers it.GITHUB_STEP_SUMMARYand::warningannotations work on forks with read-onlyGITHUB_TOKEN; no API writes needed. Good.@tautology-skipobservability: surface skipped-file count in the summary (see Design Review 4).Open Questions
src/lib/test-tautology-detector.ts/scripts/qa/tautology-detector-cli.ts. — Recommendation: edit the issue body to name the tautology detector; plan proceeds on that reading. Impact if wrong: the behavior-rule detector cannot scan test files at all, so a literal AC-1 is unimplementable.git fetch:github.base_refonly exists onpull_requestevents. — Recommendation: gate the job onpull_request(skip onpushto main — nothing to diff). Impact: none; matches the "on PRs" wording.$GITHUB_STEP_SUMMARY(AC-3 says job summary) vs job log. — Recommendation: both; the summary is whatgh apiretrieves for the Phase B tally.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Single focused change to an existing CLI + one YAML job; the existing
tautology-detector-cli.test.tsis the natural home for new tests, sotestgenadds little. SCOPE_OK./qamust check the mutation-verification markers for the gate tests (§6i) and that the CI job actually ran green on the PR (AC-1 evidence).Label Review
Current: (none)
Recommended:
enhancement,ci,plannedReason: New CI job + CLI flags; not a bug. No UI, so no
ui/testphase.Quality Loop: Won't auto-enable — SCOPE_OK, no complexity labels.
admarble commentedon Aug 21, 2026
Phase B decision — follow-up checklist
PR #955 (merged) shipped Phase A:
tautology-advisoryruns the test-tautology detector on every PR, always exits 0, and emits<!-- TAUTOLOGY_SUMMARY {"pr":N,"filesScanned":N,"totalTests":N,"findings":N,"skipped":N,"score":0.xx} -->to the job summary.TAUTOLOGY_SUMMARYlines from CI job summaries and compute the measured false-positive rate. Bar: < 20% FP rate → file a Phase B (enforcement) issue. If ≥ 20%, either tune the detector or leave Phase A as permanent advisory-only tooling — do not enforce on unreliable data (the feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan #922/feat(#922): Phase A — citation grounding checker and measured verdict on the gate #928 precedent: that gate was rejected at an 8:1 noise ratio).Aggregation command:
Known FP data point already collected on PR #955 itself: the job flagged all 5 test blocks in
scripts/qa/tautology-detector-cli.test.ts(a subprocess-driven integration test that spawns the CLI and asserts on stdout/exit code rather than importing named production functions) — the same false-positive class #885 addressed for a different file. Worth revisiting whether #885's fix should generalize to this shape, independent of the Phase B enforcement decision.admarble commentedon Aug 21, 2026
Filed #956 for the tautology-detector-cli.test.ts false-positive noted above — root cause is
path.resolve(__dirname, ...)-built spawn paths evading #885's textualdist//scripts/heuristic.test(qa): pin the tautology CI job's annotation format and summary ma…