Repository navigation
feat(action-center): measure whether a closed action helped - #820
Merged
Merged
Conversation
Phase 2 of #818. 00084 split `outcome` from `status` and left every row reading `pending_measurement`, because nothing re-read an action's metrics once it closed. `baseline` recorded the "before" — the triggering signals at the moment the action was raised — but there was no "after", so History's Result column could only report that nothing had been measured. A nightly sweep now supplies the second half. For each closed action it measures that action's own success metrics over a window ending before it was raised and an equal window after it closed, stores both halves, and derives the outcome from the comparison. Both reads go through the same daily rollup functions the KPI page reads, so an action's result and the dashboard summarising the same days cannot disagree. Deliberate limits. It does not claim causality: a before/after pair says the metrics moved, not that this action moved them, and the drawer says "measured after this action closed" rather than "because of it". It does not infer an outcome from task completion — ticking six boxes is evidence of effort, not of effect. A metric with no data in either window is reported as unmeasured rather than as zero, and an action whose rule named no success metric is reported as not measurable rather than judged against a metric it never claimed. Movement counts only past a noise band. These numbers drift week to week on their own; without a floor every outcome would be a verdict and none of them would mean anything. The after window must be over before it is read. Measuring one still in progress reads low because its later days have not happened — verified against live data, where an action closed four days ago measured zero citations for a window running three days into the future, which would have been filed as a decline. Applied to the hosted database. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj
33 of 37 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.
Phase 2 of #818.
Summary
#819 split
outcomefromstatusand left every row readingpending_measurement, because nothing re-read an action's metrics once it closed.baselinerecorded the "before" — the triggering signals at the moment the action was raised — but there was no "after", so History's Result column could only report that nothing had been measured.A nightly sweep now supplies the second half. For each closed action it measures that action's own success metrics over a window ending before it was raised and an equal window after it closed, stores both halves, and derives the outcome from the comparison.
Both reads go through the same daily rollup functions the KPI page reads, so an action's result and the dashboard summarising the same days cannot disagree.
ai_visibility_aggregates_daily→ the shared score functioninsights_aggregates_dailyshare_of_voice_aggregates_daily, percentage computed as Insights computes itWhat it will not claim
CompletedandDeclinedat once, which is the pair the whole loop exists to surface.not_measurablerather than judged against a metric it never claimed.A bug caught against live data
The after window must be over before it is read. Measuring one still in progress reads low because its later days have not happened yet.
The most recently closed action in production closed four days ago. Its after window runs three days into the future, and measured 0 citations against a before of 714 — which the first version of this would have filed as a decline. The sweep now refuses to measure until the window has elapsed, and a test pins it.
Display
The drawer's Result section was built in #815 for exactly this shape, so it mostly just fills in — but it had four fixed cards, two of which could never be measured. It now renders one card per metric the action actually claimed, as before → after with the delta, because a jump of seven means something different at a base of ten than at a base of a thousand. Time to close sits alongside. The table's Result column shows the top two, coloured by direction.
Related issue
Phase 2 of #818. Its exit condition — a completed action shows a measured before/after in History — is what this implements.
Type of change
feat— New featureDatabase
00085_action_validation— already applied to the hosted database. Addsactions.validation(jsonb) andactions.validated_at, plus a partial index so the sweep does not scan every action ever created. No data migrated; existing rows keeppending_measurementuntil the sweep reaches them.Deltas are derived at read time rather than stored, so a displayed change can never contradict the two values it came from.
How to test
The sweep runs inside the nightly tracking cycle, fire-and-forget after the rollups it reads are refreshed.
Completed/Not measured— no claim yet.CompletedwithNo meaningful change— the pair that proves completion and success are separate.Not measurable.Run from
server/:yarn test(438 passing),yarn lint,yarn format:check.Run from
web/:yarn test(216 passing),yarn lint,yarn typecheck,yarn format:check,yarn build.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdsupabase/schema.sqlregenerated withbash supabase/build-schema.shyarn lintpasses (run fromweb/) — 0 errorsyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)🤖 Generated with Claude Code
https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj