#!/usr/bin/env python3
"""Conforming review agent: refuses to review.

A refusal is a CONFORMING outcome -- the agent held up its end by saying so in the contract
rather than by dying. `findings` is empty because nothing was examined, and the reason is
recorded so an operator can tell a context limit from a broken wrapper."""
import json
import os
import sys

AGENT_ID = os.environ.get("TAUTLINE_REVIEW_AGENT_ID", "fixture-refusal")
# Echo the invocation. A real reviewer's transcript names what it reviewed, and the
# plan-review finalize gate REQUIRES the output to reference the reviewed plan path or
# content hash -- evidence that never says what it looked at cannot be bound to it.
print("reviewing:", " ".join(sys.argv[1:]))

# The PLAN-review seam has a prose contract of its own: the response must carry a
# `## Findings` section, and finalize refuses without one, calling it a reviewer-format
# error rather than a verdict. A conforming agent emits both -- the structured result
# for the build seam, this section for the plan seam -- because one wrapper serves both
# and cannot tell which invoked it.
print("## Findings")
print()
print("Refused: diff exceeds this agent's context window.")

path = os.environ.get("TAUTLINE_REVIEW_RESULT_PATH")
if not path:
    print("no TAUTLINE_REVIEW_RESULT_PATH supplied", file=sys.stderr)
    raise SystemExit(2)  # transport failure: the framework did not hold up its end

with open(path, "w", encoding="utf-8") as handle:
    json.dump(
        {
            "schema": "tautline-agent-review-result/v1",
            "agent": AGENT_ID,
            "verdict": "refused",
            "findings": [],
            "refusal": "diff exceeds this agent's context window",
        },
        handle,
    )
raise SystemExit(0)
