"""Reproduction: approve --help documents exit code 300 for agent not found.

Expected: The approve command help text should document exit code 2 for
          agent not found, consistent with all other commands (status, kill,
          collect, reject, resume, talk).
Actual:   approve --help says "Exit codes: 0 success, 1 wrong state, 300
          agent not found" -- the 300 appears to be the numeric_code from
          the error envelope (AGENT_NOT_FOUND=300) rather than the shell
          exit code (which is actually 2).
"""
from click.testing import CliRunner
from anima.shell.cli import main


def test_approve_help_exit_code_documentation():
    """approve --help should not document 300 as an exit code."""
    runner = CliRunner()
    result = runner.invoke(main, ["approve", "--help"])

    help_text = result.output

    # The help text currently says "300 agent not found" which is wrong.
    # Shell exit codes cannot exceed 255. The 300 is the numeric_code
    # from the JSON error envelope, not the shell exit code.
    assert "300" not in help_text, (
        f"approve --help documents exit code 300, which is impossible "
        f"for a shell exit code (max 255). All other commands use exit "
        f"code 2 for agent not found. The '300' is the error envelope's "
        f"numeric_code, not the shell exit code.\n"
        f"Help text excerpt: {help_text[help_text.find('Exit codes'):][:80]}"
    )


if __name__ == "__main__":
    test_approve_help_exit_code_documentation()
    print("PASS: approve --help no longer documents 300 as exit code")
