Skip to content

fix(install): persist the local-bundle pending record only on commit - #4505

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
train/0.37-final-2from
danielmeppiel-bundle-pending-commit
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
train/0.37-final-2from
danielmeppiel-bundle-pending-commit

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

apm install <bundle> wrote the parked-executables record (apm_modules/.local-bundle-pending.json, read by apm approve --pending) as soon as it had computed the approval key. That happened before policy preflight, the bundle integrity check and deployment, so a failed bundle install left the record behind. The lifecycle integrity cells bundle-files|bundle-install|lock-edited / missing-hash failed I7 on this ("failed install changed durable files").

Fix: _stage_parked_bundle_executables now returns a PendingRecordStage. The handler commits it together with the bundle's lockfile write, which is the bundle install's commit point, or at the success point when the install records no lockfile. A failed install never commits, so it writes nothing new. Approval semantics and the bundle format are unchanged.

Before: a failed apm install <tampered bundle> left apm_modules/.local-bundle-pending.json.
After: a failed install leaves the project byte-identical; a successful install still records the parked executables, and apm approve --pending lists them.

Issue and approved scope

Issue: Fixes #4492

Human scope-approval comment: apm-scope:v1 record by Daniel Meppiel (@danielmeppiel) on #4492.

Does this PR complete the issue, or what remains? It completes the approved scope. Out of scope: approval semantics and the bundle format.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Local runs used files/local-test.sh (-n 2), with apm 0.37.0 (32990f2):

Command Result
pytest tests/integration/test_local_bundle_hooks_lifecycle.py::test_approve_pending_lists_parked_bundle_executables passed; fails without the fix (assert not True: the pending record exists after the failed install)
pytest -n 2 on the 10 test_integrity.py::test_integrity_row[I|*|bundle-install|*] cells (bundle-files, approval-pins, path-containment, policy-hash-pin) 10 passed (bundle-files lock-edited / missing-hash failed before the fix)
pytest -n 2 tests/unit/commands/test_approve_deny.py tests/unit/install/test_install_local_bundle.py 135 passed
pytest tests/quality/test_lifecycle_bug_ledger.py 2 passed
uvx [email protected] check / format --check on touched files; scripts/check_complexity_ratchet.py --base-ref origin/train/0.37-final-2; lint-architecture-boundaries.sh clean

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour. (Commit carries an apm-spec-waiver: line.)

The parked-executables record for apm approve --pending was written right
after the approval key was computed, before policy preflight, the integrity
check and deployment, so a failed bundle install left
apm_modules/.local-bundle-pending.json behind. Stage it as a
PendingRecordStage and commit it with the bundle lockfile write (or at
the success point when nothing is locked).

Fixes #4492

apm-spec-waiver: local bundle pending-record write timing only; no normative requirement change

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

Copy link
Copy Markdown
Collaborator Author

Red on the parent, from guarded local runs (files/local-test.sh, system git first, APM_BINARY_PATH=.venv/bin/apm):

  • Parent tree: train/0.37-final-2 at 32990f2b1c. apm --version printed Agent Package Manager (APM) CLI version 0.37.0 (32990f2b1c).
  • pytest -n 2 "tests/lifecycle/security/test_integrity.py::test_integrity_row[I|bundle-files|bundle-install|lock-edited]" (plus the missing-hash and upstream-or-proxy cells) failed with: I7 (no silent success; a failed command preserves durable state ...): failed install changed durable files: ['project:apm_modules/.local-bundle-pending.json'].
  • pytest tests/integration/test_local_bundle_hooks_lifecycle.py::test_approve_pending_lists_parked_bundle_executables, run with src/ reverted to the parent (only the test change applied), failed with assert not (consumer / "apm_modules" / ".local-bundle-pending.json").exists() -> AssertionError: assert not True.

Green with the fix at b5cd3871ff: those cells and the lifecycle test pass, as do all 10 bundle-install integrity cells (bundle-files, approval-pins, path-containment, policy-hash-pin).

…mmit

Keep #4490's record shape (key plus declared types, approve by recorded
key); add #4505's commit-only persistence as BundleRecordStage.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit b41929f into train/0.37-final-2 Nov 20, 2026
3 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-bundle-pending-commit branch November 20, 2026 21:31
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