Skip to content

feat(content): estimate a draft's Site Audit score in the editor, free, with AI checks on request (item 9) - #1955

Merged
gkhngyk merged 13 commits into
ansvisor:mainfrom
cihan-gyk:feature/content-audit-estimate
Nov 2, 2026
Merged

gkhngyk merged 13 commits into
ansvisor:mainfrom
cihan-gyk:feature/content-audit-estimate

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Customer priorities, item 9, part 2: the Content Editor estimates the draft's Site Audit score, for free, before it is published. Stacked on #1954. No migration.

What changes

  • Header chip: "Audit ≈62", whatever Quality's phase. It opens the estimate's card.
  • Card, in Quality and from the chip: the score, the five categories, and what the score rests on. It is read again each time typing pauses.
  • How it is scored (server/src/lib/audit/draft-estimate.js):
    • The audit's own checks run on the page as Export's HTML file has it, for free.
    • The 13 checks of the whole site (robots.txt, llms.txt, HTTPS, the theme's tags and links) come from the brand's latest completed audit. Without one they're left out, and the card says so. Left out alone, the estimate ran 17 points under the full audit on the dev audits, against about 6 with them in.
  • Estimate AI checks runs the 13 checks AI reads, on Quality's AI usage (reserveAiBudget, its share shown). The verdicts come back with each later reading, so the score keeps them.
  • API: POST /api/content-drafts/:id/audit-estimate, with its own rate limit. evaluateLlmSignals reports its tokens for charging.
  • Write this's dialog names the estimate.
  • Help: Content Editor, page quality, opportunity details.

Related issue

None. Customer priorities plan, item 9.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open a draft: the header shows "Audit ≈…" within a second or two, and the chip opens its card.
  2. Type and pause: it reads again.
  3. Estimate AI checks: the score includes them, and the line says when they were read.
  4. Unit tests: draft-estimate, the route (free, AI charged, verdicts kept, refusals), ai-estimates, the client, the hook and card, the editor page.

Checked in the browser at 1024px, light and dark, with the estimate served by a local stand-in running this branch's code; its AI checks were sample verdicts, with no AI call. The owner approved the screens.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes (0 errors; 7 old warnings in files this PR doesn't touch)
  • yarn typecheck passes
  • yarn format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

Full checks: CI passed on this PR (b98311f): schema is up to date; web format:check, lint, typecheck, tests and yarn build pass; server lint, format:check and tests pass.

🤖 Generated with Claude Code

cihan-gyk and others added 4 commits November 1, 2026 19:44
…d then the page in one run (item 9)

Customer priorities item 9: an opportunity to a draft written from a brief
took six clicks. Write this, in a row's menu and as the panel's main
button, does it in one: a dialog says what happens and about how much of
the month's AI usage it takes, then the draft starts as Start opens it
and the Content Agent builds its brief (the editor's Build brief, holding
the draft's claim so Stop lets go of it) and writes the page from it, or
suggests changes to the existing page an opportunity names. A brief that
can't be built leaves the page written from what there is.

The AI usage answer adds what Write this typically takes, as a share of
the budget (ai-estimates.js); the editor's wait screen shows the brief's
run first. Help: opportunity details and content opportunities.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e, with AI checks on request (item 9)

Customer priorities item 9: no Site Audit score of a draft existed before
it was published. An Audit chip in the editor's header, there whatever
Quality's phase, and a card in Quality now estimate it: the audit's own
checks run on the page as Export's HTML file has it, read again once
typing pauses, for free; the checks of the whole site (robots.txt,
llms.txt, HTTPS, the theme's tags and links) come from the brand's latest
completed audit, and are left out without one, as leaving them out alone
ran 17 points under the full audit on the dev audits against about 6.
Estimate AI checks runs the 13 checks AI reads on Quality's AI usage; the
verdicts come back with each later reading, so the score keeps them.

Server: POST /api/content-drafts/:id/audit-estimate (draft-estimate.js,
its own rate limit), evaluateLlmSignals reports its tokens for charging,
and the AI usage answer adds what the AI checks typically take. Write
this's dialog names the estimate. Help: Content Editor, page quality,
opportunity details.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	web/src/lib/help/approved-articles.json
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	server/src/lib/audit/llm-signals.js
@gkhngyk

gkhngyk commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

This conflicts with main in server/src/lib/audit/llm-signals.js: #1919 rewrote evaluateLlmSignals (two views, cached verdicts in site_audit_llm_verdicts, auditLlmModel()). The estimate needs to be reworked on top of that version rather than rebased as is. Note that it will then read and write the verdict cache too; please confirm that is intended.

@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Reworked on top of #1919's evaluateLlmSignals (two views, cached verdicts, auditLlmModel()), with current main merged in.

On the cache, yes, that's intended: the estimate reads and writes the verdict cache through evaluateLlmSignals. Its key is the text's hash plus the signal, model and prompt version, with no page or brand in it. So a draft's verdict reaches the live page only when the text is identical, and then the verdict is the same anyway. A cached verdict isn't charged. lastVerdicts (the live page's last audit) isn't used: if the AI checks fail, the estimate says they didn't run. CI on this PR is running now; I'll update the Full checks line when it's green.

cihan-gyk and others added 2 commits November 2, 2026 01:29
… keep its verdicts' ref out of render

The estimate's route is open to the demo brand's sample drafts (its page
checks are free and write nothing), and its AI checks, which spend, refuse
the demo brand in the route itself (402 demo_brand). The hook keeps the
latest AI verdicts in its ref from an effect, not while rendering.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

CI fixes (b98311f):

  • The audit-estimate route is classified in demo-brand.js as open, with the reason: the free page checks write nothing and run on demo drafts too. The AI checks that spend budget refuse the demo brand in the route itself (402 demo_brand), with a test.
  • The ref update moved out of render into useEffect (react-hooks/refs).
  • A test component assigned an outside variable; fixed.

Locally: full server tests, web format:check, lint and the coverage tests pass.

gkhngyk
gkhngyk previously approved these changes Nov 2, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

# Conflicts:
#	help/content/opportunity-details.md
#	server/src/lib/ai-estimates.js
#	server/src/lib/ai-estimates.test.js
#	server/src/routes/billing.js
#	server/src/routes/billing.test.js
#	web/messages/en.json
#	web/src/components/content/write-this-dialog.test.tsx
#	web/src/lib/billing/ai-usage.ts
#	web/src/lib/help/approved-articles.json

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gkhngyk
gkhngyk merged commit ec28eeb into ansvisor:main Nov 2, 2026
5 checks passed
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.

2 participants