# -*- coding: utf-8 -*-
"""tests.regression.dispatch_gate.test_prompt_3270_allowed — §17.14 regression.

회장 verbatim: 3270 bytes prompt 는 hard block 대상이 아니다 (ANU paraphrase
사고 정정). 단독 fail-closed regression — fixture JSON 1:1 검증.
"""
from __future__ import annotations

import json
from pathlib import Path

from utils.prompt_byte_classifier import (
    OK_ABOVE_TARGET,
    classify_prompt_bytes,
    is_allowed,
    measure_utf8_bytes,
)


FIXTURE = (
    Path(__file__).parent.parent.parent / "fixtures" / "dispatch_gate" / "prompt_3270_allow.json"
)


def test_3270_bytes_prompt_is_allowed_chair_verbatim() -> None:
    fix = json.loads(FIXTURE.read_text())
    n = fix["input"]["prompt_byte_length"]
    assert n == 3270

    prompt = "x" * n
    assert measure_utf8_bytes(prompt) == 3270

    c = classify_prompt_bytes(prompt)
    assert c.verdict == OK_ABOVE_TARGET == fix["expected"]["verdict"]
    assert c.allowed is True == fix["expected"]["allowed"]
    assert c.hard_block is False == fix["expected"]["hard_block"]
    assert is_allowed(prompt) is True
