feat: Phase 1 - orchestrator quality gate loop + hina/gate + main CLI args
This commit is contained in:
+48
-2
@@ -1,7 +1,7 @@
|
||||
import shutil, time
|
||||
import shutil, time, logging
|
||||
from pathlib import Path
|
||||
from data.field_tree import FieldTree
|
||||
from data.test_case import TestSuite, SparkConfig
|
||||
from data.test_case import TestSuite, SparkConfig, TestCase
|
||||
from data.diff_result import VerificationRun, FieldResult
|
||||
from runners.runner import Runner
|
||||
from runners.native_java_runner import NativeJavaRunner
|
||||
@@ -18,6 +18,11 @@ from comparator.cobol_binary_reader import CobolBinaryReader
|
||||
from report.generator import ReportGenerator
|
||||
from storage.bundle import TestDataBundle
|
||||
from config import Config
|
||||
from cobol_testgen import extract_structure, generate_data, incremental_supplement
|
||||
from cobol_testgen.coverage import check_coverage
|
||||
from hina.gate import check as gate_check
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_pipeline(cfg: Config, cpath: str, cbl: str, java: str, map_path: str) -> VerificationRun:
|
||||
@@ -40,6 +45,47 @@ 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: cobol_testgen 结构提取 + 路径覆盖 + 质量门禁 ──
|
||||
try:
|
||||
cobol_src_text = Path(cbl).read_text(encoding="utf-8")
|
||||
structure = extract_structure(cobol_src_text)
|
||||
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)))
|
||||
|
||||
cov = check_coverage(structure, base_records)
|
||||
for attempt in range(cfg.max_quality_retries):
|
||||
gate_result = gate_check(
|
||||
base_testcases, {},
|
||||
cov,
|
||||
decision_threshold=cfg.quality_gate_decision_threshold,
|
||||
paragraph_threshold=cfg.quality_gate_paragraph_threshold,
|
||||
)
|
||||
if gate_result.get("passed"):
|
||||
break
|
||||
gaps = gate_result.get("issues", {}).get("decision_gaps", [])
|
||||
if gaps and structure.get("branch_tree_obj"):
|
||||
delta = incremental_supplement(structure["branch_tree_obj"], gaps)
|
||||
base_records.extend(delta)
|
||||
cov = check_coverage(structure, base_records)
|
||||
else:
|
||||
break
|
||||
|
||||
vr.paragraph_rate = cov.get("paragraph_rate", 0.0)
|
||||
vr.branch_rate = cov.get("branch_rate", 0.0)
|
||||
vr.decision_rate = cov.get("decision_rate", 0.0)
|
||||
|
||||
if cfg.quality_gate_mode != "off" and not gate_result.get("passed", True):
|
||||
vr.quality_warn = f"质量门禁未完全通过 (尝试 {attempt+1} 次)"
|
||||
vr.debug["quality_issues"] = gate_result.get("issues", {})
|
||||
except Exception as e:
|
||||
vr.debug["cobol_testgen_error"] = str(e)
|
||||
logger.warning(f"[orchestrator] cobol_testgen 分析失败: {e}")
|
||||
|
||||
suite = Agent2Data(llm).design(tree, cfg.coverage_default, cfg.runner_mode == "spark")
|
||||
vr.llm_cost += 0.002
|
||||
vr.debug["test_cases"] = [{"id":tc.id,"fields":tc.fields,"targets":tc.coverage_targets} for tc in suite.test_cases]
|
||||
|
||||
Reference in New Issue
Block a user