# -*- coding: utf-8 -*- """Hub native-confirm gate (take-two F-16, the hub sibling of drill F-11) — native confirm()/ prompt() dialogs are OS-modals that freeze browser automation (CDP) and are banned from the hub UI; consequential buttons use the inline felhomConfirm helper (templates/inline_confirm.html). The danger-zone typed-confirm flow does not use native dialogs either. Run from the repo root: python scripts/hub_confirm_gate.py Exit 1 if any native confirm(/prompt( call remains in hub templates. """ import io, os, re, sys # A gate's own console must not decide its verdict. These scripts quote back Hungarian copy, file # paths and arrow characters; a Windows console here is cp1250, and printing one of them raised # UnicodeEncodeError *before the gate had decided anything* — reuse_refs_check.py died while printing # a NOTE, which the runner then reported as a failure (2026-10-10). Same trap class as # poster_facts_gate.py's, which was found by its own red-proof. for _stream in (sys.stdout, sys.stderr): try: _stream.reconfigure(encoding="utf-8", errors="replace") except (AttributeError, ValueError, OSError): # pragma: no cover - old Python, or a pipe pass ROOT = os.path.join("hub", "internal", "web", "templates") # A bare confirm(/prompt( CALL with an argument: not preceded by an identifier character, so felhomConfirm( # never matches. window.confirm( still matches ('.' is not an identifier char). NATIVE = re.compile(r"(?