Repository navigation
fix(install): keep a drift edit of the project's own local outputs (#4873) - #4892
Merged
Daniel Meppiel (danielmeppiel) merged 8 commits intoNov 23, 2026
Merged
Conversation
…4873) OverwriteGate.keep rejected the project's own outputs (owner '.'), so a receipt-proven drift edit of a local instruction or agent errored and exited 1. Local outputs now take the shared kept-overwrite path, and the local reconcile keeps their prior local_deployed_file_hashes. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 23, 2026 01:47
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A kept local output without a prior local hash can incorrectly adopt edited bytes as its baseline during dependency-to-local overlap, requiring a hashing fix and regression coverage.
1 open issue
What changed in this PR
This PR addresses #4873 by routing the project's own local outputs through APM's shared overwrite-keep path, allowing receipt-proven drift edits to remain without failing installation.
Changes:
- Allows owner
.to use the shared keep mechanism. - Carries prior local hashes into reconciliation for kept outputs.
- Adds lifecycle coverage for preserved edits, unrelated output refreshes, and repeat-install stability.
| File | Description |
|---|---|
tests/integration/test_file_primitive_receipt_lifecycle.py |
Adds a local-edit keep lifecycle regression. |
src/apm_cli/integration/base_integrator.py |
Updates a fallback comment; no functional change. |
src/apm_cli/install/phases/post_deps_local.py |
Passes retained local hashes into reconciliation. |
src/apm_cli/install/phases/integrate.py |
Retrieves prior hashes for local-owner keeps. |
src/apm_cli/core/deployment_ledger.py |
Allows local owners through the shared keep gate. |
changelog.d/4892.fixed.md |
Documents the user-visible install fix. |
Review effort: Balanced
…ecycle helper Exclude kept local outputs from current hashing in the local reconcile, as LockfileBuilder does for dependencies, so a kept path with no prior local hash never records the edited bytes. Update the shared _run_refused helper: the project's own edited content now keeps with exit 0 (#4873). Trim the keep docstring to hold deployment_ledger.py at the 2100-line cap. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Kept dependency/local overlap paths acquire an unrebound ownership claim, causing the next install to reject the receipt and exit 1; the inventory handling and repeat-install regression need correction.
1 open issue
1 resolved since last review
Review effort: Balanced
A dependency output the project starts rendering locally after it was edited stays out of the local inventory, so its receipt's claim signature is unchanged and the next install still proves the edit (exit 0). Also pre-import apm_cli.install.audit_replay in the mock-leak guard. 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]>
Daniel Meppiel (danielmeppiel)
deleted the
cloud-4873-local-owner-drift-keep
branch
November 23, 2026 07:44
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
OverwriteGate.keeprejected the project's own outputs (receipt owner.), so a receipt-proven drift edit of a deployed local instruction or agent fell through to the error branch: install reported the edit, rolled back, and exited 1. Dependency-owned outputs already keep such an edit and exit 0 (RA-012).The fix routes owner
.through the same shared kept-overwrite path:src/apm_cli/core/deployment_ledger.py:OverwriteGate.keepno longer rejects owner..src/apm_cli/install/phases/integrate.py:_keep_prior_entriesreads a local keep's prior hash fromlocal_deployed_file_hashes.src/apm_cli/install/phases/post_deps_local.py: the local reconcile excludes kept paths from current hashing and passes the retained map ascleanup_retained_hashes, asLockfileBuilderdoes for dependencies, so a kept file keeps its prior lock hash and never records the edit's. A kept path the project did not already claim (a dependency output the project starts rendering locally after it was edited) gains no local claim, so its receipt still proves the edit on the next install.src/apm_cli/integration/base_integrator.py: comment only.tests/integration/test_required_lifecycle_state_machine.py(_run_refused) andtests/integration/test_project_self_audit_lifecycle.py: drop thelocal=Truebranch that pinned the old exit 1. A local keep now asserts the same exit 0 and warning as a dependency keep.Finalize then reports the keep (
Kept <file>: it was modified since APM deployed it.) as a warning with exit 0 fordrift, and still fails for unproven or blocking keeps, exactly as for dependencies. No parallel path.Issue and approved scope
Issue: Fixes #4873
Human scope-approval comment: #4873 (comment)
Does this PR complete the issue, or what remains? It completes it on main for every local file primitive. Local hooks and canvases join the shared gate in #4678; once that lands they inherit this keep with no further change.
Type of change
Testing
New cell
test_an_edited_local_output_is_kept_with_exit_zerointests/integration/test_file_primitive_receipt_lifecycle.py: edits a deployed local instruction and changes a local agent's source, then installs. It asserts exit 0, the keep named in output, the edited bytes unchanged, the priorlocal_deployed_file_hashesentry unchanged, the unedited local agent refreshed (control), and a repeat install that is a no-op. A second cell,test_a_kept_edit_newly_claimed_locally_never_hashes_the_edit, covers a dependency output the project starts rendering locally after it was edited: the edited hash never enters the lock, the path gains no local claim, and both installs exit 0. It fails without the change. On main it fails with exit 1 (. -- Kept .github/instructions/style.instructions.md ..., rollback).Validation evidence:
APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_file_primitive_receipt_lifecycle.py: 13 passed. Both new cells fail without the fix.uv run --extra dev pytest -n auto tests/unit: 29300 passed, 259 failed. The same failures reproduce on unmodified main: Unix install ownership, network guard, git env and transport, auth report. All are host-environment failures.uv run --extra dev pytest -n auto tests/quality: 665 passed.run_replaymock-leak guard that test: pre-load install.audit_replay so run_replay patches cannot leak (MAIN-RED FIX, #4876) #4884 fixes. It is not caused by this diff.APM_E2E_TESTS=1 ... pytest tests/integration/test_project_self_audit_lifecycle.py tests/integration/test_file_primitive_receipt_lifecycle.py: 17 passed.Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated