Skip to content

fix(audit-engine,cli): max-duration probes before the page rules stop at their own deadline #1327 - #1368

Closed
nc9 wants to merge 3 commits into
mainfrom
fix/max-duration-1327-1332
Closed

nc9 wants to merge 3 commits into
mainfrom
fix/max-duration-1327-1332

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Closes #1327

Rebased onto main after the #1324 batch (cherry-picks); resolved against the later resourceChecksCut work: maxDuration now carries both resourceChecksCut and probesSkipped.

  • Soft-404 re-fetch and cloaking probe stop at their own deadline inside the margin and are skipped; maxDuration.probesSkipped names them; page checks run on the fetched pages; siteChecksCut is true only when site checks really did not finish.
  • Docs (cli/audit, configuration/output) and CHANGELOG updated; e2e + unit tests; format, lint, tsgo, docs validate clean.

Skill change: none.

nik

… at their own deadline and are listed in the report #1327

Signed-off-by: Nik Cubrilovic <[email protected]>
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of #1368. The design is sound: each probe gets its own deadline inside the margin, a timed-out probe is skipped, and the skip is surfaced through maxDuration.probesSkipped. I read the diff only and did not run the tests.

  • (medium) packages/audit-engine/src/adapter.ts withinDeadline: the abandoned soft-404 work is not cancelled, so it keeps re-fetching and writing parsed.soft404Confirmation while the page rules run. markUnresolvedSoft404 sets unconfirmed first, and a late confirmation can then overwrite it in place. Verdicts could change mid-run, and the late writes could make output non-deterministic. Consider an AbortSignal or a cancelled flag that confirmSoft404Candidates checks before each write and each fetch. The same applies to the abandoned cloaking probe, which keeps consuming network and per-host rate budget.
  • (low) withinDeadline is inserted between the existing JSDoc for buildStreamingSiteData ("Pass 2 re-parses...") and that function. The old doc now attaches to withinDeadline. Move the helper above that comment.
  • (low) probesSkipped is pushed from the onProbeSkipped callback without dedup. That is fine for a single call, but slimMaxDuration is the only place that bounds it, and the sanitizer in report.ts does not dedupe either. A new Set is cheap.
  • (nit) The new adapter.ts lines (the import, the withinDeadline signature, the Promise.race line) look unformatted compared with the surrounding code. packages/* is not CI-checked, so run oxfmt on the changed lines only.
  • (nit) PROBES_SHARE = 0.3 sits between CHECKS_SHARE (0.2) and PAGE_RULES_SHARE (0.4). The resource checks end at 0.2 and the probes at 0.3, so confirm the probes do not overlap the resource checks' window if they run concurrently.

Tests (unit plus e2e) cover the budget and the skip path. I'd add one test that a late-resolving soft-404 probe does not overwrite unconfirmed after the skip.

…ine, cloud steps are bounded, skipped only with work to do, 3 s page-rules window #1327

Signed-off-by: Nik Cubrilovic <[email protected]>
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of #1368 (probe deadlines under --max-duration). I read the diff and did not run the tests.

  • (medium) apps/cli/src/controllers/audit.ts (cloud prefetch raceUntil): when the race times out, the prefetch promise is abandoned but not cancelled. It can keep calling cloud services and spending credits after the deadline. Because cloudResult stays unset, that spend is never recorded in the report or billing summary. Pass an abort signal into runCloudPrefetchFromPayloads, or record the spend incurred so far. Tech-detect is less affected because it reports spend through onSpend.
  • (low) packages/audit-engine/src/adapter.ts: withinDeadline was inserted between the existing doc comment ('Pass 2 re-parses, so the confirm-pass mutation must be carried by value…') and buildStreamingSiteData. That comment now attaches to withinDeadline. Move the helper above the comment.
  • (low) packages/audit-engine/src/adapter.ts: when the soft-404 pass times out, the abandoned work can still write parsed.soft404Confirmation after markUnresolvedSoft404 has run. The abort should make this rare, and the verdict is benign either way. The race is not documented, and a late write would make unconfirmed and a real verdict differ between runs.
  • (low) cloaking-probe.ts: a probe cut at the deadline discards all results, including pages already probed. Returning the partial results would keep more data. This is a design choice, but the PR does not state it.
  • (nit) packages/audit-engine/src/adapter.ts: the new lines are not oxfmt-formatted (long import, long call lines). These packages are not checked in CI, but the diff touches the surrounding lines.
  • (nit) apps/cli/src/controllers/report.ts: the probe-id regex /^[a-z0-9-]{1,40}$/ is fine and bounded. Coverage for hostile slim JSON (non-strings, more than 10 entries) is worth confirming in max-duration.test.ts.

Tests: unit and e2e tests are added for the probe deadline and for raceUntil. Documentation and the changelog are updated. I did not see a test that cloud prefetch abandonment leaves the audit consistent.

…-host delay, cloaking skipped only with paths, docs scope #1327

Signed-off-by: Nik Cubrilovic <[email protected]>
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of #1368 (probe deadlines under --max-duration). I read the source diff but did not run the tests or the e2e.

No (critical) or (high) findings. The design is sound: the probes get their own deadline inside the margin, an abort signal reaches the in-flight fetch, an unresolved soft-404 candidate falls back to unconfirmed (never dropped), and probesSkipped is validated on the slim-JSON path.

  • (medium) apps/cli/src/controllers/audit.ts (cloud prefetch and tech-detect wrapped in raceUntil): on timeout the underlying promise is abandoned, not cancelled. The paid round trips may keep running and spending credits in the background after the audit has reported them as abandoned. For tech-detect, onSpend can still increment techDetectCredits after the result was dropped. Please confirm that raceUntil attaches a catch to the losing promise (so a late rejection is not unhandled) and that late spend is still accounted for or documented. Passing an abort signal into these calls would be better if the clients support it.
  • (low) packages/audit-engine/src/adapter.ts: the new withinDeadline docblock sits between the existing docblock (the "re-parsing page stream" comment) and buildStreamingSiteData. That detaches the original doc from its function. Move withinDeadline above that docblock.
  • (low) packages/audit-engine/src/adapter.ts (cloaking skip check): the nested selectCloakingPaths(...) call is evaluated only when the probe timed out without starting. It re-derives maxPages and recentDays inline, which duplicates the config mapping already done inside resolveCloakingProbes. Share one helper so the two cannot drift.
  • (low) soft404-confirm.ts: after withinDeadline times out, markUnresolvedSoft404 runs while the abandoned confirmSoft404Candidates may still write parsed.soft404Confirmation as its aborted fetches settle. Both end up unconfirmed, so this looks benign. A test that asserts the verdict stays stable after the timeout would pin it.
  • (low) maxDurationReason in failure-reason.ts joins probesSkipped into the message. The names are validated on the slim path (/^[a-z0-9-]{1,40}$/), but nothing validates them on the live path. They are internal constants, so this is fine today. Consider typing them as a string-literal union.
  • (nit) adapter.ts and cloaking-probe.ts contain very long lines and trailing-comma style that do not match the surrounding code. Other packages are not format-checked in CI, but please keep new code readable.
  • (nit) In slimMaxDuration, hoist the probe-name regex to a module constant.

Test coverage looks good: unit tests for the deadline and budget math, an engine test, and an e2e test. Per AGENTS.md, please confirm the tests fail when the fix is reverted, and run bun run scripts/test-suites.ts --run cli and --check for the new test files.

@nc9

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.145 as f655bb58 99696ad2 73cd1a55 via #1377. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.145. Closing this original.

nik

@nc9 nc9 closed this Oct 30, 2026
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.

audit --max-duration: make the pre-page-rule fetch stage deadline-aware

1 participant