Repository navigation
Description
Epic: graph-2026-10-fundamentals Tier: mechanical Execution: sequant_run Blocked by: #1501
Problem
Every later node's AC reads a number, and today each number is produced by an ad-hoc script in a session scratchpad (fnlen.mjs, grep pipelines). Without a committed script and baseline, "the number went from A to B" is unverifiable and nothing stops it going back up. The repo already has the pattern: scripts/qa/tautology-detector-cli.ts plus the tautology-advisory CI job.
Metric definitions (§4 of the founding doc; the script implements exactly these):
| Key | Definition | Value on main 96990da |
|---|---|---|
functions.over400, functions.over200, functions.longest |
ESLint max-lines-per-function with skipBlankLines: true, skipComments: true over non-test src/**/*.ts(x), bin/**/*.ts; longest = {file, name, lines} |
4, 12, batch-executor runIssueWithLogging 1,049 |
emptyCatch.total, emptyCatch.byFile |
TypeScript AST CatchClause whose block has zero statements, non-test src |
119; batch-executor 25 |
childProcessMockFiles |
test files matching vi.mock(\s*["'](node:)?child_process |
31 |
ghCallFilesOutsideProvider |
non-test files matching spawnSync(\s*"gh" excluding src/lib/workflow/platforms/github.ts |
3 (4 sites) |
proseGate.files, proseGate.lines |
test files containing the literal SKILL.md and toContain or toMatch |
76, 30,461 |
testRatio28d.sum, testRatio28d.median, testRatio28d.commits |
over non-merge commits on main in the last 28 days: lines added to paths matching `.test.tsx?$ |
tests/ |
deprecatedWithoutRemoval |
@deprecated JSDoc tags in non-test src/bin not followed on the same line by remove in v\d+\.\d+ |
18 (of 18) |
harness.claudeMdLines, harness.skillLines, harness.skillFiles, harness.memoryFiles |
wc -l CLAUDE.md; sum and count of .claude/skills/*/SKILL.md; file count of $CLAUDE_PROJECT_MEMORY_DIR when set, else null |
25, 15,542, 19, 253 |
adrWithoutActor |
**Status:** Accepted lines in docs/adr/0*.md not matching Accepted \(owner, \d{4}-\d{2}-\d{2}\) |
11 |
--check compares every numeric key except testRatio28d.* and harness.memoryFiles against scripts/qa/health-baseline.json and exits 1 naming each key that rose; the two excluded keys are reported only (the ratio slides with its 28-day window and would read as "raised" on any later day; the memory count is local to one machine; D-6). --write-baseline rewrites the file (I-4: only in a PR that lowers a metric).
Acceptance Criteria
- AC-1:
--jsonprints every key above. Evidence:npx tsx scripts/qa/health-report.ts --json | jq -e '.functions.over200 >= 0 and .emptyCatch.total >= 0 and .childProcessMockFiles >= 0 and .ghCallFilesOutsideProvider >= 0 and .proseGate.files >= 0 and .testRatio28d.sum >= 0 and .deprecatedWithoutRemoval >= 0 and .harness.skillLines >= 0 and .adrWithoutActor >= 0' > /dev/null && echo ok→ok - AC-2: The committed baseline equals what the script prints on the PR's tree. Evidence:
test -f scripts/qa/health-baseline.json && diff <(npx tsx scripts/qa/health-report.ts --json | jq -S 'del(.generatedAt, .commit, .harness.memoryFiles, .testRatio28d)') <(jq -S 'del(.generatedAt, .commit, .harness.memoryFiles, .testRatio28d)' scripts/qa/health-baseline.json) && echo same→same - AC-3:
--checkis a ratchet. Evidence:npx vitest run scripts/qa/health-report.test.ts→≥ 4 passed, 0 failed(temp fixture tree: equal baseline → exit 0; one metric raised → exit 1 and stderr names the key; one metric lowered → exit 0 and stdout saysratchet available: <key>;--write-baselinerewrites the file and a following--checkexits 0; the fixture tree is real files, no fs mock) - AC-4: An advisory CI job runs
--checkand cannot block a merge. Evidence:grep -A14 '^ health-advisory:' .github/workflows/ci.yml | grep -c 'continue-on-error: true'→1 - AC-5: The release checklist reads the report. Evidence:
grep -c 'health-report' docs/internal/release-checklist.md→≥ 1 - AC-3 is classified as a gate test by
isGateTestEvidence; the PR body carries itsSEQUANT_MUTATIONrecord (delete the raised-metric branch in the fixture → the "names the key" case fails; restore). - AC-6: The script finishes in CI time. Evidence:
test -f scripts/qa/health-report.ts && /usr/bin/time -p npx tsx scripts/qa/health-report.ts --json > /dev/null 2> /tmp/hr-time.txt && awk '/^real/ {print ($2 < 90) ? "fast" : "slow"}' /tmp/hr-time.txt→fast
Prior fixes / producers
- Prior scripts of this class:
scripts/qa/tautology-detector-cli.ts(advisory job),scripts/qa/backtest-mutation-gate.ts. Neither computes these metrics; no prior fix. - Producers of the baseline file: this script only (I-4). Consumers: the ACs of F-03, F-04, F-06, F-07, F-08, F-09, F-11, F-12 and the
health-advisoryjob. - Re-fix-per-file and duplicate groups are not recomputed; they come from accretion
cadenceanddups(D-C).
May touch
scripts/qa/health-report.ts (new), scripts/qa/health-report.test.ts (new), scripts/qa/health-baseline.json (new), .github/workflows/ci.yml (one appended job after tautology-advisory), package.json (one lint:health script line), docs/internal/release-checklist.md (one line), tsconfig.scripts.json only if the new file is not already covered.
Non-Goals
- No metric is enforced in this node; the job is advisory (D-A). Blocking is a W2 decision.
- No edits under
plugin/,.claude/skills/,templates/skills/(I-1). - No fix to any metric; this node only measures.
testRatio28dis reported, not gated (D-6).
Done when
npx tsx scripts/qa/health-report.ts --check exits 0 on main, the baseline file is committed, and the advisory job appears on the PR's checks.
Activity
admarble commentedon Oct 19, 2026
Runner context, 2026-10-19, before launch (W0 of graph-2026-10-fundamentals; stop-at-PR). D-1..D-6 are answered on #1501 (D-1 alongside, so this runs beside consolidation W1, #1471 and #1474, whose files don't overlap).
docs/internal/release-checklist.mdexists. AC-5 edits that file, never the release skill (frozen).health-baseline.jsonafter the last source change.ci.yml/package.json/health-baseline.jsonyou create, so keep the formats simple to append to.For every phase, and the qa phase by name: run the full suite at most once, in the foreground, under
timeout, after a WIP commit. Each MCP-dispatched phase has a 30-minute wall. Prefer the targetednpx vitest run <files>for the ACs.CHANGELOG: add
[Unreleased]lines, notchangelog.d/fragments. #1370 has not merged.Freeze: nothing under
plugin/,.claude/skills/ortemplates/skills/.admarble commentedon Oct 19, 2026
Complexity: Standard (6 ACs, 5 directories)
AC Quality Check
Evidence:and parse.>= 0); it does not checkfunctions.longestshape orharness.skillFiles/adrWithoutActor-style sub-keys. Fine as a floor; AC-2 pins the values.grep -cgives 0: nohealth-advisoryjob). Note-A14meanscontinue-on-error: truemust sit within 14 lines of the job header, so place it directly underruns-on/if, beforesteps.release-checklist.mdtoday).≥ 4 passed) with a 5-case behavior list; the list is the real bar (equal→0, raised→1 naming key, lowered→0 +ratchet available: <key>, write-baseline→check 0)..testRatio28dand.harness.memoryFiles, matching--check. It does NOT exclude.commit/.generatedAtfrom the file (it deletes them in the diff) — fine.real < 90s; ESLint oversrc/is the cost driver (see risks).Scope Assessment
Non-Goals: present (no enforcement, no
plugin//.claude/skills//templates/skills/edits, no metric fixes,testRatio28dreport-only).scripts/qa,.github/workflows,docs/internal, rootpackage.json, CHANGELOG)Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1:
--jsonprints every keyVerification: Integration Test (declared evidence: jq command)
Scenario: Given the repo tree → When
npx tsx scripts/qa/health-report.ts --json→ Then JSON has all keys in the §4 table, plusgeneratedAtandcommit.Assumptions:
harness.memoryFilesisnullwhenCLAUDE_PROJECT_MEMORY_DIRunset.AC-2: Committed baseline equals script output on the PR tree
Verification: Integration Test (declared diff command)
Scenario: Given baseline generated by
--write-baselineafter the last source change → When the diff command runs → Thensame.Assumptions: Deterministic output (sorted
byFilekeys, stablelongesttie-break). Baseline must be regenerated LAST, after any CHANGELOG/doc edits, becauseharness.*andadrWithoutActorread those trees (CLAUDE.md lines, skill lines). This PR must not touch.claude/skills, so skill counts are stable.AC-3:
--checkis a ratchet (gate test)Verification: Unit Test (
scripts/qa/health-report.test.ts, ≥4 cases, real temp fixture tree, no fs mock)Scenario: equal → exit 0; raised key → exit 1, stderr names key; lowered → exit 0, stdout
ratchet available: <key>;--write-baselinethen--check→ exit 0.Assumptions: Script takes a
--root <dir>(and--baseline <file>) so tests run on a tiny fixture rather than the 1,000+-file repo.AC-4: Advisory CI job that cannot block
Verification: Manual/grep (declared) + PR checks show
health-advisory.Scenario: Given the appended job → When grep runs → Then
1.AC-5: Release checklist mentions health-report
Verification: grep (declared). One line under "Build & Test".
AC-6: Runs under 90 s
Verification: Integration Test (declared timing command)
Scenario: Then prints
fast.Implementation Plan
Phase 1: Script (
scripts/qa/health-report.ts)collectMetrics(root, opts)andcompare(current, baseline); thinmain()parses--json | --check | --write-baseline | --root | --baseline. Followtautology-detector-cli.tsstructure.Linter/ESLintAPI with an in-memory config (max-lines-per-function{max:1, skipBlankLines, skipComments}, TS parser fromtypescript-eslint) run twice thresholds 200/400 — better: one pass withmax:1, parse the "N lines" from each message, then count >200/>400 and take the max. Files: non-testsrc/**/*.ts(x),bin/**/*.ts. Do NOT use the repoeslint.config.js(avoid coupling to the shared merge-point file).typescriptcompiler APICatchClausewithblock.statements.length === 0, non-test src;byFilesorted.git log --no-merges --since=28.days --numstatonce (single git call), per-commit sums, sum and median.Phase 2: Ratchet + tests
compare: numeric leaves excepttestRatio28d.*andharness.memoryFiles; foremptyCatch.byFileandfunctions.longestcompare only scalars (total,lines) — report byFile diff informationally. Raised → stderrhealth: <key> rose A -> B, exit 1; lowered → stdoutratchet available: <key>.health-report.test.ts: build fixture tree withmkdtempSync(a long function, an empty catch, etc.),git initinside it for the ratio, call exported functions + one spawn for exit codes. Per-test timeout (ESLint startup): file name has no.integration., so the default 5 s applies — set explicit timeouts or name accordingly; confirm against the vitest project config.Phase 3: Wiring
package.json:"lint:health": "npx tsx scripts/qa/health-report.ts --check", alphabetical amonglint:*(afterlint:constitution-dod). CI jobhealth-advisoryappended aftertautology-advisory(checkout fetch-depth 0 — the ratio needs history;continue-on-error: trueright underruns-on). One line indocs/internal/release-checklist.md.[Unreleased]CHANGELOG line (notchangelog.d/).--write-baseline, then re-run AC-2.Design Review
scripts/qa/, same slot astautology-detector-cli.ts; pure functions exported so tests don't spawn.tautology-advisory. No prior fixes for this metric class (git log -Son the script names finds nothing; issue states none). Not a re-patch.--max-warnings?" — metrics are cross-file counts and non-lint (git, ADRs, harness), so no.health-advisoryjob, release-checklist line, later F-03…F-12 ACs (chore(lint): end the 2026-01 "temporarily relaxed" rules, add knip as an advisory job with a numeric baseline #1503, docs: postmortem template, the D-5-approved incidents moved from memory into docs/incidents, ADR acceptance authority named and linted #1513 append toci.yml/package.json/baseline). Keep the baseline flat-ish JSON and the CI job self-contained for easy appends.Feature Quality Planning
Notable items:
96990daab;mainis now8d1895c36. Numbers may drift (e.g. empty-catch 119). AC-2 only requires equality with the PR tree, so regenerate rather than hand-copy; note any drift in the PR body.testRatio28don shallow clones: CI needsfetch-depth: 0; if history is shallow the ratio silently shrinks. Since it's report-only, acceptable, but emitcommitsso it's visible.compare, confirm the "names the key" case fails, restore; record usingMutation-verified: AC-3 — …withfailedTestasscripts/qa/health-report.test.ts > <describe> > <case>and theSEQUANT_MUTATIONmarker. Commit before mutating.~/Projects/worktrees/feature/1502-…(clean at 8d1895c); /exec will reuse it.plugin/,.claude/skills/,templates/skills/edits.Open Questions
functions.longestequality — Recommendation: compare onlylongest.linesin--check; store file/name for info. Impact: if wrong, a rename of the longest function would false-alarm.--root/--baselineflags are not in the issue — Recommendation: add (needed for AC-3 fixture without fs mocks). Impact: otherwise tests must run on the real repo and be slow/fragile.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Single new script with a unit-tested ratchet (AC-3 declares a vitest evidence). testgen skipped: AC-3's test is itself the deliverable and the issue fully specifies its cases. No UI → no
test. Runner context says stop-at-PR; run the full suite at most once, in the foreground undertimeout, after a WIP commit.Label Review
Current: graph-2026-10-fundamentals
Recommended: +
plannedQuality Loop: Won't auto-enable (scope OK).
admarble commentedon Oct 19, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 6/6 met
Gaps:
admarble commentedon Oct 19, 2026
Execution Verification (runner, 2026-10-19), PR #1548 @ 8058510
The runner re-ran every Evidence command verbatim in the worktree:
oksame11fast(3.73 s)CI:
testandhealth-advisorypassed.Mutation (AC-3 gate test): deleted the raised-metric branch in
compare. Two tests failed, "exits 1 and names the key" and "--write-baseline … --check exits 0", 2 of 7. Restored, tree clean. The record is in the PR body.Founding-doc drift: the runner re-ran the script on a detached 96990da checkout.
emptyCatch.total= 120 (the table says 119) andproseGate.lines= 30,179 (the table says 30,461). Every other planning value reproduces.Open for the owner:
emptyCatch.byFile.*is reported but not gated. The spec's plan, step 4, chose this. See the PR body's "Decisions to review".admarble commentedon Oct 19, 2026
Owner ruling, 2026-10-19:
emptyCatch.byFile.*stays ungated in--check, as the spec chose. A catch that moves between files does not fail CI, but any rise inemptyCatch.totalstill does. This settles QA's repository_gap finding on PR #1548.