Repository navigation
fix(install): adopt unchanged committed skills on cold restore - #3564
Merged
Daniel Meppiel (danielmeppiel) merged 6 commits intoNov 12, 2026
Merged
Daniel Meppiel (danielmeppiel) merged 6 commits into
Daniel Meppiel (danielmeppiel) merged 6 commits into
Conversation
When local deployment receipts are missing (fresh clone, CI runner, Renovate), a native skill or skill bundle directory is adopted when every file equals what this install would write -- the admitted source member after final link rendering -- with no extra or missing files and every member claimed in apm.lock.yaml. The verified on-disk hash stands in for the missing baseline, so the guarded write path rewrites identical bytes and records receipts. Lockfile hashes are never used as evidence; any difference keeps the #3372 fail-closed refusal (#3490). apm-spec-waiver: local deployment receipts and cold-restore skill adoption are implementation state not covered by any OpenAPM v0.1 requirement Fixes #3391 Co-authored-by: Copilot App <[email protected]>
Same-run session hashes from the raw unchanged shortcut are not ownership evidence; adoption now requires every member to be claimed by apm.lock.yaml so unowned identical files never gain receipts. apm-spec-waiver: local deployment receipts and cold-restore skill adoption are implementation state not covered by any OpenAPM v0.1 requirement Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 11, 2026 14:58
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The adoption flow can overwrite unverified edits through a baseline-hashing race, grant receipts to initially unowned skills, and accept incompletely inspected trees.
3 open issues
What changed in this PR
This PR restores cold installs of unchanged, committed skills for fresh clones and CI runners, while preserving the fail-closed behavior introduced by #3490 for conflicting content.
Changes:
- Compare complete skill file trees against rendered package output before adopting lockfile-claimed files and recording receipts.
- Add cold-restore, edited-file preservation, and ownership regression coverage.
- Document adoption requirements and recovery behavior in the CLI reference, consumer guide, and packaged usage guide.
| File | Description |
|---|---|
src/apm_cli/integration/skill_adoption.py |
Adds rendered-tree comparison and adoption baseline helpers. |
src/apm_cli/integration/skill_integrator.py |
Integrates adoption into guarded skill writes and shares Markdown rendering. |
tests/unit/integration/test_skill_adoption.py |
Covers tree equality, rendering, symlinks, and ownership requirements. |
tests/unit/test_deployment_materialization_receipts.py |
Checks repeated unowned delivery does not create receipts. |
tests/integration/test_cold_restore_skill_adoption_lifecycle.py |
Exercises fresh-clone restoration and edited-file refusal through the installed CLI. |
tests/integration/test_cold_skill_receipt_preservation.py |
Updates overlapping replay expectations for unchanged skills. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Documents cold-restore adoption in the packaged guide. |
docs/src/content/docs/reference/cli/install.md |
Explains adoption alongside local receipt protections. |
docs/src/content/docs/consumer/install-packages.md |
Describes successful adoption and fail-closed recovery. |
CHANGELOG.md |
Records the cold-restore fix and its limits. |
Review effort: Balanced
| ) | ||
| if not all(owned(path) for path in members): | ||
| return {} | ||
| return {path: compute_file_hash(path) for path in members} |
| member = Path(directory) / name | ||
| expected[destination / member.relative_to(source)] = member | ||
| actual: set[Path] = set() | ||
| for directory, directories, filenames in os.walk(destination): |
Comment on lines
+496
to
+499
| def claimed(path: str) -> bool: | ||
| return managed_files is not None and ( | ||
| path in managed_files or (path == anchor and directory_entry in managed_files) | ||
| ) |
A warm replay whose receipt exists but yields no trusted baseline (for example root-local skills) keeps the raw unchanged shortcut, so frozen replays no longer rewrite receipt state. Adoption now applies only when no receipt record exists for the skill anchor. apm-spec-waiver: local deployment receipts and cold-restore skill adoption are implementation state not covered by any OpenAPM v0.1 requirement Co-authored-by: Copilot App <[email protected]>
Keep the PR changelog bullet under [Unreleased] after the 0.35.1 release cut. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-fix-3391-adopt-committed-skills-cold-res
branch
November 12, 2026 09:03
This was referenced Nov 12, 2026
5 of 11 tasks
This was referenced Nov 15, 2026
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
TL;DR
On a fresh clone or CI runner with no local deployment receipts,
apm install/apm install --frozennow keeps committedclaude_skillandskill_bundleoutput whose whole directory equals what the install would write (after link rendering) and records receipts, restoring the 0.34.0 behavior that Renovate and CI depend on. Anything that differs keeps #3490's fail-closed path: no overwrite, no deletion, nonzero exit with guidance.Fixes #3391
Important
Lockfile hashes are never adoption evidence. The proof is the on-disk tree compared against freshly materialized package source; the lockfile only supplies ownership claims (paths), as the existing collision gate already requires.
Problem (WHY)
main(77708eb7): coldapm installin a fresh clone of a repo with a committed native skill exits 1 withSkipped .claude/skills/<pkg>/SKILL.md: no trustworthy local deployment baselinefor every file, although the bytes are identical to the package source.obra/superpowers#v7.0.0(skill_bundle): 34 refusals. Bundles already had a raw-identity shortcut, but committedSKILL.mdfiles are the link-rendered output (../requesting-code-review/…is rewritten), so raw comparison never matches.--forceis not an option for Renovate or cloud agents, and after fix(install): preserve skills during cold replay without deployment receipts #3490 the failure blocks every lockfile restore of committed skills.The approved scope asks to adopt such files "matching the existing .apm sub-skill adoption (is_skill_dir_identical_to_source)", while "any file that differs keeps the #3372 fail-closed path" (scope record).
Approach (WHAT)
apm.lock.yaml; same-run session hashes are not ownership evidence.session.recordwrites receipts. No new authority path.SKILL.mdhas no receipt record at all (DeploymentMaterializationSession.has_receipt), so warm installs and replays whose receipt exists but is untrusted keep today's behavior and never rewrite receipt state.Implementation (HOW)
src/apm_cli/integration/skill_adoption.py(new)adoptable_skill_members(strict tree equality against rendered output),adoption_baselines(ownership-gated hashes), sharedrender_skill_markdown; the rawis_skill_dir_identical_to_source/dircmp_equalhelpers move here unchanged (keepsskill_integrator.pyunder the 2100-line cap).src/apm_cli/core/deployment_ledger.pyhas_receipt(path): whether any receipt, trusted or not, exists for a physical path.src/apm_cli/integration/skill_integrator.py_copy_skill_bundlecomputes adoption baselines before copying, falls back to them inbaseline_hash, and disables the rawunchangedshortcut only when adoption applies._resolve_markdown_links_in_skill_bundleuses the shared renderer so the comparison and the write cannot drift.tests/integration/test_cold_restore_skill_adoption_lifecycle.py(new,lifecycle_smoke, installed CLI)claude_skill/skill_bundlepackages (noapm.yml, bundle with a rendered link), committed, cloned, machine state evicted;installand--frozen.tests/integration/test_cold_skill_receipt_preservation.pytests/unit/integration/test_skill_adoption.py,tests/unit/test_deployment_materialization_receipts.pyapm-usage/commands.mdDiagrams
Legend: the cold-restore decision inside
_copy_skill_bundle; dashed nodes are new, every other node is existing #3490 behavior.flowchart LR A["_copy_skill_bundle"] --> B{"any receipt for SKILL.md?"} B -->|"yes (warm)"| W["guarded write as before"] B -->|"no (cold)"| C["adoptable_skill_members: tree == rendered output?"] C -->|"no: extra, missing or edited file"| R["refuse member, nonzero exit (#3490)"] C -->|yes| D{"every member claimed in apm.lock.yaml?"} D -->|no| R D -->|yes| E["on-disk hash becomes baseline"] E --> F["guarded write rewrites identical bytes"] F --> G["session.record: receipt written"] classDef changed stroke-dasharray: 5 5; class C,D,E changed;Trade-offs
test_missing_receipt_errors_reach_install_from_every_skill_targetstill requires nonzero).copy_directory_filesand records receipts through the one existing owner; only mtimes change..apmsub-skills benefit too when their committed copy is link-rendered. Their raw-identity shortcut is unchanged, including for unowned files (no receipts).--force, receipt root identity ([BUG] apm install -g fails with 'installation binding does not match' after a reboot when home is a btrfs subvolume #3421), other primitive types, and cold upgrades whose source changed (still fail closed per fix(install): preserve skills during cold replay without deployment receipts #3490).Benefits
apm installand--frozenexit 0 for unchanged committedclaude_skillandskill_bundleoutput, withgit statusclean andapm audit --cigreen.--force.Issue and approved scope
Issue: Fixes #3391
Human scope-approval comment: #3391 (comment) (approved by Daniel Meppiel (@danielmeppiel) at Gate B on 2026-11-10, held until #3490 merged on 2026-11-11).
scripts/governance/eligibility.cjsat77708eb7returnedrecord-present.Does this PR complete the issue, or what remains? It completes the approved scope. Cold upgrades with changed source remain fail-closed by design (#3372 / #3490).
Type of change
Testing
Validation
APM_BINARY_PATH=$PWD/.venv/bin/apm python -m pytest -n 8 tests/integration/test_cold_restore_skill_adoption_lifecycle.py tests/integration/test_cold_skill_receipt_preservation.py tests/integration/test_obsolete_dependency_claim_lifecycle.py tests/integration/test_shared_skill_preservation_lifecycle.py(head94603866)python -m pytest -n 8 tests/unit/test_deployment_materialization_receipts.py tests/unit/integration tests/unit/install(head94603866)python -m pytest -n 8 tests/unit tests/test_console.py(first commit)test_manifest_extension_keys::…warns_once_per_invocation,test_targets_phase::…names_config_source), both pass when rerun alone and touch no skill codepython -m pytest -n 8 tests/qualitypython scripts/check_test_assertions.py/scripts/check_exact_test_duplicates.pyPATH=.venv/bin:$PATH APM_E2E_TESTS=1 python -m pytest -n 8 --dist loadgroup -m 'lifecycle_smoke and not lifecycle_merge_group' tests/integration(head1f6d1207)… pytest -n 8 tests/integration/test_frozen_no_rewrite_e2e.py <cold-skill suites> tests/unit/test_deployment_materialization_receipts.py tests/unit/integration tests/unit/install(head1f6d1207)lint-auth-signals.sh,lint-architecture-boundaries.sh, file length,relative_toguardskill_integrator.pyis 2099 linesMutation and real-package evidence
skill_integrator.pytomain: the 4test_fresh_clone_adopts_unchanged_committed_skillscases fail with[x] 1 package failed:; the 4 edited cases still pass, so the byte-identical case fails on currentmain.test_frozen_no_rewrite_e2e.py::test_frozen_install_fails_on_unrecorded_skill_without_rewriting_lockfilecaught an intermediate version that bypassed the raw shortcut whenever the baseline was untrusted (receipt file rewritten on a converged frozen replay); gating on receipt absence (1f6d1207) fixes it.test_repeated_identical_unowned_delivery_does_not_create_local_authorityfailed (assert not True: receipt written) before the lockfile-claim fix in94603866, and passes after it.HOME, local CLI build:obra/superpowers#v7.0.0(skill_bundle):apm installreturned exit 1 with 34 refusals onmain; on this branch it returns exit 0 andgit status --shortis empty.Aaronontheweb/dotnet-skills/skills/aot-trimming#v1.7.1(claude_skill):apm install --frozenreturns exit 0,git status --shortis empty, andapm audit --ci --no-policyreportsAll 10 check(s) passed.Scenario Evidence
apm installor--frozen: exit 0, bytes and lock intact, receipts recorded, audit greentests/integration/test_cold_restore_skill_adoption_lifecycle.py::test_fresh_clone_adopts_unchanged_committed_skills…::test_fresh_clone_with_edited_skill_fails_closed,test_cold_skill_receipt_preservation.py::test_cold_overlapping_skill_replay_preserves_files_and_lock[*-edited-*]test_cold_skill_receipt_preservation.py::test_missing_receipt_errors_reach_install_from_every_skill_targettests/unit/test_deployment_materialization_receipts.py::test_identical_unowned_members_do_not_create_local_authority,…::test_repeated_identical_unowned_delivery_does_not_create_local_authority--global) replay of unchanged skills succeedstest_cold_skill_receipt_preservation.py::test_cold_overlapping_skill_replay_preserves_files_and_lock[*-unchanged-*]How to test
APM_BINARY_PATH=$PWD/.venv/bin/apm uv run --extra dev pytest -q tests/integration/test_cold_restore_skill_adoption_lifecycle.py→ 8 passed.apm installa dependency onobra/superpowers#v7.0.0, commit,git cloneit, thenHOME=$(mktemp -d) apm installin the clone → exit 0 andgit status --shortis empty.SKILL.mdin the clone and repeat → nonzero exit,no trustworthy local deployment baselinewith "Move the conflicting file aside and retry", and the edit is preserved.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedreq-tg-009covers agent adoption only); the commits carry anapm-spec-waivertrailer.Co-authored-by: Copilot [email protected]