Skip to content

test(rules): await rule.run() in every rules test, typecheck tests in CI #1863 - #1864

Merged
nc9 merged 2 commits into
mainfrom
boat/await-rule-run-1863
Nov 14, 2026
Merged

nc9 merged 2 commits into
mainfrom
boat/await-rule-run-1863

Conversation

@nc9

@nc9 nc9 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Closes #1863.

Summary

  • Every rules test now awaits rule.run(), or an async helper that does, before it asserts. Tests whose callbacks now await are async, and every helper that calls run() returns a Promise and is awaited by its callers.
  • Fixture type errors are fixed in the tests themselves, never in src/. Partial fixtures get typed casts, RedirectChain/SiteQuery/PageFeatureRow fixtures get the fields they were missing, and test(name, { timeout }, fn) becomes test(name, fn, { timeout }). Non-u regex literals that tsgo rejects become new RegExp(...) with the same source and flags.
  • tests/fold-inconclusive-1031.test.ts was vacuous for a different reason. It read signal.evaluated, a field that no longer exists (it became notEvaluated, which holds the complement), so it compared null with null. It now asserts that the folded and raw signals have equal notEvaluated maps and that the key lists every page. The rule is correct: the new assertion passes, and it fails when resolution ignores the inconclusive marker.
  • packages/rules typecheck is now tsgo --noEmit && tsgo --noEmit -p tsconfig.test.json, so CI's bun run typecheck keeps the tests at 0 errors.
  • No real rule bugs turned up. No assertion was weakened, and no awaited test failed against the real rule.

tsconfig.test.json errors: 952 before, 0 after.

Mutation checks (the 10 named files)

For each file I made a local edit to the rule that inverts its verdict, ran the file, then restored src/ with git checkout.

File Mutation Result
empty-heading A: swap warn/pass. B: drop the first item, suppress the unconfirmed row A fails 24/29. B fails the other 5 (labels, items, unconfirmed). 29/29
form-field-multiple-labels-1249 swap warn/pass 10/10
identical-links-same-purpose swap warn/pass 6/6
no-contextual-inbound A: swap warn/pass. B: skipped to info, drop the first item, bare labels. C: invert orphan-pages and weak-internal-links, and empty their items A fails 29/47, A+B+C fail 46/47. The survivor (#1144) checks constants only and never calls a rule
dom-size swap warn/pass, skipped to pass 10/10
content-unrendered-markup A: pass to warn, fail/warn to pass, skipped to pass. B: constant message, empty details.kinds A+B fail all 31/31 tests that call the rule. The other 53 test the pure findUnrenderedMarkup/isCodeLikeElement helpers and never call run()
probe-path-not-approved-1655 agents-md: negate the not-checked condition. llms-txt: swap the not-approved and no-result reasons 4/4
framework-data-payload-1143 swap pass/info, and a page with no document emits a check fails all 12/12 rule tests. The other 4 test the pure findFrameworkPayloads
security/leaked-secrets-budget-overrun-1556 invert the unscanned condition and the pass condition fails the 1/1 rule test. The other 2 test buildCollectedPageSignal and never call run()
security/leaked-secrets-public-tier A: swap the public and leak tiers in the rule. B: negate publicByDesign in the scanner A fails the 1/1 rule test. B also fails 15 of the 39 scanContent tests. The other 24 test detection and skip logic and never call run()
(extra) fold-inconclusive-1031 resolution ignores the inconclusive marker the rewritten assertion fails (notEvaluated[key] is undefined)

Eight of the ten already threw if run() returned a Promise, so they were not actually vacuous. They are converted anyway, as the issue asks.

Acceptance criteria

  • Every rules test awaits rule.run() or uses a helper that does. Evidence: tsgo -p tsconfig.test.json reports 0 errors, so no test reads .checks from a Promise | RuleResult.
  • Each of the 10 files is mutation-checked: see the table. The only tests that survive call a pure helper or constant and never call rule.run().
  • bunx tsgo --noEmit -p packages/rules/tsconfig.test.json reports 0 errors and is wired into the package typecheck.

Gates

  • bun run typecheck in packages/rules (both configs): exit 0. bun run typecheck at the repo root: exit 0. bun run scripts/test-suites.ts --check: ok.
  • Tests: all 226 changed test files, 5 explicit paths per invocation, run in sequence. 10 named files: 249 pass, 0 fail. The other 216: 7,805 pass, 0 fail. The 72 files touched by a final paren cleanup were re-run: 1,837 pass, 0 fail.
  • packages/rules has no format or lint script.

Agent skill

No change to the squirrelscan agent skill is needed (test-only change).

nc9 added 2 commits November 14, 2026 15:47
… in CI #1863

Every rules test now awaits rule.run() or an async helper before asserting, the remaining fixture type errors are fixed, and fold-inconclusive-1031 asserts on notEvaluated (the field evaluated became), where it compared null to null. tsconfig.test.json goes from 952 errors to 0 and runs as part of the package typecheck.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 marked this pull request as ready for review November 14, 2026 15:58
@nc9
nc9 merged commit a09f1e0 into main Nov 14, 2026
16 checks passed
@nc9
nc9 deleted the boat/await-rule-run-1863 branch November 14, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rules tests that assert on an un-awaited rule.run() result may pass vacuously

1 participant