Skip to content

fix(install): one owner and one message for a kept edited file - #4504

Merged
Daniel Meppiel (danielmeppiel) merged 6 commits into
train/0.37-final-2from
danielmeppiel-kept-edit-message
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 6 commits into
train/0.37-final-2from
danielmeppiel-kept-edit-message

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Install printed two different messages for the same outcome, a managed file kept because it holds local edits:

Per the steward ruling, base_integrator.kept_edit_message(entry, *, user_scope, proven_edit) is now the single owner. Every call site uses it:

  • the skill member copy (copy_directory_files);
  • _check_adopt_or_skip;
  • the finalize kept-overwrite report;
  • the local bundle legacy refusal.

The message has one shape: "Kept : . Move it aside, then run 'apm install[ -g]' to restore it; or run 'apm install[ -g] --force' to overwrite it." The #4360 reason text is unchanged. A receipted edit reads "it was modified since APM deployed it".

Exit code (steward precision):

  • A kept edit warns (exit 0) only when the package brings the bytes APM already deployed. The edit is drift, which audit reports.
  • When the package brings new bytes for the edited file (an upgrade), the kept edit blocks the requested state, so install errors and exits 1.

Issue and approved scope

Issue: Refs #4360

Human scope-approval comment: the steward ruling on the train-2 red I|deployed_file_hashes|install|disk-or-cache was relayed by the 0.37 Hardening PM (one owner, one message, cell re-pointed, exit-code split).

Does this PR complete the issue, or what remains? It completes the message unification. Nothing remains for this ruling.

Type of change

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

Testing

  • Tested locally (train-2 venv, apm 0.37.0):
    • pytest "tests/lifecycle/security/test_integrity.py::test_integrity_row[I|deployed_file_hashes|install|disk-or-cache]" tests/integration/test_checkout_switch_skill_lifecycle.py tests/integration/test_skill_materialization_receipt_lifecycle.py: 44 passed, 1 xfailed.
    • python -m tests.lifecycle.witnesses: up to date.
    • Lint chain clean: ruff 0.15.12 check and format, pylint R0801 10.00, auth signals, complexity ratchet, architecture linter.
  • All existing tests pass (CI)
  • Added tests for new functionality (if applicable)

Per-cell classification:

  • I|deployed_file_hashes|install|disk-or-cache: re-pointed from the cleanup line "Kept user-edited file" (wrong owner) to the install owner's message plus its next step. Still exit 0 with _SKILL_STATE unchanged. It is red on train-2, where the output is "Skipped ... modified since deployment".
  • test_user_edit_variants_never_lose_bytes[R2,R4]: the source brings new bytes for the edited SKILL.md, so the expected exit goes from 0 to 1 per the ruling. The no-loss assertions are unchanged. R1 and R3 stay at exit 0.
  • test_checkout_switch_skill_lifecycle._MODIFIED and test_skill_materialization_receipt_lifecycle: the message pin follows the new wording. Assertions are otherwise unchanged.

Changelog

  • One line under ## [Unreleased].

Spec conformance (OpenAPM v0.1)

  • N/A: no requirement text changes.

Agent note, not authored by Daniel.

base_integrator.kept_edit_message is the single owner of the message
install prints when it keeps a managed file: 'Kept <file>: <reason>. Move
it aside, then run 'apm install' to restore it; or run 'apm install
--force' to overwrite it.' The #4360 unproven reason is unchanged; a
receipted skill member modified since APM deployed it now uses the same
shape instead of the non-runnable 'Preserve your changes before
reinstalling with --force'.

A kept edit warns (exit 0) only when the package brings the same bytes
APM deployed (drift); when it brings new bytes for the edited file (an
upgrade) the kept edit blocks the requested state and install exits 1.
The integrity cell deployed_file_hashes|install|disk-or-cache is
re-pointed at the message; checkout-switch R2/R4 pin the exit 1.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…shape

Kept lines now read 'Kept <path>: <reason>. <Remedy sentence>', the shape
of base_integrator.kept_edit_message (#4504), through a shared
remediation.kept_file_message template. Tests pin the full aligned lines.

Co-authored-by: Copilot App <[email protected]>
A receipted member whose bytes differ from the recorded hash but equal
the package's bytes holds no edit to keep: it is rewritten and recorded
(adopted), with no 'Kept' line. _member_edit classifies members as
untrusted, drift (warn, exit 0) or blocked (error, exit 1).

Co-authored-by: Copilot App <[email protected]>
…eppiel-kept-edit-message

# Conflicts:
#	docs/src/content/docs/enterprise/drift-detection.md
…alog

kept_edit_message renders through remediation.kept_file_message with the
kept-file-restore and kept-file-overwrite catalog entries, the one kept-
file shape the frozen kept lines share. The template joins the two
remedies with ', or'; pins follow. _member_edit keeps the guarded
'(baseline_hash is not None and expected is None)' predicate.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
The #4504 merge brought differing_unrecorded_native_mcp_entries (#4477)
into install/mcp/ownership.py, calling the native-entry probes that
9c01d5e moved to install/mcp/native_entry.py, which left undefined names,
and pushed ownership.py to 1009 lines (install budget 1000). The function
moves beside those probes (same owner); audit's ci_checks imports it from
there. ownership.py is back to 958 lines.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 378303b into train/0.37-final-2 Nov 20, 2026
5 checks passed
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…ard fix-ups (04daadaf)

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

# Conflicts:
#	.apm/architecture/owners/contracts-tooling.json
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
#4504's variadic form is a superset; drop the narrower duplicate.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-kept-edit-message branch November 20, 2026 21:52
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…mutation

- test_frozen_no_rewrite_e2e: the kept line follows the one kept-file shape
  (#4504): asserted through frozen_withdrawal.kept_lines, plus its reason
  text; the rerun asserts neither "kept" nor "Kept".
- Steward ruling (9c01d5e wins): test_adopted_identical_files_get_no_receipt
  becomes test_adopted_identical_files_get_a_receipt. For every _ADOPTABLE
  file: the receipt hash equals sha256 of the disk bytes, no "Kept" line,
  audit --ci is clean, and apm uninstall removes them with no refusal. New
  negative: test_a_differing_file_is_never_receipted_by_adoption.
- Product: hook_bundle's identical-script adoption records the receipt for
  MANAGED scripts too (same rule as _check_adopt_or_skip in 9c01d5e).
- test_architecture_owner_rule_mutations: the update.py scope-manifest case
  pins the unique enforce_declared_policy argument (update.py now holds the
  fragment twice); the rule is AST-based, so one site trips it.

Co-authored-by: Copilot App <[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.

1 participant