Skip to content

The agent that grows with you

fix(checkpoints): refuse rollback of uncaptured nested repos

Yuan Libe6c55685be7
diff --git a/tools/checkpoint_manager.py b/tools/checkpoint_manager.py
index 16e0a969912..94b7bb8194d 100644
--- a/tools/checkpoint_manager.py
+++ b/tools/checkpoint_manager.py
@@ -1143,6 +1143,27 @@ class CheckpointManager:
return {"success": False, "error": f"Checkpoint '{commit_hash}' not found",
"debug": err or None}
+ ok, tree_out, err = _run_git(
+ ["ls-tree", "-r", "-z", commit_hash], store, abs_dir,
+ )
+ if not ok:
+ return {"success": False, "error": f"Could not inspect checkpoint: {err}"}
+ nested_repos = [
+ record.split(b"\t", 1)[1].decode(errors="replace")
+ for record in tree_out.encode().split(b"\x00")
+ if record.startswith(b"160000 commit ") and b"\t" in record
+ ]
+ if nested_repos:
+ paths = ", ".join(nested_repos)
+ return {
+ "success": False,
+ "error": (
+ "Checkpoint contains nested git repositories that were not captured "
+ f"({paths}); rollback was not performed"
+ ),
+ "nested_repositories": nested_repos,
+ }
+
skipped_user_edits: List[str] = []
kept_oversize: List[str] = []
failed_deletes: List[str] = []