Skip to content

fix(qa): the proseGate metric counts any test file that mentions SKILL.md — 34 of 76 counted files are not prose gates; count only files that read a SKILL.md and assert on it #1566

Closed

Description

@admarble

Problem

scripts/qa/health-report.ts:243 counts a test file as a prose gate when its text contains SKILL.md anywhere and it uses toContain or toMatch anywhere: text.includes("SKILL.md") && /toContain|toMatch/.test(text).

#1511's audit (docs/internal/graph-2026-10-fundamentals/prose-gates.md) found that 34 of the 76 counted files are not prose gates. In those files SKILL.md appears only as a path, a fixture, a comment or a message string. So proseGate.files and proseGate.lines move whenever someone adds an ordinary test to such a file. On 2026-10-19 that happened twice: +57 lines in #1557 and +1 in #1552. The owner ruled that this class of rise may be absorbed into the baseline until the metric is fixed. #1512 converts and deletes the real gates but keeps the counting rule (its AC-1 caps the count at keep + execute).

Owner-requested 2026-10-19.

Acceptance Criteria

  • AC-1: A file counts only when it reads a SKILL.md (a readFileSync or helper call whose path ends in SKILL.md, or one that goes through SKILL_ROOTS) and asserts on that text. Evidence: npx vitest run scripts/qa/health-report.test.ts -t "prose gate" → ≥ 3 passed, 0 failed. Cases: a file that reads SKILL.md and calls toContain on it is counted; a file that mentions SKILL.md only in a comment or path string is not; a file that reads SKILL.md but asserts nothing on it is not. Fails today: there is no such case.
  • AC-2: The count drops by the path-only files. Evidence: the PR body lists each file that leaves the count, with its row in prose-gates.md, and jq '.proseGate.files' scripts/qa/health-baseline.json is at least 25 lower than on main at the PR's base. Not runnable until the PR exists.
  • AC-3: AC-1 is a gate test, so the PR body carries its SEQUANT_MUTATION record. The mutation is to restore the includes("SKILL.md") test and confirm the comment-only case fails.

May touch

scripts/qa/health-report.ts, scripts/qa/health-report.test.ts, scripts/qa/health-baseline.json, docs/internal/graph-2026-10-fundamentals/prose-gates.md (a note on the redefinition), CHANGELOG.md.

Non-Goals

