Skip to content

fix(audit): keep each AI verdict by its input so an unchanged page keeps its score (00430) - #1919

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/audit-stable-ai-verdicts
Nov 1, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/audit-stable-ai-verdicts

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

A Site Audit of an unchanged page could move 2–3 points between runs, enough to flip a signal between pass and fail. The cause: the 13 AI-judged signals were judged again on every audit, by a preview model, at the model's default sampling. This PR keeps each AI verdict by what it was judged from, so an unchanged page keeps its score. Customer priorities plan, P0 item 1.

What changes

  • A pinned model. The default AUDIT_LLM_MODEL is now google/gemini-3.8-flash, a versioned, stable model.
    • Calls use temperature: 0 and a fixed seed.
    • The server warns once if the variable names a preview or "latest" alias.
    • server/.env.example and docs/self-host/env-variables.mdx ask for a pinned id.
  • Verdicts kept by input (00430, site_audit_llm_verdicts, service role only, RLS on):
    • The key is the hash of the input the signal reads, plus the signal, the model and the prompt version.
    • Signals read one of two views: the opening (title + first 2,000 characters) for direct-answer and bluf-answer, and the body (first 8,000 characters + word count) for the other 11.
    • An unchanged page makes no AI call. A changed page is judged again only on the signals whose view changed.
    • A daily run deletes verdicts no audit has read for 180 days (site_audit_llm_verdicts_prune).
  • When the AI call fails:
    • The page's last full audit's verdicts are used.
    • With none, the audit is marked partial (00430 adds site_audits.partial), and the score leaves those signals out.
    • A partial audit isn't compared anywhere: the Pages list score, previous score and trend, hub trend, the report's change badge and snapshot, and Action Center's fix re-check (audit-recheck, where na read as "the fix held").
    • The report shows a plain note (en.json).
  • Help: "Read a site audit report" gets "Same page, same score" (approved-articles.json refreshed).

Owner decision (2026-11-01): keep the pinned stable model even though it costs more than the preview (input $0.75 / output $3.75 per million tokens, vs $0.50 / $3; it doubles in 2027). The cache removes the call for unchanged pages.

For @gkhngyk (prod)

  1. Apply 00430.
  2. Set AUDIT_LLM_MODEL on prod to the pinned id, or remove it so the new default applies. Otherwise the preview model stays.
    • The same variable also feeds AI recommendations. Their own default is unchanged.
  3. Watch temperature: 0. Google recommends leaving Gemini 3 at 1.0 and warns that lower values can loop or hurt quality. If it shows, raise it and bump the prompt version.
  4. The first audits after deploy judge all 13 signals once more (the URL is now sent without its query, and the opening signals see only the first 2,000 characters), so scores can shift once.

Next: "A partial audit uses no credit" is stacked on this PR (owner decision 2026-11-01).

Related issue

None. Customer priorities plan, P0 item 1 (score stability).

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. Apply 00430. Audit a page twice: the second audit makes no AI call (server log) and has the same score.
  2. Change only the page's title: only the opening signals are asked again.
  3. With the AI call failing and no earlier audit of the page, the audit completes as partial. The report shows the note, and the Pages list doesn't compare it.
  4. Unit tests:
    • five runs of the same input make no AI call and give the same score;
    • a title-only change and a body-only change ask only their own view's signals;
    • with one verdict missing, only that signal is asked;
    • failure with earlier verdicts keeps the score, and without them the audit is partial;
    • llm-verdicts, history, the route, audit-recheck and the report component.

Checked in the browser at 1024px, light and dark: the partial note on a report. The user approved the screen.

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)
  • Migration added (00430) and supabase/schema.sql rebuilt

Full checks on this branch (dc9a9ca): web and server suites, yarn build, format and lint all pass. Built on bf707cb; it merges cleanly with current main.

🤖 Generated with Claude Code

…eps its score (00430)

Site Audit judged its 13 AI signals again on every audit, with a preview
model and no temperature, so an unchanged page's score moved 2-3 points.
A failed AI call turned all 13 signals n/a and re-normalised the score
without saying so.

- Pin the model: the default is google/gemini-3.8-flash, a stable,
  versioned id, called at temperature 0 with a fixed seed. .env.example
  and the self-host env reference ask for a pinned id; an alias in
  AUDIT_LLM_MODEL logs a warning once.
- Keep every verdict in site_audit_llm_verdicts (00430, service role only)
  by the hash of the input its signal reads, the signal, the model and the
  prompt version. The signals read one of two views of the page: the
  opening (title and first 2,000 characters) or the text (first 8,000
  characters and word count), one call per view to judge. An unchanged
  page makes no AI call; a changed one is judged again only on the signals
  whose view changed. Verdicts no audit read for 180 days are pruned by
  the daily run.
- A failed call keeps the verdicts of the page's latest complete audit.
  With none, the audit is marked partial (site_audits.partial, 00430) and
  is kept out of the comparisons: the Pages list's score, previous score
  and trend, the hub trend, the report's change badge, the report
  snapshot and the Action Center's fix recheck. Its report says the AI
  checks couldn't run.
- Help: "Read a site audit report" gets "Same page, same score".

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

mintlify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit eb53f5a.

Approve preview

gkhngyk
gkhngyk previously approved these changes Nov 1, 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

@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 c042d3d into ansvisor:main Nov 1, 2026
6 checks passed
gkhngyk pushed a commit that referenced this pull request Nov 5, 2026
…mer priorities item 1) (#2131)

Customer priorities plan, item 1, part 2 (part 1: #1919). A Site Audit
score now shows its range, such as "64 ± 2". It's worked out from the
page's latest 5 complete audits: half the gap between the lowest and
highest score, in whole points, rounded up. It shows from 3 audits.
Partial audits aren't counted. The rule sits in SCORE_RANGE
(web/src/lib/audit/score-range.ts).

- Report: the gauge reads "64 ± 2", and a line beside it gives the
  lowest and highest score. GET /api/audits/:id sends the page's trend
  up to the audit (pageTrend) from the history it already reads, so
  there's no new query. findPreviousCompletedAudit and pageTrendUpTo
  share one walk of that history.
- Pages tab: "± 2" after the current score, from the row's trend, with
  the same sentence on hover and for screen readers.
- Pages export: a last column, score_range.
- Help: "Read a site audit report" gets "Score range"; the overview
  article mentions it on the Pages tab and in the export.
  approved-articles.json refreshed. docs/guides/site-audit.mdx updated.


Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

Co-authored-by: Claude <[email protected]>
gkhngyk pushed a commit that referenced this pull request Nov 6, 2026
… of the score (SA-010)

Site Audit spec §6.2, SA-010 (fixes F8): each of the 48 signals now carries
an evidence level from the spec's research (§3): Strong evidence, Likely
helps, or Hygiene / informational. llms.txt presence is informational: it is
still checked and shown, with a short evidence note, but it no longer counts
toward the Trust category or the total. The report shows the level in place
of the old high / medium / standard tier, and a Formula panel beside
Category breakdown publishes the category weights, how a category adds up
its signals, what each level means and what is left out of the score.

Rubric v1.2. The AI verdicts' prompt version stays "v1.1/2" rather than
following the rubric version, so every verdict kept by #1919 is read as
before and no page is judged again: only llms.txt's weight moves scores.

Help: Read a site audit report (levels, Formula, llms.txt, when the scoring
changes); the docs guide; a What's new entry for approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants