Skip to content

test(mcp): make removal-failure injection platform-independent - #3804

Merged
Daniel Meppiel (danielmeppiel) merged 2 commits into
mainfrom
danielmeppiel-t3-p1-removal-injection
Nov 17, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 2 commits into
mainfrom
danielmeppiel-t3-p1-removal-injection

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Main is red on Windows: build-release run 44160956996 on 932e45f (#3789) failed on Windows x86_64 unit tests with tests/unit/install/test_mcp_retired_shape_heal.py::test_unsupported_skip_keeps_the_claim_when_removal_fails -- "Failed: DID NOT RAISE RequiredIntegrationError".

Cause: the test injected the cleanup write failure by making the config directory read-only (chmod 0o500). Windows does not enforce POSIX directory modes, so the rewrite succeeded there.

Fix: patch the exact write the cleanup owner performs, apm_cli.integration.mcp_integrator.atomic_write_text (called by _clean_json_mcp_config, which _remove_native_entry uses for Antigravity's JSON config), to raise OSError, and assert the patched call happened. The assertions are unchanged: removal raises RequiredIntegrationError and the ownership claim is kept. Test-only change; no product code touched. This was the only chmod-based failure injection #3789 added (git show 932e45ffbf -- tests src | grep chmod).

Issue and approved scope

Issue: Refs #3736

Human scope-approval comment: #3736 (comment)

Does this PR complete the issue, or what remains? #3736 was completed by #3789; this repairs one of its tests on Windows.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Command Result
pytest -p no:xdist tests/unit/install/test_mcp_retired_shape_heal.py 12 passed
Mutation-break: move claims.discard(name) before the removal in _skip_unsupported_remote_transport test fails ({'antigravity': set()} != claim kept); restored
uvx [email protected] check / format --check (src/ tests/ scripts/...) passed
bash scripts/lint-auth-signals.sh, bash scripts/lint-architecture-boundaries.sh passed

Windows coverage: the test is now marked windows_compat, so the PR-time Windows Compatibility Gate (-m windows_compat tests/unit tests/integration on windows-latest) runs it before merge; without the marker no PR lane runs this file on Windows (build-release runs only on main, tags and schedule).

Platform independence: the failure is injected at the Python call site (unittest.mock.patch on the module attribute the owner calls), so it does not depend on filesystem permission semantics; write.assert_called_once() fails if the code path stops reaching that write.

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.

test_unsupported_skip_keeps_the_claim_when_removal_fails made the config
directory read-only (chmod 0o500) to fail the cleanup write. Windows does
not enforce POSIX directory modes, so the write succeeded and the test
failed on Windows x86_64 (build-release run 44160956996 on 932e45f).

Patch the exact write the cleanup owner performs
(apm_cli.integration.mcp_integrator.atomic_write_text) to raise OSError,
and assert it was called. The assertions are unchanged: the removal
raises RequiredIntegrationError and the ownership claim is kept.

Refs #3736

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

The PR-time Windows gate selects -m windows_compat; mark this test so the
platform-independent injection is exercised on Windows before merge.

Refs #3736

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 regression test lacks the windows_compat marker, so the existing pre-merge Windows gate will not exercise the failure-injection repair.

1 open issue
What changed in this PR

This test-only follow-up to #3789 makes MCP cleanup-failure injection platform-independent, addressing the Windows release-test failure without changing product code.

Changes:

  • Replaces POSIX directory-permission manipulation with a mocked atomic_write_text failure.
  • Verifies the write was attempted while preserving assertions that cleanup raises and retains the ownership claim and config entry.
File Description
tests/​unit/​install/​test_mcp_retired_shape_heal.py Uses deterministic write-failure injection instead of platform-dependent permissions.

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 7efd080 into main Nov 17, 2026
24 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-t3-p1-removal-injection branch November 17, 2026 20:46
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