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-wide.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-wide.py` 29 lines ยท 2650 bytes Raw Blame History 1 from pathlib import Path 2 import subprocess,hashlib,json 3 h=Path.home();w=h/'workspace/omega-bridge-native-development';root=h/'handoffs/bridge-text-baseline';seed=w/'build/bootstrap/omc' 4 assert hashlib.sha256(seed.read_bytes()).hexdigest()=='`191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9`' 5 def literal(data): 6 escapes={9:b'\\t',10:b'\\n',34:b'\\"',92:b'\\\\'} 7 return b'"'+b''.join(escapes.get(n,bytes([n])) for n in data)+b'"' 8 def prog(data,body=None):return b'text t '+literal(data)+b'\nfn main to int\n'+(body or b'w = write 1 t 0 len t\nret 0\n')+b'end\n' 9 allbytes=bytes(range(256));rev=bytes(reversed(allbytes));repeat=allbytes*4 10 view=b'text t "abc"\nfn val a view uchar 3 to uchar\nret get a 2\nend\nfn main to int\nret int val t\nend\n' 11 edit=b'text t "abc"\nfn val a edit uchar 3 to void\nput a 0 1\nend\nfn main to int\nval t\nret 0\nend\n' 12 cases=[('all-byte-values',prog(allbytes),allbytes,0),('all-byte-reverse',prog(rev),rev,0),('repeated-alphabet',prog(repeat),repeat,0),('readonly-view-call',view,b'',ord('c')),('readonly-put',prog(b'abc',b'put t 0 1\nret 0\n'),None,None),('readonly-read',prog(b'abc',b'n = read 0 t 0 1\nret 0\n'),None,None),('readonly-edit-call',edit,None,None),('empty-runtime-bounds',prog(b'',b'i = ulong 0\nv = get t i\nret int v\n'),None,'observe')] 13 rows=[] 14 for name,src,want,status in cases: 15 built=subprocess.run([str(seed)],input=src,capture_output=True,timeout=20) 16 row={'name':name,'source_hex':src.hex(),'source_sha256':hashlib.sha256(src).hexdigest(),'native_compile_rc':built.returncode,'native_stderr':built.stderr.decode(errors='replace')} 17 if built.returncode==0: 18 assert built.stdout[:4]==b'\x7fELF' and len(built.stdout)>64 19 exe=root/(name+'.elf');exe.write_bytes(built.stdout);exe.chmod(0o700) 20 subprocess.run([str(w/'tools/verify-elf.sh'),str(exe)],check=True,capture_output=True) 21 result=subprocess.run([str(exe)],input=b'',capture_output=True,timeout=10) 22 assert not result.stderr,(name,result.stderr) 23 row.update(native_rc=result.returncode,native_stdout_hex=result.stdout.hex()) 24 if status!='observe':assert result.returncode==status and result.stdout==want,(name,result.returncode,result.stdout) 25 else:assert want is None,(name,built.returncode,built.stderr) 26 rows.append(row) 27 report={'seed_sha256':hashlib.sha256(seed.read_bytes()).hexdigest(),'source_base':'`0fc7d8662cb799e7c206b17c18ea4c3ec2b8fea9`','executed':len(rows),'cases':rows} 28 (root/'extended-native-oracle.json').write_text(json.dumps(report,indent=2)+'\n') 29 print(json.dumps({'executed':len(rows),'cases':[{k:v for k,v in r.items() if k in ('name','native_compile_rc','native_rc')} for r in rows]},indent=2))