omega-tool-model
First-party Omega tool-use model source, serving harnesses, and verification records
Brought by drakestapleton
omega-tool-model / deployment / verify.py
| 1 | import os |
| 2 | """External deployment check; never executes model-generated actions.""" |
| 3 | from pathlib import Path |
| 4 | import hashlib,json,subprocess,time |
| 5 | R=Path(__file__).resolve().parent |
| 6 | P=R.parent/'tool-omega-20261104' |
| 7 | D=(Path(os.path.expanduser('~')) / '/.local/share/omega-tool-model/round40'.lstrip('/')) |
| 8 | B=D/'omega-tool-model' |
| 9 | rows=[] |
| 10 | def run(label,cmd,data=None): |
| 11 | start=time.monotonic() |
| 12 | p=subprocess.run([str(x) for x in cmd],input=data,capture_output=True,timeout=120) |
| 13 | rec=dict(label=label,command=[str(x) for x in cmd],returncode=p.returncode,stdout=p.stdout.decode(errors='replace'),stderr=p.stderr.decode(errors='replace'),seconds=time.monotonic()-start) |
| 14 | if data is not None: rec['stdin_sha256']=hashlib.sha256(data).hexdigest() |
| 15 | rows.append(rec) |
| 16 | (R/'verification-commands.json').write_text(json.dumps(rows,indent=2)+'\n') |
| 17 | return p |
| 18 | jobs=json.loads((P/'round40/final-selected.json').read_text()) |
| 19 | turns=jobs[0]['turns'] |
| 20 | demo=run('candidate-demo',[B,'--demo']) |
| 21 | assert demo.returncode==0 and demo.stdout.decode()==turns[0]['raw'], rows[-1] |
| 22 | (R/'one-shot.json').write_text(json.dumps(dict(prompt=turns[0]['prompt'],actual=demo.stdout.decode(),expected=turns[0]['raw'],pass_=True),indent=2)+'\n') |
| 23 | for index,turn in enumerate(turns): |
| 24 | candidate=run(f'candidate-stage-{index}',[B],turn['prompt'].encode()) |
| 25 | reference=run(f'reference-stage-{index}',[P/'build/sample',D/'model.ck',160,turn['prompt'],D/'merges.bin']) |
| 26 | assert candidate.returncode==reference.returncode==0 |
| 27 | assert candidate.stdout==reference.stdout==turn['raw'].encode(),rows[-2:] |
| 28 | assert not candidate.stderr and not reference.stderr |
| 29 | for label,data,expected in [('empty',b'',2),('embedded-zero',b'Task:\x00Answer:\n',2),('byte-overflow',b'x'*4001,2),('token-overflow',(b'! '*600),3)]: |
| 30 | q=run(label,[B],data) |
| 31 | assert q.returncode==expected,rows[-1] |
| 32 | q=run('wrong-option',[B,'--unknown']) |
| 33 | assert q.returncode==2 |
| 34 | q=run('help',[B,'--help']) |
| 35 | assert q.returncode==0 and b'No tools are executed' in q.stdout |
| 36 | pins=json.loads((R/'build-receipt.json').read_text())['pins'] |
| 37 | for name,want in pins.items(): |
| 38 | assert hashlib.sha256(Path(name).read_bytes()).hexdigest()==want,name |
| 39 | (R/'verification.json').write_text(json.dumps(dict(passed=True,demonstration_passed=True,repair_stage_parity=len(turns),refusal_checks=5,help_passed=True,all_pins_unchanged=True,scope='Model-response parity only; no tools executed, no new independent accuracy claim.'),indent=2)+'\n') |
| 40 | print('Passed: real one-shot, all five repair-stage responses match, input refusals and asset hashes verified.') |