427 lines
16 KiB
Python
427 lines
16 KiB
Python
"""AST/text evidence only. No upstream imports, callbacks or prompt execution."""
|
||
|
||
import ast
|
||
import csv
|
||
import difflib
|
||
import io
|
||
import json
|
||
import textwrap
|
||
|
||
from acquire import DOC, ROOT, save, sha
|
||
|
||
OLD = ROOT / "docs/hel-892/batch178-aio-protocol"
|
||
|
||
|
||
def nodes(text):
|
||
result = {}
|
||
|
||
def visit(items, prefix=""):
|
||
for node in items:
|
||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
|
||
name = prefix + node.name
|
||
result[name] = node
|
||
if isinstance(node, ast.ClassDef):
|
||
visit(node.body, name + ".")
|
||
|
||
visit(ast.parse(text).body)
|
||
return result
|
||
|
||
|
||
def csv_save(name, rows):
|
||
stream = io.StringIO(newline="")
|
||
writer = csv.DictWriter(stream, fieldnames=list(rows[0]), lineterminator="\n")
|
||
writer.writeheader()
|
||
writer.writerows(
|
||
{key: json.dumps(value, ensure_ascii=False) for key, value in row.items()} for row in rows
|
||
)
|
||
from acquire import write
|
||
|
||
write(name, stream.getvalue().encode())
|
||
|
||
|
||
def main():
|
||
identities = json.loads((DOC / "identities.json").read_text())
|
||
csv_save("identities.csv", identities[:4])
|
||
evidence = {}
|
||
source_nodes = {}
|
||
for identity in identities[:4]:
|
||
text = (DOC / identity["file"]).read_text()
|
||
index = nodes(text)
|
||
source_nodes[identity["path"]] = index
|
||
for name, node in index.items():
|
||
excerpt = "\n".join(text.splitlines()[node.lineno - 1 : node.end_lineno]) + "\n"
|
||
evidence[identity["path"] + ":" + name] = dict(
|
||
source=identity,
|
||
function=name,
|
||
lines=[node.lineno, node.end_lineno],
|
||
text=excerpt,
|
||
sha256=sha(excerpt.encode()),
|
||
ast_sha256=sha(ast.dump(node, include_attributes=False).encode()),
|
||
)
|
||
save("branch-evidence.json", evidence)
|
||
old_evidence = json.loads((OLD / "branch-evidence.json").read_text())
|
||
save(
|
||
"reused-aux-evidence.json", {k: v for k, v in old_evidence.items() if k.startswith("aux:")}
|
||
)
|
||
locations = {
|
||
**{
|
||
name: "execution.py:" + name
|
||
for name in (
|
||
"get_input_data",
|
||
"_async_map_node_over_list",
|
||
"get_output_data",
|
||
"get_output_from_returns",
|
||
"merge_result_data",
|
||
"execute",
|
||
"validate_inputs",
|
||
"validate_prompt",
|
||
)
|
||
},
|
||
"get_input_info": "comfy_execution/graph.py:get_input_info",
|
||
"get_cache": "comfy_execution/graph.py:ExecutionList.get_cache",
|
||
"cache_update": "comfy_execution/graph.py:ExecutionList.cache_update",
|
||
"is_link": "comfy_execution/graph_utils.py:is_link",
|
||
"validate_node_input": "comfy_execution/validation.py:validate_node_input",
|
||
}
|
||
(DOC / "differences").mkdir()
|
||
comparisons = []
|
||
for version in ("0.21.1", "0.17.0"):
|
||
for name, key in locations.items():
|
||
old = old_evidence[version + ":" + name]
|
||
new = evidence[key]
|
||
old_ast = ast.dump(
|
||
ast.parse(textwrap.dedent(old["text"])).body[0], include_attributes=False
|
||
)
|
||
same = sha(old_ast.encode()) == new["ast_sha256"]
|
||
diff = "".join(
|
||
difflib.unified_diff(
|
||
old["text"].splitlines(True),
|
||
new["text"].splitlines(True),
|
||
fromfile=version + ":" + name,
|
||
tofile="8010:" + name,
|
||
)
|
||
)
|
||
filename = "differences/" + version + "__" + name + ".diff.txt"
|
||
from acquire import write
|
||
|
||
write(filename, diff.encode())
|
||
comparisons.append(
|
||
dict(
|
||
version=version,
|
||
old_commit=old["source"]["commit"],
|
||
function=name,
|
||
old_source=old["source"],
|
||
old_lines=old["lines"],
|
||
new_evidence=key,
|
||
new_lines=new["lines"],
|
||
ast_equal=same,
|
||
conclusion="same AST only" if same else "different AST; see complete text diff",
|
||
diff=filename,
|
||
runtime_equivalence="not certified",
|
||
)
|
||
)
|
||
save("function-comparison.json", comparisons)
|
||
csv_save("function-comparison.csv", comparisons)
|
||
specs = [
|
||
(
|
||
"input-link",
|
||
"execution.py",
|
||
168,
|
||
195,
|
||
(
|
||
"is_link and not rawLink; execution_list/cache/output exists; "
|
||
"output_index < len(outputs)"
|
||
),
|
||
"从cached.outputs[output_index]取值;缺缓存/越上界标missing,不靠RETURN_TYPES裁剪缓存。",
|
||
"链接局部分支与旧版相同;全函数因新增隐藏输入不同。",
|
||
"get_input_data",
|
||
),
|
||
(
|
||
"dispatch",
|
||
"execution.py",
|
||
252,
|
||
328,
|
||
"INPUT_IS_LIST or per-item slice; blocker / V1 / V3 / coroutine dispatch",
|
||
"V1直接getattr(obj,func)(**inputs);重复最后输入;V3使用clone/嵌套输入;异步可返Task。",
|
||
"V1局部调用相同;V3 build_nested_inputs新增input_is_list参数,全函数不同。",
|
||
"_async_map_node_over_list",
|
||
),
|
||
(
|
||
"result-normal",
|
||
"execution.py",
|
||
365,
|
||
383,
|
||
"dict with result, no expand, result not ExecutionBlocker",
|
||
"ui单独收集;整项result加入results,不按RETURN_TYPES长度截断。",
|
||
"所属get_output_from_returns在两旧版均AST相同。",
|
||
"get_output_from_returns",
|
||
),
|
||
(
|
||
"merge-default",
|
||
"execution.py",
|
||
331,
|
||
350,
|
||
"results nonempty; no OUTPUT_IS_LIST; all batches have compatible indices",
|
||
"按首项实际len建立False标记,再逐出口收集;AIO传出的二项result在此条件保留二项。",
|
||
"两旧版该函数AST相同;不证明继承/依赖/实跑等价。",
|
||
"merge_result_data",
|
||
),
|
||
(
|
||
"merge-explicit",
|
||
"execution.py",
|
||
334,
|
||
349,
|
||
"OUTPUT_IS_LIST present or heterogeneous result lengths",
|
||
"zip长度受显式标记限制,短标记可截断;True分支extend;后续缺索引可IndexError。",
|
||
"两旧版AST相同;不能泛化为一定保留或一定拒绝。",
|
||
"merge_result_data",
|
||
),
|
||
(
|
||
"ui",
|
||
"execution.py",
|
||
416,
|
||
423,
|
||
"one or more ui dictionaries",
|
||
"按第一个ui键汇集x[k];后项缺键可抛错,存在ui不等于生成成功。",
|
||
"两旧版AST相同。",
|
||
"get_output_from_returns",
|
||
),
|
||
(
|
||
"blocker-expand-v3",
|
||
"execution.py",
|
||
370,
|
||
415,
|
||
"expand key / _NodeOutputInternal / ExecutionBlocker",
|
||
"扩图先收subgraph_results;blocker按RETURN_TYPES长度造占位;V3独立分支,不能套普通dict结论。",
|
||
"此拆分函数两旧版AST相同;准确8010 SDK/缓存等依赖文本未取得。",
|
||
"get_output_from_returns",
|
||
),
|
||
(
|
||
"pending",
|
||
"execution.py",
|
||
352,
|
||
358,
|
||
"any unfinished asyncio.Task",
|
||
"先返回待处理结果;无待处理Task才调用拆分函数。",
|
||
"两旧版该函数AST相同。",
|
||
"get_output_data",
|
||
),
|
||
(
|
||
"async-resume",
|
||
"execution.py",
|
||
455,
|
||
491,
|
||
"pending_async_nodes or pending_subgraph_results",
|
||
"Task.result异常重新抛;子图取缓存并merge;继续走后置UI/缓存,不能视作普通同步返回。",
|
||
"execute全函数不同;只能引用本commit这些调用,不继承旧版整体成功/失败结论。",
|
||
"execute",
|
||
),
|
||
(
|
||
"call-cleanup",
|
||
"execution.py",
|
||
499,
|
||
572,
|
||
"cache miss; instantiate object; lazy checks; get_output_data try/finally",
|
||
"懒输入可PENDING;finally内aimdo条件清理也可能影响完成,未取得相关实现。",
|
||
"execute不同,新增/变化外围须独立保留条件。",
|
||
"execute",
|
||
),
|
||
(
|
||
"ui-enrich-cache",
|
||
"execution.py",
|
||
573,
|
||
629,
|
||
"nonempty output_ui; optional client; has_subgraph",
|
||
"先enrich/register并可能发executed,再子图PENDING或CacheEntry(outputs=output_data)缓存。",
|
||
"execute不同;UI/媒体/asset和cache provider行为不继承旧版。",
|
||
"execute",
|
||
),
|
||
(
|
||
"exceptions",
|
||
"execution.py",
|
||
631,
|
||
663,
|
||
"InterruptProcessingException or Exception inside execute try",
|
||
"返回FAILURE与错误详情;发生在缓存命中早返/try之外的异常不由这层概括。",
|
||
"execute不同;仅本地try作用域可核,不作全宿主异常保证。",
|
||
"execute",
|
||
),
|
||
(
|
||
"history-partial",
|
||
"execution.py",
|
||
784,
|
||
843,
|
||
"PromptExecutor loop; FAILURE/PENDING/SUCCESS",
|
||
"FAILURE处理后break;无break才execution_success;history收已有ui,局部UI不证明整体成功。",
|
||
"178原branch索引未提供该完整方法;本次从四文本取得,不冒称旧方法相同。",
|
||
"PromptExecutor.execute_async",
|
||
),
|
||
(
|
||
"declared-index",
|
||
"execution.py",
|
||
927,
|
||
991,
|
||
"linked val is length-2 list; upstream registered class",
|
||
"先r=RETURN_TYPES再r[val[1]];AIO仅声明IMAGE,索引1不能凭多返回合法化;0仍需其它校验。",
|
||
"声明索引局部赋值两旧版相同;递归visiting/cycle及全validate_inputs不同。",
|
||
"validate_inputs",
|
||
),
|
||
(
|
||
"cycle-schema-custom",
|
||
"execution.py",
|
||
849,
|
||
903,
|
||
"cycle / V3 finalized inputs / custom validator",
|
||
"新增visiting循环检测;V3模式和INPUT_TYPES调用是运行时条件,本批仅文本不调用。",
|
||
"validate_inputs不同,不能把旧校验错误集合当8010全集。",
|
||
"validate_inputs",
|
||
),
|
||
(
|
||
"partial-validation",
|
||
"execution.py",
|
||
1208,
|
||
1300,
|
||
"per-output validation exception; validate_loops; good_outputs",
|
||
"外层捕获exception_during_validation;循环校验可再移除输出;全无good输出才失败,否则部分接受。",
|
||
"validate_prompt不同:新增loop/cycle阶段;局部成功不等于case01全图成功。",
|
||
"validate_prompt",
|
||
),
|
||
(
|
||
"graph-cache",
|
||
"comfy_execution/graph.py",
|
||
230,
|
||
264,
|
||
"cache listeners and optional output_link_callback",
|
||
"get_cache触碰写回set_local;cache_update向订阅者传播并调用可选callback(value.outputs[socket])。",
|
||
"逐函数差异见comparison;缓存callback实现不在四份文本内。",
|
||
"ExecutionList.cache_update",
|
||
),
|
||
(
|
||
"type-validation",
|
||
"comfy_execution/validation.py",
|
||
193,
|
||
247,
|
||
"exact/Any/MatchType/Combo/type strings and strict flag",
|
||
"相等立即True;其余引用IO类型并做集合判断,不能只靠IMAGE字面量覆盖所有自定义类型。",
|
||
"逐函数AST比较见comparison;准确SDK IO定义未取得。",
|
||
"validate_node_input",
|
||
),
|
||
]
|
||
matrix = []
|
||
for key, path, start, end, condition, outcome, old, function in specs:
|
||
identity = next(x for x in identities if x["path"] == path)
|
||
lines = (DOC / identity["file"]).read_text().splitlines(True)
|
||
assert end <= len(lines), (key, len(lines))
|
||
excerpt = "".join(lines[start - 1 : end])
|
||
matrix.append(
|
||
dict(
|
||
id=key,
|
||
path=path,
|
||
lines=[start, end],
|
||
source_sha256=identity["sha256"],
|
||
evidence=path + ":" + function,
|
||
condition=condition,
|
||
conditional_result=outcome,
|
||
comparison_to_178=old,
|
||
excerpt=excerpt,
|
||
excerpt_sha256=sha(excerpt.encode()),
|
||
evidence_kind="static source text; engine tests 0",
|
||
)
|
||
)
|
||
save("protocol-matrix.json", matrix)
|
||
csv_save("protocol-matrix.csv", matrix)
|
||
case_path = "docs/hel-892/supplied-api/01.api.json"
|
||
case_bytes = (ROOT / case_path).read_bytes()
|
||
case = json.loads(case_bytes)
|
||
uses = []
|
||
for source, consumer in (("33", "36"), ("34", "37")):
|
||
assert case[source]["class_type"] == "AIO_Preprocessor"
|
||
assert case[consumer]["inputs"]["images"] == [source, 0]
|
||
uses.append(
|
||
dict(
|
||
source=source,
|
||
consumer=consumer,
|
||
input="images",
|
||
index=0,
|
||
preprocessor=case[source]["inputs"]["preprocessor"],
|
||
)
|
||
)
|
||
save("case-links.json", dict(file=case_path, sha256=sha(case_bytes), uses=uses, executed=False))
|
||
save(
|
||
"missing-conditions.json",
|
||
dict(
|
||
scope="Four files at historical sampling instant only; no current loaded attestation",
|
||
required_before_runtime_claim=[
|
||
{
|
||
"path": "comfy_execution/caching.py",
|
||
"reason": "Basic/Hierarchical/LRU/RAMPressureCache get/set invalidation",
|
||
},
|
||
{
|
||
"path": "comfy_execution/asset_enrichment.py",
|
||
"reason": "register_executed_outputs and emit_cached_output",
|
||
},
|
||
{
|
||
"path": "comfy_execution/media_enrichment.py",
|
||
"reason": "enrich_output_with_media_metadata before cache write",
|
||
},
|
||
{
|
||
"path": "app/assets/manager.py",
|
||
"reason": "AssetManager/NoAssets and external asset behavior",
|
||
},
|
||
{
|
||
"path": "comfy_api/internal/__init__.py",
|
||
"reason": (
|
||
"V3 _ComfyNodeInternal/_NodeOutputInternal exports; definitions unresolved"
|
||
),
|
||
},
|
||
{
|
||
"path": "comfy_api/latest/__init__.py",
|
||
"reason": "io/_io SDK export resolution; 177 other commits cannot substitute",
|
||
},
|
||
{
|
||
"path": "comfy_execution/cache_provider.py",
|
||
"reason": "external cache providers/callback contracts",
|
||
},
|
||
{
|
||
"path": "comfy_execution/utils.py",
|
||
"reason": "CurrentNodeContext surrounding sync/async calls",
|
||
},
|
||
],
|
||
other_unverified=(
|
||
"aimdo/memory cleanup, progress, registered classes/"
|
||
"dependencies/model/media/license/frontend/history"
|
||
),
|
||
additional_files_fetched=False,
|
||
proposed_next_action="总管决定是否另行授权必要准确辅助;本批不推进181",
|
||
qualification=dict(
|
||
finalized=0,
|
||
new_reliable_conversions=0,
|
||
real_generations=0,
|
||
engine_tests=0,
|
||
draft=True,
|
||
enabled=False,
|
||
checked=False,
|
||
finalized_at="",
|
||
run_at="",
|
||
rCM="excluded",
|
||
),
|
||
counters=(
|
||
"16/139; 1217/3660/294; 155 blocks/pins; 10761 values; "
|
||
"287 notes; 163 originals unchanged"
|
||
),
|
||
),
|
||
)
|
||
print(
|
||
"4 identities;",
|
||
len(evidence),
|
||
"AST excerpts;",
|
||
len(comparisons),
|
||
"function comparisons;",
|
||
len(matrix),
|
||
"branches",
|
||
)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|