Skip to content

test: Rule #2 source-scanning guards (typed errors, fetch timeouts, empty catch) - #98

Merged
Hiksang merged 4 commits into
mainfrom
test/rule2-guards
Nov 15, 2026
Merged

Hiksang merged 4 commits into
mainfrom
test/rule2-guards

Conversation

@Hiksang

@Hiksang Hiksang commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds three source-scanning test guards for SSOT Rule #2, with no new dependency. The repo has no linter; these checks run inside pnpm test, in the style of readme-cli-sync.test.ts.

Guard Fails when Baseline
rule2-typed-errors-guard A plain throw new Error( is added in src/commands, src/exchanges or src/bot (it should be a typed PerpError) Ratchet, per file: 73 / 84 / 11 today
rule2-fetch-timeout-guard A fetch( call without AbortSignal / signal is added anywhere in src/ Ratchet, per file: 78 today
rule2-silent-catch-guard An empty catch has no comment explaining why Exact (0 today)
  • A shared helper (src/__tests__/helpers/strip-source.ts) blanks comments and string text before scanning, so prose never matches. It has its own tests.
  • A ratchet fails in both directions: above the baseline (a new violation) and below it (lower the baseline, so a removed violation cannot come back). The failure message prints the current map to paste over BASELINE.
  • docs/TESTING.md §6.1 documents the guards.

No production code changes. The existing violations are not fixed here.

Rejected guards: catch { return <default> } (23 sites) and .catch(() => undefined) (5 sites) are mostly legitimate probes (isX() → false, cache miss → null). Without type information a guard could not tell them from a swallowed failure, so it would be noise.

Merge order — please read

Because the ratchets fail when a count changes in either direction, any other PR that adds or removes a plain Error or an un-timed fetch will make pnpm test fail on main after both are merged. Merge this PR last among the open fix PRs (#76, #84, #94–#97, the fetch-timeout and path branches), then update the baselines once from the printed map. fix/fetch-timeouts in particular lowers the fetch count.

Checklist

  • pnpm test passes (338 files / 7271 tests; 12 new)
  • tsc --noEmit and typecheck:test pass
  • No secrets, API keys, or private keys included
  • Breaking change? No

Testing standard (docs/TESTING.md §7)

  • Each guard was proven to fire: a temporary violation in a new file and in an existing file failed the guard; a /* signal */ comment did not bypass it; a raised baseline failed with "lower this baseline". All probes were reverted.
  • No fixture change; no test.skip / .only

Not independently reviewed yet.

🤖 Generated with Claude Code

…, empty catch)

Ratchet baselines for plain throw new Error( and fetch( without a timeout;
exact guard for uncommented empty catch blocks. Documented in docs/TESTING.md 6.1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hiksang and others added 3 commits November 15, 2026 19:03
… guard baselines

After merging main: the typed-error guard caught a plain Error added in
history report --since. The fetch-timeout baseline drops from 78 to 24
call sites now that fetchWithTimeout is on main.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Hiksang
Hiksang merged commit c1a5e19 into main Nov 15, 2026
4 checks passed
@Hiksang
Hiksang deleted the test/rule2-guards branch November 15, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant