Files
aigc-home/docs/hel-892/refonly-document-evidence/build_definition.py
T

122 lines
5.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Pin original positions and declared unknowns; no inferred implementation or execution."""
import hashlib
import json
from pathlib import Path
REPO = Path(__file__).resolve().parents[3]
OUT = Path(__file__).resolve().parent
REF = OUT.parent / "refonly-reference"
PATHS = ["example_ComfyUI_workflows/4-视频生成/uncensored/minimax-h3多参生视频无审核版.json"]
def canonical(v):
return json.dumps(v, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()
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())
fields, bindings, empty, flow = [], [], [], []
for i, n in enumerate(g["nodes"]):
nid, ptr = str(n["id"]), f"/nodes/{i}"
bindings.append(
dict(
node_id=nid,
class_type=n["type"],
source_version="未知:原件未声明",
source_id="unknown",
candidates=[],
declared_provider=None,
implementation_verified=False,
)
)
effect = editorial[nid] + " 原mode=0仅保存态,不认证执行或恢复。"
flow += [effect, nid + " 原节点完整保存 " + json.dumps(n, ensure_ascii=False)]
if n["widgets_values"] == []:
empty.append(
dict(
node_id=nid,
class_type=n["type"],
pointer=ptr,
scope="root",
state="empty_list",
named_state="missing",
effect=effect,
)
)
for j, value in enumerate(n["widgets_values"]):
fields.append(
dict(
node_id=nid,
definition_node_id=nid,
scope="root",
class_type=n["type"],
field=f"position_{j}",
label=f"第{j}保存位置({prose['position_hints'][nid][j]},仅源意图)",
pointer=f"{ptr}/widgets_values/{j}",
value=value,
json_type=type(value).__name__,
named_state="missing",
input_pointer="未知:无准确位置到后端输入映射,不以类名补实",
input_name=None,
type="原位置保存参考",
role="saved_reference",
schema_default="未知:提供方/版本未声明,没有准确schema默认",
limits="未知:无准确实现/前端版本,不认证范围、枚举支持、位置映射或恢复",
unit="未知:仅原JSON类型/位置,类名与标题不证明物理单位",
effect=effect
+ (
" 无原具名保存,不补具名值/双指针;源输入外线与位置缓存意图分列,"
"不认证此位置到schema的映射。"
),
evidence=[],
execution_note="仅静态原数据;不构造prompt/求表达式/随机/采样/模型/attention/shift/媒体/编码/上传/预览/清理。转换执行资格不变。",
)
)
flow += ["root 物理边 " + json.dumps(e, ensure_ascii=False) for e in g["links"]]
flow += ["根附加保存属性 " + json.dumps(g["extra"], ensure_ascii=False)]
flow += prose["steps"]
assert len(fields) == 40 and len(bindings) == 22 and len(empty) == 4
assert json.loads((REF / "sources.json").read_bytes())["sources"] == []
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="原件固定参考;22节点准确身份与前端版本全部未知,准确实现来源0。仅位置/原类型和静态连线,不认证schema、恢复或执行。",
user_overview=prose["overview"],
versions=[
"全部22节点无cnr_id/aux_id/ver,无frontendVersion,extra={};准确实现来源0,许可/依赖/默认/单位/映射/I/O/算法均未知。",
"旧133块8116条目/234注释冻结;新增40位置标量、零Note、无具名,累计134参考8156条目/234注释。文件名无审核版只原名称,不认证任何运行/模型/输出属性。",
],
counts=dict(
saved_fields=40,
root_saved_fields=40,
internal_saved_fields=0,
linked_saved_fields=0,
boundary_saved_fields=0,
frontend_only=0,
source_nodes=22,
root_nodes=22,
internal_nodes=0,
physical_edges=26,
source_notes=0,
saved_objects=0,
history_objects=0,
final_scalars=0,
final_prompt_constructed=False,
),
node_bindings=bindings,
fields=fields,
sources=[],
comments=[],
flow=flow,
flow_evidence=[],
zero_saved_nodes=empty,
boundaries=[],
steps=[prose["overview"]] + prose["steps"],
)