fix: close audited CAD delivery gate gaps
This commit is contained in:
@@ -200,12 +200,18 @@ def validate_source_report(report: dict[str, Any], expected_dxf_dir: Path | None
|
||||
gate = report.get("gate") or {}
|
||||
if not isinstance(gate, dict):
|
||||
gate = {}
|
||||
if gate.get("name") != "all_sources_converted_and_readable" or gate.get("status") != "PASS":
|
||||
errors.append(f"gate: all_sources_converted_and_readable must be PASS, got {gate.get('status')!r}")
|
||||
gate_status = gate.get("status")
|
||||
if gate.get("name") != "all_sources_converted_and_readable" or gate_status not in {"PASS", "WARN"}:
|
||||
errors.append(
|
||||
f"gate: all_sources_converted_and_readable must be PASS or a reasoned partial WARN, got {gate_status!r}"
|
||||
)
|
||||
if gate_status == "WARN" and not str(gate.get("partial_reason", "")).strip():
|
||||
errors.append("gate.partial_reason: WARN source reports require a non-empty partial reason")
|
||||
files = report.get("files")
|
||||
if not isinstance(files, list) or not files:
|
||||
errors.append("files: report contains no inspected DXF files")
|
||||
else:
|
||||
readable = 0
|
||||
for index, item in enumerate(files):
|
||||
if not isinstance(item, dict):
|
||||
errors.append(f"files[{index}]: expected an object")
|
||||
@@ -214,11 +220,15 @@ def validate_source_report(report: dict[str, Any], expected_dxf_dir: Path | None
|
||||
entity_count = int(item.get("modelspace_entities", 0) or 0)
|
||||
except (TypeError, ValueError):
|
||||
entity_count = 0
|
||||
if item.get("status") != "ok" or entity_count <= 0:
|
||||
if item.get("status") == "ok" and entity_count > 0:
|
||||
readable += 1
|
||||
elif gate_status == "PASS":
|
||||
errors.append(
|
||||
f"files[{index}]: {item.get('file', '?')} is not readable and nonempty "
|
||||
f"(status={item.get('status')!r}, entities={item.get('modelspace_entities')!r})"
|
||||
)
|
||||
if readable == 0:
|
||||
errors.append("files: partial reports still require at least one readable nonempty DXF")
|
||||
if expected_dxf_dir is not None:
|
||||
reported = Path(str(report.get("dxf_sanitized", "")))
|
||||
if not reported.is_absolute():
|
||||
|
||||
Reference in New Issue
Block a user