Skip to content

[BUG] apm install -g fails with 'installation binding does not match' after a reboot when home is a btrfs subvolume #3421

Closed

Description

@lkshrk

Describe the bug

After a reboot, apm install -g and apm update -g fail on a host whose home directory is a btrfs subvolume:

Error updating dependencies: Failed to resolve APM dependencies: Invalid local
materialization evidence at ~/.apm/deployment-receipts/<key>.json: installation
binding does not match. Preserve local skill edits, then remove the invalid
receipt file and retry. Existing files without trustworthy evidence will not be
overwritten.

Nothing about the installation changed. DeploymentLedger._load (src/apm_cli/core/deployment_ledger.py) compares the stored root_identity with [st_dev, st_ino] of the deployment root. btrfs gives each subvolume an anonymous device number when it is mounted, so st_dev of a directory on a subvolume is not stable across boots. On my host:

receipt (written 2026-10-27) after reboot (2026-10-30)
st_dev of ~ 56 30
st_ino of ~ 257 257
~/.apm-local/installation f82796f2… f82796f2… (unchanged)
root, scope, version match match

~ is on /dev/mapper/root[/@home] (subvol=/@home), the default layout on Arch-based distributions and on Fedora and openSUSE. All 357 recorded destinations still matched their recorded content_hash.

I understand the binding comes from #3339 / #3344: a checkout recreated at the same pathname, possibly with .apm-local/installation copied into it, must not reuse a prior installation's receipt (test_recreated_checkout_cannot_reuse_old_receipt). [st_dev, st_ino] is the right POSIX identity for that, but on btrfs (and possibly other filesystems with dynamic device numbers) the device half changes for the same directory, so a healthy root is treated as recreated. User scope is hit hardest, since ~ is never a recreated checkout, but the same applies to project roots on a subvolume.

To Reproduce

  1. On a host whose home directory is a btrfs subvolume, run apm install -g with any dependency that deploys a skill, so ~/.apm/deployment-receipts/ is written.
  2. Reboot. Compare stat -c %d ~ with the root_identity stored in the receipt; the first number differs.
  3. Run apm update -g or apm install -g; it fails with the error above.

Without a reboot, setting the first number of root_identity in the receipt to any other value reproduces the same failure deterministically.

Expected behavior

The same directory keeps its binding across reboots and remounts, while a recreated root is still rejected. Some options that keep the #3339 intent, for maintainers to choose from:

  • Bind to a mount-stable identity instead of st_dev, for example the filesystem identity from statvfs().f_fsid (on btrfs derived from the filesystem and subvolume, so I'd expect it to survive remounts, though I have not verified that across a reboot).
  • Detect recreation with inode plus creation time (statx btime), which does not involve device numbers.
  • Accept a binding whose inode and installation UUID match when only st_dev differs.

Environment (please complete the following information):

  • OS: Linux 7.2 (Arch-based), home on btrfs subvolume @home
  • Python Version: 3.13.16
  • APM Version: v0.35.0, via a fork build (0.35.0+omni.6). The fork's only change to deployment_ledger.py adds two target path prefixes; _root_identity and _load are identical to v0.35.0 and to current main.

Logs

See the error above. The only differing field is root_identity[0].

Additional context

The suggested recovery, deleting the receipt, discards the baseline for all 357 files, after which none of them can be updated in place. I restored the binding instead by setting root_identity[0] to the current st_dev after checking every recorded hash against disk, and the update then proceeded.

I'm happy to help with a fix once the scope is decided.

Activity

  1. maro114510 commented on Nov 4, 2026

    @maro114510
    Contributor

    Same thing on macOS. My home dir's st_dev changed from 16777234 to 16777229 and the receipt stopped matching.

    --force doesn't get past it. You have to delete the receipt, and then running without --force wipes skill files.

    #3439 doesn't fix a receipt that's already drifted, I tried it.

  2. danielmeppiel commented on Nov 10, 2026

    @danielmeppiel
    Collaborator

    Decision: approve
    Area: project
    Scope: Keep deployment-receipt root binding stable across reboots and remounts on Linux and macOS by accepting and rebinding a receipt when only the root's st_dev differs while inode, installation UUID, resolved root path and (where the platform provides it) birth time all match, while a recreated root or a copied .apm-local is still rejected, preserving the #3339/#3344 receipt safety boundary.
    Done when: Unit tests simulating a changed st_dev with matching inode, installation UUID, path and birth time show apm install -g and project install succeed and the receipt is rebound; a changed inode, UUID, path or birth time is still rejected with the existing error; a copied .apm-local in a recreated checkout is rejected; tests cover Linux-style and macOS-style stat results; the tests fail on current main.
    Out of scope: A new receipt namespace or format version; Windows identity changes; volume-UUID or statvfs-based identity; receipt migration beyond rebinding; recovery when receipts are missing (#3372, #3391).
    Review contact: Daniel Meppiel (@danielmeppiel)

  3. danielmeppiel commented on Nov 10, 2026

    @danielmeppiel
    Collaborator

    The apm-scope:v1 record above was approved by Daniel Meppiel (@danielmeppiel) at Gate B on 2026-11-10 in the coordinator session of the issue-reduction program. It is the scope a fix for this issue will be reviewed against.

    Review contact: Daniel Meppiel (@danielmeppiel).

    Linked pull requests:


    Generated by autopilot-issue-triage-worker. This comment is AI-generated and may contain errors.

  4. added
    status/accepted
    on Nov 10, 2026
  5. danielmeppiel commented on Nov 10, 2026

    @danielmeppiel
    Collaborator

    Delivered by #3439, merged as 59549ac. On Linux and macOS, a deployment receipt is now rebound when only the root's st_dev changes and inode, installation UUID, resolved path and birth time (where recorded) all match. A recreated root or a copied .apm-local is still rejected. This meets the Done-when of the approved scope record, so I am closing this as completed. Missing-receipt recovery (#3372, #3391) was out of scope and is tracked separately.


    Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/accepted

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions