import pathlib from failure import Failure from loop_effects.effects import Effects from agent_cycle.stop import Stop def checkout_root(cwd: pathlib.Path, effects: Effects) -> str | Stop: found = effects.git("rev-parse", "--show-toplevel", cwd=str(cwd)) return Stop(1, found.reason) if isinstance(found, Failure) else found.strip()