fix(mothership): close the scheduled-job review gaps
Merged
WA
6d ago+215+215+012345678901234567890123456789-31-31-01234567890123456789
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 reachedmain. PlanUsageLimitDisplaygets a props interface.
Type of Change
- Bug fix
Testing
lane.integration.tsagainst 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 --noEmitis clean,check:migrationspasses.
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)