diff --git a/.claude/skills/mechanical-refactor-verify/mechanical_refactor_verify_utils.py b/.claude/skills/mechanical-refactor-verify/mechanical_refactor_verify_utils.py index 5896bcb870..af83a77a59 100644 --- a/.claude/skills/mechanical-refactor-verify/mechanical_refactor_verify_utils.py +++ b/.claude/skills/mechanical-refactor-verify/mechanical_refactor_verify_utils.py @@ -11,11 +11,11 @@ from pathlib import Path -def exec_command(cmd: str, cwd: str | None = None, check: bool = True) -> str: - print(f" $ {cmd}", flush=True) +def exec_command(cmd: list[str], cwd: str | None = None, check: bool = True) -> str: + print(f" $ {' '.join(shlex.quote(c) for c in cmd)}", flush=True) result = subprocess.run( cmd, - shell=True, + shell=False, cwd=cwd, capture_output=True, text=True, @@ -27,7 +27,8 @@ def exec_command(cmd: str, cwd: str | None = None, check: bool = True) -> str: def git_add_and_commit(message: str, cwd: str) -> None: - exec_command(f"git add -A && git commit -m {shlex.quote(message)}", cwd=cwd) + exec_command(["git", "add", "-A"], cwd=cwd) + exec_command(["git", "commit", "-m", message], cwd=cwd) def dedent(text: str, n: int) -> str: @@ -41,14 +42,14 @@ def verify_mechanical_refactor( target_commit: str, transform: "Callable[[Path], None]", ) -> None: - repo_root = exec_command("git rev-parse --show-toplevel") + repo_root = exec_command(["git", "rev-parse", "--show-toplevel"]) worktree_dir = tempfile.mkdtemp(prefix="verify-mechanical-") branch_name = f"verify-mechanical-{base_commit[:8]}" try: print(f"[1/4] Creating worktree at {base_commit[:8]}...") exec_command( - f"git worktree add -b {branch_name} {worktree_dir} {base_commit}", + ["git", "worktree", "add", "-b", branch_name, worktree_dir, base_commit], cwd=repo_root, ) @@ -56,13 +57,13 @@ def verify_mechanical_refactor( transform(Path(worktree_dir)) print("[3/4] Running pre-commit...") - exec_command("pre-commit run --all-files", cwd=worktree_dir, check=False) - if exec_command("git status --porcelain", cwd=worktree_dir): + exec_command(["pre-commit", "run", "--all-files"], cwd=worktree_dir, check=False) + if exec_command(["git", "status", "--porcelain"], cwd=worktree_dir): git_add_and_commit("pre-commit fixes", cwd=worktree_dir) print(f"[4/4] Diffing against {target_commit[:8]}...") diff = exec_command( - f"git diff {target_commit} -- .", + ["git", "diff", target_commit, "--", "."], cwd=worktree_dir, check=False, ) diff --git a/miles/backends/training_utils/ci_utils.py b/miles/backends/training_utils/ci_utils.py index 42626c28a0..a9a3a0f65f 100644 --- a/miles/backends/training_utils/ci_utils.py +++ b/miles/backends/training_utils/ci_utils.py @@ -50,7 +50,7 @@ def check_grad_norm( rollout_id=rollout_id, step_id=step_id, ) - expected_grad_norm = torch.load(ci_load_grad_norm_path, weights_only=False) + expected_grad_norm = torch.load(ci_load_grad_norm_path, weights_only=True) assert math.isclose( grad_norm, expected_grad_norm,