fix(task-14): per-space resolution, mirrored inserts, tags above the box, per-axis scale

Closes the four verified BLOCKING findings on pid_graph.

1. scope="all" attached across layouts: the port grid, bbox candidates,
   vertex grid, junctions and text lookup were pooled from every space.
   The grid is now keyed by (space, cell) and every lookup filters by the
   edge's space; junctions carry `space`.
2. A mirrored INSERT (extrusion -Z, as MIRROR3D / foreign DXFs store it)
   got its catalogue ports on the unmirrored image at 1.0. Both engines
   report `mirrored` on INSERT properties (ezdxf: extrusion z < 0; COM:
   Normal z < 0; default False); transform_port takes `mirrored` and
   applies x -> -x about the WCS insertion point after rotation/scale,
   direction (180 - d) mod 360 — cross-checked against Insert.matrix44.
   resolve_endpoint passes it through too, so draw_line starts on the
   mirror image as well.
3. The text-tag fallback searched a full circle around the box top, so a
   line label or note below the symbol beat the tag above it. Candidates
   must now sit at or above top - height/2 (spec §9.2 step 6), nearest
   wins, and line-number texts are never equipment tags.
4. A non-uniform INSERT scale re-ran the transform with the X factor and
   set `inferred` (reserved for foreign-block ports). transform_port
   gains `strict=False` for the reader: point ports scale per axis
   exactly; a radial port keeps min(sx, sy)·r and the node drops to 0.6
   with notes ["non-uniform scale"]. Node dicts gain `y_scale`,
   `mirrored` and `notes` (default []).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
Umut CAN
2026-09-16 10:35:20 +03:00
co-authored by Claude Opus 5
parent ea47cbdd7e
commit 6ad3734c47
8 changed files with 388 additions and 50 deletions
+5 -2
View File
@@ -65,8 +65,10 @@ async def resolve_endpoint(backend: AutoCADBackend, ref: dict) -> dict:
ins = info.properties["insertion"]
x_scale = float(info.properties.get("x_scale", 1.0))
# The full INSERT transform: a mirrored symbol (``entity_mirror`` writes
# ``y_scale = -1``) has its ports on the mirrored geometry, not on the
# unmirrored one; a stretched symbol is refused by ``transform_port``.
# ``y_scale = -1``; MIRROR3D and foreign DXFs store extrusion -Z, which
# the engines report as ``mirrored``) has its ports on the mirrored
# geometry, not on the unmirrored one; a stretched symbol is refused
# by ``transform_port``.
try:
world = transform_port(
Port(port_name, float(lx), float(ly), ldir, kind, float(radius)),
@@ -75,6 +77,7 @@ async def resolve_endpoint(backend: AutoCADBackend, ref: dict) -> dict:
float(info.properties.get("rotation_deg", 0.0)),
x_scale,
float(info.properties.get("y_scale", x_scale)),
bool(info.properties.get("mirrored", False)),
)
except ValueError as exc:
raise ValueError(f"{handle}: {exc}") from exc