Files
aigc-home/docs/hel-892/videoinfo-evidence/build_contract.py
T

123 lines
6.6 KiB
Python

"""Index pinned source bytes as text only; never import upstream plugin code."""
import ast
import json
from pathlib import Path
root = Path("docs/hel-892/videoinfo-reference")
x = json.loads((root / "sources.json").read_text())
needles = {
"videohelpersuite__nodes.py": [
"class VideoInfoLoaded:",
'"video_info": ("VHS_VIDEOINFO",)',
'RETURN_TYPES = ("FLOAT","INT", "FLOAT", "INT", "INT",)',
"RETURN_NAMES = (",
'keys = ["fps", "frame_count", "duration", "width", "height"]',
'loaded_info.append(video_info[f"loaded_{key}"])',
"return (*loaded_info,)",
'"VHS_VideoInfoLoaded": VideoInfoLoaded,',
],
"__init__.py": ["NODE_CLASS_MAPPINGS", "WEB_DIRECTORY"],
"web__js__VHS.core.js": [
"function useKVState(nodeType)",
'chainCallback(this, "onConfigure"',
"if (!this.widgets)",
"if (typeof(info.widgets_values)",
"let widgetDict = info.widgets_values",
"if (info.widgets_values.length)",
'chainCallback(this, "onSerialize"',
"info.widgets_values = {};",
"info.widgets_values[w.name] = w.value;",
"async beforeRegisterNodeDef",
'if(nodeData?.name?.startsWith("VHS_"))',
"useKVState(nodeType);",
'if (["INT", "FLOAT"].includes(inp[0]))',
"const originalAddInput = this.addInput;",
],
"web__js__videoinfo.js": [
"let originalHandleFile",
"async function handleFile",
"app.loadGraphData",
],
}
for r in x["sources"]:
lines = (root / r["local_file"]).read_text().splitlines()
r["rule_locations"] = {
f"{needle}#{i + 1}": [i + 1, i + 1]
for needle in needles.get(r["local_file"], [])
for i, line in enumerate(lines)
if needle in line
}
if r["local_file"] == "videohelpersuite__nodes.py":
cls = next(
n
for n in ast.parse("\n".join(lines)).body
if isinstance(n, ast.ClassDef) and n.name == "VideoInfoLoaded"
)
r["rule_locations"]["full_class"] = [cls.lineno, cls.end_lineno]
(root / "sources.json").write_text(json.dumps(x, ensure_ascii=False, indent=2) + "\n")
contract = {
"authority": "public_reference_only_not_target_object_info",
"verified_facts": {
"provider": "comfyui-videohelpersuite",
"commit": "537f3a02269e14ab4b0350d4189a52034e9a3b12",
"registration": "__init__.py imports nodes.NODE_CLASS_MAPPINGS; nodes.py:1041 maps VHS_VideoInfoLoaded to VideoInfoLoaded",
"input": {"video_info": "VHS_VIDEOINFO"},
"output_slots": [
{"slot": i, "name": n, "type": t, "dictionary_key": "loaded_" + k}
for i, (n, t, k) in enumerate(
zip(
["fps🟦", "frame_count🟦", "duration🟦", "width🟦", "height🟦"],
["FLOAT", "INT", "FLOAT", "INT", "INT"],
["fps", "frame_count", "duration", "width", "height"],
)
)
],
"implementation": "get_video_info appends dictionary values in keys order and returns tuple; no type cast, validation, numeric default or media probing in this method",
"widgets": "none: custom VHS_VIDEOINFO socket has no scalar widget constructor",
"VHS_hook": "VHS.core.js beforeRegisterNodeDef applies useKVState to every VHS_ class, including this one; restore returns for absent widgets, or loops zero widgets; onSerialize always writes {}",
"empty_array": "pinned LGraphNode.configure restores widget values by looping existing widgets; zero widgets means [] is inert; VHS useKVState empty array has length 0, no migration; accept only {} and []",
"frontend_sources": "reuse setget-reference/sources.json pinned 1.37.11/1.48.6 LGraphNode, ExecutableNodeDTO, executionUtil, app and API exposure; vhs-reference frontend construction of custom socket",
"other_JS": "fixed tree has only web/js/VHS.core.js and web/js/videoinfo.js under production web; videoinfo.js intercepts loading workflow from video metadata, does not change VideoInfoLoaded schema; testframework excluded",
"scalar_widget_overrides": "VHS numeric widget override only INT/FLOAT inputs; not applicable to custom VHS_VIDEOINFO. Other load/combine preview/upload/format branches not selected by this node name",
"license": "GPL-3.0 full upstream LICENSE and notices retained; byte originals not reformatted",
"bypass_pointer_only": "setget-reference/web__js__setgetnodes.js getInputLink has bypass Get handling; intentionally not implemented",
},
"explicit_reference_assumptions": {
"composition": "only new VideoInfoLoaded@537f3a02 + old fixed VHS Combine@4ee72c06/Load@85509813 + old core identity serializers and root KJ@ab72eda7/Reroute; normal mode only",
"provider": "exact cnr_id and full commit required; aux conflicts rejected; no release equivalence",
"frontend": "1.37.11 explicit selection when missing; 1.48.6 requires explicit exact declaration",
"alias": "unchanged precise KJ aux-only missing-version assumption; literal aux still rejected; root scope only",
"extension": "unmodified fixed constructors/serializers, no custom override/UE binding; declaration does not prove target installation",
"return_names": "original names checked against schema; display label/localized_name never determine slot/type",
},
"target_unknown": [
"actual plugin/frontend/UE versions",
"info dictionary values and types at execution",
"media presence/validity",
"numeric fps/frame count/duration/dimensions",
"API/golden equivalence",
"execution/history",
"queue hooks",
],
"real_chains": {
"546": "VHS_LoadVideo573 slot3 -> info546 -> FLOAT slot0 -> Set568 -> Get535 -> Combine550.frame_rate",
"101": "VHS_LoadVideo112 slot3 -> info101 -> FLOAT slot0 -> Set104 -> Get121 -> Combine200.frame_rate",
"loader": "both 8e4d79471bf1952154768e8435a9300077b534fa; not covered; dimension UE bindings present",
"aliases": "four literal aux IDs unproven; entity schema does not upgrade origin/scope authority",
"scalar": "saved frame_rate30 and loader force_rate0/16 are not final fps; no info dictionary evaluated",
},
"not_supported": [
"other VHS versions/classes",
"other frontend versions",
"nested alias scope",
"bypass/mute/loops",
"media read/ffprobe",
"partial prompt or production eligibility",
],
}
(root / "contract.json").write_text(
json.dumps(contract, ensure_ascii=False, indent=2) + "\n"
)
print("indexed", len(x["sources"]), "originals")