voidful commited on
Commit
a82f053
·
verified ·
1 Parent(s): a3caaa3

Add submission safety gate to reports

Browse files
Files changed (1) hide show
  1. src/space_service.py +30 -0
src/space_service.py CHANGED
@@ -477,6 +477,13 @@ def _build_report(result: RefCheckResult, reports: list[EntryReport]) -> str:
477
  "",
478
  ]
479
 
 
 
 
 
 
 
 
480
  if result.removed_details:
481
  lines.extend(["### Removed", ""])
482
  for key, title, reason in result.removed_details:
@@ -530,3 +537,26 @@ def _build_report(result: RefCheckResult, reports: list[EntryReport]) -> str:
530
  lines.append("")
531
 
532
  return "\n".join(lines).strip() + "\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  "",
478
  ]
479
 
480
+ gate_status, gate_reasons = _submission_safety_gate(result)
481
+ lines.extend(["### Submission Safety Gate", ""])
482
+ lines.append(f"- Status: **{gate_status}**")
483
+ for reason in gate_reasons:
484
+ lines.append(f"- {reason}")
485
+ lines.append("")
486
+
487
  if result.removed_details:
488
  lines.extend(["### Removed", ""])
489
  for key, title, reason in result.removed_details:
 
537
  lines.append("")
538
 
539
  return "\n".join(lines).strip() + "\n"
540
+
541
+
542
+ def _submission_safety_gate(result: RefCheckResult) -> tuple[str, list[str]]:
543
+ reasons = []
544
+ if result.review_details:
545
+ reasons.append(f"FAIL: {len(result.review_details)} reference(s) still need manual review.")
546
+ if result.issues:
547
+ reasons.append(f"FAIL: {result.issues} reference(s) still have strict verification issues.")
548
+ if result.not_found:
549
+ reasons.append(f"FAIL: {result.not_found} reference(s) could not be found in configured sources.")
550
+ if result.removed_details:
551
+ reasons.append(
552
+ f"FAIL: {len(result.removed_details)} reference(s) were removed; confirm the paper text no longer cites them."
553
+ )
554
+ if result.total_output and result.verified != result.total_output:
555
+ reasons.append(f"FAIL: only {result.verified}/{result.total_output} output reference(s) are strictly verified.")
556
+ if result.duplicate_details:
557
+ reasons.append(f"WARN: {len(result.duplicate_details)} duplicate title group(s) should be checked.")
558
+
559
+ failures = [reason for reason in reasons if reason.startswith("FAIL")]
560
+ if failures:
561
+ return "FAIL - do not submit yet", reasons
562
+ return "PASS - all output references are strictly verified", reasons or ["PASS: no unresolved reference risks detected."]