Skip to content

#3701 (1/2) record deployment receipts for every file primitive - #4023

Merged
Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-literate-broccoli
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-literate-broccoli

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Draft, PR 1 of 2 for #3701 (receipt plumbing). Stale cleanup must not trust a lockfile hash alone. Before cleanup can require evidence (PR 2), APM has to record that evidence. Until now, local deployment receipts covered only skills.

This PR records an installation-bound receipt for every final-rendered write of every file primitive:

  • Each file-primitive writer (instructions, prompts, agents, commands, hooks including Kiro docs and hook scripts, canvas, skill plugin bin/ and .claude-plugin/plugin.json) reports every final-rendered write with BaseIntegrator.note_rendered_write. Adopted and skipped files are never reported, so receipt-less adoption does not extend beyond the existing skill rule (the record puts that out of scope).
  • record_rendered_writes (in core/deployment_ledger.py, the receipt owner) drains those reports after every integrator call in integrate_package_primitives, including writes made before a failure, and records them through the live DeploymentMaterializationSession. The session is the one already bound for the integrate phase of install and the uninstall survivor rebuild. Drift replay and dry runs have no session, so they record nothing.
  • DeploymentMaterializationSession.record now locates writes under any target deploy root, not only skill roots. It refuses symlinks and paths outside every target root instead of recording them.
  • cowork:// lockfile rows now carry content hashes: compute_deployed_hashes decodes them under the resolved Cowork root. That brings these rows under req-lk-012 (canonical sha256 envelope for every deployed file), cited by a new conformance test.
  • Architecture guard install-deployment-provenance-state now requires every file-primitive writer to report writes and the install service to record them, with mutation traps.

Not in this PR (PR 2, stacked): enforcement in the cleanup owner (receipt or locked-render equality required), the render fallback, removing the cowork:// hash exemption, integrator sync and skill path migration, lifecycle tests, docs and CHANGELOG.

Issue and approved scope

Issue: Refs #3701

Human scope-approval comment: #3701 (comment) (apm-scope:v1, record-present via scripts/governance/eligibility.cjs)

Does this PR complete the issue, or what remains? No. This is part 1 of the two dependent PRs the record calls for. PR 2 adds enforcement and the render fallback.

Type of change

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

Testing

  • Tested locally: APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_file_primitive_receipt_lifecycle.py tests/spec_conformance/test_cowork_deployed_hash_reqs.py tests/unit/test_deployment_materialization_receipts.py tests/unit/integration/test_deployed_files_manifest.py (149 passed); tests/integration/test_architecture_materialization_receipts.py plus related owner-rule mutations (43 passed); lint chain and scripts/lint-architecture-boundaries.sh clean.
  • All existing tests pass: pytest tests/unit has no new failures. The local failures (git signing, network and credential fixtures) also fail on main in this sandbox.
  • Added tests: installed-CLI receipt lifecycle (closed-world across every non-experimental target: each deployed file of a fresh install has a matching receipt; adopted files on a receipt-less clone get none), unit tests and a req-lk-012 conformance test.

Changelog

  • N/A -- the CHANGELOG line ships with PR 2, where the behaviour becomes user-visible.

Spec conformance (OpenAPM v0.1)

  • Test edit: @pytest.mark.req("req-lk-012") in tests/spec_conformance/test_cowork_deployed_hash_reqs.py (cowork:// rows now hashed per the existing requirement; no spec text change).

…3701)

Integrators report final-rendered writes (never adopted or skipped
files) in IntegrationResult.rendered_writes; the install service records
them through the installation-bound DeploymentMaterializationSession,
which now locates writes under any target deploy root. Skill plugin bin
copies are recorded too. cowork:// lockfile rows now carry hashes.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…req-lk-012 (#3701)

Integrators report each final-rendered write with note_rendered_write;
the deployment ledger owner drains and records them per integrator call,
including writes before a failure. Keeps hook and skill integrators under
the file-length guard. Adds installed-CLI receipt lifecycle tests and a
req-lk-012 conformance test for cowork:// deployed-file hashes.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…ycle oracles (#3701)

