Skip to content

refactor(report): isAuditFailed, isScoreless and one max-duration partial rule for live and rebuilt reports - #1673

Closed
nc9 wants to merge 2 commits into
mainfrom
fix/report-status-helpers-1662
Closed

nc9 wants to merge 2 commits into
mainfrom
fix/report-status-helpers-1662

Conversation

@nc9

@nc9 nc9 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Closes #1662

What

  • isAuditFailed(status) and isScoreless(status) sit beside auditStatusToLifecycle in core-contracts, which now uses them. failed and blocked are failed; partial and an absent status are not. They replace the open-coded status === "failed" || status === "blocked" (and its negation) in the JSON, LLM, markdown, text and HTML renderers, locked-rules, waf-blocked, grouping, the console renderer, fail-on, the MCP billed audit and the engine's report-stream (whose private isScorelessStatus is gone). isScoreless is the same set today and a separate name for the N/A-score sites, so a status that fails but keeps a score changes one place.
  • withMaxDurationCut(run, cut) in reports/reconstruct.ts is the one place a --max-duration cut makes a completed (or status-less) run partial, with the cut's reason and the max_duration code. The live audit (controllers/audit.ts) and the rebuild from the stored scope (reconstructReport) both call it. It is applied after the smart-audit carried-page override rather than inside deriveCrawlRunStatus: that override resets the status to completed, so a cut applied inside the derivation would be swallowed.

No output changes: statuses, reasons and codes are what they were.

Acceptance criteria

  • isAuditFailed / isScoreless exist next to auditStatusToLifecycle and replace the open-coded checks. Left as they are: commands/audit.ts lines that the exit-code change (squirrel audit: exit code and outcome come from 34 scattered assignments; one precedence function, outcome in JSON #1657 / the exit code PR) deletes, and coverage.ts, which asks for failed alone (a redirect failure), not failed-or-blocked.
  • The partial-on-max-duration rule is one function used by the live audit and the squirrel report rebuild. It sits beside deriveCrawlRunStatus and not inside it, for the ordering reason above.
  • Test: the same cut gives the same status, reason and code live and rebuilt from the store (apps/cli/tests/reports/max-duration-status-1662.test.ts: a 7-row table for the function, plus a stored crawl rebuilt with reconstructReport compared with the live call).

Characterization first

apps/cli/tests/reports/rebuilt-max-duration-status-1662.test.ts pins the rebuild (a crawl with no cut has no status stamped; one with a recorded cut is partial with the cut's reason and max_duration). It was run against the old reconstruct.ts and was green before the change. packages/core-contracts/tests/audit-status-1662.test.ts tables the predicates and auditStatusToLifecycle over every status, null and undefined.

Also run by explicit path, unchanged: report json-status, llm-status, html-status, max-duration-partial-1271, locked-rules-coverage, failure-notice, passed-rules, failure-reason-renderers; the CLI fail-on, max-duration, fail-on-timed-out-security-970, mcp max-duration and billed-audit-summary, reconstruct-page-rule-counts-1260 and the audit-max-duration e2e; the engine's report-stream-v2 and streaming-scoring goldens. tsgo in apps/cli, packages/report, packages/audit-engine, packages/core-contracts; root lint; bun run format:check in apps/cli; make validate.

Notes

  • No JSON field is added, so JSON_REPORT_SCHEMA_VERSION is untouched.
  • This PR and the exit-code PR both touch commands/audit.ts; the lines this one leaves alone are the ones that PR removes, so they should not conflict.
  • grouping.ts's reportPassedRules parameter is now typed status?: AuditStatus (was string) so it can use the predicate.
  • The squirrelscan agent skill needs no change.

@nc9
nc9 force-pushed the fix/report-status-helpers-1662 branch from 8a2d2dd to b82b323 Compare November 10, 2026 11:13
@nc9
nc9 marked this pull request as ready for review November 10, 2026 11:13
@nc9
nc9 force-pushed the fix/report-status-helpers-1662 branch from b82b323 to 1fd4f12 Compare November 11, 2026 00:22
@nc9

nc9 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Already on main as 31f70ba and 0af0104, which landed through an earlier bundle, so merging this changes nothing. Closing as landed.

nik

@nc9 nc9 closed this Nov 13, 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.

report: failed-or-blocked check open-coded 10+ times and partial status derived in two places

1 participant