OUTPUT #698 | 6250 karakter | 126 satır

========== YENİ KOMUT | 17.09.2026 12:16:51 ==========

        return _block(
            "Shorts production guard: direct TTS/final assembly outside the canonical pipeline "
            "is blocked during normal production. Use shorts_fast_pipeline.py. If proof Vision "
            "cannot issue a valid receipt, stop with QA_UNAVAILABLE; do not build a fallback final."
        )

    # Explicitly requested alternate/code-driven workflows remain available.
    if tool_name == "skill_view" and not alternate_method:
        name = str(args.get("name") or "")
        if name and name != "shorts-core":
            return _block(
                "Shorts production guard: shorts-core is the sole production authority "
                "for this footage-based Shorts/Reels turn. Do not load another production, "
                "debug, installation, or QA skill. Continue with shorts-core and the canonical pipeline."
            )

    # Vision policy: do not impose arbitrary call counts.
    # The agent may re-evaluate when the evidence or question genuinely changes.
    # Only exact no-progress repetition of the same visual evidence + question is blocked.
    if tool_name in {"browser_vision", "computer_use"} and not alternate_method:
        return _block(
            "Shorts production guard: this QA fallback is disabled during normal production. "
            "Use vision_analyze as the primary visual QA path; if Vision is unavailable after "
            "the permitted retry, continue with controlled QA_UNAVAILABLE rather than inventing a fallback."
        )

    if tool_name == "vision_analyze":
        image_url = str(args.get("image_url") or "")
        question = str(args.get("question") or "").strip()
        raw = image_url[7:] if image_url.startswith("file://") else image_url
        image_path = Path(raw).expanduser()

        # ASSET-001 diagnostic:
        # Pre-casting source/range/asset Vision inspection is intentionally OPEN.
        # No artificial Vision-call cap and no mandatory batching in this diagnostic.
        # Use visual inspection only when it helps choose footage that actually fulfills
        # the creative contract. Existing duplicate/no-progress and other guards remain active.

        if image_path.name == "proof_contact_sheet.jpg":
            pending_path = image_path.parent / "proof_pending.json"
            current_fingerprint = None
            pending = {}
            try:
                if pending_path.exists():
                    pending = json.loads(pending_path.read_text(encoding="utf-8"))
                    current_fingerprint = pending.get("fingerprint")
            except Exception:
                pending = {}
            proof_state = _read_proof_attempt_state(image_path, pending)

            if (
                int(proof_state.get("failed_attempts") or 0) >= 2
                and current_fingerprint
                and proof_state.get("last_fingerprint") == current_fingerprint
            ):
                return _block(
                    "Shorts production guard: PROOF_STRATEGY_EXHAUSTED — this proof strategy "
                    "already failed initial review plus one repair. Do not retry Vision on the "
                    "same accepted candidates/casting. Materially change the proof footage or "
                    "casting, rerun proof-check, and continue the production autonomously."
                )

        # Content identity matters more than filename: a repaired final_contact_sheet
        # at the same path is new evidence and must be allowed to be judged again.
        try:
            image_identity = _sha_file(image_path.resolve())
        except Exception:
            image_identity = str(image_path)

        normalized_question = re.sub(r"\s+", " ", question).strip()
        sig_raw = json.dumps(
            {
                "session": session_id,
                "image": image_identity,
                "question": normalized_question,
            },
            ensure_ascii=False,
            sort_keys=True,
        )
        signature = hashlib.sha256(sig_raw.encode("utf-8")).hexdigest()

        with _LOCK:
            if signature in _VISION_SEEN:
                return _block(
                    "Shorts production guard: this exact visual evidence has already been "
                    "asked the same question. Reuse the existing result. If evidence was repaired "
                    "or the verification question genuinely needs correction, change the evidence "
                    "or question rather than repeating the same call."
                )
        return None

    # During a production turn the agent may USE the installed toolchain, but may not redesign it.
    if not explicit_system_change:
        if tool_name == "skill_manage":
            return _block(
                "Shorts production guard: do not modify skills during a production job. "
                "Use the current canonical pipeline and finish the artifact."
            )

        if tool_name in {"write_file", "patch"}:
            path = str(
                args.get("path")
                or args.get("file_path")
                or ""
            )
            if path.endswith("proof_receipt.json") or path.endswith("proof_pending.json"):
                return _block(
                    "Shorts production guard: proof state is runtime-owned. "
                    "Do not write or patch proof receipts/pending attestations manually; "
                    "only a real vision_analyze PASS may issue the receipt."
                )
            if any(path.startswith(prefix) for prefix in _PROTECTED_PREFIXES):
                return _block(
                    "Shorts production guard: production-time mutation of Hermes core/tools/skills "
                    "is blocked. Use the installed production stack as-is and finish the video."
                )

        if tool_name == "terminal":
            cmd = str(args.get("command") or "")
            low = cmd.lower()
            if "proof_receipt.json" in low or "proof_pending.json" in low:
root@213-238-170-219:~#