fix(install): ship no Python bytecode into the installed skill trees and the hub

install.sh copies the rendered skills with cp -a, which carried __pycache__, *.pyc and *.pyo along; Python loads a lone .pyc before the module of the same name, so a stray file in a skill could shadow its script. After each copy, find -H prunes them in .agents/skills and .claude/skills, also when .claude/skills is a symlink to .agents/skills; the delete before the copy uses -H too. orchestrator.sh drops .pyc and .pyo besides __pycache__ in the hub tree.

Tests: test_no_python_bytecode_reaches_the_installed_skills (linked and unlinked) and test_install_ships_no_bytecode_from_the_tree fail on base 3418738 and pass; shellcheck and ruff clean; two independent reviews, round 2 holds.

🎯 Fix: 95 %
💥 Break: 2 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 93
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 11:18:31 +00:00
1 parent 3418738993
commit 6897f86d35
4 files changed
+39 -9

No files matched your search

+10 -5
View File
@@ -195,12 +195,17 @@ class TestOrchestratorMigration(unittest.TestCase):
self.assertIn("Environment=PATH=/usr/bin:/bin", unit.read_text(encoding="utf-8").splitlines())
def test_install_ships_no_bytecode_from_the_tree(self):
planted = REPO_ROOT / "orchestrator" / "client" / "__pycache__" / "planted.cpython-0.pyc"
planted.parent.mkdir(exist_ok=True)
planted.write_bytes(b"planted")
self.addCleanup(planted.unlink, True)
client = REPO_ROOT / "orchestrator" / "client"
if not (client / "__pycache__").exists():
(client / "__pycache__").mkdir()
self.addCleanup(shutil.rmtree, client / "__pycache__", True)
for planted in (client / "__pycache__" / "planted.cpython-0.pyc", client / "planted.pyc", client / "planted.pyo"):
planted.write_bytes(b"planted")
self.addCleanup(planted.unlink, True)
self.install()
self.assertEqual(sorted((self.home / ".local" / "share" / NEW).rglob("__pycache__")), [])
hub = self.home / ".local" / "share" / NEW
self.assertEqual(sorted(path for path in hub.rglob("*") if path.name == "__pycache__" or path.suffix in (".pyc", ".pyo")), [])
self.assertTrue((hub / "client" / "permission_hook.py").is_file())
def test_old_names_live_only_in_the_migration(self):
done = subprocess.run(["git", "grep", "-niE", "kvb[-_]hub", "--", ".", ":!docs/requirements", f":!{Path(__file__).relative_to(REPO_ROOT)}"], cwd=REPO_ROOT, capture_output=True, text=True, check=False)