Repository navigation
fix(audit): run one audit per page at a time, so the same page never costs twice (00431) - #1920
Merged
Merged
Conversation
…costs twice (00431) Two requests for one page at once started two audits and used two credits, and /pricing, /pricing/ and /pricing?utm= were three pages with three credits. Nothing in the database stopped it. - Server: every start (Site Audit page, Re-audit, AI Traffic, bulk, auto-audit, Chat, MCP) goes through one path that keys the page by its normalized address (pageKey). A page with an audit running gets that audit back with no new credit; the quota is checked only for the pages started. A run older than two hours (cut short by a restart) is marked failed first so it doesn't hold its page. - 00431: site_audits.page_key, filled for the audits kept, and a partial unique index (brand_id, page_key) where status = 'running', so two requests that race can't both start; the loser gets the running audit. - A page audited in the last 10 minutes isn't started unless force: POST /api/audits and the internal endpoint answer 409 recently_audited with that audit, and bulk lists such pages in `recent`. - Web: one page asks "Audited N min ago. Open it or audit again?" (Site Audit page, report re-run, AI Traffic card); several pages say which weren't started, with Audit again. Chat's run_site_audit, the MCP tool, the in-app agent and the REST route take `force` and say the recent audit back so the model asks first. - Help: "Run a site audit" gets "Auditing a page again". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
8 of 13 tasks
# Conflicts: # server/src/routes/audits-pages.test.js # supabase/schema.sql # web/messages/en.json
8 of 13 tasks
This was referenced Nov 1, 2026
gkhngyk
pushed a commit
that referenced
this pull request
Nov 2, 2026
…iewer (#1964) The MCP tools changed in #1920, #1927 and #1916; the skills and the MCP guide still described the old answers. - get_ai_traffic / GET /ai-traffic: `tracking` (not_detected, installed_quiet, active); a 0 with not_detected means nothing is measured yet. Coach skills (MCP + REST), mcp-server.mdx and api-reference/metrics.mdx (GET /api/v1/ai-traffic returns it too). - run_site_audit / POST /site-audits: a running page's audit comes back with alreadyRunning and no credit; a page audited in the last 10 minutes returns recently_audited and starts nothing unless force. Coach skills, audit-fix (Chat) and mcp-server.mdx; library.json refreshed. - get_content_draft_package: the qualified reviewer (reviewer) and its WebPage reviewedBy JSON-LD once the page names them. mcp-server.mdx. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two requests for the same page could each start an Site Audit and each use a credit. This happened with two clicks, or with
/pricing,/pricing/and/pricing?utm=…one after another, and we measured it: three spellings used three credits. Now one audit runs per page at a time, and a page audited in the last 10 minutes asks before it runs again. Customer priorities plan, P0 item 3.What changes
pageKey: host without www, lowercased, path without a trailing slash, no query or fragment.runningrow older than 2 hours (cut short by a restart) is markedfailedfirst, so it doesn't hold the page.site_audits.page_keyand fills it for existing rows;(brand_id, page_key) where status = 'running', so a racing request loses and gets the running audit back;recently_auditedwithrecent: { auditId, finishedAt }. The page asks "Audited N min ago. Open it or audit again?", and Audit again sendsforce: true.recent, and a toast offers Audit again.run_site_auditand the MCP tool takeforceand tell the model, so it asks the person first.For @gkhngyk:
forceparameter; a skills docs PR follows.fix/audit-stable-ai-verdicts(fix(audit): keep each AI verdict by its input so an unchanged page keeps its score (00430) #1919) also touchesroutes/audits.jsandaudits-pages.test.js, so the second to merge will have small conflicts. Its mock assumesevaluateLlmSignalsreturns an array, while fix(audit): keep each AI verdict by its input so an unchanged page keeps its score (00430) #1919 returns{ results, partial }. The tests aren't affected, because the job doesn't complete.Related issue
None. Customer priorities plan, P0 item 3 (no double credit).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
/pricing, then right away/pricing/and/pricing?utm=x. One audit runs, and one credit is used when it completes./pricingagain. It asks "Open it or audit again?", and Audit again runs a new one.forceor 10 minutes later starts a new one;Checklist
yarn lintpasses (0 errors; 7 old warnings in files this PR doesn't touch)yarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)supabase/schema.sqlrebuiltFull checks on this branch (a1d34d0, from 1220a2b): web 801 files / 8,346 tests pass, and
yarn buildpasses. Serverformat:checkand lint are clean, and 352 files / 4,995 tests pass (3 skipped).🤖 Generated with Claude Code