Files
cobol-java-v3/test_pipeline.py
hangshuo652 bc1d56d1a4 feat: Phase 2 complete — 13 Phases of COBOL type classification and test benchmark
P0.6: gcov infrastructure
P1: extract_structure output expansion (11 new feature fields)
P2: Confusion group rule engine (8 pairs + contradiction + backtrack)
P3: 4-factor confidence calculation + quality gate update
P4: 33+2 COBOL program type test samples (22 files, 7 categories)
P5: parametrized/ test data generation engine
P6: japanese_data.py lookup tables
P7-10: Type-specific test suites (~159 parametrized tests)
P11: Full classification pipeline (classify_program) + orchestrator integration
P12: Documentation (module-interfaces, test-plan v3.0, coverage-matrix)

Architecture decisions:
- classification_pipeline/ merged to hina/pipeline/
- parametrized/ as independent module
- japanese_data.py as root-level file
- hina/__all__ only exports classify_program()

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-19 23:51:55 +08:00

53 lines
1.8 KiB
Python

import json, os, sys, traceback
sys.path.insert(0, ".")
os.environ["LLM_API_KEY"] = "sk-ca4961087c7f4aefa8ed0fc6f3d02329"
os.environ["LLM_API_BASE"] = "https://api.deepseek.com/v1"
from config import Config
from orchestrator import run_pipeline
cfg = Config()
cfg.llm_model = "deepseek-chat"
cfg.runner_mode = "native"
print("STEP 1: Reading copybook...")
cp = "uploads/ec17bf32/copybook.cpy"
with open(cp) as f:
text = f.read()
print(f" Copybook text ({len(text)} chars):\n{text}")
print("\nSTEP 2: Agent1Parser (LLM)...")
from agents.agent1_parser import Agent1Parser
from agents.llm import LLMClient
try:
llm = LLMClient(model="deepseek-chat", timeout=30)
tree = Agent1Parser(llm).parse(text)
fields = tree.flatten()
print(f" Fields parsed: {list(fields.keys())}")
for name, f in fields.items():
print(f" {name}: level={f.level}, pic={f.pic}, usage={f.usage}, offset={f.offset}, len={f.length}")
except Exception as e:
print(f" ERROR: {e}")
traceback.print_exc()
print("\nSTEP 3: Full orchestrator...")
try:
vr = run_pipeline(cfg, cp, "uploads/ec17bf32/program.cbl",
"uploads/ec17bf32/java", "uploads/ec17bf32/mapping.yaml")
print(f" Status: {vr.status} (exit_code={vr.exit_code})")
print(f" Program: {vr.program}")
print(f" Matched: {vr.fields_matched}")
print(f" Mismatched: {vr.fields_mismatched}")
print(f" Duration: {vr.duration_s:.1f}s")
print(f" Debug keys: {list(vr.debug.keys())}")
print(f" Debug details:")
for k, v in vr.debug.items():
if v:
if isinstance(v, dict):
print(f" {k}: {'OK' if v.get('ok') else 'FAIL'} {str(v.get('log',''))[-200:]}")
else:
print(f" {k}: {v}")
except Exception as e:
print(f" ERROR: {e}")
traceback.print_exc()