Repository navigation
feat(audit): re-audit first the pages fixed through the Action Center, on the brand's own domains (learning B7) - #1698
Merged
Conversation
…its fix is completed Learning B7. A page an Action Center fix was completed on waited out the auto-audit's 30-day rest like any other, since its last audit was the one that found the issue, so whether the fix took was read a month late, if at all. - fixedPages: the pages named by fix-category actions completed in the last 30 days (their targets' addresses, deleted actions left out, the newest fix first) that no audit has read since the fix. - pickRunPages takes them first, up to half the run's slots (rounded up), past the 30-day rest and the tried-lately list; a page being audited is left. The rest of the run is the inboxes', as before. A read that fails leaves the run as it was. - The Site Audit guide says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A fix action's targets were taken whenever they were http(s) addresses, so a competitor's page or any other site named by a fix could be audited at the org's cost. fixedPages now reads brand_domains for the run's brands in one query and keeps a target only when it is on its action's brand's domains or a subdomain of one (onBrandDomain); a brand without a domain offers none. With no fix completed lately, nothing more is read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Site Audit guide says excluded pages stay out of Opportunities and auto-audits, but a fixed page skipped both of the inbox's filters. fixedPages now reads site_audit_page_prefs (every row, past PostgREST's 1000-row page) and site_audit_brand_settings for the run's brands, and leaves out a page the brand excluded, or one under its exclude patterns unless pinned, as the inbox does. Prefs and patterns are the action's own brand's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… pages fixedPages keyed its pages and their last audits by the page alone, so when two brands of an org share a domain one brand's audit counted for the other's fix, and one brand's fix hid the other's (the action's result, A2, reads only its own brand's audits). Pages, prefs and audits are now keyed by the brand's page (runPageKey, `brandId|key`), the audits read with their brand. pickRunPages keys its taken and running sets the same way, so one brand's fixed page neither takes nor skips another brand's inbox row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…xed pages The audits since the oldest fix were read in one request, without an order, so past PostgREST's 1000 rows the rest were dropped without an error and a page audited since its fix could be taken again. They are now read through readAllRpcRows, ordered by created_at and id, a slice at a time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d ones FIXED_PER_ACTION (20) cut a fix's targets before the pages audited since the fix (and the excluded ones) were left out, so a fix of 25 pages whose first five were audited offered 15, not 20. The cap now counts only the pages still due, each counted for its newest fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Site Audit guide said fixed pages take "up to half its pages"; they take up to about half the run, rounded up, and only pages of the brand's own site. The headers of auto-audit.js and auto-audit-sweep.js now name the fixed pages a run takes first, and the comments say "not audited or tried since": any audit of the brand's counts, finished or not. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ariants and rounding - A fixedPages read that fails leaves the run to the inboxes, as before. - An audit counts for a fixed page by the address it ended at (final_url). - www, a trailing slash, http or https, a query or a fragment name the same page, both among a fix's targets and in the audits since. - A five-page run gives fixed pages three slots: half, rounded up. 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 |
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good.
Own change. b8f706d through 62b0ccf on 3f6a4d4. Server and docs only. It merges cleanly on main (b591947), and with #1687–#1689 squashed before it. No code depends on #1689; as you say, merge it after #1689 so the guide's "so the action's result says whether the fix took" is true when it ships.
Checked
- Which pages. Completed, non-deleted
fixactions of the run's own brands from the last 30 days; theirtargets[].idand http(s)targetIds; kept to the action's brand's domains withonBrandDomain(a brand with no domain gives none); excluded pages and exclude patterns left out unless pinned, as the inbox does. Keys arebrandId|page, so two brands on one domain don't close each other's pages. - When a page drops out. Any audit of the brand's created since the fix (finished or not, by
urlorfinal_url) takes it out, so a page that fails to audit isn't retried every run. The audits are read in pages, ordered bycreated_atandid, so the 1,000-row cut doesn't hide one. - The run. Fixed pages take at most half the slots, rounded up, then the inbox fills the rest as before; a page in both is taken once; a page being audited now is skipped. A failed read of fixed pages leaves the run to the inbox. Nothing is spent beyond the auto-audit's existing quota.
- Tests. On this PR's tree,
src/lib/auditpasses (16 files, 199 tests). With main'sauto-audit.jsandauto-audit-sweep.jsput back, 13 of the two files' tests fail.
Before the API deploy. Nothing changes; the sweep is server-only. The guide's new sentence goes out with the docs before the API does.
9 of 12 tasks
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
Learning B7: a page fixed through the Action Center is re-audited first in the next auto-audit run.
A fix's result needs the fixed page audited again (A2, #1689). Until now, the auto-audit run took pages only from its inbox, so a fixed page could wait up to a month.
fixedPages(brands, now)(auto-audit-sweep.js) collects pages to re-audit:category = 'fix'actions completed in the last 30 days (payload.targets[].idand http(s)targetIds). Deleted actions are left out.brand_domains+onBrandDomain); a brand with no domain gives none. Site Audit accepts any address, so a competitor page someone audited for comparison could otherwise have been re-audited on the customer's quota.site_audit_page_prefsmarked excluded, andsite_audit_brand_settings.exclude_patternsunless the page is pinned. The guide says excluded pages stay out of auto-audits.urlorfinal_url). The audits are read in pages (readAllRpcRows), so nothing is cut at 1,000 rows.brand|page, so brands that share a domain don't close each other's fixes.pickRunPages(…, fixed)(auto-audit.js):Cost: within the auto-audit's existing quota. Nothing new is spent; only the order changes. Ended plans don't run auto-audits (#1608).
Pre-push review fixes:
final_url, address variants (www, trailing slash, http/https, query, #) and rounding.Merge after #1689 (A2): the guide's sentence "so the action's result says whether the fix took" is true only once A2 judges a fix by its re-audited pages.
Where people see it:
No new button.
Related issue
Agentic learning report, phase B (B7). No GitHub issue.
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
cd server && npx vitest run src/lib/audit/auto-audit.test.js src/lib/audit/auto-audit-sweep.test.jsThe tests cover:
The original query was run read-only against the dev database.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Server checks at 62b0ccf:
npm test(noSUPABASE_*env, as in CI): 3,350 tests passed;content-agent.test.js' timing test ran over under load and passed alone.The web is unchanged (docs only). The first commit uses the scope
site-audit; the rest useaudit, the repo's usual scope.🤖 Generated with Claude Code