"""CLI utility to execute large-scale quantum stress harnesses. The command bootstraps the marketing intelligence engine, derives a quantum stress plan for a given prompt, and then uses the deployment harness to simulate repeated node deployments. It is designed for deterministic runs but supports Monte Carlo sampling when the operator wants additional variance. """ from __future__ import annotations import argparse import json from typing import Any from services.quantum_harness import QuantumDeploymentHarness from services.seeder_api.intelligence import ( MarketingIntelligenceEngine, MiniQuantumSimulator, QuantumSimulationProcess, ) def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description="Quantum deployment stress harness") parser.add_argument("prompt", help="Marketing or revenue prompt to evaluate") parser.add_argument( "--campaign-limit", type=int, default=3, help="Number of ranked campaigns to feed into the quantum planner", ) parser.add_argument( "--plan-limit", type=int, default=1, help="Number of quantum plans to evaluate", ) parser.add_argument( "--nodes", type=int, default=8, help="Virtual node count for deployment simulation", ) parser.add_argument( "--agents", type=int, default=1_000_000, help="Target agents per rollout scenario", ) parser.add_argument( "--iterations", type=int, default=3, help="Number of harness passes to execute", ) parser.add_argument( "--shots", type=int, default=2048, help="Shot count passed to the simulator (if supported)", ) parser.add_argument( "--monte-carlo", action="store_true", help="Enable Monte Carlo sampling instead of deterministic amplitudes", ) parser.add_argument( "--pretty", action="store_true", help="Pretty-print the JSON response", ) return parser def main(argv: list[str] | None = None) -> int: parser = build_parser() args = parser.parse_args(argv) engine = MarketingIntelligenceEngine.from_file() ranked = engine.recommend_statistical(args.prompt, limit=max(1, args.campaign_limit)) simulator = MiniQuantumSimulator(shots=max(1, args.shots)) process = QuantumSimulationProcess(simulator=simulator) plans = process.plans(args.prompt, ranked, limit=max(1, args.plan_limit)) if not plans: parser.error("No quantum plan available for the supplied prompt") harness = QuantumDeploymentHarness(simulator=simulator) payload: dict[str, Any] = { "prompt": args.prompt, "campaign_limit": args.campaign_limit, "plan_limit": args.plan_limit, "nodes": args.nodes, "target_agents": args.agents, "iterations": args.iterations, "monte_carlo": args.monte_carlo, "plans": [], } for plan in plans: harness_result = harness.stress( plan, nodes=max(1, args.nodes), target_agents=max(1, args.agents), iterations=max(1, args.iterations), shots=max(1, args.shots), monte_carlo=args.monte_carlo, ) payload["plans"].append(harness_result) if args.pretty: print(json.dumps(payload, indent=2, sort_keys=True)) else: print(json.dumps(payload)) return 0 if __name__ == "__main__": # pragma: no cover - CLI entry point raise SystemExit(main())