Skip to content

fix(install): --frozen refuses a dropped target before any write (#4517) - #4519

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
train/0.37-final-2from
bug-sweep/p4517
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
train/0.37-final-2from
bug-sweep/p4517

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Fixes #4517 (scope record: #4517 (comment))

Description

When apm.yml drops a target but apm.lock.yaml still records that target's files, apm install --frozen used to delete those files and then exit 1 ("files recorded in apm.lock.yaml are missing"). A failed command changed bytes on disk. Meanwhile apm audit --ci passed the same state, so the two disagreed (I3).

The contract the steward approved: no deletion before the gate passes, and --frozen never writes when it refuses.

  • One predicate: install/manifest_reconcile._dropped_target_of is the dropped-target classifier. The target-contraction owner (reconcile_target_deployed_files) now uses it too, so there are no parallel copies. dropped_target_files(project_root, lock) exposes it.
  • Frozen refusal before any write: InstallService.enforce_frozen calls _refuse_frozen_dropped_targets before the pipeline. It exits 1 naming the target and each recorded file, with the catalog remedy FROZEN_TARGET_DROPPED: "Run 'apm install' to retire the dropped target and update apm.lock.yaml (without --frozen, ...), then commit apm.lock.yaml."
  • Audit agrees (I3): a new block-level baseline check lockfile-targets-current runs after no-orphaned-packages. It uses the same owner and the same remedy.
  • Docs: baseline-checks.md, lockfile-spec.md, the install reference and the apm-usage governance.md are updated.
  • Fixtures: the exact ordered check lists (test_ci_checks, test_audit_policy_command, the state machine) gain the new check. The journey goldens and yaml counts (P02, J11, E01 x2) are pure +1-check deltas, approved by the steward.

Issue and approved scope

Issue: Fixes #4517

Human scope-approval comment: #4517 (comment)

This PR completes the issue. Out of scope, per the record: passing --frozen when only the dropped target's files are missing (rejected), and changes to non-frozen retirement.

Type of change

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

Testing

  • Tested locally (single targeted node through the host guard; CI validates the rest per the host emergency)
  • All existing tests pass (CI)
  • Added tests for new functionality (if applicable)

New installed-CLI cell: tests/integration/test_frozen_dropped_target_lifecycle.py::test_frozen_refuses_a_dropped_target_with_zero_writes_and_its_remedy_runs (lifecycle_smoke). It steps through:

  1. Install with targets [copilot, claude], then confirm it is converged: --frozen and audit --ci both pass and change no bytes.
  2. Drop claude.
  3. --frozen exits 1 and the project tree (lock, deployed files, apm_modules) is byte-identical. The output names the target and .claude/rules/one.md (target claude) and prints the remedy exactly once.
  4. audit --ci exits 1 with no writes.
  5. Execute the remedy: a plain apm install retires the claude file and its lock row, after which --frozen and audit --ci both pass byte-stably.

Fails-before evidence (APM_BINARY_PATH = this worktree's .venv/bin/apm, --version = 0.37.0):

  • SHA1 dfd327c2e7 (test only, on train-2 b7bd508b3c), RED: AssertionError: a refused --frozen install changed files -- the snapshot lost .claude/rules/one.md (Right contains 1 more item: {'.claude/rules/one.md': ...}).
  • SHA2 f9d904000d (fix), GREEN: the node passes, along with tests/unit/policy/test_ci_checks.py. In tests/unit/test_audit_policy_command.py one test fails, TestCiWithPolicyFlag::test_ci_with_policy_json_output. That failure is PRE-EXISTING on base b7bd508b3c (same JSONDecodeError with base src): an integrity advisory on stdout ahead of the JSON, emitted by commands/audit.py, which this PR does not touch.

Lint (touched files): uvx [email protected] check and format --check, scripts/lint-auth-signals.sh, and the complexity ratchet are clean. The architecture linter and pylint were not run locally because of the host emergency; CI covers them.

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 (frozen refusal ordering and an audit check; waiver in the commit message).

enforce_frozen now refuses, before the pipeline, a lock that still records
files of a target apm.yml no longer declares, naming the target, its files and
the FROZEN_TARGET_DROPPED remedy. The dropped-target predicate is shared with
the contraction owner (manifest_reconcile._dropped_target_of). New baseline
audit check lockfile-targets-current fails the same state through the same
owner, so apm audit --ci agrees with --frozen (I3).

apm-spec-waiver: frozen refusal ordering only; no OpenAPM-observable lock format change.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
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.

1 participant