Repository navigation
fix(update): adopt unchanged locked skills when receipts are missing - #3638
Daniel Meppiel (danielmeppiel) merged 6 commits into
Conversation
On a fresh clone or CI runner without local deployment receipts (for example microsoft/apm-action scheduled updates), `apm update` refused to replace committed skill files of the package it updates and left new files behind. The #3391 cold-restore rule now extends to update: a skill tree identical to what the currently locked version renders, fetched from its full-SHA locked commit, is adopted as the baseline and replaced by the new version. Lockfile hashes are never used as evidence. The adoption decision is shared by skill materialization and the read-only skill preflight, so a skill file without a trustworthy baseline is refused before any package writes: a failed update leaves the working tree and lockfile unchanged. apm-spec-waiver: local deployment receipts and receipt-less skill adoption are implementation state not covered by any OpenAPM v0.1 requirement Fixes #3625 Co-authored-by: Copilot App <[email protected]>
…ate-cold-baseline-3625
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Preflight can allow receipt-less updates that fail after partially writing files, while locked-tree link resolution can incorrectly reject unchanged skills.
2 open issues
What changed in this PR
This PR extends cold-restore skill adoption to receipt-less updates, addressing #3625 for fresh clones and CI runners. It uses the currently locked source as baseline evidence rather than trusting lockfile hashes.
Changes:
- Adds lazy retrieval of locked sources and shares adoption decisions between preflight and copying.
- Adds preflight diagnostics and an early integration exit for detected untrusted replacements.
- Adds regression coverage and documents receipt-less update behavior.
| File | Description |
|---|---|
tests/unit/integration/test_skill_preflight.py |
Tests trusted, untrusted, and locked-adoptable preflight cases. |
tests/unit/integration/test_skill_adoption.py |
Tests locked-source adoption, rejection, caching, and cleanup. |
tests/integration/test_update_receipt_less_lifecycle.py |
Adds installed-CLI update and edited-file regression scenarios. |
src/apm_cli/integration/skill_preflight.py |
Reports untrusted managed replacements before copying. |
src/apm_cli/integration/skill_integrator.py |
Uses shared adoption logic and rebasable copy filters. |
src/apm_cli/integration/skill_adoption.py |
Adds locked-source retrieval and shared tree-baseline decisions. |
src/apm_cli/integration/base_integrator.py |
Extracts the existing baseline-refusal message. |
src/apm_cli/install/template.py |
Converts untrusted conflicts into package diagnostics. |
src/apm_cli/install/pipeline.py |
Attaches locked sources to update sessions and cleans up scratch files. |
src/apm_cli/install/phases/integrate.py |
Stops integration after baseline preflight refusal. |
src/apm_cli/install/context.py |
Tracks baseline preflight refusal state. |
src/apm_cli/core/deployment_ledger.py |
Holds the session’s locked-source provider. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Documents receipt-less update adoption and refusal behavior. |
docs/src/content/docs/reference/cli/update.md |
Explains locked-source adoption during updates. |
docs/src/content/docs/reference/cli/install.md |
Adds the update exception to receipt guidance. |
docs/src/content/docs/consumer/install-packages.md |
Describes receipt-less updates in the consumer workflow. |
CHANGELOG.md |
Records the update fix and intended preservation guarantees. |
Review effort: Balanced
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Supply Chain Security Expert | 0 | 0 | 0 | Locked-source adoption uses full-SHA pins, byte-for-byte content comparison (no lockfile hash trust), fail-closed on every error path, and all-or-nothing preflight before any writes. |
| Test Coverage Expert | 0 | 2 | 0 | Both receipt-less update lifecycle regression traps pass on this head and failed on main; unit coverage thorough; no gap found. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
Zero required findings from either panelist, clean security posture, load-bearing regression traps proven on this commit. This is a scoped P0 fix inside human-approved boundaries with no breaking changes. Ship once CI is green.
Full per-persona findings
Supply Chain Security Expert
No findings.
Test Coverage Expert
- [recommended] Lifecycle regression trap covers happy-path receipt-less update replacing unchanged locked files. at
tests/integration/test_update_receipt_less_lifecycle.py
Informational positive evidence; no gap.
Proof (passed):tests/integration/test_update_receipt_less_lifecycle.py::test_receipt_less_update_replaces_unchanged_locked_files - [recommended] Lifecycle regression trap covers fail-closed path when user has edited a managed file. at
tests/integration/test_update_receipt_less_lifecycle.py
Informational positive evidence; no gap.
Proof (passed):tests/integration/test_update_receipt_less_lifecycle.py::test_receipt_less_update_with_edited_file_fails_closed
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-review-worker. This comment is AI-generated and may contain errors.
Addresses Copilot inline on skill_preflight.py:264: an identical managed member without a baseline is now refused in preflight unless copying keeps it through the raw-identical sub-skill shortcut, so a native skill whose removed file was edited cannot leave a partial failed update. Addresses Copilot inline on skill_adoption.py:240: the locked tree renders links with a resolver rooted at the locked package and projected into the current deployment root, matching what the earlier deployment wrote. Moves the update-only locked-source fetcher out of install/pipeline.py to keep it under its LOC budget, and makes the lifecycle fixture remove read-only Git packs on Windows. apm-spec-waiver: local deployment receipts and receipt-less skill adoption are implementation state not covered by any OpenAPM v0.1 requirement Co-authored-by: Copilot <[email protected]>
…ate-cold-baseline-3625
The architecture linter reserves deployment-frame projection for its owners and the pipeline ownership-snapshot shape for one canonical with block. The locked-source renderer is now BaseIntegrator.projected_resolve_links and the pipeline closes locked sources in a finally around the unchanged snapshot block. apm-spec-waiver: local deployment receipts and receipt-less skill adoption are implementation state not covered by any OpenAPM v0.1 requirement Co-authored-by: Copilot <[email protected]>
APM Review Panel:
|
Main's #3638 refuses receipt-less skill replacement before any package write. Prove that such a refusal fails the install before the lock and before the native Claude phase, so no plugin registration changes for an install a gate rejected. Mutation-break: dropping the FAILED precommit return lets resync_claude_plugins run and fails both scope cases. Addresses delta panel test-coverage-expert finding at 0d91bcc. Co-authored-by: Copilot App <[email protected]>
0.36.0 includes microsoft/apm#3638, which adopts unchanged committed skills when the local deployment receipts are missing, but only for `apm update`. After a manifest edit, `apm install` on a fresh checkout still refuses every committed file of the changed package ("no trustworthy local deployment baseline") and fails, so the dependabot#3625 workaround and the edited-file check are still needed. With them, every end-to-end scenario matches a fresh install of the new version and passes `apm install --frozen`. 0.36 also copies the source licence into subdirectory packages (microsoft/apm#3646). The copied LICENSE is recorded in `deployed_files` and `deployed_file_hashes` like any other deployed file, so the updater handles it without change. The checksums come from the release's `.sha256` files and match both downloaded archives.
…3883) On a fresh clone without deployment receipts, `apm install` after an apm.yml ref bump (the Renovate flow) refused every file of a changed skill with "no trustworthy local deployment baseline", although the committed files are byte-identical to what the currently locked version renders. The locked-source baseline from #3638 was gated on `apm update` only. skill_adoption now supplies that baseline whenever a lock entry exists and the commit being installed (installing_commit) differs from it, and skips the redundant download when they match. Lockfile hashes are still never trusted and edited files still fail closed. A new install-deployment-skill-adoption-baseline guard pins the owner. apm-spec-waiver: receipt-less skill adoption is APM deployment-state behavior with no OpenAPM requirement Co-authored-by: Copilot App <[email protected]>
* fix(install): reuse an apm_modules copy only when it matches the lock (#3884) The resolver gate (drift.should_force_ref_recheck) compared only the manifest ref with the lock, so a package copy left by an older lock was read during resolution: its outdated apm.yml widened a locked skill subset and the first `apm install --frozen` failed with "dependency selections differ", while integrate later re-downloaded the copy and a second run passed. drift.locked_copy_proof now owns "does this copy hold the locked content": git HEAD, then the .apm-pin marker naming the locked resolved_commit, then the content-hash fallback (rows without a commit or copies without a marker). The resolver gate, the parallel pre-download skip and the integrate skip all consume it. Guarded by install-deployment-locked-copy-validity. apm-spec-waiver: cache-reuse correctness fix inside the existing resolver gate; no OpenAPM contract change Co-authored-by: Copilot App <[email protected]> * fix(install): adopt locked skill output after an apm.yml ref change (#3883) On a fresh clone without deployment receipts, `apm install` after an apm.yml ref bump (the Renovate flow) refused every file of a changed skill with "no trustworthy local deployment baseline", although the committed files are byte-identical to what the currently locked version renders. The locked-source baseline from #3638 was gated on `apm update` only. skill_adoption now supplies that baseline whenever a lock entry exists and the commit being installed (installing_commit) differs from it, and skips the redundant download when they match. Lockfile hashes are still never trusted and edited files still fail closed. A new install-deployment-skill-adoption-baseline guard pins the owner. apm-spec-waiver: receipt-less skill adoption is APM deployment-state behavior with no OpenAPM requirement Co-authored-by: Copilot App <[email protected]> * fix(mcp,lsp): record ${CLAUDE_PLUGIN_ROOT} portably so frozen replay works in any clone MCP and LSP servers from Claude plugins were recorded with the placeholder expanded to the absolute apm_modules path, in apm.lock.yaml and in committed native configs. A clone at another path failed `apm install --frozen` and `apm audit --ci`, and an ordinary install rewrote committed files (#3825). - APMPackage keeps the authored placeholder in MCP/LSP declarations and binds the package root (deps/plugin_root_render.py, new owner); the lock write, --frozen comparison, audit config-consistency and native receipts all use the portable form. The extraction-time expansion path is removed. - Only target renders expand it: ${CLAUDE_PROJECT_DIR:-.} in the shared root .mcp.json (Claude Code, Copilot CLI), ${workspaceFolder} for Cursor and VS Code, ${CLAUDE_PROJECT_DIR} in the Claude LSP plugin; other targets and user scope keep the absolute path. - A lock from an earlier release holding the expanded value is equivalent (same root, or another clone's root with the same install path), so upgrades replay --frozen; the next install rewrites it once, refreshing the native receipt. - Owner registered with mutation_writes.plugin_root_render and a mutation case. Closes #3825 scope: #3825 (comment) Co-authored-by: Copilot App <[email protected]> * docs(changelog): note lock-derived expected state fixes (#3900) Co-authored-by: Copilot App <[email protected]> * fix(install): keep .apm-pin trust honest (#3884 panel folds) Folds the lean panel on #3900: - a readable .git HEAD decides alone; the marker cannot outrank it (python-architect A1); - for deployment reuse a marker counts only on rows whose content_hash is verified before the bytes are reused, so commit-only rows keep main's re-download (supply-chain S2, test-coverage T2); - sync_markers_for_lockfile stamps only copies the copy-validity owner proves (or legacy unmarked, unhashed copies), so a copy left by an older lock is never marked as current (supply-chain S1, T3); - staleness needs contradicting evidence (hash, marker or .git), so legacy unmarked, unhashed copies keep main's no-network replay (spec req-rs-015 frozen short-pin contract); - unit coverage for every owner branch, the integrate marker paths and the marker writer (T1, T2), each mutation-broken. Co-authored-by: Copilot App <[email protected]> * fix(mcp): keep pre-#3825 MCP state replayable and removable; refuse plugin-root agent export Review follow-ups for #3825 on #3900: - Ownership keeps the recorded baseline. A lock written before #3825 holds ${CLAUDE_PLUGIN_ROOT} expanded; normalizing it to the portable declaration made an unfingerprinted Claude or Cursor entry look foreign, so install reported a collision instead of migrating it. The stored baseline now proves the old write, and the install rewrites it in the portable form. - `apm install --frozen` replays a legacy-equivalent server at its recorded root (CurrentMcpConfigView.replay_recorded_roots), so native files keep matching their lock receipts and an immediate uninstall can remove them. - The legacy match accepts only a normalized absolute root (no empty, "." or ".." segments), since --frozen now writes the recorded value. - `apm pack --format agent-plugin` refuses an MCP server using ${CLAUDE_PLUGIN_ROOT}: Agent Plugins do not resolve it and the bundle does not include the plugin's files. Co-authored-by: Copilot App <[email protected]> * fix(install): .apm-pin never proves bytes about to be deployed The pre-download skip trusted a matching marker on a tampered copy and left the re-download to integrate's sequential path, which classifies a Claude plugin differently and rewrote package_type in apm.lock.yaml (test_plugin_redownload_and_update_restamp_verify_on_fresh_clone). Deployment reuse now needs the git HEAD or the verified content hash, as on main; the marker only gates resolution freshness and staleness. Co-authored-by: Copilot App <[email protected]> * fix(install): strict-by-default copy proof; marker writer asks the owner Delta panel folds on #3900: - locked_copy_proof never consults .apm-pin unless trust_marker=True, so a new deployment caller cannot trust the marker by omission; only locked_copy_is_stale (resolution freshness) opts in, and the guard rejects trust_marker=True in download/integrate (python-architect). - sync_markers_for_lockfile now asks locked_copy_is_stale instead of a second legacy rule, so a checkout whose git HEAD contradicts the lock is never stamped (python-architect, supply-chain). - Owner record text updated; unit traps for the .git staleness clause and the marker writer, each mutation-broken (test-coverage). Co-authored-by: Copilot App <[email protected]> * fix(mcp): --frozen never writes a lock-sourced plugin root A pre-#3825 lock records ${CLAUDE_PLUGIN_ROOT} expanded, and the moved-clone match accepts any normalized absolute prefix ending in the install path. The frozen replay rendered native MCP commands at that root, so lock text chose the absolute path a command runs (for example a rebuilt, uncommitted .cursor/mcp.json), and audit --ci accepted it. - replay_recorded_roots no longer renders the recorded root. It marks the server so --frozen keeps a native entry that already equals the recorded render (no new path; its lock receipt stays the uninstall proof), and every other entry gets this project's own portable render. - Ownership accepts an entry that is exactly this project's portable render of a recorded other-clone baseline (portable_rewrite_equivalent), so the portable entries a frozen install writes stay removable without a receipt. Co-authored-by: Copilot App <[email protected]> * docs(changelog): one line per #3900 change, caveat inline (#3914 rule) Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>


Description
TL;DR
On a fresh clone or CI runner without local deployment receipts (every
microsoft/apm-actionscheduled update),apm updaterefused to replace the committed skill files of the package it updates, exited 1 and left the new version's added file behind. This PR extends the #3391 / #3564 cold-restore rule to update: a skill tree byte-identical to what the currently locked version renders — fetched from its full-SHA locked commit — becomes the baseline and is replaced. Lockfile hashes are never trusted, locally edited files still fail closed, and a refusal now happens before any package writes, so a failed update leaves the tree and lockfile untouched.Problem (WHY)
main(9034594) with a local two-tag fixture:apm update --yes→ exit 1, 3 ×no trustworthy local deployment baseline, lockfile stays at v0.4.1, and?? .agents/skills/beta/added.mdis left untracked.copy_directory_fileslet sibling members (new files, adoptable skills) write before the failure, so the "No install transaction changes were committed" summary was not true for native skill files.Approach (WHAT)
skill_adoption.py: after the current-source comparison fails, compare with the locked source, materialized once per package from the lock's full-SHA commit (build_download_ref(..., require_locked=True)). Same whole-tree, claimed-in-lock, rendered-bytes rule; no lockfile hashes.apm update/install --update(ctx.update_refs), only for skills without any local receipt, fetched lazily only when the current-source comparison fails.find_unmanaged_conflicts) now reports managed files that materialization would refuse (untrusted), using the sameskill_tree_baselinesdecision. Refusals are recorded as package diagnostics and integrate returns before any package writes.Implementation (HOW)
integration/skill_adoption.pyLockedSkillSources(lazy per-owner fetch into private scratch,DeployableSourcePlanbuilt like the current plan, fail-closed on errors,close()removes scratch),locked_skill_sources(ctx)(update-only fetcher: full-SHArequire_lockedpin through the existing downloader) andskill_tree_baselines, the single decision used by preflight and copy.integration/skill_integrator.py_copy_skill_bundleroutes throughskill_tree_baselines; the copy filter exposesrebased(plan)so the locked tree uses the identical filter. Net −5 lines (file stays under the 2100-line guard).integration/skill_preflight.pySkillConflict(untrusted=True), including identical bytes unless copying keeps them through the raw-identical sub-skill shortcut.install/template.py,install/phases/integrate.py,install/context.pyskill_baseline_refusedstops integrate before any write. Unmanaged conflicts keep raising as before.install/pipeline.py,core/deployment_ledger.pyLockedSkillSourcesto the materialization session and close it in afinallyaround the unchanged ownership-snapshot block (pipeline stays under its 1000-line budget).integration/base_integrator.pyuntrusted_baseline_message()shared by copy and preflight (text unchanged);projected_resolve_links()renders the locked tree with a resolver rooted at the locked package, projected into the current deployment frame.Diagram
Legend: per receipt-less skill tree, the shared baseline decision (new behavior boxed) that both preflight and the copy step consume.
flowchart LR A["Skill tree, no local receipt"] --> B{"Equals current source render?"} B -->|yes| OK["Adopt on-disk hashes as baseline"] B -->|no| C{"apm update?"} subgraph NEW["New in this PR"] C -->|yes| D["Fetch locked full-SHA commit once"] D --> E{"Equals locked source render?"} end C -->|no| R["Refuse in preflight, write nothing"] E -->|yes| OK E -->|no| R OK --> W["Replace with new version, record receipts"]Trade-offs
deployed_file_hashes(explicitly out of scope) and journaling/rolling back native writes (a much larger transaction redesign).Benefits
apm update --yes(apm-actionupdate: true) exits 0, replaces changed skill files, adds new ones, and moves the lockfile.git statusexactly as before: no untracked leftovers, no lockfile change.Issue and approved scope
Issue: Fixes #3625
Human scope-approval comment: #3625 (comment) (Done-when and Out-of-scope followed literally: no new flags, no
--forcechange, no receipt redesign, no apm-action change, lockfile hashes never trusted).Does this PR complete the issue, or what remains? Completes it.
Note
Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.
Type of change
Testing
Scenario evidence
claude_skill) exits 0, replaces files and moves the locktests/integration/test_update_receipt_less_lifecycle.py::test_receipt_less_update_replaces_unchanged_locked_fileswindows_compat)tests/integration/test_update_receipt_less_lifecycle.py::test_receipt_less_update_with_edited_file_fails_closedwindows_compat)--force, edits, extra files or unavailable locked sourcetests/unit/integration/test_skill_adoption.py(test_update_*,test_locked_sources_close_removes_private_scratch)windows_compat)tests/unit/integration/test_skill_preflight.py::test_managed_file_without_trusted_baseline_is_refused_before_writeswindows_compat)test_cold_restore_skill_adoption_lifecycle.py,test_cold_skill_receipt_preservation.py,test_skill_materialization_receipt_lifecycle.pyCommands and results
mainbefore the fix:pytest tests/integration/test_update_receipt_less_lifecycle.py -p no:xdist→ 2 failed (exit 1 + 3 refusals;?? .agents/skills/beta/added.md).skill_tree_baselinesto skip the locked fallback → happy-path test fails (exit 1); removing the preflight refusal/early return → fail-closed test fails (M beta/SKILL.md,?? beta/added.md).origin/main:pytest -p no:xdist tests/integration/test_update_receipt_less_lifecycle.py tests/unit/integration/test_skill_adoption.py tests/unit/integration/test_skill_preflight.py tests/integration/test_cold_restore_skill_adoption_lifecycle.py→ 58 passed.pytest -p no:xdist tests/unit/install/phases/test_cleanup_phase.py tests/unit/install/test_pipeline_ownership_snapshot.py tests/unit/test_deployment_materialization_receipts.py tests/unit/test_symlink_containment.py tests/integration/test_architecture_{materialization_receipts,skill_preflight,skill_provenance_scope,shared_skill_preservation}.py→ 196 passed, 1 skipped.pytest -p no:xdist tests/integration/test_cold_skill_receipt_preservation.py tests/integration/test_cold_restore_skill_adoption_lifecycle.py tests/integration/test_skill_materialization_receipt_lifecycle.py→ 69 passed.e98b879987/5732a016f9with regressionstest_identical_member_needs_a_baseline_unless_copy_keeps_itandtest_locked_links_render_into_the_current_deployment_frame, both mutation-break verified. Exact-head (5732a01) functional set: 172 passed, 1 skipped; CI 23 pass / 3 skipping / 0 failing.lint-auth-signals.sh,lint-architecture-boundaries.sh, file-length) → clean.How to test
APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest -p no:xdist tests/integration/test_update_receipt_less_lifecycle.pysrc/changes and rerun: both tests fail as in the issue.uv run --extra dev pytest -p no:xdist tests/unit/integration/test_skill_adoption.py tests/unit/integration/test_skill_preflight.pySpec conformance (OpenAPM v0.1)
apm-spec-waiver:(local receipts and receipt-less adoption are implementation state, as in fix(install): adopt unchanged committed skills on cold restore #3564).Co-authored-by: Copilot [email protected]