Skip to content

chore(lib): convert the remaining ~94 empty catches to noteSuppressed, forbid empty catch bodies by lint, show the count in sequant logs #1505

Closed

Description

@admarble

Epic: graph-2026-10-fundamentals Tier: mechanical Execution: sequant_run Blocked by: #1504, #1471

Problem

After F-03, 94 empty catch clauses remain across ~40 files (conventions-detector 6, state-hook 6, project-name 5, prompt 4, watch 4, …). Converting them and landing the lint in the same PR avoids a warn phase: one no-restricted-syntax rule holds one severity, and a second config block replaces the rule rather than extending it (D-B). no-empty cannot do this job because it treats a comment-only block as non-empty by design. The selector CatchClause > BlockStatement[body.length=0] was probed on 2026-10-18 and flags comment-only catches. sequant logs gains one line per run once #1471 has moved parseLogFile to run-logs.ts.

Acceptance Criteria

  • AC-1: No empty catch remains. Evidence: npx tsx scripts/qa/health-report.ts --json | jq '.emptyCatch.total' → 0
  • AC-2: Lint forbids them at error. Evidence: grep -c 'CatchClause > BlockStatement\[body.length=0\]' eslint.config.js → ≥ 1
  • AC-3: Lint is green with the rule (constraint: green today, must stay green after AC-2). Evidence: npm run lint > /dev/null 2>&1 && echo green → green
  • AC-4: sequant logs prints the count. Evidence: npx vitest run src/commands/logs.test.ts -t "suppressed" → ≥ 1 passed, 0 failed (new file, none exists today; a run-log fixture with suppressed: {total: 3, byScope: {state: 2, progress: 1}} renders a line matching Suppressed errors: 3 \(state 2, progress 1\); a log without the field renders no such line)
  • AC-4 is classified as a gate test by isGateTestEvidence; the PR body carries its SEQUANT_MUTATION record (remove the suppressed line from the renderer → the test fails; restore).
  • AC-5: The baseline moves down with the PR. Evidence: jq '.emptyCatch.total' scripts/qa/health-baseline.json → 0

Prior fixes / producers

Class tracked in #1504 (two prior fixes named there). This node is the mechanical remainder; the outcome AC (AC-1) covers every producer.

May touch

