HEL-892: document Qwen prompt subgraph saved scopes and override chains
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -15,6 +15,9 @@ DEFINITION_SHA256 = "4da30b7b4314d6e3e37b3cefcaae710072ae0ee4e323e999789e63b3860
|
||||
|
||||
# Explicit path allowlist; a recomputed caller-supplied digest cannot extend trust.
|
||||
DEFINITIONS = {
|
||||
(
|
||||
"example_ComfyUI_workflows/3-图像生成/Qwen-Image-2.1/Qwen_image2.1_文生图_提示词增强.json"
|
||||
): "928548bb722554748fc961f3f2750ef993648a597622a39a1775d5117cc3bd9e",
|
||||
SOURCE_PATH: DEFINITION_SHA256,
|
||||
(
|
||||
"example_ComfyUI_workflows/0-基础处理:图像合"
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -202,8 +202,8 @@ def test_graph_specific_semantics_and_companion():
|
||||
assert d["dependencies"]["check_state"] == "unchecked"
|
||||
|
||||
|
||||
def test_other_seven_documents_and_block_swaps():
|
||||
assert len(DEFINITIONS) == 8
|
||||
def test_other_eight_documents_and_block_swaps():
|
||||
assert len(DEFINITIONS) == 9
|
||||
for path in DEFINITIONS:
|
||||
if path == PATH:
|
||||
continue
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
"""All saved scopes, bound overrides and rejection of forged editorial trust."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from calliope.comfyui.fixed_document import DEFINITIONS, canonical
|
||||
from calliope.comfyui.library import build_document
|
||||
from calliope.comfyui.source_reviews import review_for
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
OUT = REPO / "docs/hel-892/qwen-document-evidence"
|
||||
PATH = next(p for p in DEFINITIONS if p.endswith("Qwen_image2.1_文生图_提示词增强.json"))
|
||||
RAW = (REPO / PATH).read_bytes()
|
||||
SOURCE = json.loads(RAW)
|
||||
REVIEW = review_for(PATH, hashlib.sha1(RAW).hexdigest())
|
||||
BLOCK = REVIEW["fixed_version_document"]
|
||||
|
||||
|
||||
def doc(source=None, review=None, path=PATH):
|
||||
return build_document(
|
||||
path,
|
||||
SOURCE if source is None else source,
|
||||
None,
|
||||
None,
|
||||
[],
|
||||
REVIEW if review is None else review,
|
||||
)
|
||||
|
||||
|
||||
def pointer(obj, path):
|
||||
for part in path.strip("/").split("/"):
|
||||
part = part.replace("~1", "/").replace("~0", "~")
|
||||
obj = obj[int(part)] if isinstance(obj, list) else obj[part]
|
||||
return obj
|
||||
|
||||
|
||||
@pytest.mark.parametrize("index", range(64))
|
||||
def test_every_saved_position_scope_and_citation(index):
|
||||
f = BLOCK["fields"][index]
|
||||
v = pointer(SOURCE, f["pointer"])
|
||||
assert canonical(v) == canonical(f["value"]) and type(v).__name__ == f["json_type"]
|
||||
assert canonical(pointer(SOURCE, f["named_pointer"])) == canonical(v)
|
||||
prefix = f["pointer"].split("/widgets_values/")[0]
|
||||
n = pointer(SOURCE, prefix)
|
||||
assert str(n["id"]) == f["definition_node_id"] and n["type"] == f["class_type"]
|
||||
assert f["node_id"] == ("459:" if f["scope"] == "definition" else "") + str(n["id"])
|
||||
assert all(
|
||||
f[k]
|
||||
for k in [
|
||||
"effect",
|
||||
"label",
|
||||
"schema_default",
|
||||
"unit",
|
||||
"limits",
|
||||
"execution_note",
|
||||
"evidence",
|
||||
]
|
||||
)
|
||||
for i in f["evidence"]:
|
||||
e = BLOCK["sources"][i]
|
||||
raw = (OUT / e["local_file"]).read_bytes()
|
||||
assert hashlib.sha256(raw).hexdigest() == e["sha256"]
|
||||
assert len(e["commit"]) == 40 and e["commit"] in e["url"]
|
||||
assert 1 <= e["lines"][0] <= e["lines"][1] <= len(raw.decode().splitlines())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("index", range(64))
|
||||
@pytest.mark.parametrize("kind", ["value", "type", "pointer", "named"])
|
||||
def test_saved_and_named_mutations_cannot_rebind_document(index, kind):
|
||||
s, r = copy.deepcopy(SOURCE), copy.deepcopy(REVIEW)
|
||||
f = r["fixed_version_document"]["fields"][index]
|
||||
if kind == "pointer":
|
||||
f["pointer"] = "/definitions/subgraphs/999/nodes/999/widgets_values/0"
|
||||
else:
|
||||
p = f["named_pointer"] if kind == "named" else f["pointer"]
|
||||
parent, _, key = p.rpartition("/")
|
||||
target = pointer(s, parent)
|
||||
target[int(key) if isinstance(target, list) else key] = (
|
||||
{"forged": True} if kind != "type" else str(f["value"]) + "tampered"
|
||||
)
|
||||
r["fixed_version_document"]["canonical_sha256"] = hashlib.sha256(canonical(s)).hexdigest()
|
||||
r["caller_digest"] = hashlib.sha256(canonical(r["fixed_version_document"])).hexdigest()
|
||||
fixed = doc(s, r)["fixed_version"]
|
||||
assert not fixed["matched"] and "fields" not in fixed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("index", range(17))
|
||||
def test_host_bindings_are_scoped_named_and_have_physical_provenance(index):
|
||||
b = BLOCK["bindings"][index]
|
||||
assert b["value_pointer"] == f"/nodes/1/widgets_values/{index}"
|
||||
assert canonical(pointer(SOURCE, b["named_pointer"])) == canonical(
|
||||
pointer(SOURCE, b["value_pointer"])
|
||||
)
|
||||
boundary = pointer(SOURCE, b["boundary_pointer"])
|
||||
assert boundary["id"] == b["boundary_id"] and boundary["name"] == b["name"]
|
||||
for t in b["targets"]:
|
||||
socket = pointer(SOURCE, t["target_pointer"])
|
||||
edge = pointer(SOURCE, t["link_pointer"])
|
||||
assert socket["name"] == t["field"] and socket["link"] == edge["id"]
|
||||
assert edge["origin_slot"] == index and edge["target_id"] == int(t["definition_node_id"])
|
||||
assert "widgetId(rootGraph.id, 459," in b["widget_id_rule"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"kind",
|
||||
[
|
||||
"source_path",
|
||||
"sha1",
|
||||
"sha256",
|
||||
"canonical",
|
||||
"subgraph_digest",
|
||||
"definition_id",
|
||||
"scope",
|
||||
"widgetId",
|
||||
"boundary",
|
||||
"seed1",
|
||||
"seed2",
|
||||
"prompt",
|
||||
"note1",
|
||||
"note2",
|
||||
"model",
|
||||
"edge",
|
||||
"source",
|
||||
"citation",
|
||||
"version",
|
||||
"frontend",
|
||||
"host_name",
|
||||
"host_binding",
|
||||
"switch",
|
||||
"text_template",
|
||||
"companion",
|
||||
],
|
||||
)
|
||||
def test_forged_identity_graph_and_caller_digest_are_refused(kind):
|
||||
s, r = copy.deepcopy(SOURCE), copy.deepcopy(REVIEW)
|
||||
b = r["fixed_version_document"]
|
||||
g = s["definitions"]["subgraphs"][0]
|
||||
if kind == "source_path":
|
||||
b["source_path"] = "other.json"
|
||||
elif kind == "sha1":
|
||||
r["source_sha"] = "0" * 40
|
||||
elif kind == "sha256":
|
||||
b["source_sha256"] = "0" * 64
|
||||
elif kind == "canonical":
|
||||
b["canonical_sha256"] = "0" * 64
|
||||
elif kind == "subgraph_digest":
|
||||
b["subgraph_sha256"] = "0" * 64
|
||||
elif kind == "definition_id":
|
||||
g["id"] = "forged"
|
||||
elif kind == "scope":
|
||||
b["fields"][-1]["scope"] = "root"
|
||||
elif kind == "widgetId":
|
||||
b["bindings"][0]["widget_id_rule"] = "widgetId(other,459,prompt)"
|
||||
elif kind == "boundary":
|
||||
g["inputs"][0]["linkIds"].reverse()
|
||||
elif kind in ["seed1", "seed2"]:
|
||||
g["nodes"][6 if kind == "seed1" else 7]["widgets_values"][0 if kind == "seed1" else 8] = 777
|
||||
elif kind == "prompt":
|
||||
s["nodes"][5]["widgets_values"][0] = "forged"
|
||||
elif kind in ["note1", "note2"]:
|
||||
s["nodes"][3 if kind == "note1" else 4]["widgets_values"][0] = "forged"
|
||||
elif kind == "model":
|
||||
g["nodes"][0]["widgets_values"][0] = "other.safetensors"
|
||||
elif kind == "edge":
|
||||
g["links"][0]["origin_slot"] = 1
|
||||
elif kind == "source":
|
||||
b["sources"][0]["commit"] = "0" * 40
|
||||
elif kind == "citation":
|
||||
b["sources"][0]["lines"] = [1, 2]
|
||||
elif kind == "version":
|
||||
g["nodes"][0]["properties"]["ver"] = "0.33.0"
|
||||
elif kind == "frontend":
|
||||
s["extra"]["frontendVersion"] = "1.53.10"
|
||||
elif kind == "host_name":
|
||||
s["nodes"][1]["inputs"][8]["name"] = "sampler"
|
||||
elif kind == "host_binding":
|
||||
g["links"][19]["target_slot"] = 7
|
||||
elif kind == "switch":
|
||||
g["nodes"][10]["widgets_values"][0] = True
|
||||
elif kind == "text_template":
|
||||
g["nodes"][7]["widgets_values"][11] = True
|
||||
else:
|
||||
b["companion_difference"]["export_sha256"] = "0" * 64
|
||||
if kind != "canonical":
|
||||
b["canonical_sha256"] = hashlib.sha256(canonical(s)).hexdigest()
|
||||
if kind != "subgraph_digest":
|
||||
b["subgraph_sha256"] = hashlib.sha256(canonical(g)).hexdigest()
|
||||
r["caller_digest"] = hashlib.sha256(canonical(b)).hexdigest()
|
||||
assert doc(s, r)["fixed_version"]["matched"] is False
|
||||
|
||||
|
||||
def test_exact_coverage_override_chains_and_api_difference():
|
||||
b = doc()["fixed_version"]
|
||||
assert b["matched"]
|
||||
saved = set()
|
||||
for scope, g in [("root", SOURCE), ("def", SOURCE["definitions"]["subgraphs"][0])]:
|
||||
for i, n in enumerate(g["nodes"]):
|
||||
if n["type"] == "MarkdownNote":
|
||||
continue
|
||||
for j, _ in enumerate(n.get("widgets_values", [])):
|
||||
saved.add(
|
||||
("/nodes/" if scope == "root" else "/definitions/subgraphs/0/nodes/")
|
||||
+ f"{i}/widgets_values/{j}"
|
||||
)
|
||||
assert saved == {f["pointer"] for f in b["fields"]} and len(saved) == 64
|
||||
assert sum(f["scope"] == "root" for f in b["fields"]) == 25
|
||||
assert len(b["comments"]) == 2 and all(
|
||||
pointer(SOURCE, c["pointer"]) == c["text"] for c in b["comments"]
|
||||
)
|
||||
fields = {(f["node_id"], f["field"]): f for f in b["fields"]}
|
||||
for nid, name in [("459:458", "seed"), ("459:471", "sampling_mode.seed")]:
|
||||
f = fields[nid, name]
|
||||
assert f["value"] == 0 and f["binding"]["value_pointer"] == "/nodes/1/widgets_values/10"
|
||||
assert fields["459", "seed"]["value"] == 447606998181263
|
||||
assert fields["459", "scheduler"]["binding"]["targets"][0]["field"] == "sampler_name"
|
||||
assert fields["459", "scheduler_1"]["binding"]["targets"][0]["field"] == "scheduler"
|
||||
assert "713" in fields["459", "prompt"]["execution_note"]
|
||||
assert all("覆盖" in fields["459", name]["execution_note"] for name in ["width", "height"])
|
||||
assert fields["459:471", "use_default_template"]["value"] is False
|
||||
assert "不采用" in fields["459:475", "value"]["execution_note"]
|
||||
assert (
|
||||
fields["459:474", "switch"]["value"] is False and fields["459", "switch"]["value"] is True
|
||||
)
|
||||
diff = b["companion_difference"]["differences"]
|
||||
assert len(diff) == 16 and sum(d["field"] == "_meta" for d in diff) == 14
|
||||
assert {(d["node_id"], d["field"]) for d in diff if d["field"] != "_meta"} == {
|
||||
("459:451", "unet_name"),
|
||||
("459:473", "clip_name"),
|
||||
}
|
||||
assert (
|
||||
b["counts"]["final_entities"] == 16
|
||||
and b["counts"]["final_scalars"] == 42
|
||||
and b["counts"]["final_endpoints"] == 18
|
||||
)
|
||||
@@ -0,0 +1,988 @@
|
||||
"""Source-bound Qwen subgraph editorial document. Never execute upstream or a model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[3]
|
||||
OUT = Path(__file__).resolve().parent
|
||||
PATH = "example_ComfyUI_workflows/3-图像生成/Qwen-Image-2.1/Qwen_image2.1_文生图_提示词增强.json"
|
||||
|
||||
|
||||
def canonical(value):
|
||||
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()
|
||||
|
||||
|
||||
def build():
|
||||
from calliope.comfyui.serialization_reference import CASE04_PROFILE
|
||||
from calliope.comfyui.ui2api import convert_reference
|
||||
|
||||
raw = (REPO / PATH).read_bytes()
|
||||
s = json.loads(raw)
|
||||
g = s["definitions"]["subgraphs"][0]
|
||||
refs, fields = [], []
|
||||
|
||||
def ref(directory, filename, start, end, claim):
|
||||
root = OUT.parent / directory
|
||||
item = next(
|
||||
x
|
||||
for x in json.loads((root / "sources.json").read_bytes())["sources"]
|
||||
if x["local_file"] == filename
|
||||
)
|
||||
data = (root / filename).read_bytes()
|
||||
assert hashlib.sha256(data).hexdigest() == item["sha256"]
|
||||
assert 1 <= start <= end <= len(data.decode().splitlines())
|
||||
refs.append(
|
||||
{
|
||||
**{k: item[k] for k in ("id", "commit", "file", "sha256", "url")},
|
||||
"license": item.get("license", "沿用来源manifest许可"),
|
||||
"local_file": "../" + directory + "/" + filename,
|
||||
"lines": [start, end],
|
||||
"claim": claim,
|
||||
}
|
||||
)
|
||||
return len(refs) - 1
|
||||
|
||||
def core(file, start, end, claim):
|
||||
return ref("promoted-reference", "core-0.38.0__" + file, start, end, claim)
|
||||
|
||||
def case(file, start, end, claim):
|
||||
return ref("case04-reference", file, start, end, claim)
|
||||
|
||||
schemas = {
|
||||
"UNETLoader": core("nodes.py", 991, 1015, "UNET动态文件列表、精度枚举与加载选项"),
|
||||
"CLIPLoader": core("nodes.py", 1016, 1041, "CLIP动态文件、type注册枚举、device与加载调用"),
|
||||
"VAELoader": core("nodes.py", 775, 869, "VAE动态文件/近似模型列表、文件读取及校验"),
|
||||
"EmptyLatentImage": core("nodes.py", 1254, 1274, "latent宽高/batch schema与张量创建"),
|
||||
"KSampler": core(
|
||||
"nodes.py", 1605, 1644, "seed/steps/cfg/算法/调度/denoise声明及common_ksampler调用"
|
||||
),
|
||||
"TextGenerate": core(
|
||||
"comfy_extras__nodes_textgen.py",
|
||||
4,
|
||||
88,
|
||||
"动态on采样、生成长度、模板与system条件、MTP和文本输出",
|
||||
),
|
||||
"TextEncodeQwenImage21": core(
|
||||
"comfy_extras__nodes_qwen.py",
|
||||
111,
|
||||
182,
|
||||
"正负文本、参考图像分辨率、三出口及未接参考图条件",
|
||||
),
|
||||
"QwenImage21Cache": core(
|
||||
"comfy_extras__nodes_qwen.py",
|
||||
185,
|
||||
215,
|
||||
"cache枚举、clone及transformer_options写入;不证明实际缓存效果",
|
||||
),
|
||||
"ComfySwitchNode": core(
|
||||
"comfy_extras__nodes_logic.py", 86, 122, "switch为真取on_true、假取on_false及lazy请求"
|
||||
),
|
||||
"PrimitiveStringMultiline": core(
|
||||
"comfy_extras__nodes_primitive.py", 25, 42, "多行字符串schema与原字符串返回"
|
||||
),
|
||||
"VAEDecode": core("nodes.py", 320, 345, "LATENT和VAE输入、IMAGE输出与解码调用"),
|
||||
"PreviewAny": case(
|
||||
"0.38.0__comfy_extras__nodes_preview_any.py",
|
||||
9,
|
||||
48,
|
||||
"文本UI响应及原输入透传槽;本轮未执行",
|
||||
),
|
||||
"ResolutionSelector": case(
|
||||
"0.38.0__comfy_extras__nodes_resolution.py",
|
||||
7,
|
||||
90,
|
||||
"比例枚举、MP及倍数schema、1024平方和round对齐算法",
|
||||
),
|
||||
"SaveImageAdvanced": case(
|
||||
"0.38.0__comfy_extras__nodes_images.py",
|
||||
1769,
|
||||
1928,
|
||||
"png动态分支、前缀目录/计数器、可选元数据、ui.images描述",
|
||||
),
|
||||
}
|
||||
encoding = case(
|
||||
"0.38.0__comfy_extras__nodes_images.py",
|
||||
1639,
|
||||
1705,
|
||||
"PNG整数化/颜色条件与编码;没有处理真实图像",
|
||||
)
|
||||
restore = ref(
|
||||
"promoted-reference",
|
||||
"1.53.6__src__lib__litegraph__src__LGraphNode.ts",
|
||||
1072,
|
||||
1225,
|
||||
"控件位置与具名恢复/序列化;本图双存储互证",
|
||||
)
|
||||
host = ref(
|
||||
"structure-reference",
|
||||
"1.53.6__src__lib__litegraph__src__subgraph__SubgraphNode.ts",
|
||||
415,
|
||||
688,
|
||||
"从定义边界逐跳构造控件,widgetId(rootGraph.id,host.id,input.name)与host恢复",
|
||||
)
|
||||
hostsave = ref(
|
||||
"structure-reference",
|
||||
"1.53.6__src__lib__litegraph__src__subgraph__SubgraphNode.ts",
|
||||
986,
|
||||
1025,
|
||||
"host通过widgetId读取store并保存;字段名稳定,标签非字段",
|
||||
)
|
||||
wid = ref(
|
||||
"promoted-reference",
|
||||
"1.53.6__src__types__widgetId.ts",
|
||||
1,
|
||||
39,
|
||||
"控件身份由图/节点/字段组成,不将标签或位置当绑定",
|
||||
)
|
||||
execution = ref(
|
||||
"structure-reference",
|
||||
"1.53.6__src__utils__executionUtil.ts",
|
||||
76,
|
||||
180,
|
||||
"执行输入组装、具体边界解析和物理连线覆盖",
|
||||
)
|
||||
dyn = case(
|
||||
"1.53.6__src__core__graph__widgets__dynamicWidgets.ts",
|
||||
99,
|
||||
297,
|
||||
"动态分支构造限定名及状态恢复;sampling_mode.seed为限定名",
|
||||
)
|
||||
seed = ref(
|
||||
"promoted-reference",
|
||||
"1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useIntWidget.ts",
|
||||
30,
|
||||
88,
|
||||
"仅裸名seed/noise_seed或显式控制标记附加控制,不给限定名自动添控件",
|
||||
)
|
||||
control = case(
|
||||
"1.53.6__src__scripts__valueControl.ts", 1, 140, "fixed控制不改变保存值;未模拟队列钩子"
|
||||
)
|
||||
filename = case(
|
||||
"1.53.6__src__extensions__core__saveImageExtraOutput.ts",
|
||||
1,
|
||||
74,
|
||||
"保存前缀serialize替换入口;本图固定字符串不含替换token",
|
||||
)
|
||||
ref(
|
||||
"case04-reference",
|
||||
"1.53.6__src__utils__searchAndReplace.ts",
|
||||
5,
|
||||
57,
|
||||
"文件名前缀上下文替换,仅说明未调用",
|
||||
) if (
|
||||
OUT.parent / "case04-reference/1.53.6__src__utils__searchAndReplace.ts"
|
||||
).exists() else None
|
||||
limits_ref = core("nodes.py", 1, 58, "MAX_RESOLUTION常量16384")
|
||||
sampler_ref = case("0.38.0__comfy__samplers.py", 971, 986, "固定KSAMPLER_NAMES枚举")
|
||||
sampler_data = (
|
||||
(OUT.parent / "case04-reference/0.38.0__comfy__samplers.py").read_text().splitlines()
|
||||
)
|
||||
for i, line in enumerate(sampler_data):
|
||||
if line.startswith("SAMPLER_NAMES") or line.startswith("SCHEDULER_NAMES"):
|
||||
ref(
|
||||
"case04-reference",
|
||||
"0.38.0__comfy__samplers.py",
|
||||
i + 1,
|
||||
min(i + 15, len(sampler_data)),
|
||||
"算法/调度器静态名称;不等于目标可用列表",
|
||||
)
|
||||
|
||||
ref(
|
||||
"promoted-reference",
|
||||
"1.53.6__src__lib__litegraph__src__LGraphNode.ts",
|
||||
150,
|
||||
205,
|
||||
"双存储序列化与命名恢复状态",
|
||||
)
|
||||
ref(
|
||||
"promoted-reference",
|
||||
"1.53.6__src__lib__litegraph__src__LGraphNode.ts",
|
||||
1227,
|
||||
1288,
|
||||
"常规节点serializeFromStoreState保存控件",
|
||||
)
|
||||
core("nodes.py", 2075, 2135, "精确内置节点注册映射")
|
||||
core("nodes.py", 2470, 2535, "精确core扩展加载列表")
|
||||
core("comfy_extras__nodes_qwen.py", 237, 250, "Qwen扩展注册列表")
|
||||
# Editorial specifications are explicit, not inferred from labels or widget positions.
|
||||
spec = {}
|
||||
|
||||
def add(cls, name, label, typ, default, unit, limits, effect):
|
||||
spec[cls, name] = dict(
|
||||
field=name,
|
||||
label=label,
|
||||
type=typ,
|
||||
schema_default=default,
|
||||
unit=unit,
|
||||
limits=limits,
|
||||
effect=effect,
|
||||
evidence=[schemas[cls]],
|
||||
)
|
||||
|
||||
add(
|
||||
"ResolutionSelector",
|
||||
"aspect_ratio",
|
||||
"画面比例",
|
||||
"COMBO / STRING",
|
||||
"1:1 (Square)",
|
||||
"宽高比",
|
||||
"固定8项比例枚举,源3:4。",
|
||||
"决定宽高比例,和MP/倍数共同传给计算;不直接给实际产物尺寸。",
|
||||
)
|
||||
add(
|
||||
"ResolutionSelector",
|
||||
"megapixels",
|
||||
"目标像素总量",
|
||||
"FLOAT",
|
||||
"1.0",
|
||||
"MP(1024×1024像素尺度)",
|
||||
"0.1..16.0,schema步进0.1。",
|
||||
"total_pixels=MP×1024×1024,再按比例开方;本图1.5,不当作1024宽高或输出验证。",
|
||||
)
|
||||
add(
|
||||
"ResolutionSelector",
|
||||
"multiple",
|
||||
"尺寸对齐倍数",
|
||||
"INT",
|
||||
"8",
|
||||
"像素",
|
||||
"8..128,schema步进4。",
|
||||
"width/height分别按round(比例×scale/multiple)×multiple对齐;preview只前端显示,不额外保存或执行。",
|
||||
)
|
||||
for cls, name, label in [
|
||||
("UNETLoader", "unet_name", "扩散模型文件"),
|
||||
("CLIPLoader", "clip_name", "文本模型文件"),
|
||||
("VAELoader", "vae_name", "VAE文件"),
|
||||
]:
|
||||
add(
|
||||
cls,
|
||||
name,
|
||||
label,
|
||||
"动态COMBO / STRING",
|
||||
"动态列表首项,无固定默认文件名",
|
||||
"不适用",
|
||||
"文件列表依赖目标目录/注册;未检查。",
|
||||
(
|
||||
"保持源文件名与反斜杠;按对应diffusion_models/text_encoders/vae解析加载。名称中的int"
|
||||
"8/bf16不证明实际精度、硬件支持或内存效果。内部保存名和宿主覆盖名分列,不能按注释替换。"
|
||||
),
|
||||
)
|
||||
add(
|
||||
"UNETLoader",
|
||||
"weight_dtype",
|
||||
"UNET加载精度选项",
|
||||
"COMBO / STRING",
|
||||
"首项default",
|
||||
"不适用",
|
||||
"default/fp8_e4m3fn/fp8_e4m3fn_fast/fp8_e5m2。",
|
||||
"default不强设dtype;fp8选项设置模型dtype,fast另置fp8_optimizations。真实精度/性能依赖加载器和权重,未验证。",
|
||||
)
|
||||
add(
|
||||
"CLIPLoader",
|
||||
"type",
|
||||
"文本编码器类别",
|
||||
"COMBO / STRING",
|
||||
"首项stable_diffusion;函数默认同名",
|
||||
"不适用",
|
||||
"固定core枚举含qwen_image和stable_diffusion,完整枚举见引用。",
|
||||
"映射CLIPType再调load_clip;453保存qwen_image用于图像条件,473保存stable_diffusion用于PE文本生成,不能因模型名相似合并。",
|
||||
)
|
||||
add(
|
||||
"CLIPLoader",
|
||||
"device",
|
||||
"文本模型设备选择",
|
||||
"COMBO / STRING",
|
||||
"default",
|
||||
"不适用",
|
||||
"default/cpu。",
|
||||
"cpu显式设load/offload设备为CPU;default沿加载器策略,不承诺GPU常驻或设备可用。",
|
||||
)
|
||||
for name, label in [("width", "潜空间图像宽度"), ("height", "潜空间图像高度")]:
|
||||
add(
|
||||
"EmptyLatentImage",
|
||||
name,
|
||||
label,
|
||||
"INT",
|
||||
"1024",
|
||||
"像素尺度",
|
||||
"16..MAX_RESOLUTION=16384,schema步进8。",
|
||||
"供空latent创建,按height//8、width//8形成空间维度;本图被外部ResolutionSelector覆盖,不用内部1024推断产物。",
|
||||
)
|
||||
add(
|
||||
"EmptyLatentImage",
|
||||
"batch_size",
|
||||
"潜空间批量",
|
||||
"INT",
|
||||
"1",
|
||||
"张/批",
|
||||
"1..4096。",
|
||||
"决定空latent批量维;本图1。实际显存/批量产出依赖模型执行,未验证。",
|
||||
)
|
||||
for name, label, typ, default, limits, effect in [
|
||||
(
|
||||
"seed",
|
||||
"噪声种子",
|
||||
"INT",
|
||||
"0",
|
||||
"0..18446744073709551615;参考候选另限制JS安全整数。",
|
||||
"用于采样噪声。宿主同一seed还供文本生成,但两类含义各自独立;相同种子不保证目标推理可复现。",
|
||||
),
|
||||
(
|
||||
"control_after_generate",
|
||||
"生成后种子控制",
|
||||
"前端COMBO",
|
||||
"前端裸seed附加控件默认randomize;本图保存fixed",
|
||||
"fixed/increment/decrement/randomize;本参考仅fixed。",
|
||||
"附加前端控件,fixed保持值;不进入执行prompt,不模拟队列随机化。",
|
||||
),
|
||||
(
|
||||
"steps",
|
||||
"去噪步数",
|
||||
"INT",
|
||||
"20",
|
||||
"1..10000。",
|
||||
"传给common_ksampler的去噪步数;不承诺更多步提高质量或固定耗时。",
|
||||
),
|
||||
(
|
||||
"cfg",
|
||||
"条件引导强度",
|
||||
"FLOAT",
|
||||
"8.0",
|
||||
"0..100,schema步进0.1/round0.01。",
|
||||
"传入条件引导参数。源1不同于默认8;注释关于负向/质量仅源建议,不作模型质量保证。",
|
||||
),
|
||||
(
|
||||
"sampler_name",
|
||||
"采样算法",
|
||||
"COMBO / STRING",
|
||||
"SAMPLERS首项",
|
||||
"固定KSampler.SAMPLERS枚举;源euler。",
|
||||
"算法名称传给采样器;宿主字段名scheduler实际绑定此字段,不是调度器。",
|
||||
),
|
||||
(
|
||||
"scheduler",
|
||||
"噪声调度器",
|
||||
"COMBO / STRING",
|
||||
"SCHEDULERS首项",
|
||||
"固定KSampler.SCHEDULERS枚举;源simple。",
|
||||
"决定噪声序列调度;宿主scheduler_1才绑定此字段。",
|
||||
),
|
||||
(
|
||||
"denoise",
|
||||
"去噪比例",
|
||||
"FLOAT",
|
||||
"1.0",
|
||||
"0..1,schema步进0.01。",
|
||||
"传入采样denoise;本图空latent值1,不能保证质量或推断实际图像。",
|
||||
),
|
||||
]:
|
||||
add(
|
||||
"KSampler",
|
||||
name,
|
||||
label,
|
||||
typ,
|
||||
default,
|
||||
"步" if name == "steps" else "无量纲",
|
||||
limits,
|
||||
effect,
|
||||
)
|
||||
spec["KSampler", name]["evidence"] += [control, seed, sampler_ref]
|
||||
for name, label in [("prompt", "正向编码文本"), ("negative_prompt", "负向编码文本")]:
|
||||
add(
|
||||
"TextEncodeQwenImage21",
|
||||
name,
|
||||
label,
|
||||
"STRING",
|
||||
"未显式指定default",
|
||||
"不适用",
|
||||
"多行dynamic_prompts字符串;不执行文本。",
|
||||
(
|
||||
"分别编码正负条件;prompt实际接Switch经PreviewAny透传,negative_prompt接宿主空字符串"
|
||||
"。未接images/vae,不把未使用latent出口当采样输入。"
|
||||
),
|
||||
)
|
||||
add(
|
||||
"TextEncodeQwenImage21",
|
||||
"resolution",
|
||||
"参考图像缩放尺度",
|
||||
"INT",
|
||||
"1024",
|
||||
"像素尺度",
|
||||
"0..4096,schema步进32;0保留参考尺寸后按32对齐。",
|
||||
"仅参考图分支按约resolution平方像素保比例缩放;本图images未接、输出latent未用,不能当最终生成尺寸,采样尺寸来自EmptyLatentImage。",
|
||||
)
|
||||
text_specs = [
|
||||
(
|
||||
"prompt",
|
||||
"文本生成原始提示",
|
||||
"STRING",
|
||||
"空字符串",
|
||||
"多行dynamic_prompts;未声明长度界限。",
|
||||
"通过clip.tokenize进入生成;本图root483经713覆盖宿主prompt再到471,不采用内部空串。",
|
||||
),
|
||||
(
|
||||
"max_length",
|
||||
"文本生成长度上限",
|
||||
"INT",
|
||||
"512",
|
||||
"1..32768。",
|
||||
"传给clip.generate的max_length;不是汉字数保证或实际输出长度。",
|
||||
),
|
||||
(
|
||||
"sampling_mode",
|
||||
"文本采样模式",
|
||||
"动态COMBO / STRING",
|
||||
"首分支on",
|
||||
"on/off;本图on,off分支无子字段。",
|
||||
"决定do_sample;on展开限定名采样参数,不能照数组长度推断其它分支。",
|
||||
),
|
||||
(
|
||||
"sampling_mode.temperature",
|
||||
"文本采样温度",
|
||||
"FLOAT",
|
||||
"0.7",
|
||||
"0.01..2.0,schema步进0.000001。",
|
||||
"on分支传temperature;实际随机性/文本效果未实跑。",
|
||||
),
|
||||
(
|
||||
"sampling_mode.top_k",
|
||||
"文本top-k",
|
||||
"INT",
|
||||
"64",
|
||||
"0..1000。",
|
||||
"on分支传top_k;不把schema默认与执行缺省50混同。",
|
||||
),
|
||||
(
|
||||
"sampling_mode.top_p",
|
||||
"文本top-p",
|
||||
"FLOAT",
|
||||
"0.95",
|
||||
"0..1,schema步进0.01。",
|
||||
"on分支传top_p;不承诺质量与效果。",
|
||||
),
|
||||
(
|
||||
"sampling_mode.min_p",
|
||||
"文本min-p",
|
||||
"FLOAT",
|
||||
"0.05",
|
||||
"0..1,schema步进0.01。",
|
||||
"on分支传min_p;本图0,不等于schema默认0.05。",
|
||||
),
|
||||
(
|
||||
"sampling_mode.repetition_penalty",
|
||||
"文本重复惩罚",
|
||||
"FLOAT",
|
||||
"1.05",
|
||||
"0..5,schema步进0.01。",
|
||||
"on分支传repetition_penalty;数值调整效果未验证。",
|
||||
),
|
||||
(
|
||||
"sampling_mode.seed",
|
||||
"文本采样种子",
|
||||
"INT",
|
||||
"0",
|
||||
"0..18446744073709551615;参考JS安全域另限。",
|
||||
"本图接同一宿主447606998181263;限定名不是裸seed,前端不自动附加control_after_generate。内部0被覆盖。",
|
||||
),
|
||||
(
|
||||
"sampling_mode.presence_penalty",
|
||||
"文本出现惩罚",
|
||||
"FLOAT",
|
||||
"0.0",
|
||||
"可选,0..5,schema步进0.01。",
|
||||
"on分支传presence_penalty;本图0,效果未验证。",
|
||||
),
|
||||
(
|
||||
"thinking",
|
||||
"思考模式开关",
|
||||
"BOOLEAN",
|
||||
"false",
|
||||
"true/false;模型支持时才适用。",
|
||||
"传给tokenize的thinking;宿主false覆盖内部false。第二thinking输出未接,不声称已生成思考内容。",
|
||||
),
|
||||
(
|
||||
"use_default_template",
|
||||
"使用模型默认模板",
|
||||
"BOOLEAN",
|
||||
"true",
|
||||
"true/false。",
|
||||
"本图false使skip_template=true,system_prompt条件传空字符串,虽连475指南也不采用;不是默认true。",
|
||||
),
|
||||
(
|
||||
"mtp",
|
||||
"多token预测策略",
|
||||
"COMBO / STRING",
|
||||
"auto",
|
||||
"auto/off/2/3/4/5。",
|
||||
"auto转True、off转False、数字转int交generate;无MTP权重时无效,效果/速度/同seed输出不保证。",
|
||||
),
|
||||
]
|
||||
for name, label, typ, default, limits, effect in text_specs:
|
||||
add(
|
||||
"TextGenerate",
|
||||
name,
|
||||
label,
|
||||
typ,
|
||||
default,
|
||||
"token上限(非实际长度)" if name == "max_length" else "无量纲",
|
||||
limits,
|
||||
effect,
|
||||
)
|
||||
spec["TextGenerate", name]["evidence"] += [dyn, seed]
|
||||
add(
|
||||
"ComfySwitchNode",
|
||||
"switch",
|
||||
"提示词支路开关",
|
||||
"BOOLEAN",
|
||||
"schema未显式指定default;不把内部保存false当默认",
|
||||
"无量纲",
|
||||
"true→on_true;false→on_false。",
|
||||
"内部false被宿主true覆盖;本图true选择471生成文本,false才选483原文本。lazy仅请求选中支路,不按优化标签猜分支或保证增强效果。",
|
||||
)
|
||||
add(
|
||||
"PrimitiveStringMultiline",
|
||||
"value",
|
||||
"不透明原始文本",
|
||||
"STRING",
|
||||
"空字符串",
|
||||
"不适用",
|
||||
"多行文本,未声明静态长度界限。",
|
||||
(
|
||||
"原样透传字符串;root483供原始提示,内部475供system指南。475虽经709连471.system_prom"
|
||||
"pt,当前use_default_template=false使其不生效;未改写/求值/执行。"
|
||||
),
|
||||
)
|
||||
add(
|
||||
"QwenImage21Cache",
|
||||
"device",
|
||||
"KV缓存设备策略",
|
||||
"COMBO / STRING",
|
||||
"auto",
|
||||
"不适用",
|
||||
"auto/gpu/cpu/off。",
|
||||
(
|
||||
"clone模型并写qwen_image21_cache.device;源码tooltip说明auto先余显存后RAM、o"
|
||||
"ff逐步重算。实际硬件/内存/缓存是否使用未知,不称已加速。"
|
||||
),
|
||||
)
|
||||
add(
|
||||
"QwenImage21Cache",
|
||||
"dtype",
|
||||
"KV缓存存储精度",
|
||||
"COMBO / STRING",
|
||||
"default",
|
||||
"不适用",
|
||||
"default/int8/int4。",
|
||||
"写入cache.dtype,tooltip称default无损、int8/int4较低存储精度;实际误差/节省量未验证,不混同UNET权重精度。",
|
||||
)
|
||||
for name, label, default, limits, effect in [
|
||||
(
|
||||
"filename_prefix",
|
||||
"输出文件前缀",
|
||||
"ComfyUI",
|
||||
"字符串;本图固定前缀不含上下文替换token。",
|
||||
(
|
||||
"images来自459槽0;固定前缀image/Qwen_image_2.1交输出目录路径解析,计数器形成文件名。元数据"
|
||||
"受disable_metadata及hidden prompt/extra_pnginfo条件控制,未实际保存。"
|
||||
),
|
||||
),
|
||||
(
|
||||
"format",
|
||||
"图像保存格式",
|
||||
"首分支png",
|
||||
"png/exr/avif;本图只解释png保存分支。",
|
||||
"动态png选择决定下属bit_depth/input_color_space;schema其它分支不视为本图保存控件。",
|
||||
),
|
||||
(
|
||||
"format.bit_depth",
|
||||
"PNG位深",
|
||||
"8-bit",
|
||||
"png分支8-bit/16-bit。",
|
||||
"本图8-bit整数化/clamp后编码,支持通道数1/3/4依编码表;不证明透明背景或实际色深。",
|
||||
),
|
||||
(
|
||||
"format.input_color_space",
|
||||
"PNG输入色彩空间",
|
||||
"sRGB",
|
||||
"png分支仅sRGB。",
|
||||
"PNG路径色彩选择不修改像素;不套EXR的逆sRGB转换,实际输出色彩未验证。",
|
||||
),
|
||||
]:
|
||||
add(
|
||||
"SaveImageAdvanced",
|
||||
name,
|
||||
label,
|
||||
"STRING / COMBO" if name != "filename_prefix" else "STRING",
|
||||
default,
|
||||
"不适用",
|
||||
limits,
|
||||
effect,
|
||||
)
|
||||
spec["SaveImageAdvanced", name]["evidence"] += [encoding, filename, dyn]
|
||||
|
||||
result = convert_reference(s, CASE04_PROFILE)
|
||||
assert result.prompt is not None and result.reference_only
|
||||
# Reuse proven boundary resolver to corroborate bindings, never infer from UI labels.
|
||||
by_id = {n["id"]: n for n in g["nodes"]}
|
||||
bindings = []
|
||||
for slot, b in enumerate(g["inputs"]):
|
||||
targets = []
|
||||
for lid in b["linkIds"]:
|
||||
ei = next(i for i, e in enumerate(g["links"]) if e["id"] == lid)
|
||||
e = g["links"][ei]
|
||||
n = by_id[e["target_id"]]
|
||||
inp = n["inputs"][e["target_slot"]]
|
||||
assert inp.get("widget") is None or inp["widget"] == {"name": inp["name"]}
|
||||
targets.append(
|
||||
dict(
|
||||
node_id=f"459:{n['id']}",
|
||||
definition_node_id=str(n["id"]),
|
||||
field=inp["name"],
|
||||
link_pointer=f"/definitions/subgraphs/0/links/{ei}",
|
||||
target_pointer=f"/definitions/subgraphs/0/nodes/{g['nodes'].index(n)}/inputs/{e['target_slot']}",
|
||||
)
|
||||
)
|
||||
binding = dict(
|
||||
slot=slot,
|
||||
name=b["name"],
|
||||
boundary_id=b["id"],
|
||||
boundary_pointer=f"/definitions/subgraphs/0/inputs/{slot}",
|
||||
widget_id_rule=f"widgetId(rootGraph.id, 459, {b['name']!r})",
|
||||
value_pointer=f"/nodes/1/widgets_values/{slot}",
|
||||
named_pointer=f"/nodes/1/widgets_values_named/{b['name']}",
|
||||
targets=targets,
|
||||
)
|
||||
bindings.append(binding)
|
||||
target_host = {(t["node_id"], t["field"]): b for b in bindings for t in b["targets"]}
|
||||
for scope, graph in [("root", s), ("definition", g)]:
|
||||
for ni, n in enumerate(graph["nodes"]):
|
||||
if n["type"] == "MarkdownNote":
|
||||
continue
|
||||
prefix = f"/nodes/{ni}" if scope == "root" else f"/definitions/subgraphs/0/nodes/{ni}"
|
||||
nodeid = str(n["id"]) if scope == "root" else f"459:{n['id']}"
|
||||
names = list(n.get("widgets_values_named", {}))
|
||||
values = n.get("widgets_values", [])
|
||||
if n["id"] == 458:
|
||||
names = [
|
||||
"seed",
|
||||
"control_after_generate",
|
||||
"steps",
|
||||
"cfg",
|
||||
"sampler_name",
|
||||
"scheduler",
|
||||
"denoise",
|
||||
]
|
||||
assert len(values) == len(names)
|
||||
for offset, (name, v) in enumerate(zip(names, values)):
|
||||
binding = None
|
||||
if n["id"] == 459:
|
||||
binding = next(b for b in bindings if b["name"] == name)
|
||||
first = next(
|
||||
t
|
||||
for t in binding["targets"]
|
||||
if (by_id[int(t["definition_node_id"])]["type"], t["field"]) in spec
|
||||
)
|
||||
tn = by_id[int(first["definition_node_id"])]
|
||||
d = dict(spec[tn["type"], first["field"]])
|
||||
d["field"] = name
|
||||
d["label"] = "宿主暴露:" + d["label"]
|
||||
note = "宿主保存值,经稳定边界送至" + ", ".join(
|
||||
t["node_id"] + "." + t["field"] for t in binding["targets"]
|
||||
)
|
||||
else:
|
||||
d = dict(spec[n["type"], name])
|
||||
note = "固定参考采用此内部保存值;不等于目标执行已验证。"
|
||||
role = "scalar"
|
||||
if (nodeid, name) in target_host:
|
||||
b = target_host[nodeid, name]
|
||||
note = f"内部保存值保留,但被宿主{b['name']}({b['value_pointer']})覆盖。"
|
||||
binding = b
|
||||
role = "linked"
|
||||
if n["id"] == 459 and name in ["prompt", "width", "height"]:
|
||||
note += (
|
||||
";进一步被根物理外线覆盖:"
|
||||
+ {
|
||||
"prompt": "483槽0,经link713",
|
||||
"width": "13槽0,经link670",
|
||||
"height": "13槽1,经link671",
|
||||
}[name]
|
||||
)
|
||||
role = "linked"
|
||||
if nodeid in ["459:456", "459:471", "459:474"] and name in [
|
||||
"width",
|
||||
"height",
|
||||
"prompt",
|
||||
"on_false",
|
||||
]:
|
||||
note += "宿主" + (
|
||||
"prompt再被483槽0经713覆盖。"
|
||||
if name in ["prompt", "on_false"]
|
||||
else name + "再被ResolutionSelector13外线670/671覆盖。"
|
||||
)
|
||||
if (nodeid, name) == ("459:452", "prompt"):
|
||||
note = (
|
||||
"内部空文本被687覆盖:474槽0→472.source,"
|
||||
"472槽0透传→452.prompt;当前宿主switch=true选471。"
|
||||
)
|
||||
role = "linked"
|
||||
if name == "control_after_generate":
|
||||
role = "frontend"
|
||||
note = (
|
||||
"前端附加控制fixed不改变seed;执行输入中剔除。"
|
||||
"限定名sampling_mode.seed不新增此控件。"
|
||||
)
|
||||
if nodeid == "483":
|
||||
note = (
|
||||
"根483原字符串经713→459.prompt,分发到474.on_false与471.prompt,"
|
||||
"优先宿主英文缓存。"
|
||||
)
|
||||
if nodeid == "459:475":
|
||||
note = (
|
||||
"原system指南经709→471.system_prompt;use_default_template=false条件"
|
||||
"使传入tokenize的system_prompt为空,不采用此指南作为当前生效指令。"
|
||||
)
|
||||
d.update(
|
||||
node_id=nodeid,
|
||||
definition_node_id=str(n["id"]),
|
||||
scope=scope,
|
||||
class_type=n["type"],
|
||||
value=v,
|
||||
json_type=type(v).__name__,
|
||||
pointer=prefix + f"/widgets_values/{offset}",
|
||||
named_pointer=prefix + "/widgets_values_named/" + name,
|
||||
role=role,
|
||||
execution_note=note,
|
||||
evidence=list(
|
||||
dict.fromkeys(
|
||||
[*d["evidence"], restore, host, hostsave, wid, execution, limits_ref]
|
||||
)
|
||||
),
|
||||
)
|
||||
if binding:
|
||||
d["binding"] = binding
|
||||
fields.append(d)
|
||||
assert len(fields) == 64
|
||||
comments = [
|
||||
dict(
|
||||
node_id=str(n["id"]),
|
||||
pointer=f"/nodes/{i}/widgets_values/0",
|
||||
text=n["widgets_values"][0],
|
||||
)
|
||||
for i, n in enumerate(s["nodes"])
|
||||
if n["type"] == "MarkdownNote"
|
||||
]
|
||||
assert len(comments) == 2
|
||||
api_raw = (OUT.parent / "supplied-api/04.api.json").read_bytes()
|
||||
api = json.loads(api_raw)
|
||||
diffs = []
|
||||
scalars = endpoints = 0
|
||||
for nid, a in result.prompt.items():
|
||||
b = api[nid]
|
||||
assert a["class_type"] == b["class_type"] and a["inputs"].keys() == b["inputs"].keys()
|
||||
for name, v in a["inputs"].items():
|
||||
w = b["inputs"][name]
|
||||
assert type(v) is type(w)
|
||||
if isinstance(v, list):
|
||||
endpoints += 1
|
||||
else:
|
||||
scalars += 1
|
||||
if v != w:
|
||||
diffs.append(dict(node_id=nid, field=name, source_reference=v, supplied_api=w))
|
||||
if a.get("_meta") != b.get("_meta"):
|
||||
diffs.append(
|
||||
dict(
|
||||
node_id=nid,
|
||||
field="_meta",
|
||||
source_reference=a.get("_meta"),
|
||||
supplied_api=b.get("_meta"),
|
||||
)
|
||||
)
|
||||
assert len(result.prompt) == 16 and scalars == 42 and endpoints == 18
|
||||
assert sum(d["field"] == "_meta" for d in diffs) == 14
|
||||
assert len(diffs) == 16
|
||||
flows = [
|
||||
(
|
||||
"本图用途:根提示词可选文本生成后编码图像条件,经空latent采样、VAE解码、SaveImageAdvanced保存。"
|
||||
"源19节点(含宿主/两注释),根6节点4边,定义13节点33边,37源边与展开16实体/42最终标量/18端点分列。64"
|
||||
"保存位置不是64最终执行参数。"
|
||||
),
|
||||
(
|
||||
"作用域:根459实例引用definitions.subgraphs[0] c291ceec-b98f-4751-9d0b"
|
||||
"-7bc288f27b30;内部ID写459:451等,同时保留原定义节点ID。-10/-20只是子图边界虚拟节点,非执"
|
||||
"行算法。"
|
||||
),
|
||||
(
|
||||
"优先链:实际物理外线→宿主暴露值→内部保存值。17控件由固定SubgraphNode逐边界/内部widget构造,wid"
|
||||
"getId(rootGraph.id,459,input.name)寻址,具名/位置双存储一致;不按标签或端口数组猜。s"
|
||||
"cheduler标签sampler实际到458.sampler_name,scheduler_1到458.schedul"
|
||||
"er。"
|
||||
),
|
||||
(
|
||||
"prompt:483槽0经713→459.prompt;定义边684到474.on_false、711到471.prom"
|
||||
"pt,覆盖宿主英文缓存与内部空串。宿主switch=true经688覆盖474内部false,true取471槽0经71"
|
||||
"2至on_true;false才直取483。474槽0经686→472文本预览,472槽0经687→452.prompt"
|
||||
"。没有证明真实优化效果。"
|
||||
),
|
||||
(
|
||||
"system指南:475原字符串经709至471.system_prompt;本图use_default_templat"
|
||||
'e=false使tokenize(skip_template=true, system_prompt=""),所以指南虽'
|
||||
"保存/连线却不采用。thinking=false也不表示模型真实支持;两个原prompt和指南均未改写/执行。"
|
||||
),
|
||||
(
|
||||
"双seed:宿主/nodes/1/widgets_values/10=447606998181263经667→458.s"
|
||||
"eed与697→471.sampling_mode.seed;两内部0均被覆盖。KSampler附加fixed为前端控制"
|
||||
";限定名sampling_mode.seed不自动加控制,不声称队列随机化或目标可重复。"
|
||||
),
|
||||
(
|
||||
"尺寸:宿主width/height保存1024/1024被13经670/671覆盖,再经660/661到456;13比例"
|
||||
"3:4、1.5MP、multiple8,固定算法用MP×1024×1024开方并round到倍数。本轮未计算/生成产物,"
|
||||
"不把1024或注释2048×2048当实际输出。452.resolution仅参考图像尺度,本图未接images,不决定"
|
||||
"采样宽高。"
|
||||
),
|
||||
(
|
||||
"模型链:451→480→458.model;453→452.clip;473→471.clip;454→457.vae。"
|
||||
"宿主模型文件覆盖内部文件,反斜杠原样保留。动态列表/实际模型/设备/缓存/UE扩展安装未知,名称int8/bf16不证明"
|
||||
"实际精度或内存效果。"
|
||||
),
|
||||
(
|
||||
"条件和输出:452槽0/1分别→458.positive/negative;456→458.latent_image;4"
|
||||
"58→457.samples;457槽0→子图-20→459槽0经672→461.images。452额外latent出"
|
||||
"口未用。472仅文本预览/透传,不生成字幕文件。461固定png/8-bit/sRGB保存路径、元数据与ui.image"
|
||||
"s是源码协议,实际history/文件/尺寸/色彩未验证。"
|
||||
),
|
||||
(
|
||||
"两条MarkdownNote全文在下列原注释保留。模型链接/目录/原生2K、透明提示、建议步数/CFG均只是源注释,不是"
|
||||
"已验证环境事实或下载授权;本轮没有加载权重、处理素材或访问目标目录。"
|
||||
),
|
||||
(
|
||||
"case04历史配套:16实体42标量18端点逐项重核;除451.unet_name与473.clip_name两项反/"
|
||||
"正斜杠路径字符串差异外其余输入及类型一致,14处标题差异保留。不推断路径等价/不等价;配套身份及目标安装未知,294配套"
|
||||
"参数、空映射、companion_unverified/环境未检查/全停用不变。"
|
||||
),
|
||||
]
|
||||
for b in bindings:
|
||||
flows.append(
|
||||
"暴露绑定:459."
|
||||
+ b["name"]
|
||||
+ ";"
|
||||
+ b["widget_id_rule"]
|
||||
+ ";"
|
||||
+ b["value_pointer"]
|
||||
+ ";边界"
|
||||
+ b["boundary_pointer"]
|
||||
+ " → "
|
||||
+ json.dumps(b["targets"], ensure_ascii=False)
|
||||
)
|
||||
for scope, graph in [("root", s), ("definition", g)]:
|
||||
for i, e in enumerate(graph["links"]):
|
||||
flows.append("源边 " + scope + " " + str(i) + ":" + json.dumps(e, ensure_ascii=False))
|
||||
restorations = json.loads((OUT.parent / "case04-evidence/field-pointers.json").read_bytes())
|
||||
assert len(restorations) == 46
|
||||
for row in restorations:
|
||||
obj = s
|
||||
for part in row["source_value_pointer"].strip("/").split("/"):
|
||||
part = part.replace("~1", "/").replace("~0", "~")
|
||||
obj = obj[int(part)] if isinstance(obj, list) else obj[part]
|
||||
assert type(obj) is type(row["value"]) and obj == row["value"]
|
||||
final_endpoints = [
|
||||
dict(node_id=nid, field=name, endpoint=value)
|
||||
for nid, node in result.prompt.items()
|
||||
for name, value in node["inputs"].items()
|
||||
if isinstance(value, list)
|
||||
]
|
||||
assert len(final_endpoints) == 18
|
||||
# Current final graph evidence stays separate from saved UI positions.
|
||||
(OUT / "reference-comparison.json").write_text(
|
||||
json.dumps(
|
||||
dict(
|
||||
profile=CASE04_PROFILE,
|
||||
serialization_stage=result.serialization_stage,
|
||||
nodes=16,
|
||||
scalars=42,
|
||||
endpoints=18,
|
||||
differences=diffs,
|
||||
resolved_boundaries=result.resolved_boundaries,
|
||||
saved_restorations=restorations,
|
||||
final_endpoints=final_endpoints,
|
||||
source_sha256=hashlib.sha256(raw).hexdigest(),
|
||||
api_sha256=hashlib.sha256(api_raw).hexdigest(),
|
||||
),
|
||||
ensure_ascii=False,
|
||||
indent=2,
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
return dict(
|
||||
notice="固定版本参考说明:声明frontend1.53.6/core0.38.0,UE7.8保存记录不证明实际扩展;目标模型/安装/设备/实跑未知",
|
||||
source_path=PATH,
|
||||
source_sha1=hashlib.sha1(raw).hexdigest(),
|
||||
source_sha256=hashlib.sha256(raw).hexdigest(),
|
||||
canonical_sha256=hashlib.sha256(canonical(s)).hexdigest(),
|
||||
subgraph_sha256=hashlib.sha256(canonical(g)).hexdigest(),
|
||||
versions=[
|
||||
(
|
||||
"frontend1.53.6=7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1;仅固定保"
|
||||
"存/恢复/serialize参考,实际队列设置未知。"
|
||||
),
|
||||
(
|
||||
"全部可执行节点声明core0.38.0;精确提交6b747c0428c343e1417219641db93a4fb7cb"
|
||||
"69ae沿promoted/case04来源清单,不套core0.33。"
|
||||
),
|
||||
"UE7.8记录/实际扩展影响、动态文件列表、模型素材可用性、目标安装和历史导出版本仍未知。",
|
||||
],
|
||||
counts=dict(
|
||||
saved_fields=64,
|
||||
root_saved=25,
|
||||
definition_saved=39,
|
||||
source_notes=2,
|
||||
host_saved=17,
|
||||
source_nodes=19,
|
||||
physical_edges=37,
|
||||
linked_saved_fields=sum(f["role"] == "linked" for f in fields),
|
||||
frontend_only=1,
|
||||
final_entities=16,
|
||||
final_scalars=42,
|
||||
final_endpoints=18,
|
||||
),
|
||||
fields=fields,
|
||||
sources=refs,
|
||||
flow=flows,
|
||||
flow_evidence=list(range(len(refs))),
|
||||
comments=comments,
|
||||
bindings=bindings,
|
||||
companion_difference=dict(
|
||||
export_file="04.api.json",
|
||||
export_sha256=hashlib.sha256(api_raw).hexdigest(),
|
||||
differences=diffs,
|
||||
source_export_equivalence_verified=False,
|
||||
),
|
||||
steps=[
|
||||
"未来取得实跑授权后先核对真实前端/core/UE及动态模型列表;本轮不访问目标机、不运行插件或模型。",
|
||||
"先在根图核对483原始提示及13比例/MP/倍数;宿主prompt/width/height缓存被外线覆盖,不把源注释当实际尺寸。",
|
||||
"展开459逐项核对17宿主绑定和39内部保存值,保留作用域/JSON指针及覆盖说明,scheduler与scheduler_1不要互换。",
|
||||
"核对提示开关true→471、false→原文本;本图默认模板关闭使475指南不采用,不能仅修改指南就承诺提示优化。",
|
||||
"逐个核对UNET/两CLIP/VAE实际覆盖文件、cache和采样参数;双seed同源但含义不同。模型不存在/设备不支持须先处理真实环境,不依文件名宣称就绪。",
|
||||
(
|
||||
"核对452条件→458采样→457解码→461固定PNG链和472文本预览;真实history与产物经授权验证后再讨论保"
|
||||
"存/质量。当前未定稿、未实跑、全停用,不增加执行资格。"
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
target = REPO / "calliope-backend/src/calliope/comfyui/source_reviews.json"
|
||||
reviews = json.loads(target.read_bytes())
|
||||
block = build()
|
||||
assert reviews[PATH]["source_sha"] == block["source_sha1"]
|
||||
reviews[PATH]["fixed_version_document"] = block
|
||||
target.write_text(json.dumps(reviews, ensure_ascii=False, indent=2) + "\n")
|
||||
(OUT / "definition.json").write_text(json.dumps(block, ensure_ascii=False, indent=2) + "\n")
|
||||
print(hashlib.sha256(canonical(block)).hexdigest())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,299 @@
|
||||
"""Actual 2dbcefb upgrade, one-row rollback, user protection and package byte checks."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import sqlite3
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[3]
|
||||
OUT = Path(__file__).resolve().parent
|
||||
BASE = "2dbcefba40df2f2079d16a77f82775652267921d"
|
||||
sys.path.insert(0, str(REPO / "calliope-backend"))
|
||||
|
||||
|
||||
def write(name, data):
|
||||
(OUT / name).write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n")
|
||||
|
||||
|
||||
def main():
|
||||
from calliope.comfyui.fixed_document import DEFINITIONS as ALL_DEFINITIONS
|
||||
from calliope.comfyui.fixed_document import canonical
|
||||
|
||||
definitions = {
|
||||
p: d
|
||||
for p, d in ALL_DEFINITIONS.items()
|
||||
if p.endswith("Qwen_image2.1_文生图_提示词增强.json")
|
||||
}
|
||||
old_paths = ALL_DEFINITIONS.keys() - definitions.keys()
|
||||
from calliope.comfyui.library import rollback_batch
|
||||
from scripts.audit_library_documents import audit
|
||||
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
work = Path(directory)
|
||||
old = work / "old"
|
||||
old.mkdir()
|
||||
raw = subprocess.check_output(["git", "archive", BASE, "calliope-backend/src"], cwd=REPO)
|
||||
with tarfile.open(fileobj=io.BytesIO(raw)) as archive:
|
||||
archive.extractall(old, filter="data")
|
||||
db = work / "old.db"
|
||||
|
||||
def run(name, historical=False):
|
||||
output = work / name
|
||||
env = {
|
||||
**os.environ,
|
||||
"PYTHONPATH": str((old if historical else REPO) / "calliope-backend/src"),
|
||||
}
|
||||
subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-m",
|
||||
"calliope.comfyui.library_cli",
|
||||
"import",
|
||||
"--root",
|
||||
str(REPO / "example_ComfyUI_workflows"),
|
||||
"--db",
|
||||
str(db),
|
||||
"--source-commit",
|
||||
BASE,
|
||||
"--companions",
|
||||
str(REPO / "docs/hel-892/supplied-api/manifest.json"),
|
||||
"--output-dir",
|
||||
str(output),
|
||||
],
|
||||
cwd=REPO,
|
||||
env=env,
|
||||
check=True,
|
||||
stdout=subprocess.DEVNULL,
|
||||
)
|
||||
return json.loads((output / "import_report.json").read_bytes()), output
|
||||
|
||||
def rows():
|
||||
with sqlite3.connect(db) as conn:
|
||||
conn.row_factory = sqlite3.Row
|
||||
return {
|
||||
r["source_repo_path"]: dict(r) for r in conn.execute("SELECT * FROM workflows")
|
||||
}
|
||||
|
||||
first, _ = run("old-first", True)
|
||||
before = rows()
|
||||
assert first["counts"] == {"imported": 155, "user_excluded": 1}
|
||||
for p in old_paths:
|
||||
assert json.loads(before[p]["doc_json"])["fixed_version"]["matched"]
|
||||
for p in definitions:
|
||||
assert "fixed_version" not in json.loads(before[p]["doc_json"])
|
||||
original = db
|
||||
old_protection = []
|
||||
|
||||
def protect_old(name):
|
||||
nonlocal db
|
||||
save_db = db
|
||||
db = work / (name + ".db")
|
||||
with sqlite3.connect(save_db) as src, sqlite3.connect(db) as dst:
|
||||
src.backup(dst)
|
||||
for p in old_paths:
|
||||
dst.execute(
|
||||
"UPDATE workflows SET description=? WHERE source_repo_path=?", (name, p)
|
||||
)
|
||||
snapshot = rows()
|
||||
protected, _ = run(name)
|
||||
assert (
|
||||
protected["counts"] == {"conflict": 8, "skipped": 147, "user_excluded": 1}
|
||||
if name == "old-user-after"
|
||||
else protected["counts"]
|
||||
== {"conflict": 8, "updated": 1, "skipped": 146, "user_excluded": 1}
|
||||
)
|
||||
# New document updates before upgrade are expected, every old edited row must be exact.
|
||||
result = rows()
|
||||
assert all(result[p] == snapshot[p] and len(result[p]) == 29 for p in old_paths)
|
||||
old_protection.append(
|
||||
{"phase": name, "counts": protected["counts"], "whole_old_rows_protected": 8}
|
||||
)
|
||||
db = save_db
|
||||
|
||||
protect_old("old-user-before")
|
||||
db = work / "user-before.db"
|
||||
with sqlite3.connect(original) as src, sqlite3.connect(db) as dst:
|
||||
src.backup(dst)
|
||||
for p in definitions:
|
||||
dst.execute(
|
||||
"UPDATE workflows SET description=? WHERE source_repo_path=?",
|
||||
("用户升级前编辑", p),
|
||||
)
|
||||
user_before = rows()
|
||||
protected_before, _ = run("user-before")
|
||||
assert protected_before["counts"] == {
|
||||
"conflict": 1,
|
||||
"skipped": 154,
|
||||
"user_excluded": 1,
|
||||
}
|
||||
assert rows() == user_before
|
||||
db = original
|
||||
upgrade, _exported = run("upgrade")
|
||||
after = rows()
|
||||
assert upgrade["counts"] == {"updated": 1, "skipped": 154, "user_excluded": 1}
|
||||
for path, row in after.items():
|
||||
if path not in definitions:
|
||||
assert row == before[path]
|
||||
else:
|
||||
for k in row.keys() - {
|
||||
"doc_json",
|
||||
"batch_id",
|
||||
"imported_at",
|
||||
"library_fingerprint",
|
||||
}:
|
||||
assert row[k] == before[path][k]
|
||||
d = json.loads(row["doc_json"])
|
||||
assert d["fixed_version"]["matched"]
|
||||
b = {k: v for k, v in d["fixed_version"].items() if k != "matched"}
|
||||
assert hashlib.sha256(canonical(b)).hexdigest() == definitions[path]
|
||||
write("actual-" + Path(path).stem + ".json", d)
|
||||
protect_old("old-user-after")
|
||||
repeat, _ = run("repeat")
|
||||
assert repeat["counts"] == {"skipped": 155, "user_excluded": 1}
|
||||
with sqlite3.connect(db) as conn:
|
||||
conn.row_factory = sqlite3.Row
|
||||
rollback = rollback_batch(conn, upgrade["batch_id"])
|
||||
assert len(rollback["files"]) == 1 and all(
|
||||
f["result"] == "restored" for f in rollback["files"]
|
||||
)
|
||||
assert rows() == before
|
||||
redo, _ = run("redo")
|
||||
assert redo["counts"] == upgrade["counts"]
|
||||
for p in definitions:
|
||||
with sqlite3.connect(db) as conn:
|
||||
conn.execute(
|
||||
"UPDATE workflows SET description=? WHERE source_repo_path=?",
|
||||
("用户升级后编辑", p),
|
||||
)
|
||||
user_after = rows()
|
||||
protected_after, _ = run("user-after")
|
||||
assert protected_after["counts"] == protected_before["counts"]
|
||||
assert rows() == user_after and all(len(user_after[p]) == 29 for p in definitions)
|
||||
db = work / "fresh.db"
|
||||
fresh, fresh_export = run("fresh")
|
||||
fresh_repeat, _ = run("fresh-repeat")
|
||||
assert fresh["counts"] == first["counts"]
|
||||
assert fresh["states"] == {"pending_check": 16, "needs_conversion": 139}
|
||||
assert fresh_repeat["counts"] == repeat["counts"]
|
||||
companion = 0
|
||||
for row in rows().values():
|
||||
d = json.loads(row["doc_json"])
|
||||
companion += sum(p.get("value_origin") == "supplied_api_companion" for p in d["params"])
|
||||
assert (
|
||||
not row["is_enabled"]
|
||||
and row["doc_completed_at"] is None
|
||||
and row["exec_verified_at"] is None
|
||||
)
|
||||
assert not d["status"]["doc_done"] and not d["status"]["exec_verified"]
|
||||
assert d["dependencies"]["check_state"] == "unchecked"
|
||||
assert companion == 294
|
||||
report = audit(REPO, fresh_export)
|
||||
assert report["named_values_preserved"] == 1217 and report["unnamed_widget_nodes"] == 3660
|
||||
assert report["full_documents_completed"] == report["real_executions"] == 0
|
||||
write("audit-summary.json", {k: v for k, v in report.items() if k != "files"})
|
||||
write(
|
||||
"import-protection.json",
|
||||
dict(
|
||||
historical_code=BASE,
|
||||
old_eight_protection=old_protection,
|
||||
first=first["counts"],
|
||||
upgrade=upgrade["counts"],
|
||||
repeat=repeat["counts"],
|
||||
restored_rows=1,
|
||||
untouched_whole_rows=154,
|
||||
eligibility_columns_unchanged=True,
|
||||
redo=redo["counts"],
|
||||
user_before=protected_before["counts"],
|
||||
user_after=protected_after["counts"],
|
||||
user_whole_row_columns=29,
|
||||
fresh=fresh["counts"],
|
||||
fresh_repeat=fresh_repeat["counts"],
|
||||
states=fresh["states"],
|
||||
source_named_fields=1217,
|
||||
positional_widgets=3660,
|
||||
companion_values=companion,
|
||||
new_saved_definitions=64,
|
||||
old_saved_definitions=138,
|
||||
all_disabled=True,
|
||||
dependencies_unchecked=True,
|
||||
doc_done=0,
|
||||
executed=0,
|
||||
),
|
||||
)
|
||||
reviews_path = "calliope-backend/src/calliope/comfyui/source_reviews.json"
|
||||
previous = json.loads(
|
||||
subprocess.check_output(["git", "show", f"{BASE}:{reviews_path}"], cwd=REPO)
|
||||
)
|
||||
current = json.loads((REPO / reviews_path).read_bytes())
|
||||
for p in definitions:
|
||||
assert "fixed_version_document" not in previous[p]
|
||||
current[p].pop("fixed_version_document")
|
||||
assert previous == current
|
||||
boundaries = json.loads(
|
||||
(REPO / "docs/hel-892/h3-document-evidence/unchanged-boundaries.json").read_bytes()
|
||||
)
|
||||
paths = [f["path"] for f in boundaries["files"]] + boundaries["frozen_conversion_and_audits"]
|
||||
paths += ["calliope-backend/src/calliope/comfyui/library.py"]
|
||||
kept = []
|
||||
for p in paths:
|
||||
raw = (REPO / p).read_bytes()
|
||||
assert raw == subprocess.check_output(["git", "show", f"{BASE}:{p}"], cwd=REPO)
|
||||
kept.append(dict(path=p, sha256=hashlib.sha256(raw).hexdigest()))
|
||||
ui = "calliope-web/src/lib/components/WorkflowDocumentDrawer.svelte"
|
||||
assert (REPO / ui).read_text().split("<style>")[1] == subprocess.check_output(
|
||||
["git", "show", f"{BASE}:{ui}"], cwd=REPO
|
||||
).decode().split("<style>")[1]
|
||||
write(
|
||||
"boundaries.json",
|
||||
dict(
|
||||
base=BASE,
|
||||
files=kept,
|
||||
originals=163,
|
||||
source_reviews_only_one_new_block=True,
|
||||
drawer_css_unchanged=True,
|
||||
conversion_rerun=False,
|
||||
old_28_profiles_9_candidates_6_diffs="unchanged artifacts and implementation",
|
||||
),
|
||||
)
|
||||
packages = []
|
||||
with (
|
||||
zipfile.ZipFile(next((REPO / "calliope-backend/dist").glob("*.whl"))) as wheel,
|
||||
tarfile.open(next((REPO / "calliope-backend/dist").glob("*.tar.gz"))) as sdist,
|
||||
):
|
||||
for name in ["fixed_document.py", "source_reviews.json", "library.py"]:
|
||||
raw = (REPO / "calliope-backend/src/calliope/comfyui" / name).read_bytes()
|
||||
assert wheel.read("calliope/comfyui/" + name) == raw
|
||||
member = next(
|
||||
n for n in sdist.getnames() if n.endswith("/src/calliope/comfyui/" + name)
|
||||
)
|
||||
assert sdist.extractfile(member).read() == raw
|
||||
packages.append(
|
||||
dict(
|
||||
file=name,
|
||||
sha256=hashlib.sha256(raw).hexdigest(),
|
||||
wheel=True,
|
||||
sdist=True,
|
||||
)
|
||||
)
|
||||
write("package-check.json", packages)
|
||||
print(
|
||||
(
|
||||
"PASS: actual old-code upgrade1/skip154, ro"
|
||||
"llback1, user conflicts1 before/after, old"
|
||||
"8 protected, fresh155, 64+138 definitions, "
|
||||
"1217/3660/294, boundaries and packages"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,69 @@
|
||||
// Source-bound Qwen detail GET; no processing, writes or external requests.
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const out = '.local-evidence/qwen-document/browser';
|
||||
fs.mkdirSync(out, { recursive:true });
|
||||
const checks=[], requests=[], errors=[];
|
||||
function check(value,text) { assert.ok(value,text); checks.push(text); console.log('PASS '+text); }
|
||||
const browser=await chromium.launch({headless:true,executablePath:process.env.BROWSER_EXECUTABLE});
|
||||
try {
|
||||
const page=await browser.newPage({viewport:{width:1440,height:1000}});
|
||||
page.on('request',r=>{if(r.url().includes('/api/'))requests.push({method:r.method(),url:r.url()});});
|
||||
page.on('pageerror',e=>errors.push(e.message));
|
||||
const list=await(await fetch('http://127.0.0.1:8247/api/workflows')).json();
|
||||
const details=[];
|
||||
for(const name of ['Qwen_image2.1_文生图_提示词增强','ControlNet_aux_常用样例','Qwen3-ASR-语音转文字','Qwen3-ASR-Subtitle语音转字幕','Minimax-H3提示词增强','音频转MP3格式','音频人声分离','视频-音频分离','图像嵌入文字描述']) {
|
||||
const record=list.find(x=>x.name===name);assert.ok(record);
|
||||
const url=`http://127.0.0.1:8247/api/workflows/${record.id}`;requests.push({method:'GET',url});details.push(await(await fetch(url)).json());
|
||||
}
|
||||
check(details.map(d=>d.doc_json.fixed_version.fields.length).join(',')==='64,36,19,30,18,5,8,8,14','64新项与138旧项,九图独立');
|
||||
await page.goto('http://127.0.0.1:5173/connections',{waitUntil:'networkidle'});
|
||||
const dialog=page.getByRole('dialog',{name:'工作流说明'});
|
||||
async function begin(name) {
|
||||
const row=page.locator('.wf-row').filter({has:page.locator('.wf-name').filter({hasText:name})}).first();
|
||||
const button=row.getByRole('button',{name:'说明',exact:true});await button.focus();await page.keyboard.press('Enter');return button;
|
||||
}
|
||||
async function loaded() {
|
||||
await dialog.getByText('用途与来源',{exact:true}).waitFor();
|
||||
await dialog.evaluate(el=>Promise.all(el.getAnimations().map(a=>a.finished)));
|
||||
}
|
||||
const detail=details[0],fixed=detail.doc_json.fixed_version;
|
||||
for(const width of [1440,390]) {
|
||||
await page.setViewportSize({width,height:width===390?844:1000});
|
||||
const button=await begin(detail.name);await loaded();
|
||||
check((await dialog.innerText()).includes(fixed.notice),`${width}声明/参考/未知提示`);
|
||||
for(const t of ['说明未定稿','未验证实跑','未检查'])check((await dialog.innerText()).includes(t),`${width} ${t}`);
|
||||
check(!detail.is_enabled&&!detail.doc_completed_at&&!detail.exec_verified_at,`${width}停用与时间戳保持`);
|
||||
for(const field of fixed.fields) {
|
||||
const summary=dialog.getByText(`节点 ${field.node_id} · ${field.label}(${field.field})`,{exact:true});
|
||||
await summary.focus();await page.keyboard.press('Enter');const box=summary.locator('..');
|
||||
check(await box.evaluate(el=>el.open),`${width} ${field.node_id}.${field.field}键盘展开`);
|
||||
const text=await box.innerText();
|
||||
check(text.includes(field.effect)&&text.includes(field.limits)&&text.includes(field.schema_default)&&text.includes(field.execution_note),`${width} ${field.node_id}.${field.field}语义/默认/条件`);
|
||||
check(await box.locator(':scope > pre').textContent()===(typeof field.value==='string'?field.value:JSON.stringify(field.value,null,2)),`${width} ${field.node_id}.${field.field}原值类型`);
|
||||
await box.getByText('来源依据',{exact:true}).click();const evidence=await box.innerText();
|
||||
check(evidence.includes(field.pointer)&&field.evidence.every(i=>{const e=fixed.sources[i];return evidence.includes(e.commit)&&evidence.includes(e.sha256)&&evidence.includes(e.lines.join('~'));}),`${width} ${field.node_id}.${field.field}精确引用`);
|
||||
check(!evidence.includes('undefined'),`${width} ${field.node_id}.${field.field}无伪指针`);
|
||||
check(await dialog.locator('.drawer-body').evaluate(el=>el.scrollWidth<=el.clientWidth),`${width} ${field.node_id}.${field.field}无横向溢出`);
|
||||
if(['switch','use_default_template','seed','sampling_mode.seed','width','prompt','value'].includes(field.field))await page.screenshot({path:`${out}/${width}-${field.node_id}-${field.field}.png`});
|
||||
await summary.click();
|
||||
}
|
||||
const text=await dialog.innerText();
|
||||
for(const t of ['64保存位置不是64最终执行参数','17控件','widgetId(rootGraph.id,459,input.name)','双seed','use_default_template=false','两条MarkdownNote','14处标题差异','18端点','37源边','ui.images'])check(text.includes(t),`${width}图特定用途 ${t}`);
|
||||
check(await dialog.locator('summary').filter({hasText:/节点 [\d:]+ · .*(/}).count()===64,`${width}恰好64项`);
|
||||
const basis=dialog.getByText('版本、源图与连线依据',{exact:true});await basis.click();
|
||||
check((await basis.locator('..').innerText()).includes('UE7.8'),`${width}扩展与目标绑定未知`);
|
||||
await dialog.getByText('固定版本参数说明',{exact:true}).scrollIntoViewIfNeeded();await page.screenshot({path:`${out}/${width}-overview.png`});
|
||||
await page.keyboard.press('Escape');await dialog.waitFor({state:'hidden'});check(await button.evaluate(el=>el===document.activeElement),`${width}焦点归还`);
|
||||
for(const d of [...details.slice(1),details[0]]) {
|
||||
await begin(d.name);await loaded();check(await dialog.locator('summary').filter({hasText:/节点 [\d:]+ · .*(/}).count()===d.doc_json.fixed_version.fields.length,`${width}切换${d.name}不串条`);await page.keyboard.press('Escape');
|
||||
}
|
||||
}
|
||||
let release,entered,delivered;const hold=new Promise(r=>release=r),intercept=new Promise(r=>entered=r),done=new Promise(r=>delivered=r);
|
||||
await page.route(`**/api/workflows/${details[0].id}`,async route=>{entered();await hold;await route.fulfill({json:details[0]});delivered();});
|
||||
await begin(details[0].name);await intercept;await page.keyboard.press('Escape');await begin(details[1].name);await loaded();release();await done;
|
||||
check(await dialog.locator('summary').filter({hasText:/节点 [\d:]+ · .*(/}).count()===36,'迟到Qwen响应不覆盖ControlNet36项');await page.keyboard.press('Escape');
|
||||
check(errors.length===0,'无脚本错误');check(requests.every(r=>r.method==='GET'&&new URL(r.url).hostname==='127.0.0.1'),'全本地GET无写/生成/目标请求');
|
||||
fs.writeFileSync(`${out}/browser-results.json`,JSON.stringify({checks,requests,errors,viewports:[1440,390]},null,2));
|
||||
} finally {await browser.close();}
|
||||
@@ -0,0 +1,81 @@
|
||||
"""Foreground local browser check; stop every owned service before returning."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
OUT = ROOT / ".local-evidence/qwen-document/browser"
|
||||
|
||||
|
||||
def main():
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
# Refuse to reuse another operator's service or port.
|
||||
import socket
|
||||
|
||||
for port in (8247, 5173):
|
||||
with socket.socket() as sock:
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.bind(("127.0.0.1", port))
|
||||
processes = []
|
||||
logs = []
|
||||
try:
|
||||
commands = [
|
||||
([sys.executable, str(ROOT / "e2e/workflow-document-server.py")], ROOT),
|
||||
(
|
||||
["node", "node_modules/vite/bin/vite.js", "--host", "127.0.0.1"],
|
||||
ROOT / "calliope-web",
|
||||
),
|
||||
]
|
||||
for i, (command, cwd) in enumerate(commands):
|
||||
log = (OUT / f"service-{i}.log").open("w")
|
||||
logs.append(log)
|
||||
processes.append(
|
||||
subprocess.Popen(command, cwd=cwd, stdout=log, stderr=log, start_new_session=True)
|
||||
)
|
||||
for url in (
|
||||
"http://127.0.0.1:8247/api/workflows",
|
||||
"http://127.0.0.1:5173/connections",
|
||||
):
|
||||
deadline = time.monotonic() + 30
|
||||
while True:
|
||||
if any(p.poll() is not None for p in processes):
|
||||
raise RuntimeError("Local service exited; inspect service logs")
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=1) as response:
|
||||
if response.status == 200:
|
||||
break
|
||||
except (urllib.error.URLError, TimeoutError):
|
||||
pass
|
||||
if time.monotonic() > deadline:
|
||||
raise TimeoutError(url)
|
||||
time.sleep(0.2)
|
||||
subprocess.run(["node", "e2e/qwen-document.mjs"], cwd=ROOT, check=True)
|
||||
subprocess.run(["node", "e2e/controlnet-document.mjs"], cwd=ROOT, check=True)
|
||||
subprocess.run(["node", "e2e/asr-document.mjs"], cwd=ROOT, check=True)
|
||||
subprocess.run(["node", "e2e/media-document.mjs"], cwd=ROOT, check=True)
|
||||
subprocess.run(["node", "e2e/audio-document.mjs"], cwd=ROOT, check=True)
|
||||
subprocess.run(["node", "e2e/h3-document.mjs"], cwd=ROOT, check=True)
|
||||
finally:
|
||||
for p in processes:
|
||||
if p.poll() is None:
|
||||
os.killpg(p.pid, signal.SIGTERM)
|
||||
try:
|
||||
p.wait(timeout=10)
|
||||
except subprocess.TimeoutExpired:
|
||||
os.killpg(p.pid, signal.SIGKILL)
|
||||
p.wait(timeout=5)
|
||||
for log in logs:
|
||||
log.close()
|
||||
print("All owned browser services stopped.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user