Skip to content

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

Merged
Bharath-code merged 2 commits into
mainfrom
feat/p4-merge-daily-pipelines
Jul 12, 2026
Merged

feat(trigger): P4 — merge duplicate daily pipelines, deterministic scheduling#11
Bharath-code merged 2 commits into
mainfrom
feat/p4-merge-daily-pipelines

Conversation

@Bharath-code

Copy link
Copy Markdown
Owner

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 on main (which already has P3b).

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.

Verification

  • npm run verify green: typecheck clean, 489 tests pass, production build succeeds.

🤖 Generated with Claude Code

@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.

@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 8:03am

Bharath-code and others added 2 commits July 12, 2026 13:31
…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]>
@Bharath-code Bharath-code force-pushed the feat/p4-merge-daily-pipelines branch from 986562f to b38e587 Compare July 12, 2026 08:02
@Bharath-code Bharath-code merged commit 16ea072 into main Jul 12, 2026
8 of 9 checks passed
@Bharath-code Bharath-code deleted the feat/p4-merge-daily-pipelines branch July 12, 2026 09:31
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