Last active
July 14, 2026 02:15
-
-
Save jasonLaster/003e956fcb23357272a6304c98bff0d5 to your computer and use it in GitHub Desktop.
Mechanical refactor transform: mirror agent and trainer tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Reproducible transform for mirroring agent rollout and trainer tests. | |
| Run from the repo root: python3 /tmp/transform_agent_trainer_test_layout.py | |
| """ | |
| import sys | |
| from pathlib import Path | |
| sys.path.append(".claude/skills/mechanical-refactor-verify") | |
| from mechanical_refactor_verify_utils import git_add_and_commit, verify_mechanical_refactor | |
| BASE_COMMIT = "23eb002571d220f3d06150d2fcdc4a727c4383a3" | |
| TARGET_COMMIT = "cb6e4765f126e11cdcde75c56b4162f8454a6884" | |
| def replace(path: Path, old: str, new: str) -> None: | |
| """Apply one targeted path replacement.""" | |
| path.write_text(path.read_text().replace(old, new)) | |
| def transform(dir_root: Path) -> None: | |
| """Move agent and trainer tests and repair depth-sensitive paths.""" | |
| tests_dir = dir_root / "autonomy/tests" | |
| rollouts_dir = tests_dir / "rollouts" | |
| trainers_dir = tests_dir / "trainers" | |
| (tests_dir / "test_strands_rollout.py").rename(rollouts_dir / "test_agent_rollout.py") | |
| (trainers_dir / "__init__.py").write_text("\n") | |
| for test_name in ( | |
| "test_distill_only.py", | |
| "test_reloadable_process_group.py", | |
| "test_train_dispose_try_finally.py", | |
| ): | |
| (tests_dir / test_name).rename(trainers_dir / test_name) | |
| distill_test = trainers_dir / "test_distill_only.py" | |
| dispose_test = trainers_dir / "test_train_dispose_try_finally.py" | |
| replace(distill_test, "parents[2]", "parents[3]") | |
| replace(dispose_test, "autonomy.tests.test_distill_only", "autonomy.tests.trainers.test_distill_only") | |
| replace(dispose_test, "parents[2]", "parents[3]") | |
| readme = dir_root / "autonomy/README_CLAUDE.md" | |
| replace( | |
| readme, | |
| "│ ├── test_strands_rollout.py # Strands rollout integration tests with typed interface", | |
| "│ ├── rollouts/test_agent_rollout.py # Agent rollout integration tests with typed interface", | |
| ) | |
| replace( | |
| readme, | |
| "[test_strands_rollout.py](tests/test_strands_rollout.py) - Strands rollout integration", | |
| "[test_agent_rollout.py](tests/rollouts/test_agent_rollout.py) - Agent rollout integration", | |
| ) | |
| git_add_and_commit("mechanical: mirror agent and trainer tests", cwd=str(dir_root)) | |
| if __name__ == "__main__": | |
| verify_mechanical_refactor( | |
| base_commit=BASE_COMMIT, | |
| target_commit=TARGET_COMMIT, | |
| transform=transform, | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment