Skip to content

Owner moves: install and uninstall commit order, install entry routing (H2b) - #4255

Merged
Daniel Meppiel (danielmeppiel) merged 132 commits into
mainfrom
danielmeppiel-h2b-install-commit
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 132 commits into
mainfrom
danielmeppiel-h2b-install-commit

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Trust and integrity consistency hardening (owner consolidation), part of 0.37. H2 in one PR (supersedes #4138): install entry routing, install and uninstall commit order, and the lockfile write authority.

  • install-commit-order (install/commit_gate.py): every check completes before apm.lock.yaml and deployed files are committed. Merged direct + transitive MCP policy and require_hashes run after every package is acquired and before the first deployed byte; require_hashes runs again on the built lockfile before it is written. A failing check leaves the lockfile and deployed files byte-identical.

  • install-entry-routing: install --dry-run runs run_install_pipeline(dry_run=True) (resolution into rollback staging, policy gate and commit gate in preview mode, stop before the first write); ProspectiveInstallPlan projects that plan instead of running a second resolver.

  • lockfile-write-authority (deps/lockfile_write_authority.py): one write authority for apm.lock.yaml with a closed set of writer scopes (including apm compile); each command commits the lockfile once, deployment receipt claims bind only after that commit, and early flushes are limited to a closed set of sites. SIGINT and SIGTERM before the commit unwind as a failure: the staged lockfile is discarded and the audit-gated deploy snapshot is restored.

  • Also included: With nothing declared, install writes no lockfile, so install --frozen fails while audit --ci passes #4050 (--frozen with nothing declared is a converged no-op, matching audit --ci), install that retires the last deployed file removes the empty target root; the next install recreates it #4132 (cleanup keeps project-layout target roots such as a pre-existing .github/), install -g drops a transitive relative-path dependency without a diagnostic #4153 (transitive relative local paths at user scope), apm update reports an unchanged ref-less dependency as updated on every run #4166 (apm update on a ref-less dependency changes nothing until its default branch moves), Garbage-collect orphaned deployment receipts whose project root no longer exists #4176 (deployment receipts of deleted projects are collected), and Install that fails at the lockfile or MCP config write keeps the deployed files of the failed attempt #4164 (after a killed install, audit --ci reports the unrecorded state and the next install adopts matching bytes, including rendered commands).

  • Audit-gated deploy snapshot owned by InstallTransaction (install/deploy_snapshot.py): when the install-time content audit can block, every path integration can write in this install is captured before the integrate phase; a block restores it byte for byte (the lockfile is already discarded through its writer scope). No copy is taken while the audit is off.

  • apm install --mcp and apm mcp install judge org MCP policy through the commit gate (enforce_mcp_policy) and print the same refusal as apm install.

  • Uninstall refuses out-of-project paths before any change, and resolves the remaining packages' trust before its first write; a refusal leaves apm.yml, the lockfile and deployed files unchanged. A removed package's skill directory that holds only user content is released, as apm prune does.

  • apm install refuses a symlinked apm.lock.yaml before it deploys anything.

  • A failed install removes target root directories it created that are left empty (for example .github/), and an org-policy refusal after the lockfile is staged discards it while the deploy restore puts disk back: the lockfile matches disk after every exit.

Reviewer note (#4132): tests/integration/test_mcp_pruned_runtime_dir_cleanup_lifecycle.py asserts that an emptied opt-in .claude/ or .opencode/ root survives, with every MCP-cleanup assertion kept; user-scope roots APM created are removed.

Reviewer note: the snapshot covers each active target's primitive folders and skills root, merged hook configs, every path the previous lockfile records, .gitignore, .apm-local/ and the receipts file; it does not snapshot whole user-scope roots such as ~/.claude to avoid undoing unrelated concurrent writes.

Issue and approved scope

Part of #4085 (scope record: #4085 (comment))
Fixes #4086 (scope record: #4086 (comment))
Fixes #4050 (scope record: #4050 (comment))
Fixes #4132 (scope record: #4132 (comment))
Fixes #4153 (scope record: #4153 (comment))
Fixes #4166 (scope record: #4166 (comment))
Fixes #4176 (scope record: #4176 (comment))
Fixes #4185 (scope record: #4185 (comment))
Fixes #4162 (scope record: #4162 (comment))
Fixes #4168 (scope record: #4168 (comment))
Fixes #4159 (scope record: #4159 (comment))
Fixes #4164 (scope record: #4164 (comment))
Fixes #4299 (scope record: #4299 (comment))

Does this PR complete the issue, or what remains? It completes #4086, #4050, #4132, #4153, #4166, #4176, #4185, #4162, #4168, #4159, #4164 and #4299. #4085 is closed by hand after this lands, with a verification comment; its bundle entry admits through install/bundle_admission.py (landed with #4157). Ordering of service reconciliation before the post-install and native-registration commit points is tracked in #4319.

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, green after (installed CLI):

  • tests/integration/test_install_commit_order_lifecycle.py::test_audit_block_keeps_previous_install_byte_identical
  • tests/integration/test_install_commit_order_lifecycle.py::test_audit_block_on_fresh_project_commits_nothing
  • tests/integration/test_install_commit_order_lifecycle.py::test_audit_block_sees_hidden_character_only_in_transformed_output
  • tests/integration/test_install_commit_order_lifecycle.py::test_direct_mcp_entry_reaches_the_install_policy_verdict
  • tests/integration/test_uninstall_refusal_atomicity_lifecycle.py
  • tests/integration/test_install_symlinked_lockfile_lifecycle.py
  • tests/integration/test_install_commit_order_lifecycle.py::test_failed_install_removes_the_target_root_it_created
  • tests/unit/deps/test_lockfile_write_refusal.py

Changelog

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

Spec conformance (OpenAPM v0.1)

  • N/A -- enforces the existing req-pl-002 commit order; no spec text change.

apm-spec-waiver: owner consolidation that enforces the existing req-pl-002 commit order; no new normative behavior

Output-oracle cell #4334 (install-verbose-diagnostics-repeat)

Version output regex Disposition
Original (same as #4338's) ^\s*((?:Package target restriction|\[i\] perf: )[^\n]*)$.*^\s*\1$ Kept
Tightened (withdrawn) ^\s*(\[i\] perf: [^\n]*)$.*^\s*\1$|^\s*(Package target restriction[^\n]*)\n\s*\2$ Withdrawn: it missed a terminal-wrapped restriction line, so it was weaker than the original

Add install/commit_gate.py as the single owner of the checks that guard
the two install commit points. The merged direct and transitive MCP
policy and require_hashes now run after every package is acquired and
before the first deployed byte; require_hashes runs again on the built
lockfile before it is written. A failing check leaves apm.lock.yaml and
deployed files unchanged.

Refs #4085

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Add the lockfile-write-authority owner: a closed set of writer entry
points (install, install --mcp, local bundles, lock, update, uninstall,
prune, compile) that each commit apm.lock.yaml at most once per command.
LockFile.write stages inside a writer scope and LockFile.read sees the
staged document; removal and rollback route through the owner. Compile
refuses a lockfile it may not rewrite before changing files.

Guarded by contracts-tooling-lockfile-write-authority with a mutation
case, installed-CLI write-count tests and a writer mapping test.

Refs #4086

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Scopes open at a command's first lockfile write, so the newer-generator
gate always refuses first; a failed or interrupted command discards what
it staged. Adds per-sub-check guard mutations, a shrink-only commit-site
baseline, and installed-CLI proofs for frozen, failure and MCP+LSP
installs.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The preview now runs run_install_pipeline(dry_run=True): resolution into
rollback staging, the policy gate and the commit gate in preview mode,
then it stops before the first write. ProspectiveInstallPlan projects
that plan instead of running a second resolver, so dry-run and install
reach the same decisions. Extract the skill path migration phase and the
preserved-install hint to keep module budgets.

Refs #4085

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…d CLI

Run each writer in the closed set against a newer-generator lockfile and
assert no write, no file change and an unchanged manifest; keep policy on
in the lifecycle tests; leave install/phases/lockfile.py untouched (its
LOC budget), relying on the authority's read-through.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
With no APM, MCP or LSP dependency declared, apm install writes no
lockfile. One owner (install/plan.py manifest_requires_lockfile) now
answers whether a missing lockfile is converged, for both
apm install --frozen and the audit lockfile-exists check, so the two
agree at project and user scope. Removes the GATE machine's known cell
for this disagreement.

Refs #4050

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
… package at user scope (#4153)

A relative local_path declared by a dependency now resolves against the
declaring package at every scope via deps/path_anchoring.local_dep_base_dir.
An unresolvable transitive local dependency fails the install with a clear
error instead of being dropped silently.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…ecorded ref (RA-007)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
)

Add install-deployment-lockfile-required: manifest_requires_lockfile is
the one owner, and enforce_frozen, frozen service integration and the
audit lockfile-exists check route through it; no other function
re-derives the answer. Registered on frozen-install-mutation-eligibility
with a mutation case.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Add install-deployment-cleanup-target-roots: cleanup_empty_parents stops
at every target root, and integration/install-phase modules remove
directories only through it or a closed set of owned-directory
removals. Mutation case, ledger row and changelog.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Add closed-world rules install-deployment-install-entry-routing and
install-deployment-install-commit-order with mutation cases, register the
install-entry-routing and install-commit-order owners (InstallTransaction
included), and record the #4085 ledger row.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Installed-CLI parametrized test: valid, unknown, all, MCP-only runtimes
(intellij, copilot-app), a target outside the project's active set, a
path-like value and malformed shapes give the same exit code and reason
for dependencies.apm and dependencies.mcp, and refusals change nothing.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Resolve tests/utils/lifecycle_evidence.py: the #4299 strict cell (widened by
#4386) stays deleted because this PR fixes #4299; the #4386 unit test now
asserts the transitive parked-MCP repeat is a plain I9 failure.

Co-authored-by: Copilot App <[email protected]>
- The commit gate does not repeat the policy-disabled notice.
- An unreadable MCP client config is reported once per file.
- A dry run leaves no new user state directories or version pins.
- An unchanged install reads through a symlinked lockfile; a planned
  change refuses before deploying.
- A failed lockfile commit names apm.lock.yaml.
- Re-point guard mutation fragments and align tests with #4153, #4166
  and #4185; drop the output cells for #4241 and #4249, which pass.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The pre-download frozen MCP check stays silent (the hydrated check and the
MCP phase report parked servers); the commit gate does not repeat the org
policy discovery notice. An install refuses a symlinked lockfile only
when it adds or removes a dependency or updates refs, so an unchanged
install still reads through it.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…nstall entry routing (H2b) (train resolution 9cb8cde by H-D)

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

# Conflicts:
#	tests/lifecycle/generator/rules.py
#	tests/quality/lifecycle_obligations.json
#	tests/unit/integration/test_content_identical_adopt.py
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…ckstop

An install interrupted by SIGTERM at its commit point without a deploy
snapshot leaves deployed files the lockfile does not record (strict cell
keyed to #4282); apm audit --ci reports the drift, the next install
converges, and a repeat install changes nothing.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…nstall entry routing (H2b) (train resolution c640a18 by H-D)

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

# Conflicts:
#	tests/lifecycle/generator/rules.py
#	tests/unit/integration/test_content_identical_adopt.py
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…nstall entry routing (H2b) (train resolution 1b72766 by H-D)

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…nstall entry routing (H2b)

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
#4255)

#4255 passed logger=None to the pre-pipeline admission check to avoid a duplicate parked notice; #4440 owns that with without_parked_notices(), which drops only parked notices and keeps the cold-cache verbose log that test_frozen expects. Verified by #4440's owner (bcb09e24): the notice prints exactly once and both unit tests pass.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit cb7d6d8 into main Nov 21, 2026
1 check passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-h2b-install-commit 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

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

2 participants