Skip to content

fix(install): a refused install --mcp leaves apm.yml and .github untouched (#4759) - #4803

Merged
Daniel Meppiel (danielmeppiel) merged 10 commits into
mainfrom
danielmeppiel-p2-4759-mcp-refusal-no-write
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 10 commits into
mainfrom
danielmeppiel-p2-4759-mcp-refusal-no-write

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

apm install --mcp NAME ... refused a name that collides with a user's own .mcp.json entry, but only after it had already added NAME to apm.yml and written under .github/. A refused install must leave the project byte-for-byte unchanged.

run_mcp_install (src/apm_cli/install/mcp/command.py) now runs #4745's existing refuse_unrecorded_mcp_collisions on the self-defined --mcp entry before it bootstraps the user manifest or edits apm.yml. This reuses the existing preflight rather than adding a second one. The refusal message and exit code 1 are unchanged. If the lockfile or targets can't be read, the early check doesn't refuse; the later MCP stage still runs the same comparison. Dry-run skips the early check.

Issue and approved scope

Issue: Fixes #4759

Human scope-approval comment: #4759 (comment)

Does this PR complete the issue, or what remains? Yes, it completes the issue.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Not yet run: under host park mode (rule 17) the full suite, the bug-ledger test and the MCP unit and lifecycle neighbour tests run in CI only. A local neighbour run was stopped before it finished and had shown 4 unidentified failures, so CI is the verdict for those.

  • Regression test: tests/lifecycle/scenarios/test_ownership_siblings.py::test_a_users_mcp_entry_blocks_a_server_of_the_same_name[inline-mcp]. The cell pair|SRC=inline-mcp|DEPLOYED=unowned is now a required declared refusal; it was strict known-failing. The test asserts exit 1, the conflict message, unchanged apm.yml bytes, no .github/, .mcp.json kept and an empty changed set.
  • Fails before the fix: with HEAD~1 source and the binary driver, the test fails with I7 ... failed install changed the manifest and failed install changed durable files: ['project:.github'].
  • Passes after: -k mcp_entry gives 7 passed.
  • Manual repro: before the fix, rc=1 and apm.yml gained the entry. After the fix, rc=1 and the apm.yml and .mcp.json hashes are unchanged. A non-colliding --mcp entry still installs (rc=0) and is recorded in the lockfile.
  • Lint, all exit 0: uvx [email protected] check and format --check, pylint R0801, scripts/lint-auth-signals.sh, the complexity ratchet, check_test_assertions.py, tests.quality.taxonomy --changed, lint_architecture_boundaries.py and tests.lifecycle.generator --check.

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

…#4759)

apm install --mcp NAME -- COMMAND detected a collision with the user's own
.mcp.json entry only in the MCP write path, after apm.yml had been
modified. Run the #4745 native collision projection
(refuse_unrecorded_mcp_collisions) on the self-defined entry before the
manifest write, so a refused install leaves every durable file
byte-identical (I7). The conflict message and exit code are unchanged.

Flip the strict cell pair|SRC=inline-mcp|DEPLOYED=unowned to required
with a declared refusal, add the bug-ledger row and changelog fragment.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 19:40
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.38.0 milestone Nov 22, 2026

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

The architecture guard does not protect the new early-refusal delegation or its ordering before manifest writes, and the changelog exceeds the word limit and ends with the wrong reference.

2 open issues
What changed in this PR

Extends #4745’s collision protection to direct apm install --mcp commands. Conflicts involving unrecorded self-defined servers are checked before manifest or deployment writes, addressing #4759.

Changes:

  • Reuses the existing collision preflight before manifest mutation, while skipping dry runs and deferring unreadable state to later validation.
  • Makes the lifecycle regression required and asserts unchanged durable state on refusal.
  • Adds a bug-ledger record and changelog fragment.
File Description
tests/​quality/​lifecycle_obligations.json Promotes the inline MCP collision scenario to required coverage.
tests/​lifecycle/​scenarios/​test_ownership_siblings.py Asserts the conflict diagnostic and unchanged manifest, connection, and deployment state.
tests/​lifecycle/​scenarios/​_kit.py Declares the expected inline MCP refusal contract.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​4759.json Links the state-preservation defect to its regression test.
src/​apm_cli/​install/​mcp/​command.py Runs the shared collision preflight before manifest writes.
src/​apm_cli/​install/​mcp/​collision_preflight.py Updates the module docstring to describe the direct-install caller.
changelog.d/​4803.fixed.md Documents the user-visible refusal behavior.

Review effort: Balanced

Comment thread src/apm_cli/install/mcp/command.py Resolved
Comment thread changelog.d/4803.fixed.md Resolved
apm-spec-waiver: install --mcp collision refusal ordering is APM CLI behaviour; no OpenAPM v0.1 requirement governs when a refused install writes the manifest.

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

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.

🔵 Needs a closer look

The new pre-manifest collision check lacks a static wiring guard and mutation coverage, allowing its removal or bypass to pass the architecture gate undetected.

1 open issue
1 resolved since last review

Review effort: Balanced

…t route (#4759)

check_mcp_ownership_migration now pins run_mcp_install delegating to
_refuse_native_mcp_collision and that helper delegating to
refuse_unrecorded_mcp_collisions, with a mutation case for each edge.

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

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.

🟢 Approval recommended

No active review issues are reported for the change adding collision preflight checks to direct MCP installs.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

…t cells (#4759)

The differing-collision case now asserts the refused add leaves apm.yml and
the other target untouched, then declares the entry to reach the partially
installed state the repeat, --force, --frozen and prune cells exercise.

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

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

The collision lifecycle test lacks recorded ownership, so the second install is refused early and all four differing cases fail before exercising the intended repeat, force, and frozen checks.

1 open issue

Review effort: Balanced

…#4759)

A declared entry hits the same unrecorded-collision refusal, so the
differing case now installs to the other target alone to record its claim
before the repeat, --force, --frozen and prune cells.

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

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.

🟢 Approval recommended

No active review issues remain to block approval.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

…cp-refusal-no-write

# Conflicts:
#	tests/lifecycle/scenarios/test_ownership_siblings.py
#	tests/quality/lifecycle_obligations.json

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

A nonexistent callable is imported outside the try block, causing non-dry-run self-defined install --mcp requests to fail with ImportError even when no collisions exist.

1 open issue

Review effort: Balanced

Comment thread src/apm_cli/install/mcp/command.py Resolved
… the --mcp preflight (#4759)

#4763 renamed refuse_unrecorded_mcp_collisions; the direct --mcp preflight,
its architecture guard edge and mutation case now use the new owner name.

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

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.

🟢 Approval recommended

No active review issues remain for the change that moves direct MCP-install collision checks ahead of manifest writes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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.

🟢 Approval recommended

No active review issues are reported for the change that adds collision checks before direct MCP manifest writes.

No open issues 🎉

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 139e6e2 into main Nov 22, 2026
72 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-p2-4759-mcp-refusal-no-write branch November 22, 2026 23:01
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.

[BUG] install --mcp that refuses a name conflict with a user's .mcp.json entry still edits apm.yml and writes under .github

2 participants