Skip to content

fix(cli): bill and print the audited page count the report shows - #453

Merged
nc9 merged 2 commits into
mainfrom
fix/billing-shown-page-count-2399
Oct 3, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/billing-shown-page-count-2399

Conversation

@nc9

@nc9 nc9 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

This is the CLI half of a billing fix. The server change is in the private repo (repo#2399). A completed signed-in audit's page charge now equals 2 × the audited page count its report shows, and cloud renders prepaid for pages that were never audited are refunded at settlement.

Changes

  • auditedPageCount(report) (what the CLI sends as pagesAudited, and the basis of its printed spend) is now coverage.auditedPages ?? totalPages. Before, it used scanScope.pagesCrawled, the crawl count, which also counts error pages such as a 404 kept for its broken-link finding. For example, a cloud report showed "Scan: 4 pages crawled" next to "Coverage: audited 2 of 2 known pages" and "2 pages".
  • Bound: the count is never more than the pages this run fetched (scanScope.pagesCrawled, else pages.length). A smart re-audit's report also covers pages carried from earlier audits, and those are never billed again. Example: coverage says 50 audited, the crawl fetched 10, the CLI sends 10.
  • withAuditPageSettlement now mirrors the server's two-way settlement: the page line is exactly pagesAudited pages, whatever was prepaid. Before, it kept prepaid renders beyond that count, as the server did.
  • Docs, cloud/credits.mdx: the audited-page row says "every page the report shows as audited". A new paragraph explains that a URL fetched but not audited (a 404 or a 500) isn't charged, a render paid for one is refunded when the audit completes, and pages a smart audit carries forward aren't charged again.

Testing

  • tests/controllers/render-spend.test.ts: 12 pass, including the carried-pages bound (coverage 50, fetched 10 → 10).
    • 13 prepaid and 2 audited → one line of 2 pages / 4 credits.
    • A zero-page audit drops the prepaid line.
    • The count rule covers coverage vs crawl, a smart-audit union (12 of 40), and the no-coverage header.
  • tests/commands/render-decision.test.ts: 46 pass.
  • bun run typecheck, bun run lint and oxfmt: clean.
  • make validate in docs: all checks passed.

Ordering. This is safe to land before or after the server change. Server-side, a published report's shown count is authoritative regardless of what the CLI sends. This only affects unpublished runs and the CLI's printed total.

Changelog: The audit spend summary now counts the pages your report shows as audited, and no longer counts cloud renders of pages that came back as errors, which are refunded.

nc9 added 2 commits October 2, 2026 19:10
…o#2399)

The CLI now sends and prints the page count its report shows as audited: the
coverage line's count, else the "N pages" header. It used to use the crawl
count, which also counts 404 pages kept for their broken-link findings. The
spend summary mirrors the server's settlement in both directions: the page
line is exactly that many pages, and prepaid renders for pages that were
never audited are refunded. The credits docs say so.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 marked this pull request as ready for review October 3, 2026 05:29
@nc9
nc9 merged commit bfe872e into main Oct 3, 2026
14 checks passed
@nc9
nc9 deleted the fix/billing-shown-page-count-2399 branch October 3, 2026 05:29
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.

1 participant