Skip to content

fix(install): install --frozen -g verifies native plugin files before writing - #4423

Merged
Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
bug-sweep/p4225
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
bug-sweep/p4225

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

apm install --frozen --global now verifies locked native plugin files before writing anything, so it gives the same verdict as apm audit --ci.

Before this change, when files under a native plugin root (~/.agents/plugins/<name>/) no longer matched the native_plugin fingerprint in apm.lock.yaml:

  • apm audit --ci exited 1 and named the plugin.
  • apm install --frozen --global exited 0, rewrote the root and printed "Deployed files verified against apm.lock.yaml".

Changes:

  • Product, frozen gate (InstallService._enforce_frozen_deployed_hashes, pre-deploy pass). It checks every locked native plugin root through claude_plugins.registrar.native_deployed_drift, which applies the fingerprint audit's drift check uses (verify_claude_native_cache).
    • A mismatch exits 1 with --frozen: deployed files do not match the hashes recorded in apm.lock.yaml.
    • Each mismatch is a reason line - native plugin '<name>' (.agents/plugins/<name>): expected sha256:..., observed sha256:...; run 'apm install --global' to restore it.
    • Nothing is written, and no "verified" or "Parked" line prints.
    • A root that does not exist yet is not a mismatch: the install deploys it.
  • Product, plain install (reconcile_claude_plugins). When apm install --global replaces a root whose locked fingerprint did not change, it prints [!] Restored ~/.agents/plugins/<name>: its files differed from apm.lock.yaml.
  • Lifecycle I1 oracle (tests/lifecycle/oracles.py, reviewed by the Stream T lead). A managed path counts as recorded only when all three hold:
    • the same lock has a native_plugin record for the root the path lies under;
    • the observation is user scope (new Observation.user_scope, default False, set by GateReplay.observe);
    • the root's tree carries the record's fingerprint.
      A mismatch is its own I1 violation, and paths outside every root still fail. 4 unit cases in tests/lifecycle/machines/test_m_gate.py, one negative per condition.

Native plugins deploy only at user scope (install/exec_gate.py plugin_bin_deployable; NativePluginRecord.root is under the user's .agents/plugins), so there is no project-scope variant.

Cells

Issue and approved scope

Issue: Fixes #4225 (scope record: #4225 (comment))

Human scope-approval comment: the scope record above.

Does this PR complete the issue, or what remains? It completes #4225. The org-policy gap at user scope stays with #3703.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally

  • All existing tests pass

  • Added tests for new functionality (if applicable)

  • Red before: APM_E2E_TESTS=1 pytest -n 0 "tests/integration/test_claude_native_hook_lifecycle.py::test_frozen_install_verifies_native_plugin_files_like_audit" failed with src/ stashed: the frozen install exited 0.

  • Green after: that test and test_plugin_with_root_skills_deploys_bin_natively_after_approve_and_trust passed (2 passed). The new test also checks:

    • paired audit --ci exits 1;
    • the frozen install exits 1 with the named reason line and restore command, prints no "verified" or "Parked" line, and leaves the changed bytes and the lock bytes as they were;
    • a plain install then restores the root with the [!] line, and a later frozen install passes.
  • Oracle unit cases: pytest -n 0 tests/lifecycle/machines/test_m_gate.py -k i1_: 4 passed.

  • Gate rows: APM_E2E_TESTS=1 pytest tests/lifecycle/security/test_gate_removal.py -k "marketplace-install and bin or native-plugin": 4 passed, 6 xfailed (strict).

  • Quality checks: pytest tests/quality/test_gate_cell_obligations.py tests/quality/test_promise_obligations.py tests/quality/test_lifecycle_bug_ledger.py: passed. tests/integration/test_native_plugin_cache_audit.py: 8 passed.

  • Lint mirror:

    • uvx [email protected] check / format --check on the changed files: passed.
    • pylint R0801: 10.00/10.
    • lint-auth-signals.sh: clean.
    • lint-architecture-boundaries.sh: exit 0.
    • check_complexity_ratchet.py --base-ref origin/main: clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

… 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]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 16:55
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

GateReplay.observe() skips fingerprint verification when a locked plugin root is deleted and no managed paths remain, allowing a missing deployment to escape detection without regression coverage.

1 open issue
What changed in this PR

This PR adds native-plugin integrity checks to global frozen installs, aligning drift rejection with apm audit --ci and addressing #4225.

Changes:

  • Rejects changed native plugin roots before deployment and reports when a plain install restores them.
  • Extends lifecycle lockfile checks to recognize fingerprint-verified native roots at user scope.
  • Adds regression coverage and updates gate expectations, leaving user-scope organization-policy failures tracked under #3703.
File Description
src/​apm_cli/​install/​service.py Adds native-plugin drift checks to frozen-install enforcement.
src/​apm_cli/​claude_plugins/​registrar.py Detects deployed drift and reports restored plugin roots.
tests/​lifecycle/​oracles.py Recognizes native-root ownership through scope and fingerprint checks.
tests/​lifecycle/​machines/​test_m_gate.py Adds native-root ownership and mismatch cases.
tests/​integration/​test_claude_native_hook_lifecycle.py Tests frozen rejection, state preservation, and restoration.
tests/​lifecycle/​security/​test_gate_removal.py Records user scope in lifecycle observations.
tests/​lifecycle/​security/​gate_slices/​native.py Promotes fixed native-plugin cases and reassigns remaining failures.
tests/​lifecycle/​security/​gate_slices/​bin.py Promotes fixed marketplace executable cases and reassigns remaining failures.
tests/​quality/​generated_obligations.json Synchronizes required cases and known failures.
tests/​fixtures/​lifecycle_bug_ledger.json Records #4225 regression coverage.
CHANGELOG.md Documents frozen-install native-plugin verification.

Review effort: Balanced

Comment on lines +422 to +423
if not under:
continue
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…plugin files before writing

Co-authored-by: Copilot App <[email protected]>

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
…LOC budget

The registrar returns DeployedHashDrift rows, so the frozen gate reports
them through its existing reason lines; each names the plugin root, both
digests and 'apm install --global'.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…plugin files before writing

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 449df96 into main Nov 21, 2026
42 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the bug-sweep/p4225 branch November 21, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The user lockfile does not record the bin/ files a marketplace plugin deployed

2 participants