Skip to content

fix(action-center): give a new brand its first actions after its first run - #844

Merged
gkhngyk merged 1 commit into
mainfrom
fix/first-signal-pass-after-onboarding
Sep 27, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/first-signal-pass-after-onboarding

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Summary

A new brand opened an empty Action Center and stayed that way until the next night. This had two causes, and fixing either one alone would not have been enough.

1. No pass after the first run. Signal passes run only after a nightly (cron) run. A brand's first run is started by onboarding or by the payment success route as an immediate (manual) run, so its first pass waited for the next night. Now, when an immediate full run stamps, runFirstSignalPass runs a pass for a brand that has never had one, recorded against that manual run. Later manual runs still do not trigger passes. The nightly pass and the catch-up sweep still read only nightly runs.

2. That pass would have found nothing. The library's detectors judged a prompt only after it had 3 days of results in the window. A first run is one day, even though it answers every prompt on every platform. A read-only check on a brand created today: 25 prompts, 6 answers each, the brand is absent from all of them, and the detectors raised 0 signals.

ae_prompt_stats and ae_competitor_prompt_stats now also return cur_answers. A prompt counts as tracked on 3 days or 5 answers, whichever comes first (promptMinAnswers). Answers only accumulate inside the window, so a prompt that qualifies on day one still qualifies on day two. The signals it raises do not flap closed while the day count catches up. On the same brand, the new rule finds 23 prompts with demand and no visibility across 5 topics, plus 2 unmapped prompts.

Both RPC changes are additive (a new field in a jsonb result). Code that does not read the field is unaffected, so the migration and the deploy can land in either order.

Related issue

Follow-up to #839 · tracking #818

Type of change

  • fix — Bug fix

How to test

  • cd server && npx vitest run → 854 passing. New tests cover runFirstSignalPass (runs once, reads any source, is a no-op after the first pass, leaves the nightly pass on cron runs only) and the answer-count rule in isTracked / classifyPrompt.
  • After deploy: create a brand and let its first tracking run finish. A signal_runs row should appear for it within a minute of the run stamping, and the Action Center should show its first actions.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • Changes are focused — one concern per PR

🤖 Generated with Claude Code

…t run

Signal passes rode only the nightly run, and a brand's first run is a
manual one, so a new brand's Action Center stayed empty until the next
night. Its first stamped run now gets a pass of its own; later manual runs
still do not.

That pass alone found nothing: the library judged a prompt only after three
days of results, and a first run is one day across every platform. Prompt
and competitor stats now carry an answer count, and a prompt answered
enough times counts as tracked whatever the days.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Sep 27, 2026
@gkhngyk
gkhngyk merged commit 55862cc into main Sep 27, 2026
6 checks passed
@gkhngyk
gkhngyk deleted the fix/first-signal-pass-after-onboarding branch September 27, 2026 13:37
@gkhngyk gkhngyk mentioned this pull request Oct 2, 2026
33 of 37 tasks
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.

1 participant