Skip to content

chore(lint): end the 2026-01 "temporarily relaxed" rules, add knip as an advisory job with a numeric baseline #1503

Closed

Description

@admarble

Epic: graph-2026-10-fundamentals Tier: mechanical Execution: sequant_run Blocked by: #1502

Problem

eslint.config.js carries three rules at warn under the comment "Temporarily relaxed rules for gradual adoption", added 2026-01-11. Nine months later they produce 3 warnings in the whole tree. The relaxation can end. Separately, nothing in the repo reports unused exports: the dormant surface found in the usage audit (6 commands, 64 of 89 flags, 26 of 65 settings) was visible only through run logs. knip is the standard tool; it lands advisory with a numeric baseline in F-01's report (OQ-9 default), not as a blocking check.

Acceptance Criteria

  • AC-1: No relaxed rule remains and lint is green. Evidence: grep -cE '"(@typescript-eslint/no-unused-vars|@typescript-eslint/no-empty-object-type|prefer-const)": "warn"' eslint.config.js → 0
  • AC-2: Lint passes with the rules at error (constraint: green today, must stay green after AC-1). Evidence: npm run lint > /dev/null 2>&1 && echo green → green
  • AC-3: knip is installed and configured. Evidence: jq -e '.devDependencies.knip' package.json > /dev/null && test -f knip.json && echo ok → ok
  • AC-4: knip runs as an advisory job. Evidence: grep -A14 '^ knip-advisory:' .github/workflows/ci.yml | grep -c 'continue-on-error: true' → 1
  • AC-5: The health report carries the unused-export count and the baseline records it. Evidence: npx tsx scripts/qa/health-report.ts --json | jq -e '.unusedExports >= 0' > /dev/null && jq -e '.unusedExports >= 0' scripts/qa/health-baseline.json > /dev/null && echo ok → ok

Prior fixes / producers

  • Prior fixes: git log -S "Temporarily relaxed" --format='%h %ad %s' -- eslint.config.js → one commit (2026-01-11), never revisited. Isolated.
  • Producers of eslint.config.js: F-02, F-04, F-07, F-08 each append one config block (§8 style rule). This node edits only the existing "relaxed" block and adds nothing else.

May touch

eslint.config.js (the relaxed block only), package.json (knip devDependency, one lint:knip script line), package-lock.json, knip.json (new), .github/workflows/ci.yml (one appended job), scripts/qa/health-report.ts (the unusedExports key), scripts/qa/health-baseline.json (regenerated with --write-baseline, I-4), and the ≤ 3 source lines the warnings point at.

Non-Goals

  • No removal of any export knip reports (F-10, D-2).
  • No knip ignore entries beyond entry points and generated files; noise is carried as the baseline number, not hidden.
  • No edits under plugin/, .claude/skills/, templates/skills/ (I-1).

Done when

npm run lint is green with no warn relaxation, and the knip-advisory check appears on the PR.

Activity

  1. added
    graph-2026-10-fundamentals
    on Oct 18, 2026
  2. admarble commented on Oct 19, 2026

    @admarble
    ContributorAuthor

    Runner context, 2026-10-19, before launch (fundamentals W1, beside #1521/#1528 and the judgment set; stop-at-PR). main = ec9d583.

    Changed since filing:

    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, and this wave runs 7 issues at once. Prefer the targeted npx vitest run <files> for the ACs.
    CHANGELOG: add [Unreleased] lines, not changelog.d/ fragments. #1370 has not merged.
    Freeze: nothing under plugin/, .claude/skills/ or templates/skills/.
    Health baseline: if this PR changes a measured metric, regenerate scripts/qa/health-baseline.json with npx tsx scripts/qa/health-report.ts --write-baseline after the last source change. Never hand-edit it. npm run lint:health must print "no metric rose".

  3. admarble commented on Oct 19, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (5 ACs, 5 directories)

    AC Quality Check

    All five ACs carry a command-shaped Evidence:; each was run against main (ec9d583):

    AC Fails on main today? Note
    AC-1 ✅ yes (3, not 0) gates the work
    AC-2 ⚠️ passes today (npm run lint is already green, --max-warnings 0) stated as a constraint; only meaningful after AC-1, so run it after the edit
    AC-3 ✅ yes (no knip, no knip.json)
    AC-4 ✅ yes (no knip-advisory job) -A14 window must contain continue-on-error: true exactly once, so keep the job ≤14 lines after its header
    AC-5 ✅ yes (no unusedExports key)

    One gap: AC-5 checks the key is >= 0 but not that it matches the knip count. Plan adds a test for that (see AC-5).


    Scope Assessment

    Non-Goals: present (no export removal, no ignore beyond entry points/generated files, nothing under plugin/, .claude/skills/, templates/skills/).

    Metric Value Status
    Feature count 2 (end relaxation, knip advisory) ✅
    AC items 5 ✅
    Directory spread 5 (root config, .github/workflows, scripts/qa, src ≤3 lines, lockfile) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: No relaxed rule remains

    Verification: Integration Test (grep command)
    Scenario: Given eslint.config.js lines 29-32 → When the three warn entries and the "Temporarily relaxed" comment are removed → Then the grep prints 0
    Assumptions: Removing the entries means the rules fall back to the typescript-eslint recommended preset, where no-unused-vars and no-empty-object-type are error and prefer-const is error via eslint.configs.recommended/preset. Verify in the config which presets are spread above the block; if one is not, set the rule to "error" explicitly. Otherwise AC-2 stays green while enforcement is silently off.

    AC-2: Lint passes at error

    Verification: Integration Test (npm run lint)
    Scenario: Given AC-1 applied → When npm run lint → Then exit 0
    Assumptions: The issue says 3 warnings remain; on main lint prints none under --max-warnings 0, so the ≤3 source-line fix may already be unnecessary. Confirm by running lint with the rules at error before touching source. Mutation check: add an unused var in a scratch file, confirm lint fails, remove it.

    AC-3: knip installed and configured

    Verification: Integration Test (jq + file test)
    Scenario: Given no knip → When npm i -D knip and add knip.json → Then evidence prints ok
    Assumptions: Entry points: bin/cli.ts, src/index.ts, scripts/** runnable files, vitest test globs; ignore only for generated/dist. Add one lint:knip script (knip). Lockfile diff must contain only knip and its deps (discard unrelated libc churn).

    AC-4: knip runs as advisory job

    Verification: Integration Test (grep on ci.yml)
    Scenario: Given ci.yml → When knip-advisory: job appended after health-advisory with continue-on-error: true → Then grep count is 1
    Assumptions: Mirror health-advisory (pinned action SHAs, if: pull_request, Node 22.x, npm ci). Pinned SHAs must be copied from the existing job, not retyped.

    AC-5: Health report carries unusedExports; baseline records it

    Verification: Unit Test (scripts/qa/health-report.test.ts) + command evidence
    Scenario: Given knip configured → When health-report.ts --json → Then .unusedExports is a number ≥ 0 and health-baseline.json has the same key
    Assumptions: unusedExports: number added to HealthMetrics and collectMetrics, computed by spawning npx knip --reporter json (exit code non-zero on findings is normal, so parse stdout, don't trust the status) and summing exports + types entries. The key is gated by default (not in UNGATED), consistent with the ratchet; the CI job stays advisory. Fixture-tree tests in health-report.test.ts run collectMetrics on a temp root with no knip config: the counter must return 0 (not throw) there, and the fixture-key assertions must be updated. Regenerate the baseline with --write-baseline after the last source change; never hand-edit.


    Implementation Plan

    Phase 1: Retire the relaxation (AC-1, AC-2)

    1. eslint.config.js:29-32: delete the comment and three warn entries (the block only; refactor(commands): split initCommand, doctorCommand, syncCommand and updateCommand to ≤ 200 counted lines; max-lines-per-function ratchet for src/commands #1509 appends its own block later). Check the presets above supply error for all three; else set explicit "error".
    2. npm run lint; fix any finding (≤3 source lines per "May touch").

    Phase 2: knip (AC-3, AC-4)

    1. npm i -D knip; add knip.json and the lint:knip script line.
    2. Run npx knip once locally to confirm entry points are sane (noise is carried as the baseline number, not hidden).
    3. Append knip-advisory to .github/workflows/ci.yml after health-advisory.

    Phase 3: Health report (AC-5)

    1. Add the unusedExports counter + type field in scripts/qa/health-report.ts; extend health-report.test.ts (fixture returns 0; a stubbed knip JSON of N entries yields N).
    2. npx tsx scripts/qa/health-report.ts --write-baseline, then npm run lint:health must print "no metric rose". CHANGELOG [Unreleased] lines (not changelog.d/).

    Targeted run only: npx vitest run scripts/qa/health-report.test.ts; full suite at most once, foreground, under timeout, after a WIP commit.


    Design Review

    1. Where does this belong? Config in eslint.config.js/knip.json; the metric in the existing health-report script that feat(qa): health-report.ts — one script prints the fundamentals baseline, --check fails a raised metric, advisory CI job, release-checklist line #1502 created, not a new script.
    2. Simplest approach? Delete the entries (rely on presets). Rejected: a knip-specific wrapper script, and a blocking knip check (OQ-9 says advisory).
    3. Pattern / re-patch count? Follows the health-advisory job + ratchet-metric pattern from feat(qa): health-report.ts — one script prints the fundamentals baseline, --check fails a raised metric, advisory CI job, release-checklist line #1502. git log -S "Temporarily relaxed" = one commit; no prior fix issues. Not a re-patch.
    4. Reviewer challenge: "Why shell out to knip inside the report?" The AC requires the key in --json output, and the baseline must come from the same producer. A second challenge is runtime, since knip adds seconds to lint:health; measure it and note it in the PR.
    5. Producers/consumers of HealthMetrics: producer collectMetrics (one); consumers run/format/compare, health-report.test.ts, health-baseline.json, the health-advisory job, the release checklist line. compare treats keys absent from the baseline as non-rises, so ordering is safe.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • npx knip inside collectMetrics needs knip installed in the health-advisory job; npm ci covers it once the lockfile is updated.
    • Knip's JSON shape varies by version; pin the version and parse defensively (missing section → 0 only if knip ran, a spawn failure should surface as an error, not a silent 0).
    • Mutation-verification for gate tests: record Mutation-verified: for the AC-5 test (delete the counter, confirm the named test fails, restore) in the PR body, with the file path before the first >.

    Open Questions

    1. Count which knip categories? Recommendation: unused exports + unused exported types (the "unused export" meaning of the key); report files/dependencies separately later. Impact: baseline number changes, nothing else.
    2. AC-2/source lines already clean? Recommendation: proceed; if lint is green at error with no source edits, the PR touches no src/ at all. Impact: none.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Mechanical tier, config plus one metric. AC-5 declares a unit-test-shaped check but is a small extension of an existing tested script; targeted tests in exec suffice, so testgen is skipped.


    Label Review

    Current: graph-2026-10-fundamentals
    Recommended: + planned
    Reason: Plan posted.
    Quality Loop: Won't auto-enable (SCOPE_OK).

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

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 5/5 met

    Gaps:

    • Script change has no /verify evidence (section 11 Not Verified)
    • Deferred knip files/dependencies reporting has no terminal state
    • The || true makes knip-advisory always green, so findings never surface as a failed advisory check — dropped: optional polish, owner call

    Suggestions:

    • knip-advisory runs npx knip || true and also sets continue-on-error: true. Because of the || true, the job is always green, so no signal appears in the checks list even when knip finds something. Dropping || true would let the job show up as a failed but non-blocking check.
    • Every lint:health run and every health-report run now spawns knip, which takes about 2.5 s. That's fine, but worth knowing.
  6. admarble commented on Oct 19, 2026

    @admarble
    ContributorAuthor

    Execution Verification (runner, 2026-10-19), PR #1550 @ 7e7649e

    The runner re-ran every Evidence command verbatim in the worktree:

    • AC-1: 0
    • AC-2: green
    • AC-3: ok
    • AC-4: 1
    • AC-5: ok; unusedExports = 342 is recorded in the baseline.

    npm run lint:health: no metric rose. The baseline diff adds only unusedExports; the ungated testRatio28d drifted.

    The lockfile diff is knip and its dependencies. The codex entries were rewritten at the same versions (0.162.1), and there is no libc churn.

    knip-advisory passed on the head. Its || true keeps it green on purpose: knip exits 1 with 342 unused exports today, and the ratchet is unusedExports in lint:health. The owner rules on keeping it.

  7. added a commit that references this issue on Oct 19, 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

    graph-2026-10-fundamentalsplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions