Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

Preserve exact authored coordinates in component repair evidence

tt-a1i3d7fdcc0889a
diff --git a/archify/renderers/architecture/render-architecture.mjs b/archify/renderers/architecture/render-architecture.mjs
index c2039061..a561559a 100644
--- a/archify/renderers/architecture/render-architecture.mjs
+++ b/archify/renderers/architecture/render-architecture.mjs
@@ -467,6 +467,15 @@ if (arch.meta?.quality_profile === 'showcase') {
}
// ---- Validation: mechanical correctness, never layout taste -----------------
+function componentDiagnosticBox(component) {
+ return {
+ ...componentBox(component),
+ x: component.x,
+ y: component.y,
+ ...(Array.isArray(component.pos) ? { pos: [...component.pos] } : {}),
+ };
+}
+
function validateArchitecture() {
const problems = [];
const diagnostics = [];
@@ -543,7 +552,7 @@ function validateArchitecture() {
diagnostics.push({
code: 'layout/component-out-of-bounds', severity: 'error', message,
subject: { diagramType: 'architecture', nodeId: c.id },
- evidence: { bounds: componentBox(c), viewBox: [...viewBox], overflow },
+ evidence: { bounds: componentDiagnosticBox(c), viewBox: [...viewBox], overflow },
supportedFixes,
});
problems.push(message);
@@ -600,7 +609,7 @@ function validateArchitecture() {
diagnostics.push({
code: 'layout/component-overlap', severity: 'error', message,
subject: { diagramType: 'architecture', nodeId: list[i].id },
- evidence: { otherId: list[j].id, minimumGapPx: 8, boxes: [componentBox(list[i]), componentBox(list[j])] },
+ evidence: { otherId: list[j].id, minimumGapPx: 8, boxes: [componentDiagnosticBox(list[i]), componentDiagnosticBox(list[j])] },
supportedFixes: [
`move component "${list[j].id}" pos to [${separation[0].pos[0]}, ${separation[0].pos[1]}] (${separation[0].relation})`,
`or move component "${list[j].id}" pos to [${separation[1].pos[0]}, ${separation[1].pos[1]}] (${separation[1].relation})`,
diff --git a/test/architecture-component-diagnostics.test.mjs b/test/architecture-component-diagnostics.test.mjs
index 49091e12..680cd4a9 100644
--- a/test/architecture-component-diagnostics.test.mjs
+++ b/test/architecture-component-diagnostics.test.mjs
@@ -195,11 +195,15 @@ test('left/top overflow offers a directional move instead of a viewBox enlargeme
test('fractional geometry gets a separation coordinate that clears the minimum gap', t => {
const { cwd, input, diagram } = setup(t, [
- { id: 'a', type: 'backend', label: 'A', pos: [10.4, 10], size: [10, 20] },
- { id: 'b', type: 'backend', label: 'B', pos: [21, 10], size: [10, 20] },
+ { id: 'a', type: 'backend', label: 'A', pos: [10.4, 10.25], size: [10, 20] },
+ { id: 'b', type: 'backend', label: 'B', pos: [21.15, 10.25], size: [10, 20] },
], [400, 260]);
const overlap = validate(input, cwd).diagnostics.find(d => d.code === 'layout/component-overlap');
assert.ok(overlap, 'fractional coordinates still report the overlap');
+ assert.deepEqual(overlap.evidence.boxes.map(({ x, y, pos }) => ({ x, y, pos })), [
+ { x: 10.4, y: 10.25, pos: [10.4, 10.25] },
+ { x: 21.15, y: 10.25, pos: [21.15, 10.25] },
+ ], 'Repair evidence must preserve authored coordinates exactly.');
const move = overlap.supportedFixes[0].match(/pos to \[(\d+), (\d+)\]/);
assert.ok(move, overlap.supportedFixes[0]);
diagram.components[1].pos = [Number(move[1]), Number(move[2])];
@@ -230,6 +234,8 @@ test('a fractional edge overflow moves by the exact overflow, not a rounded pixe
], [320, 240]);
const outOfBounds = validate(input, cwd).diagnostics.find(d => d.code === 'layout/component-out-of-bounds');
assert.equal(outOfBounds.evidence.overflow.left, 10.44);
+ assert.equal(outOfBounds.evidence.bounds.x, -10.44);
+ assert.deepEqual(outOfBounds.evidence.bounds.pos, [-10.44, 20]);
const move = outOfBounds.supportedFixes[0].match(/right by ([\d.]+)px/);
assert.ok(move, outOfBounds.supportedFixes[0]);
// Exact, not rounded to any decimal grid: a rounded-down move leaves the