Skip to content

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

fix(check): keep curved route pieces contiguous in analysis

To3akaRinaef1a3f6c9c5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d3a5300f..7ec56e6d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,7 @@ All notable changes are documented here. Format loosely follows [Keep a Changelo
### Fixed
-- **SVG 路径检查(#641)。** 统一解析关系线和结构边界的 `M/L/H/V/Q/Z` 路径,正确保留子路径与闭合语义;截断参数、非法数值和不支持的命令现在有限失败并给出定位诊断,避免检查挂起、漏检或虚构跨子路径线段。普通有效产物的 9 项检查保持不变。
+- **SVG 路径检查(#641)。** 统一解析关系线和结构边界的 `M/L/H/V/Q/Z` 路径,正确保留子路径与闭合语义;截断参数、非法数值和不支持的命令现在有限失败并给出定位诊断,避免检查挂起、漏检或虚构跨子路径线段。非共线 `Q` 前后的直线保留真实连续性,避免虚假交叉、标签遮挡和漏检;曲线采样点不会增加微线段预算。普通有效产物的 9 项检查保持不变。
- **Brand ICO data bounds (#585).** Capture and pinned re-fetches reject empty, directory-overlapping or out-of-bounds image ranges in ICO directory entries, while preserving valid PNG/DIB payloads and normal icon fallback.
### Changed
diff --git a/archify.zip b/archify.zip
index f448a374..30bdda5a 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/references/delivery-contract.md b/archify/references/delivery-contract.md
index 224d1641..ea770f23 100644
--- a/archify/references/delivery-contract.md
+++ b/archify/references/delivery-contract.md
@@ -336,10 +336,38 @@ recovery journal, or delivery lock makes every checker fail before accepting
the preserved HTML; report the diagnostics and complete a successful recovery
delivery before collecting new browser evidence.
+Static `check` uses the same SVG path analysis for inspected relationships and
+structural frames. It supports `M/L/H/V/Q/Z`, their lowercase relative forms,
+repeated parameters, and finite numbers. Each `M` starts an independent subpath;
+`Z` closes only the current subpath. Separate subpaths never create connecting
+segments that are absent from the drawing. Straight segments separated by a
+non-collinear `Q` also remain separate in route analysis; curve sample points
+do not become micro-segments in straight-route budgets or rhythm checks.
+Segment lengths and stretch are measured per continuous piece, while actual
+bends are summed per relationship. A relationship exceeding a budget is counted
+once, and internal piece boundaries do not receive the short shared-trunk
+exception reserved for semantic endpoints.
+
+This is not a promise of full SVG command support: `A/C/S/T` produce
+`artifact/svg-path-unsupported`; missing parameters, invalid numbers, and other
+syntax errors produce `artifact/svg-path-malformed`. The checker exits non-zero
+instead of skipping a bad path or waiting indefinitely. Path failures append a
+`svg_path_data` check; normal valid artifacts retain the existing nine checks.
+Diagnostics carry the inspected `pathIndex`, `role`, available relationship/frame
+`id`, parsing `tokenOffset`, available `command`, and `reason` so the generating
+source can be located and repaired. `pathIndex` is one-based; `tokenOffset` is a
+zero-based UTF-16 offset in `d` after numeric character references are decoded.
+Apparent tags in comments, CDATA, and attribute text are ignored. Passing static
+path checks does not establish browser or perceptual visual acceptance.
+
+<details>
+<summary>中文说明</summary>
+
静态 `check` 对受检关系线和结构边界的 SVG 路径使用同一解析结果,支持
`M/L/H/V/Q/Z` 及其小写相对形式、重复参数和有限数值。每个 `M` 开始独立
子路径,`Z` 只闭合当前子路径;子路径之间不会被拼接成图中不存在的线段。
-线段长度和伸长率按连续子路径测量,真实转弯数汇总到原关系;超预算关系
+非共线 `Q` 前后的直线也保持分离,不会把曲线采样点计为直线路由预算或
+节奏检查中的微线段。线段长度和伸长率按连续片段测量,真实转弯数汇总到原关系;超预算关系
只计一次,内部子路径断点不享有语义起终点的短共享线例外。
这不是完整 SVG 命令集的支持承诺:`A/C/S/T` 返回
`artifact/svg-path-unsupported`;缺少参数、非法数值等格式错误返回
@@ -351,6 +379,8 @@ delivery before collecting new browser evidence.
从 0 开始的 UTF-16 位置。注释、CDATA 和属性文本中的伪标签不参与检查。
静态路径检查通过仍不代表浏览器或感知视觉验收通过。
+</details>
+
The delivery interface exposes four separate claims:
1. `deliver` proves deterministic artifact checks and byte identity.
diff --git a/archify/scripts/check-render-output.mjs b/archify/scripts/check-render-output.mjs
index 345a9133..5e392c8e 100644
--- a/archify/scripts/check-render-output.mjs
+++ b/archify/scripts/check-render-output.mjs
@@ -483,9 +483,8 @@ function collectArrows(fragment, useActualPoints = false) {
const parsed = line ? null : inspectedPath(attrs, tag.index, pathIndex, 'relationship');
const segments = line ? lineSegments(attrs) : parsed.subpaths.flatMap(part => part.segments);
const borderSegments = line ? segments : parsed.subpaths.flatMap(part => part.straightSegments);
- const pointsOf = parts => parts.length ? [parts[0].start, ...parts.map(segment => segment.end)] : [];
- let routeSubpaths = line ? [pointsOf(segments)]
- : parsed.subpaths.map(part => pointsOf(part.straightSegments));
+ let routeSubpaths = line ? continuousRoutePoints(segments)
+ : parsed.subpaths.flatMap(part => continuousRoutePoints(part.straightSegments));
// Legacy single-path metadata remains supported. It cannot bridge actual moveto boundaries.
if (!useActualPoints && (line || parsed.subpaths.length === 1)) {
const authoredPoints = parseRoutePoints(attrs['data-composition-points']);
@@ -526,6 +525,21 @@ function collectArrows(fragment, useActualPoints = false) {
return arrows;
}
+function continuousRoutePoints(segments) {
+ const parts = [];
+ for (const { start, end } of segments) {
+ const previous = parts.at(-1);
+ // 非共线 Q 不参与直线预算;其两端也不能被拼接成一条虚构直线。
+ if (previous && previous.at(-1)[0] === start[0] && previous.at(-1)[1] === start[1]) {
+ previous.push(end);
+ } else {
+ parts.push([start, end]);
+ }
+ }
+ // 保留没有直线的子路径位置,避免把前一片段误认作语义终点。
+ return parts.length ? parts : [[]];
+}
+
function inspectedPath(attrs, offset, pathIndex, role) {
if (pathAnalyses.has(offset)) return pathAnalyses.get(offset);
const result = analyzeSvgPath(decodeNumericReferences(attrs.d || ''));
diff --git a/archify/test/svg-path-checker.test.mjs b/archify/test/svg-path-checker.test.mjs
index 440d06cf..4dd76c8c 100644
--- a/archify/test/svg-path-checker.test.mjs
+++ b/archify/test/svg-path-checker.test.mjs
@@ -38,7 +38,7 @@ async function check(t, body, { publicCli = false, rootAttrs = '', profile = 'sh
return execute(t, args, body);
}
-async function execute(t, args, description) {
+async function execute(t, args, description, timeoutMs = deadlineMs) {
const child = spawn(process.execPath, args, {
detached: process.platform !== 'win32',
stdio: ['ignore', 'pipe', 'pipe'],
@@ -55,7 +55,7 @@ async function execute(t, args, description) {
const timer = setTimeout(() => {
timedOut = true;
try { killTree(child); } catch (error) { cleanupError = error; }
- }, deadlineMs);
+ }, timeoutMs);
t.after(async () => {
clearTimeout(timer);
if (!exited) killTree(child);
@@ -65,7 +65,7 @@ async function execute(t, args, description) {
clearTimeout(timer);
assert.ifError(spawnError);
assert.ifError(cleanupError);
- assert.equal(timedOut, false, `路径检查在 ${deadlineMs}ms 内未退出,已终止进程树:${description}`);
+ assert.equal(timedOut, false, `路径检查在 ${timeoutMs}ms 内未退出,已终止进程树:${description}`);
assert.equal(result.signal, null, stderr);
assert.ok(stdout.trim(), `路径检查必须返回 JSON 回执:${stderr}`);
return { ...result, receipt: JSON.parse(stdout), stderr };
@@ -143,6 +143,32 @@ test('正常二次曲线继续受检,不能为拒绝其他曲线而禁止已
assertPass(await check(t, arrow('m20 20l60 0q20 0 20 20v80')));
});
+test('readable-v2 的圆角前后直线不生成虚假跨越,采样点不成为微线段', async t => {
+ const rounded = arrow('M20 20L80 20Q100 20 100 40L100 120');
+ const other = arrow('M50 70H96', { id: 'other', from: 'c', to: 'd', extra: 'data-edge-key="1"' });
+ const label = '<g data-edge-key="1" data-edge-from="c" data-edge-to="d" data-edge-label="Clear"><rect class="c-mask" x="84" y="64" width="8" height="12"/></g>';
+ const result = await check(t, rounded + other + label, {
+ publicCli: true, rootAttrs: 'data-layout-contract="readable-v2"',
+ });
+ assertPass(result);
+ const metrics = result.receipt.composition.metrics;
+ assert.equal(metrics.properCrossings, 0);
+ assert.equal(metrics.labelRouteClearanceIssues, 0);
+ assert.equal(metrics.maxBends, 0);
+ assert.equal(metrics.minSegmentPx, 46);
+ assert.equal(metrics.microSegmentCount, 0);
+});
+
+test('readable-v2 仍检出圆角后可见直线上的真实交叉', async t => {
+ const result = await check(t, arrow('M20 20L80 20Q100 20 100 40L100 120')
+ + arrow('M92 70H160', { id: 'other', from: 'c', to: 'd' }), {
+ publicCli: true, rootAttrs: 'data-layout-contract="readable-v2"',
+ });
+ assert.equal(result.code, 1);
+ assert.equal(result.receipt.checks.find(item => item.name === 'relationship_crossings').ok, false);
+ assert.deepEqual(result.receipt.composition.issues.find(item => item.code === 'composition/proper-crossing').point, [100, 70]);
+});
+
const disconnected = 'M20 20L100 20M100 100L200 100';
const acrossGap = arrow('M80 60L120 60', { id: 'other', from: 'c', to: 'd', extra: 'data-edge-key="1"' });
for (const rootAttrs of ['', 'data-layout-contract="readable-v2"']) {
@@ -246,6 +272,15 @@ test('多子路径只以真实最后一段检测 marker-end,早期片段不产
assert.equal(result.receipt.composition.metrics.arrowheadCollisions, 0);
});
+test('末尾仅有 M 的子路径不把早期直线当作最终箭头', async t => {
+ const result = await check(t, arrow('M20 20H100 M200 100', { from: 'a', to: 'end' })
+ + arrow('M20 21H100 M200 200', { id: 'other', from: 'b', to: 'end' }), {
+ publicCli: true, rootAttrs: 'data-layout-contract="readable-v2"',
+ });
+ assertPass(result);
+ assert.equal(result.receipt.composition.metrics.arrowheadCollisions, 0);
+});
+
for (const [name, left, right, from, to, passes] of [
['实际 source', 'M20 20H40V60 M100 100H140', 'M20 20H40V0 M180 100H220', 'a', 'other-end', true],
['内部 source', 'M20 20H60 M100 100H120V140', 'M20 60H60 M100 100H120V60', 'a', 'other-end', false],
@@ -322,7 +357,7 @@ process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'architectu
${JSON.stringify(path.join(skillRoot, 'examples/web-app.architecture.json'))}, ${JSON.stringify(output)}, '--json'];
await import(${JSON.stringify(pathToFileURL(cli).href)});
`);
- const result = await execute(t, [wrapper], 'deliver with an unsupported rendered path');
+ const result = await execute(t, [wrapper], 'deliver with an unsupported rendered path', deadlineMs * 5);
assert.equal(result.code, 1, JSON.stringify(result.receipt));
assert.equal(result.receipt.stage, 'check');
assert.equal(result.receipt.ok, false);