Skip to content

feat(trigger): P4 — merge duplicate daily pipelines, deterministic scheduling#10

Closed
Bharath-code wants to merge 1 commit into
feat/p3b-playwright-exitfrom
feat/p4-merge-daily-pipelines
Closed

feat(trigger): P4 — merge duplicate daily pipelines, deterministic scheduling#10
Bharath-code wants to merge 1 commit into
feat/p3b-playwright-exitfrom
feat/p4-merge-daily-pipelines

Conversation

@Bharath-code

Copy link
Copy Markdown
Owner

Stacked on #9 (P3b) — this branch includes P3b's commits since visionAnalysisContext depends on the Firecrawl-based captureScreenshot(). Merge #9 first, then this will show a clean diff against main.

Completes P4 of docs/FIRECRAWL_CONSOLIDATION.md: merges the two duplicate 6am UTC daily cron pipelines.

What changed

  • dailyPricingAnalysis is now the sole 6am cron entrypoint. It already loops every competitor for pricing-context checks; it now also fires the extracted visionAnalysisContext child 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/alerts insert) extracted out of the old dailyAnalysis.ts, as a plain child task mirroring checkPricingContext's existing pattern.
  • dailyAnalysis.ts kept, slimmed — not deleted. userSchedules.ts / /api/schedule attach live PRO (6h) / ENTERPRISE (hourly) custom cadences to this task's id via schedules.create(); deleting it would have silently broken that feature. It's now a thin loop that calls visionAnalysisContext.trigger() per competitor — no duplicated business logic left.
  • Deterministic schedulingshouldCheckContext's frequency-decay coin flip used Math.random(), making it untestable. Replaced with stableFraction(): sha256 of competitorId:contextId:date mapped 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 — same intended behavior, now reproducible.

Verification

  • npm run verify green: typecheck clean, 489 tests pass (18 new/rewritten across the 4 touched trigger test files), production build succeeds.

🤖 Generated with Claude Code

…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]>
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rivaleye Ready Ready Preview, Comment Jul 12, 2026 2:38am

@kilo-code-bot

kilo-code-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

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.

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.

1 participant