Repository navigation
[0.38] #3701 (2/2) cleanup deletes only with deployment evidence, never a lockfile hash alone - #4049
Draft
Daniel Meppiel (danielmeppiel) wants to merge 13 commits into
Draft
Daniel Meppiel (danielmeppiel) wants to merge 13 commits into
Daniel Meppiel (danielmeppiel) wants to merge 13 commits into
Conversation
… hash alone (#3701) remove_stale_deployed_files now requires a DeploymentEvidence (keyword, no default): a matching local deployment receipt, or byte equality with the drift replay of the pre-transition lock (the locked render). Files that differ are kept as edited; files without evidence are kept with a warning naming them and the manual fix. cowork:// rows lose their exemption. Integrator sync (base, hooks, skills), the deferred skill directory pass, skill path migration, install, update, uninstall and prune all route through this owner; uninstall and prune render before removing package sources. Managed final symlinks keep their rule. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…en files inline (#3701) Committed-output clones with fresh HOME/APM_HOME and no receipts cover install orphan cleanup, update stale cleanup, uninstall (modules present, source only, neither) and prune: locked-render bytes go, a forged row's user file and an edited file stay. The deploying machine uninstalls every primitive through receipts with the source gone. cowork:// rows go only with a matching receipt. Install and update now name kept unproven files inline, as they do user edits. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…ment evidence (#3701) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
#3701) Proposed amendment 0.1.76 (provisional number; counts recomputed at merge). Adds req-lk-024 (Section 5.2, consumer MUST): a lockfile-driven deletion of a deployed file needs a matching local deployment record or byte equality with the locked version's render; a lockfile hash alone never authorizes it; unproven or differing files are kept and named; the render is established before the source is removed. Updates Sections 1.3, 5.7, 10.7, 10.11, 11.3.2, Appendix C/D, the requirements manifest, a req-lk-024 conformance test and CONFORMANCE.{md,json}. Isolated so it can be dropped if the editor keeps the rule implementation-only. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…vidence (#3701) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…kill dirs (#3701) Unit tests now state their evidence explicitly: receipted files on the deploying machine, or none on a clone. Tests whose point was that a lockfile row alone must not delete keep that intent. Legacy deployed_skills migrations record skill directories with a trailing slash; the cleanup owner now recognizes them instead of refusing the entry. Documents the pipeline.py and manifest_reconcile.py LOC budgets the required evidence argument costs. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…follow the evidence rule (#3701) Uninstall target cleanup now names each file kept for lack of evidence, as install does. Hook sidecars an older APM wrote carry only a lockfile hash, so their lifecycle contract now expects them kept and named, with the manual fix (delete, then rerun) restoring the contract. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-3701-enforcement
branch
from
November 20, 2026 04:47
cd5d4cf to
babed8a
Compare
…fallback (#3701) Review folds (c9b13584 on babed8a): - A stale receipt no longer blocks the render comparison: a file adopted from a newer render after a pull is removed when it equals the locked render (EDITED only when no evidence matches). - The locked render also covers targets the lock recorded, so a target dropped from apm.yml stays provable on a clone without receipts. - When the whole-lock render fails, each owning package renders alone, so one unmaterializable package loses only its own evidence; the failure is named per package. - Kept files are named once: uninstall flushes its diagnostics before it stops and with its outcome, apm update renders install diagnostics, and the duplicate inline lines are gone. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…decars (#3701) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-3701-enforcement
branch
from
November 20, 2026 05:13
babed8a to
8e26f25
Compare
#3701) DeploymentEvidence is scope-bound, so remove_synced_files passes its user_scope through: user-scope uninstall syncs validate user roots and retire receipts in the user store instead of the project one. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Install, update, uninstall and prune references, the enterprise security cleanup-authority paragraph and the apm-usage commands resource now say a lockfile hash alone never authorizes deleting a deployed file. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-3701-enforcement
branch
from
November 20, 2026 05:46
8e26f25 to
3f98387
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Draft, PR 2 of 2 for #3701 (enforcement and render fallback). Stacked on #4023 (receipt plumbing).
A lockfile hash alone no longer authorizes deleting a deployed file. Every lockfile-driven deletion now needs evidence that APM deployed the current bytes. That covers install and update orphan and stale cleanup, target contraction, uninstall (Step 3 and Phase 1), prune, the deferred skill-directory pass, integrator sync and skill path migration. The evidence is one of:
install/drift.run_replay, the existing package-image owner) renders the pre-transition lock into a private scratch tree, with the targets the lock recorded as well as the manifest's, so a just-dropped target stays provable. It runs only when some candidate has no matching receipt, fetches the locked commit when the checkout is gone, and falls back to rendering each owning package alone when the whole-lock render fails, so one unmaterializable package loses only its own evidence.A stale receipt does not block the render comparison: receipt OR render. A file adopted from a newer render after a pull is still removable.
Without evidence the file is kept, and a warning names it and the manual fix. A file that differs from its evidence is kept as user-edited.
cowork://rows lose their exemption. Managed final symlinks keep their current unlink rule. Uninstall still stops, keeping the declaration, when a target file is retained.One owner, closed-world
integration/cleanup.pyownsDeploymentEvidence(receipts plus the lazy locked render) andremove_stale_deployed_files(..., evidence=...).evidenceis keyword-only with no default, so no caller can fail open.remove_synced_filesis the only path for integrator sync deletions. Hook and skillsync_integrationandBaseIntegrator.sync_remove_filesused tounlink/rmtreewith no check.install/phases/cleanup.deployment_evidence(ctx)builds one evidence per install, fromctx.existing_lockfile.DeploymentEvidence.preparebefore removing package sources.install-deployment-provenance-statenow requires these routes, with mutation traps.Known limitations and consequences
copilot-cowork.package.jsonan older APM wrote carries only a lockfile hash, and today's locked render does not produce it. Install and update now keep it and name it, and uninstall stops naming it. The manual fix is to delete it and rerun.test_hook_js_sidecar_lifecycle_contract.pynow asserts this flow.Decision for Daniel
spec(normative, pending Daniel)) addsreq-lk-024(Section 5.2, consumer MUST): a lockfile-driven deletion needs a matching local deployment record, or byte equality with the locked version's render. A lockfile hash alone never authorizes it. Unproven or differing files are kept and named.apm-spec-waiver:with an informative note in Section 10.7.Spec renumbering at merge
0.1.76 is provisional. Recompute the amendment number, the statement count (now 149, of which 144 MUST and 5 SHOULD) and the Appendix D row against
mainat merge time, then regenerate CONFORMANCE.{md,json}.Docs re-home after #3996
mainlayout)enterprise/security.md, "Lockfile cleanup authority" paragraphenterprise/security.md(or under "Drift and integrity" inreference/lockfile-spec.md).reference/cli/install.md, "Stale-file cleanup" bulletreference/cli/update.md, receipt-less update paragraphreference/cli/uninstall.md, retained-paths paragraphreference/cli/prune.md, cleanup paragraphpackages/apm-guide/.apm/skills/apm-usage/commands.mdReview folds (c9b13584 on babed8a)
verdictfalls through to the render on a receipt mismatchtest_adopted_after_pull_then_uninstall_uses_the_locked_renderresolve_audit_targets(include_recorded=True)viaReplayConfig.include_recorded_targets); duplicate inline lines removed;apm updaterenders install diagnosticstest_dropped_target_is_proven_by_the_render_of_recorded_targets; update test asserts the kept file is named oncetest_render_evidence_is_per_package[other-package],[removed-package]DeploymentEvidenceis scope-bound;remove_synced_filespasses itsuser_scopetest_synced_removal_retires_receipts_in_the_evidence_scopePre-merge
mainafter [0.38] #3701 (1/2) record deployment receipts for every file primitive #4023 merges; CI must go green there. CI does not run while the base is the PR1 branch.git merge-tree --write-tree), PR2 head vsorigin/main: 0 conflicts. Vsorigin/danielmeppiel-native-hook-delivery: 5, all generated or append-only (CHANGELOG.md, CONFORMANCE.json, CONFORMANCE.md,specs/openapm-v0.1.mdAppendix C/D, andenterprise/security.mdfrom the docs: zero-based redesign around the agent supply chain #3996 rewrite).Issue and approved scope
Issue: Fixes #3701
Human scope-approval comment: #3701 (comment) (apm-scope:v1, record-present via
scripts/governance/eligibility.cjs)Does this PR complete the issue? Yes, together with #4023 (its base).
Type of change
Testing
Local CI-mirror evidence. CI does not run on this stacked PR, and the sandbox has 2 CPUs.
uv run --extra dev ruff checkandruff format --checkonsrc/ tests/ scripts/...pylint --enable=R0801 --min-similarity-lines=10bash scripts/lint-architecture-boundaries.sh;tests/integration/test_architecture_materialization_receipts.pybash scripts/lint-auth-signals.shpytest tests/unit -n 3(excluding the sandbox-environment files that also fail onmain)APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_cleanup_deployment_evidence_lifecycle.pyAPM_E2E_TESTS=1 pytest -m 'lifecycle_smoke and not lifecycle_merge_group' tests/integrationorigin/mainin this sandbox (9test_marketplace_explicit_refresh_lifecycle, 10test_unix_installer_path_integration, 1test_hook_event_native_lifecycle::test_claude_project_hook_runs_from_external_cwd). The other 4 were real and are fixed (test_hook_js_sidecar_lifecycle_contractx3,test_stale_cleanup_hash_authority_lifecyclex1): rerun 6 passed.pytest tests/spec_conformance;python -m tests.spec_conformance.orphan_checkThe new lifecycle tests run on committed-output clones with a fresh HOME and APM_HOME, and assert that no receipts exist before each command. They cover:
apm_modulespresent (source unreachable), with only the source reachable, and with neither (exits 1 naming the files, declaration kept);APM_COPILOT_COWORK_SKILLS_DIRfixture: a receipt removes the file; receipt-less or edited files are kept and named).Changelog
## [Unreleased]/ Fixed, ending(closes #3701, #4049).Spec conformance (OpenAPM v0.1)
req-lk-024anchor, prose and Appendix C row (proposed 0.1.76).openapm-v0.1.requirements.yml.tests/spec_conformance/test_deletion_evidence_reqs.py(@pytest.mark.req("req-lk-024")).