Skip to content

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

fix(workflow): report every overlapping node pair in one validation round

tt-a1i3f72d7605312
diff --git a/archify.zip b/archify.zip
index a0c86519..105a1dae 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/renderers/workflow/workflow-compiler.mjs b/archify/renderers/workflow/workflow-compiler.mjs
index 8b6b9735..f559211c 100644
--- a/archify/renderers/workflow/workflow-compiler.mjs
+++ b/archify/renderers/workflow/workflow-compiler.mjs
@@ -2729,6 +2729,10 @@ function validateReadableInputsBeforeRouting() {
}
byLane.set(node.lane, [...(byLane.get(node.lane) || []), node]);
}
+ // Every overlapping pair is reported at once. Failing on the first pair
+ // made an author who stacked two groups of nodes fix one, rerun, and only
+ // then learn about the other; the draft already contained both.
+ const overlaps = [];
for (const [lane, laneNodes] of byLane) {
for (let left = 0; left < laneNodes.length; left += 1) {
for (let right = left + 1; right < laneNodes.length; right += 1) {
@@ -2748,7 +2752,7 @@ function validateReadableInputsBeforeRouting() {
: [];
});
const message = `Workflow nodes "${leftNode.id}" and "${rightNode.id}" are less than 8px apart in lane "${lane}".`;
- fail({
+ overlaps.push({
code: 'workflow/node-overlap',
severity: 'error',
message,
@@ -2767,6 +2771,11 @@ function validateReadableInputsBeforeRouting() {
}
}
}
+ if (overlaps.length) {
+ throwDiagnosticError(overlaps.length === 1
+ ? overlaps[0].message
+ : `Workflow node overlap:\n- ${overlaps.map((entry) => entry.message).join('\n- ')}`, overlaps);
+ }
}
function gapYBetween(fromLane, toLane, bias = 0.5) {
diff --git a/archify/test/architecture-first-draft.test.mjs b/archify/test/architecture-first-draft.test.mjs
index 6cf0c32a..67dfd698 100644
--- a/archify/test/architecture-first-draft.test.mjs
+++ b/archify/test/architecture-first-draft.test.mjs
@@ -75,3 +75,16 @@ test('architecture: a self-loop with cramped explicit sides names the loop and t
fs.rmSync(tmp, { recursive: true, force: true });
}
});
+
+// The workflow draft from the same study stacked two separate groups of nodes
+// in one lane. Failing on the first pair cost the author a full round before
+// the second group was even reported.
+test('workflow: every overlapping node pair of a first draft is reported in one round', () => {
+ const { status, receipt } = validate('workflow', path.join(skillRoot, 'test/fixtures/workflow-first-draft/release-luna.workflow.json'));
+ assert.equal(status, 1);
+ const overlaps = receipt.diagnostics.filter((entry) => entry.code === 'workflow/node-overlap');
+ assert.equal(overlaps.length, 7, JSON.stringify(receipt.diagnostics, null, 2));
+ const pairs = overlaps.map((entry) => entry.evidence.nodes.map((node) => node.id).join('>'));
+ assert.ok(pairs.includes('test_join>staging_deploy'));
+ assert.ok(pairs.includes('metric_gate>rollback_stable'));
+});
diff --git a/archify/test/fixtures/workflow-first-draft/release-luna.workflow.json b/archify/test/fixtures/workflow-first-draft/release-luna.workflow.json
new file mode 100644
index 00000000..f77364c1
--- /dev/null
+++ b/archify/test/fixtures/workflow-first-draft/release-luna.workflow.json
@@ -0,0 +1,379 @@
+{
+ "schema_version": 2,
+ "diagram_type": "workflow",
+ "meta": {
+ "title": "一次生产发布审批工作流",
+ "locale": "zh-CN",
+ "quality_profile": "showcase",
+ "output": "release-luna.html"
+ },
+ "lanes": [
+ {
+ "id": "developer",
+ "label": "开发者"
+ },
+ {
+ "id": "ci",
+ "label": "CI 与发布平台"
+ },
+ {
+ "id": "oncall",
+ "label": "值班负责人"
+ },
+ {
+ "id": "audit",
+ "label": "审计旁路"
+ }
+ ],
+ "phases": [
+ {
+ "id": "build_phase",
+ "label": "提交与验证",
+ "fromCol": 0,
+ "toCol": 2
+ },
+ {
+ "id": "approval_phase",
+ "label": "预发布与审批",
+ "fromCol": 2,
+ "toCol": 4
+ },
+ {
+ "id": "release_phase",
+ "label": "灰度与全量",
+ "fromCol": 4,
+ "toCol": 5
+ }
+ ],
+ "groups": [
+ {
+ "id": "parallel_checks",
+ "label": "并行检查,全部通过才汇合",
+ "lane": "ci",
+ "fromCol": 1,
+ "toCol": 2,
+ "variant": "security"
+ }
+ ],
+ "mainPath": [
+ "submit_release",
+ "test_join",
+ "staging_deploy",
+ "smoke_test",
+ "duty_approval",
+ "canary_5",
+ "metric_gate",
+ "full_release",
+ "publish_success"
+ ],
+ "nodes": [
+ {
+ "id": "submit_release",
+ "lane": "developer",
+ "col": 0,
+ "type": "frontend",
+ "label": "提交版本",
+ "sublabel": "开发者发起发布"
+ },
+ {
+ "id": "unit_tests",
+ "lane": "ci",
+ "col": 1,
+ "type": "backend",
+ "label": "单元测试",
+ "sublabel": "并行执行",
+ "yOffset": -68
+ },
+ {
+ "id": "security_scan",
+ "lane": "ci",
+ "col": 1,
+ "type": "security",
+ "label": "安全扫描",
+ "sublabel": "并行执行",
+ "yOffset": 68
+ },
+ {
+ "id": "test_join",
+ "lane": "ci",
+ "col": 2,
+ "type": "backend",
+ "label": "检查汇合",
+ "sublabel": "两项均通过"
+ },
+ {
+ "id": "staging_deploy",
+ "lane": "ci",
+ "col": 2,
+ "type": "cloud",
+ "label": "预发布部署",
+ "sublabel": "部署候选版本"
+ },
+ {
+ "id": "smoke_test",
+ "lane": "ci",
+ "col": 3,
+ "type": "backend",
+ "label": "冒烟测试",
+ "sublabel": "验证预发布环境"
+ },
+ {
+ "id": "duty_approval",
+ "lane": "oncall",
+ "col": 4,
+ "type": "security",
+ "label": "值班负责人审批",
+ "sublabel": "批准或拒绝"
+ },
+ {
+ "id": "canary_5",
+ "lane": "ci",
+ "col": 4,
+ "type": "cloud",
+ "label": "5% 灰度",
+ "sublabel": "观察生产指标"
+ },
+ {
+ "id": "metric_gate",
+ "lane": "ci",
+ "col": 5,
+ "type": "security",
+ "label": "指标达标?",
+ "sublabel": "灰度结果分支"
+ },
+ {
+ "id": "rollback_stable",
+ "lane": "ci",
+ "col": 5,
+ "type": "backend",
+ "label": "回滚上一稳定版本",
+ "sublabel": "指标不达标"
+ },
+ {
+ "id": "rollback_end",
+ "lane": "ci",
+ "col": 5,
+ "type": "external",
+ "label": "终止本次发布",
+ "sublabel": "通知负责人;不自动重试"
+ },
+ {
+ "id": "full_release",
+ "lane": "ci",
+ "col": 5,
+ "type": "cloud",
+ "label": "全量发布",
+ "sublabel": "指标达标"
+ },
+ {
+ "id": "publish_success",
+ "lane": "developer",
+ "col": 5,
+ "type": "external",
+ "label": "通知开发者成功"
+ },
+ {
+ "id": "revise_version",
+ "lane": "developer",
+ "col": 1,
+ "type": "frontend",
+ "label": "修改版本",
+ "sublabel": "修复后重新提交",
+ "yOffset": 175
+ },
+ {
+ "id": "audit_log",
+ "lane": "audit",
+ "col": 3,
+ "type": "database",
+ "label": "审计日志",
+ "sublabel": "旁路记录:测试、审批、灰度、回滚",
+ "yOffset": 112
+ }
+ ],
+ "edges": [
+ {
+ "id": "submit_to_unit",
+ "from": "submit_release",
+ "to": "unit_tests",
+ "label": "提交后触发",
+ "role": "main"
+ },
+ {
+ "id": "submit_to_scan",
+ "from": "submit_release",
+ "to": "security_scan",
+ "label": "提交后触发",
+ "role": "branch",
+ "variant": "security"
+ },
+ {
+ "id": "unit_pass",
+ "from": "unit_tests",
+ "to": "test_join",
+ "label": "通过"
+ },
+ {
+ "id": "scan_pass",
+ "from": "security_scan",
+ "to": "test_join",
+ "label": "通过",
+ "variant": "security"
+ },
+ {
+ "id": "join_to_staging",
+ "from": "test_join",
+ "to": "staging_deploy",
+ "label": "两项均通过",
+ "role": "main"
+ },
+ {
+ "id": "staging_to_smoke",
+ "from": "staging_deploy",
+ "to": "smoke_test",
+ "label": "部署完成",
+ "role": "main"
+ },
+ {
+ "id": "smoke_to_approval",
+ "from": "smoke_test",
+ "to": "duty_approval",
+ "label": "冒烟通过",
+ "role": "main"
+ },
+ {
+ "id": "approval_to_canary",
+ "from": "duty_approval",
+ "to": "canary_5",
+ "label": "批准",
+ "role": "main"
+ },
+ {
+ "id": "canary_to_gate",
+ "from": "canary_5",
+ "to": "metric_gate",
+ "label": "观察完成",
+ "role": "main"
+ },
+ {
+ "id": "gate_to_full",
+ "from": "metric_gate",
+ "to": "full_release",
+ "label": "达标",
+ "role": "main"
+ },
+ {
+ "id": "full_to_success",
+ "from": "full_release",
+ "to": "publish_success",
+ "label": "发布完成",
+ "role": "main"
+ },
+ {
+ "id": "tests_fail_to_revise",
+ "from": "unit_tests",
+ "to": "revise_version",
+ "label": "失败,修改",
+ "role": "error",
+ "variant": "dashed"
+ },
+ {
+ "id": "scan_fail_to_revise",
+ "from": "security_scan",
+ "to": "revise_version",
+ "label": "失败,修改",
+ "role": "error",
+ "variant": "dashed"
+ },
+ {
+ "id": "smoke_fail_to_revise",
+ "from": "smoke_test",
+ "to": "revise_version",
+ "label": "失败,修改",
+ "role": "error",
+ "variant": "dashed"
+ },
+ {
+ "id": "approval_reject_to_revise",
+ "from": "duty_approval",
+ "to": "revise_version",
+ "label": "拒绝,修改",
+ "role": "error",
+ "variant": "dashed"
+ },
+ {
+ "id": "revise_to_submit",
+ "from": "revise_version",
+ "to": "submit_release",
+ "label": "重新提交",
+ "role": "return",
+ "variant": "dashed"
+ },
+ {
+ "id": "gate_to_rollback",
+ "from": "metric_gate",
+ "to": "rollback_stable",
+ "label": "不达标,回滚",
+ "role": "error",
+ "variant": "security"
+ },
+ {
+ "id": "rollback_to_end",
+ "from": "rollback_stable",
+ "to": "rollback_end",
+ "label": "回滚完成",
+ "role": "error",
+ "variant": "dashed"
+ },
+ {
+ "id": "test_audit",
+ "from": "test_join",
+ "to": "audit_log",
+ "label": "记录测试结果",
+ "role": "async",
+ "variant": "dashed"
+ },
+ {
+ "id": "approval_audit",
+ "from": "duty_approval",
+ "to": "audit_log",
+ "label": "记录审批决定",
+ "role": "async",
+ "variant": "dashed"
+ },
+ {
+ "id": "canary_audit",
+ "from": "metric_gate",
+ "to": "audit_log",
+ "label": "记录灰度结果",
+ "role": "async",
+ "variant": "dashed"
+ },
+ {
+ "id": "rollback_audit",
+ "from": "rollback_end",
+ "to": "audit_log",
+ "label": "记录回滚结果",
+ "role": "async",
+ "variant": "dashed"
+ }
+ ],
+ "cards": [
+ {
+ "dot": "cyan",
+ "title": "控制条件",
+ "items": [
+ "单元测试与安全扫描并行,只有全部通过才进入预发布。",
+ "审计日志是旁路记录,不决定成功或重试。"
+ ]
+ },
+ {
+ "dot": "amber",
+ "title": "失败路径",
+ "items": [
+ "测试、冒烟或审批拒绝都回到开发者修改并重新提交。",
+ "灰度指标不达标时回滚并终止本次发布,不自动重新灰度。"
+ ]
+ }
+ ]
+}
\ No newline at end of file