Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions scripts/sync_research_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <root>/.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
Expand Down
25 changes: 25 additions & 0 deletions scripts/tests/test_sync_research_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]):
Expand Down
Loading