"""Local native-friendly reception repair against the exact failed private61.

This parent is a regression reproducer, not a qualified release. The native
105A2 interception/lunge routine, all its other callers, physics, AI ratings,
RNG, menus, rosters and artwork must remain byte-identical.
"""
import hashlib

PARENT = '0b6dd3a7bff09a323224a28927dcf77a28e1ad06429b40be683a3a91cadf1a19'


def verify(before, after):
    assert hashlib.sha256(before).hexdigest() == PARENT, 'exact failed private61 regression parent required'
    assert len(before) == len(after) == 3145728
    allowed = [(0x120, 0x180), (0x18E, 0x190), (0x225800, 0x226000), (0x2DD000, 0x2DD400), (0x2DF000, 0x2DF400)]
    changes = [i for i, (a, b) in enumerate(zip(before, after)) if a != b]
    bad = [i for i in changes if not any(lo <= i < hi for lo, hi in allowed)]
    assert changes and not bad, ('outside local friendly-reception scope', [hex(i) for i in bad[:32]])
    assert after[0x225FF0:0x225FF4] == b'FRCP'
    assert before[0x10588:0x10750] == after[0x10588:0x10750], 'original native interception/lunge changed'
    assert before[0x225000:0x225800] == after[0x225000:0x225800], 'original finisher tracking changed'
    return dict(parent_sha256=PARENT, rom_sha256=hashlib.sha256(after).hexdigest(),
                changed_bytes=len(changes), allowed_regions=allowed,
                all_other_ROM_bytes_exact=True, no_global_hook_or_new_RAM=True,
                scope='Only an actual friendly B24 interception may retain its existing CPU buffer and finish after true ownership. Original native interception and finisher tracking remain exact. No AI ratings, win-rate tuning, forced catches or shot outcomes.')
