Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-bridge/blob/main/evidence/text-parent-baseline/probe-bridge-text-baseline.py # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-bridge / evidence / text-parent-baseline / probe-bridge-text-baseline.py` 29 lines ยท 2694 bytes Raw Blame History 1 from pathlib import Path 2 import subprocess,hashlib,json,os 3 h=Path.home();w=h/'workspace/omega-bridge-native-development';root=h/'handoffs/bridge-text-baseline';root.mkdir(exist_ok=True) 4 seed=w/'build/bootstrap/omc';emitter=w/'build/bridge' 5 assert hashlib.sha256(seed.read_bytes()).hexdigest()=='`191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9`' 6 def program(lit):return b'text t '+lit+b'\nfn main to int\nw = write 1 t 0 len t\nret 0\nend\n' 7 cases=[('empty',program(b'""'),b''),('hello',program(b'"hello"'),b'hello'),('escapes',program(b'"A\\tB\\\\C\\\"D\\nZ"'),b'A\tB\\C"D\nZ'),('raw-nul',program(b'"A\x00B"'),b'A\x00B'),('utf8',program('"caf\u00e9 \u03a9"'.encode()),'caf\u00e9 \u03a9'.encode()),('unused',b'text t "abc"\nfn main to int\nret 0\nend\n',b''),('bad-escape',program(b'"a\\qb"'),None),('unterminated',program(b'"abc'),None),('inline-literal',b'fn main to int\nw = write 1 "abc" 0 3\nret 0\nend\n',None)] 8 rows=[] 9 for name,src,want in cases: 10 build=subprocess.run([str(seed)],input=src,capture_output=True,timeout=20) 11 row={'name':name,'source':src.decode('utf8'),'source_sha256':hashlib.sha256(src).hexdigest(),'native_compile_rc':build.returncode,'native_stderr':build.stderr.decode(errors='replace')} 12 if want is not None: 13 assert build.returncode==0 and build.stdout[:4]==b'\x7fELF' and len(build.stdout)>64,(name,build.returncode,build.stderr) 14 exe=root/(name+'.elf');exe.write_bytes(build.stdout);exe.chmod(0o700) 15 subprocess.run([str(w/'tools/verify-elf.sh'),str(exe)],check=True,capture_output=True) 16 got=subprocess.run([str(exe)],capture_output=True,timeout=10) 17 assert got.returncode==0 and got.stdout==want and got.stderr==b'',(name,got) 18 row.update(native_rc=got.returncode,native_stdout_hex=got.stdout.hex(),expected_stdout_hex=want.hex()) 19 targets={} 20 for target in ('C','P'): 21 result=subprocess.run([str(emitter)],input=target.encode()+src,capture_output=True,timeout=10) 22 assert result.returncode in (16,24) and not result.stdout,(name,target,result.returncode,result.stdout[:80]) 23 targets[target]={'rc':result.returncode,'stdout_bytes':len(result.stdout),'stderr':result.stderr.decode(errors='replace')} 24 row['old_bridge']=targets 25 else:assert build.returncode!=0,(name,'unexpected native acceptance') 26 rows.append(row) 27 report={'source_commit':'`0fc7d8662cb799e7c206b17c18ea4c3ec2b8fea9`','seed_sha256':hashlib.sha256(seed.read_bytes()).hexdigest(),'cases':rows,'executed':len(rows),'native_accepts':sum('native_rc' in r for r in rows),'native_refusals':sum('native_rc' not in r for r in rows)} 28 (root/'baseline.json').write_text(json.dumps(report,indent=2)+'\n') 29 print(json.dumps({k:v for k,v in report.items() if k!='cases'},indent=2))