diff --git a/scripts/sync_research_workflow.py b/scripts/sync_research_workflow.py index b3eb01d0e3..8800bfbc6c 100644 --- a/scripts/sync_research_workflow.py +++ b/scripts/sync_research_workflow.py @@ -57,6 +57,17 @@ def load_profile(path, *, lifecycle_skills=False): raise ValueError( f"{path}: workflow_docs must name a directory inside the repository" ) + # The profile lives at /.agents/research-workflow.json, so the + # repository root is two levels up. A value that merely *resolves* to + # that root -- "docs/.." and its spellings, or a symlink naming the + # root itself -- reaches the same place "" and "." do, and is rejected + # with the same diagnostic instead of failing later inside() with a + # generic path error (#7083). + repo_root = path.parent.parent.resolve() + if (path.parent.parent / workflow_docs).resolve() == repo_root: + raise ValueError( + f"{path}: workflow_docs must name a directory inside the repository" + ) skills = profile.get("lifecycle_skills", SKILLS) if ( lifecycle_skills diff --git a/scripts/tests/test_sync_research_workflow.py b/scripts/tests/test_sync_research_workflow.py index 1546ded0d5..6662ddd63b 100644 --- a/scripts/tests/test_sync_research_workflow.py +++ b/scripts/tests/test_sync_research_workflow.py @@ -136,6 +136,31 @@ def test_workflow_docs_must_not_name_the_repository_root(self): "directory inside the repository", ) + def test_workflow_docs_must_not_resolve_to_the_repository_root(self): + for directory in (self.source, self.target): + path = directory / ".agents/research-workflow.json" + for value in ("docs/..", "docs/../", "./docs/..", "a/b/../.."): + with self.subTest(directory=directory.name, value=value): + self.assert_clean_failure( + path, + {"workflow_docs": value}, + "research-workflow.json: workflow_docs must name a " + "directory inside the repository", + ) + + def test_workflow_docs_symlink_to_repository_root_is_rejected(self): + for directory in (self.source, self.target): + path = directory / ".agents/research-workflow.json" + link = directory / "rootlink" + link.symlink_to(directory, target_is_directory=True) + with self.subTest(directory=directory.name): + self.assert_clean_failure( + path, + {"workflow_docs": "rootlink"}, + "research-workflow.json: workflow_docs must name a " + "directory inside the repository", + ) + def test_lifecycle_skills_entries_must_be_directory_names(self): path = self.source / ".agents/research-workflow.json" for value in ([""], ["."], [".."], ["a/b"]):