OUTPUT #737
PARÇA 3 / 4
TOPLAM: 132172 karakter | 2996 satır
BU PARÇA: 40000 karakter
     "verification": declared.get("verification"),
878-        }
879-        state_path.write_text(json.dumps(obj, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
880-
881-    question = None
882-    if obj.get("state") in {"repair_attempted", "verification_pending"}:
883-        question = (
--
887-            "verdict must be PASS or FAIL; verifier must be vision_analyze; "
888-            "post_repair_semantic_verified must be a boolean; copy repair_token exactly."
889-        )
890-        brief_path = work / "vision_qa_brief.json"
891-        brief = json.loads(brief_path.read_text(encoding="utf-8"))
892-        brief["repair_verification_contract"] = {
893-            "state": obj.get("state"),
894-            "artifact_sha256": artifact_sha,
895:            "contact_sheet_sha256": sheet_sha,
896-            "repair_token": obj.get("repair_token"),
897-            "required_post_repair_verdict": "vision_analyze PASS",
898-            "claim_fixed_before_verified": False,
899-        }
900-        brief_path.write_text(json.dumps(brief, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
901-    return obj, question
902-
903-def parse_manifest_arg(argv=None):
--
1262-        "creative_intent": m.get("creative_intent", {}),
1263-        "performance_plan": m.get("performance_plan", {}),
1264-        "directing_plan": m.get("directing_plan", {}),
1265-        "audio_intent": m.get("audio_intent", {}),
1266-    }, sort_keys=True, ensure_ascii=False))
1267-    qa_meta = work / ".qa.json"
1268-    cached_qa = False
1269-
1270:    if qa_meta.exists() and (work / "final_contact_sheet.jpg").exists():
1271-        try:
1272-            cached_qa = json.loads(
1273-                qa_meta.read_text(encoding="utf-8")
1274-            ).get("sig") == qa_sig
1275-        except Exception:
1276-            pass
1277-
1278-    if not cached_qa:
--
1303-        "creative_status": "PENDING_FINAL_SEMANTIC_VISION_QA",
1304-        "version": VERSION,
1305-        "cached_tts": cached_tts,
1306-        "cached_visual": cached_visual,
1307-        "cached_final": cached_final,
1308-        "cached_qa": cached_qa,
1309-        "duration": probe_duration(final),
1310-        "final": str(final),
1311:        "contact_sheet": str(work / "final_contact_sheet.jpg"),
1312-        "vision_qa_brief": str(work / "vision_qa_brief.json"),
1313-        "vision_question": repair_vision_question or final_vision_question,
1314-        "vision_question_mode": "repair_inline" if repair_vision_question else "canonical_sibling_file",
1315-        "caption_plan": str(work / "caption_plan.json"),
1316-        "caption_grouping_mode": caption_plan["grouping_mode"],
1317-        "timing_plan": str(work / "timing_plan.json"),
1318-        "video_md5": final_md5,
1319-        "repair_state": repair_state.get("state"),

/home/hermes/.hermes/skills/media/shorts-core/scripts/shorts_fast_pipeline.py.pre-proof-receipt-path-20260909
721-        FFMPEG, "-y", "-v", "error",
722-        "-i", str(final),
723-        "-vf",
724-        f"select='{select}',"
725-        "scale=360:640:flags=lanczos,"
726-        f"tile={cols}x{rows}:margin=0:padding=0",
727-        "-fps_mode", "vfr",
728-        "-frames:v", "1",
729:        str(work / "final_contact_sheet.jpg")
730-    ])
731:    (work / "semantic_contact_sheet.json").write_text(
732-        json.dumps({
733-            "times": times,
734-            "frames": frame_nums,
735-            "shot_count": len(shots),
736-            "samples": samples,
737-            "grid": [cols, rows]
738-        }, ensure_ascii=False, indent=2),
739-        encoding="utf-8"
--
822-        for chunk in iter(lambda: f.read(1024 * 1024), b""):
823-            h.update(chunk)
824-    return h.hexdigest()
825-
826-
827-def prepare_repair_state(manifest, work, final):
828-    """Bind repair claims to the exact artifact and post-repair semantic QA."""
829-    work, final = Path(work), Path(final)
830:    sheet = work / "final_contact_sheet.jpg"
831-    declared = manifest.get("repair_state")
832-    declared = declared if isinstance(declared, dict) else {"state": "not_attempted"}
833-    state = str(declared.get("state") or "not_attempted")
834-    artifact_sha = sha256_file(final)
835-    sheet_sha = sha256_file(sheet)
836-    state_path = work / "repair_state.json"
837-    existing = {}
838-    if state_path.exists():
--
841-        except Exception:
842-            existing = {}
843-
844-    # A runtime-issued verified state remains valid only for byte-identical
845-    # artifact and semantic sheet. Any visual change returns to pending.
846-    if (
847-        existing.get("state") == "verified"
848-        and existing.get("artifact_sha256") == artifact_sha
849:        and existing.get("contact_sheet_sha256") == sheet_sha
850-    ):
851-        obj = existing
852-    else:
853-        if state == "verified":
854-            verification = declared.get("verification") or {}
855-            if (
856-                verification.get("verifier") != "vision_analyze"
857-                or verification.get("verdict") != "PASS"
858-                or verification.get("artifact_sha256") != artifact_sha
859-            ):
860-                raise SystemExit("REPAIR_VERIFICATION_INVALID_OR_STALE")
861-        token = (
862-            existing.get("repair_token")
863-            if existing.get("artifact_sha256") == artifact_sha
864:            and existing.get("contact_sheet_sha256") == sheet_sha
865-            else secrets.token_hex(24)
866-        )
867-        obj = {
868-            "state": state,
869-            "repair_attempted": state != "not_attempted",
870-            "verification_pending": state in {"repair_attempted", "verification_pending"},
871-            "claim_fixed_allowed": state == "verified",
872-            "artifact": str(final.resolve()),
873-            "artifact_sha256": artifact_sha,
874:            "contact_sheet": str(sheet.resolve()),
875:            "contact_sheet_sha256": sheet_sha,
876-            "repair_token": token,
877-            "verification": declared.get("verification"),
878-        }
879-        state_path.write_text(json.dumps(obj, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
880-
881-    question = None
882-    if obj.get("state") in {"repair_attempted", "verification_pending"}:
883-        question = (
--
887-            "verdict must be PASS or FAIL; verifier must be vision_analyze; "
888-            "post_repair_semantic_verified must be a boolean; copy repair_token exactly."
889-        )
890-        brief_path = work / "vision_qa_brief.json"
891-        brief = json.loads(brief_path.read_text(encoding="utf-8"))
892-        brief["repair_verification_contract"] = {
893-            "state": obj.get("state"),
894-            "artifact_sha256": artifact_sha,
895:            "contact_sheet_sha256": sheet_sha,
896-            "repair_token": obj.get("repair_token"),
897-            "required_post_repair_verdict": "vision_analyze PASS",
898-            "claim_fixed_before_verified": False,
899-        }
900-        brief_path.write_text(json.dumps(brief, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
901-    return obj, question
902-
903-def parse_manifest_arg(argv=None):
--
1251-        "creative_intent": m.get("creative_intent", {}),
1252-        "performance_plan": m.get("performance_plan", {}),
1253-        "directing_plan": m.get("directing_plan", {}),
1254-        "audio_intent": m.get("audio_intent", {}),
1255-    }, sort_keys=True, ensure_ascii=False))
1256-    qa_meta = work / ".qa.json"
1257-    cached_qa = False
1258-
1259:    if qa_meta.exists() and (work / "final_contact_sheet.jpg").exists():
1260-        try:
1261-            cached_qa = json.loads(
1262-                qa_meta.read_text(encoding="utf-8")
1263-            ).get("sig") == qa_sig
1264-        except Exception:
1265-            pass
1266-
1267-    if not cached_qa:
--
1292-        "creative_status": "PENDING_FINAL_SEMANTIC_VISION_QA",
1293-        "version": VERSION,
1294-        "cached_tts": cached_tts,
1295-        "cached_visual": cached_visual,
1296-        "cached_final": cached_final,
1297-        "cached_qa": cached_qa,
1298-        "duration": probe_duration(final),
1299-        "final": str(final),
1300:        "contact_sheet": str(work / "final_contact_sheet.jpg"),
1301-        "vision_qa_brief": str(work / "vision_qa_brief.json"),
1302-        "vision_question": repair_vision_question or final_vision_question,
1303-        "vision_question_mode": "repair_inline" if repair_vision_question else "canonical_sibling_file",
1304-        "caption_plan": str(work / "caption_plan.json"),
1305-        "caption_grouping_mode": caption_plan["grouping_mode"],
1306-        "timing_plan": str(work / "timing_plan.json"),
1307-        "video_md5": final_md5,
1308-        "repair_state": repair_state.get("state"),

/home/hermes/.hermes/skills/media/shorts-core/scripts/production_guardrails.py.bak-pre-hook-payoff-fix-20260907
584-
585-    if r.get("pass") is not True:
586-        errors.append("PROOF_GATE_INVALID: receipt does not contain pass=true")
587-    if r.get("verifier") != "vision_analyze":
588-        errors.append("PROOF_GATE_INVALID: verifier must be vision_analyze")
589-    if r.get("receipt_source") != "shorts-production-guard/post_tool_call":
590-        errors.append("PROOF_GATE_INVALID: receipt was not issued by the vision post-tool hook")
591-
592:    sheet = r.get("contact_sheet")
593:    sheet_hash = r.get("contact_sheet_sha256")
594-    if not isinstance(sheet, str) or not Path(sheet).exists():
595-        errors.append("PROOF_GATE_INVALID: accepted proof contact sheet is missing")
596-    elif not isinstance(sheet_hash, str) or sha_file(sheet) != sheet_hash:
597-        errors.append("PROOF_GATE_STALE: accepted proof contact sheet changed after Vision verification")
598-
599-    if r.get("fingerprint") != proof_fingerprint(data):
600-        errors.append(
601-            "PROOF_GATE_STALE: creative intent, proof candidates, or proof source changed after acceptance"
--
760-        })
761-
762-    missing_cover = sorted(required_cover - covered)
763-    if missing_cover:
764-        hard.append(
765-            "proof_gate candidates do not cover required targets: " + ", ".join(missing_cover)
766-        )
767-
768:    sheet = wd / "proof_contact_sheet.jpg"
769-    if proof_frames:
770-        cols = 5
771-        rows = max(1, (len(proof_frames) + cols - 1) // cols)
772-        run([
773-            FFMPEG, "-y", "-v", "error",
774-            "-framerate", "1",
775-            "-i", str(wd / "proof_frame_%03d.jpg"),
776-            "-vf", f"tile={cols}x{rows}:margin=0:padding=0",
--
812-    passed = not hard and bool(valid) and sheet.exists()
813-
814-    pending_path = wd / "proof_pending.json"
815-    if passed:
816-        pending = {
817-            "fingerprint": fingerprint,
818-            "proof_token": proof_token,
819-            "manifest": str(mp),
820:            "contact_sheet": str(sheet.resolve()),
821:            "contact_sheet_sha256": sha_file(sheet),
822-            "receipt": str(receipt),
823-            "created_at": time.time(),
824-        }
825-        pending_path.write_text(
826-            json.dumps(pending, ensure_ascii=False, indent=2) + "\n",
827-            encoding="utf-8"
828-        )
829-    else:
--
841-        "notes must be a short string. "
842-        "proof_token must be copied exactly."
843-    )
844-
845-    return {
846-        "pass": passed,
847-        "version": VERSION,
848-        "fingerprint": fingerprint,
849:        "proof_contact_sheet": str(sheet) if sheet.exists() else None,
850-        "proof_qa_brief": str(brief_path),
851-        "proof_pending": str(pending_path) if passed else None,
852-        "vision_question": vision_question if passed else None,
853-        "valid_candidates": len(valid),
854-        "hard_failures": hard,
855-        "next": (
856:            "Call vision_analyze on proof_contact_sheet using vision_question. "
857-            "A PASS receipt is issued automatically by the shorts-production-guard post_tool_call hook. "
858-            "Never create a verdict or proof receipt manually."
859-            if passed else "Repair proof candidates before any TTS/render work."
860-        )
861-    }
862-
863-
864-def proof_accept(*args, **kwargs):

/home/hermes/.hermes/skills/media/shorts-core/scripts/test_shorts_fast_pipeline.py.pre-case-pipe-regressions-20260909-153922
161-                final_target, "Return strict final JSON.", {"payoff": "shown"}
162-            )
163-            self.assertEqual(final_ref, f"@file:{final_target.resolve()}")
164-            self.assertIn('"payoff": "shown"', final_target.read_text(encoding="utf-8"))
165-
166-    def test_valid_receipt_short_circuits_unchanged_proof_without_new_question(self):
167-        with tempfile.TemporaryDirectory() as td:
168-            root = Path(td)
169:            sheet = root / "proof_gate" / "proof_contact_sheet.jpg"
170-            sheet.parent.mkdir()
171-            sheet.write_bytes(b"accepted evidence")
172-            receipt = sheet.parent / "proof_receipt.json"
173-            manifest_path = root / "manifest.json"
174-            manifest = {
175-                "creative_intent": {
176-                    "promise": "visible promise",
177-                    "primary_visual_proof": "visible proof",
--
192-                "shots": [],
193-            }
194-            manifest_path.write_text(json.dumps(manifest), encoding="utf-8")
195-            receipt.write_text(json.dumps({
196-                "pass": True,
197-                "receipt_source": "shorts-production-guard/post_tool_call",
198-                "verifier": "vision_analyze",
199-                "fingerprint": guard.proof_fingerprint(manifest),
200:                "contact_sheet": str(sheet),
201:                "contact_sheet_sha256": guard.sha_file(sheet),
202-            }), encoding="utf-8")
203-
204-            result = guard.proof_check(manifest_path, sheet.parent)
205-
206-            self.assertTrue(result["pass"])
207-            self.assertFalse(result["vision_required"])
208-            self.assertEqual(result["proof_status"], "already_accepted")
209-            self.assertIsNone(result["vision_question"])

/home/hermes/.hermes/skills/media/shorts-core/scripts/shorts_fast_pipeline.py.bak-freeze-semantics-20260907-013423
454-        FFMPEG, "-y", "-v", "error",
455-        "-i", str(final),
456-        "-vf",
457-        f"select='{select}',"
458-        "scale=360:640:flags=lanczos,"
459-        f"tile={cols}x{rows}:margin=0:padding=0",
460-        "-fps_mode", "vfr",
461-        "-frames:v", "1",
462:        str(work / "final_contact_sheet.jpg")
463-    ])
464:    (work / "semantic_contact_sheet.json").write_text(
465-        json.dumps({
466-            "times": times,
467-            "frames": frame_nums,
468-            "shot_count": len(shots),
469-            "grid": [cols, rows]
470-        }, ensure_ascii=False, indent=2),
471-        encoding="utf-8"
472-    )
--
792-    qa_sig = stamp([final], "deterministic-final-qa-v4|" + json.dumps({
793-        "shots": shots,
794-        "creative_intent": m.get("creative_intent", {}),
795-        "performance_plan": m.get("performance_plan", {}),
796-    }, sort_keys=True, ensure_ascii=False))
797-    qa_meta = work / ".qa.json"
798-    cached_qa = False
799-
800:    if qa_meta.exists() and (work / "final_contact_sheet.jpg").exists():
801-        try:
802-            cached_qa = json.loads(
803-                qa_meta.read_text(encoding="utf-8")
804-            ).get("sig") == qa_sig
805-        except Exception:
806-            pass
807-
808-    if not cached_qa:
--
816-        "pass": True,
817-        "version": VERSION,
818-        "cached_tts": cached_tts,
819-        "cached_visual": cached_visual,
820-        "cached_final": cached_final,
821-        "cached_qa": cached_qa,
822-        "duration": probe_duration(final),
823-        "final": str(final),
824:        "contact_sheet": str(work / "final_contact_sheet.jpg"),
825-        "vision_qa_brief": str(work / "vision_qa_brief.json"),
826-        "video_md5": final_md5,
827-    }
828-    (work / "pipeline_result.json").write_text(
829-        json.dumps(result, ensure_ascii=False, indent=2),
830-        encoding="utf-8"
831-    )
832-    print(json.dumps(result, ensure_ascii=False))

