#!/usr/bin/env python3 """Clean-home source contracts. Complements compiled UI and optional real-device probe; this does not claim to run Compose or prove device appearance/lifecycle.""" from pathlib import Path import re ROOT=Path(__file__).resolve().parents[1] source=(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/CallScreen.kt').read_text() # Blank comments/strings without changing offsets, so nested lambdas can be inspected. pattern=r'"""[\s\S]*?"""|"(?:\\.|[^"\\])*"|//[^\n]*|/\*[\s\S]*?\*/' clean=re.sub(pattern,lambda m:' '*len(m[0]),source) def block(marker,within=None): start,end=within or (0,len(source)) at=clean.index(marker,start,end) body_at=at+len(marker) if marker.startswith('fun '): # Default callback lambdas belong to the parameter list, not the body. params=clean.index('(',body_at,end) depth=1;body_at=params+1 while depth: assert body_at