Receipts stay in the existing APM_HOME/deployment-receipts store. The
diamond uninstall step now declares that store because the survivor
rebuild rewrites the shared instruction and records its receipt; the
skill receipt oracle filters to skill members since other primitives
are receipted too.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Main grew install/services.py and skill_integrator.py. Fold the
integrator receipt bracketing into deployment_ledger.recorded_writes
and let _copy_plugin_file report its own write.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title [0.38] #3701 (1/2) record deployment receipts for every file primitive #3701 (1/2) record deployment receipts for every file primitive Nov 20, 2026
@danielmeppiel
Daniel Meppiel (danielmeppiel) marked this pull request as ready for review November 20, 2026 08:39
Copilot AI balanced review requested due to automatic review settings November 20, 2026 08:39
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit d90f562 into main Nov 20, 2026
33 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-literate-broccoli branch November 20, 2026 08:39

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

Cowork lockfile handling incorrectly includes symlink targets, while the architecture guard can miss unreported hook-bundle writes, with regression coverage gaps for both issues.

2 open issues
What changed in this PR

This is the receipt-plumbing half of #3701. It extends local deployment evidence beyond skills, preparing stale cleanup to require stronger proof in the follow-up PR; cleanup enforcement is unchanged here.

Changes:

  • Report final-rendered file writes and record them through the installation-bound receipt session, including writes completed before an integrator fails.
  • Add content hashes for cowork:// deployed-file entries.
  • Extend architecture guards, receipt lifecycle tests, and conformance coverage.
File Description
tests/​unit/​test_deployment_materialization_receipts.py Tests non-skill receipts and target-root boundaries.
tests/​unit/​integration/​test_deployed_files_manifest.py Tests Cowork deployed-file hashing.
tests/​spec_conformance/​test_cowork_deployed_hash_reqs.py Adds canonical Cowork hash conformance coverage.
tests/​integration/​test_required_lifecycle_state_machine.py Updates expectations for additional primitive receipts.
tests/​integration/​test_file_primitive_receipt_lifecycle.py Tests installed-CLI receipts and receipt-less adoption.
tests/​integration/​test_architecture_materialization_receipts.py Adds receipt-routing mutation cases.
src/​apm_cli/​integration/​skill_integrator.py Shares receipt ownership and reports plugin writes.
src/​apm_cli/​integration/​prompt_integrator.py Reports rendered prompt writes.
src/​apm_cli/​integration/​kiro_hook_integrator.py Reports Kiro hook document writes.
src/​apm_cli/​integration/​instruction_integrator.py Reports rendered instruction writes.
src/​apm_cli/​integration/​hook_integrator.py Uses LF-only JSON output and reports writes.
src/​apm_cli/​integration/​hook_bundle.py Reports copied assets and generated sidecars.
src/​apm_cli/​integration/​command_integrator.py Reports rendered command writes.
src/​apm_cli/​integration/​canvas_integrator.py Reports copied canvas bundle files.
src/​apm_cli/​integration/​base_integrator.py Adds shared write-report collection and draining.
src/​apm_cli/​integration/​agent_integrator.py Reports rendered agent writes.
src/​apm_cli/​install/​services.py Wraps integrator calls in receipt recording.
src/​apm_cli/​install/​phases/​lockfile.py Resolves Cowork entries for content hashing.
src/​apm_cli/​core/​deployment_ledger.py Extends receipt locations and drains reported writes.
scripts/​architecture_linter/​checks/​mutation_hook_contract.py Recognizes the updated hook JSON writer.
scripts/​architecture_linter/​checks/​install_base_integrator_and_contraction.py Adds write-reporting and receipt-routing guards.
CONFORMANCE.md Updates the req-lk-012 test count.
CONFORMANCE.json Registers the new Cowork conformance test.

Review effort: Balanced

"with recorded_writes(integrators.skill, integrators.skill, projection_targets,",
),
**{
f"src/apm_cli/integration/{name}.py": ("note_rendered_write(",)
if cowork_root is None:
continue
try:
_full = from_lockfile_path(_rel, cowork_root)
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
main's phases/lockfile.py reached 1017 lines when #4023 merged, with no
KNOWN_LARGE_MODULES entry; the frozen disposition adds three.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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.

2 participants