Skip to content

fix(audit-engine): a rule that timed out never resolves its prior findings #968 - #997

Merged
nc9 merged 2 commits into
mainfrom
fix/968-timeout-no-resolve
Oct 21, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/968-timeout-no-resolve

Conversation

@nc9

@nc9 nc9 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #968.

A rule abandoned for its time budget leaves a skipped <rule>-error check, which names none of the rule's real checks. When it timed out on every page, the resolution signal had no key for the rule, and the merge resolved a prior finding on a crawled page.

  • collectResolutionEvidence records the pages each rule timed out on and emits a rule-wide key <rule>|* (resolutionRuleKey, core-contracts) in notEvaluated only, never in failing, so no tally counts it as a check. A skip naming no page, or a clipped page list, marks every crawled page.
  • computeMerge carries a prior finding whose page is listed under its rule's <rule>|* key, and every page of the rule when that key is truncated.
  • Compatibility: an older consumer does not know the key and ignores it (today's behaviour, never worse). Older producers send no such key, so the new consumer behaves as before. No wire-shape change; the key rides in existing maps and counts against the existing caps.

Tests: packages/audit-engine/tests/timeout-no-resolve-968.test.ts covers the signal and the publish merge, through both the original and compact signals: all-pages timeout carries, partial timeout carries its page, a page the rule cleared still resolves, no timeout still resolves. 5 of the 15 fail without the fix. Existing resolution, merge and rescore tests pass.

Docs: no change needed. Agent skill: no change needed.

Known coarseness: the in-process timeout path (runner.ts ~536-575) emits a count-only row with no page, so one timed-out page marks every crawled page as not run for that rule. That over-carries, never wrongly resolves. The precise per-page path is at runner.ts ~901 (page-time extractors).

@claude

claude Bot commented Oct 21, 2026

Copy link
Copy Markdown

Review of #997. The approach is sound and the fix is narrow. The tests cover both the sampled and compact signals. I found one real gap and a few smaller points.

  • (medium) packages/rules/src/resolution.ts:335 The comment on if (evaluated.size >= limits.maxChecks) break; // dropped key = no signal (safe) is wrong for this key. Without a <rule>|* key, the merge falls back to resolving, which is the bug this PR fixes. When the evaluated map is already at maxChecks, a rule that timed out on every page is silently dropped and its prior findings resolve. Reserve room for the rule-wide keys, or add the rule key to truncated instead of dropping it. truncated is the carry-everything direction, and the merge already checks it. Please add a test with the cap exhausted.
  • (low) packages/rules/src/resolution.ts:427 In the crawledOverCap branch, truncated now also gets every key in evidence.evaluated, not just the rule-wide keys. That is broader than the PR describes. It is probably harmless, since non-failing keys have nothing to resolve. Please confirm it doesn't change expected output for other checks, or limit it to the |* keys.
  • (low) packages/audit-engine/src/merge-core.ts:~976 The new comment block is inserted in the middle of the existing "never resolve" comment. The older comment is now separated from the checkKey branch it describes. Move the new block so both stay attached to their code.
  • (nit) In the timedOut collection, pagesTruncated is compared against check.pages?.length even on the pageUrl path. Consider checking it only for aggregated skips.
  • (nit) The tests have no case for a rule-wide key that is truncated, or for the maxChecks cap. A case for the truncated key would also cover the signal?.truncatedChecks.has(ruleKey) branch in the merge.

Security: nothing found. The change is a safe-direction one: carry instead of resolve. Compatibility with older consumers looks right.

@claude

claude Bot commented Oct 21, 2026

Copy link
Copy Markdown

Review of #997 (rule-wide <rule>|* not-evaluated key so a rule that timed out on every page no longer resolves prior findings).

The approach is sound. The key only goes in notEvaluated and truncated. Per-check keys give way under the key cap. Older consumers ignore the key, so they behave as before. The tests cover sampled and compact signals, partial timeouts, truncation, the key cap and recovery on the next clean run. I only read the diff and did not run the test suite.

  • (low) packages/audit-engine/src/merge-core.ts (~line 969): the new block sits in the middle of an existing comment. The sentence "Its absence from the fresh findings is not evidence the finding is gone… carry regardless" now sits above the pub#968 block, but it describes the checkKey block below it. Put the pub#968 block before that comment, or move the comment back down.
  • (low) packages/rules/src/resolution.ts: checkCap is reduced by the number of timed-out rules, so with many timed-out rules the per-check keys are crowded out. Dropped check keys fall back to "no signal", which the code comment calls safe, and that holds for the common case. If timedOutRules ever reaches maxChecks, checkCap is 0 and no per-check keys survive. That is fine, but a test for it would pin the behaviour down.
  • (nit) The break guarded by evaluated.size >= limits.maxChecks is labelled unreachable. Consider turning it into a dev-time assertion, or drop it, so it doesn't hide a future regression.
  • (nit) The CHANGELOG entry is clear. The release header above it is dated 2026-10-22, which is in the future. Check that date separately from this PR.

I found nothing blocking.

@nc9
nc9 force-pushed the fix/968-timeout-no-resolve branch from 5e1f161 to 377c509 Compare October 21, 2026 22:44
@claude

claude Bot commented Oct 21, 2026

Copy link
Copy Markdown

Reviewed the diff. I found nothing that should block the merge. I read the code but did not run the tests or check CI.

The change adds a rule-wide <rule>|* key to notEvaluated. The merge now carries prior findings on pages where the rule timed out, so a rule that timed out on every page no longer resolves them. The tests cover sampled and compact signals, partial timeouts, truncation, the key cap, and the carry clearing on the next normal run.

  • (low) packages/audit-engine/src/merge-core.ts ~L969-985: the new pub#968 block sits under the existing comment that explains the notEvaluatedByCheck carry just below it. That comment now reads as if it described the new block. Put the new block after the existing check, or move the comment so each one sits with its own code.
  • (low) packages/rules/src/resolution.ts: when the crawled list is clipped, the line for (const key of evidence.evaluated.keys()) truncated.add(key) adds every key to truncated. That includes keys that are already in failing and the unconfirmed-only keys. Confirm that truncated has no size cap in RESOLUTION_SIGNAL_LIMITS or the compact encoder, and that old consumers handle the |* key in truncated. The CHANGELOG and doc comment only say old consumers ignore it in notEvaluated.
  • (nit) packages/rules/src/resolution.ts: the if (evaluated.size >= limits.maxChecks) break; guard is marked unreachable. evaluated can also gain keys from the unconfirmed-merge path, and the checkCap reservation only accounts for failing. If that path can add keys, the guard drops the rule-wide key silently, which would bring the bug back. A test that mixes unconfirmed keys with timeouts near the cap would settle it.
  • (nit) The CHANGELOG entry could mention the user-visible effect for old CLI/cloud consumers: they ignore the new key and behave as before.

@nc9
nc9 merged commit 38d5269 into main Oct 21, 2026
15 checks passed
@nc9
nc9 deleted the fix/968-timeout-no-resolve branch October 21, 2026 22:57
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.

resolution: a rule that times out on every page resolves its prior findings (key absent)

1 participant