Repository navigation
fix(content): stop opportunities piling up on the same prompts - #869
Merged
Merged
Conversation
The nightly generator ranks prompts by a deterministic score, so the same top prompts won every night and collected rewordings of one idea: one prompt held 38 open opportunities across 32 nights, while 628 of the brand's 709 prompts had none. Only exact-title repeats were caught. - Prompts with 3 or more open opportunities (MAX_OPEN_PER_PROMPT) are skipped before the top-25 cut, so the slots go to the next prompts. - The remaining candidates list their open titles as "Already suggested", and the instructions forbid repeating or rewording them. - An out-of-range relatedPromptIndex now drops the opportunity in both generators instead of attaching it to the top candidate. - Open opportunities are read in pages, past PostgREST's 1,000-row cap. The Generate button path replaces a brand's open opportunities rather than appending, so it needs only the index fix. Closes #837
This was referenced Oct 2, 2026
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
Closes #837.
The nightly content-opportunity generator ranks prompts by a deterministic score (volume, visibility gap and competitor gap), so the same top prompts won every night. Only exact-title repeats were filtered, and the model rewords the same idea each run. As a result, on the largest brand:
None of the earlier generator fixes addressed this: #735 (three per run), #442 (index leak), #369/#640 (brand language) and #63 (preserve pending).
Changes
MAX_OPEN_PER_PROMPT(3) or more open opportunities are dropped before the top-25 cut, so the run's slots go to the next prompts down. On the largest brand today 58 prompts are at the cap and 651 stay eligible, 628 of them with no opportunity yet.relatedPromptIndexused to fall back to the top candidate, the most crowded prompt. It now discards the opportunity in both generators.openCountsByPrompt,belowOpenCapandrelatedCandidatelive inopportunity-limits.jsnext to the existing shared count rule, and both generators import them.Generate button path.
content-worker.jsdeletes a brand's open (new) opportunities before inserting the new ones, so it replaces the list rather than appending to it. The cap and the already-suggested list would have nothing to act on there, so that path gets only the index fix. The issue also proposed adding the exact-title check to it; that check would have nothing to compare against, since the list is cleared first.Not in this PR. The existing backlog of open opportunities stays as it is. This change stops new pile-up; clearing what already accumulated is a separate data decision. #857 later replaces the per-prompt cap with per-cluster generation.
Related issue
Closes #837
Type of change
How to test
|| scored[0]fallback, and that the nightly generator applies the cap and the "Already suggested" list.Checklist
yarn lint,yarn format:checkandyarn test(883 passed, 6 new) pass fromserver/🤖 Generated with Claude Code