From 828515483badd70f7ce9968cab6f2df14f90663b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 30 Oct 2026 08:23:20 +0100 Subject: [PATCH] fix(roles): skip the agent harness directory when copying a local custom role A custom role with a local source (`source.url: /opt/src/custom`) is copied with shutil.copytree, which skipped only .git and __pycache__. A dev checkout that Claude Code has worked in carries an empty `.claude/.cc-writes` (mode 0700, ignored by the global gitignore), unreadable for the runner uid, so `infinito administration deploy dedicated` aborted before the play with "Custom roles refused: ... [Errno 13] Permission denied". A git source never carries that directory, because it is staged through `git archive`. The copy now skips `.claude` as well. The ignore list has one consumer, the local branch of stage(); git sources are unchanged. A new test creates `.claude/.cc-writes` at mode 000: before the fix it fails in shutil with the reported Permission denied, after it all 102 custom-role tests pass. Reported by the GUI lane on efd72474a6. Co-Authored-By: Claude Opus 5.5 (1M context) --- cli/administration/roles/source.py | 2 +- .../unit/python/cli/administration/roles/test_source.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cli/administration/roles/source.py b/cli/administration/roles/source.py index aa55fc1bbb..1c7208d504 100644 --- a/cli/administration/roles/source.py +++ b/cli/administration/roles/source.py @@ -16,7 +16,7 @@ from utils.roles.custom import CustomRoleError if TYPE_CHECKING: from .declaration import Source -_COPY_IGNORE = shutil.ignore_patterns(".git", "__pycache__") +_COPY_IGNORE = shutil.ignore_patterns(".git", ".claude", "__pycache__") _DROPPED_ENV = frozenset( { "GIT_ALTERNATE_OBJECT_DIRECTORIES", diff --git a/tests/unit/python/cli/administration/roles/test_source.py b/tests/unit/python/cli/administration/roles/test_source.py index e37dbe2f1b..f8d529643a 100644 --- a/tests/unit/python/cli/administration/roles/test_source.py +++ b/tests/unit/python/cli/administration/roles/test_source.py @@ -127,6 +127,15 @@ class TestStage(_SourceFixture, unittest.TestCase): self.assertFalse((target / "__pycache__").exists()) self.assertIn("(working tree)", origin) + def test_local_directory_skips_unreadable_agent_harness_state(self): + harness = self.repo / ROLE_PATH / ".claude" / ".cc-writes" + harness.mkdir(parents=True) + harness.chmod(0o000) + self.addCleanup(harness.chmod, 0o700) + target = self.root / "staged" + stage(ROLE, Source(str(self.repo), None, ROLE_PATH), target) + self.assertFalse((target / ".claude").exists()) + def test_path_that_is_a_file_is_refused(self): with self.assertRaisesRegex(CustomRoleError, "source.path is not a directory"): stage(ROLE, Source(str(self.repo), "v1.0.0", "README.md"), self.root / "s")