Skip to content

Add idempotency guard to prevent duplicate CREATED states in create_next_states task #246

@coderabbitai

Description

@coderabbitai

Problem

The create_next_states task in state-manager/app/tasks/create_next_states.py can create duplicate next states if the task is re-run or retried. This can happen due to task failures, retries, or other operational scenarios.

Proposed Solution

Implement an idempotency guard by:

  1. Computing a deterministic key (e.g., run_id + graph + next_identifier + canonicalized parents)
  2. Checking for existing states with that key before creating new ones
  3. Enforcing a unique index on that key at the database level

Context

This issue was identified during code review of PR #236 that introduces the bulk create_next_states functionality.

References:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions