Files
aigc-home/docs/hel-892/scail-document-evidence/build_definition.py
T
2026-11-01 18:11:45 +08:00

729 lines
32 KiB
Python

"""Scoped exact-declaration reference; parse AST/text only, never upstream imports."""
import ast
import copy
import hashlib
import json
from pathlib import Path
REPO = Path(__file__).resolve().parents[3]
OUT = Path(__file__).resolve().parent
REF = OUT.parent / "scail-reference"
PATHS = ["example_ComfyUI_workflows/6-动作迁移/Wan2.1_SCAIL2_角色迁移_动作迁移_FOR循环长视频.json"]
HOSTS = {
"d1ab1953-6167-4827-b44e-b4108cea5702": "213",
"56bf150b-bd14-4513-8e03-335e1972ba62": "262",
"6364e15c-3513-4e4e-b219-3144805563c2": "368",
}
BINDINGS = {
"328": ("unknown", "", "GetNode"),
"329": ("unknown", "", "GetNode"),
"264": ("core0240", "comfy_extras/nodes_math.py", "MathExpressionNode"),
"347": ("unknown", "", "Reroute"),
"201": ("core0240", "comfy_extras/nodes_video.py", "CreateVideo"),
"348": ("unknown", "", "GetNode"),
"349": ("unknown", "", "GetNode"),
"202": ("core0240", "comfy_extras/nodes_video.py", "SaveVideo"),
"213": ("boundary", "", ""),
"336": ("unknown", "", "Reroute"),
"343": ("unknown", "", "Reroute"),
"354": ("unknown", "", "Reroute"),
"334": ("core0250", "comfy_extras/nodes_primitive.py", "StringMultiline"),
"331": ("kjint", "nodes/nodes.py", "INTConstant"),
"330": ("kjint", "nodes/nodes.py", "INTConstant"),
"337": ("kjint", "nodes/nodes.py", "INTConstant"),
"262": ("boundary", "", ""),
"346": ("core0250", "comfy_extras/nodes_primitive.py", "StringMultiline"),
"333": ("unknown", "", "Reroute"),
"356": ("unknown", "", "Reroute"),
"327": ("unknown", "", "SetNode"),
"326": ("unknown", "", "SetNode"),
"270": ("core0240", "comfy_extras/nodes_video.py", "CreateVideo"),
"357": ("unknown", "", "Label (rgthree)"),
"358": ("unknown", "", "Label (rgthree)"),
"335": ("unknown", "", "Reroute"),
"338": ("unknown", "", "Reroute"),
"332": ("unknown", "", "Reroute"),
"368": ("boundary", "", ""),
"342": ("unknown", "", "GetNode"),
"377": ("unknown", "", "Reroute"),
"271": ("core0240", "comfy_extras/nodes_video.py", "SaveVideo"),
"376": ("core0250", "comfy_extras/nodes_preview_any.py", "PreviewAny"),
"379": ("unknown", "", "Reroute (rgthree)"),
"355": ("core0250", "comfy_extras/nodes_primitive.py", "Boolean"),
"341": ("unknown", "", "SetNode"),
"265": ("core0240", "comfy_extras/nodes_preview_any.py", "PreviewAny"),
"380": ("rgthree", "py/display_any.py", "RgthreeDisplayAny"),
"263": ("core0240", "comfy_extras/nodes_images.py", "GetImageSize"),
"155": ("core0240", "comfy_extras/nodes_video.py", "LoadVideo"),
"30": ("core0240", "nodes.py", "LoadImage"),
"215": ("core0240", "comfy_extras/nodes_video.py", "GetVideoComponents"),
"381": ("core0271", "comfy_extras/nodes_video.py", "VideoSlice"),
"213:11": ("core0240", "nodes.py", "LoraLoaderModelOnly"),
"213:7": ("core0240", "nodes.py", "VAELoader"),
"213:156": ("core0240", "comfy_extras/nodes_post_processing.py", "ResizeImageMaskNode"),
"213:163": ("core0240", "comfy_extras/nodes_images.py", "GetImageSize"),
"213:9": ("core0240", "nodes.py", "CLIPLoader"),
"213:75": ("core0240", "nodes.py", "CLIPVisionLoader"),
"213:154": ("core0240", "nodes.py", "UNETLoader"),
"213:95": ("core0240", "comfy_extras/nodes_model_advanced.py", "ModelSamplingSD3"),
"213:27": ("core0240", "comfy_extras/nodes_custom_sampler.py", "KSamplerSelect"),
"213:18": ("core0240", "comfy_extras/nodes_custom_sampler.py", "BasicScheduler"),
"213:19": ("core0240", "comfy_extras/nodes_custom_sampler.py", "SamplerCustom"),
"213:168": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"213:167": ("core0240", "comfy_extras/nodes_primitive.py", "Float"),
"213:165": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"213:166": ("core0240", "comfy_extras/nodes_primitive.py", "Float"),
"213:169": ("core0240", "comfy_extras/nodes_logic.py", "SwitchNode"),
"213:170": ("core0240", "comfy_extras/nodes_logic.py", "SwitchNode"),
"213:171": ("core0240", "comfy_extras/nodes_logic.py", "SwitchNode"),
"213:177": ("core0240", "comfy_extras/nodes_images.py", "ImageFromBatch"),
"213:178": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"213:179": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"213:180": ("core0240", "comfy_extras/nodes_math.py", "MathExpressionNode"),
"213:182": ("core0240", "comfy_extras/nodes_math.py", "MathExpressionNode"),
"213:183": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"213:184": ("core0240", "comfy_extras/nodes_math.py", "MathExpressionNode"),
"213:191": ("core0193", "nodes.py", "CLIPTextEncode"),
"213:193": ("core0193", "nodes.py", "CheckpointLoaderSimple"),
"213:197": ("core0240", "comfy_extras/nodes_wan.py", "SCAIL2ColoredMask"),
"213:203": ("core0240", "comfy_extras/nodes_primitive.py", "Boolean"),
"213:6": ("core0240", "nodes.py", "VAEDecode"),
"213:172": ("core0240", "comfy_extras/nodes_primitive.py", "Boolean"),
"213:76": ("core0240", "nodes.py", "CLIPVisionEncode"),
"213:4": ("core0240", "nodes.py", "CLIPTextEncode"),
"213:3": ("core0240", "nodes.py", "CLIPTextEncode"),
"213:212": ("core0193", "nodes.py", "CLIPTextEncode"),
"213:318": ("core0240", "nodes.py", "LoraLoaderModelOnly"),
"213:196": ("core0240", "comfy_extras/nodes_sam3.py", "SAM3_VideoTrack"),
"213:198": ("core0240", "comfy_extras/nodes_sam3.py", "SAM3_VideoTrack"),
"213:114": ("core0240", "comfy_extras/nodes_wan.py", "WanSCAILToVideo"),
"213:199": ("core0240", "nodes.py", "PreviewImage"),
"213:200": ("core0240", "nodes.py", "PreviewImage"),
"213:157": ("core0240", "comfy_extras/nodes_video.py", "GetVideoComponents"),
"262:216": ("core0240", "nodes.py", "LoraLoaderModelOnly"),
"262:217": ("core0240", "nodes.py", "VAELoader"),
"262:218": ("core0240", "comfy_extras/nodes_post_processing.py", "ResizeImageMaskNode"),
"262:220": ("core0240", "comfy_extras/nodes_images.py", "GetImageSize"),
"262:221": ("core0240", "nodes.py", "CLIPLoader"),
"262:222": ("core0240", "nodes.py", "CLIPVisionLoader"),
"262:223": ("core0240", "nodes.py", "UNETLoader"),
"262:227": ("core0240", "comfy_extras/nodes_custom_sampler.py", "SamplerCustom"),
"262:228": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"262:229": ("core0240", "comfy_extras/nodes_primitive.py", "Float"),
"262:230": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"262:231": ("core0240", "comfy_extras/nodes_primitive.py", "Float"),
"262:236": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"262:237": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"262:238": ("core0240", "comfy_extras/nodes_math.py", "MathExpressionNode"),
"262:239": ("core0240", "comfy_extras/nodes_math.py", "MathExpressionNode"),
"262:240": ("core0240", "comfy_extras/nodes_primitive.py", "Int"),
"262:241": ("core0240", "comfy_extras/nodes_math.py", "MathExpressionNode"),
"262:242": ("core0193", "nodes.py", "CLIPTextEncode"),
"262:243": ("core0193", "nodes.py", "CheckpointLoaderSimple"),
"262:245": ("core0240", "comfy_extras/nodes_wan.py", "SCAIL2ColoredMask"),
"262:247": ("core0240", "comfy_extras/nodes_primitive.py", "Boolean"),
"262:250": ("core0240", "nodes.py", "VAEDecode"),
"262:251": ("core0240", "comfy_extras/nodes_images.py", "ImageFromBatch"),
"262:252": ("core0240", "comfy_extras/nodes_post_processing.py", "ColorTransfer"),
"262:253": ("core0240", "comfy_extras/nodes_images.py", "ImageFromBatch"),
"262:256": ("core0240", "nodes.py", "CLIPVisionEncode"),
"262:257": ("core0240", "nodes.py", "CLIPTextEncode"),
"262:258": ("core0240", "nodes.py", "CLIPTextEncode"),
"262:261": ("core0193", "nodes.py", "CLIPTextEncode"),
"262:319": ("core0240", "nodes.py", "LoraLoaderModelOnly"),
"262:259": ("core0240", "comfy_extras/nodes_wan.py", "WanSCAILToVideo"),
"262:248": ("core0240", "nodes.py", "PreviewImage"),
"262:249": ("core0240", "nodes.py", "PreviewImage"),
"262:246": ("core0240", "comfy_extras/nodes_sam3.py", "SAM3_VideoTrack"),
"262:219": ("core0240", "comfy_extras/nodes_video.py", "GetVideoComponents"),
"262:235": ("core0240", "comfy_extras/nodes_images.py", "ImageFromBatch"),
"262:244": ("core0240", "comfy_extras/nodes_sam3.py", "SAM3_VideoTrack"),
"262:339": ("unknown", "", "Reroute"),
"262:226": ("core0240", "comfy_extras/nodes_custom_sampler.py", "BasicScheduler"),
"262:224": ("core0240", "comfy_extras/nodes_model_advanced.py", "ModelSamplingSD3"),
"262:225": ("core0240", "comfy_extras/nodes_custom_sampler.py", "KSamplerSelect"),
"262:255": ("core0240", "comfy_extras/nodes_primitive.py", "Boolean"),
"262:234": ("core0240", "comfy_extras/nodes_logic.py", "SwitchNode"),
"262:233": ("core0240", "comfy_extras/nodes_logic.py", "SwitchNode"),
"262:232": ("core0240", "comfy_extras/nodes_logic.py", "SwitchNode"),
"368:344": ("mathpkg", "py/math_expression.py", "MathExpression"),
"368:370": ("easy", "py/nodes/logic.py", "forLoopStart"),
"368:369": ("easy", "py/nodes/logic.py", "forLoopEnd"),
"368:372": ("easy", "py/nodes/logic.py", "showAnything"),
"368:374": ("core0240", "comfy_extras/nodes_post_processing.py", "BatchImagesNode"),
"368:375": ("unknown", "", "Reroute"),
"368:373": ("mathpkg", "py/math_expression.py", "MathExpression"),
"368:371": ("mathpkg", "py/math_expression.py", "MathExpression"),
}
LAYOUTS = {
"328": ["position_0"],
"329": ["position_0"],
"264": ["expression"],
"201": ["fps", "position_1"],
"348": ["position_0"],
"349": ["position_0"],
"202": ["filename_prefix", "format", "codec"],
"213": [],
"334": ["value"],
"331": ["value"],
"330": ["value"],
"337": ["value"],
"262": [],
"346": ["value"],
"327": ["position_0"],
"326": ["position_0"],
"270": ["fps", "position_1"],
"368": [],
"342": ["position_0"],
"271": ["filename_prefix", "format", "codec"],
"376": ["position_0", "position_1", "position_2"],
"355": ["value"],
"341": ["position_0"],
"265": ["position_0", "position_1", "position_2"],
"380": ["position_0"],
"263": [],
"155": ["file", "upload"],
"30": ["image", "upload"],
"215": [],
"381": ["start_time", "duration", "strict_duration"],
"213:11": ["lora_name", "strength_model"],
"213:7": ["vae_name"],
"213:156": [
"resize_type",
"resize_type.width",
"resize_type.height",
"resize_type.crop",
"scale_method",
],
"213:163": [],
"213:9": ["clip_name", "type", "device"],
"213:75": ["clip_name"],
"213:154": ["unet_name", "weight_dtype"],
"213:95": ["shift"],
"213:27": ["sampler_name"],
"213:18": ["scheduler", "steps", "denoise"],
"213:19": ["add_noise", "noise_seed", "control_after_generate", "cfg"],
"213:168": ["value", "control_after_generate"],
"213:167": ["value"],
"213:165": ["value", "control_after_generate"],
"213:166": ["value"],
"213:169": ["switch"],
"213:170": ["switch"],
"213:171": ["switch"],
"213:177": ["batch_index", "length"],
"213:178": ["value", "control_after_generate"],
"213:179": ["value", "control_after_generate"],
"213:180": ["expression"],
"213:182": ["expression"],
"213:183": ["value", "control_after_generate"],
"213:184": ["expression"],
"213:191": ["text"],
"213:193": ["ckpt_name"],
"213:197": ["object_indices", "sort_by", "replacement_mode"],
"213:203": ["value"],
"213:6": [],
"213:172": ["value"],
"213:76": ["crop"],
"213:4": ["text"],
"213:3": ["text"],
"213:212": ["text"],
"213:318": ["lora_name", "strength_model"],
"213:196": ["detection_threshold", "max_objects", "detect_interval"],
"213:198": ["detection_threshold", "max_objects", "detect_interval"],
"213:114": [
"width",
"height",
"length",
"batch_size",
"pose_strength",
"pose_start",
"pose_end",
"video_frame_offset",
"previous_frame_count",
"replacement_mode",
],
"213:199": [],
"213:200": [],
"213:157": [],
"262:216": ["lora_name", "strength_model"],
"262:217": ["vae_name"],
"262:218": [
"resize_type",
"resize_type.width",
"resize_type.height",
"resize_type.crop",
"scale_method",
],
"262:220": [],
"262:221": ["clip_name", "type", "device"],
"262:222": ["clip_name"],
"262:223": ["unet_name", "weight_dtype"],
"262:227": ["add_noise", "noise_seed", "control_after_generate", "cfg"],
"262:228": ["value", "control_after_generate"],
"262:229": ["value"],
"262:230": ["value", "control_after_generate"],
"262:231": ["value"],
"262:236": ["value", "control_after_generate"],
"262:237": ["value", "control_after_generate"],
"262:238": ["expression"],
"262:239": ["expression"],
"262:240": ["value", "control_after_generate"],
"262:241": ["expression"],
"262:242": ["text"],
"262:243": ["ckpt_name"],
"262:245": ["object_indices", "sort_by", "replacement_mode"],
"262:247": ["value"],
"262:250": [],
"262:251": ["batch_index", "length"],
"262:252": ["method", "source_stats", "strength"],
"262:253": ["batch_index", "length"],
"262:256": ["crop"],
"262:257": ["text"],
"262:258": ["text"],
"262:261": ["text"],
"262:319": ["lora_name", "strength_model"],
"262:259": [
"width",
"height",
"length",
"batch_size",
"pose_strength",
"pose_start",
"pose_end",
"video_frame_offset",
"previous_frame_count",
"replacement_mode",
],
"262:248": [],
"262:249": [],
"262:246": ["detection_threshold", "max_objects", "detect_interval"],
"262:219": [],
"262:235": ["batch_index", "length"],
"262:244": ["detection_threshold", "max_objects", "detect_interval"],
"262:226": ["scheduler", "steps", "denoise"],
"262:224": ["shift"],
"262:225": ["sampler_name"],
"262:255": ["value"],
"262:234": ["switch"],
"262:233": ["switch"],
"262:232": ["switch"],
"368:344": ["expression"],
"368:370": ["total"],
"368:369": [],
"368:372": ["position_0"],
"368:374": [],
"368:373": ["expression"],
"368:371": ["expression"],
}
def canonical(v):
return json.dumps(v, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()
def node_schema(class_node):
"""Extract INPUT_TYPES expressions only, never interpret plugin code."""
method = next(
(
m
for m in class_node.body
if isinstance(m, (ast.FunctionDef, ast.AsyncFunctionDef)) and m.name == "INPUT_TYPES"
),
None,
)
if method is None:
method = next(
(
m
for m in class_node.body
if isinstance(m, ast.FunctionDef) and m.name == "define_schema"
),
None,
)
if method is None:
return {}
schema = {}
for call in ast.walk(method):
if (
not isinstance(call, ast.Call)
or not isinstance(call.func, ast.Attribute)
or call.func.attr != "Input"
):
continue
if (
not call.args
or not isinstance(call.args[0], ast.Constant)
or not isinstance(call.args[0].value, str)
):
continue
default = next(
(ast.unparse(k.value) for k in call.keywords if k.arg == "default"),
"无显式default;动态选项由准确代码/目标决定",
)
schema[call.args[0].value] = (default, ast.unparse(call))
return schema
literals = {}
for assignment in method.body:
if isinstance(assignment, ast.Assign) and len(assignment.targets) == 1:
target = assignment.targets[0]
if isinstance(target, ast.Name):
try:
ast.literal_eval(assignment.value)
except (ValueError, TypeError):
continue
literals[target.id] = assignment.value
class LiteralNames(ast.NodeTransformer):
def visit_Name(self, node):
return copy.deepcopy(literals.get(node.id, node))
schema = {}
for d in ast.walk(method):
if not isinstance(d, ast.Dict):
continue
for k, v in zip(d.keys, d.values, strict=True):
if (
isinstance(k, ast.Constant)
and isinstance(k.value, str)
and isinstance(v, ast.Tuple)
):
default = "无显式default;动态枚举或首项依准确代码,目标选项未知"
for opts in v.elts[1:]:
if isinstance(opts, ast.Dict):
for dk, dv in zip(opts.keys, opts.values, strict=True):
if isinstance(dk, ast.Constant) and dk.value == "default":
default = ast.unparse(dv)
schema[k.value] = (default, ast.unparse(LiteralNames().visit(copy.deepcopy(v))))
return schema
def scoped_graphs(g):
return [("", "", g)] + [
(HOSTS[s["id"]] + ":", f"/definitions/subgraphs/{i}", s)
for i, s in enumerate(g["definitions"]["subgraphs"])
]
def build(index=0):
raw = (REPO / PATHS[index]).read_bytes()
g = json.loads(raw)
prose = json.loads((OUT / "prose.json").read_bytes())
editorial = json.loads((OUT / "editorial.json").read_bytes())
manifest = json.loads((REF / "sources.json").read_bytes())["sources"]
sources, trees = [], {}
for e in manifest:
data = (REF / e["local_file"]).read_bytes()
assert hashlib.sha256(data).hexdigest() == e["sha256"]
sources.append(
dict(
e,
local_file="../scail-reference/" + e["local_file"],
lines=[1, len(data.decode().splitlines())],
claim="准确声明提交/发布成员,仅静态;源码许可不是模型素材许可,目标/恢复未知",
)
)
if e["file"].endswith(".py"):
trees[e["local_file"]] = ast.parse(data)
fields, comments, bindings, empty, flow = [], [], [], [], []
boundaries = []
for pre, prefix, graph in scoped_graphs(g):
scope = "root" if not pre else "宿主" + pre[:-1] + "内部定义"
edge_by_id = {e[0] if isinstance(e, list) else e["id"]: e for e in graph["links"]}
for ni, n in enumerate(graph["nodes"]):
nid, ptr = pre + str(n["id"]), f"{prefix}/nodes/{ni}"
flow.append(nid + " 原节点完整保存 " + json.dumps(n, ensure_ascii=False))
if n["type"] in ["Note", "MarkdownNote"]:
comments.append(
dict(
node_id=nid,
pointer=ptr + "/widgets_values/0",
text=n["widgets_values"][0],
meaning=prose["notes"][nid],
evidence=[],
)
)
continue
key, file, symbol = BINDINGS[nid]
cl, schema, rs, candidates = None, {}, [], []
if key not in ["unknown", "boundary"]:
ei = next(i for i, e in enumerate(manifest) if e["id"] == key and e["file"] == file)
entry = manifest[ei]
cl = next(
(
c
for c in trees[entry["local_file"]].body
if isinstance(c, ast.ClassDef) and c.name == symbol
),
None,
)
rs = [i for i, e in enumerate(manifest) if e["id"] == key]
if cl:
sources.append(
dict(
sources[ei],
lines=[cl.lineno, cl.end_lineno],
claim=f"{nid}准确{key}类{symbol}静态schema/实现;原额外项/协议冲突另列",
)
)
rs.append(len(sources) - 1)
schema = node_schema(cl)
candidates = [dict(source=ei, symbol=symbol, lines=[cl.lineno, cl.end_lineno])]
if n["type"] == "ResizeImageMaskNode":
# Exact SCALE_DIMENSIONS branch, not a different resize branch.
method = next(
m
for m in cl.body
if isinstance(m, ast.FunctionDef) and m.name == "define_schema"
)
option = next(
c
for c in ast.walk(method)
if isinstance(c, ast.Call)
and isinstance(c.func, ast.Attribute)
and c.func.attr == "Option"
and c.args
and isinstance(c.args[0], ast.Attribute)
and c.args[0].attr == "SCALE_DIMENSIONS"
)
for c in ast.walk(option):
if (
isinstance(c, ast.Call)
and isinstance(c.func, ast.Attribute)
and c.func.attr == "Input"
and c.args
and isinstance(c.args[0], ast.Constant)
):
name = c.args[0].value
default = next(
(
ast.unparse(k.value)
for k in c.keywords
if k.arg == "default"
),
"无显式default",
)
schema["resize_type." + name] = (default, ast.unparse(c))
schema["resize_type.crop"] = schema["crop"]
source_id = (
"subgraph-definition"
if key == "boundary"
else "unknown-no-version"
if key == "unknown"
else key
if cl
else "unresolved-" + key
)
bindings.append(
dict(
node_id=nid,
class_type=n["type"],
source_version=n.get("properties", {}).get("ver", "未知:没有准确版本"),
source_id=source_id,
candidates=candidates,
declared_provider=n.get("properties", {}).get("cnr_id"),
implementation_verified=cl is not None,
scope=scope,
notice="宿主仅原定义边界,不当后端类"
if key == "boundary"
else "准确类/具体未匹配/无版本分列,不借同名或后版补实",
)
)
effect = editorial[nid] + " 原mode=0,不认证执行;无具名保存,不补具名值/双指针。"
flow.append(effect)
w = n.get("widgets_values")
if "widgets_values" not in n or w is None or w == []:
empty.append(
dict(
node_id=nid,
class_type=n["type"],
pointer=ptr,
scope=scope,
state="missing"
if "widgets_values" not in n
else "null"
if w is None
else "empty_list",
named_state="missing",
effect=effect,
)
)
continue
for j, (name, value) in enumerate(zip(LAYOUTS[nid], w, strict=True)):
known = name in schema
inp = next(
(i for i, x in enumerate(n.get("inputs", [])) if x["name"] == name), None
)
link = n["inputs"][inp].get("link") if inp is not None else None
e = edge_by_id.get(link)
boundary_link = (
pre and isinstance(e, dict) and e["origin_id"] == graph["inputNode"]["id"]
)
aux = (
name == "control_after_generate"
or (n["type"] in ["LoadImage", "LoadVideo"] and name == "upload")
or n["type"] == "Display Any (rgthree)"
)
role = (
"boundary_saved_cache"
if known and boundary_link
else "linked_override"
if known and link is not None
else "frontend_only"
if aux
else "schema_input"
if known
else "extra_saved"
)
default, limits = schema.get(
name,
(
"未知:无准确后端字段/额外保存,不借后版补默认",
"未知:额外保存或准确实现未核准,原位置/控件名不等于后端支持",
),
)
evidence = rs + (
[i for i, e in enumerate(manifest) if e["id"] in ["frontend", "litegraph"]]
if aux
else []
)
fields.append(
dict(
node_id=nid,
definition_node_id=str(n["id"]),
scope=scope,
class_type=n["type"],
field=name,
label=prose["labels"].get(name, name + "原保存(映射与额外项分列)"),
pointer=ptr + "/widgets_values/" + str(j),
value=value,
json_type=type(value).__name__,
named_state="missing",
input_pointer=f"{ptr}/inputs/{inp}"
if known and inp is not None
else "未知:无准确后端字段映射,不由位置/同名补实",
input_name=name if known and inp is not None else None,
type=limits,
role=role,
schema_default=default,
limits=limits,
unit=prose["units"].get(
nid + "." + name, "准确schema类型/原JSON类型分列;无明确物理单位则未知"
),
effect=effect
+ (
" 原边界连接缓存;宿主外线/空口和proxy映射另列,非恢复或生效证明。"
if boundary_link
else ""
)
+ (
" 此原保存不在准确schema,不能认证生效/恢复。"
if not known and not aux
else ""
),
evidence=evidence,
execution_note="仅静态保存与源码;未构造prompt/执行插件模型SAM媒体表达式随机循环采样解码I/O清理;转换/执行资格不变。",
)
)
flow += [
scope + " 物理/边界记录 " + json.dumps(e, ensure_ascii=False) for e in graph["links"]
]
if pre:
host = next(n for n in g["nodes"] if str(n["id"]) + ":" == pre)
boundary = dict(
host_node_id=str(host["id"]),
definition_id=graph["id"],
pointer=prefix,
host=host,
inputNode=graph["inputNode"],
outputNode=graph["outputNode"],
inputs=graph["inputs"],
outputs=graph["outputs"],
widgets=graph["widgets"],
state=graph["state"],
extra=graph["extra"],
proxyWidgets=host["properties"]["proxyWidgets"],
proxy_mappings=[],
)
for pi, (target, widget) in enumerate(host["properties"]["proxyWidgets"]):
n = next(n for n in graph["nodes"] if str(n["id"]) == target)
preview = widget == "$$canvas-image-preview"
f = next(
(f for f in fields if f["node_id"] == pre + target and f["field"] == widget),
None,
)
assert preview or f is not None
inp = next((x for x in n.get("inputs", []) if x["name"] == widget), None)
internal_edge = edge_by_id.get(inp.get("link")) if inp else None
host_slot = (
internal_edge["origin_slot"]
if isinstance(internal_edge, dict)
and internal_edge["origin_id"] == graph["inputNode"]["id"]
else None
)
mapping = dict(
proxy_index=pi,
raw=[target, widget],
node_id=pre + target,
widget=widget,
preview_only=preview,
**(dict(saved_pointer=f["pointer"], saved_value=f["value"]) if f else {}),
backend_mapping_verified=f["input_name"] is not None if f else False,
internal_origin_edge=internal_edge,
definition_input=graph["inputs"][host_slot] if host_slot is not None else None,
host_input=host["inputs"][host_slot] if host_slot is not None else None,
scope="原proxy/控件/保存位置/边界origin结构核准;后端schema缺口和宿主恢复另列;预览不造保存项",
)
boundary["proxy_mappings"].append(mapping)
flow.append(
"宿主"
+ str(host["id"])
+ " proxy原映射 "
+ json.dumps(mapping, ensure_ascii=False)
)
boundaries.append(boundary)
flow.append(
"宿主"
+ str(host["id"])
+ " 三scope原边界 "
+ json.dumps(boundary, ensure_ascii=False)
)
flow += ["根附加属性 " + json.dumps(g["extra"], ensure_ascii=False)] + prose["steps"]
assert len(fields) == 195 and len(comments) == 10 and len(boundaries) == 3
return dict(
source_path=PATHS[index],
source_sha1=hashlib.sha1(raw).hexdigest(),
source_sha256=hashlib.sha256(raw).hexdigest(),
canonical_sha256=hashlib.sha256(canonical(g)).hexdigest(),
notice=prose["notice"],
user_overview=prose["overview"],
versions=prose["versions"],
counts=dict(
saved_fields=195,
root_saved_fields=sum(f["scope"] == "root" for f in fields),
internal_saved_fields=sum(f["scope"] != "root" for f in fields),
linked_saved_fields=sum(f["role"] == "linked_override" for f in fields),
boundary_saved_fields=sum(f["role"] == "boundary_saved_cache" for f in fields),
frontend_only=sum(f["role"] == "frontend_only" for f in fields),
source_nodes=149,
root_nodes=53,
internal_nodes=96,
physical_edges=254,
source_notes=10,
proxy_widgets=48,
proxy_saved_references=44,
proxy_previews=4,
final_scalars=0,
final_prompt_constructed=False,
),
node_bindings=bindings,
fields=fields,
sources=sources,
comments=comments,
flow=flow,
flow_evidence=[],
zero_saved_nodes=empty,
boundaries=boundaries,
steps=[prose["overview"]] + prose["steps"],
)