Skip to content

World's first open-source, agentic video production system. 12 production pipelines, 100+ tools, 700+ agent skill and production-knowledge files. Turn your AI coding assistant into a full video production studio.

fix(checkpoint): scope resume to recorded pipeline identity (#702)

Rudy Mizrahi Celeklib137959cce14
diff --git a/lib/checkpoint.py b/lib/checkpoint.py
index f0cc4b99..23e4b228 100644
--- a/lib/checkpoint.py
+++ b/lib/checkpoint.py
@@ -605,14 +605,18 @@ def get_completed_stages(
"""Return list of stages that have a completed checkpoint.
When pipeline_type is provided, only checks stages defined in that
- pipeline's manifest — preventing false positives from leftover
- checkpoints of a different pipeline type.
+ pipeline's manifest and requires their recorded pipeline_type to match —
+ preventing false positives from a previous pipeline's shared stages.
"""
stages_to_check = get_pipeline_stages(pipeline_type)
completed = []
for stage in stages_to_check:
cp = read_checkpoint(pipeline_dir, project_id, stage)
- if cp and cp.get("status") == "completed":
+ if (
+ cp
+ and cp.get("status") == "completed"
+ and (pipeline_type is None or cp.get("pipeline_type") == pipeline_type)
+ ):
completed.append(stage)
return completed
diff --git a/tests/lib/test_checkpoint_resume_identity.py b/tests/lib/test_checkpoint_resume_identity.py
new file mode 100644
index 00000000..99cab58e
--- /dev/null
+++ b/tests/lib/test_checkpoint_resume_identity.py
@@ -0,0 +1,39 @@
+"""A pipeline switch must not reuse another pipeline's completed work."""
+
+from lib.checkpoint import get_completed_stages, get_next_stage, write_checkpoint
+from tests.contracts.test_phase0_contracts import sample_artifact
+
+
+def test_pipeline_switch_restarts_shared_stage(tmp_path):
+ # Both real manifests begin with research, but its completion belongs to
+ # the old cinematic run, not the new framework-smoke run.
+ write_checkpoint(
+ tmp_path, "film", "research", "completed",
+ {"research_brief": sample_artifact("research_brief")},
+ pipeline_type="cinematic", human_approved=True,
+ )
+
+ assert get_completed_stages(tmp_path, "film", "framework-smoke") == []
+ assert get_next_stage(tmp_path, "film", "framework-smoke") == "research"
+
+
+def test_matching_pipeline_completion_is_retained(tmp_path):
+ write_checkpoint(
+ tmp_path, "film", "research", "completed",
+ {"research_brief": sample_artifact("research_brief")},
+ pipeline_type="framework-smoke", human_approved=True,
+ )
+
+ assert get_completed_stages(tmp_path, "film", "framework-smoke") == ["research"]
+ assert get_next_stage(tmp_path, "film", "framework-smoke") == "script"
+
+
+def test_unscoped_legacy_resume_still_accepts_completion(tmp_path):
+ write_checkpoint(
+ tmp_path, "film", "research", "completed",
+ {"research_brief": sample_artifact("research_brief")},
+ human_approved=True,
+ )
+
+ assert get_completed_stages(tmp_path, "film") == ["research"]
+ assert get_next_stage(tmp_path, "film") == "proposal"