Spaces:
Configuration error
Configuration error
ORION System Update 2026-05-12: Multi-Agent Discussion, KRIA Validation, Agent Refactor, DDGK->ORION Migration
da3e674 | #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| EXECUTE NOW β Execution Pipeline Starter | |
| ========================================== | |
| Liest task_queue.json, fuehrt JEDEN Task aus, speichert Ergebnis + SHA-256, | |
| aktualisiert task_queue.json (erledigt/fehlgeschlagen). | |
| Usage: | |
| python autonomous/execute_now.py # Alle Tasks | |
| python autonomous/execute_now.py --task task_001_query_esa # Einzelner Task | |
| python autonomous/execute_now.py --report # Nur Bericht anzeigen | |
| python autonomous/execute_now.py --reset # Queue zuruecksetzen | |
| """ | |
| from __future__ import annotations | |
| import json | |
| import sys | |
| import time | |
| from datetime import datetime, timezone | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| if str(ROOT) not in sys.path: | |
| sys.path.insert(0, str(ROOT)) | |
| from autonomous.execution_engine import TaskExecutor, TaskStatus | |
| from autonomous.audit_chain import AuditChain | |
| from autonomous.epistemic_state import EpistemicState | |
| def main(): | |
| import argparse | |
| parser = argparse.ArgumentParser(description="ORION Execution Pipeline β Tasks AUSFUEHREN") | |
| parser.add_argument("--task", type=str, default=None, help="Einzelnen Task ausfuehren (ID)") | |
| parser.add_argument("--report", action="store_true", help="Nur Bericht anzeigen") | |
| parser.add_argument("--reset", action="store_true", help="Task-Queue zuruecksetzen") | |
| parser.add_argument("--stop-on-error", action="store_true", help="Bei erstem Fehler stoppen") | |
| parser.add_argument("--queue", type=str, default=None, help="Pfad zur Task-Queue (default: autonomous/task_queue.json)") | |
| args = parser.parse_args() | |
| queue_path = Path(args.queue) if args.queue else ROOT / "autonomous" / "task_queue.json" | |
| # --report | |
| if args.report: | |
| if not queue_path.exists(): | |
| print(f"Keine Task-Queue gefunden: {queue_path}") | |
| sys.exit(1) | |
| # TemporΓ€ren Executor nur fΓΌr Report | |
| executor = TaskExecutor(queue_path=queue_path) | |
| print(f"\n{'='*60}") | |
| print(f" EXECUTION REPORT") | |
| print(f" Queue: {queue_path}") | |
| print(f"{'='*60}\n") | |
| try: | |
| tasks = executor.load_queue() | |
| completed = sum(1 for t in tasks if t.get("status") == "completed") | |
| failed = sum(1 for t in tasks if t.get("status") == "failed") | |
| pending = sum(1 for t in tasks if t.get("status") == "pending") | |
| skipped = sum(1 for t in tasks if t.get("status") == "skipped") | |
| running = sum(1 for t in tasks if t.get("status") == "running") | |
| print(f" Tasks gesamt: {len(tasks)}") | |
| print(f" Completed: {completed}") | |
| print(f" Failed: {failed}") | |
| print(f" Pending: {pending}") | |
| print(f" Skipped: {skipped}") | |
| print(f" Running: {running}") | |
| print() | |
| for t in tasks: | |
| tid = t.get("id", t.get("task_id", "?")) | |
| status = t.get("status", "?") | |
| ttype = t.get("type", t.get("action", "?")) | |
| icon = {"completed": "OK", "failed": "FAIL", "pending": "PEND", "skipped": "SKIP", "running": "RUN"}.get(status, status) | |
| print(f" [{icon}] {tid} ({ttype})") | |
| result = t.get("result", {}) | |
| if result.get("sha256"): | |
| print(f" SHA-256: {result['sha256'][:40]}...") | |
| if result.get("error"): | |
| print(f" ERROR: {result['error'][:120]}") | |
| print() | |
| except Exception as exc: | |
| print(f"Fehler beim Laden: {exc}") | |
| sys.exit(1) | |
| return | |
| # --reset | |
| if args.reset: | |
| if not queue_path.exists(): | |
| print(f"Keine Task-Queue gefunden: {queue_path}") | |
| sys.exit(1) | |
| data = json.loads(queue_path.read_text(encoding="utf-8")) | |
| tasks = data.get("tasks", []) if isinstance(data, dict) else data | |
| for t in tasks: | |
| t["status"] = "pending" | |
| t.pop("result", None) | |
| t.pop("started_at", None) | |
| t.pop("completed_at", None) | |
| executor = TaskExecutor(queue_path=queue_path) | |
| executor.save_queue(tasks) | |
| print(f"Task-Queue zurueckgesetzt: {len(tasks)} Tasks auf pending") | |
| return | |
| # ββ Execution ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| if not queue_path.exists(): | |
| print(f"Fehler: Task-Queue nicht gefunden: {queue_path}") | |
| print(f"Erstelle leere Queue...") | |
| queue_path.write_text(json.dumps({"tasks": []}, indent=2), encoding="utf-8") | |
| sys.exit(1) | |
| # Executor initialisieren | |
| audit = AuditChain(agent_id=1, agent_name="TaskExecutor") | |
| epistemic = EpistemicState(agent_id=1, agent_name="TaskExecutor") | |
| executor = TaskExecutor( | |
| queue_path=queue_path, | |
| audit_chain=audit, | |
| epistemic=epistemic, | |
| agent_id=1, | |
| agent_name="TaskExecutor", | |
| ) | |
| start_time = time.monotonic() | |
| if args.task: | |
| # Einzelnen Task ausfΓΌhren | |
| print(f"\n FΓΌhre einzelnen Task aus: {args.task}") | |
| try: | |
| result = executor.execute_single(args.task) | |
| print(f" Status: {result.status.value}") | |
| if result.sha256: | |
| print(f" SHA-256: {result.sha256}") | |
| if result.error: | |
| print(f" ERROR: {result.error}") | |
| except ValueError as exc: | |
| print(f" Task nicht gefunden: {exc}") | |
| sys.exit(1) | |
| else: | |
| # Alle Tasks ausfΓΌhren | |
| results = executor.execute_all(stop_on_error=args.stop_on_error) | |
| elapsed = (time.monotonic() - start_time) * 1000 | |
| # Abschlussbericht | |
| report = executor.get_report() | |
| report["elapsed_ms"] = round(elapsed, 1) | |
| report_path = ROOT / "output" / f"execution_report_{datetime.now().strftime('%Y-%m-%d')}.json" | |
| report_path.parent.mkdir(parents=True, exist_ok=True) | |
| report_path.write_text(json.dumps(report, indent=2, ensure_ascii=False), encoding="utf-8") | |
| print(f" Report gespeichert: {report_path}") | |
| # Audit speichern | |
| audit.save() | |
| # Exit-Code | |
| failed = sum(1 for r in report["results"] if r["status"] == "failed") | |
| sys.exit(1 if failed > 0 else 0) | |
| if __name__ == "__main__": | |
| main() | |