Skip to content

feat(action-center): judge a Site Audit fix by its pages audited again since it closed (learning A2) - #1689

Merged
gkhngyk merged 6 commits into
ansvisor:mainfrom
cihan-gyk:feature/outcome-audit-kinds
Oct 28, 2026
Merged

gkhngyk merged 6 commits into
ansvisor:mainfrom
cihan-gyk:feature/outcome-audit-kinds

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Learning phase A, A2: a Site Audit fix is judged by its pages audited again since it closed.

Stacked on #1688. This PR's own commit: 771bf92.

F01, F03 and F10 had no metric to measure, because their signals name none. So their result always read "could not be measured", and the audit's own answer was never asked: does the page pass now?

  • audit-recheck.js goes through each page target that names the checks that raised it (F03, F10…).
    • It reads the latest audit of the page since the action closed, by the address asked for or the one it ended at.
    • The page passes when every named check does. Validity's warn still fails, the same way the page check reads it.
    • A low-scored page (F01) passes once its score is past the line its signal is raised under.
    • The result is kept as validation.audit: { pages, audited, passed }.
  • In validate.js, a fix whose pages were audited again is judged by them: all or some passing reads improved, none reads no meaningful change. A4 (feat(action-center): read a result by the action's main metric, and say "mixed" when its metrics moved both ways (learning A4) #1690) makes "some" read mixed.
  • With no page audited again, the metrics judge, as before.
  • validateAction's four writes now go through one finish, which keeps the signals (A3) and the audit beside the metrics.
  • History's drawer says "Audited again since it closed: 1 of 2 pages pass.", or that none was audited again yet and the result comes from the metrics.

Follow-ups:

  • read targetIds too; today only the payload.targets sample is read (10 of 40 low-scored pages);
  • the audits query's limit(500);
  • na counts as passing, which is consistent with the detector, but an LLM check failing to na can read as fixed.

Where people see it: Action Center › History › a Site Audit fix › Result.

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

cd server && npx vitest run src/lib/action-center/audit-recheck.test.js src/lib/action-center/validate.test.js

Related issue

Agentic learning report (artifact; draft in the maintainers' notes), phase A: "measure correctly". No GitHub issue. Learning stays within one brand (product decision).

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Full checks at the top of the phase A stack (A5, 596dba6):

  • server format, lint and npm test (no SUPABASE_* env, as in CI): 3,359 tests passed. content-people.test.js timed out under load and passed alone (32/32).
  • web format, lint (0 errors; 7 warnings already on main), typecheck, vitest (444 files, 4,348 tests) and build: all pass.

A pre-push review of the six branches was run, and its before-merge findings are fixed in the stack (A4: 18e00bc, 5500708, c427343, cc1f9c8; A6: 381f5c6, 52a34fb; A5: 639c3a17). Only new measurements change. Actions already measured keep their result; there's no backfill.

🤖 Generated with Claude Code

cihan-gyk and others added 5 commits October 28, 2026 08:48
… measured result

Learning phase A, A3 (the agentic learning report, gaps 2 and 4). An
action's result compared its metrics before and after, but never asked
the question closest to its own aim: did the signals that raised it end?
Signals close as resolved (the condition gone) or resolved with
`supersededBy` (still there, as another kind), and that never reached
the outcome.

- validate.js: when an action is measured, signalOutcome reads its
  signals through action_signals and keeps the counts in
  `validation.signals`: total, ended, replaced, dismissed, open. An action
  with no metric to measure keeps them too (its validation was null). An
  action no signal raised (sent from Content, Insights…) has none.
- History's drawer says it under Result: "Of the 4 signals that raised it,
  when measured: 2 ended, 1 turned into another, 1 still open."
- The Action Center guide says so.

The outcome itself is unchanged; A4 decides what counts as improved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pages it names, brand-wide beside

Learning phase A, A1 (the report's gap 2). The night engine's actions
were measured on the whole brand's figures, so "recover 6 prompts" was
judged by every prompt the brand tracks, and a small real effect drowned
in the rest. Their targets are in the payload already.

- validate.js: an action whose payload's targetEntity is 'prompts' or
  'pages' (targetScope) is measured on those targets with the basket
  measure the actions sent from Content use: every target it counts
  (targetIds, else targets), prompt ids as uuids, a page written as a
  path read on the brand's primary domain. The metrics are its basket
  KPIs that the action names (all six when it names none). The brand-wide
  figures over the same windows are kept as `brandWide`, and
  `scope: { kind: 'targets', entity, prompts, pages }` says what it was.
- A basket that measured nothing (no answers in either window) leaves the
  action to the brand-wide measure, as before; so does any other target
  (competitors, sources…).
- History's drawer: "Measured on the 2 prompts it named." under Result, and
  "Brand-wide over the same days: Citations 100 → 104" under the cards.
- The guide says so.

Stacked on feature/outcome-signals-resolved (A3): both change
validateAction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n since it closed

Learning phase A, A2 (the report's gap 3). F01, F03 and F10 had no metric
to measure (their signals name none), so their result always read "could
not be measured", and the audit's own answer was never asked: does the
page pass now? (A1 already measures them on their pages' citations and AI
sessions, which rarely move in a week for a technical fix.)

- audit-recheck.js: for each page target that names the checks that
  raised it (F03, F10…), the latest audit of the page since the action
  closed, by the address asked for or ended at; it passes when every named
  check does (validity's warn still fails, as the page check reads it). A
  low-scored page (F01) passes once its score is past the line its signal
  is raised under. `{ pages, audited, passed }`, kept as validation.audit.
- validate.js: a fix with pages audited again is judged by them: all or
  some passing reads improved, none no meaningful change (A4 will say
  mixed for some). With none audited again, the metrics judge, as before.
  validateAction's four writes now go through one `finish`, which keeps
  the signals (A3) and the audit beside the metrics.
- History's drawer: "Audited again since it closed: 1 of 2 pages pass.",
  or that none was yet and the result is from the metrics.
- The guide says so.

Stacked on feature/outcome-target-basket (A1).

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

The A1 drawer test built its metrics with unit 'count', which
ActionResultMetric doesn't take: tsc failed on the test.

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

mintlify Bot commented Oct 28, 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 4572609.

Approve preview

@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.

Looks good, with follow-ups.

Own change. 771bf92 on top of #1688; f849a69 only merges #1688's test commit in, and re-merging its parents gives the same tree. Once #1688 is squashed, this PR's own change applies to main cleanly; GitHub will show conflicts until the branch takes main after that squash.

Checked

  • What passes. The detector raises an audit signal only on fail (detect.js, audits family), so reading pass, na and warn as gone matches what would raise it again; the json-ld-validity warn stays a failure, as the page check reads it. A check missing from audit_signal_results reads as not passing, which is the safe side. F01's line is total_score * 100 >= auditLowScore, the same scale and threshold record.js raises it under.
  • Matching pages. Targets and audits are both keyed with pageScope (no scheme, no www., no query or trailing slash), by url or final_url, and each page takes its newest completed audit after completed_at. Only fix definitions consume the audit signal kinds that carry checks, so no other action is judged this way.
  • One finish. All four write paths go through it; signals (A3) and the audit are kept beside the metrics, and the verdict falls back to the metrics' when no page was audited again. The sweep picks only pending_measurement actions, so an error in the new read leaves the action for the next night, as the other reads do.
  • Tests. On the stack's tree, audit-recheck.test.js and validate.test.js pass, and history-drawer.test.tsx passes (7). The same holds with #1687–#1689, #1698 and #1693 squashed onto main.

Follow-ups (besides the three you list)

  1. The verdict is read once. The sweep measures a fix once, the day after its week ends (validate.js:310), and writes it; it never comes back to it. A fix whose pages haven't been audited again by then is judged on metrics for good, even if the audit lands a day later. That happens whenever auto-audit is off, the run's fixed share is full, or a run falls just after the week (runs are up to 7 days apart). Suggest: while audit.audited === 0, return null (still pending) for up to a set number of days after the close (say 30, the same span #1698 re-audits within), and only then fall back to the metrics.
  2. "From the metrics" when there are none. auditNotYet (web/messages/en.json:2570) says "the result is from the metrics", but a fix with no metric reads "Not measurable" under it. Say "not audited again yet" and let outcomeExplain carry the rest, or pick the sentence by item.outcome.

Before the API deploy. Nothing shows. The drawer's audit line needs the deployed sweep's validation.audit; fixes measured before keep their result.

@gkhngyk
gkhngyk merged commit a1db520 into ansvisor:main Oct 28, 2026
5 of 6 checks passed
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…tion Center (learning D2) (#1709)

* feat(action-center): send a page from its Site Audit report to the Action Center as a Fix action

Learning D2. A Site Audit report showed what a page fails, but the only way
to the Action Center was the nightly pass, a day later and grouped with
other pages. A person can now send the page from its report at once.

- server from-audit.js: the audit read again within the brand (completed,
  its page and score), its failing checks (a fail, and a warning for
  JSON-LD validity only, as the page check reads them) with their names;
  one Fix action a page (dedup on the page), impact high below the
  low-score line, F01's plan, the page and its checks as its target (what
  an audit run again reads), measured on the page (basket kinds), scored
  as a site fix (priority sentByHand). 404 for another brand's audit, 409
  not completed or nothing to fix.
- POST /api/action-center/audits { brandId, auditId }.
- Web: "Send to Action Center" on the report's header once it fails a
  check, with a toast that opens the action (or the one already open);
  audit_page joins the action kinds ("Fix the issues Site Audit found on
  /path", "the page fails N checks"), its no-signals note in the drawer.
- Docs: the Site Audit and Action Center guides.

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

* feat(action-center): show the report, page and failing checks of an action sent from Site Audit

An audit_page action's drawer only said it had no detection signals, so the
person had to find the report again to see what to fix. Its Overview tab
now shows where it came from with a link to the audit report, the page, and
the checks it failed when sent, named by the labels Site Audit gave them.

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

* fix(action-center): refuse to send an older Site Audit report of a page audited since

A report stays open at its own URL after the page is audited again, and
sending it named the checks the page failed then, some of them maybe fixed
since. The server now looks for a later completed audit of the same page
(the Pages list's page key of final_url, else url) and refuses with 409
newer_audit and the latest audit's id; the report's toast says so and opens
the latest report.

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

* test(action-center): cover the route that sends a Site Audit report to the Action Center

POST /api/action-center/audits had no route test. It now pins what the
route lets through and how it answers: 400 for an invalid id, 403
not_in_workspace, 201 created and 200 already open, 404, and 409
nothing_to_fix, not_completed and newer_audit with the page's latest audit.

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

* docs(audit): place the report's Send to Action Center where the guide explains it

- Site Audit guide: the paragraph on sending one page moves from after the
  closing card into "How audits feed the Action Center". It says the action
  is judged like a nightly Site Audit fix, by the page audited again since
  it closed (learning A2, #1689, on main), and by its metrics until then.
- The report's section says what a second send does (a notice naming the
  open action with Open, not the action opened) and that only a page's
  latest report can be sent.
- Action Center guide: the two Site Audit rows of "Sending work to the
  Action Center" become one.

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

* test(action-center): pin F01's audit tasks, two sends at once and a not-applicable check for a Site Audit send

The test's brand had no Site Audit source, so F01's analyze_site_audit and
validate_technical_fix left the plan and the test, checking only that some
task was planned, didn't notice. Its brand now has its audits and the test
names the five tasks in order. It also covers two sends at once (the
insert refused by the open-action index returns the other send's action;
another refusal fails) and a check that is not applicable to the page,
which is neither sent nor enough to send.

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

* test(action-center): let the audits route test stub requireFeature, which the route file now uses

The Products route (#1642) guards itself with requireFeature, so the router doesn't load in a test whose plan-guard mock has none. The audits route test gets the same pass-through stub as the pages and content-drafts tests on main.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
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