Skip to content

fix(mcp): announce kept MCP entries on every install path (#4861) - #4908

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-4861-mcp-kept-entry-reporting
Nov 23, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-4861-mcp-kept-entry-reporting

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Reporting accuracy for kept MCP entries from lockless write evidence (#4801, #4818). Copilot review of #4818 found five gaps; each one leaves a notice or audit finding missing or wrong. Nothing is removed differently. Retirement decisions are unchanged (#4784 owns any retirement change).

  1. Local bundle (apm install <bundle>) and
  2. apm install --mcp NAME / apm mcp install NAME returned before the kept-entry announcement. Both now call a new announce-only helper, announce_kept_mcp_writes, with the lockfile's complete managed-server set and configs (all owners), so nothing unrelated is retired.
  3. Stale key-less record: a located rewrite (owner/demo under demo) now supersedes the key-less record for the same runtime, config and name. Other profiles' records stay.
  4. Redeclared on the same native key: announce-only now applies the same _declared_keys() check retirement uses.
  5. Unusable evidence: every recognized reason (including OSError and path-traversal, such as a symlinked evidence file) is now warned on a lockless install, not only McpWriteEvidenceError.

Docs: reference/cli/install.md ("MCP cleanup without a lockfile") names the extra install paths and unusable-evidence cases.

Issue and approved scope

Issue: Fixes #4861

Human scope-approval comment: #4861 (apm-scope:v1 record)

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

apm-spec-waiver: kept-entry reporting accuracy for lockless MCP evidence; no OpenAPM-observable behaviour changes

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
promise: P-INV-I4 -- a kept entry is announced on every later install (source: install/mcp/write_receipts.py)
cell: OP=install SCOPE=project LOCK=present PRIM=mcp MCPOWN=claude PATH={--mcp NAME, mcp install NAME, local bundle}   owner: install/mcp/write_receipts.py
instrument: today test -> tests/integration/test_mcp_kept_entry_announcement_lifecycle.py (new: no module drives the kept state into these paths) + 3 cells in tests/unit/install/test_mcp_write_receipts.py (extends)
oracles: [I4, I6, snapshot of the kept entry]  decisive: "Kept MCP server 'kept-mcp'" in the output and the edited entry unchanged
failing-before: CI=true pytest <both modules> -p no:xdist -> 6 failed, 30 passed (all six new cells)
passing-after: same -> 36 passed; tests/lifecycle/scenarios/test_mcp_write_receipts.py + install/test_architecture_invariants.py -> 12 passed; test_lifecycle_bug_ledger.py + test_mcp_write_receipts.py -> 35 passed
guard+mutation: n/a     ledger: 4861
hints executed: none printed

Lint chain (local), all clean:

  • ruff check / format --check (0.15.12)
  • lint_architecture_boundaries.py --root .
  • pylint R0801
  • lint-auth-signals
  • complexity ratchet
  • tests.quality.taxonomy --changed
  • check_test_assertions.py (AQ unchanged)
  • tests.lifecycle.generator --check

The install-module LOC budget still holds: integration.py 998 and local_bundle_handler.py 994, both under 1000.

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.

…ept reporting

Reporting accuracy for kept entries from lockless MCP write evidence
(#4861, deferred from #4818). Nothing is removed differently:
- apm install <bundle>, apm install --mcp NAME and apm mcp install NAME
  announce kept entries (announce-only) against the lockfile's complete
  managed-server set, through one helper, announce_kept_mcp_writes;
- a located rewrite supersedes the key-less record of the same runtime,
  config and name, so a retired entry leaves no stale notice or audit
  finding;
- announce-only skips a server redeclared on the same native key, as
  retirement already does;
- every recognized unusable-evidence reason (OSError, path traversal)
  is announced on a lockless install, not only a parse error.
Six red-first cells.

Fixes #4861

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 04:09

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

Audit still filters receipts only by managed names, so a kept entry redeclared as self-defined on the same native key incorrectly fails apm audit --ci.

1 open issue
What changed in this PR

This PR follows up on #4801 and #4818 to improve APM’s kept-MCP-entry reporting across install paths, without changing which entries are removed.

Changes:

  • Adds kept-entry announcements to local bundle and direct MCP installs.
  • Updates stale receipt handling, native-key redeclaration filtering, and unusable-evidence warnings.
  • Adds regression coverage, a bug-ledger entry, and documentation.
File Description
tests/​unit/​install/​test_mcp_write_receipts.py Tests receipt supersession, redeclaration, and unsafe-evidence warnings.
tests/​integration/​test_mcp_kept_entry_announcement_lifecycle.py Checks announcements and entry preservation across install paths.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​4861.json Records reporting failures and regression tests.
src/​apm_cli/​install/​mcp/​write_receipts.py Adds the announcement helper and adjusts reporting filters.
src/​apm_cli/​install/​mcp/​integration.py Announces kept entries after direct MCP installs.
src/​apm_cli/​install/​local_bundle_handler.py Announces kept entries after local bundle installs.
docs/​src/​content/​docs/​reference/​cli/​install.md Documents additional announcement paths and unusable evidence.
changelog.d/​4908.fixed.md Summarizes the user-visible reporting changes.

Review effort: Balanced

@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.38.0 milestone Nov 23, 2026
A kept owner/demo entry redeclared as self-defined demo on the same
native key stopped warning at install but still failed apm audit --ci
(kept-mcp-entries). The native-key check now lives in the kept() reader
both install and audit use, with the lockfile's MCP configs passed from
audit. The redeclaration cell asserts the audit reader agrees (red
before).

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 block the kept-MCP-entry reporting changes.

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 recorded for the changes making kept MCP-entry reporting consistent across install paths and audit.

No open issues 🎉

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit fd56d1f into main Nov 23, 2026
74 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-4861-mcp-kept-entry-reporting branch November 23, 2026 07:24
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
Fold the changelog.d fragments for #4858, #4868, #4870, #4880 and #4908 into [0.38.1].

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.

Lockless MCP evidence: kept-entry reporting gaps on some install paths

2 participants