Skip to content

fix(install): a user LSP entry conflict that wrote nothing leaves apm.lock.yaml unchanged (#4697) - #4705

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-fix-4697-lsp-conflict-lock
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-fix-4697-lsp-conflict-lock

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

When apm install fails because a harness LSP config already holds a user-owned entry with the same name as a package's LSP server, the command exited 1 but still committed apm.lock.yaml. The pipeline had staged the gated package row (exec_status: gated_pending_approval -> deployed). LSPUserEntryConflictError is not a commit refusal, so the lockfile writer scope published it, which breaks lifecycle law I7.

The fix lives at the LSP install owner and follows the MCP native-conflict path (MCPNativeConflictError.wrote_connections):

  • LSPIntegrator.install reports wrote_servers on the conflict error (whether any other server changed a config).
  • run_lsp_integration re-raises a conflict that wrote no server as LSPUserEntryRefusal, before any cleanup or lock update. That class sets refuses_commit = True, the same refusal marker the org-policy block uses. The transaction then discards the staged lockfile and restores journaled writes, and native registration does not flush. The failed install leaves the lockfile byte-identical.
  • If other servers were written, behavior is unchanged from [BUG] apm install takes over a user's own LSP server entry with the same name #4628: they are recorded, then the install fails.
  • The refusal applies only to a persisting install whose MCP stage staged no lockfile change. If MCP wrote a connection in the same command, the conflict commits so that write stays recorded (MCP adapter writes are outside the deploy journal). Uninstall and prune (persist=False) finish reconciliation before failing, as before.

Unchanged: the refusal message, exit code 1, the user's entry, successful installs, and MCP behavior. The local-bundle path (run_owned_lsp_integration) is unchanged: it records the bundle's own deployed files.

Composes with #4678 (E4626): this PR does not touch tests/lifecycle/oracles.py and does not overlap its hunks.

Issue and approved scope

Issue: Fixes #4697

Human scope-approval comment: #4697 (comment)

Does this PR complete the issue, or what remains? Completes it. The strict known cell {"I7": Known("#4282", ...)} in test_ownership_siblings.py::test_a_users_lsp_entry_is_never_taken_over is removed. The cell now asserts the lockfile is byte-identical after both install and install --force.

Type of change

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

Testing

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

Validation evidence (local, on main 488a4b1e):

Command Result
pytest tests/lifecycle/scenarios/test_ownership_siblings.py::test_a_users_lsp_entry_is_never_taken_over (real binary) passed; on main it fails with I7 ... failed install changed the lockfile
pytest tests/integration/test_lsp_user_entry_lifecycle.py (real binary, #4628 controls + MCP-write regression) 4 passed; the MCP regression fails on f0a4808
pytest on 40 LSP, service-integration, uninstall and prune modules (after review fold) 1903 passed, 4 skipped
pytest on the 22 unit, integration and quality modules touching LSP integration, the lockfile write authority, the transaction, service integration and the ledger 2591 passed
uvx [email protected] check / format --check (CI paths) clean
pylint R0801, scripts/lint-auth-signals.sh, scripts/lint-architecture-boundaries.sh clean
scripts/check_complexity_ratchet.py --base-ref <main> clean
python -m tests.quality.taxonomy --changed clean
tests/spec_conformance/mode_b_detector.sh 18 substantive lines (< 20), OK

Bug-ledger row: tests/fixtures/lifecycle_bug_ledger/bugs/4697.json.

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: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 22:14

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 conflict refusal can leave MCP writes deployed but unrecorded during service-only installs and prevent stale LSP entries and ownership claims from being cleaned up during uninstall.

2 open issues
What changed in this PR

This PR addresses #4697 by routing LSP user-entry conflicts through the install transaction’s commit-refusal mechanism when no other LSP server changed.

Changes:

  • Tracks whether an LSP conflict occurred alongside server changes.
  • Refuses lockfile commits for no-change conflicts while retaining partial-write handling.
  • Strengthens regression coverage and records the fix in the lifecycle ledger and changelog.
File Description
tests/​unit/​install/​test_lsp_integration.py Checks commit behavior with and without server writes.
tests/​lifecycle/​scenarios/​test_ownership_siblings.py Requires unchanged lockfile bytes after normal and forced conflicts.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​4697.json Records the bug and regression tests.
src/​apm_cli/​integration/​lsp_integrator.py Reports server changes on conflict errors.
src/​apm_cli/​install/​lsp/​integration.py Converts no-change conflicts into commit refusals.
src/​apm_cli/​install/​errors.py Adds conflict write metadata and the refusal exception.
changelog.d/​4705.fixed.md Documents the lockfile-preservation fix.

Review effort: Balanced

Comment thread src/apm_cli/install/lsp/integration.py Resolved
Comment thread src/apm_cli/install/lsp/integration.py Resolved
… needs recording (#4697)

Review fold for #4705:
- Uninstall and prune reconcile LSP in memory (persist=False): a user-entry
  conflict finishes stale cleanup and ownership updates before failing.
- When the MCP stage of the same command already staged a lockfile change
  (an MCP connection written), the conflict commits instead of refusing, so
  that write stays recorded; MCP adapter writes are outside the deploy journal.

Co-authored-by: Copilot App <[email protected]>
apm-spec-waiver: bug fix restoring lifecycle law I7 for a failed install on a user LSP entry conflict; OpenAPM v0.1 specifies no LSP config ownership, so no new normative surface.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit adbee57 into main Nov 22, 2026
70 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-4697-lsp-conflict-lock branch November 22, 2026 08:43
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] A failed install on a user LSP entry conflict still changes apm.lock.yaml

2 participants