Last active
July 14, 2026 02:27
-
-
Save jasonLaster/6378880af4c9bc7c799ed5504082dca8 to your computer and use it in GitHub Desktop.
Mechanical refactor transform: mirror package support 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 | |
| """Reproduce the package-support test layout moves.""" | |
| 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 = "26c70d7a7525f555c3e68feeab758c6efcfab6ce" | |
| def _replace(path: Path, old: str, new: str) -> None: | |
| content = path.read_text() | |
| updated = content.replace(old, new) | |
| if updated == content: | |
| raise RuntimeError(f"replacement not found in {path}: {old!r}") | |
| path.write_text(updated) | |
| def transform(dir_root: Path) -> None: | |
| """Move package-support tests and update their references.""" | |
| moves = { | |
| "autonomy/tests/test_container_utils.py": "autonomy/tests/utils/test_container_utils.py", | |
| "autonomy/tests/test_package_dist_names.py": "autonomy/tests/packages/test_dist_names.py", | |
| } | |
| for source_name, target_name in moves.items(): | |
| source = dir_root / source_name | |
| target = dir_root / target_name | |
| target.parent.mkdir(parents=True, exist_ok=True) | |
| source.rename(target) | |
| (dir_root / "autonomy/tests/packages/__init__.py").write_text("\n") | |
| _replace( | |
| dir_root / "autonomy/tests/packages/test_dist_names.py", | |
| 'PACKAGES_ROOT = Path(__file__).resolve().parent.parent / "packages"', | |
| 'PACKAGES_ROOT = Path(__file__).resolve().parent.parent.parent / "packages"', | |
| ) | |
| for relative_path in ( | |
| ".claude/skills/add-subpackage/SKILL.md", | |
| "autonomy/packages/public/README.md", | |
| "autonomy/packages/public/circuit_client/README.md", | |
| ): | |
| _replace( | |
| dir_root / relative_path, | |
| "autonomy/tests/test_package_dist_names.py", | |
| "autonomy/tests/packages/test_dist_names.py", | |
| ) | |
| _replace( | |
| dir_root / "autonomy/packages/internal/gym_proxy/tests/test_proxy_integration.py", | |
| "autonomy/tests/\ntest_container_utils.py", | |
| "autonomy/tests/utils/\ntest_container_utils.py", | |
| ) | |
| _replace( | |
| dir_root / ".github/CODEOWNERS", | |
| "/autonomy/packages/ @GymPod/SlimeCodeowners @GymPod/NextAct\n", | |
| ( | |
| "/autonomy/packages/ @GymPod/SlimeCodeowners @GymPod/NextAct\n" | |
| "/autonomy/tests/packages/ @GymPod/SlimeCodeowners @GymPod/NextAct\n" | |
| ), | |
| ) | |
| _replace( | |
| dir_root / "autonomy/packages/internal/circuit_internal/ARCHITECTURE.md", | |
| ( | |
| "`autonomy/tests/test_package_isolation.py` enforces the autonomy boundary\n" | |
| "mechanically. The `slime.*` / `strands.*` boundary is enforced by code\n" | |
| "review and grep. If you find yourself wanting to import either inside this\n" | |
| "package, the work belongs in the wrapper instead — see\n" | |
| ), | |
| ( | |
| "The import-linter contracts in `autonomy/pyproject.toml` enforce the autonomy\n" | |
| "boundary mechanically, with\n" | |
| "`autonomy/tests/scripts/test_import_linter_sync.py` keeping the package list in\n" | |
| "sync. The `slime.*` / `strands.*` boundary is enforced by code review and grep.\n" | |
| "If you find yourself wanting to import either inside this package, the work\n" | |
| "belongs in the wrapper instead — see\n" | |
| ), | |
| ) | |
| git_add_and_commit("[tests, packages] refactor: mirror package support 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