From 62412b5eba205d7734c8388bbbc9f41a6d157f83 Mon Sep 17 00:00:00 2001 From: fleet creator-b Date: Sat, 7 Nov 2026 05:55:56 -0600 Subject: [PATCH] fix(sync-research-workflow): reject root/empty workflow_docs and non-name lifecycle_skills entries (#6873) --- scripts/sync_research_workflow.py | 24 ++++++++++++++++---- scripts/tests/test_sync_research_workflow.py | 23 +++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/scripts/sync_research_workflow.py b/scripts/sync_research_workflow.py index 4ee5260fc0..b3eb01d0e3 100644 --- a/scripts/sync_research_workflow.py +++ b/scripts/sync_research_workflow.py @@ -48,20 +48,36 @@ def load_json_object(path): def load_profile(path, *, lifecycle_skills=False): profile = load_json_object(path) - if not isinstance(profile.get("workflow_docs"), str): + workflow_docs = profile.get("workflow_docs") + if not isinstance(workflow_docs, str): raise ValueError(f"{path}: workflow_docs must be a string") # noqa: TRY004 + if not Path(workflow_docs).parts: + # "" and "." name the repository root itself: source_files would + # treat the whole checkout (including .git) as the docs tree. + raise ValueError( + f"{path}: workflow_docs must name a directory inside the repository" + ) skills = profile.get("lifecycle_skills", SKILLS) if ( lifecycle_skills and "lifecycle_skills" in profile and ( not isinstance(skills, list) - or any( - not isinstance(skill, str) for skill in skills - ) + or any(not isinstance(skill, str) for skill in skills) ) ): raise ValueError(f"{path}: lifecycle_skills must be a list of strings") + if lifecycle_skills and any( + skill in (".", "..") + or not Path(skill).parts + or Path(skill).parts != (skill,) + for skill in skills + ): + # "" / "." would map the whole .agents/skills tree, and a name + # with separators is not a skill directory name. + raise ValueError( + f"{path}: lifecycle_skills entries must be directory names" + ) return profile, skills diff --git a/scripts/tests/test_sync_research_workflow.py b/scripts/tests/test_sync_research_workflow.py index 7532b4a1ca..1546ded0d5 100644 --- a/scripts/tests/test_sync_research_workflow.py +++ b/scripts/tests/test_sync_research_workflow.py @@ -124,6 +124,29 @@ def test_workflow_docs_must_be_a_string_in_both_profiles(self): "research-workflow.json: workflow_docs must be a string", ) + def test_workflow_docs_must_not_name_the_repository_root(self): + for directory in (self.source, self.target): + path = directory / ".agents/research-workflow.json" + for value in ("", ".", "./"): + 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_lifecycle_skills_entries_must_be_directory_names(self): + path = self.source / ".agents/research-workflow.json" + for value in ([""], ["."], [".."], ["a/b"]): + with self.subTest(value=value): + self.assert_clean_failure( + path, + {"workflow_docs": "docs/workflow", "lifecycle_skills": value}, + "research-workflow.json: lifecycle_skills entries must be " + "directory names", + ) + def test_lifecycle_skills_must_be_a_list_of_strings(self): path = self.source / ".agents/research-workflow.json" for value in ("research-workflow", [123], None):