Skip to content

Commit fe09324

Browse files
Jammy2211Jammy2211
authored andcommitted
fix: scan root workspace entry scripts
1 parent bbfbc8b commit fe09324

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

agents/conductors/hygiene/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ kinds, which is what makes its count comparable (or not):
4141
| `deps` | capped/pinned specifiers in library `pyproject.toml` (**surface**) | `/dep_audit` (Heart, hits PyPI) |
4242
| `docs` | `docs/api/*.rst` + `currentmodule` counts across the 3 doc repos (**surface**) | `/audit_docs` (Heart, imports) |
4343
| `crlf` | executable scripts (`.sh` + shebang-`755` `.py`) with CRLF — the shebang breaks on Linux/HPC (**debris**, the ranked count); library `.py` CRLF is reported separately as *cosmetic* (Python reads it fine — don't mass-normalise) | `/refactor` + `.gitattributes eol=lf` |
44-
| `docstrings` | consecutive module-level triple-quoted expressions separated only by whitespace in user-facing `*_workspace` and `HowTo*` `scripts/**/*.py` files (**finding**) | `/refactor` (mechanically merge each confirmed boundary) |
44+
| `docstrings` | consecutive module-level triple-quoted expressions separated only by whitespace in user-facing `*_workspace` and `HowTo*` root `*.py` entry scripts and `scripts/**/*.py` files (**finding**) | `/refactor` (mechanically merge each confirmed boundary) |
4545
| `config` | library `config/*.yaml` keys missing from the matching workspace config — recursive diff (**surface**) | `/refactor` (mirror keys) |
4646
| `artifacts` | tracked files that look like leaked run outputs / stray data (under `output/`, or data-ext outside fixtures) (**debris**) | `/repo_cleanup` (gitignore + `git rm --cached`) |
4747
| `packaging` | ignored, fully-untracked top-level `*.egg-info/` and `build/` directories in managed library repos (**debris**) | preview then run `PyAutoBrain/bin/clean_slate.sh --packaging`; repo-set, exact-name, root-depth and tracked-file guards apply |

agents/conductors/hygiene/_hygiene_docstrings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ def scan(root: Path) -> tuple[list[Finding], list[ParseError], int]:
125125
repositories = repository_paths(root)
126126

127127
for repository in repositories:
128-
for path in sorted((repository / "scripts").rglob("*.py")):
128+
script_paths = {
129+
*repository.glob("*.py"),
130+
*(repository / "scripts").rglob("*.py"),
131+
}
132+
for path in sorted(script_paths):
129133
relative = path.relative_to(repository).as_posix()
130134
try:
131135
source = path.read_text(encoding="utf-8")

skills/hygiene/hygiene.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Shared routing context: `PyAutoBrain/skills/COMMANDS.md`.
1919
tracked leaked outputs/data; `packaging` = ignored, fully-untracked top-level
2020
`*.egg-info/` and `build/` directories in managed library repositories;
2121
`docstrings` = exact adjacent module-level triple-quoted documentation
22-
boundaries in user-facing workspace and HowTo scripts.)
22+
boundaries in user-facing workspace and HowTo root entry scripts and
23+
`scripts/**/*.py` files.)
2324
2. Execute the emitted plan: run the named delegate — `/repo_cleanup` (git
2425
debris), `/cli_noise_clean`, `/dep_audit`, `/audit_docs` — for the full audit,
2526
or for `perf` route slow imports/functions to `/refactor` / `/bug` (JAX-adapt

tests/test_hygiene_conductor.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ def test_docstrings_reports_only_adjacent_top_level_triple_quoted_blocks(tmp_pat
142142
] == [(1, 3), (3, 4)]
143143

144144

145+
def test_docstrings_includes_root_level_entry_scripts(tmp_path):
146+
scripts = tmp_path / "demo_workspace" / "scripts"
147+
scripts.mkdir(parents=True)
148+
entry_script = tmp_path / "demo_workspace" / "start_here.py"
149+
entry_script.write_text('"""first"""\n\n"""second"""\n')
150+
151+
result = _run(["docstrings", "--json"], tmp_path)
152+
153+
assert result.returncode == 0, result.stderr
154+
row = json.loads(result.stdout)["row"]
155+
assert row["count"] == 1
156+
assert row["findings"][0]["file"] == "start_here.py"
157+
assert row["findings"][0]["first_end_line"] == 1
158+
assert row["findings"][0]["second_line"] == 3
159+
160+
145161
def test_docstrings_human_output_includes_exact_locations(tmp_path):
146162
_write_docstring_fixture(tmp_path)
147163

0 commit comments

Comments
 (0)