diff --git a/orchestrator.py b/orchestrator.py index 87743e9..0cac23f 100644 --- a/orchestrator.py +++ b/orchestrator.py @@ -48,10 +48,20 @@ def run_pipeline(cfg: Config, cpath: str, cbl: str, java: str, map_path: str) -> if vr.llm_cost > cfg.max_llm_cost: return _done(vr, t0, "BLOCKED", 3) - # ── Phase 1+2: cobol_testgen + HINA Agent + 策略 Agent + 质量门禁 ── + # ── Phase 1+2: cobol_testgen + HINA Agent + 策略 Agent + 质量门禁 ── try: cobol_src_text = Path(cbl).read_text(encoding="utf-8") - structure = extract_structure(cobol_src_text) + structure = extract_structure(cobol_src_text, source_dir=str(Path(cbl).parent)) + + # cobol_testgen 路径枚举 + 基础数据生成 + base_records = generate_data(cobol_src_text, structure, source_dir=str(Path(cbl).parent)) + vr.debug["cobol_testgen_records"] = len(base_records) + vr.debug["total_branches"] = structure.get("total_branches", 0) + + # 转换为 TestCase 列表(增强管线的基础数据集) + complete_tests = [] + for i, rec in enumerate(base_records): + complete_tests.append(TestCase(id=f"CTG-{i+1:04d}", fields=dict(rec))) # HINA Agent 类型判定 hina_result = {} @@ -68,18 +78,13 @@ def run_pipeline(cfg: Config, cpath: str, cbl: str, java: str, map_path: str) -> vr.debug["hina_agent_error"] = str(e) logger.warning(f"[orchestrator] HINA Agent 判定失败: {e}") - # cobol_testgen 路径枚举 + 基础数据生成 - base_records = generate_data(cobol_src_text, structure) - vr.debug["cobol_testgen_records"] = len(base_records) - vr.debug["total_branches"] = structure.get("total_branches", 0) - - base_testcases = [] - for i, rec in enumerate(base_records): - base_testcases.append(TestCase(id=f"CTG-{i+1:04d}", fields=dict(rec))) - - # 策略 Agent 补充 - strategy_tests = strategy_supplement(base_testcases, hina_result) - complete_tests = base_testcases + strategy_tests + # 策略 Agent 补充(追加标记记录,统一为 TestCase 格式) + for m in strategy_supplement([], hina_result): + complete_tests.append(TestCase( + id=m.get("id", f"STG-{len(complete_tests)+1:04d}"), + fields=m.get("fields", {}), + coverage_targets=m.get("coverage_targets", []), + )) # 质量门禁循环 cov = check_coverage(structure, base_records) @@ -95,11 +100,17 @@ def run_pipeline(cfg: Config, cpath: str, cbl: str, java: str, map_path: str) -> if gaps and structure.get("branch_tree_obj"): delta = incremental_supplement(structure["branch_tree_obj"], gaps) base_records.extend(delta) + # 同步更新 complete_tests + for i, d in enumerate(delta): + complete_tests.append(TestCase( + id=f"CTG-S{attempt+1}-{i+1:04d}", + fields=dict(d), + )) cov = check_coverage(structure, base_records) else: break - vr.paragraph_rate = cov.get("paragraph_rate", 0.0) + vr.paragraph_rate = 0.0 # Phase 3 通过 gcov 获取精确值 vr.branch_rate = cov.get("branch_rate", 0.0) vr.decision_rate = cov.get("decision_rate", 0.0) @@ -112,6 +123,7 @@ def run_pipeline(cfg: Config, cpath: str, cbl: str, java: str, map_path: str) -> suite = Agent2Data(llm).design(tree, cfg.coverage_default, cfg.runner_mode == "spark") vr.llm_cost += 0.002 + suite.test_cases = complete_tests # 替换为增强管线数据(P1/P2 修复) vr.debug["test_cases"] = [{"id":tc.id,"fields":tc.fields,"targets":tc.coverage_targets} for tc in suite.test_cases] vr.debug["spark_config"] = {"records":suite.spark_config.num_records} if suite.has_spark else None diff --git a/report/generator.py b/report/generator.py index caee157..c581177 100644 --- a/report/generator.py +++ b/report/generator.py @@ -95,6 +95,11 @@ table{{border-collapse:collapse}} td,th{{padding:6px 12px}} def generate_machine_json(self, run: VerificationRun, p: Path) -> Path: d = {"program": run.program, "status": run.status, "exit_code": run.exit_code, - "timestamp": run.timestamp, "duration_s": run.duration_s, "runner": run.runner} + "timestamp": run.timestamp, "duration_s": run.duration_s, "runner": run.runner, + "branch_rate": run.branch_rate, "paragraph_rate": run.paragraph_rate, + "decision_rate": run.decision_rate, "quality_score": run.quality_score, + "hina_type": run.hina_type, "hina_confidence": run.hina_confidence, + "heal_retry": run.heal_retry, "simple_retry": run.simple_retry, + "total_retry": run.total_retry} p.write_text(json.dumps(d)) return p