Skip to content

fix(frozen): withdraw unrecorded deployments before refusing (#4309) - #4394

Merged
Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-frozen-unrecorded-rollback-4309
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-frozen-unrecorded-rollback-4309

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

A refused apm install --frozen that had deployed files apm.lock.yaml does not record (for example a new local skill) exited 1 but left those files on disk. As a result, the lock no longer matched the disk, which breaks I1 and I7. Before refusing, the frozen owner (InstallService._enforce_frozen_no_rewrite) now calls the new install/frozen_withdrawal.py:

  • It removes exactly the unrecorded files this install wrote. The proof is this installation's deployment receipts, applied through the canonical deletion owner remove_stale_deployed_files, which also retires those receipts. Parent directories the removal empties are removed too.
  • A file without that proof is kept and named in the refusal (kept <path>: no receipt proves this install wrote it). That covers a user file the install adopted, or a file edited since.
  • The diagnostic is unchanged. The tip now says the unrecorded files were removed and apm.lock.yaml is unchanged.

The refusal stays post-deploy. Refusing before the first write would need path-level deploy plans that the pipeline does not have. Native target files sit outside the install transaction, so rollback could not undo them either.

Issue and approved scope

Issue: Fixes #4309

Human scope-approval comment: #4309 (comment)

Does this PR complete the issue, or what remains? It completes it: a refused frozen install leaves disk and lock byte-identical, and the spine's strict cell spine-cell-frozen-underrecording is removed.

Type of change

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

Testing

  • Tested locally (not run: the host is under a no-local-tests rule, so CI validates)
  • All existing tests pass (pending CI)
  • Added tests for new functionality (if applicable)

What changed in the tests:

  • tests/integration/test_frozen_no_rewrite_e2e.py (installed CLI, lifecycle_smoke) used to pin the deployed file; that assertion failed before this fix. It now asserts exit 1, the named diagnostic, the new tip, that the deployed path is absent, and a byte-identical project snapshot (assert_snapshot_set_unchanged). It carries the tm006 markers e2e and promise("P-INV-I7", "P-LAW-lockfile.frozen_preserves_bytes", "req-lk-006").
  • Spine: spine-cell-frozen-underrecording is removed from _spine_kit.py and test_m_spine.py.
  • Ledger: a row for apm install --frozen exits 1 on an unrecorded deployment but leaves the newly deployed files in place #4309 in tests/fixtures/lifecycle_bug_ledger.json.

Static gates, all green: ruff on the changed files, scripts/lint_architecture_boundaries.py, the complexity ratchet, and python -m tests.lifecycle.generator --check. service.py is at 997 of its 1000-line budget.

Changelog

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

Spec conformance (OpenAPM v0.1)

  • N/A -- req-lk-006 (frozen never writes the lockfile) is unchanged; this restores the durable-state invariant around it.

A refused apm install --frozen that deployed files apm.lock.yaml does not
record left them on disk, so the lock no longer matched the disk (I7).
The frozen owner now removes exactly the unrecorded files this install
wrote, proven by this installation's deployment receipts, through the
cleanup owner, then refuses. A file without that proof is kept and named.

The installed-CLI test asserts exit 1, the named diagnostic and a
byte-identical project; the spine's strict cell
spine-cell-frozen-underrecording is removed; a ledger row is added.

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:02
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

Frozen-install withdrawal can delete pre-existing or committed skill files because it relies on historical receipts and overly broad recursive cleanup instead of limiting removal to writes from the current invocation.

4 open issues
What changed in this PR

This PR addresses #4309 by adding receipt-based cleanup before apm install --frozen refuses unrecorded deployments. It connects frozen-install enforcement to the existing deletion owner while keeping the lockfile unchanged.

Changes:

  • Adds deployment withdrawal and kept-path reporting to frozen-install refusal.
  • Strengthens lifecycle snapshot assertions and removes the known-failure exception.
  • Updates recovery documentation, the regression ledger, and the changelog.
File Description
tests/​quality/​test_taxonomy_baseline.json Removes the regression test’s taxonomy exception.
tests/​lifecycle/​machines/​test_m_spine.py Stops expecting the frozen-underrecording failure.
tests/​lifecycle/​machines/​_spine_kit.py Removes the known-failure allowance.
tests/​integration/​test_frozen_no_rewrite_e2e.py Adds deployment-removal and unchanged-snapshot assertions.
tests/​fixtures/​lifecycle_bug_ledger.json Records #4309 and its regression test.
src/​apm_cli/​install/​service.py Invokes withdrawal before refusing unrecorded deployments.
src/​apm_cli/​install/​frozen_withdrawal.py Implements receipt-based cleanup and refusal reporting.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Updates the frozen-install command guidance.
docs/​src/​content/​docs/​reference/​cli/​install.md Documents withdrawal and distinguishes hash-drift recovery.
CHANGELOG.md Adds the user-facing frozen-install fix entry.

Review effort: Balanced

…l cannot prove it wrote

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 20, 2026
This was referenced Nov 20, 2026
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…e refusing (#4309)

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

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
#4258 makes kept a required keyword (explicit kept=() at non-install callers); #4394's frozen_withdrawal caller predates that and relied on the old default.

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

Review fold on #4394:
- A journal taken before the pipeline (this installation's receipts and the
  existing target directories) scopes withdrawal to files whose receipt is
  new or changed in this invocation; an older receipt never authorizes it.
- Files the committed lock records are protected, even under a new
  directory claim.
- Only directories this invocation created are removed.
- Each kept file names its reason (adopted, edited, could not be removed)
  with a runnable next step.
Component tests pin each tightening.

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

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

# Conflicts:
#	src/apm_cli/install/frozen_withdrawal.py
#	src/apm_cli/integration/cleanup.py
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 806a81d into main Nov 21, 2026
72 of 74 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-frozen-unrecorded-rollback-4309 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

Development

Successfully merging this pull request may close these issues.

apm install --frozen exits 1 on an unrecorded deployment but leaves the newly deployed files in place

2 participants