feat(trigger): P4 — merge duplicate daily pipelines, deterministic scheduling#11
Merged
Merged
Conversation
|
Kilo Code Review could not run — your account is out of credits. Add credits or switch to a free model to enable reviews on this change. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…heduling Two independent 6am UTC crons were doing separate competitor fetches and separate sequential work loops (dailyPricingAnalysis for structured pricing, dailyAnalysis for full-page vision analysis). Merged into one entrypoint: - Extracted the vision-analysis body into visionAnalysisContext, a plain child task (mirrors checkPricingContext's pattern). - dailyPricingAnalysis is now the sole 6am cron; it fires visionAnalysisContext once per competitor (not per pricing-context) inside the loop it already runs, instead of a second competitor fetch. - dailyAnalysis.ts kept but slimmed — userSchedules.ts / /api/schedule still attach PRO (6h) / ENTERPRISE (hourly) custom cadences to its task id, so deleting it would have broken that live feature. It now just loops active competitors and calls visionAnalysisContext.trigger(), no duplicated logic. - Replaced shouldCheckContext's Math.random() frequency-decay coin flip with stableFraction(): sha256(competitorId:contextId:date) mapped to [0,1). Same seed -> same result (deterministic, testable), while the date component still rotates which competitors get skipped day to day. Verified: npm run verify green (typecheck, 489 tests, build). Co-Authored-By: Claude Fable 5 <[email protected]>
986562f to
b38e587
Compare
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.
Reopen of #10 — GitHub auto-closed #10 when I deleted its stacked base branch (
feat/p3b-playwright-exit) on merging #9. Same commits, now based directly onmain(which already has P3b).Completes P4 of
docs/FIRECRAWL_CONSOLIDATION.md: merges the two duplicate 6am UTC daily cron pipelines.What changed
dailyPricingAnalysisis now the sole 6am cron entrypoint. It already loops every competitor for pricing-context checks; it now also fires the extractedvisionAnalysisContextchild task once per competitor (not per pricing-context) instead of a second full competitor fetch + separate cron firing at the identical time of day.visionAnalysisContext.ts(new) — the full-page vision-analysis body (screenshot → Gemini → hash-compare → R2 upload →analyses/alertsinsert) extracted out of the olddailyAnalysis.ts, as a plain child task mirroringcheckPricingContext's existing pattern.dailyAnalysis.tskept, slimmed — not deleted.userSchedules.ts//api/scheduleattach live PRO (6h) / ENTERPRISE (hourly) custom cadences to this task's id viaschedules.create(); deleting it would have silently broken that feature. It's now a thin loop that callsvisionAnalysisContext.trigger()per competitor — no duplicated business logic left.shouldCheckContext's frequency-decay coin flip usedMath.random(), making it untestable. Replaced withstableFraction(): sha256 ofcompetitorId:contextId:datemapped to [0,1). Same seed → same result (deterministic per day, directly testable), while the date component still rotates which competitors get skipped day to day.Verification
npm run verifygreen: typecheck clean, 489 tests pass, production build succeeds.🤖 Generated with Claude Code