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

103 lines
5.5 KiB
Python

"""Index exact pinned declarations and call sites; upstream code is data only."""
import json
from pathlib import Path
root = Path("docs/hel-892/setget-reference")
x = json.loads((root / "sources.json").read_text())
for entry in x["sources"]:
lines = (root / entry["local_file"]).read_text().splitlines()
needles = {
"web__js__setgetnodes.js": [
"function getGraphAncestors(graph)",
"function findSetterByName(graph, name)",
"function getLink(graph, linkId)",
"class SetNode extends LGraphNode",
"class GetNode extends LGraphNode",
"this.isVirtualNode = true;",
'this.properties["aux_id"] = "kijai/ComfyUI-KJNodes"',
"this.addWidget(",
"this.addInput(",
"this.addOutput(",
"if (app.configuringGraph) return;",
"onConfigure()",
"this.properties.previousName = this.widgets[0].value;",
"const name = checkForPreviousName",
"getInputLink(slot)",
"n => n.type === 'SetNode' && n.widgets[0].value === name",
'LiteGraph.registerNodeType("SetNode", SetNode)',
'LiteGraph.registerNodeType("GetNode", GetNode)',
"app.graphToPrompt = async function",
],
"__init__.py": ['WEB_DIRECTORY = "./web"'],
}.get(
entry["local_file"],
[
"widget.value = info.widgets_values[i++]",
"this.onConfigure?.(info)",
"getInputLink(slot: number)",
"const virtualLink = this.node.getInputLink(slot)",
"return inputNodeDto.resolveInput(virtualLink.target_slot, visited, type)",
"node.isVirtualNode ||",
"app.configuringGraphLevel++",
"window.comfyAPI.${moduleName}.${name}",
],
)
entry["rule_locations"] = {
f"{needle}#{i + 1}": [i + 1, i + 1]
for needle in needles
for i, line in enumerate(lines)
if needle in line
}
(root / "sources.json").write_text(json.dumps(x, ensure_ascii=False, indent=2) + "\n")
contract = {
"authority": "public_reference_only",
"verified_facts": {
"provider": "kijai/ComfyUI-KJNodes",
"commit": "ab72eda7ffad6280422d71ab7d54d3fb87c0ba18",
"registration": "WEB_DIRECTORY -> web/js/setgetnodes.js app.registerExtension/registerCustomNodes -> LiteGraph.registerNodeType",
"virtual": "both constructors set isVirtualNode=true; graphToPrompt omits virtual nodes",
"current_name": "single Constant widget; widgets_values[0] restored unchanged by LGraphNode.configure",
"lookup": "Get.getInputLink(slot) finds first SetNode with strict widgets[0].value === name in graph._nodes, then returns setter.inputs[slot] link",
"set_direct": "inherits LGraphNode.getInputLink(slot); same slot input link",
"frontend_chain": "app.graphToPrompt -> executionUtil.graphToPrompt -> ExecutableNodeDTO.resolveInput/resolveOutput -> virtual getInputLink -> setter input DTO resolveInput -> ultimate entity output",
"callbacks": "app wraps graph.configure with configuringGraphLevel; KJ onConnectionsChange and widget callbacks skip during configuringGraph; onConfigure paste rename requires !configuringGraph",
"previous_name": "Set.update may rename getters through previousName during editing callbacks; it is NOT Get.getInputLink lookup key; titles/labels are not lookup keys",
"scope": "upstream has ancestor/descendant traversal and cross-graph patch; exact current root lookup is separately visible in getInputLink; no scope isolation inferred from execution IDs",
"duplicates": "upstream same-root find returns first; reference rejects all duplicates",
"mode": "upstream can alter bypass Get mode while resolving prompt; reference rejects all nonzero modes without emulation",
"license": "KJ GPL-3.0, frontend GPL-3.0; full license texts and file notices preserved",
},
"explicit_reference_assumptions": {
"missing_version": "only for exact KJ aux_id, select the pinned commit; not target proof",
"missing_provider": "rejected, including literal SetNode/GetNode aux_id",
"missing_frontend": "explicit 1.37.11 only; 1.48.6 requires exact declaration",
"composition": "unmodified pinned root-only KJ plus previously pinned VHS and core widget construction/serialization, before queue hooks; no UE or other override",
"supported_types": "saved concrete equal socket/link types only; no wildcard/union coercion or inference",
"names": "exact saved string; no trim/casefold/Unicode normalization; nonempty whitespace string is valid if exactly matched",
},
"target_unknown": [
"actual provider/version",
"UE behavior and extension overrides",
"models/files/history",
"queue-time hooks",
"execution equivalence",
],
"not_supported": [
"nested/cross-boundary SetGet",
"mute/bypass/loops",
"dynamic type inference",
"arbitrary KJ classes",
"98 other frontend cohort",
"production registration or eligibility",
],
"rules": "sources.json rule_locations; exact line hits against full original byte SHA256",
}
(root / "contract.json").write_text(
json.dumps(contract, ensure_ascii=False, indent=2) + "\n"
)
# Remove discovery scratch created during this run; selected contract originals remain.
for name in ["commit.json", "historical-commit.json", "historical-setgetnodes.js"]:
(root / name).unlink(missing_ok=True)
print("indexed", len(x["sources"]))