Skip to content

fix(rules): a rule abandoned for its time budget is not evaluated, never a failed check #960 - #969

Merged
nc9 merged 3 commits into
mainfrom
fix/960-timed-out-rule
Oct 20, 2026
Merged

nc9 merged 3 commits into
mainfrom
fix/960-timed-out-rule

Conversation

@nc9

@nc9 nc9 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

A rule abandoned for its time budget is now an explicit not-evaluated state, never a failed check:

  • Page rules: <rule>-error is skipped with skipReason: "rule-timed-out" (new shared constant in core-contracts) on EVERY page it times out on, the first included (was fail on the first). Site-rule timeouts too. Thrown errors stay fail.
  • Page-time extractors (collectedTimeoutChecks): a skipped row per timed-out page, same shape.
  • <rule>-timeouts info row (pagesNotChecked) kept, and now also emitted for extractor timeouts, since the per-page row is a skip.
  • details.timedOut stays on every row, so the rule-result cache still refuses to replay a timed-out page; template fan-out still keys on the -error name.

What I traced

  • Scoring and tallies: calculateRuleScore / addChecksToTally ignore skipped (and a rule with only skips is excluded from scoring), so a timeout adds no fail, no failUnits and no score change. New rule-timeout-score-960.test.ts runs the real RuleRunner and scorer: first-page and later-page timeout give failed/failUnits 0 and the same overall as the audit with that page left unchecked.
  • CLI and cloud use the same runner, so the statuses are identical. Resolution: a skip with this reason is not evidence, so on a check other pages emitted the timed-out page lands in notEvaluated and its prior finding carries (new test in resolution-compact.test.ts).
  • Known gap, not widened here: if a rule times out on EVERY page, none of its real check keys exists, so a prior finding resolves as with the old fail row. Filed resolution: a rule that times out on every page resolves its prior findings (key absent) #968 with criteria.

Codex pass: 3 findings, fixed (site-timeout gate, per-page extractor skips); the all-pages gap is #968.

Visibility of a timed-out security rule

rule-timed-out is now in NOT_CHECKED_SKIP_REASONS, so every report prints Not checked: <rule>. ... A timed-out rule did not check those pages, so no finding there is not a clean result. Run the audit again, or raise [rules] time_budget_ms if the machine was busy. (CLI console in yellow, text, markdown, HTML, XML, LLM, editor summary), not only the -timeouts info row. Test renders a timed-out security/leaked-secrets through the text and markdown renderers. Side effects of that membership, both intended: the publish cap pins these rows (like the other not-checked rows), and a rule whose every check timed out is not listed as a locked cloud rule. Caveat: info-severity rules are left out of the line by design, and a rule timing out on thousands of pages pins one small row per page.

Elapsed time

RuleTimeoutError measures wall-clock ms; each timed-out row carries ruleId, budgetMs, elapsedMs (diagnostic only, never scored or tallied) and the -timeouts row carries maxElapsedMs; extractor timeouts carry it through the collected signal. Details pass through the publish step untouched.

Docs

rules/index#rule-time-budget, configuration/rules#time_budget_ms, CHANGELOG Fixed; tangly check passes. Rule verdicts unchanged apart from this status; audit-engine goldens (rule-cache-replay, streaming canonical) pass.

skills: no change in this repo's skill files found (skills/ is a separate repo); the squirrelscan skill may describe -error checks as failures, to be checked there.

Closes #960

@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown

