tests: add reproducer for pack retaining deleted files between builds (#710)
Metadata
Current evaluation
Adds a fix for charmcraft pack retaining deleted files between builds by cleaning stale parts before each lifecycle run, resolving the reproducer test and awaiting review.
Suggested action: needs triage
Reason: The PR lacks labels, an assignee, and any maintainer assessment. It requires initial triage to verify if the upstream craft-parts bug has been resolved (potentially making this workaround obsolete) and to initiate the standard review process.
Staleness:
45
Complexity:
40
Confidence:
80
Issue body
## Summary
Adds a failing unit test that reproduces #710: `charmcraft pack` includes files that were deleted from the working directory since the last pack, because craft-parts does not clean stale files from the stage/prime directories on incremental rebuilds.
## Bug
When `LifecycleManager.run()` is called a second time after a source file has been deleted, craft-parts skips all lifecycle steps with `reason='already ran'`. The deleted file persists in `prime/` and is included in the repacked `.charm` archive.
Upstream bug: https://github.com/canonical/craft-parts/issues/851
Workaround: run `charmcraft clean` (or `charmcraft clean <part-name>`) between packs.
## Reproducer
```
uv run python -m pytest tests/unit/parts/test_lifecycle.py::test_stale_files_removed_from_prime_after_repack -v
```
The test fails with:
```
AssertionError: Stale file from deleted source is still present in prime directory after repack
```
Closes #710
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| 2026-06-15 11:35:47.418748+00:00 | qwen3.6-35b-a3b-mtp-q6 |
Staleness:
45
Complexity:
40
Confidence:
80
|
needs triage | Adds a fix for charmcraft pack retaining deleted files between builds by cleaning stale parts before each lifecycle run, resolving the reproducer test and awaiting review. |
| 2026-06-15 11:32:23.593701+00:00 | pending | — | — | — |