Files
2026-09-30 07:50:57 +08:00

53 lines
3.7 KiB
Python

"""Gate the diagnostic prototype, never promote it as learned/full-brain runtime."""
import json
from pathlib import Path
import sys
from context import ROOT,EXP,MODEL,CFG,save,check,integrity,digest
from run_suite import load,compare
def seal(root):
rows=[]
for p in sorted(root.rglob('*')):
if '__pycache__' in p.parts or '.venv' in p.parts:continue
if p.is_file():rows.append(dict(path=str(p.relative_to(root)),bytes=p.stat().st_size,sha256=digest(p)))
assert not (root/'manifest.json').exists() and not (root/'checksums.sha256').exists()
save(root/'manifest.json',dict(root=str(root),files=rows))
with (root/'checksums.sha256').open('x') as f:
for r in rows:f.write(r['sha256']+' '+r['path']+'\n')
f.write(digest(root/'manifest.json')+' manifest.json\n')
def main():
check();after=integrity();save(EXP/'regression/old-integrity-after.json',after)
summary=json.loads((EXP/'regression/gpu-complete.json').read_text());ref=json.loads((EXP/'regression/frozen-five.json').read_text())
expected=(len(CFG['synthetic_cases'])+len(CFG['real_cases'])+len(CFG['prior_motifs']))*len(CFG['precisions'])*CFG['gpu_repeats']
assert len(summary['trials'])==expected
rows=[]
for record in summary['trials']:
name=record['case'];precision=record['precision'];repeat=record['repeat'];case=EXP/'cases'/name
oracle=load(EXP/'oracle'/(name+'-'+precision)/'state.npz');gpu=load(EXP/'gpu'/(name+'-'+precision+f'-r{repeat}')/'state.npz')
actual=compare(oracle,gpu,case,precision);assert actual==record['comparison'],'Stored report differs from raw states'
first=load(EXP/'gpu'/(name+'-'+precision+'-r0')/'state.npz')
import numpy as np
equal={k:bool(np.array_equal(v,gpu[k])) for k,v in first.items()};assert equal==record['repeat_arrays']
rows.append(record)
passed=all(r['pass_all'] for r in rows) and ref['pass_all'] and all(x['pass'] for x in after.values())
status='PASS-ISOLATED-GPU-NUMERICAL-GATE' if passed else 'FAIL-ISOLATED-GPU-NUMERICAL-GATE'
save(EXP/'audit/final-status.json',dict(status=status,pass_all=passed,cases=expected//6,gpu_runs=expected,
full_brain_author_equivalence=False,conditioning=False,learning_achieved=False,candidate_generated=False,
next_gate='Short full-graph same-precision author comparison, then fixed DoOR CAL only if numerical gates pass'))
lines=['# Phase 4AE GPU作者语义数值门禁','',f'状态:`{status}`。','',
'仅验证固定小网络,尚未证明全脑等价、生物学正确或学习可用。未训练、未修改冻结输入或旧模型。','',
'| case | precision | events | max V/g error V | exact whole history | pass |','|---|---|---:|---:|---|---|']
for r in rows:
if r['repeat']:continue
c=r['comparison'];lines.append(f"| {r['case']} | {r['precision']} | {c['oracle_events']} | {c['max_abs_volt']} | {c['bitwise_history']} | {r['pass_all']} |")
lines+=['','每项GPU执行3次,检查原始事件、输入请求实际送达、逐目标到达顺序及guard、计数、不应期和完整状态。',
'大整数、随机图、重复/零边属于纯数值夹具,不是新增MaleCNS连接或生理假设。真实子图使用全部既有诱导边、原contact count与冻结transmitter sign。',
'原始冻结完整性与旧五组全脑deterministic-v2回归再次核验;该旧回归PASS不等于新动力学全脑PASS。',
'没有根据活动强度选择参数;尚须短时全图对照及嗅觉信息保持测试。','']
with (EXP/'REPORT.md').open('x',encoding='utf-8') as f:f.write('\n'.join(lines))
check();seal(MODEL);seal(EXP);print(status,flush=True)
if not passed:raise SystemExit(1)
if __name__=='__main__':main()