Codex 当前会话
项目 GPT-6 API 调用:0。工程图读图、代码编写、执行检查与修复由当前会话完成。
{E(readings[case]["body"])}
- '+''.join('
- '+E(s)+' ' for s in readings[case]['features'])+'
假设与未完成项
- '+''.join('
- '+E(s)+' ' for s in readings[case]['assumptions'])+'
"""Report current-session Codex work versus the Luna-only project API arm."""
import os
import html,json,shutil,sys
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT/'scripts'))
from export_stage_trace import export_trace,read_json
E=lambda x:html.escape(str(x))
def build():
root=ROOT/'output/codex_luna_comparison'; static=Path(os.environ.get('CADMIND_REPORT_STATIC_DIR', str(ROOT.parent/'frontend/public/static'))); assets=static/'codex-luna-assets';assets.mkdir(exist_ok=True)
readings=read_json(ROOT/'experiments/codex_luna/readings.json')
manifest={'cases':[]}; sections=[]; summaries={}
for case,job,rev in [('3B','quality_20260908_035808_af9ddee6','v2'),('3C','quality_20260908_035809_9ac20815','v1')]:
folder=ROOT/'output'/job; luna=assets/(case+'_luna'); trace=export_trace(folder,luna)
source=root/(case+'_codex_'+rev); codex=assets/(case+'_codex');shutil.copytree(source,codex,dirs_exist_ok=True)
shutil.copy2(ROOT/'experiments/codex_luna/build_codex_cases.py',codex/'authored_build.py')
shutil.copy2(ROOT/'experiments/codex_luna/readings.json',codex/'readings.json')
if case=='3B':shutil.copytree(root/'3B_codex_v1',assets/'3B_codex_v1',dirs_exist_ok=True)
report=read_json(folder/'report.json',{}); jobstate=read_json(folder/'job.json',{})
if report:
for name in ['model.step','model.stl','iso.png','report.json']:
if (folder/name).exists():shutil.copy2(folder/name,luna/name)
models={e.get('model') for e in trace['api_calls']}; assert models <= {'gpt-5.6-luna'}, models
summaries[case]={'luna_job':job,'luna_state':jobstate,'api_models':list(models),'luna_phases':{k:{x:y for x,y in p.items() if x!='candidates'} for k,p in trace['phases'].items()},'codex_phases':read_json(source/'stages.json'),'codex_repair_count':len(readings[case]['repairs']),'luna_reason':report.get('quality_reason')}
manifest['cases'].append({'id':case,'runs':[{'id':'luna','label':'Luna API · 新实验','folder':str(folder)}]})
cp='codex-luna-assets/'+case+'_codex/';lp='codex-luna-assets/'+case+'_luna/'
text=f' 项目 GPT-6 API 调用:0。工程图读图、代码编写、执行检查与修复由当前会话完成。 {E(readings[case]["body"])} {E(jobstate.get("status"))} · {jobstate.get("calls",0)} 次 API 尝试 · {jobstate.get("elapsed_s",0)} 秒 {E(report.get("quality_reason","运行中;以下为已保存进度"))} 读图、建模、评审全部 Luna;两件并行。90 次尝试 / 1800 秒 / 每响应上限24000输出 tokens。 全部阶段记录 · 展开的能力调用 Python · 带校验重放入口 Codex · 主要特征已生成,细节待核验 Luna · {E(jobstate.get("status"))} Codex 包络:{E([round(v,3) for v in m["candidate_bbox_mm"]])} mm;与参考STEP的体积差:{m["volume_relative_error"]*100:.2f}%。'
if case in lm:text+=f' Luna 体积差:{lm[case]["volume_relative_error"]*100:.2f}%。'
if case=='3B':text+=' 3B求交指标未通过材料点一致性核验,不提供可置信IoU。'
else:
text+=f' Codex 正交配准体积IoU:{m["best_axis_aligned_volume_iou"]:.3f}。'
audits=read_json(root/'luna_metric_audit.json',{})
if case in lm and audits.get(case,{}).get('sanity_check_passed'):text+=f' Luna:{lm[case]["best_axis_aligned_volume_iou"]:.3f}。'
text+=' 体积差和IoU都不是还原准确率,也不替代特征核对。 Codex:已导出有效单实体;细节仍待核验 {E(c["notes"])} Luna:{E(p["status"])} 工具调用 {p["tool_calls"]};返回拒绝 {p["tool_errors"]};正式提交 {p["submissions"]};正式评审失败 {p["review_failures"]};失败后新候选 {p["repair_candidates"]} 尚无本阶段正式候选。 Codex STEP · Codex STL'
if report:text+=f' · Luna STEP · Luna STL'
text+='{case}
Codex 当前会话
'+''.join('
假设与未完成项
'+''.join('
GPT-5.6 Luna · 项目 API
'+label+'
'+E(json.dumps(b,ensure_ascii=False,indent=2))+'
输入的两张工程图
'
for suffix in ['1','2']:
name=case.lower()+suffix+'.png';shutil.copy2(Path('/Users/jerry/Downloads')/name,assets/name)
text+=f''
text+='
当前结果预览

'
text+='{label}

正视 / 俯视 / 右视
'+''.join(f'
' for v in ['front','top','side'])+'逐次操作 / 参数 / 反馈
'+E(json.dumps([t for t in trace['tools'] if t['stage']==stage],ensure_ascii=False,indent=2))+'
Codex 修复记录
'+E(json.dumps(readings[case]['repairs'],ensure_ascii=False,indent=2))+'
'
if case=='3B':text+=''
text+=f'
新实验:仅 Luna 调用项目 API;GPT-6 由当前 Codex 会话操作程序。两边最终都经过 CADmind 能力库和 build123d。