Activity

  1. added
    bug
    on Oct 20, 2026
  2. admarble commented on Oct 20, 2026

    @admarble
    ContributorAuthor

    Runner context, 2026-10-20, before launch (stop-at-PR; default tier). main = 77fc3c5.

    State on main:

    This issue's metric lowers by design. Regenerating the baseline after the definition change is the point (AC-2). List every file that leaves the count.

    #1506 (PlatformProvider / fake GitHub) runs at the same time. It does not touch health-report.ts.

    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 targeted npx vitest run <files> for the ACs.
    CHANGELOG: add [Unreleased] lines under the existing ### Added / ### Changed headings, not changelog.d/ fragments, and never add a second heading of the same name.
    Lint: #1503 made no-unused-vars, no-empty-object-type and prefer-const errors, and knip counts unused exports. Don't export what nothing imports.
    Health baseline: regenerate scripts/qa/health-baseline.json (npx tsx scripts/qa/health-report.ts --write-baseline) only to record a metric that went down. If npm run lint:health reports a rise, restructure so it holds. Otherwise leave the baseline alone and name the rise in the PR body. Owner ruling: a proseGate.lines rise caused by tests in files that mention SKILL.md only as a path may be absorbed, and must be said so.
    Freeze: nothing under plugin/, .claude/skills/ or templates/skills/.

  3. admarble commented on Oct 20, 2026

    @admarble
    ContributorAuthor

    Complexity: Simple (3 ACs, 2 directories)

    AC Quality Check

    • AC-1 Evidence is runnable and fails today (no "prose gate" case exists in health-report.test.ts). Its three cases are enumerated, so no vague wording.
    • AC-2 is "not runnable until the PR exists". That is acceptable, since the baseline diff is the evidence. The "≥ 25 lower" threshold is plausible: all 34 not a prose gate: rows in prose-gates.md still exist on main (checked), and the baseline is 63 files today.
    • AC-3 is a process AC. /qa §6i needs the failedTest path to be the FILE path (scripts/qa/health-report.test.ts > ...).

    Scope Assessment

    Non-Goals: present in the issue (no gate conversion, no other metrics, nothing under plugin/, .claude/skills/ or templates/skills/).

    Metric Value Status
    Feature count 1 ✅
    AC items 3 ✅
    Directory spread 2 ✅

    Verdict: ✅ SCOPE_OK

    Acceptance Criteria

    AC-1: Count only files that read a SKILL.md and assert on that text

    Verification: Unit Test
    Scenario: Given fixture test files in a temp root → When collectMetrics runs → Then a file that reads SKILL.md and calls toContain counts; a comment-only or path-string-only file does not; a file that reads it but asserts nothing does not.
    Assumptions: SKILL_ROOTS (from scripts/check-skill-sync.ts) is the only helper-path form to recognize, besides a literal path ending in SKILL.md.

    AC-2: The count drops by the path-only files

    Verification: Manual Test (PR-body list plus a baseline diff)
    Scenario: Given the new rule → When the baseline is regenerated → Then .proseGate.files is ≥ 25 below 63 and each departing file is listed with its prose-gates.md row.

    AC-3: Mutation record for AC-1

    Verification: Manual Test (PR body)
    Scenario: Given AC-1's tests → When the old includes("SKILL.md") test is restored → Then the comment-only case fails. Record it as Mutation-verified: AC-1 — … and in the SEQUANT_MUTATION marker with failedTest set to scripts/qa/health-report.test.ts > ….

    Implementation Plan

    Phase 1: Redefine the detector (scripts/qa/health-report.ts:243)

    1. Extract a small non-exported isProseGate(text). A file counts when (a) it has a read of a skill file, meaning a readFileSync/read-helper call, in the same statement or a variable it flows from, whose path argument ends in SKILL.md or goes through SKILL_ROOTS, and (b) it has a toContain|toMatch assertion. Do not export it, because knip counts unused exports. Keep the REMOVAL_VERSION_RE import from chore(lint): every @deprecated names its removal version — lint:deprecations in CI, CONTRIBUTING rule #1510.
    2. Strip comments before matching, so a comment-only mention cannot count. Don't match SKILL.md inside quoted strings that are not a read argument.
    3. Spike first: run the new rule over the repo and diff its file list against the 34 not a prose gate: rows. A real gate that goes uncounted (or a path-only file still counted) means the rule needs tuning. Candidate edge: sync.install-scope.integration.test.ts "edits a real SKILL.md".

    Phase 2: Tests, baseline, docs

    1. Add three cases to scripts/qa/health-report.test.ts in a describe("prose gate") block. The AC-1 -t "prose gate" filter matches that block name.
    2. Regenerate the baseline with npx tsx scripts/qa/health-report.ts --write-baseline. It only lowers proseGate. Check the diff touches no other key. If lines moves for another reason, name it in the PR.
    3. Add a note on the redefinition to prose-gates.md, since the Method section describes the old heuristic. Add an [Unreleased] line under the existing ### Changed heading in CHANGELOG.md.
    4. Run npx vitest run scripts/qa/health-report.test.ts and npm run lint:health. Do not run the full suite more than once, in the foreground under timeout, after a WIP commit.

    Design Review

    1. Where does this logic belong? In collectMetrics in health-report.ts, the only place that counts the metric.
    2. What's the simplest correct approach? A text heuristic (comment strip, then a read-of-SKILL.md regex plus assertion regex). Rejected: parsing the AST with the TS compiler. It is heavier, and the metric is a ratchet, not a proof.
    3. Pattern and re-patch count? This is a text-heuristic metric. git log -S'includes("SKILL.md")' shows one origin, feat(qa): health-report.ts — one script prints the fundamentals baseline, --check fails a raised metric, advisory CI job, release-checklist line #1502 (11cb5e4), and no earlier fix. This issue is the first correction, so there is no recurrence stop.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • The regenerated baseline lowers on purpose (the owner's ratchet ruling).
    • Heuristic edge cases such as a read through a local helper or a const p = ...SKILL.md variable are the main risk. The spike in step 3 settles them.
    • Whether the table's 34 files are all gone is unknown until the spike runs. AC-2's ≥ 25 slack covers a few misclassifications.

    Open Questions

    1. How to treat a file that reads a helper-returned skill text (loadSkill("qa")) with no literal SKILL.md? Recommendation: count it only if the helper path goes through SKILL_ROOTS or the file also holds a literal path ending in SKILL.md, as AC-1 says. Impact: a missed gate would lower the count wrongly. The spike will show whether any such file exists.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: one script plus its test, with a metric-only baseline change. There is no UI, so no test phase. testgen is skipped because the bug label with ≤2 code ACs means targeted tests suffice.

    Label Review

    Current: bug
    Recommended: bug, planned
    Quality Loop: won't auto-enable (scope is OK).

  4. added
    planned
    on Oct 20, 2026
  5. admarble commented on Oct 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_NOT_MET

    AC coverage: 1/3 met

    Gaps:

    • AC-1 rule counts a file that mentions SKILL_ROOTS only in a string, the mention-not-read class AC-1 excludes; strip string literals or require an import and add a test case
    • AC-2 requires each departing file listed with its prose-gates.md row; add the rows (all 32 are not-a-prose-gate rows) and correct the joiner list
    • Two path-only files remain in the count; name them in the PR body or tighten the rule
    • No case covers a file that reads SKILL.md but asserts with toContain on unrelated output
    • Formatting churn makes the real change harder to review
    • Required CI test check still running
  6. admarble commented on Oct 20, 2026

    @admarble
    ContributorAuthor

    Runner note for the exec+qa re-run, 2026-10-20. QA returned AC_NOT_MET; its findings are on this issue. Fix all three fix_now items:

    1. AC-1. SKILL_ROOTS or SKILL.md inside a string literal must not count. Strip string literals before the test, or require a real import or read call. Add a test case: a file whose only SKILL_ROOTS is inside a string.
    2. AC-2. List every file that leaves the count, with its prose-gates.md row, and correct the list of files that join the count.
    3. The two path-only files still counted (src/commands/update.integration.test.ts and src/lib/templates.test.ts): tighten the rule so they leave the count, or name each one in the PR body with the reason it stays.

    Also: revert the pure 80-column re-wrapping in health-report.ts and its test, so the diff shows only the real change. If a case is quick to add, cover the documented gap too: a file that reads SKILL.md but calls toContain on unrelated output.

  7. added a commit that references this issue on Oct 20, 2026
  8. admarble commented on Oct 20, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #1566 (Simple Fix)

    Size Gate

    Check Value
    Diff size 77 lines (threshold: 100)
    package.json changed No
    Security-sensitive paths No
    Decision Inline checks

    AC Coverage

    AC Description Status Notes
    AC-1 Count only files that read a SKILL.md and assert on it; ≥3 cases MET npx vitest run scripts/qa/health-report.test.ts -t "prose gate" → 4 passed, 0 failed. Covers read+toContain counted (literal, variable, SKILL_ROOTS), comment/path/fixture/scratch not counted, SKILL_ROOTS-in-string not counted, and read-without-assert not counted. A whole-repo spike gave 34 files leaving and 1 joining; each departing file is a not a prose gate: row, and each of the 29 kept files is a gate row.
    AC-2 PR body lists each departing file with its prose-gates.md row; baseline ≥25 lower NOT_MET The baseline half is met: jq '.proseGate.files' is 30, down from 63 on main (−33). The PR body does not list the files. It says "The list is in /tmp/left.txt, so paste it into the PR body." That is an unexecuted instruction, and /tmp/left.txt is not visible to reviewers. The prior QA run raised the same finding.
    AC-3 SEQUANT_MUTATION record for AC-1 MET The marker is present and names scripts/qa/health-report.test.ts > prose gate > does not count …, a file in the diff. QA re-ran the mutation by restoring text.includes("SKILL.md") && /toContain|toMatch/: the comment/path-string case failed (plus the counts case), and the file was restored.

    Coverage: 2/3 AC items fully met

    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 5 OK
    Lines added +74 -
    Lines deleted -3 -
    Security patterns 0 OK

    npx vitest run scripts/qa/health-report.test.ts → 12/12 passed. npm run lint:health → "no metric rose above the baseline". The baseline diff touches only proseGate.

    CI Status

    Check State Impact
    test (required) IN_PROGRESS ⏳ PENDING
    knip-advisory FAILURE Advisory. Also red on #1568 (main), so not this diff
    typecheck, canary, validate-*, health-advisory, tautology-advisory, Gitleaks, node-floor-guard SUCCESS ✅

    Code Review

    Strengths:

    Issues:

    • AC-2's PR-body listing is missing (see above).

    Suggestions:

    • The line-comment strip (^|[^:"'\\])//.*$also cuts inside a string such as"a // b"`, which can leave an unbalanced quote for the later string strip. This is harmless on today's corpus (the spike matches the audit), but it is fragile.
    • The PR body has no prose Mutation-verified: AC-1 — … line, which CLAUDE.md asks for alongside the marker. Its "+77 / −8" figure is also stale (the actual diff is +74 / −3).
    • Known limit, documented in the PR: a file that reads SKILL.md and calls toContain on unrelated output still counts.

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    scripts/qa/health-report.ts Standard Yes scripts/qa/health-report.test.ts

    Coverage: 1/1

    Anti-Pattern Detection

    None found.

    Trust-Boundary Check

    Finding: Clean. The diff implements only the product requirements. No agent-directed external-text instruction was acted on.

    Status: Clean

    Behavior-Rule Survival Check

    AC Triggered? Survivors Status
    AC-1 No — N/A

    Status: N/A. The old includes("SKILL.md") rule is removed from collectMetrics, and it was the only counting site.

    Declared-Evidence Execution

    AC Evidence Executed? Result
    AC-1 npx vitest run scripts/qa/health-report.test.ts -t "prose gate" Yes ✅ 4 passed, 0 failed
    AC-2 jq '.proseGate.files' scripts/qa/health-baseline.json Yes ✅ 30, down from 63 (≥25 lower). The listing half is missing

    Status: Complete

    Mutation Verification

    AC Gate Test? Marker Status
    AC-1 Yes scripts/qa/health-report.test.ts > prose gate > does not count a file that names the skill file only in a comment or a path string Verified (QA re-ran it)

    Status: Verified

    CHANGELOG Verification

    Result: CHANGELOG requirements met. The [Unreleased] ### Changed entry includes (#1566).

    Risk Assessment

    • Likely failure mode: The heuristic misses a future real gate that reads via a helper with no SKILL.md literal and no SKILL_ROOTS. That would lower the metric silently. A // inside a string could also break the string strip.
    • Not tested: A read of SKILL.md followed by toContain on unrelated output (documented limit). There is also no case for // inside a string literal.
    • Sibling sites considered: Class searched: other health metrics counting by bare substring presence. childProcessMockFiles uses a call regex rather than a mention test, and the Non-Goals exclude other metrics.
    • Sibling-line audit: none. This is a single-call-site fix in collectMetrics.

    Follow-up Ledger

    • "reads SKILL.md, asserts on unrelated output" limit (runner note, optional) — ⚠️ unresolved. Drop it or file it.
    • Status: Unresolved

    Verdict: AC_NOT_MET

    AC-2 is NOT_MET. The PR body must list each file that leaves the count together with its prose-gates.md row. Instead it holds the exec's note to paste the list from /tmp/left.txt. Everything else checks out: the rule matches the audit across the whole repo, the baseline drop is 33, and the mutation was re-run and confirmed. The required CI test check was still pending at review time.

    Next Steps

    1. Edit the PR body (use gh api -X PATCH) to list the 34 departing files below with their not a prose gate: row from prose-gates.md. Name the 1 joiner, __tests__/quality-checks-worktree-root.integration.test.ts, and delete the /tmp/left.txt sentence.
    2. Add the prose Mutation-verified: AC-1 — … line and correct the diff-size figure.
    3. Record the unrelated-output limit as filed or dropped.
    4. Re-run QA after CI test reports.
    Departing files (computed by QA from the old and new rules over git ls-files)

    scripts/check-skill-sync.test.ts, scripts/lint-skill-calls.test.ts, scripts/spec/ground-check.test.ts, src/commands/tests/locks-cli.integration.test.ts, src/commands/doctor.test.ts, src/commands/init.codex.integration.test.ts, src/commands/init.next-steps-1387.test.ts, src/commands/serve.integration.test.ts, src/commands/sync-source-invocation.integration.test.ts, src/commands/sync.install-scope.integration.test.ts, src/commands/sync.test.ts, src/commands/update.integration.test.ts, src/commands/update.test.ts, src/commands/version-preflight.test.ts, src/lib/tests/assess-collision-detect.test.ts, src/lib/tests/writer-state-matrix.test.ts, src/lib/ac-parser.test.ts, src/lib/assess/renderer.test.ts, src/lib/heuristics/tests/behavior-rule-detector.test.ts, src/lib/locks/checkout-lock.test.ts, src/lib/merge-check/merge-check-extended.test.ts, src/lib/merge-check/merge-check.test.ts, src/lib/skills-commit-state.integration.test.ts, src/lib/templates.test.ts, src/lib/workflow/drivers/tests/driver-conformance.test.ts, src/lib/workflow/drivers/opencode.test.ts, src/lib/workflow/phase-executor.property.test.ts, src/lib/workflow/phase-executor.test.ts, src/lib/workflow/qa-stagnation.test.ts, src/lib/workflow/run-orchestrator.test.ts, src/lib/workflow/run-orchestrator.worktree-failure.test.ts, src/lib/workflow/run-skills-commit-warning.integration.test.ts, src/lib/workflow/skills-preflight.integration.test.ts, src/lib/workflow/skills-preflight.test.ts

    Structured Gap Findings

  9. added
    needs-work
    on Oct 20, 2026
  10. admarble commented on Oct 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_NOT_MET

    AC coverage: 2/3 met

  11. admarble commented on Oct 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 3/3 met

    Gaps:

    • Section 11 script verification is Not Verified; QA ran lint:health and recomputed 63 to 30, but there is no /verify record
    • A file that reads SKILL.md but calls toContain on unrelated output still counts and has no case — dropped: needs an AST, beyond a text heuristic
    • The line-comment strip also cuts at // inside a string literal — dropped: does no harm on the current files; the recomputed list matches the audit

    Suggestions:

    • The line-comment strip also cuts at a // inside a string, such as "a // b". It does no harm on today's files (the recomputed list matches the audit), but it is fragile.
    • The PR body still has the stale "QA has not run" banner.
  12. admarble commented on Oct 20, 2026

    @admarble
    ContributorAuthor

    Execution Verification (runner, 2026-10-20), PR #1569 @ c3d9538

    The runner re-ran the ACs and the script in the worktree. The branch is current with main.

    • scripts/qa/health-report.test.ts: 12 passed. The AC-1 -t "prose gate" cases: 4 passed.
    • AC-2: proseGate.files is 30 on the branch and 63 on main.
    • npm run lint:health: no metric rose.
    • Lint green; CI test passed.

    The departing-file list was recomputed independently. The runner compared the old rule (includes("SKILL.md") && /toContain|toMatch/) with the new isProseGate over every tracked test file: 34 leave, 1 joins (quality-checks-worktree-root.integration.test.ts, which reads through SKILL_ROOTS) and 29 stay. Each of the 34 is a keep row whose note says it is not a prose gate. The table is in the PR body.

    AC-1 mutation reproduced: reverting isProseGate to the old rule fails does not count a file that names the skill file only in a comment or a path string.

    Two limits, both documented and dropped:

    • A file that reads SKILL.md but calls toContain on unrelated output still counts. Telling those apart needs an AST.
    • The // comment strip can cut inside a string literal. It does no harm on today's files.
  13. added a commit that references this issue on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-workplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions