MCPcopy Create free account
hub / github.com/OpenRaiser/NanoResearch / rollback

Method rollback

nanoresearch/agents/code_editor.py:69–83  ·  view source on GitHub ↗

Restore code from a snapshot. Returns True on success.

(self, snapshot_id: str)

Source from the content-addressed store, hash-verified

67 # -- rollback ------------------------------------------------------
68
69 def rollback(self, snapshot_id: str) -> bool:
70 """Restore code from a snapshot. Returns True on success."""
71 zip_path = self.backup_dir / f"{snapshot_id}.zip"
72 if not zip_path.exists():
73 return False
74
75 # Remove current files (except .code_backups)
76 for fp in list(self.code_dir.rglob("*")):
77 if fp.is_file() and ".code_backups" not in fp.parts:
78 fp.unlink()
79
80 # Extract
81 with zipfile.ZipFile(zip_path, "r") as zf:
82 zf.extractall(self.code_dir)
83 return True
84
85 def rollback_latest(self) -> str | None:
86 """Rollback to the most recent snapshot. Returns snapshot id or None."""

Callers 3

rollback_latestMethod · 0.95
rollback_toMethod · 0.45
rollback_toMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected