Repository navigation
fix(install): name native target files a failed install leaves on disk - #3641
Conversation
InstallTransaction restores apm.yml and apm_modules staging only; native target integrations run outside it. A failure after integration now lists every deployed path that apm.lock.yaml does not track, gives one next step (remove the files, or re-run apm install with --force when skipped as not managed by APM), and the FAILED summary no longer says "No install transaction changes were committed" when such files remain. Reporting only: no rollback, deletion, or ownership tracking of native target files, and no InstallTransaction or resolution staging changes. apm-spec-waiver: failure-output wording only; no install, lockfile or staging semantics change (#3525) Fixes #3525 Co-authored-by: Copilot App <[email protected]>
…5-install-rollback-partial-files
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The residue report labels skill directories as removable files, so following its cleanup advice after a failed forced install could delete unrelated user files.
4 open issues
What changed in this PR
This PR addresses #3525 by reporting untracked native deployment residue after failed installs. It changes failure reporting without adding rollback, deletion, or ownership tracking.
Changes:
- Compares recorded deployments against the on-disk lockfile on unsuccessful pipeline exits.
- Adds residue paths and recovery guidance, and adjusts failed-summary wording.
- Adds regression tests, troubleshooting guidance, and a changelog entry.
| File | Description |
|---|---|
tests/unit/install/test_failed_install_residue.py |
Tests failure exits, lockfile exclusions, and logger wording. |
src/apm_cli/install/pipeline.py |
Calls residue reporting after unsuccessful pipeline exits. |
src/apm_cli/install/failure_residue.py |
Collects deployment claims absent from the lockfile. |
src/apm_cli/core/command_logger.py |
Renders residue details and updates failed summaries. |
docs/src/content/docs/troubleshooting/install-failures.md |
Documents residue recovery steps. |
CHANGELOG.md |
Records the failure-reporting change. |
Review effort: Balanced
The residue report runs in the pipeline finally block while the original failure propagates. A crash while rendering it must never replace that error, so the call is suppressed and a regression test proves a raising reporter still surfaces DirectDependencyError. Addresses panel python-architect finding on src/apm_cli/install/pipeline.py. Co-authored-by: Copilot <[email protected]>
…5-install-rollback-partial-files
The residue reporter now suppresses its own errors instead of the pipeline wrapping the call, so the guard lives with the report owner and pipeline.py stays within the 1000-line install module budget enforced by test_architecture_invariants (CI Build & Test Shard 1 failed at 1001). Co-authored-by: Copilot <[email protected]>
…5-install-rollback-partial-files
Address Copilot review on the failed-install residue report: - skill directory claims are dropped when their members are claimed, so the "remove these files" advice never targets a directory that may hold unrelated user files; - user-scope (-g) residue renders home-rooted paths and suggests 'apm install -g'; - file-backed target locators (cowork://) resolve through their owning target for display, and non-file locators (copilot-app-db://) are listed as entries, not files; - lockfile claim membership routes through the canonical DeploymentLedgerCodec.legacy_deployed_file_claims owner. Co-authored-by: Copilot <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | All delta folds architecturally sound: owner routing, directory filter, scope rendering, locator decode, never-raise placement. |
| CLI Logging Expert | 0 | 0 | 0 | Wording, grammar, ASCII symbols, scope-correct hints, and no-rollback contract all correct. |
| Test Coverage Expert | 0 | 0 | 0 | All six delta behaviors have regression traps. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
Three-persona delta panel is unanimous with zero findings on a CI-green head. All material folds are regression-trapped and architecturally sound. Merge at maintainer discretion.
Folded in this run
- (panel) python-architect: residue reporter must never mask the original install exception -- resolved in b2a19f4 (guard moved into the module in c69bdb0).
- (copilot) Exclude aggregate skill directory claims from the removable list -- resolved in dbbc151.
- (copilot) User-scope residue:
~/paths andapm install -gnext step -- resolved in dbbc151. - (copilot) Decode
cowork://for display; listcopilot-app-db://rows as non-file entries -- resolved in dbbc151. - (copilot) Route lockfile claim membership through
DeploymentLedgerCodec.legacy_deployed_file_claims-- resolved in dbbc151.
Copilot signals reviewed
src/apm_cli/install/failure_residue.py:46-- LEGIT: skill directory could be advised for removal (resolved in dbbc151).src/apm_cli/core/command_logger.py:271-- LEGIT:-gnext step and home-rooted paths (resolved in dbbc151).src/apm_cli/install/failure_residue.py:46-- LEGIT: locators shown as files (resolved in dbbc151).src/apm_cli/install/failure_residue.py:36-- LEGIT: second claim-membership implementation (resolved in dbbc151).
Regression-trap evidence (mutation-break gate)
TestPipelineFailureExits::test_raised_failure_reports_every_deployed_path-- deleted the pipeline reporter call; 3 tests FAILED; restored.TestInstallLoggerResidue::test_failed_summary_with_residue_drops_uncommitted_claim-- kept the old FAILED sentence; test FAILED; restored.TestUnrecordedDeployedPaths::test_paths_recorded_by_on_disk_lockfile_are_excluded-- deleted lockfile subtraction; test FAILED; restored.TestPipelineFailureExits::test_report_failure_never_masks_the_original_error-- deleted the never-raise guard; test FAILED; restored.TestUnrecordedDeployedPaths::test_skill_directory_claims_are_not_reported_as_removable-- deleted the aggregate-directory filter; 4 tests FAILED; restored.TestResidueClassification::test_user_scope_paths_are_home_rooted,TestInstallLoggerResidue::test_user_scope_next_step_reruns_global_install,TestResidueClassification::test_file_backed_locators_resolve_and_rows_stay_entries-- deleted the~/prefix, the-gcommand, and the locator decode in turn; each test FAILED; restored.
Lint contract
ruff check and ruff format --check (src, tests, architecture scripts) silent; pylint R0801 10.00/10; lint-auth-signals.sh and lint-architecture-boundaries.sh clean on dbbc151.
CI
All checks green at dbbc151 (23 pass, 3 skipping, license/cla pass) after 1 CI fix iteration (install module LOC budget: pipeline.py 1001 -> 999).
| PR | head | stance | iterations | folds | deferrals | copilot rounds | CI | mergeable | merge state | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3641 | dbbc151 | ship_now | 2 | 5 | 0 | 2 | green | MERGEABLE | BLOCKED | awaiting CODEOWNER review; 0 unresolved threads |
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.
…ack-partial-files Co-authored-by: Copilot App <[email protected]>
Avoids landing-order conflicts with other queued PRs. Co-authored-by: Copilot App <[email protected]>
…ack-partial-files Co-authored-by: Copilot App <[email protected]>
After merging main, pipeline.py reached 1007 lines and failed the 1000-line install module budget (test_no_install_module_exceeds_loc_budget, CI run 43279911187). The finished-vs-failed decision now lives in failure_residue.record_install_outcome, which records it on the install context; report_failed_install_residue returns early once the install finished. pipeline.py keeps one import and one call (1000 lines). Two regression traps cover the guard and the pipeline wiring. Co-authored-by: Copilot App <[email protected]>
…ack-partial-files Co-authored-by: Copilot App <[email protected]>
…ack-partial-files Co-authored-by: Copilot App <[email protected]>
…ack-partial-files Co-authored-by: Copilot App <[email protected]>
Main's pipeline.py reached exactly 1000 lines (#3652), so the CI merge commit put it at 1002 with this PR's import and reporter call (test_no_install_module_exceeds_loc_budget). The finally block's exit sequence -- deactivate Copilot plugin registration, close the TUI, then report failed-install residue -- now lives in finalization.close_pipeline_attempt, beside close_install_contexts, in the same order. pipeline.py is 999 lines, one under main. Co-authored-by: Copilot App <[email protected]>
close_pipeline_attempt must deactivate Copilot plugin registration, close the TUI, then report residue. No test asserted those calls or their order, so a later refactor could drop or reorder them silently. Addresses the CEO follow-up from the delta panel on 11f286b. Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | Clean Extract Method into finalization.py: same order, same guards, no import cycle, no ownership shift; 999 LOC. |
| Test Coverage Expert | 0 | 0 | 0 | Refactor-only delta; mutation-break proves the residue path is still guarded through close_pipeline_attempt. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
Unanimous panel, zero findings, CI green at the exact head, mutation-break evidence intact. The one curated follow-up (exit-order trap) is already folded. Ship as-is.
Folded in this run
- (landing desk)
pipeline.py1007 > 1000 after main merge: outcome decision moved tofailure_residue.record_install_outcome-- resolved in 200f2c9. - (ci) Main's
pipeline.pyreached 1000 (fix(policy): judge the declared constraint, accept package release tags (supersedes #3381) #3652), merge commit 1002: exit sequence moved tofinalization.close_pipeline_attempt-- resolved in 11f286b. - (panel) test-coverage-expert via CEO: trap the deactivate / TUI exit / residue report order -- resolved in 812039c.
Copilot signals reviewed
No new Copilot review since 3815779. The four earlier inline items (skill directories, -g scope, locators, canonical claim owner) were LEGIT and folded in dbbc151; all threads resolved.
Regression-trap evidence (mutation-break gate)
TestUnrecordedDeployedPaths::test_only_an_unfinished_install_reports[success-False]-- removed theinstall_finishedguard; FAILED; restored.TestPipelineFailureExits::test_finished_install_skips_the_residue_scan-- pipeline returned the finalize result withoutrecord_install_outcome; FAILED; restored.TestPipelineFailureExits::*+ CLI test -- removed the reporter call fromclose_pipeline_attempt; 4 tests FAILED; restored.TestClosePipelineAttempt::test_exit_sequence_runs_in_order-- dropped the Copilot deactivate call, then swapped TUI exit and report; FAILED each time; restored.
Lint contract
ruff check and ruff format --check (src, tests, architecture scripts) silent; pylint R0801 10.00/10; lint-auth-signals.sh and lint-architecture-boundaries.sh clean. Merged with main 9e0a4a8 (head is current with main).
CI
All checks green at 812039c (23 success including license/cla, 2 neutral, 1 skipped).
| PR | head | stance | iterations | folds | deferrals | copilot rounds | CI | mergeable | merge state | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3641 | 812039c | ship_now | 3 | 3 | 0 | 2 | green | MERGEABLE | BLOCKED | awaiting CODEOWNER review; 0 unresolved threads |
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.
Bring in #3626, #3419 and #3641. Move this PR's CODEX_HOME CHANGELOG bullet off the Fixed section tail, where new entries land, to avoid repeat append conflicts. Co-authored-by: Copilot App <[email protected]>



Description
TL;DR — When
apm installfails after primitives were already deployed to harness directories, those files stayed on disk with no mention, and the failure summary said “No install transaction changes were committed.” The next run then treated them as unmanaged. Failure output now lists every deployed path thatapm.lock.yamldoes not track, gives one next step, and drops the uncommitted claim when such files remain. Reporting only: nothing is deleted, restored, or newly tracked.Problem (WHY)
InstallTransactionrolls back onlyapm.ymlandapm_modulesstaging; its own docstring says “Native target integrations are outside this transaction.”main(0d214b8561) left.claude/agents/helper.mdon disk and printed only[x] Install failed after 0.1s.— no path, no next step.not managed by APM(the [BUG] Referencing files in a private GitHub repository burns through anonymous GitHub API quota and hits the rate limit #3185 / 0.33.0 report).Approach (WHAT)
ctx.package_deployed_files+ctx.local_deployed_files, minus aggregate skill-directory claims, minus what the on-diskapm.lock.yamlrecords at exit (viaDeploymentLedgerCodec.legacy_deployed_file_claims) — the set a later run treats as unmanaged.-g):~/-rooted paths. File-backed locators (cowork://) decode through their owning target; non-file locators (copilot-app-db://) are listed as entries, not files.FAILEDresults.[!]warning with the count and each path, and one[i]next step: Remove these files, or re-runapm install(apm install -gfor user scope; add--forceif it skips them as not managed by APM).FAILEDsummary swaps “No install transaction changes were committed.” for “N native target item(s) listed above remain in place.” only when residue was reported; otherwise unchanged.Implementation (HOW)
src/apm_cli/install/context.pyinstall_finished, for the reporter's skip check.src/apm_cli/install/failure_residue.py(new)record_install_outcome,unrecorded_deployed_paths,failed_install_residue(scope + locator classification),report_failed_install_residue(never raises, so it cannot mask the install error). Lockfile claims come from theDeploymentLedgerCodecowner; unreadable lock → list everything. No filesystem writes.src/apm_cli/install/pipeline.pyfinalizeresult throughrecord_install_outcome(marksctx.install_finishedunless it isFAILED); thefinallyblock now callsclose_pipeline_attempt(ctx). 999 lines, one under main (1000), so the install module budget holds.src/apm_cli/install/finalization.pyclose_pipeline_attemptruns the pipeline's existing exit sequence in the same order (deactivate Copilot plugin registration, close the TUI), then the residue reporter, which returns early once the install finished.src/apm_cli/core/command_logger.pyInstallLogger.failed_install_residue(residue)renders files, non-file entries, and the scope-correct next step (output stays with the CommandLogger owner);install_summaryuses it for theFAILEDsentence.docs/.../troubleshooting/install-failures.mdtests/unit/install/test_failed_install_residue.py(new)Failure exits now pass through one reporter before the command renders its error; the boxed node is new.
flowchart LR I["integrate phase<br/>writes native files"] --> X{"pipeline exit"} X -->|"finalize ok"| OK["lockfile records files"] X -->|"raise or FAILED result"| R["report_failed_install_residue<br/>deployed minus on-disk lock"] R --> L["InstallLogger.failed_install_residue<br/>paths + next step"] L --> T["transaction rollback<br/>apm.yml + apm_modules only"] style R stroke-width:3pxTrade-offs
-gscope, locator display, codec-owned claims. All folded with regression tests.finallyvs. at the command boundary. The pipeline is shared byinstall,update, anddeps update; reporting there covers every caller. Cost: the block prints before the command’s final[x]line.deployed_filescannot be enumerated without integrator changes; out of scope here.apm updatewithout deployment receipts deletes (0.35.0) or refuses to replace (0.35.1+) the files of the package it updates #3625 (apm updateall-or-nothing with cold-restore adoption): no PR is open yet. This change adds no rollback owner; if [BUG]apm updatewithout deployment receipts deletes (0.35.0) or refuses to replace (0.35.1+) the files of the package it updates #3625 introduces one, its residue should route throughfailure_residue.py.Benefits
not managed by APMskip on the next run.apm.ymlrestore, lockfile writing,InstallTransaction, or resolution staging.Issue and approved scope
Fixes #3525
Human scope-approval comment: #3525 (comment) (
apm-scope:v1, approver and review contact Daniel Meppiel (@danielmeppiel);eligibility.cjs→record-present).This PR completes the approved scope. Out of scope and untouched: rolling back native files, tracking them in the transaction or a recovery journal,
InstallTransaction/ resolution staging changes, and BaseIntegrator’s unmanaged-file handling.Note
Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.
Type of change
Testing
Scenario evidence
test_failed_install_residue.py::TestCliFailureAfterNativeDeploy::test_failure_lists_every_leftover_path_without_rollback_claimTestInstallLoggerResidue::test_failed_summary_with_residue_drops_uncommitted_claimapm.ymlrestore and no-lockfile-on-failure are unchangedtest_failure_lists_every_leftover_path_without_rollback_claim(byte-equalapm.yml, noapm.lock.yaml);test_install_transaction.pyunchanged and greenFAILEDresult) reportTestPipelineFailureExits::*TestUnrecordedDeployedPaths::test_paths_recorded_by_on_disk_lockfile_are_excluded,::test_skill_directory_claims_are_not_reported_as_removableapm install -gfailures show~/paths and anapm install -gnext step;cowork://decodes, DB rows are not called filesTestResidueClassification::*,TestInstallLoggerResidue::test_user_scope_next_step_reruns_global_install,::test_entries_are_not_called_filesTestPipelineFailureExits::test_report_failure_never_masks_the_original_errorTestCliFailureAfterNativeDeploy::test_successful_install_reports_no_residueValidation output
Reproduction on
main(0d214b8561), real CLI withLockfileBuilder.build_and_saveforced to raise after integration:Same repro on this branch:
Tests (no xdist):
Mutation-break (each restored afterwards):
FAILEDsummary keeps the old sentence~/prefix /-gcommand removedLint mirror (merged with
origin/main):ruff check+ruff format --checkclean, pylint R0801 10.00/10,lint-auth-signals.shclean,lint-architecture-boundaries.shclean, largestsrcfile 2099 lines.How to test
pytest -q -p no:xdist tests/unit/install/test_failed_install_residue.py.apm/agents/x.agent.md, then runapm install --target claudewithapm_cli.install.phases.lockfile.LockfileBuilder.build_and_savepatched to raise; confirm.claude/agents/x.mdis listed with the next step and no rollback wording appears.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedapm-spec-waiver:line for the Mode B critical-path gate.Co-authored-by: Copilot [email protected]