"""ADW Orchestrator: Run all 6 phases. ZTE mode auto-ships to factory."""
import json, sys, subprocess
aid = sys.argv[sys.argv.index("--adw-id")+1] if "--adw-id" in sys.argv else "test"
zte = "--zte" in sys.argv
phases = ["plan","build","test","review","document","ship"]
results = []
for p in phases:
    r = subprocess.run(["python3", f"adw_modules/adw_{p}_iso.py", "--adw-id", aid], capture_output=True, text=True, timeout=300)
    results.append({"phase":p,"pass":r.returncode==0})
    if r.returncode!=0 and not zte: break
all_ok = all(r["pass"] for r in results)
print(json.dumps({"adw_id":aid,"phases":results,"shipped":all_ok}))
