docs: pin unversioned multi-reference workflow saved positions
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
"""Bind actual GET, reversible text, screenshots and completed checks."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from build_definition import OUT, REF, REPO
|
||||
from rebuild import BASE
|
||||
|
||||
BROWSER = REPO / ".local-evidence/refonly-document/browser"
|
||||
|
||||
|
||||
def sha(raw):
|
||||
return hashlib.sha256(raw).hexdigest()
|
||||
|
||||
|
||||
def write(name, data):
|
||||
(OUT / name).write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n")
|
||||
|
||||
|
||||
def main():
|
||||
actual = json.loads((BROWSER / "actual-get.json").read_bytes())
|
||||
export = OUT / ("actual-" + actual["name"] + ".json")
|
||||
doc = json.loads(export.read_bytes())
|
||||
assert actual["doc_json"] == doc
|
||||
shutil.copyfile(BROWSER / "actual-get.json", OUT / "actual-get.json")
|
||||
write(
|
||||
"get-binding.json",
|
||||
dict(
|
||||
workflow_id=actual["id"],
|
||||
get_sha256=sha((BROWSER / "actual-get.json").read_bytes()),
|
||||
export_sha256=sha(export.read_bytes()),
|
||||
doc_json_equals_isolated_export=True,
|
||||
comparison="Parsed JSON content equality, not original HTTP serialization bytes",
|
||||
pins=json.loads((OUT / "pins.json").read_bytes()),
|
||||
),
|
||||
)
|
||||
for p in (REPO / ".local-evidence").glob("refonly-*.log"):
|
||||
shutil.copyfile(p, OUT / (p.stem + ".txt"))
|
||||
for name in [
|
||||
"configure-refonly.py",
|
||||
"prose-refonly.py",
|
||||
"checks-refonly.py",
|
||||
"browser-refonly.py",
|
||||
"finish-refonly.py",
|
||||
]:
|
||||
shutil.copyfile(REPO / ".local-evidence" / name, OUT / (name + ".txt"))
|
||||
for p in (REPO / ".local-evidence").glob("refonly-*.txt"):
|
||||
shutil.copyfile(p, OUT / p.name)
|
||||
b = doc["fixed_version"]
|
||||
browser = json.loads((OUT / "browser-results.json").read_bytes())
|
||||
backend = json.loads((OUT / "backend-request-counts.json").read_bytes())
|
||||
reports = [OUT.parent / "多参生视频无审核版原保存与未知身份固定参考中文说明.md"]
|
||||
assert len(reports) == 1
|
||||
report = reports[0].read_text()
|
||||
texts = []
|
||||
for n in b["comments"]:
|
||||
raw = n["text"]
|
||||
literal = json.dumps(raw, ensure_ascii=False, indent=2)
|
||||
assert "\n```json\n" + literal + "\n```" in report
|
||||
assert json.loads(literal) == raw
|
||||
renders = [r for r in browser["text_renderings"] if r["kind"] == "Note" + n["node_id"]]
|
||||
assert len(renders) == 2 and all(r["decoded_sha256"] == sha(raw.encode()) for r in renders)
|
||||
texts.append(
|
||||
dict(
|
||||
node_id=n["node_id"],
|
||||
raw_codepoints=len(raw),
|
||||
raw_sha256=sha(raw.encode()),
|
||||
report_json_sha256=sha(literal.encode()),
|
||||
decoded_sha256=sha(json.loads(literal).encode()),
|
||||
CR=raw.count("\r"),
|
||||
LF=raw.count("\n"),
|
||||
literal_backslash_n=raw.count("\\n"),
|
||||
tail_LF=raw.endswith("\n"),
|
||||
browser_renderings=renders,
|
||||
)
|
||||
)
|
||||
assert not b["comments"] and not doc.get("source_notes")
|
||||
source_texts = []
|
||||
for f in b["fields"]:
|
||||
if f["node_id"] != "1" or f["field"] != "position_0":
|
||||
continue
|
||||
raw = f["value"]
|
||||
renders = [r for r in browser["text_renderings"] if r["kind"] == "prompt1"]
|
||||
assert len(renders) == 2 and all(
|
||||
r["rendered_utf8_sha256"] == sha(raw.encode()) for r in renders
|
||||
)
|
||||
source_texts.append(
|
||||
dict(
|
||||
node_id="1",
|
||||
characters=len(raw),
|
||||
LF=raw.count("\n"),
|
||||
CR=raw.count("\r"),
|
||||
tail_LF=raw.endswith("\n"),
|
||||
raw_sha256=sha(raw.encode()),
|
||||
report_json_sha256=sha(json.dumps(raw, ensure_ascii=False).encode()),
|
||||
decoded_sha256=sha(raw.encode()),
|
||||
browser_renderings=renders,
|
||||
)
|
||||
)
|
||||
write(
|
||||
"rendered-text-sha256.json",
|
||||
dict(raw_json_decoded_separate=True, notes=texts, source_texts=source_texts),
|
||||
)
|
||||
fields = []
|
||||
original = json.loads((OUT / "definition-0.json").read_bytes())
|
||||
for f, source_field in zip(b["fields"], original["fields"], strict=True):
|
||||
assert f["pointer"] == source_field["pointer"]
|
||||
assert f["value"] == source_field["value"]
|
||||
assert type(f["value"]).__name__ == f["json_type"] == type(source_field["value"]).__name__
|
||||
assert "named_pointer" not in f and "named_value" not in f
|
||||
literal = json.dumps(source_field["value"], ensure_ascii=False, indent=2)
|
||||
assert "\n```json\n" + literal + "\n```" in report
|
||||
assert json.loads(literal) == f["value"]
|
||||
fields.append(
|
||||
dict(
|
||||
pointer=f["pointer"],
|
||||
named_state=f["named_state"],
|
||||
json_type=f["json_type"],
|
||||
source_order_report_json_sha256=sha(literal.encode()),
|
||||
get_json_sha256=sha(json.dumps(f["value"], ensure_ascii=False, indent=2).encode()),
|
||||
get_value_type=type(f["value"]).__name__,
|
||||
)
|
||||
)
|
||||
write("saved-value-evidence.json", dict(saved_entries=40, fields=fields))
|
||||
viewed = json.loads((OUT / "viewed-screenshots.json").read_bytes())
|
||||
write(
|
||||
"screenshot-review.json",
|
||||
dict(
|
||||
viewed=[dict(path=n, sha256=sha((BROWSER / n).read_bytes())) for n in viewed],
|
||||
total=len(list(BROWSER.glob("*.png"))),
|
||||
findings="代表默认用途、22未知身份、共享MODEL/独立Math/普通output链、保存边界/完整prompt/字符串64实际查看;长文DOM/SHA,不称逐字目验,无横溢,未改CSS/字体。",
|
||||
),
|
||||
)
|
||||
tests = int(re.search(r"(\d+) passed", (OUT / "refonly-tests-final.txt").read_text())[1])
|
||||
frozen = json.loads((OUT / "baseline-frozen-files.json").read_bytes())
|
||||
closure = json.loads((OUT / "source-closure.json").read_bytes())
|
||||
rows = json.loads((REF / "sources.json").read_bytes())["sources"]
|
||||
write(
|
||||
"validation-results.json",
|
||||
dict(
|
||||
base=BASE,
|
||||
backend_tests=tests,
|
||||
browser_assertions=browser["assertion_count"],
|
||||
browser_groups=browser["assertionGroups"],
|
||||
source_rows=len(rows),
|
||||
source_closure_files=closure["count"],
|
||||
accurate_nodes=0,
|
||||
unresolved_implementation_nodes=0,
|
||||
unknown_nodes=22,
|
||||
saved_entries=40,
|
||||
notes=0,
|
||||
screenshots=len(list(BROWSER.glob("*.png"))),
|
||||
viewed=len(viewed),
|
||||
backend_fixed_gets=backend["fixed_count"],
|
||||
browser_fixed_gets=browser["request_accounting"]["fixed_count"],
|
||||
backend_polling_gets=backend["polling_count"],
|
||||
browser_polling_gets=browser["request_accounting"]["polling_count"],
|
||||
fixture_interceptions=len(browser["interceptions"]),
|
||||
readiness_gets=1,
|
||||
forbidden_requests=0,
|
||||
frozen_baseline_files=frozen["count"],
|
||||
old_fixed_blocks=133,
|
||||
other_reviews=155,
|
||||
frontend_build="rerun this batch",
|
||||
full_browser="rerun this batch; no accumulation",
|
||||
upstream_executed=False,
|
||||
target_connected=False,
|
||||
),
|
||||
)
|
||||
print("PASS actual GET/export,40 un-named original positions and full prompt raw/DOM SHA")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user