fix(compile): run orphan cleanup on --clean when last primitive removed (closes #2130)#2134
fix(compile): run orphan cleanup on --clean when last primitive removed (closes #2130)#2134danielmeppiel wants to merge 5 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Docs sync advisoryVerdict: no_change * Pages affected: 0 * LLM calls: 0/15 * Took: <1s No docs impact detected. Existing docs already state that |
There was a problem hiding this comment.
Pull request overview
Fixes an edge case in apm compile --clean where removing the final primitive previously caused an early validation exit (exit 1) that prevented the orphan-cleanup phase from running, leaving stale APM-owned outputs (notably CLAUDE.md) behind.
Changes:
- Allow
compile --clean(when not combined with--validate/--watch) to proceed even when the project has no remaining primitives, so compiler cleanup can still run. - Treat “empty Claude output” as an orphan condition so
--cleancan remove stale APM-managedCLAUDE.md, with an updated reason string used in removal messaging. - Add a regression test covering “remove last primitive, then run
compile --clean” ensuringCLAUDE.mdis deleted and the command exits 0.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/compilation/test_compile_clean_last_primitive_2130.py | Adds regression test asserting --clean removes stale CLAUDE.md after last primitive is removed. |
| src/apm_cli/compilation/agents_compiler.py | Expands Claude orphan detection to treat empty output as an orphan scenario and improves removal messaging. |
| src/apm_cli/commands/compile/cli.py | Adds allow_empty to validation so clean-only runs can reach orphan cleanup even with zero primitives. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Low
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | The empty-output signal and caller boundary now remain consistent end to end. |
| CLI Logging Expert | 0 | 0 | 0 | Cleanup output is contextual and free of contradictory warnings. |
| DevX UX Expert | 0 | 0 | 0 | Earlier scoped pass confirmed idempotent clean semantics; terminal return had a schema-format error. |
| Supply Chain Security Expert | 0 | 0 | 0 | Explicit clean, ownership marker, containment, and project identity gates remain intact. |
| OSS Growth Hacker | 0 | 0 | 0 | This is bounded reliability work with no conversion-surface impact. |
| Test Coverage Expert | 0 | 0 | 0 | All changed promises have integration-with-fixtures regression coverage. |
B = highest-severity findings, R = recommended, N = nits.
Counts are advisory signal strength. The maintainer ships.
Folded in this run
- (panel) Corrected the no-primitives progress message -- resolved in
959127c0b. - (panel) Added the negative
--clean --validateboundary test -- resolved in959127c0b. - (copilot) Typed the pytest
monkeypatchfixture -- resolved in959127c0b. - (panel) Unified formatter suppression on
would_emit_no_claude_md-- resolved ind366a8c22. - (panel) Documented the validation/watch caller boundary and both empty-output causes -- resolved in
d366a8c22and077fd204a. - (panel) Suppressed the generic zero-output warning for expected no-primitives cleanup -- resolved in
077fd204a. - (panel) Removed irrelevant duplicate-context advice when preserving a hand-authored file in an empty project -- resolved in
077fd204a. - (panel) Added output and hand-authored-preservation assertions -- resolved in
077fd204a.
Copilot signals reviewed
tests/unit/compilation/test_compile_clean_last_primitive_2130.py:13-- LEGIT: the new pytest fixture parameter lacked the repository-requiredpytest.MonkeyPatchannotation (resolved in959127c0b).
Regression-trap evidence (mutation-break gate)
test_clean_validate_still_rejects_project_without_primitives-- deleted thenot validateguard; the test failed with exit 0 instead of 1; guard restored.test_clean_removes_claude_md_after_last_primitive_is_removed-- deleted expected zero-output suppression; the test failed on the contradictory warning; guard restored.test_clean_preserves_hand_authored_claude_md_without_duplicate_guidance-- removed context-aware guidance; the test failed onduplicate context; guard restored.
Lint contract
The full CI-mirror chain passed at 077fd204a: ruff check, ruff format check, pylint R0801, and auth-signal lint all exited 0 with no diagnostics.
CI
All terminal checks passed on the final head, including Lint, both Linux test shards, Coverage Combine, binary smoke, Spec conformance, CodeQL, NOTICE, merge gate, self-check, and CLA. CI recovery iterations: 0.
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #2134 | 077fd20 |
ship_now | 4 | 8 | 0 | 2 | green | MERGEABLE | BLOCKED | awaiting required review |
Recommendation
All in-scope follow-ups are folded, local validation is clean, and GitHub CI is green. Ready for maintainer review.
Full per-persona findings
No remaining findings from Python Architecture, CLI Logging, Supply Chain Security, OSS Growth, or Test Coverage. Auth, Docs, and Performance were inactive because their surfaces were not touched. The terminal DevX return missed the current JSON shape after two attempts; its earlier scoped review reported no remaining UX concern.
This panel is advisory. Re-apply the panel-review label after new changes to re-run.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Correct the zero-primitives progress message, type the pytest fixture, and lock the validate boundary with a mutation-proven regression test. Addresses panel and Copilot follow-ups. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reuse the broadened empty-output signal for formatter suppression and document the validation/watch caller boundary. Addresses the final Python architecture panel follow-up. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Suppress the contradictory zero-output warning for expected orphan cleanup, preserve hand-authored files without irrelevant duplicate-context advice, and add mutation-proven message regressions. Addresses the terminal logging and architecture panel findings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Superseded by #2155. The reliability campaign consolidated all 13 point fixes into a single architectural cure PR that re-homes each fix under its canonical owner module and adds owner-invariant guards. The fix for #2130 is folded into #2155 and re-verified there (full CI green). Closing this point PR in favor of the consolidated cure; the branch is preserved and this can be reopened if #2155 is not merged. |
apm compile --cleanpreviously stopped at empty-project validation after the final primitive was removed, leaving an APM-ownedCLAUDE.mdstale. This change lets clean-only empty projects reach the existing marker-guarded orphan cleanup and treats empty Claude output as an orphan condition while continuing to preserve hand-authored files.How to test
uv run --extra dev python -m pytest tests/unit/compilation/test_compile_clean_last_primitive_2130.py -quv run --extra dev python -m pytest tests/ -k "compile or clean or orphan" -qcloses #2130