Skip to content

fix(mothership): close the scheduled-job review gaps - #9345

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/scheduled-jobs-review-findings
Oct 23, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/scheduled-jobs-review-findings

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Fixes the review findings on the v0.9.33 release PR (#9339) that hold up, all in the scheduled-jobs lane from #9331. Findings that are not defects are answered on their threads.

  • Dispatch race: dispatch takes a per-occurrence lock, so a tick's attempt and the reconciler's can't overlap; one could otherwise close the record as skipped or blocked while the other admitted the turn, leaving a live run outside the deadline and finalize checks.
  • Run number: each occurrence's run number is fixed on its record at claim, so a retried dispatch is briefed "Run 1", not the job's count after a later claim.
  • Auto-disable email: a failure reports "turned off after failures" only when it turned an active job off, not when a person had already turned it off.
  • Deadline stop: the stop mark is written after the Stop is delivered, so a crash in between delivers it again (both steps are idempotent).
  • Spend cap in the brief: the run's dollar cap is stated only where hosted billing enforces it.
  • Migration 0437: an invalid index left by an interrupted concurrent build is moved aside and rebuilt on replay, as 0435 does, instead of being kept by IF NOT EXISTS. 0437 has not reached main.
  • PlanUsageLimitDisplay gets a props interface.

Type of Change

  • Bug fix

Testing

  • lane.integration.ts against real Postgres and Redis, provisioned through the versioned migrations (INTEGRATION_DB_PROVISION=migrate bun run test:integration lane.integration): 18 pass. The three new tests (manual turn-off sends no auto-disable email, a retried occurrence keeps its run number, a held dispatch lock leaves the occurrence alone) fail on the pre-fix code; the streak test now also asserts the email is sent exactly once.
  • Job unit tests pass, tsc --noEmit is clean, check:migrations passes.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

- dispatch one attempt at a time per occurrence, so a skip or block never closes a live run's record
- brief each occurrence with the run number fixed at its claim, not the job's moving count
- report an automatic turn-off only when this failure turned the job off, not one a person already turned off
- mark a deadline stop after it is delivered, so a crash before then delivers it again
- state the run's spend cap only where hosted billing enforces it
- recover an invalid index left by an interrupted build in the job migration, as 0435 does
- give PlanUsageLimitDisplay a props interface
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 23, 2026 8:36pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/jobs/reconcile.ts
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

This PR closes scheduled-job review gaps:

  • Only one attempt at a time dispatches each scheduled occurrence.
  • The reconciler retries time-limit Stops until delivery finishes.
  • Each job brief keeps its run number and spend cap tied to the occurrence.
  • Failure notices go only to jobs the failure turns off.
  • Scheduled-job indexes can be rebuilt after an interrupted migration.
  • The plan usage limit card has a named props type.

The latest changes separate a requested deadline Stop from completed delivery. They retry unfinished delivery before finalizing, addressing the previous unnumbered finding. No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read open job occurrence] --> B{Stop requested but not delivered?}
  B -->|Yes| C[Deliver Stop to the original run]
  B -->|No| D{Live run past deadline?}
  D -->|Yes| E[Record Stop request]
  E --> C
  C --> F[Record completed delivery]
  D -->|No| G{Run ended?}
  F --> G
  G -->|Yes| H[Finalize occurrence]
  G -->|No| I[Check again next pass]
Loading

Reviews (2) · Last reviewed commit: "fix(mothership): record why a run stops ..." · Reviewed by Greptile

Comment thread apps/sim/lib/mothership/jobs/reconcile.ts Outdated
…nd redeliver one an earlier pass did not finish
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 2fc2008 into staging Oct 23, 2026
67 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/scheduled-jobs-review-findings branch October 23, 2026 21:17

This branch was previously deployed

1 inactive deployment
Preview — 37b4326a Deployed Oct 23, 2026 by vercel[bot]
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