Repository navigation
fix(uninstall): refuse before any change when a file lacks deletion evidence (#3701) - #4294
Merged
Daniel Meppiel (danielmeppiel) merged 719 commits intoNov 21, 2026
Merged
Daniel Meppiel (danielmeppiel) merged 719 commits into
Daniel Meppiel (danielmeppiel) merged 719 commits into
Conversation
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 11:47
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Evidence preflight occurs after potentially mutating steps and omits shrinking survivor selections and hash-tracked skill assets, allowing uninstall to remove files or rewrite apm.yml before detecting missing evidence or edits.
3 open issues
What changed in this PR
This PR moves uninstall’s deployment-evidence check earlier to prevent partial removal when tracked files cannot safely be deleted, supporting the cleanup protections introduced for #3701.
Changes:
- Adds an evidence preflight with per-file refusal reasons and recovery instructions.
- Expands installed-CLI tests to check unchanged files on refusal and exercise recovery steps.
- Documents the intended refusal behavior and upgrade implications.
| File | Description |
|---|---|
| tests/integration/test_uninstall_refusal_lockfile_truth_lifecycle.py | Asserts manifest, lockfile, and tree remain unchanged on refusal. |
| tests/integration/test_stale_cleanup_hash_authority_lifecycle.py | Updates the expected refusal message. |
| tests/integration/test_cleanup_deployment_evidence_lifecycle.py | Adds unchanged-state and recovery lifecycle coverage. |
| src/apm_cli/integration/cleanup.py | Adds evidence refusal queries, reasons, and remedies. |
| src/apm_cli/commands/uninstall/cli.py | Checks deletion evidence before package removal. |
| packages/apm-guide/.apm/skills/apm-usage/commands.md | Updates the uninstall behavior reference. |
| docs/src/content/docs/reference/cli/uninstall.md | Documents early refusal and recovery options. |
| CHANGELOG.md | Adds an uninstall deployment-evidence upgrade note. |
Review effort: Balanced
This was referenced Nov 20, 2026
Closed
Co-authored-by: Copilot App <[email protected]>
…pack line Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json
…ns; name every credential tried Co-authored-by: Copilot App <[email protected]> # Conflicts: # src/apm_cli/core/auth.py # src/apm_cli/marketplace/version_pins.py # tests/fixtures/lifecycle_bug_ledger.json
…oject and user scope Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…le lacks deletion evidence (#3701) Co-authored-by: Copilot App <[email protected]>
…er match without a local receipt; cleanup retains files the install kept Co-authored-by: Copilot App <[email protected]>
…eny refusal Co-authored-by: Copilot App <[email protected]>
The pre-download frozen MCP check stays silent (the hydrated check and the MCP phase report parked servers); the commit gate does not repeat the org policy discovery notice. An install refuses a symlinked lockfile only when it adds or removes a dependency or updates refs, so an unchanged install still reads through it. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Register update's provenance re-verification write as a commit site of the lockfile write authority, and name the install-writes-lockfile decision in one helper the preflight guard reads. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…touched (#4318) apm update refreshes apm.yml dependencies only. With a local bundle installed it now names the bundle (from its hook ownership markers and compile staging slugs, else its file count) and gives the runnable next step: apm install <newer-bundle-file>. The lifecycle generator's strict cell rule|U8|update-leaves-a-local-bundle-untouched becomes required. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…/apm into danielmeppiel-p4-from-p3local
… writing `apm install --frozen --global` now checks each locked native plugin root against its recorded fingerprint in the frozen hash verification, before any write. A mismatch exits 1 naming the plugin, the expected and observed digests and `apm install --global`, as `apm audit --ci` reports it; nothing is written. A plain install that restores a changed root prints a [!] line. The lifecycle I1 oracle treats a path under a native_plugin root as recorded only when the same lock records that root, the observation is user scope and the tree carries the record's fingerprint. Four gate cells become required; six org-policy cells stay strict under #3703. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…hor citations (#3701) test_integrity's git-skill-hash uninstall-prune/disk-or-cache cell now expects the preflight refusal (exit 1, nothing removed). The symlinked member cell (path-containment) stays strict: the preflight skips final symlinks by design, so that uninstall still removes package sources before refusing. Generator citations follow uninstall/cli.py. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…--ci, install, --frozen and update Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/integration/test_trust_integrity_consistency_lifecycle.py
…pies that match the lock Co-authored-by: Copilot App <[email protected]>
A parked local bundle's record (#4221) lives under apm_modules/; prune now reads a directory without packages as empty. The needle for the bundle approval-key guard follows the key's helper, and the strict cells for #4169 and #4214 are removed now that both hold. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]> # Conflicts: # src/apm_cli/commands/install.py # src/apm_cli/install/phases/resolve.py # tests/fixtures/lifecycle_bug_ledger.json # tests/lifecycle/generator/rules.py # tests/quality/lifecycle_obligations.json # tests/utils/lifecycle_evidence.py
Co-authored-by: Copilot App <[email protected]>
generated_obligations.json drifted when journey known cells were dropped without --write. Regenerate it and add a test that runs the witnesses check, so a stale file fails CI. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]> # Conflicts: # src/apm_cli/install/service.py # tests/fixtures/lifecycle_bug_ledger.json
…robe cannot read the config (#4390) Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json
At user scope the install gate discovers org policy from APM_HOME, never from the HOME repository's remote (#4087). The frozen stale-decision check and the retired-hook naming discovered from the deploy root (HOME), so a HOME remote's org-deny made --frozen refuse a hook the gate still deployed (GATE user spine). Both now discover from manifest_root, as the gate does. E01 step 4's check count follows exec-status-current. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…; one row re-keyed to #4443 Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/quality/generated_obligations.json
… on a terminal and honors NO_COLOR Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json # tests/utils/lifecycle_evidence.py
…fusals as [x] errors Co-authored-by: Copilot App <[email protected]> # Conflicts: # src/apm_cli/commands/update.py # tests/lifecycle/generator/rules.py
…_status (#4053) Co-authored-by: Copilot App <[email protected]>
…acts module tests/quality/test_generated_obligations.py is not in any CI job's file list; test_promise_obligations.py runs in Architecture Ratchet Contracts. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
native.py keeps every strict cell still failing on the merged tree: the re-keyed #4444/#4445/#4446/#4447 rows and the train #3703 native-plugin rows; the #4154 and #4225 cells whose fixes are in are dropped (35 native rows: 23 pass, 12 strict xfail). Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/lifecycle/machines/test_m_source.py # tests/lifecycle/security/gate_slices/bin.py
…ble next step Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/quality/generated_obligations.json
…nt promise ids Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/quality/generated_obligations.json
…link (#4451) Cleanup keeps a claimed skill directory that holds a symlink, so uninstall removed the package's apm_modules copy and then exited 1. The evidence preflight (DeploymentEvidence.refusals) now refuses a symlinked member of a claimed directory up front, naming it and the next step. Managed final symlinks outside claimed directories keep their unlink rule. test_integrity's path-containment uninstall cell flips to required: exit 1, the reason and next step, and apm_modules, apm.yml, the lockfile and the skill directory byte-identical. Fixes #4451 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]> # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json # tests/lifecycle/generator/rules.py # tests/lifecycle/security/test_integrity.py # tests/unit/integration/test_cleanup_helper.py
5 of 10 tasks
Train-2 merged and resolved (integrity cells use the refusal oracle; both sides of cleanup_helper tests kept). Open: test_integrity on the merged tree showed 6 failures and 6 strict XPASS in train-2 cells (bundle hook retire, policy cache pin) not yet triaged. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
With #4360 on the base, install keeps an edited managed file instead of rewriting it, so remedy (a) no longer needs to move files aside first. The remedy test executes it as printed: install keeps and names the edited file (exit 1), uninstall still refuses only that file and changes nothing, and after the documented manual step uninstall completes with the user's bytes intact. Docs and the apm-guide row follow. Co-authored-by: Copilot App <[email protected]>
Steward ruling: a printed remedy must converge when executed literally. Install keeps an edited file (#4360) and exits 1, so remedy (a) moves files holding edits aside first; the remedy test runs it in printed order (move aside, install exit 0, uninstall exit 0, user bytes preserved). This reverts commit 6807592. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…4485, #4294, #4315, #4505 Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-uninstall-evidence-refusal
branch
November 21, 2026 05:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Steward ruling on the #4049 uninstall behavior: the refusal is intended and keeps exit 1, because an edited lock must never authorize deleting user bytes. This PR meets the ruling's conditions.
Nothing changes on refusal. Uninstall used to discover a missing-evidence file during target cleanup, after removing package sources and while rewriting
apm.lock.yaml. It now asks the evidence owner up front. Right after preparing deletion evidence, and before touchingapm_modules/,apm.ymlorapm.lock.yaml,_refuse_uninstall_without_evidencelists every file the uninstall would delete: claims of the removed packages and projected orphans, minus files survivors still claim, root-local files and preserved profile values. It then callsDeploymentEvidence.refusals(). Any file without evidence (edited, unproven or unreadable) stops the uninstall with exit 1; staged local refreshes are cleaned up and nothing else is written. The existing post-cleanup abort stays as a backstop for races.The message names every file and the reason, plus two runnable remedies. Both are defined once in the cleanup owner (
refusal_reason,uninstall_evidence_remedies):apm install(-gat user scope) once with access to the package source, which re-establishes deployment evidence, then rerunapm uninstall(install keeps an edited file per install overwrites user-edited managed files when no deployment receipt exists #4360, so uninstall still refuses it until it is moved aside);No force flag exists on
apm uninstall, so per the ruling no flag is added. The explicit consent path for offline sources is a 0.38 follow-up for the PM to file.Installed-CLI tests.
test_uninstall_refusal_changes_nothing_and_its_remedy_runscreates receipts through the CLI and seeds a user edit. It evicts machine state and makes the source unreachable, then asserts the refusal leaves the whole tree byte-identical, includingapm_modules/,apm.ymlandapm.lock.yaml, and that it names every file and both remedies.apm install, thenapm uninstall. The edited file is still refused and named "edited since APM deployed it", with nothing changed. After the documented manual step (move it aside), uninstall completes and the user's bytes survive.test_pre_receipt_uninstall[unavailable],test_unhashed_lock_claims_never_delete_user_files, andtest_refused_uninstall_lock_claims_only_files_on_disk. The last one now asserts lock, manifest and tree are unchanged on refusal; the old contract dropped removed files from the lock.Docs. The CHANGELOG gains an upgrade note ("After upgrading,
apm uninstallneeds deployment evidence..."). The uninstall reference and the apm-guidecommands.mdrow are updated.Issue and approved scope
Issue: Fixes #4451, fixes #4467; Refs #3701 (Part of #3701)
Human scope-approval comment: #3701 (comment). The steward ruling was relayed by the 0.37 Hardening PM.
Does this PR complete the issue, or what remains? Remaining: the 0.38 consent flag for offline or deleted sources (to be filed by the PM).
Type of change
Testing
--root ., clean), complexity ratchet (clean), pylint R0801 (10.00), auth-signal lint. This host runs no tests; the full-integration label is requested.Changelog
## [Unreleased]inCHANGELOG.md(upgrade notes).Spec conformance (OpenAPM v0.1)
#4451 fold
DeploymentEvidence.refusalsalso refuses a member of a claimed directory that was replaced by a symlink. Cleanup keeps such a directory, so without this check uninstall removed the package'sapm_modulescopy and then exited 1. Managed final symlinks outside claimed directories keep their unlink rule (unit:test_refusals_name_a_symlinked_member_of_a_claimed_directory).The installed-CLI
test_integrity_row[I|path-containment|uninstall-prune|disk-or-cache]was a strict expected failure on main and is now required. It asserts:apm_modules,apm.yml, the lockfile and the skill directory are byte-identical.Local:
test_integrity89 passed, 15 xfailed.#4467 and train-2 delta (head 6807592)
test_integrity_row[I|deployed_file_hashes|uninstall-prune|disk-or-cache]is now required and asserts exit 1, the refusal, "Nothing was removed", the printed next step, and byte-identicalapm.lock.yaml,apm.yml, the skill directory andapm_modules. The installed-CLI remedy test also refuses on the edited file with the tree byte-identical.test_integrity.py:deployed_file_hashes|uninstall-prune|disk-or-cache: train strict xfail -> required, on the refusal oracle (the oracle is stricter:apm_modulesis added to the unchanged set).path-containment|uninstall-prune|disk-or-cache: train strict xfail -> required, on the refusal oracle plus "replaced by a symbolic link" (uninstall preflight should refuse a deployed skill directory whose member is a symlink before changing apm_modules #4451).Local: lint chain clean (ruff 0.15.12 check and format, pylint R0801 10.00, auth signals, complexity ratchet). Both uninstall-prune cells pass. The remedy test passes.
Agent note, not authored by Daniel.