Repository navigation
perf(install): replay a verified unchanged local plugin's deploy instead of re-planning it - #5870
Draft
Daniel Meppiel (danielmeppiel) wants to merge 194 commits into
Draft
Daniel Meppiel (danielmeppiel) wants to merge 194 commits into
Daniel Meppiel (danielmeppiel) wants to merge 194 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>
…n records Each user-scope package verified this run gets an advisory hint record in the deploy store, keyed by its content hash: its instructions as [[name, is_global], ...] in discovery order. Finalize merges the records in discovery's walk order (first name wins) and walks only what has no record: stray files outside packages, or a package without a valid record. The hint is identical; the records decide nothing else. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Red until integrate replays verified plugins: - the 23-plugin re-pass plans only what cannot replay (discover_primitives and planned_skill_files 23 -> 0 when unchanged); - small-world cells: an unchanged plugin plans nothing and changes no byte; a deleted or edited deployed file sends only its own package down the full path; a link-rendered member takes the full path. Guards (green today, must stay green): an edit recorded in the lock too is refused as today; a path the lock adds never gets a receipt (removal keeps the user's file); an active policy still refuses a newly denied type; a scanner-critical byte still blocks; a new sibling re-renders like a fresh install; a target change re-plans. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…forged-record cells Packages kept from the previous lockfile get their hint record looked up like any other locked package. A forged record changes only the hint line; the deployed tree stays byte-identical. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…isting a package The live staging tree at the apm_modules root is scratch, not installed content, so a global instruction inside a backup no longer raises the hint. A recorded package root contributes its record after an lstat of .git, without being listed. The no-record path uses the same walk. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ing it A local skills-only plugin that resolve sealed this run skips link-resolver discovery and skill planning when its deploy is proven current (install/local_plugin_replay.py): - P3/CG1: the deployed path set is derived from the seal by the planner's own mapping (skill_preflight.skill_destinations), under this run's targets and deployment plan. - RP2/CG3: it must equal the lock row's set exactly; anything else takes the full integrate. - RP1/P7: each deployed file is read (regular, unlinked) and must hash to the sealed member digest, so a rendered member, a user edit or a missing file takes the full path. - P4: any policy in effect disables replay for the run; frozen, dry-run, --force and skill selections do too. - P5: a skill directory another package of this run deploys is never replayed. - RP5: the scanner judges the sealed bytes; any finding takes the full path, which reports it as today. - The commit gate keeps every replayed plan in its input. A replayed package records the converged full path's outcome: the same deployed values, completed reintegration and "(files unchanged)" line, and it writes nothing. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… oversize hint records Test-only. Each cell fails on its mutant: following a directory symlink, entering a universally skipped directory, accepting an int flag, and dropping the entry cap. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- N1 (AUD): a replayed package hands the sealed digests it verified to the lockfile phase (ctx.package_verified_hashes), which records them instead of re-reading the deployed files. That saves one read per file and closes the window between verification and the lock write. Cell: bytes swapped into a deployed file after verification are never recorded (mutant: re-read -> red). - The resolver never widens past the package root. Cell: a link into another plugin's root, which arrives in a later run, keeps the replayed render byte-equal to a fresh install. - template.dependency_deployment_plan is the one plan builder for skill preflight and replay (R0801 on the composed tree). - The changelog line is shortened. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- D1 (AUD): _holds computes both digests from one buffer: the raw sha256 the seal binds, and content_hash_of_bytes, the CRLF->LF hash that compute_file_hash records and apm audit verifies (apm#1952). Cell: a CRLF SKILL.md replays, its lock hash equals compute_file_hash of the deployed file, and apm audit is clean (mutant: raw digest -> red). - package_verified_hashes is write-once per dependency key. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Dec 4, 2026
…run's seal 3d (#5866) built each verified package's hint list with package_instruction_list. That rides integrate's discovery on the full path, but parses every replayed package again (23 walks on the re-pass). A replayed package now stages no fresh list. Finalize reads its stored hint record under the content hash the seal verified this run (K). A missing, corrupt or stale record walks the package (R), and the record stays advisory (A, 3d P4). Cells (3d's module, replay path): a kept record answers with no package listed; a missing, corrupt or stale record walks and still prints the hint; a forged record hides only the hint line, with deployed bytes identical. Mutant (no replay branch): these cells and 3d's test_the_install_hint_walks_no_recorded_package go red. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…age_hashes - install-g-23-plugins-repass rows re-measured on the train-11 tip cbc2f38 + #58707bed305 (scratch #5874, Linux Lifecycle Smoke run 47241016951); budget = measured + max(1, 5%). - discover_primitives and planned_skill_files 23 -> 0 - lstat 15233 -> 7877; stat 37297 -> 21034; scandir 5450 -> 4052 - open_reads 4545 -> 2682; realpath 1204 -> 696 - hashed_bytes 23.4 -> 13.8 MB; hash_objects 3365 -> 2065 - lockfile_reads 24 -> 23; path_home 71 -> 49 - Closed-world owner rule install-deployment-package-hash-writer (AUD): only source_helpers.record_package_digests writes ctx.package_hashes, which keys the lock row and the replayed hint record. Registered in _EXPECTED_RULE_ID_TEXT, with one sorted MutationCase (a second writer -> red). Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A component cell runs the two-install journey through CliRunner, so the replay owner runs in the test process and counts toward tier2 integration coverage (the gate read 69 < 70 at c0b71ac; replay ran only in subprocesses). It also covers a CRLF member. 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 4, 2026
…ured on the train-14 tree Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> # Conflicts: # tests/unit/install/test_local_plugin_image.py
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Dec 4, 2026
Re-measured on cbc2f38 + #5870c0b71ac + #5876 (scratch #5878, Linux Lifecycle Smoke run 47256467695); budget = measured + max(1, 5%). - install-g-23-plugins-repass: scandir 4052 -> 2691, stat 21034 -> 16333, hash_objects 2065 -> 1805, hashed_bytes 13758926 -> 11819456, open_reads 2682 -> 2394 (one walk per tree in the verifier). - scandir on the skill journeys (the prune folds into the copy walk): install-50-skills 704 -> 654, install-g-50-skills 704 -> 599, install-g-50-skills-linked 652 -> 547, install-g-14-plugins 3279 -> 2884. Rows within their slack, and the v0.39.2-anchored path rows, are unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replay never masks a new package. Cell: install alpha, add beta to apm.yml, install again. beta deploys byte-equal to its source and is the only package planned; alpha replays unchanged; the lock holds both (mutant: every package takes the replay branch -> red). Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
6 of 10 tasks
… seals The resolve pool can import utils.sealed_files in one thread while another reads a manifest. sys.modules then holds the module with __spec__._initializing set and its functions not yet defined, and `apm lock` failed with "partially initialized module 'apm_cli.utils.sealed_files' has no attribute 'sealed'" (Lifecycle Smoke shard 10, test_command_after_a_target_change[lock-multi-widened]). No seal exists before seal_image runs, which needs the finished module, so the one probe, utils/sealed_probe.loaded_sealed_files(), answers None for an absent or still-initializing registry. yaml_io.sealed_bytes and both invocation_scope resets use it. The utils package re-exports it so `apm list` imports no new module (111). Cells: a registry with __spec__._initializing set is never read, and load_yaml returns the file's bytes (red at f39be2b with the CI message); a fresh interpreter imports the lockfile phase, yaml_io, sealed_files and the replay owner on their own. Refs #5838 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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
Slice 8b of the #5838 install-floor plan. It stacks on #5849 (slice 8). When a local skills-only plugin's image has been verified unchanged this run, integrate now replays its previous deploy instead of re-planning it. The replay skips link-resolver discovery and skill planning, about 0.5 s of a 23-plugin re-pass (c8ec3603's profile).
The owner is
install/local_plugin_replay.py. It follows AUD's rule: the lock says WHERE to look, never WHAT is correct.skill_preflight.skill_destinations, which wraps_plan_skill_files). It uses this run's targets and deployment plan, with no discovery.--dry-run,--forceand skill selections do too.A replayed package writes nothing and records the converged full path's outcome: the same deployed values, the CompletedReintegration and the
(files unchanged)line.Further folds after review:
_holdscomputes two digests from one read: the raw sha256 the seal binds, andcontent_hash_of_bytes, the CRLF->LF lock-domain hash (apm#1952). The lock records that value (ctx.package_verified_hashes, write-once per package) instead of re-reading the deployed file.install-deployment-package-hash-writer, makessource_helpers.record_package_digeststhe only writer ofctx.package_hashes.Follow-up (deferred): on the 23-plugin re-pass, finalize spends 5-9 ms reading one hint record per replayed package (was ~1 ms).
Scope note: this covers the skills-copy route only. At project scope, a
.claude-pluginplugin with targets claude or copilot takes the native route, which plans no skills.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 8b (no-op integrate for verified unchanged plugins). It stacks on #5849 (train 8), so until #5849 lands its diff against main includes #5849. The design was approved by AUD (RP1-RP7, CG1-CG3) and c8ec3603; the PGM lead ruled the skip-planning design. It merges the signed real head #5866327adcd (train 11). Rows are measured on the train-11 tip cbc2f38 + this head (scratch #5874, Linux Lifecycle Smoke run 47241016951). The re-pass rows tighten: discover_primitives and planned_skill_files 23 -> 0, lstat 15,233 -> 7,877, stat 37,297 -> 21,034, open_reads 4,545 -> 2,682, hashed_bytes 23.4 -> 13.8 MB.
Type of change
Testing
Evidence (local runs through local-test.sh, sequential):
test_repass_plans_only_what_cannot_replayand 4 replay cells were red (discover_primitives / planned_skill_files 23 -> 0; small world 2 -> 0 / 1).tests/integration/test_local_plugin_replay.py25 passed.KNOWN_TARGETSskills target. Every skills-copy target replays with byte-identical project state (deployed trees, lock, receipts).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)
Agent assessment