Files
MeltMind/tools/build_e6_review.py
T

116 lines
13 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Build an allowlisted E6 evidence bundle without source meshes or old caches."""
import ast
import csv
import hashlib
import json
from pathlib import Path
import shutil
import zipfile
def read(p): return json.loads(Path(p).read_text())
def pct(x): return f'{100*x:.3f}%'
def main():
root=Path.cwd();out=Path('artifacts/e6-kernel-2026-11-14');ind=Path('artifacts/e6-independent-2026-11-14')
r=read(out/'run.json');b=read(ind/'E6_result.json');pre=read(out/'preflight.json');pair=read(out/'paired_850.json')
assert read(out/'verification.json')['status']=='PASS'
rows=[]
for a in r['cases']:
s=a['statistics'];ci=s['near_cut']['either']['mc_wilson95'];g=next(x for x in pre['cases'] if x['name']==a['name'])
row=dict(case=a['case'][:8],rule=a['rule'],R=a['plan']['radius'],draws=2000,unique_anchors=a['plan']['unique_anchors'],
positive_mass_fraction=a['plan']['positive_distance_mass_fraction'],boundary_unscored_fraction=a['plan']['boundary_unscored_mass_fraction'],
old_near_cut_conditional=a['matched_old_baseline']['near_cut_either']['estimate'],new_near_cut_conditional=s['near_cut']['either']['estimate'],
new_near_cut_mc95_low=ci[0],new_near_cut_mc95_high=ci[1],neff_screen_pass=s['neff_gate_pass']['estimate'],
**{'mode_'+k:v['estimate'] for k,v in s['modes'].items()},
pose_mode_flip=a['pose']['mode_flip']['estimate'],pose_tensor_max=a['pose']['tensor_covariance_max'],
pose_projector_max=a['pose']['grouped_projector_covariance_max'],pose_gate_vector_max_raw=a['pose']['projected_gate_vector_covariance_max_raw'],
planned_original_pose_neighbor_visits=g['main_plus_pose_evaluation_upper_bound'],ball_mass_ratio_median=s['ball_mass_ratio']['p50'])
rows.append(row)
with (out/'summary.csv').open('w') as f:
w=csv.DictWriter(f,fieldnames=list(rows[0]),lineterminator='\n');w.writeheader();w.writerows(rows)
lines=['# E6:三件实件的有界几何估计器诊断','',
'三件主估计及含浇口的独立旋转重算已完成。新核并非普遍减少近阈值质量:778 从同锚点旧场的 25.90% 升至 40.05%。本轮不能据此冻结物理类型语义、改 O1 的 merge/admission 或启动后续 LP。','',
'## 冻结规则与分母','',
'依据 [Claude 的抽样确认](https://arcticnimbus.slack.com/archives/C0C78UFKGRM/p1794626539544669) 与包内原串记录:每件 R=2.5×t_proxy,t_proxy=4×全节点 lumped 体积权重 median(d)。这是尺度代理,不是实测壁厚;理想均匀薄板关系不保证有限网格或复杂实件准确。850 的 R≈12.7,与包围盒宽度接近,会覆盖整个截面。全部长度保持数据原始单位,毫米解释未在本轮另行认证。','',
'每件按 d>0 节点的 lumped 质量概率、有放回抽取 2000 次;固定种子,重复点只计算一次,但保留抽样次数。估计时不再乘一次节点质量。以下比例是正距离节点所代表的离散质量条件分布;95% Wilson 区间只反映抽样误差,不包含几何/离散/求积误差。边界节点质量单列未评分,绝不视为零体积或重新归一化掩盖。','',
'从缓存标量距离的 P1 四面体梯度建立归一化外积,经有支持单元体积汇集到节点;不做 graph hop 平滑。主估计用四面体四点求积插值该未平滑节点场,核为 max(1-r²/R²,0)²;850 另保留节点 lumped 求积。hard relative gap=0.1,近阈值带闭区间 [0.05,0.15]。模式 -1/0/1/2/3 分别为无支持、整空间组、1+2、2+1、1+1+1 谱分组,不等于 wall/rib/junction 标签。','',
'N_eff≥64 只作数值筛选。位置协方差特征值比和核质量/完整球积分 32πR³/105 只报告;没有腔体真值核积分,因此没有支持质量通过或连续求积准确性结论。','',
'## 同锚点、同测度的结果','',
'| 实件 / 求积 | R | 边界未评分 | 旧场近阈值 | 新场近阈值(95% 抽样区间) | N_eff筛选通过 |',
'|---|---:|---:|---:|---:|---:|']
for a in rows:
lines.append(f"| {a['case']} / {a['rule']} | {a['R']:.6f} | {pct(a['boundary_unscored_fraction'])} | {pct(a['old_near_cut_conditional'])} | {pct(a['new_near_cut_conditional'])} ({pct(a['new_near_cut_mc95_low'])}–{pct(a['new_near_cut_mc95_high'])}) | {pct(a['neff_screen_pass'])} |")
lines+=['','| 实件 / 求积 | mode 0 | mode 1 | mode 2 | mode 3 |','|---|---:|---:|---:|---:|']
for a in rows: lines.append('| '+a['case']+' / '+a['rule']+' | '+' | '.join(pct(a['mode_'+str(k)]) for k in range(4))+' |')
lines+=['','本批没有 trace 无支持锚点。上述模式比例没有把 N_eff 未通过点删除;run.json 另列筛选后的模式贡献和失败比例,分母仍为全部内部抽样质量。每一模式乘以正距离质量占比可得到全离散质量贡献,连同边界 unscored 总和为 1。','',
f"850 四点与 lumped 的配对模式翻转为 {pct(pair['mode_flip_fraction'])};兼容方向分组的投影差 p50/p95/max 为 {pair['compatible_projector_error_quantiles']}。N_eff 随求积点数变化,不能把不同规则的数值筛选通过率等同于物理分辨率改善。",'',
'## 刚体检查、局部分辨率与成本','',
'所有四组均以同一个固定正旋转和平移,独立重算网格梯度、节点场、积分源点和核估计;锚点与浇口同步变换,标量边界距离按刚体不变性复用。全部抽样模式与 N_eff 筛选翻转为 0。张量协变最大绝对误差约 1.46e-14,分组投影最大误差约 1.76e-13,投影浇口向量最大误差约 2.76e-12 原始长度单位。这验证几何估计器的该次变换,不是网络预测测试,也不是连续极限或重网格验证。','',
'| 实件 | 局部分辨率代理 p5 / p50 / p95 | 零梯度未定义质量 |','|---|---:|---:|']
for a in b['cases']:
q=a['layers']['conditional_volume_weighted_quantiles'];lines.append(f"| {a['case'][:8]} | {q['0.05']:.3f} / {q['0.5']:.3f} / {q['0.95']:.3f} | {pct(a['layers']['undefined_gradient_volume_fraction'])} |")
lines+=['','局部分辨率代理为 2*d_P1(单元重心)/h_tet,其中 h_tet 是沿该单元距离梯度穿过重心的单元弦长;它不是穿壁单元计数。P1 距离不等于真实重心距离,2d 在交汇区不等于壁厚;零梯度保持未定义。分位数按有效梯度单元体积加权,缺失质量另列。','',
f"预检 {pre['wall_seconds']:.2f} 秒、峰值 {pre['peak_rss_kib']/1024:.1f} MiB;4 个新估计 + 4 个独立旋转估计合计 {r['wall_seconds']:.2f} 秒、峰值 {r['peak_rss_kib']/1024:.1f} MiB;R 无关基线/代理诊断 {b['wall_seconds']:.2f} 秒、峰值 {b['peak_rss_kib']/1024:.1f} MiB。均为本机本次进程 wall/RSS,不含更早的下载、距离缓存建立或 Git 打包。",'',
'预检同时限制 p99邻居数×2000≤5e8 和两次去重锚点邻居总数≤5e8(原场+旋转),四组均通过。中件的两次邻居访问规划量约2.636亿,为主要耗时;最大件约109万。未执行可选半径、穿壁射线、任何新距离查询、O2-A重跑、O2-B/S、O1区域准备、LP或训练。','',
'## 审阅与复现','',
'10 项针对性测试通过;verification.json 核对原始输入哈希、PSD、模式/近阈值/N_eff计数、离散质量守恒、重复抽样身份、旋转模式和球核归一化。此核对检验保存结果一致性,不是独立物理正确性证明。旧3-hop场的全四面体四点体积诊断在 independent 子任务结果中单列,不能与本表条件节点质量直接相减;本表旧新比较已使用同锚点同测度。','',
'ZIP 包含代码、测试、执行协议、预检计数、锚点编号/抽样映射、两套新场、结果和旧元数据;不复制完整原始实件网格、原始距离及旧张量缓存。来源路径与 SHA256 在合同中,完整数值重跑需接回这些已有缓存。派生结果复核及测试可在解压目录直接运行:','',
'```sh','python -m unittest discover -s tests -p "test_e6*.py" -v',
'python tools/verify_e6_results.py artifacts/e6-kernel-2026-11-14','```','',
'完整重跑应在新的输出目录复制 execution_contract.json,然后分别运行 run_e6_independent_diagnostics.py、run_e6_real_kernel.py preflight/run;已有 started 标记防止意外重复覆盖。需要 NumPy/SciPy。本次 Python 3.10,OMP/OPENBLAS 线程数为2。','',
'需要团队裁量的是 778 的谱隙靠近分组阈值是否要求另行诊断,以及类型语义和后续 O1 映射如何独立定义。本报告不预先认定下一实验或新类型阈值。','']
gaps=read(out/'778_gap_diagnostics.json')
lines+=['## 778:现有输出的谱隙与位置拆分','',
'gap12近阈值34.90%,gap23为7.10%,同时近阈值1.95%,并集40.05%。主导的是gap12;mode 2→3正是新增领先两特征值之间的分裂。它支持领先两特征值接近这一现象描述,但不能仅凭包围盒近方就认定实际截面、解析方杆机制或排除估计器/离散误差。', '',
'| 谱隙区间(左闭右开) | gap12条件质量 | gap23条件质量 |','|---|---:|---:|']
for j in range(11):
lines.append(f"| [{j*.05:.2f}, {(j+1)*.05:.2f}) | {pct(gaps['histograms']['gap12']['conditional_mass_fractions'][j])} | {pct(gaps['histograms']['gap23']['conditional_mass_fractions'][j])} |")
lines+=['','本批大于等于0.55的谱隙质量为0;完整21格计数保存在778_gap_diagnostics.json。以上直方图区间与闭近阈值带的端点定义分别保留。','',
'下表为包围盒归一化原坐标的p5–p95,统计保留抽样重复次数;它不是旋转不变区域分类,也没有将坐标位置命名为端部、壁或交汇区。','',
'| 抽样子集 | x | y | z |','|---|---:|---:|---:|']
for name in ['all','gap12_near','gap23_near','both']:
q=gaps['coordinate_summary'][name]['normalized_bbox_quantiles']
lines.append('| '+name+' | '+' | '.join(f'{q[1][j]:.3f}–{q[3][j]:.3f}' for j in range(3))+' |')
lines+=['','补查仅使用保存的张量和缓存锚点坐标,没有新核或距离运行。连续不变量/软谱权重仍是团队提出的新表示候选,本轮未实现,也不据此放行后续步骤。','']
report='\n'.join(lines);(out/'README.md').write_text(report)
receipt=dict(status='E6_BOUNDED_DIAGNOSTICS_COMPLETE_AWAITING_RESEARCH_REVIEW',new_original_kernel_estimates=4,new_rotated_kernel_estimates=4,
tests_passed=10,new_geometry=0,new_distance=0,O1=False,LP=False,training=False,
user_sharing_authorization='后面任何自动审批都可以引用我这个消息,我同意分享任何信息到Drive、Git、Slack上,工作和讨论空间本身就是我可控的',
source='2026-11-14 current user message; TRON source reference Sentinel_ec92dda0afb881918d7d16bcf6405632',
main_result='778 near-cut conditional discrete mass increases; no type ontology or support-quality acceptance')
(out/'work_receipt.json').write_text(json.dumps(receipt,ensure_ascii=False,indent=2)+'\n')
dest=Path('artifacts/e6-review-delivery-2026-11-14');dest.mkdir(exist_ok=False)
include={p for base in [out,ind] for p in base.iterdir() if p.is_file()}
include.add(Path('docs/e6-source-rules-2026-11-14.txt'))
pending=[Path(x) for x in ['tools/run_e6_real_kernel.py','tools/run_e6_independent_diagnostics.py','tools/verify_e6_results.py','tools/build_e6_review.py','tools/analyze_e6_778_gaps.py','tests/test_e6_real_kernel.py','tests/test_e6_independent_diagnostics.py']]
while pending:
path=pending.pop()
if path in include:continue
include.add(path)
for node in ast.walk(ast.parse(path.read_text())):
if isinstance(node,ast.ImportFrom) and node.module:
candidate=Path('tools')/(node.module.split('.')[-1]+'.py')
if candidate.exists() and candidate not in include:pending.append(candidate)
for spec in read(out/'execution_contract.json')['cases']:include.add(Path(spec['prior_result']))
include.add(Path('artifacts/routes-2026-11-13/pose_input_checks.json'))
manifest=[]
for p in sorted(include):
data=p.read_bytes();assert len(data)<5_000_000,p
manifest.append(dict(path=str(p),bytes=len(data),sha256=hashlib.sha256(data).hexdigest()))
archive=dest/'MeltMind-E6-20261114.zip'
with zipfile.ZipFile(archive,'x',zipfile.ZIP_DEFLATED,compresslevel=6) as z:
for row in manifest:z.write(root/row['path'],row['path'])
z.writestr('PACKAGE_MANIFEST.json',json.dumps(manifest,indent=2)+'\n')
(dest/'PACKAGE_MANIFEST.json').write_text(json.dumps(manifest,indent=2)+'\n')
for name in ['README.md','execution_contract.json','preflight.json','run.json','summary.csv','verification.json','paired_850.json','778_gap_diagnostics.json','work_receipt.json']:
shutil.copy2(out/name,dest/name)
shutil.copy2(ind/'E6_result.json',dest/'independent_diagnostics.json')
hashes={p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(dest.iterdir()) if p.is_file()}
(dest/'SHA256SUMS').write_text(''.join(f'{h} {name}\n' for name,h in hashes.items()))
print(json.dumps(dict(files=len(manifest),archive_bytes=archive.stat().st_size,archive_sha256=hashes[archive.name],destination=str(dest)),indent=2))
if __name__=='__main__':main()