From 7c5f10ca2601ae6f4fa44949b841c2c8d2c048ab Mon Sep 17 00:00:00 2001 From: Coding-Dev-Tools Date: Tue, 21 Jul 2026 14:20:39 -0400 Subject: [PATCH] =?UTF-8?q?feat(licensing):=20Phase=204=20=E2=80=94=20free?= =?UTF-8?q?ze=20gate=20snapshot=20against=20re-snapshot=20after=20patching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engraphis/cloud_license.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/engraphis/cloud_license.py b/engraphis/cloud_license.py index 888d2f3..ea402e1 100644 --- a/engraphis/cloud_license.py +++ b/engraphis/cloud_license.py @@ -688,10 +688,19 @@ def _verify_module_integrity(): _lock_sentinel = object() _GATE_SNAPSHOT = gate +_GATE_LOCK_TAKEN = 0 # generation counter — prevents re-snapshot after first call def _verify_gate_integrity(): - """Raise if ``gate`` has been monkeypatched since import.""" + """Raise if ``gate`` has been monkeypatched since first call. + + Frozen on first call; re-snapshotting ``_GATE_SNAPSHOT = gate`` after + patching will be ignored once the counter is non-zero. + """ + global _GATE_SNAPSHOT, _GATE_LOCK_TAKEN + if _GATE_LOCK_TAKEN == 0: + _GATE_SNAPSHOT = gate + _GATE_LOCK_TAKEN = 1 try: from engraphis.licensing import _TEST_MODE_PUBKEY_OVERRIDE if _TEST_MODE_PUBKEY_OVERRIDE: