#!/usr/bin/env python3 from pathlib import Path ROOT=Path(__file__).resolve().parents[1] main=(ROOT/'desktop/src/main.rs').read_text() cache=(ROOT/'desktop/src/optical_cache.rs').read_text() qr=(ROOT/'desktop/src/qr.rs').read_text() protocol=(ROOT/'desktop/src/protocol.rs').read_text() base45=(ROOT/'desktop/src/base45.rs').read_text() analyzer=(ROOT/'android/app/src/main/java/com/qft/optical/QrAnalyzer.kt').read_text() android_protocol=(ROOT/'android/app/src/main/java/com/qft/optical/Protocol.kt').read_text() activity=(ROOT/'android/app/src/main/java/com/qft/optical/MainActivity.kt').read_text() assert 'render_qr_grid' not in qr+cache+main assert 'self.optical.lanes' not in main assert 'OPTICAL_MULTI' not in analyzer assert 'newFixedThreadPool' not in analyzer # 本守卫的用意是锁住「单通道大二维码」这个设计,chunk 大小只是附带指标。 # 早先写死 450 的断言在常量改成 320 时就一直是红的(没人发现), # 改成范围检查:既能挡住"退回多通道小块",又不会因为正常调参而误报。 import re match = re.search(r'DEFAULT_CHUNK_SIZE: u16 = (\d+)', main) assert match, '未找到 DEFAULT_CHUNK_SIZE' chunk_size = int(match.group(1)) assert 128 <= chunk_size <= 4096, f'DEFAULT_CHUNK_SIZE={chunk_size} 超出单个大二维码的合理区间' assert 'source.text_frame(page_index)' in cache and 'render_qr_fitted' in cache assert 'QFT2:' in protocol and 'base45::encode' in protocol and 'EcLevel::L' in qr assert 'Base45.decode' in android_protocol and 'QFT2' in android_protocol assert 'assembler.acceptText(code.text)' in activity and 'acceptBinary' not in activity assert 'grayBuffer.capture(image, current)' in analyzer and 'fingerprint = text.hashCode()' in analyzer assert 'BB8' in base45 and 'UJCLQE7W581' in base45 print(f'PASS single-channel guard: one large QFT2/Base45 QR, {chunk_size}B chunks, no 2x2/4-lane path, Android locked-ROI text decode only')