fix(server): stop stacking a tool profile's visibility on every session
Release / test (full, windows-latest, 3.11) (push) Canceled after 0s
Release / test (pdf, ubuntu-latest, 3.11) (push) Canceled after 0s
Release / test (pdf, ubuntu-latest, 3.12) (push) Canceled after 0s
Release / build (push) Canceled after 0s
Release / publish-pypi (push) Canceled after 0s
Release / github-release (push) Canceled after 0s

What the first Linux CI run of the 1.6 tree found.

- fastmcp 3's enable()/disable() append a Visibility transform per call,
  and a tool lookup walks the transform stack as nested calls. The
  lifespan re-applies the tool profile on every client connection, so an
  in-process server grew two layers per session until every tool call,
  system_status included, raised RecursionError (CPython 3.11 counts C
  frames against the limit). The profile's transforms now replace the
  previous ones, as _apply_discovery_mode already did; a test switches
  the profile 600 times and then calls a tool. The local suite runs in
  half the time it took with the stack growing.
- 21 fake-ActiveX tests build a real pywin32 VARIANT; they now skip
  without pywin32, like the suite's other VARIANT-dependent COM tests,
  and the Windows lane keeps running them.
- A test spelled a path through a directory it never created, which only
  Windows normalises away; it creates the directory.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
Umut CAN
2026-09-25 00:49:16 +03:00
co-authored by Claude Opus 5.5
parent 17bf3a39ce
commit cdb1063896
8 changed files with 99 additions and 1 deletions
+11
View File
@@ -10,6 +10,7 @@ Strategy:
from __future__ import annotations
import importlib.util
import math
import sys
from types import SimpleNamespace
@@ -21,6 +22,13 @@ import pytest
from backends.base import normalize_lineweight
from backends.com_backend import ComBackend
#: A path that marshals a point or an object array builds a real pywin32 VARIANT,
#: and pywin32 exists only on Windows. The Windows lane runs these; elsewhere
#: they skip, like the suite's other VARIANT-dependent COM tests.
needs_pywin32 = pytest.mark.skipif(
importlib.util.find_spec("win32com") is None, reason="pywin32 not installed"
)
@pytest.mark.asyncio
async def test_active_document_switch_clears_com_document_state(monkeypatch):
@@ -1312,6 +1320,7 @@ def _square(x0, y0, size):
@pytest.mark.asyncio
@needs_pywin32
async def test_a_chain_of_lines_becomes_one_closed_polyline_loop(island_seat):
"""A flattened bore is 180 line edges; one temporary polyline carries them
in a single COM call and is deleted once the hatch has evaluated it."""
@@ -1327,6 +1336,7 @@ async def test_a_chain_of_lines_becomes_one_closed_polyline_loop(island_seat):
@pytest.mark.asyncio
@needs_pywin32
async def test_arcs_stay_true_arcs_in_radians_and_clockwise_is_swapped(island_seat):
"""Curved-edge fidelity is the reason this tool exists: an arc edge becomes
an AcDbArc, never a chord chain. ActiveX arcs run counter-clockwise, so a
@@ -1355,6 +1365,7 @@ async def test_arcs_stay_true_arcs_in_radians_and_clockwise_is_swapped(island_se
@pytest.mark.asyncio
@needs_pywin32
async def test_a_loop_autocad_refuses_is_taken_back_out(island_seat):
"""AutoCAD answers an open loop with E_FAIL (measured); the temporary
entities are deleted and the call says nothing was added."""