ZaStoGram/Tools/check_mtproxy_phase_classification.py
loop-uh 3f8f8f27e7 Extract mtproxy module with unified retry authority
Move MTProxy policy engine from tgnet/ to self-contained jni/mtproxy/ module. Consolidate reconnect hold computation into single MtProxyRetryAuthority owner (was split across Connection, ConnectionSocket, endpoint policy, and probe coordinator, causing hold misalignment bugs). Add MtProxyTerminalDiagnostic module with host tests for pre-I/O verdict preservation (fixes 02.07/30.06 clobber livelocks). Auto-generate phase classification (isPreIoTerminalVerdict, needsReconnectBackoff, isObservationFacadePhase, isLocalSchedulerTimeout) from single Python contract into both C++ and Java to eliminate parallel maintenance. Pass native hold (coordinator terminal hold + endpoint cooldown) via JNI to Java so reconnect timer and health store use THE clock, not re-derived ones. Optimize log flushing: batch debug lines, flush errors immediately. Add module boundary guard, host build system (MSVC), and unit tests for retry logic and terminal diagnostic derivation.
2026-07-02 18:25:13 +03:00

35 lines
1 KiB
Python

#!/usr/bin/env python3
"""Guard: MtProxyPhaseClassification.h must match Tools/mtproxy_phase_contract.py.
The header is generated (single source of truth is the Python contract); a
stale checked-in copy means a phase classification edit did not go through the
contract. Regenerate with Tools/generate_mtproxy_phase_classification.py.
"""
from pathlib import Path
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[1]
GENERATOR = ROOT / "Tools/generate_mtproxy_phase_classification.py"
def main() -> int:
result = subprocess.run(
[sys.executable, str(GENERATOR), "--check"],
cwd=ROOT,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=False,
)
if result.returncode != 0:
sys.stderr.write(result.stderr)
print("MTProxy phase classification guard failed.", file=sys.stderr)
return 1
print("MTProxy phase classification guard passed.")
return 0
if __name__ == "__main__":
raise SystemExit(main())