Skip to content

fix(investigations): restart only from the status it read - #2321

Merged
Makisuo merged 1 commit into
mainfrom
fix/investigation-restart-guard
Nov 6, 2026
Merged

Makisuo merged 1 commit into
mainfrom
fix/investigation-restart-guard

fix(investigations): restart only from the status it read

eba5480
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 6, 2026 in 34s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge. A two-line guard on status = existing.status, matching the documented "guard on the state it was decided from" rule, pinned by a test that fails without it.
no findings · tests covered · risk high

restartInvestigation's UPDATE now also requires the status it read, so a resolve landing between the read and the write is a 409 instead of being overwritten. The added PGlite test lands exactly that write and pins the 409, the unchanged row and the unsent turn.

  • restartInvestigation UPDATE guards on status = existing.status
  • New test wraps Database to run a resolve between the restart's read and its update
What was checked
  • existing.status is the post-sweep status from getInvestigation (InvestigationService.ts:618), and failed stays restartable, so a swept run still restarts
  • resolved is in RESTARTABLE_INVESTIGATION_STATUSES (packages/domain/src/http/investigations.ts:66), so the new equality blocks only the concurrent change
  • The orphan claim path (startedAt null) still passes: the equality holds on investigating and the startedAt IS NULL branch decides

eba5480 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.