#!/usr/bin/env python3
"""Conforming PLAN reviewer that accepts ONLY the certified argument shape.

`run-plan-review` launches a plan wrapper as `wrapper --plan <path>` and `agent-conformance`
certifies exactly that. An argparse-based wrapper -- the ordinary way to write a CLI -- rejects
an unexpected positional, so a launcher that appends anything extra breaks a wrapper the
certificate says will work.

This fixture is that wrapper: it refuses any argv beyond `--plan <path>`, so a test using it
fails the moment a launch path invents its own shape.
"""
import json
import os
import sys

AGENT_ID = os.environ.get("TAUTLINE_REVIEW_AGENT_ID", "fixture-strict-argv")

argv = sys.argv[1:]
if len(argv) != 2 or argv[0] != "--plan":
    print(
        f"unexpected argv {argv!r}: this reviewer accepts only `--plan <path>`",
        file=sys.stderr,
    )
    raise SystemExit(2)  # transport failure: it was not invoked the certified way
with open(argv[1], encoding="utf-8") as handle:
    handle.read()

print("reviewing:", " ".join(argv))
print("## Findings")
print()
print("No blockers found.")

path = os.environ.get("TAUTLINE_REVIEW_RESULT_PATH")
if not path:
    print("no TAUTLINE_REVIEW_RESULT_PATH supplied", file=sys.stderr)
    raise SystemExit(2)

with open(path, "w", encoding="utf-8") as handle:
    json.dump(
        {
            "schema": "tautline-agent-review-result/v1",
            "agent": AGENT_ID,
            "verdict": "clean",
            "findings": [],
        },
        handle,
    )
raise SystemExit(0)
