Skip to content

Commit f2a64ee

Browse files
committed
fix: add purge_unknown tests and wire clean command into docs/agent config
- Add three unit tests for FindingsStore.purge_unknown: noop when state_dir missing, keeps allowed names, removes unknown files and dirs - Document pythinker-review clean command in README alongside clean-locks - Add pythinker review clean guidance to code_reviewer.yaml so the agent knows to use it for stale review state maintenance
1 parent 7b5eaca commit f2a64ee

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

packages/pythinker-review/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Phase 1 now ports the highest-value behavior from the mounted blackbox repos:
105105
outside the reviewed chunk/feature, unsafe paths, omitted/truncated line ranges, or non-matching
106106
evidence snippets; invalid sibling findings are recorded as drops without failing the whole run.
107107
- Reviewflow pure-Python stateful commands cover `init`, `map`, `status`, `review`, `ci`,
108-
`report`, `show --finding`, `next`, `triage`, `revalidate`, `fix`, `open-pr`, `doctor`, and
109-
`clean-locks`.
108+
`report`, `show --finding`, `next`, `triage`, `revalidate`, `fix`, `open-pr`, `doctor`,
109+
`clean-locks`, and `clean` (removes unexpected entries from `.pythinker-review/`).
110110
- Code-review prompt parity covers partial-diff caveats, concrete trigger scenarios, test analysis,
111111
suggested regression tests, and minimum fix scope.
112112
- Code-reviewr PR assistant parity adds read-only `describe`, `improve`/`suggest`, `ask`,

packages/pythinker-review/tests/unit/test_findings_store.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,36 @@ def test_begin_twice_without_finalize_raises(tmp_path: Path) -> None:
7878
with pytest.raises(RuntimeError, match="begin\\(\\) called twice"):
7979
store.begin(meta)
8080
store.finalize(meta)
81+
82+
83+
def test_purge_unknown_noop_when_state_dir_missing(tmp_path: Path) -> None:
84+
store = FindingsStore(repo_root=tmp_path)
85+
assert store.purge_unknown() == []
86+
87+
88+
def test_purge_unknown_keeps_allowed_names(tmp_path: Path) -> None:
89+
state_dir = tmp_path / ".pythinker-review"
90+
state_dir.mkdir()
91+
(state_dir / "index.json").write_text("{}", encoding="utf-8")
92+
(state_dir / "runs").mkdir()
93+
(state_dir / "security-scan").mkdir()
94+
store = FindingsStore(repo_root=tmp_path)
95+
assert store.purge_unknown() == []
96+
assert (state_dir / "index.json").exists()
97+
assert (state_dir / "runs").exists()
98+
assert (state_dir / "security-scan").exists()
99+
100+
101+
def test_purge_unknown_removes_unknown_file_and_dir(tmp_path: Path) -> None:
102+
state_dir = tmp_path / ".pythinker-review"
103+
state_dir.mkdir()
104+
stray_file = state_dir / "stray.json"
105+
stray_file.write_text("{}", encoding="utf-8")
106+
stray_dir = state_dir / "old-report"
107+
stray_dir.mkdir()
108+
(stray_dir / "data.txt").write_text("x", encoding="utf-8")
109+
store = FindingsStore(repo_root=tmp_path)
110+
removed = store.purge_unknown()
111+
assert set(removed) == {"stray.json", "old-report"}
112+
assert not stray_file.exists()
113+
assert not stray_dir.exists()

src/pythinker_code/agents/default/code_reviewer.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ agent:
1010
- Use `pythinker review diff` by default for bounded branch/diff review; add `--with-security` when the parent requests security coverage.
1111
- For repo-wide, long-running, resumable, or feature-slice review requests, prefer the stateful flow: `pythinker review init`, `pythinker review map`, then `pythinker review review --limit <n> --jobs <n>` followed by `report`/`next`/`show`/`triage` as needed.
1212
- Use `pythinker review describe`, `suggest`/`improve`, `ask`, `ask-line`, `labels`, `changelog`, `docs`, `compliance`, `help-docs`, `similar-issues`, `tools`, or `config` only when the parent explicitly asks for that artifact/helper.
13+
- Use `pythinker review clean` to remove unexpected entries from `.pythinker-review/` when the parent requests maintenance or cleanup of stale review state; pass `--dry-run` first to preview what will be removed.
1314
- For code-reviewr parity requests, prefer local read-only options such as `--labels-file`, `--extra-instructions`, `--best-practices-file`, `--min-score`, `--docs-style`, `--symbol`, `--pr-url`, and `--issues-dir` instead of provider publishing.
1415
- Do not edit files, commit, stage, push, approve, merge, or publish provider comments.
1516

0 commit comments

Comments
 (0)