"""Inventory immutable core bytes and reuse the SAME pinned frontend identity.""" import hashlib import json from pathlib import Path ROOT = Path(__file__).resolve().parent CORE = "2f35f4a08176d993cded35dac3332be4f7287f41" FRONTEND = "743be3f4fe2e374b0ee39f0ded56e7cb65a837c5" ANCHORS = ( "class StringMultiline", "class Float", "class ResolutionSelector", "class AspectRatio", "class MathExpressionNode", "class RandomNoise", "class BasicScheduler", "def define_schema", "async def get_node_list", "async def comfy_entrypoint", "class MultiType", "class Autogrow", "class TemplateNames", "def as_dict", "def _expand_schema_for_dynamic", "node_id", "get_node_list()", "schema.node_id", "nodes_primitive.py", "nodes_resolution.py", "nodes_math.py", "nodes_custom_sampler.py", "SCHEDULER_HANDLERS =", "SCHEDULER_NAMES =", "def execute", "noise_seed", "control_after_generate", "getRestoredWidgetValue", "createWidgetRestorationState", "restoreNamed", "serializeValue", "widgets_values_named", "serialiseWidgetValues", "widget.options?.serialize", "inputs[input.name]", "applyAutogrow", "addAutogrowGroup", "autogrowOrdinalToName", "onConnectionsChange", "getOrderedInputSpecs", "for (const inputSpec of orderedInputSpecs)", "mode === 'fixed'", "beforeQueued", "afterQueued", "applyDynamicInputs", "RESOLUTION", "serialize: false", "fallbackWidgetsValuesNames", ) def main(): old = json.loads((ROOT.parent / "h3-reference/sources.json").read_bytes()) rows = [] for entry in old["sources"]: if entry["id"].startswith("frontend:"): row = dict(entry) row["local_file"] = "../h3-reference/" + row["local_file"] row["reuse"] = ( "same frontend1.53.10 full commit, no core0.30.0 identity reused" ) rows.append(row) existing = {r["id"] for r in rows} for p in sorted(ROOT.glob("*__*")): prefix, _, tail = p.name.partition("__") if prefix not in ("core", "frontend"): continue filename = tail.replace("__", "/") ident = f"{prefix}:{filename}" if ident in existing: # Already references the same full commit original, do not duplicate. continue repo, sha, tag = ( ("Comfy-Org/ComfyUI", CORE, "v0.33.0") if prefix == "core" else ("Comfy-Org/ComfyUI_frontend", FRONTEND, "v1.53.10") ) lines = p.read_text().splitlines() locations = { f"{anchor}@{i}": [i, min(i + 4, len(lines))] for anchor in ANCHORS for i, line in enumerate(lines, 1) if anchor in line } rows.append( { "id": ident, "repository": f"https://github.com/{repo}", "commit": sha, "tag": tag, "file": filename, "lines": [[1, len(lines)]], "rule_locations": locations, "raw_url": f"https://raw.githubusercontent.com/{repo}/{sha}/{filename}", "url": f"https://github.com/{repo}/blob/{sha}/{filename}", "sha256": hashlib.sha256(p.read_bytes()).hexdigest(), "local_file": p.name, "license": "GPL-3.0", "target_version_match": "unknown", } ) identities = [] for name, repo, ref, expected, local in ( ("core-tag", "Comfy-Org/ComfyUI", "v0.33.0", CORE, "core-tag.json"), ( "frontend-tag", "Comfy-Org/ComfyUI_frontend", "v1.53.10", FRONTEND, "../h3-reference/ComfyUI_frontend-tag.json", ), ): raw = (ROOT / local).read_bytes() data = json.loads(raw) assert data["object"]["sha"] == expected and data["object"]["type"] == "commit" identities.append( { "id": name, "raw_url": f"https://api.github.com/repos/{repo}/git/ref/tags/{ref}", "local_file": local, "sha256": hashlib.sha256(raw).hexdigest(), "ref": f"refs/tags/{ref}", "commit": expected, } ) (ROOT / "sources.json").write_text( json.dumps( { "schema_version": 1, "authority": "public_reference_only_not_object_info", "sources": rows, "identity_observations": identities, "target_installation": "unknown", "source_graph_identity": "unknown", "upstream_code_executed": False, }, ensure_ascii=False, indent=2, ) + "\n" ) if __name__ == "__main__": main()