feat: add scientific subtitle review workflow

This commit is contained in:
2026-08-25 14:22:30 +08:00
parent 555ed525f6
commit fb5a4017f6
11 changed files with 1054 additions and 14 deletions
@@ -177,6 +177,42 @@ def assess_delivery(download_manifest: Path) -> dict[str, Any]:
"missing": missing_batches,
}
execution = download.get("execution")
scientific_review_required = (
isinstance(execution, dict)
and execution.get("scientific_review_required") is True
)
scientific_review_report_path = subtitle_dir / "scientific-review" / "report.json"
scientific_review: dict[str, Any] | None = None
if scientific_review_required:
reviewed_translations = (
subtitle_dir
/ "scientific-review"
/ "reviewed-translations"
/ "translations.json"
)
missing_review = [
str(path)
for path in (scientific_review_report_path, reviewed_translations)
if not path.is_file()
]
if missing_review:
return {
"complete": False,
"stage": "scientific_review_required",
"job_dir": str(job_dir),
"missing": missing_review,
}
scientific_review = _read_json(scientific_review_report_path)
if scientific_review.get("status") != "complete":
raise DeliveryError("scientific review report is incomplete")
if scientific_review.get("human_expert_reviewed") is not False:
raise DeliveryError("scientific review report makes an invalid human-review claim")
if scientific_review.get("subtitle_manifest_sha256") != _sha256_file(
subtitle_manifest_path
):
raise DeliveryError("scientific review report is bound to a different subtitle manifest")
rendered_dir = subtitle_dir / "rendered"
required_rendered = [rendered_dir / "bilingual.ass", rendered_dir / "validation.json"]
missing_rendered = [str(path) for path in required_rendered if not path.is_file()]
@@ -187,6 +223,13 @@ def assess_delivery(download_manifest: Path) -> dict[str, Any]:
"job_dir": str(job_dir),
"missing": missing_rendered,
}
if scientific_review_required:
validation = _read_json(rendered_dir / "validation.json")
binding = validation.get("scientific_review")
if validation.get("translation_quality_reviewed") is not True or not isinstance(binding, dict):
raise DeliveryError("rendered subtitles did not use the scientific-review gate")
if binding.get("report_sha256") != _sha256_file(scientific_review_report_path):
raise DeliveryError("rendered subtitles use a stale scientific review report")
if deliverable == "bilingual-subs":
return complete("bilingual_subs_complete", rendered_dir=str(rendered_dir))