Repository navigation
perf(install): keep an unchanged local plugin's verified image on re-pass - #5849
Open
Daniel Meppiel (danielmeppiel) wants to merge 167 commits into
Open
Daniel Meppiel (danielmeppiel) wants to merge 167 commits into
Daniel Meppiel (danielmeppiel) wants to merge 167 commits into
Conversation
…t collected fails A required cell in tests/quality/harness_conformance.json must earn a passing receipt. Until now ReceiptWitnessPlugin only checked witnesses that passed, so a skipped witness left its required cell unproven without failing anything. - ReceiptWitnessPlugin fails a skipped or xfailed witness of a required cell (setup or call phase), naming every cell and the skip reason. A cell that no longer applies leaves through the contract (applies()), not a run-time skip. Skips of nodes that witness no required cell stay skips. - harness_ratchet.uncollected_witnesses(): every required witness node must be collected (pytest --collect-only over the witness modules), so a renamed or unparametrized witness is refused. - Mutation tests: a required witness that skips fails the gate (pytester), a skip outside required cells stays a skip, and a dropped node is named as not collected. Refs #5796 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…easured; plain skips and untracked xfails fail Refs #5796 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…quired cells A required cell's witness passes with a receipt, or is a strict KnownFailure listed in required_known_failing whose tracking equals the ledger issue, whose issue is open (closed-issue gate), and whose failure matches. Any other xfail, a skip in any phase, an uncollected node or a strict XPASS fails. The ledger only shrinks against the merge-base; a base without the section compares against the frozen 8-cell #5797 set. Refs #5796 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adds src/apm_cli/lens/: model.py, the stdlib-only interface contract of the apm list inventory (frozen dataclasses Source, Evidence, HarnessRef, Location, Item, CoverageCell, NotVisible, Inventory), and verdict.py, the only evidence -> state judgment (state, folder_content, item_state). Registers the lens-observation owner with guard registry-delegation-lens-observation: model.py imports only the standard library, only verdict.py writes an APM health state, and no lens module writes, deletes, spawns or opens a socket. One mutation case proves it. Refs #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
J13 step 1 now runs 'apm run --list' against an O1 golden captured from today's 'apm list' (the 0.39 scripts table), and asserts it runs nothing. Step 4's diagnose advice moves to 'apm run --list'. Refs #5756 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
'apm run --list' prints the 'apm list' scripts table or the No scripts found panel byte-for-byte, exits 0 and runs nothing, so bare 'apm list' can switch to the agent-config inventory. The script-not-found hint and the docs now point to 'apm run --list'. Refs #5756 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5756 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adds the test-only R0 layer of the apm list test plan: structured oracles, pending-witness promises, laws, schema, mutations and static guards. No committed cells: every HC-LIST promise stays pending-witness, so the harness ratchet is untouched. - oracles.Evidence gains json_equal and rows_equal (parsed path plus expected value), checked inside check_obligation; a mismatch or an unparseable output fails with no receipt. - tests/lifecycle/list_oracle.py is the one parser of apm list output (schema-validated JSON views; text rows by header column spans; summary and footer by exact clause and line). - HC-LIST-01..15 and HC-LIST-03.targets appended to harness_contract.py as pending-witness; HC-LIST-07 carries scopes=(user,) with a citation. - P-LAW-list.* laws in the property catalog as forward laws citing #5745; the ledger guard accepts a law only when bug-referenced or forward with a cited issue. - JSON Schema plus 4 outcome fixtures; S137 AST guard; C6 clone proof; tests/lifecycle/mutations/list.yaml. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
lens/apm_layers.py reads one scope's lockfile once and turns its deployment ledger rows into logical items: kind and name come from the target layout, rows for one physical path are deduped (targets kept apart), and projections of one package item collapse into one item with several locations. Each unique physical file is classified once through deps/file_provenance.classify_file (made public at its owner). Folder items get a bounded recursive name walk without link following: a file outside the record makes the folder modified, a partial walk leaves it unverifiable. Recorded values that escape their root are rejected lexically, before any filesystem call. 'orphaned' is not produced in 0.40 (declared is 'yes' for every locked owner). Refs #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
'apm run --list' no longer imports from list_cmd, whose scripts body goes away when bare 'apm list' switches to the inventory. The renderer lives in run.py (a new module would need an architecture owner); output stays byte-identical. The list_cmd unit cases are ported to test_run_list.py. Refs #5756 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
lens/inventory.build(ctx) reads each requested scope's APM layer once, asks the reader package for native observations (an empty scan until the readers land) and joins them: a native observation at or inside a path an APM item lists is dropped, so one physical path is one location; a scope whose lockfile is unreadable turns its native items into not-checked. APM locations take HARNESSES from the reader records and keep ledger targets apart. --target and NAME selection run before states are summarised, and under exactly one --target same-name copies get the documented ORDER (higher/lower with order_rank, coexist, or unknown; a missing copy is never ranked). The context carries the keys the renderer needs. Refs #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…es detection The build input key for the --target selection is 'harnesses' (the target vocabulary guard rejects a raw targets read in src). build() resolves the detected harnesses (signal folders at the project and home roots, apm.yml targets and ledger targets, kept to harness reader records) and passes the selection and the detected set to the readers' scan. ORDER under one target now uses the readers' tier_of and the record's ranked/coexist/unknown rule: copies in one tier tie, and a copy whose tier cannot be read is unknown. Refs #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
MCP ledger rows (uri locators under target mcp, one per runtime) become MCP claims instead of file items. The inventory joins each claim to the readers' observation of that server name for that runtime at that scope: the location takes the observed config path and entry pointer, the observation is claimed (not listed again as unrecorded), and the entry is compared with the recorded fingerprint through the ownership owner's mcp_native_hash, imported only when an entry is compared. Entry values are read only for that comparison and never returned; the item carries the readers' keys-only shape. An entry not observed is unverifiable. Refs #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mark test_run_list.py as component (it writes apm.yml and drives Click), and keep the docs truthful while bare 'apm list' still lists scripts. Refs #5756 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Run tests/quality/test_list_{conformance_guards,oracle}.py in the
ratchet contracts job (ci.yml and merge-train.yml, kept identical).
- P-LAW-list.* forward laws are phase 0: no spine transition covers them
until the list observation invariant lands.
- list_oracle: the command kind and Commands section; an empty inventory
summary has no clause; rows() refuses -v detail lines, and details()
attaches them to the row above.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
User-scope APM items now say they are declared in the $APM_HOME manifest, shown as ~/.apm/apm.yml when it sits under the home root; project items keep apm.yml. Refs #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The oracle unit test credited a pending-witness cell id; use a neutral cell id so the pending-witness leak guard stays clean. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Under -g the project scope has no root, so context.roots values may be null. Reader order rules name the item kind (skill), unlike sources (skills); HC-LIST-10 now applies where a skill rule is recorded. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…paths
- Item names drop any extension the registry gives the primitive, so one
instruction deployed as name.instructions.md and name.md is one item.
- ORDER ranks each copy by the tier of its best location the target reads;
only copies sharing a best tier tie.
- Recorded paths that map to no primitive layout, and paths not confined to
their root, are coverage cells, never a made-up 'file' item; 'canvas'
joins the kind vocabulary.
- User-scope rows under $HOME are matched under the target root install
resolves (root variables such as CLAUDE_CONFIG_DIR honoured).
- Path dedupe and the ancestor manifest hint are separator-agnostic
('../apm.yml' on every OS).
- The folder walk cap is a read_layer parameter, so tests pass it instead
of patching the owner.
Refs #5754
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Link ownership through path_security.user_owned_link, native activation keys from native_plugins.settings, no target-vocabulary reads, records.py counted as registry data by the harness-literal guard, and a vendor file name is not the removed plugin-lifecycle symbol. Refs #5746, #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…olders by descriptor Folds AUD F1-F3: the managed-settings ownership gate is re-checked on fstat, subfolders below a root are opened O_NOFOLLOW and listed by descriptor, and the tombstone exemption applies only to the quoted installed_plugins.json name. Refs #5746, #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… evidence not_visible[].os and record OS rows use linux, macos and windows (sys.platform mapped once). A plugin activation entry in a settings file now sets configured and evidence_source on the install record with the same plugin id (narrowest scope, then the file read last); an entry with no install record is one plugin item with present no. Install records carry plugin@marketplace ids. Tests are Windows-safe (bytes for frontmatter, absolute tmp system paths). Refs #5746, #5754 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ine bypass Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
force-pushed
the
pgm/5838-skip-unchanged-plugins
branch
from
December 3, 2026 18:20
6c94077 to
97d4782
Compare
Reuse must refuse a synthesized path that merely contains the staging slot (for example "<slot>-skill"), and the per-command root memo must not share an answer between two spellings of a relative root after a chdir. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reuse now refuses a synthesized path that contains the staging slot anywhere, not only as a whole segment, and resolve_root keys its memo on the absolute path so two spellings of a relative root never share an answer. Both are AUD review nits, cost 0. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
6 of 14 tasks
Re-measured every fs.scandir_calls and fs.open_reads row on the composed train-5 tip ace1dbb (Linux PR CI Lifecycle Smoke), budget = measured + 5%. The earlier rows were measured on this PR's own base, which lacked the train links underneath. Bisected per link: - #5837 (train 3 B3) lists each deployed skill root once more: install-50-skills 654 -> 704 (+50), cold/warm installs +40, install-g-50-skills +50, plugin journeys +78 / +132; - #5842 (train 5 B5) removes listings: install-g-50-skills -160, install-g-14-plugins -543, repass -1031; plugin reads -27 / -44; - no other link moves these counters; other open_reads moves are run-to-run variation of up to 3. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
On a filesystem that can clone (APFS, btrfs, xfs), normalize still copied every skill file of a local plugin image into .apm/skills byte by byte. The cells expect no byte copy there, and an independent file with nlink 1 whether the clone runs or is refused. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Normalize materializes .apm/skills with robust_copytree, which clones each file (clonefile on APFS, FICLONE on btrfs/xfs) and copies it where the filesystem cannot (ext4, Windows, any error). The view is always an independent file with nlink 1; nothing is hard-linked. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ity once - The normalization build stamp moves out of the plugin image to <cache_root>/normalized-images/<sha256(resolved path)>.build. It stores the build stamp plus the resolved image path, which must match exactly. It is written with a same-directory temp file and os.replace, and refused below any linked cache component. It is read with lstat, S_ISREG, O_NOFOLLOW|O_NONBLOCK and a bounded read; anything else is a stale build. It is removed when APM rewrites, uninstalls or prunes the image. An APM-created .apm/ in the image made validation skip plugin normalization, so declared skills never deployed. - _build_identity is computed once per process under a lock, with an explicit reset seam for tests that edit the source tree. - Seal keys are normcase-normalized; on Windows the image walk reads st_nlink through lstat because scandir reports 0. - Re-pass warning parity: images with a skills declaration stay on the full path, so their normalization and shadowing warnings repeat. - POSIX-only image cells skip on Windows. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A Windows junction lstats as a directory with st_reparse_tag set; the image walk now refuses any entry carrying a reparse tag, so a junction inside the image reads IMAGE_DIFFERS. The local _linked_below shim is replaced by integration.skill_layout.linked_below. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ing it The build stamp is a freshness hint: a stamp hit only lets the verifier try, and the source digests and the in-memory synthesis still decide. A frozen binary or an installed distribution reuses the verdict build identity; a source or editable tree is fingerprinted by each file's path, size and mtime (one lstat per file, no reads) instead of reading the whole package (~12 MB) once per process. Computed once per process under a lock, with reset_build_stamp for tests. Cells: concurrent stamps fingerprint once; a source-tree stamp reads no content; an installed build reuses the verdict identity; a plugin source edit that keeps size and mtime still fails the digest compare (unit and re-pass lifecycle). Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…o cells Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Dec 3, 2026
# Conflicts: # tests/unit/install/test_local_plugin_image.py
Seals exist only after install imports utils.sealed_files, so the manifest and receipt readers ask through yaml_io.sealed_bytes, which returns None when the registry was never loaded, and invocation_scope resets it only when present. Read-only commands such as apm list no longer import the registry (imports.list stays 111 on the train-7 tree). verdict_record stays within its LOC budget once composed. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Re-measured install-g-14-plugins and install-g-23-plugins-repass on the train-7 tip 23a1586 with this change (scratch #5859, Linux Lifecycle Smoke run 47195071297); budget = measured + max(1, 5%). - Re-pass: copytree and normalize 23 -> 0, files_written 602 -> 58, lstat, stat, scandir, realpath and open_reads tightened. - Re-pass hashed_bytes and hash_objects raised for AUD's verification (sealed members + F1 dest digest); the redundant share is removed in slice 5 (c8ec3603 plan section 20). - Fresh lstat_calls raised for the source-tree stamp fingerprint (one lstat per apm_cli file, once per process; frozen and wheel installs stat once). At 97d4782 the same tree measured 183,956,207 / 586,664,850 hashed bytes and 24,100 / 74,006 open reads: red against these rows. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical file-swap races can hang installation, follow destination symlinks, and let skill rendering overwrite verified content with forged bytes.
3 open issues
What changed in this PR
Reduces repeated local-plugin installation work for #5838 by reusing verified cached images. The supplied diff also includes related performance improvements and the read-only apm list inventory transition.
Changes:
- Reuses unchanged plugin images with sealed metadata and digest-checked copies.
- Reduces repeated imports, parsing, discovery and path resolution.
- Adds inventory contracts, regression coverage, architecture guards and documentation.
| File | Description |
|---|---|
| tests/unit/scripts/test_architecture_runner.py | Registers new guard expectations. |
| tests/unit/scripts/test_architecture_removed_plugin_tombstone.py | Tests removed-symbol detection exceptions. |
| tests/unit/scripts/test_architecture_harness_literals.py | Allows harness reader records. |
| tests/unit/lens/test_verdict.py | Tests inventory state judgments. |
| tests/unit/lens/test_model.py | Enforces lightweight model imports. |
| tests/unit/lens/readers/test_reader_records.py | Validates reader record contracts. |
| tests/unit/lens/readers/__init__.py | Adds reader test package. |
| tests/unit/lens/__init__.py | Adds inventory test package. |
| tests/unit/integration/test_hook_shared_scope_claims.py | Isolates lockfile memo coverage. |
| tests/unit/install/test_sources_selection.py | Updates install context mocks. |
| tests/unit/install/test_sources_materialisation.py | Updates materialization mocks. |
| tests/unit/install/test_build_identity_memo.py | Tests concurrent build-identity caching. |
| tests/unit/core/test_runnable_prompts.py | Updates script-listing guidance assertion. |
| tests/unit/core/test_remediation_w4_phases_targets_catalog.py | Accounts for sealed-image remediation. |
| tests/unit/core/test_remediation_commands_catalog.py | Accounts for inventory remediation. |
| tests/unit/core/test_output_mode.py | Isolates update-notice tests. |
| tests/quality/test_lifecycle_bug_ledger.py | Validates forward lifecycle laws. |
| tests/quality/test_known_cells_cite_open_issues.py | Tests forward-law issue tracking. |
| tests/quality/promise-catalog.json | Registers inventory and performance promises. |
| tests/quality/known_cell_issues.py | Tracks forward laws and harness failures. |
| tests/quality/known_cell_issue_states.json | Adds tracked issue states. |
| tests/quality/generated_obligations.json | Adds script-listing golden obligation. |
| tests/lifecycle/oracles.py | Adds parsed inventory assertions. |
| tests/lifecycle/machines/_spine_kit.py | Checks inventory against lifecycle state. |
| tests/lifecycle/list_contract/fixtures/no-match.json | Defines empty inventory example. |
| tests/lifecycle/list_contract/fixtures/error.json | Defines usage-error example. |
| tests/lifecycle/list_contract/fixtures/drift-unknown.json | Defines drift and uncertainty examples. |
| tests/lifecycle/list_contract/fixtures/clean.json | Defines clean inventory example. |
| tests/lifecycle/journeys/index.yaml | Migrates script-listing journey. |
| tests/lifecycle/journeys/goldens/J13/01.txt | Pins script-listing output. |
| tests/lifecycle/journeys/consumer/J13-run-scripts.yaml | Exercises apm run --list. |
| tests/lifecycle/driver.py | Supports global inventory invocation. |
| tests/integration/test_verdict_record.py | Resets build identity between scenarios. |
| tests/integration/test_remaining_modules_coverage.py | Updates install context mocks. |
| tests/integration/test_local_bundle_hooks_lifecycle.py | Clarifies inventory coverage in comments. |
| tests/integration/test_list_import_diet.py | Checks inventory import footprint. |
| tests/integration/test_install_sources_classification.py | Updates source-classification mocks. |
| tests/integration/test_failure_next_step_lifecycle.py | Verifies script-listing remediation. |
| tests/integration/test_coverage_phase4.py | Removes relocated script-listing tests. |
| tests/integration/test_architecture_pack_lockfile_read.py | Registers lockfile memo ownership. |
| tests/integration/test_architecture_owner_rule_mutations.py | Adds guard mutation cases. |
| tests/integration/test_architecture_outcome_guards.py | Checks warnings on plugin reinstallation. |
| tests/integration/test_architecture_lockfile_write_authority.py | Updates reader routing expectation. |
| tests/fixtures/perf/plugins.py | Builds deterministic multi-plugin fixtures. |
| tests/fixtures/perf/counters.py | Adds function-call counters. |
| tests/fixtures/perf/count_budgets.py | Adds plugin journeys and counters. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.text_json_agree.json | Defines text/JSON agreement law. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.scripts_transition.json | Defines script-listing migration law. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.read_only.json | Defines read-only inventory law. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.nondisclosure.json | Defines output disclosure limits. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.json_contract.json | Defines inventory JSON contract. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.hostile_input.json | Defines hostile-input handling law. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.honesty_vocabulary.json | Defines inventory wording constraints. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.extra_files.json | Defines extra-file detection law. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.exit_contract.json | Defines inventory exit codes. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.confinement.json | Defines recorded-path confinement law. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.ci_isolation.json | Defines CI scope isolation. |
| tests/fixtures/lifecycle_bug_ledger/property_catalog/list.audit_is_the_gate.json | Separates inventory from audit enforcement. |
| tests/fixtures/lifecycle_bug_ledger/bugs/5830.json | Records legacy-layout regression coverage. |
| src/apm_cli/utils/yaml_io.py | Serves sealed YAML bytes. |
| src/apm_cli/utils/sealed_files.py | Stores invocation-scoped verified image data. |
| src/apm_cli/utils/realpath.py | Reuses directory proofs and root resolutions. |
| src/apm_cli/utils/path_security.py | Reduces repeated HOME and root resolution. |
| src/apm_cli/utils/content_hash.py | Exposes hashed payload paths. |
| src/apm_cli/utils/atomic_io.py | Copies already-verified bytes atomically. |
| src/apm_cli/primitives/discovery.py | Shares one discovery inventory. |
| src/apm_cli/policy/__init__.py | Loads policy exports lazily. |
| src/apm_cli/models/validation.py | Skips normalization for sealed manifests. |
| src/apm_cli/models/manifest_io.py | Reads verified manifest bytes. |
| src/apm_cli/marketplace/__init__.py | Loads marketplace exports lazily. |
| src/apm_cli/lens/verdict.py | Centralizes inventory state judgments. |
| src/apm_cli/lens/ci_scope.py | Defines inventory CI detection. |
| src/apm_cli/lens/__init__.py | Introduces lightweight observation package. |
| src/apm_cli/integration/write_seam.py | Verifies sealed members before copying. |
| src/apm_cli/integration/prompt_integrator.py | Defers unnecessary link-resolver setup. |
| src/apm_cli/integration/instruction_integrator.py | Defers unnecessary link-resolver setup. |
| src/apm_cli/integration/cleanup.py | Accepts proven legacy skill members. |
| src/apm_cli/integration/base_integrator.py | Uses sealed digests for unchanged checks. |
| src/apm_cli/integration/agent_integrator.py | Defers unnecessary link-resolver setup. |
| src/apm_cli/integration/__init__.py | Loads integrator exports lazily. |
| src/apm_cli/install/verdict_record.py | Caches build identity under a lock. |
| src/apm_cli/install/sources.py | Reuses resolved local-plugin images. |
| src/apm_cli/install/source_helpers.py | Uses sealed-aware manifest loading. |
| src/apm_cli/install/run_memos.py | Centralizes install memo resets. |
| src/apm_cli/install/pipeline.py | Resets memos at pipeline entry. |
| src/apm_cli/install/phases/resolve.py | Retains eligible local images. |
| src/apm_cli/install/phases/local_content.py | Checks reuse and clears rewritten seals. |
| src/apm_cli/install/phases/finalize.py | Skips irrelevant compile-hint discovery. |
| src/apm_cli/install/phases/cleanup.py | Invalidates removed image stamps. |
| src/apm_cli/install/context.py | Tracks resolved and sealed plugins. |
| src/apm_cli/deps/registry/config_loader.py | Reuses unchanged registry YAML parses. |
| src/apm_cli/deps/registry/__init__.py | Loads registry exports lazily. |
| src/apm_cli/deps/lockfile.py | Reuses adopted lockfile snapshots. |
| src/apm_cli/deps/lockfile_write_authority.py | Invalidates memoized reads after writes. |
| src/apm_cli/deps/lockfile_read_memo.py | Caches independent lockfile snapshots. |
| src/apm_cli/deps/file_provenance.py | Exposes shared file classification. |
| src/apm_cli/core/script_runner.py | Points users to apm run --list. |
| src/apm_cli/core/remediation.py | Adds inventory and image-change guidance. |
| src/apm_cli/core/invocation_memo.py | Clears seals at invocation boundaries. |
| src/apm_cli/core/deployment_ledger.py | Reuses containment-root resolutions. |
| src/apm_cli/commands/uninstall/engine.py | Invalidates removed plugin stamps. |
| src/apm_cli/commands/run.py | Adds non-executing script listing. |
| src/apm_cli/commands/deps/__init__.py | Loads dependency commands lazily. |
| src/apm_cli/commands/_helpers.py | Defers installed-package scanner imports. |
| src/apm_cli/commands/__init__.py | Removes eager command imports. |
| src/apm_cli/cli.py | Updates dispatch and offline inventory handling. |
| src/apm_cli/bundle/__init__.py | Loads bundle exports lazily. |
| src/apm_cli/_lazy_exports.py | Provides shared lazy-export helper. |
| scripts/architecture_linter/groups/registry_delegation.py | Registers inventory ownership guard. |
| scripts/architecture_linter/checks/registry_lens_observation.py | Guards read-only inventory architecture. |
| scripts/architecture_linter/checks/registry_harness_literals.py | Recognizes harness reader records. |
| scripts/architecture_linter/checks/marketplace_bundle_and_audit.py | Exempts documented vendor filename. |
| scripts/architecture_linter/checks/install_skills_root_derivation.py | Removes legacy derivation exception. |
| scripts/architecture_linter/checks/install_manifest_snapshot.py | Requires sealed-aware manifest loading. |
| scripts/architecture_linter/checks/install_deployment_analyzers.py | Registers manifest-read guard. |
| scripts/architecture_linter/checks/contracts_lockfile_write_authority.py | Updates lockfile reader routing. |
| scripts/architecture_linter/checks/contracts_lockfile_regular_read.py | Updates regular-reader routing. |
| scripts/architecture_linter/checks/contracts_lockfile_generator.py | Updates version-warning routing. |
| packages/apm-guide/.apm/skills/apm-usage/commands.md | Documents inventory and script listing. |
| docs/src/content/docs/troubleshooting/index.md | Explains inventory versus package listing. |
| docs/src/content/docs/troubleshooting/common-errors.md | Updates script remediation guidance. |
| docs/src/content/docs/reference/targets-matrix.md | Documents legacy skill cleanup. |
| docs/src/content/docs/reference/cli/run.md | Documents --list and exit codes. |
| docs/src/content/docs/reference/cli/preview.md | Updates script-listing reference. |
| docs/src/content/docs/integrations/canvas.md | Documents installed canvas visibility. |
| docs/src/content/docs/consumer/install-packages.md | Updates script-listing command. |
| changelog.d/5852.fixed.md | Notes copy-on-write plugin cloning. |
| changelog.d/5850.fixed.md | Notes image and root-resolution safeguards. |
| changelog.d/5849.changed.md | Notes unchanged plugin-image reuse. |
| changelog.d/5843.fixed.md | Notes reduced HOME lookups. |
| changelog.d/5842.fixed.md | Notes deferred link-resolver setup. |
| changelog.d/5841.fixed.md | Notes discovery and parsing reuse. |
| changelog.d/5840.changed.md | Notes reduced install imports. |
| changelog.d/5839.fixed.md | Notes normalization and scanning improvements. |
| changelog.d/5836.fixed.md | Notes legacy skill-copy cleanup. |
| changelog.d/5812.breaking-changes-and-upgrade-notes.md | Explains script-listing migration. |
| changelog.d/5812.added.md | Announces offline configuration inventory. |
| changelog.d/5806.added.md | Announces apm run --list. |
| .github/workflows/merge-train.yml | Runs inventory quality guards. |
| .github/workflows/ci.yml | Runs inventory quality guards. |
| .apm/architecture/owners/install-deployment.json | Registers image seals and manifest guards. |
| .apm/architecture/owners/core-runtime.json | Registers lazy exports and inventory ownership. |
| .apm/architecture/owners/contracts-tooling.json | Registers lockfile read memo ownership. |
Review effort: Balanced
| import hashlib | ||
|
|
||
| try: | ||
| return hashlib.sha256(path.read_bytes()).hexdigest() if path.is_file() else None |
|
|
||
| owner = sealed_owner(source) | ||
|
|
||
| data = Path(source).read_bytes() |
| f"The cached copy of {owner} changed while it was being installed; " | ||
| f"nothing was recorded. {SEALED_IMAGE_CHANGED.sentence()}" | ||
| ) | ||
| return _copy2_bytes(source, destination, data) |
This branch has not been deployed
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
When
apm install -gis run again with the same local Claude-style plugins, a plugin whose source is unchanged now keeps its cachedapm_modulesimage. Before, every plugin was copied and normalized again on every run. Re-passing the 23 plugins of the #5838 world now normalizes none (main: 46; slice 1: 23).An image is kept only when it is exactly what normalizing the unchanged source would write. At
-g,apm_modules, the lock and the receipts are all writable by anyone who can write HOME, so the only trust anchors are the local source and a fresh in-memory synthesis by the running build:apm_modules..apm/plus the manifest equal the synthesized set..apm/skills/**is byte-equal toskills/**, andapm.ymland the skill receipt are byte-equal to a fresh in-memory synthesis (deps/plugin_parser.expected_skills_only_normalization)..apm/.buildis a freshness hint only; integrity never rests on it.After the check, the verified bytes are sealed for the rest of the command (
utils/sealed_files, cleared when each command starts and ends):read_manifest_text,load_yaml,load_yaml_roundtrip, the receipt reader) serves the verified bytes, never the file.write_seam.copy2copies a bound member only from bytes that hash to it, and writes a synthesized file from its sealed bytes.install-deployment-manifest-text-read) keeps install and the package-image readers off raw manifest reads. Its allowlist gives a reason for each exception.cost: one hash pass over each source (the floor) plus the image's raw and
.apm/parts (~8 ms on the 23-plugin world), against ~1.2 s saved.Issue and approved scope
Issue: Refs #5838
Human scope-approval comment: #5838 (comment)
Does this PR complete the issue, or what remains? No. This is slice 8 (skip unchanged local plugins on re-pass) of the #5838 floor plan, targeting train 7. It sits on the train-4 tip (#5839 + #5840), so until train 4 lands its diff against main includes them. Design and security reviews (AUD): GO at each step (d44fbae, a6d69aa, 6221211, da2f37a); this head folds F1-F3.
Type of change
Testing
Red-first: 783541a adds
tests/integration/test_local_plugin_repass_cost.py. At #5839 it fails with 23 normalizations where the cells expect 0 / 1 / 1 / 1. Cells:copy2) -> red.tests/unit/install/test_local_plugin_image.py):.apm, tampered.apm, manifest and receipt, linked root, and link plus deleted stamp, all under a current (forged) stamp;load_yaml, the dependency-only check and the round-trip reader all serve sealed bytes); F2 (a synthesized file is copied from its sealed bytes; an unbound file is refused).Each has a mutation partner that goes red.
Commands, run one at a time through the host guard:
APM_E2E_TESTS=1 pytest tests/integration/test_local_plugin_repass_cost.py tests/integration/test_local_plugin_install_cost.py -n0-> 30 passedpytest tests/unit/install tests/unit/integration tests/unit/utils tests/unit/deps tests/unit/models tests/unit/core tests/unit/agent_plugins tests/unit/test_cli_lazy_dispatch.py -n0-> 16040 passed, 47 skippedpytest tests/integration/test_architecture_owner_rule_mutations.py tests/unit/scripts/test_architecture_runner.py -n0-> 1819 passed (before the train-4 merge)relative_toguards, pylint R0801, committed symlinks, auth signals, architecture boundaries, tm006) -> all passChangelog
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)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
Agent assessment
Change confidence: medium-high. The skip crosses an attacker-writable boundary, so every reuse rests only on the source and a fresh synthesis, and every later read or copy of the image is served from verified bytes or refused. Each security property has a cell with a red mutation partner, and the security owner reviewed each step. The residual risk is breadth: a future reader or copier that bypasses
write_seamor the sealed manifest readers. The closed-world rule guards the manifest side; copies already route through the seam.