Reviewed the diff. The change is coherent: timed-out rules become skipped <rule>-error checks with a shared RULE_TIMED_OUT_SKIP_REASON. The -timeouts summary is now emitted for site-rule extractor timeouts too. The tests cover the score and tally, the resolution signal, and the case where a site rule times out itself. I did not run the test suite.

  • (medium) packages/rules/src/runner.ts A timed-out security rule such as security/leaked-secrets no longer fails anything, and the health score does not change. A CI gate that keys on failures or on the score will pass on pages that were never scanned. The only signal left is an info row. The docs warn about this, but consider giving security-category timeouts a more visible status or a summary-level warning, or confirm that the info row is enough.
  • (low) runner.ts (page-rule timeouts) Only the first skipped check carries details.pages, and the value is updated in place. Later skipped checks copy the count at the time they were made, so it goes stale. Collector timeouts drop pages from details entirely. Consumers should read pagesNotChecked from the -timeouts row. A comment saying so would help.
  • (low) runner.ts:~772 budgetMs falls back to 0 when timeouts[0] is missing. That can't happen given the timeouts && guard, but a summary that says 0 ms would mislead if it ever did.
  • (nit) The rule-timed-out literal still appears in the tests and in the page-rule earlier branch of runner.ts. Use the new constant there too.

@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown

Review of #969 (timed-out rule becomes a skipped check, not a fail).

The change is coherent. The test coverage is good: it uses the real runner and the real scorer, and covers the first-page and later-page cases plus the resolution-signal carry. I read the diff only and did not run the tests.

  • (medium) packages/rules/src/runner.ts (site-rule path): the summary row is now built inline in runSiteRules for collected-signal timeouts via timeoutSummaryCheck. timeoutSummaryChecks() also emits a <rule>-timeouts row for page rules. If one rule id can time out in both places, the audit would carry two <rule>-timeouts rows with different counts. Please add a test, or dedupe by rule id.
  • (medium) Security rules (e.g. security/leaked-secrets) that time out now add nothing to the failed counts or the score. The only signal left is an info row, and the score looks the same as if the page were clean. That follows from the design and the message text is explicit about it. Consider whether the CLI summary or report should surface *-timeouts for security rules more loudly than other info rows.
  • (low) earlier.maxElapsedMs = Math.max(earlier.maxElapsedMs ?? 0, e.elapsedMs ?? 0) || undefined is hard to read. Use an explicit if (e.elapsedMs !== undefined) guard.
  • (low) In the site-rule path, budgetMs falls back to 0 when timeouts[0].details has no budgetMs, and the message then says 'exceeded its 0 ms'. A fallback to the real budget would be safer.
  • (low) packages/rules/src/collected-signals.ts: the inline doc comment inside the timedOut type is long on one line. Pull elapsedMs out onto its own line, as the neighbouring fields do.
  • (nit) The test asserts elapsedMs >= budget - 5. Timer rounding makes that fine today, but it could be flaky on a loaded CI machine.

@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown

Reviewed the diff: the runner, the page-time extractor path, the site-rule path, docs, changelog and tests. I didn't run the test suite.

  • (medium) packages/rules/src/runner.ts (timeout handling): demoting a timeout from fail to skipped means a page built to make a security rule time out (e.g. security/leaked-secrets via ReDoS) now contributes no failure and no score impact. Previously the first such page was a fail. The -timeouts info row still reports it, but info rows don't affect the score, exit code or CI gates. If the intent is that this is correct per pub#960, consider at least keeping security-category timeouts visible to gating (e.g. a warning-level check) or documenting that a timed-out security rule can leave a clean score.
  • (low) runner.ts: earlier.maxElapsedMs = Math.max(earlier.maxElapsedMs ?? 0, e.elapsedMs ?? 0) || undefined and the Math.max(0, ...timeouts.map(...)) spread are a little obscure. A small helper would be clearer. The spread is also unbounded for a very large site, though in practice it's fine.
  • (low) The per-page -error skipped checks now scale with the number of timed-out pages (one per page, not one per audit). On a site where a rule times out everywhere this grows report size linearly. This is probably acceptable, but worth a note or a cap.
  • (nit) The elapsedMs type on timedOut in collected-signals.ts has an inline JSDoc inside a type literal. Pulling it into a named interface would read better.
  • (nit) Test coverage is good (end-to-end score parity, resolution carry-over, config tests). A test for the site-rule path (gatedOff with rule-timed-out skips) would round it out, since that is the subtlest logic change.

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.

A rule abandoned for its time budget renders as a failed check with a rule-error message

1 participant