/home/hermes/.hermes/skills/media/shorts-core/scripts/production_guardrails.py.bak-proof-duration-20260907-015132
553-
554-    if r.get("pass") is not True:
555-        errors.append("PROOF_GATE_INVALID: receipt does not contain pass=true")
556-    if r.get("verifier") != "vision_analyze":
557-        errors.append("PROOF_GATE_INVALID: verifier must be vision_analyze")
558-    if r.get("receipt_source") != "shorts-production-guard/post_tool_call":
559-        errors.append("PROOF_GATE_INVALID: receipt was not issued by the vision post-tool hook")
560-
561:    sheet = r.get("contact_sheet")
562:    sheet_hash = r.get("contact_sheet_sha256")
563-    if not isinstance(sheet, str) or not Path(sheet).exists():
564-        errors.append("PROOF_GATE_INVALID: accepted proof contact sheet is missing")
565-    elif not isinstance(sheet_hash, str) or sha_file(sheet) != sheet_hash:
566-        errors.append("PROOF_GATE_STALE: accepted proof contact sheet changed after Vision verification")
567-
568-    if r.get("fingerprint") != proof_fingerprint(data):
569-        errors.append(
570-            "PROOF_GATE_STALE: creative intent, proof candidates, or proof source changed after acceptance"
--
723-        })
724-
725-    missing_cover = sorted(required_cover - covered)
726-    if missing_cover:
727-        hard.append(
728-            "proof_gate candidates do not cover required targets: " + ", ".join(missing_cover)
729-        )
730-
731:    sheet = wd / "proof_contact_sheet.jpg"
732-    if proof_frames:
733-        cols = 5
734-        rows = max(1, (len(proof_frames) + cols - 1) // cols)
735-        run([
736-            FFMPEG, "-y", "-v", "error",
737-            "-framerate", "1",
738-            "-i", str(wd / "proof_frame_%03d.jpg"),
739-            "-vf", f"tile={cols}x{rows}:margin=0:padding=0",
--
775-    passed = not hard and bool(valid) and sheet.exists()
776-
777-    pending_path = wd / "proof_pending.json"
778-    if passed:
779-        pending = {
780-            "fingerprint": fingerprint,
781-            "proof_token": proof_token,
782-            "manifest": str(mp),
783:            "contact_sheet": str(sheet.resolve()),
784:            "contact_sheet_sha256": sha_file(sheet),
785-            "receipt": str(receipt),
786-            "created_at": time.time(),
787-        }
788-        pending_path.write_text(
789-            json.dumps(pending, ensure_ascii=False, indent=2) + "\n",
790-            encoding="utf-8"
791-        )
792-    else:
--
804-        "notes must be a short string. "
805-        "proof_token must be copied exactly."
806-    )
807-
808-    return {
809-        "pass": passed,
810-        "version": VERSION,
811-        "fingerprint": fingerprint,
812:        "proof_contact_sheet": str(sheet) if sheet.exists() else None,
813-        "proof_qa_brief": str(brief_path),
814-        "proof_pending": str(pending_path) if passed else None,
815-        "vision_question": vision_question if passed else None,
816-        "valid_candidates": len(valid),
817-        "hard_failures": hard,
818-        "next": (
819:            "Call vision_analyze on proof_contact_sheet using vision_question. "
820-            "A PASS receipt is issued automatically by the shorts-production-guard post_tool_call hook. "
821-            "Never create a verdict or proof receipt manually."
822-            if passed else "Repair proof candidates before any TTS/render work."
823-        )
824-    }
825-
826-
827-def proof_accept(*args, **kwargs):

/home/hermes/.hermes/skills/media/shorts-core/scripts/production_guardrails.py.bak-p0-robustness-20260907-203544
773-
774-    if r.get("pass") is not True:
775-        errors.append("PROOF_GATE_INVALID: receipt does not contain pass=true")
776-    if r.get("verifier") != "vision_analyze":
777-        errors.append("PROOF_GATE_INVALID: verifier must be vision_analyze")
778-    if r.get("receipt_source") != "shorts-production-guard/post_tool_call":
779-        errors.append("PROOF_GATE_INVALID: receipt was not issued by the vision post-tool hook")
780-
781:    sheet = r.get("contact_sheet")
782:    sheet_hash = r.get("contact_sheet_sha256")
783-    if not isinstance(sheet, str) or not Path(sheet).exists():
784-        errors.append("PROOF_GATE_INVALID: accepted proof contact sheet is missing")
785-    elif not isinstance(sheet_hash, str) or sha_file(sheet) != sheet_hash:
786-        errors.append("PROOF_GATE_STALE: accepted proof contact sheet changed after Vision verification")
787-
788-    if r.get("fingerprint") != proof_fingerprint(data):
789-        errors.append(
790-            "PROOF_GATE_STALE: creative intent, proof candidates, or proof source changed after acceptance"
--
949-        })
950-
951-    missing_cover = sorted(required_cover - covered)
952-    if missing_cover:
953-        hard.append(
954-            "proof_gate candidates do not cover required targets: " + ", ".join(missing_cover)
955-        )
956-
957:    sheet = wd / "proof_contact_sheet.jpg"
958-    if proof_frames:
959-        cols = 5
960-        rows = max(1, (len(proof_frames) + cols - 1) // cols)
961-        run([
962-            FFMPEG, "-y", "-v", "error",
963-            "-framerate", "1",
964-            "-i", str(wd / "proof_frame_%03d.jpg"),
965-            "-vf", f"tile={cols}x{rows}:margin=0:padding=0",
--
1001-    passed = not hard and bool(valid) and sheet.exists()
1002-
1003-    pending_path = wd / "proof_pending.json"
1004-    if passed:
1005-        pending = {
1006-            "fingerprint": fingerprint,
1007-            "proof_token": proof_token,
1008-            "manifest": str(mp),
1009:            "contact_sheet": str(sheet.resolve()),
1010:            "contact_sheet_sha256": sha_file(sheet),
1011-            "receipt": str(receipt),
1012-            "created_at": time.time(),
1013-        }
1014-        pending_path.write_text(
1015-            json.dumps(pending, ensure_ascii=False, indent=2) + "\n",
1016-            encoding="utf-8"
1017-        )
1018-    else:
--
1030-        "notes must be a short string. "
1031-        "proof_token must be copied exactly."
1032-    )
1033-
1034-    return {
1035-        "pass": passed,
1036-        "version": VERSION,
1037-        "fingerprint": fingerprint,
1038:        "proof_contact_sheet": str(sheet) if sheet.exists() else None,
1039-        "proof_qa_brief": str(brief_path),
1040-        "proof_pending": str(pending_path) if passed else None,
1041-        "vision_question": vision_question if passed else None,
1042-        "valid_candidates": len(valid),
1043-        "hard_failures": hard,
1044-        "next": (
1045:            "Call vision_analyze on proof_contact_sheet using vision_question. "
1046-            "A PASS receipt is issued automatically by the shorts-production-guard post_tool_call hook. "
1047-            "Never create a verdict or proof receipt manually."
1048-            if passed else "Repair proof candidates before any TTS/render work."
1049-        )
1050-    }
1051-
1052-
1053-def proof_accept(*args, **kwargs):

/home/hermes/.hermes/skills/media/shorts-core/scripts/production_guardrails.py.bak-pre-source-duration-gate-20260909
1001-
1002-    if r.get("pass") is not True:
1003-        errors.append("PROOF_GATE_INVALID: receipt does not contain pass=true")
1004-    if r.get("verifier") != "vision_analyze":
1005-        errors.append("PROOF_GATE_INVALID: verifier must be vision_analyze")
1006-    if r.get("receipt_source") != "shorts-production-guard/post_tool_call":
1007-        errors.append("PROOF_GATE_INVALID: receipt was not issued by the vision post-tool hook")
1008-
1009:    sheet = r.get("contact_sheet")
1010:    sheet_hash = r.get("contact_sheet_sha256")
1011-    if not isinstance(sheet, str) or not Path(sheet).exists():
1012-        errors.append("PROOF_GATE_INVALID: accepted proof contact sheet is missing")
1013-    elif not isinstance(sheet_hash, str) or sha_file(sheet) != sheet_hash:
1014-        errors.append("PROOF_GATE_STALE: accepted proof contact sheet changed after Vision verification")
1015-
1016-    if r.get("fingerprint") != proof_fingerprint(data):
1017-        errors.append(
1018-            "PROOF_GATE_STALE: creative intent, proof candidates, or proof source changed after acceptance"
--
1056-    # A runtime-issued receipt already binds the proof fingerprint, evidence
1057-    # sheet hash, casting contract, and source identities. If all of that is
1058-    # still valid, regenerating frames/question/pending state cannot add proof;
1059-    # it only invites another Vision and main-agent loop.
1060-    receipt_errors = validate_proof_receipt(data, mp)
1061-    if not hard and not receipt_errors:
1062-        receipt_path = proof_receipt_path(data, mp)
1063-        receipt = json.loads(receipt_path.read_text(encoding="utf-8"))
1064:        sheet = Path(receipt["contact_sheet"]).resolve()
1065-        return {
1066-            "pass": True,
1067-            "version": VERSION,
1068-            "fingerprint": proof_fingerprint(data),
1069-            "proof_status": "already_accepted",
1070-            "vision_required": False,
1071:            "proof_contact_sheet": str(sheet),
1072-            "proof_qa_brief": None,
1073-            "proof_pending": None,
1074-            "vision_question": None,
1075-            "valid_candidates": len(gate.get("candidates") or []),
1076-            "valid_casting_roles": len(casting_review_entries(data)),
1077-            "hard_failures": [],
1078-            "warnings": [],
1079-            "next": "Proof receipt is current; proceed without another proof Vision call.",
--
1264-        casting_valid.append(reviewed)
1265-
1266-    missing_cover = sorted(required_cover - covered)
1267-    if missing_cover:
1268-        hard.append(
1269-            "proof_gate candidates do not cover required targets: " + ", ".join(missing_cover)
1270-        )
1271-
1272:    sheet = wd / "proof_contact_sheet.jpg"
1273-    if proof_frames:
1274-        cols = 5
1275-        rows = max(1, (len(proof_frames) + cols - 1) // cols)
1276-        run([
1277-            FFMPEG, "-y", "-v", "error",
1278-            "-framerate", "1",
1279-            "-i", str(wd / "proof_frame_%03d.jpg"),
1280-            "-vf", f"tile={cols}x{rows}:margin=0:padding=0",
--
1323-    passed = not hard and bool(valid) and sheet.exists()
1324-
1325-    pending_path = wd / "proof_pending.json"
1326-    if passed:
1327-        pending = {
1328-            "fingerprint": fingerprint,
1329-            "proof_token": proof_token,
1330-            "manifest": str(mp),
1331:            "contact_sheet": str(sheet.resolve()),
1332:            "contact_sheet_sha256": sha_file(sheet),
1333-            "receipt": str(receipt),
1334-            "created_at": time.time(),
1335-        }
1336-        pending_path.write_text(
1337-            json.dumps(pending, ensure_ascii=False, indent=2) + "\n",
1338-            encoding="utf-8"
1339-        )
1340-    else:
--
1358-    )
1359-
1360-    return {
1361-        "pass": passed,
1362-        "version": VERSION,
1363-        "fingerprint": fingerprint,
1364-        "proof_status": "vision_required" if passed else "invalid",
1365-        "vision_required": bool(passed),
1366:        "proof_contact_sheet": str(sheet) if sheet.exists() else None,
1367-        "proof_qa_brief": str(brief_path),
1368-        "proof_pending": str(pending_path) if passed else None,
1369-        "vision_question": vision_question if passed else None,
1370-        "valid_candidates": len(valid),
1371-        "valid_casting_roles": len(casting_valid),
1372-        "hard_failures": hard,
1373-        "warnings": warnings,
1374-        "next": (
1375:            "Call vision_analyze on proof_contact_sheet using vision_question. "
1376-            "A PASS receipt is issued automatically by the shorts-production-guard post_tool_call hook. "
1377-            "Never create a verdict or proof receipt manually."
1378-            if passed else "Repair proof candidates before any TTS/render work."
1379-        )
1380-    }
1381-
1382-
1383-def proof_accept(*args, **kwargs):

/home/hermes/.hermes/skills/media/shorts-core/scripts/shorts_fast_pipeline.py.bak-p0-repair-truth-20260907-203022
697-        FFMPEG, "-y", "-v", "error",
698-        "-i", str(final),
699-        "-vf",
700-        f"select='{select}',"
701-        "scale=360:640:flags=lanczos,"
702-        f"tile={cols}x{rows}:margin=0:padding=0",
703-        "-fps_mode", "vfr",
704-        "-frames:v", "1",
705:        str(work / "final_contact_sheet.jpg")
706-    ])
707:    (work / "semantic_contact_sheet.json").write_text(
708-        json.dumps({
709-            "times": times,
710-            "frames": frame_nums,
711-            "shot_count": len(shots),
712-            "samples": samples,
713-            "grid": [cols, rows]
714-        }, ensure_ascii=False, indent=2),
715-        encoding="utf-8"
--
1111-        "creative_intent": m.get("creative_intent", {}),
1112-        "performance_plan": m.get("performance_plan", {}),
1113-        "directing_plan": m.get("directing_plan", {}),
1114-        "audio_intent": m.get("audio_intent", {}),
1115-    }, sort_keys=True, ensure_ascii=False))
1116-    qa_meta = work / ".qa.json"
1117-    cached_qa = False
1118-
1119:    if qa_meta.exists() and (work / "final_contact_sheet.jpg").exists():
1120-        try:
1121-            cached_qa = json.loads(
1122-                qa_meta.read_text(encoding="utf-8")
1123-            ).get("sig") == qa_sig
1124-        except Exception:
1125-            pass
1126-
1127-    if not cached_qa:
--
1138-        "creative_status": "PENDING_FINAL_SEMANTIC_VISION_QA",
1139-        "version": VERSION,
1140-        "cached_tts": cached_tts,
1141-        "cached_visual": cached_visual,
1142-        "cached_final": cached_final,
1143-        "cached_qa": cached_qa,
1144-        "duration": probe_duration(final),
1145-        "final": str(final),
1146:        "contact_sheet": str(work / "final_contact_sheet.jpg"),
1147-        "vision_qa_brief": str(work / "vision_qa_brief.json"),
1148-        "caption_plan": str(work / "caption_plan.json"),
1149-        "caption_grouping_mode": caption_plan["grouping_mode"],
1150-        "timing_plan": str(work / "timing_plan.json"),
1151-        "video_md5": final_md5,
1152-    }
1153-    (work / "pipeline_result.json").write_text(
1154-        json.dumps(result, ensure_ascii=False, indent=2),

/home/hermes/.hermes/skills/media/shorts-core/scripts/production_guardrails.py.pre-receipt-selfheal-20260909
1030-
1031-    if r.get("pass") is not True:
1032-        errors.append("PROOF_GATE_INVALID: receipt does not contain pass=true")
1033-    if r.get("verifier") != "vision_analyze":
1034-        errors.append("PROOF_GATE_INVALID: verifier must be vision_analyze")
1035-    if r.get("receipt_source") != "shorts-production-guard/post_tool_call":
1036-        errors.append("PROOF_GATE_INVALID: receipt was not issued by the vision post-tool hook")
1037-
1038:    sheet = r.get("contact_sheet")
1039:    sheet_hash = r.get("contact_sheet_sha256")
1040-    if not isinstance(sheet, str) or not Path(sheet).exists():
1041-        errors.append("PROOF_GATE_INVALID: accepted proof contact sheet is missing")
1042-    elif not isinstance(sheet_hash, str) or sha_file(sheet) != sheet_hash:
1043-        errors.append("PROOF_GATE_STALE: accepted proof contact sheet changed after Vision verification")
1044-
1045-    if r.get("fingerprint") != proof_fingerprint(data):
1046-        errors.append(
1047-            "PROOF_GATE_STALE: creative intent, proof candidates, or proof source changed after acceptance"
--
1085-    # A runtime-issued receipt already binds the proof fingerprint, evidence
1086-    # sheet hash, casting contract, and source identities. If all of that is
1087-    # still valid, regenerating frames/question/pending state cannot add proof;
1088-    # it only invites another Vision and main-agent loop.
1089-    receipt_errors = validate_proof_receipt(data, mp)
1090-    if not hard and not receipt_errors:
1091-        receipt_path = proof_receipt_path(data, mp)
1092-        receipt = json.loads(receipt_path.read_text(encoding="utf-8"))
1093:        sheet = Path(receipt["contact_sheet"]).resolve()
1094-        return {
1095-            "pass": True,
1096-            "version": VERSION,
1097-            "fingerprint": proof_fingerprint(data),
1098-            "proof_status": "already_accepted",
1099-            "vision_required": False,
1100:            "proof_contact_sheet": str(sheet),
1101-            "proof_qa_brief": None,
1102-            "proof_pending": None,
1103-            "vision_question": None,
1104-            "valid_candidates": len(gate.get("candidates") or []),
1105-            "valid_casting_roles": len(casting_review_entries(data)),
1106-            "hard_failures": [],
1107-            "warnings": [],
1108-            "next": "Proof receipt is current; proceed without another proof Vision call.",
--
1302-        casting_valid.append(reviewed)
1303-
1304-    missing_cover = sorted(required_cover - covered)
1305-    if missing_cover:
1306-        hard.append(
1307-            "proof_gate candidates do not cover required targets: " + ", ".join(missing_cover)
1308-        )
1309-
1310:    sheet = wd / "proof_contact_sheet.jpg"
1311-    if proof_frames:
1312-        cols = 5
1313-        rows = max(1, (len(proof_frames) + cols - 1) // cols)
1314-        run([
1315-            FFMPEG, "-y", "-v", "error",
1316-            "-framerate", "1",
1317-            "-i", str(wd / "proof_frame_%03d.jpg"),
1318-            "-vf", f"tile={cols}x{rows}:margin=0:padding=0",
--
1361-    passed = not hard and bool(valid) and sheet.exists()
1362-
1363-    pending_path = wd / "proof_pending.json"
1364-    if passed:
1365-        pending = {
1366-            "fingerprint": fingerprint,
1367-            "proof_token": proof_token,
1368-            "manifest": str(mp),
1369:            "contact_sheet": str(sheet.resolve()),
1370:            "contact_sheet_sha256": sha_file(sheet),
1371-            "receipt": str(receipt),
1372-            "created_at": time.time(),
1373-        }
1374-        pending_path.write_text(
1375-            json.dumps(pending, ensure_ascii=False, indent=2) + "\n",
1376-            encoding="utf-8"
1377-        )
1378-    else:
--
1396-    )
1397-
1398-    return {
1399-        "pass": passed,
1400-        "version": VERSION,
1401-        "fingerprint": fingerprint,
1402-        "proof_status": "vision_required" if passed else "invalid",
1403-        "vision_required": bool(passed),
1404:        "proof_contact_sheet": str(sheet) if sheet.exists() else None,
1405-        "proof_qa_brief": str(brief_path),
1406-        "proof_pending": str(pending_path) if passed else None,
1407-        "vision_question": vision_question if passed else None,
1408-        "valid_candidates": len(valid),
1409-        "valid_casting_roles": len(casting_valid),
1410-        "hard_failures": hard,
1411-        "warnings": warnings,
1412-        "next": (
1413:            "Call vision_analyze on proof_contact_sheet using vision_question. "
1414-            "A PASS receipt is issued automatically by the shorts-production-guard post_tool_call hook. "
1415-            "Never create a verdict or proof receipt manually."
1416-            if passed else "Repair proof candidates before any TTS/render work."
1417-        )
1418-    }
1419-
1420-
1421-def proof_accept(*args, **kwargs):

/home/hermes/.hermes/skills/media/shorts-core/scripts/shorts_fast_pipeline.py.pre-render-no-tts-regeneration-20260909-163310
721-        FFMPEG, "-y", "-v", "error",
722-        "-i", str(final),
723-        "-vf",
724-        f"select='{select}',"
725-        "scale=360:640:flags=lanczos,"
726-        f"tile={cols}x{rows}:margin=0:padding=0",
727-        "-fps_mode", "vfr",
728-        "-frames:v", "1",
729:        str(work / "final_contact_sheet.jpg")
730-    ])
731:    (work / "semantic_contact_sheet.json").write_text(
732-        json.dumps({
733-            "times": times,
734-            "frames": frame_nums,
735-            "shot_count": len(shots),
736-            "samples": samples,
737-            "grid": [cols, rows]
738-        }, ensure_ascii=False, indent=2),
739-        encoding="utf-8"
--
822-        for chunk in iter(lambda: f.read(1024 * 1024), b""):
823-            h.update(chunk)
824-    return h.hexdigest()
825-
826-
827-def prepare_repair_state(manifest, work, final):
828-    """Bind repair claims to the exact artifact and post-repair semantic QA."""
829-    work, final = Path(work), Path(final)
830:    sheet = work / "final_contact_sheet.jpg"
831-    declared = manifest.get("repair_state")
832-    declared = declared if isinstance(declared, dict) else {"state": "not_attempted"}
833-    state = str(declared.get("state") or "not_attempted")
834-    artifact_sha = sha256_file(final)
835-    sheet_sha = sha256_file(sheet)
836-    state_path = work / "repair_state.json"
837-    existing = {}
838-    if state_path.exists():
--
841-        except Exception:
842-            existing = {}
843-
844-    # A runtime-issued verified state remains valid only for byte-identical
845-    # artifact and semantic sheet. Any visual change returns to pending.
846-    if (
847-        existing.get("state") == "verified"
848-        and existing.get("artifact_sha256") == artifact_sha
849:        and existing.get("contact_sheet_sha256") == sheet_sha
850-    ):
851-        obj = existing
852-    else:
853-        if state == "verified":
854-            verification = declared.get("verification") or {}
855-            if (
856-                verification.get("verifier") != "vision_analyze"
857-                or verification.get("verdict") != "PASS"
858-                or verification.get("artifact_sha256") != artifact_sha
859-            ):
860-                raise SystemExit("REPAIR_VERIFICATION_INVALID_OR_STALE")
861-        token = (
862-            existing.get("repair_token")
863-            if existing.get("artifact_sha256") == artifact_sha
864:            and existing.get("contact_sheet_sha256") == sheet_sha
865-            else secrets.token_hex(24)
866-        )
867-        obj = {
868-            "state": state,
869-            "repair_attempted": state != "not_attempted",
870-            "verification_pending": state in {"repair_attempted", "verification_pending"},
871-            "claim_fixed_allowed": state == "verified",
872-            "artifact": str(final.resolve()),
873-            "artifact_sha256": artifact_sha,
874:            "contact_sh