Repository navigation
[0.38] feat(install): recognise earlier writes after a branch round trip (multi-hash receipt history) (#4428) - #4730
Merged
Daniel Meppiel (danielmeppiel) merged 10 commits intoNov 22, 2026
Conversation
…h round trip (#4428) Deployment receipts keep up to 8 earlier hashes per key (receipt_history.py), and DeploymentMaterializationSession trusts a file that holds one of them after the existing binding checks pass. Cleanup's receipt_hashes stays latest-only, so history is never deletion evidence. Co-authored-by: Copilot App <[email protected]>
…cs (#4428) Co-authored-by: Copilot App <[email protected]>
…y docstring (#4428) Co-authored-by: Copilot App <[email protected]>
…eipt-history # Conflicts: # tests/unit/test_deployment_materialization_receipts.py
…deletion evidence (#4428) Co-authored-by: Copilot App <[email protected]>
) Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 22, 2026 10:16
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical ownership-handoff flaw can cause older hashes to be trusted under a new owner’s binding, and the deletion-safety regression can pass without exercising cleanup.
2 open issues
What changed in this PR
This PR addresses #4428 by adding local receipt history so install can recognize earlier deployed bytes after switching branches and back, avoiding unnecessary manual recovery.
Changes:
- Retains up to eight earlier hashes per receipt and consults them for trusted overwrite baselines, not deletion evidence.
- Updates branch-switch regressions and adds coverage for history limits, malformed history, user edits, and removal safety.
- Documents the behavior and registers the history module with the deployment-state owner.
| File | Description |
|---|---|
tests/unit/test_deployment_materialization_receipts.py |
Tests historical baselines, bounded history, and invalid history rejection. |
tests/integration/test_checkout_switch_skill_lifecycle.py |
Tests branch round trips, user-edit protection, and removal safety. |
src/apm_cli/core/receipt_history.py |
Implements bounded receipt history and historical hash matching. |
src/apm_cli/core/deployment_ledger.py |
Integrates history with receipt recording, persistence, and baseline decisions. |
docs/src/content/docs/reference/cli/install.md |
Explains branch-round-trip recovery and deletion limits. |
changelog.d/4730.fixed.md |
Adds the user-facing fix entry. |
.apm/architecture/owners/install-deployment.json |
Registers history under deployment provenance ownership. |
Review effort: Balanced
…claim binding (#4428) A rewrite keeps the replaced hash only for the same key, owner and claim signature; bind_committed_claims forgets the history when it rebinds. The removal cells assert a successful install so they reach cleanup. Co-authored-by: Copilot App <[email protected]>
…eipt-history # Conflicts: # src/apm_cli/core/deployment_ledger.py
…eipt-history # Conflicts: # src/apm_cli/core/deployment_ledger.py
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The CLI documentation incorrectly excludes receipts written under another branch’s lock, although _trusted_hash() accepts earlier writes with matching installation, owner, and claim bindings.
1 open issue
Review effort: Balanced
3 of 10 tasks
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-p2-4428-receipt-history
branch
November 22, 2026 21:42
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 22, 2026
Merge main f4efa6b and fold #4730 and #4769 (bundle allow-list policy from #4677) into the [0.38.0] block. Co-authored-by: Copilot App <[email protected]>
Merged
3 of 10 tasks
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 22, 2026
Main (#4730) moved is_canonical_bundle_hash into core/receipt_history; this branch had moved it into core/deployment_state. Keep receipt_history as the single owner (deployment_state imports it) and drop the duplicate ledger helper. Co-authored-by: Copilot App <[email protected]>
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
After a branch round trip without a reinstall (install on main, install on
branch B, check out main again), a source edit to a local skill refused with
"no trustworthy local deployment baseline" and asked the user to move the
deployed skill aside. The deployed bytes were ones this installation had
written earlier, but each deployment receipt kept only the latest hash
(branch B's).
Each receipt key now keeps a short, bounded history of the hashes this
installation wrote there (
core/receipt_history.py, up toHISTORY_LIMIT= 8 earlier hashes,oldest dropped first).
DeploymentMaterializationSessionrecords it on every flushedwrite and consults it only where it already decides a trusted baseline: when
the lock no longer claims the receipt's latest hash and the file does not hold
it, bytes equal to an earlier write here are a trusted baseline. Binding rules
are unchanged (same installation identity, owner and claim signature; the lock
can only withdraw trust). The history is local state next to the receipts,
never in
apm.lock.yaml, never shared across checkouts, and never deletionevidence. A malformed history fails closed like a malformed receipt.
Issue and approved scope
Issue: Fixes #4428
Human scope-approval comment: #4428 (apm-scope:v1 record by Daniel Meppiel (@danielmeppiel); moved back to 0.38.0)
Does this PR complete the issue, or what remains? It completes the issue.
Done-when mapping:
test_source_edit_after_branch_round_trip_installs_without_recoveryloses its#4428strict-xfail marker and passes (strict xfail on main = fails there).test_user_edit_after_branch_round_trip_is_still_refused: a user edit to thedeployed skill after the same round trip is still refused with the scoped
recovery and nothing is deleted.
test_removal_after_branch_round_trip_needs_todays_deletion_evidence[member|skill]:removing a member, or the whole local skill (the uninstall of local
content;
apm uninstalltakes dependencies only), keeps the deployed bytesbecause history is not deletion evidence.
test_branch_switch_then_source_edit_never_deletes_skill_memberskeeps everynever-delete assertion; its refusal assertions now expect the install to
succeed where history proves the bytes, and the genuine edit in the other
skill is kept and named.
test_user_edit_variants_never_lose_bytes,test_member_skipped_as_modified_is_never_stale,tests/integration/test_receiptless_overwrite_lifecycle.py.Type of change
Testing
Validation evidence (host under a test cap: targeted files only, heavy suites on CI):
pytest tests/integration/test_checkout_switch_skill_lifecycle.py -n 2(real binary): 26 passed.tests/unit/test_deployment_materialization_receipts.py: earlier write is a baseline but not deletion evidence, history is bounded, an invalid history is refused.ruff check/ruff format --check(0.15.12, CI paths): clean.scripts/lint_architecture_boundaries.py --root .: exit 0.pylint R0801: 10.00/10.lint-auth-signals.sh: clean.check_complexity_ratchet.py --base-ref main: clean.check_test_assertions.py: assertion-quality ratchet clean.tests.quality.taxonomy --changed: clean.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.apm-local/, not the lockfile).