Skip to content

feat(content): generate three opportunities per run instead of five to fifteen - #735

Merged
gkhngyk merged 1 commit into
mainfrom
feature/730-three-content-opportunities
Aug 18, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/730-three-content-opportunities

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The prompt asked for five to fifteen opportunities and the model reliably landed near ten — 9.9 to 10.6 per brand per night across ten days of production. That is more than anyone works through in a day, and because generation appends nightly, whatever goes unread accumulates: the open list already averages 147 rows per brand and reaches 773 on the largest.

Three per run. A short list that gets read beats a long one that gets scrolled past.

The instruction changed, not just the number

At ten the ranking barely mattered — the good findings arrived alongside the filler. At three there is no room for filler, so the rule now names what the slots are for:

Generate exactly 3 opportunities: the 3 highest-impact ones supported by the data provided, not the first 3 that come to mind. Weigh volume, the visibility gap and the competitor gap together when choosing which 3 to keep, and drop anything you would have ranked below them.

The prompt data reaching the model is already ordered by score, which is what "provided" refers to.

Why a shared constant rather than two edited numbers

The rule lived in two places:

  • server/src/lib/opportunity-generator.js — fired automatically after each tracking cycle
  • server/src/workers/content-worker.js — the queued run behind the Generate button

Each carried its own hand-written sentence and its own .max(20), and the two had already drifted in wording ("depending on data richness" in one, not the other). Editing two literals is how they drifted in the first place, so both now import one constant. The button and the nightly run cannot disagree about how many a brand gets.

opportunity-limits.test.js fails if a literal ceiling or a hand-written count sentence is written back into either generator. That is the regression worth pinning — the numbers agreeing today says nothing about them agreeing after the next edit.

What this does not fix

Accumulation. Three a night is still ninety a month, and the two paths write differently: the automatic one appends, skipping only rows whose prompt_id and title match an existing new row exactly, while the manual one deletes every new row before inserting. So a manual Generate replaces the list and the nightly run grows it.

Reducing the count slows that down; it does not settle it. Whether the nightly run should replace, expire, or genuinely deduplicate is a separate decision and deliberately not made here. #731, now merged, at least makes the backlog clearable.

Related issue

Closes #730

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

  1. Trigger a manual generation from the Content page for a brand with a rich tracking history and confirm exactly three opportunities come back.
  2. Confirm the three are distinct recommendations rather than one idea in three wordings.
  3. Run a tracking cycle for a brand on a plan with content optimization and confirm the automatic path produces the same count as the button.
  4. Confirm a brand with very little data still produces a sensible result rather than failing schema validation — the floor is still one.
  5. Spot-check that the three chosen relate to high-volume or high-gap prompts rather than arbitrary ones.

Checklist

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

Server suite passes: 287 tests, including 6 new ones. No web/ files are touched.

…o fifteen

The prompt asked for five to fifteen and the model reliably landed near ten:
across ten days of production it produced 9.9 to 10.6 per brand per night.
That is more than anyone works through in a day, and generation appends, so
whatever goes unread accumulates — the open list already averages 147 rows per
brand and reaches 773 on the largest. A short list that gets read beats a long
one that gets scrolled past.

Three changes the instruction as well as the number. At ten the ranking barely
mattered because the good findings arrived alongside the filler; at three there
is no room for filler, so the rule now says the slots go to the highest-impact
opportunities the data supports rather than to whichever the model composes
first. The prompt data reaching the model is already score-ordered.

The rule was written twice — once in the generator fired after each tracking
cycle, once in the queued generator behind the Generate button — as a
hand-written sentence and a schema ceiling apiece, and the two had already
drifted in wording. Both now read one shared constant, so the button and the
nightly run cannot disagree about how many a brand gets. Tests fail if a
literal is written back into either file.

This does not address the accumulation itself: three a night still adds ninety
a month, and the automatic path appends while the manual path replaces. That
asymmetry needs its own decision.

Closes #730
@gkhngyk
gkhngyk merged commit 00597f9 into main Aug 18, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the feature/730-three-content-opportunities branch August 18, 2026 18:29
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.

Content: generate three opportunities per run instead of five to fifteen

1 participant