Add safe Vcore wowdiag and wowsrc imports with original-data provenance
This commit is contained in:
1 parent
4543e7cd31
commit
741c1ca4a5
25 files changed
+1469
-9
No files matched your search
@@ -150,6 +150,13 @@ class CaseAssembler:
|
||||
add(path, role)
|
||||
reports = [(path, load(path, "report")) for path, role in roles if role == "report"]
|
||||
reproductions = [(path, load(path, "reproduction")) for path, role in roles if role == "reproduction"]
|
||||
for _, document in reports + reproductions:
|
||||
nodes = [document] + [node for field in ("observations", "expected_behavior", "comments", "tester_hypotheses", "facts", "entities", "data_quality_issues") for node in document.get(field, [])]
|
||||
for node in nodes:
|
||||
if "origin" in node:
|
||||
for field in ("source_ref", "archive_ref"):
|
||||
if node["origin"].get(field) is not None:
|
||||
require_file(reader, node["origin"][field])
|
||||
for _, document in reproductions:
|
||||
for path in document.get("attachments", []):
|
||||
add(path, "attachment")
|
||||
@@ -174,11 +181,15 @@ class CaseAssembler:
|
||||
identity = (entity["type"], entity_id)
|
||||
record = entities.setdefault(identity, {"type": identity[0], "id": identity[1], "roles": [], "provenance": []})
|
||||
record["roles"] = sorted(set(record["roles"]) | set(entity.get("roles", [])))
|
||||
record["provenance"].append(provenance(path, f"/entities/{index}", "report" if document["format"] == "viano-bug-report" else "reproduction_record"))
|
||||
record["provenance"].append(provenance(path, f"/entities/{index}", "report" if document["format"] == "viano-bug-report" else "reproduction_record", entity))
|
||||
issues = []
|
||||
|
||||
def issue(code, message, refs=None):
|
||||
issues.append({"code": code, "message": message, "refs": refs or []})
|
||||
for path, report in reports:
|
||||
for index, item in enumerate(report.get("data_quality_issues", [])):
|
||||
source = item.get("origin", {"source_ref": path, "json_pointer": f"/data_quality_issues/{index}"})
|
||||
issue(item["code"], item["message"], [{"source_ref": source["source_ref"], "json_pointer": source["json_pointer"]}])
|
||||
|
||||
if not index_ref:
|
||||
issue("MISSING_INPUT_INDEX", "No explicit case input index was supplied")
|
||||
@@ -215,7 +226,8 @@ class CaseAssembler:
|
||||
"format": "viano-case", "format_version": 1, "builder_version": "1",
|
||||
"case": {"case_id": manifest["case_id"], "package_id": manifest["package_id"], "analysis_revision": int(manifest["analysis_revision"]),
|
||||
"source_generation": int(manifest["package_generation"]), "project": copy.deepcopy(manifest["project"])},
|
||||
"bug": {"reports": [{"source_ref": path, "title": document.get("title"), "summary": document.get("summary")} for path, document in reports]},
|
||||
"bug": {"reports": [{"source_ref": path, "title": document.get("title"), "summary": document.get("summary"),
|
||||
**({"origin": copy.deepcopy(document["origin"])} if "origin" in document else {})} for path, document in reports]},
|
||||
"human_observations": {"observations": observations, "comments": comments, "tester_hypotheses": hypotheses},
|
||||
"expected_behavior": expected,
|
||||
"reproduction": {"records": reproduction_records},
|
||||
|
||||
@@ -3,8 +3,11 @@ import copy
|
||||
|
||||
def provenance(path: str, pointer: str, kind: str, statement: dict | None = None) -> dict:
|
||||
value = statement or {}
|
||||
return {"kind": kind, "source_ref": path, "json_pointer": pointer,
|
||||
"author": value.get("author"), "observed_at": value.get("observed_at")}
|
||||
result = {"kind": kind, "source_ref": path, "json_pointer": pointer,
|
||||
"author": value.get("author"), "observed_at": value.get("observed_at")}
|
||||
if "origin" in value:
|
||||
result["origin"] = copy.deepcopy(value["origin"])
|
||||
return result
|
||||
|
||||
|
||||
def collect_statements(documents: list[tuple[str, dict]], field: str, prefix: str) -> list[dict]:
|
||||
|
||||
@@ -8,12 +8,15 @@ from .report_collector import provenance
|
||||
def collect_reproductions(documents: list[tuple[str, dict]], inline_limit: int) -> tuple[list[dict], list[dict]]:
|
||||
records, facts = [], []
|
||||
for path, document in documents:
|
||||
records.append({"id": f"R{len(records) + 1:04d}", "source_ref": path,
|
||||
record = {"id": f"R{len(records) + 1:04d}", "source_ref": path,
|
||||
"steps": list(document.get("steps", [])), "events_ref": document.get("events_ref"),
|
||||
"attachments": list(document.get("attachments", []))})
|
||||
"attachments": list(document.get("attachments", []))}
|
||||
if "origin" in document:
|
||||
record["origin"] = copy.deepcopy(document["origin"])
|
||||
records.append(record)
|
||||
for index, fact in enumerate(document.get("facts", [])):
|
||||
record = {"id": f"F{len(facts) + 1:04d}", "name": fact["name"],
|
||||
"provenance": provenance(path, f"/facts/{index}", "reproduction_record")}
|
||||
"provenance": provenance(path, f"/facts/{index}", "reproduction_record", fact)}
|
||||
if len(json_bytes(fact["value"])) > inline_limit:
|
||||
record["value_ref"] = {"source_ref": path, "json_pointer": f"/facts/{index}/value"}
|
||||
else:
|
||||
|
||||
@@ -11,6 +11,17 @@ def _literal(value) -> str:
|
||||
return text.replace("\r", "\\r").replace("\n", "<br>")
|
||||
|
||||
|
||||
def _origin_lines(origin: dict | None) -> list[str]:
|
||||
if origin is None:
|
||||
return []
|
||||
result = [f" Original source: {_literal(origin['source_ref'])} {_literal(origin['json_pointer'])}"]
|
||||
if "decoded_json_pointer" in origin:
|
||||
result.append(f" Decoded JSON pointer: {_literal(origin['decoded_json_pointer'])}")
|
||||
if "source_timestamp" in origin:
|
||||
result.append(f" Source timestamp (unchanged): {_literal(origin['source_timestamp'])}")
|
||||
return result
|
||||
|
||||
|
||||
def render_summary(case: dict) -> str:
|
||||
"""Pure presentation of the canonical case, with no additional interpretation."""
|
||||
validate(case, "case")
|
||||
@@ -22,6 +33,7 @@ def render_summary(case: dict) -> str:
|
||||
lines += [f"- Source: {_literal(report['source_ref'])}",
|
||||
f" Title: {_literal(report['title']) if report['title'] is not None else '(not supplied)'}",
|
||||
f" Summary: {_literal(report['summary']) if report['summary'] is not None else '(not supplied)'}"]
|
||||
lines.extend(_origin_lines(report.get("origin")))
|
||||
for label, records in (("Direct human observations", case["human_observations"]["observations"]),
|
||||
("Tester comments", case["human_observations"]["comments"]),
|
||||
("Tester hypotheses (supplied)", case["human_observations"]["tester_hypotheses"]),
|
||||
@@ -33,11 +45,13 @@ def render_summary(case: dict) -> str:
|
||||
f" Source: {_literal(source['source_ref'])} {_literal(source['json_pointer'])}",
|
||||
f" Author: {_literal(source['author']) if source['author'] is not None else '(not supplied)'}",
|
||||
f" Observed at: {_literal(source['observed_at']) if source['observed_at'] is not None else '(not supplied)'}"]
|
||||
lines.extend(_origin_lines(source.get("origin")))
|
||||
if "claim" in record:
|
||||
lines.append(f" Claim: {_literal(record['claim']['key'])} = {_literal(json.dumps(record['claim']['value'], sort_keys=True, ensure_ascii=False))}")
|
||||
lines += ["", f"Expected-behavior completeness: {case['expected_behavior']['completeness']}", "", "## Reproductions", ""]
|
||||
for record in case["reproduction"]["records"]:
|
||||
lines.append(f"- {_literal(record['id'])}: {_literal(record['source_ref'])}")
|
||||
lines.extend(_origin_lines(record.get("origin")))
|
||||
for step in record["steps"]:
|
||||
lines.append(f" Step: {_literal(step)}")
|
||||
if record["events_ref"]:
|
||||
@@ -49,6 +63,7 @@ def render_summary(case: dict) -> str:
|
||||
lines.append(f"- {_literal(entity['type'])} / {_literal(entity['id'])}; roles: {_literal(', '.join(entity['roles']))}")
|
||||
for source in entity["provenance"]:
|
||||
lines.append(f" Source: {_literal(source['source_ref'])} {_literal(source['json_pointer'])}")
|
||||
lines.extend(_origin_lines(source.get("origin")))
|
||||
lines += ["", "## Facts supplied by reproduction records", ""]
|
||||
for fact in case["runtime_facts"]["facts"]:
|
||||
source = fact["provenance"]
|
||||
@@ -59,6 +74,7 @@ def render_summary(case: dict) -> str:
|
||||
value = _literal(json.dumps(fact['value'], sort_keys=True, ensure_ascii=False))
|
||||
lines.append(f"- {_literal(fact['id'])}: {_literal(fact['name'])} = {value}")
|
||||
lines.append(f" Source: {_literal(source['source_ref'])} {_literal(source['json_pointer'])}")
|
||||
lines.extend(_origin_lines(source.get("origin")))
|
||||
for label, refs in (("Runtime data", case["runtime_facts"]["raw_refs"]), ("Database context", case["database_context"]["refs"]),
|
||||
("Source context", case["source_context"]["refs"]), ("Supplied research", case["research"]["refs"]),
|
||||
("Prior cases", case["inputs"]["prior_cases"]), ("Unclassified inputs", case["inputs"]["unclassified"])):
|
||||
|
||||
Reference in new issue
Block a user