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

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #2310, addressing this CodeRabbit finding: #2310 (review)

restartInvestigation guarded its UPDATE on any restartable status, not the one it read. A resolve landing between the read and the update was silently overwritten. The UPDATE now also requires status = existing.status (the unclaimed investigating guard stays), so the race returns the existing InvestigationTransitionError 409 ("changed while restarting").

New PGlite test wraps Database to run a resolve right after the restart's read, then asserts the 409, the row still resolved, and no turn sent.

Without the fix the test fails (the restart succeeds and the row is back to investigating):

 FAIL  src/services/errors/InvestigationService.test.ts > InvestigationService > refuses a restart when the run was resolved after the restart read it
      Tests  1 failed | 26 skipped (27)

With the fix:

 Test Files  1 passed (1)
      Tests  27 passed (27)

packages/backend typecheck and oxlint -c .oxlintrc.effect.json on both files are clean.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

A resolve that lands between the restart's read and its update now
returns the 409 instead of being overwritten.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: de4b5f06-a69d-406f-887b-a08019243763
Commits

Reviewing files that changed from the base of the PR and between a86d988 and eba5480.

Files selected for processing: 2

  • packages/backend/src/services/errors/InvestigationService.test.ts
  • packages/backend/src/services/errors/InvestigationService.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@maple-review-bot

maple-review-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Maple review

🟢 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

eba5480 · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@Makisuo
Makisuo merged commit 3af37dc into main Nov 6, 2026
33 checks passed
@Makisuo
Makisuo deleted the fix/investigation-restart-guard branch November 6, 2026 20:03
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