Every non-test file with an empty catch (list from health-report.ts --json | jq '.emptyCatch.byFile' at launch), eslint.config.js (one appended block, D-B), src/commands/logs.ts and src/commands/logs.test.ts (after #1471), scripts/qa/health-baseline.json (I-4), CHANGELOG entry.

Non-Goals

Done when

emptyCatch.total is 0, lint rejects a new empty catch, and sequant logs shows the per-run count.

Activity

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

    @admarble
    ContributorAuthor

    Runner context, 2026-10-21, before launch (fundamentals W3; stop-at-PR; mechanical tier). main = fc346aa (#1506 merged as #1576: platforms/github.ts changed; it holds 4 of the empty catches).

    Count on main today: emptyCatch.total is 92 in 42 files, not 94. The baseline says 92. Take the list from npx tsx scripts/qa/health-report.ts --json | jq '.emptyCatch.byFile'.

    Lint scope. I probed the AC-2 selector over the lint surface. It flags 101 sites: the 92 that the health report counts, plus 9 in 6 scripts/ files (mcp-launch.mjs 3, analytics/ready-backtest.ts 2, one each in analytics/analyze-runs.ts, generate-constitution-dod.ts, probes/claude-cloud-probe.ts, spec/ground-check.ts). Tests are in the lint ignores, so they don't count. Apply the rule to src/**/*.ts and bin/**/*.ts only, which is the set AC-1 measures. Leave the 9 script sites alone and name them in the PR body as out of scope.

    Flat config replaces the rule; it doesn't add to it (D-B). A later block that sets no-restricted-syntax replaces every earlier selector for the files it matches. Two existing blocks set this rule: the global require() ban and the phase-executor.ts console/stdout ban (#647). So:

    • The new src/** + bin/** block must list the require() selector again.
    • It must sit before the phase-executor.ts block.
    • The empty-catch selector must also be added to the phase-executor.ts block.
      Before you commit, prove each of these with a scratch edit and npx eslint <file>, then revert:
    1. An empty catch in phase-executor.ts errors.
    2. A console.log in phase-executor.ts still errors.
    3. An empty catch in another src/ file errors.
    4. A require() in a src/ file still errors.
    5. An empty catch in a scripts/ file does not error.
      Record the five results in the PR body.

    Converting a site. Use catch (err) { noteSuppressed("<scope>", err, "<context>"); } from src/lib/workflow/suppressed.ts. Use other when no scope fits. Don't change what happens after the error (Non-Goal). A comment-only body still fails the selector. suppressed.ts imports nothing, so importing it can't create a cycle. If a file must not depend on lib/workflow/ (check the file's existing imports), use an explicit statement with a one-line reason instead, and list those sites in the PR body.

    AC-4. src/commands/logs.test.ts doesn't exist yet. parseLogFile is in src/lib/run-logs.ts (#1471), and the run-log schema already has suppressed (run-log-schema.ts:474). For the mutation record, remove the renderer line and confirm only the new test fails. Write the record with the file path first, in the SEQUANT_MUTATION format.

    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, so commit at least every 10 minutes during exec. Prefer targeted npx vitest run <files> runs for the ACs.
    CHANGELOG: add [Unreleased] lines under the existing headings, not changelog.d/ fragments, and never add a second heading of the same name.
    Lint: don't export what nothing imports (knip).
    Health baseline: regenerate scripts/qa/health-baseline.json with npx tsx scripts/qa/health-report.ts --write-baseline only to record a metric that went down, here emptyCatch.total to 0 (AC-5). If npm run lint:health reports a rise in any other metric, restructure so it holds. If you can't, leave the baseline alone and name the rise in the PR body.
    PR body and commits: no claude.ai/code/session_ links anywhere (Gitleaks rule claude-session-url). The plain "Generated with Claude Code" line is fine.
    Freeze: nothing under plugin/, .claude/skills/ or templates/skills/.

  3. admarble commented on Oct 21, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (5 ACs, 4 directories)

    AC Quality Check

    Scope Assessment

    Non-Goals: Present in the issue (no behaviour change, no #1472/#1475 files, no plugin/, .claude/skills/, templates/skills/).

    Metric Value Status
    Feature count 3 (convert, lint, logs line) ⚠️
    AC items 5 ✅
    Directory spread 4 (src/commands, src/lib/**, bin, config/scripts) ⚠️

    Verdict: ⚠️ SCOPE_WARNING. 92 mechanical sites in 42 files. The risk is breadth, not complexity.

    Acceptance Criteria

    AC-1: No empty catch remains

    Verification: Integration Test (CLI). health-report.ts --json | jq '.emptyCatch.total' → 0 (92 today)
    Scenario: Given 92 sites in 42 files → When each is converted → Then total is 0.
    Assumptions: The health counter and the lint selector agree on src/** and bin/**. They do per the runner probe (101 − 9 scripts/ sites = 92).

    AC-2: Lint forbids them at error

    Verification: Integration Test. grep -c on the selector, plus 5 scratch-edit npx eslint proofs.
    Scenario: Given the new block → When an empty catch is added in src/ or phase-executor.ts → Then eslint errors. A console.log in phase-executor.ts and a require() in src/ still error. A scripts/ empty catch does not.

    AC-3: Lint stays green

    Verification: Integration Test. npm run lint exits 0.

    AC-4: sequant logs prints the suppressed count

    Verification: Unit Test, a gate test. New src/commands/logs.test.ts.
    Scenario: Given a run log with suppressed:{total:3,byScope:{state:2,progress:1}} → When displayLogSummary renders it → Then it prints Suppressed errors: 3 (state 2, progress 1). A log without the field prints no such line.
    Assumptions: displayLogSummary is not exported (logs.ts:48). Either export it, which knip forbids unless the test imports it (it will), or call logsCommand with a temp log dir and spy on console.log. Prefer the second, so there is no new export.

    AC-5: Baseline moves to 0

    Verification: Integration Test. jq '.emptyCatch.total' scripts/qa/health-baseline.json → 0.

    Implementation Plan

    Phase 1: Lint rule (do first, so it lists every remaining site)

    1. In eslint.config.js, add a files: ["src/**/*.ts","bin/**/*.ts"] block before the phase-executor.ts block (eslint.config.js:48). It lists the require() selector and CatchClause > BlockStatement[body.length=0] at error.
    2. Add the empty-catch selector to the phase-executor.ts block as well. A later block replaces the rule instead of extending it.
    3. Run the five scratch-edit proofs and revert each. Keep the results for the PR body.

    Phase 2: Convert the 92 sites (parallel by directory; see parallel-groups.md)

    Groups: (a) src/commands/* and bin/* (21 sites); (b) src/lib/*.ts top level (≈33); (c) src/lib/{relay,locks,upstream}/* (≈16); (d) src/lib/workflow/** (≈22).
    4. Use catch (err) { noteSuppressed("<scope>", err, "<ctx>"); }, scope other if none fits. Do not change what happens after the error.
    5. Check each file's imports first. bin/preflight.ts, fs.ts and process-group.ts may not be allowed to depend on lib/workflow/. Use an explicit statement plus a one-line reason there and list those sites in the PR body.
    6. Commit after each group, at least every 10 minutes (30-minute MCP wall).

    Phase 3: sequant logs line and baseline

    1. Add the "Suppressed errors: N (scope n, …)" line in displayLogSummary (src/commands/logs.ts). Print nothing when the field is absent.
    2. Write src/commands/logs.test.ts with a test whose name contains "suppressed".
    3. Run health-report.ts --write-baseline and confirm only emptyCatch.total moved. Add a CHANGELOG [Unreleased] line under an existing heading. Run npm run lint and npm run lint:health.
    4. Mutation record for AC-4: remove the renderer line, confirm only the new test fails, restore. Put the SEQUANT_MUTATION marker in the PR body with src/commands/logs.test.ts first in failedTest.

    Design Review

    1. Where does this belong? The lint rule goes in eslint.config.js. The counter is the existing src/lib/workflow/suppressed.ts. The render goes in commands/logs.ts.
    2. Simplest approach: One lint block and a mechanical rewrite. Rejected: no-empty (it allows comment-only bodies), and a warn-then-error ratchet (D-B means one severity per rule).
    3. Pattern and re-patch count: This continues the feat(run): a dropped error leaves a trace — noteSuppressed() counts into the run log, batch-executor's 25 silent catches converted #1504 noteSuppressed pattern. It is the mechanical remainder of the class tracked there, so it fixes the class and is not a local patch.
    4. Reviewer challenge: "Why not apply the rule to scripts/ too?" The runner scoped that out. The 9 script sites are named in the PR body. "Why does noteSuppressed now run on paths that never had a run log?" The counter is module-level and a no-op without a sink, and it never throws.
    5. Producers and consumers: Producers of empty catches are the 42 files in emptyCatch.byFile, and the lint selector is the fence. Consumers are health-report.ts and health-baseline.json, LogWriter (persists the counts), run-log-schema.ts, and commands/logs.ts. One counter is consumed by two readers, with no parity risk.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Several converted sites run in CLI paths that are not sequant run. The counts are never persisted there, which is harmless and should be stated in the PR body.
    • noteSuppressed in hot paths such as phase-executor.ts adds a counter increment only.
    • Knip: do not export anything new that nothing imports.

    Open Questions

    1. Does the bin/ selector need ignores for generated files? Recommendation: no, since bin/ is hand-written. Impact: lint fails on a new bin file, caught by AC-3.
    2. Files that must not import lib/workflow/. Recommendation: use an explicit statement with a reason, listed in the PR body. Impact: a import cycle if wrong, so check imports per file.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Mechanical tier with a clear outcome metric. AC-4 is a gate test, so QA enforces the mutation record. No testgen: only one new test and the stubs are described above. The runner's context says to stop at the PR.

    Label Review

    Current: graph-2026-10-fundamentals
    Recommended: graph-2026-10-fundamentals (no change)
    Quality Loop: Won't auto-enable. Scope is ⚠️ but mechanical.

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

    @admarble
    ContributorAuthor

    QA Verdict: NEEDS_VERIFICATION

    AC coverage: 5/5 met

    Gaps:

    • Line-number context labels drift with every edit; function names would stay accurate

    Needs human review:

    • Gating CI checks are still pending; re-run QA after CI completes
  6. added a commit that references this issue on Oct 22, 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