Skip to content

[BUG] Stale cleanup still trusts a lockfile hash that matches a file APM never deployed #3701

Closed

Description

Follow-up to #3663 (0.36.0 lifecycle sweep, #3649).

Stale-file cleanup now deletes a lockfile-listed file only when its recorded hash matches. A row with no hash keeps the file and warns. A lockfile row whose recorded hash equals the sha256 of a committed user file still authorizes deleting that file on a machine without local receipts. The hash proves the content, not that APM deployed it.

Expected

On a clone without receipts, deleting a stale file needs evidence that APM deployed it. That is a local receipt, or a byte match against what the locked package version renders. Lockfile hashes alone are not enough, matching the cold-restore adoption rule.

Notes

Today, local receipts cover only skills. Instructions, agents, prompts and hooks have none, and cowork:// rows record no hashes, so they are exempt from the hash gate. This needs receipts for every primitive kind, or re-materializing removed packages during orphan cleanup.

Activity

  1. added
    area/content-security
    area/lockfile
    type/bug
    pillar/consume
    on Nov 12, 2026
  2. danielmeppiel commented on Nov 13, 2026

    @danielmeppiel
    CollaboratorAuthor

    Related coverage gap from the #3672 review: the cleanup gate exempts cowork:// rows from the recorded-hash requirement, because install records no hashes for them. Managed final symlinks are also unlinked without a hash. Both have unit coverage (tests/unit/integration/test_cleanup_helper.py, and the hook sync symlink tests in tests/unit/integration/test_deployed_files_manifest.py) but no installed-CLI lifecycle case. The cowork case needs a OneDrive-root fixture. Once install records hashes for cowork:// rows, drop the exemption and add the lifecycle case.

  3. added
    status/needs-design
    on Nov 19, 2026
  4. danielmeppiel commented on Nov 19, 2026

    @danielmeppiel
    CollaboratorAuthor

    Decision: approve
    Area: project
    Scope: Every lockfile-driven deletion of a deployed file or tree (install, update, uninstall and prune stale cleanup, the deferred skill-directory pass, integrator sync and skill path migration) requires evidence that APM deployed those bytes: a matching local deployment receipt, or byte equality with what the locked package version renders. A lockfile hash alone never authorizes deletion. Record receipts for every successful final-rendered write of every file primitive (instructions, agents, prompts and commands, hooks, skills) through the installation-bound deployment materialization session; record hashes for cowork:// rows and remove their exemption. For receipt-less rows, render the locked package version through the existing package-image and skill locked-source materialization owners; uninstall and prune materialize that evidence before removing package sources. When no evidence can be obtained, the file is kept with a warning naming it and the manual fix; uninstall then stops as it does today for retained files, keeping the declaration. Managed final symlinks keep their current unlink rule. Ships as two dependent PRs under this record: receipt plumbing, then full enforcement with render fallback.
    Done when: installed-CLI lifecycle tests on committed-output clones with fresh HOME and APM_HOME, asserting no receipts exist immediately before cleanup, exercise install, update, uninstall and prune: a forged lockfile row whose hash matches a user file that differs from the locked render keeps the file; a file equal to the locked render is removed; an edited file is kept. On the deploying machine, removing a dependency removes its instruction, agent, prompt and hook files via receipts. A pre-receipt (upgrade) uninstall succeeds with apm_modules present and with it removed but the source reachable, and stops naming the files when neither is available. A cowork:// row (user scope, experimental flag, APM_COPILOT_COWORK_SKILLS_DIR fixture) is removed only with valid provenance. Docs (the install, update, uninstall and prune references and the enterprise security cleanup-authority paragraph), the apm-usage resources, one CHANGELOG line.
    Out of scope: lockfile schema changes, adopting receipt-less files during install beyond the existing skill rule, frozen mode (it deletes nothing), MCP and native config cleanup.
    Review contact: Daniel Meppiel (@danielmeppiel)

  5. added
    status/accepted
    and removed
    status/needs-design
    on Nov 19, 2026
  6. 89 remaining items

  7. added 6 commits that reference this issue on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/content-securityarea/lockfilepillar/consumestatus/acceptedtype/bug

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions