letitloop 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- letitloop-0.2.0.dist-info/METADATA +232 -0
- letitloop-0.2.0.dist-info/RECORD +175 -0
- letitloop-0.2.0.dist-info/WHEEL +5 -0
- letitloop-0.2.0.dist-info/entry_points.txt +4 -0
- letitloop-0.2.0.dist-info/licenses/LICENSE +21 -0
- letitloop-0.2.0.dist-info/top_level.txt +1 -0
- orchestrator/SKILL.md +292 -0
- orchestrator/__init__.py +151 -0
- orchestrator/anti_ouroboros.py +78 -0
- orchestrator/approval.py +139 -0
- orchestrator/ast_node_splicer.py +130 -0
- orchestrator/ast_splicer.py +94 -0
- orchestrator/audit.py +88 -0
- orchestrator/budget.py +195 -0
- orchestrator/checkpoint.py +248 -0
- orchestrator/cli.py +1971 -0
- orchestrator/codebase_introspector.py +66 -0
- orchestrator/component_slicer.py +185 -0
- orchestrator/config.py +152 -0
- orchestrator/contract.py +404 -0
- orchestrator/dag_validator.py +172 -0
- orchestrator/elasticity_governor.py +80 -0
- orchestrator/env_doctor.py +166 -0
- orchestrator/errors.py +211 -0
- orchestrator/events.py +120 -0
- orchestrator/evidence.py +203 -0
- orchestrator/exceptions.py +37 -0
- orchestrator/experimental/arena_arbiter.py +260 -0
- orchestrator/experimental/fuzz_engine.py +206 -0
- orchestrator/experimental/mutation_tester.py +382 -0
- orchestrator/failure.py +226 -0
- orchestrator/fast_sandbox.py +126 -0
- orchestrator/feasibility_gate.py +115 -0
- orchestrator/feedback.py +302 -0
- orchestrator/fixtures/__init__.py +0 -0
- orchestrator/fixtures/example_contract.json +50 -0
- orchestrator/fixtures/generated/evidence-cli-run-test-step-1.json +47 -0
- orchestrator/fixtures/generated/evidence-cli-run-test-step-2.json +47 -0
- orchestrator/fixtures/generated/evidence-inject-test-a.json +47 -0
- orchestrator/fixtures/generated/evidence-inject-test-b.json +47 -0
- orchestrator/fixtures/generated/evidence-inject-test-c.json +47 -0
- orchestrator/fixtures/generated/evidence-json-test-a.json +47 -0
- orchestrator/fixtures/generated/evidence-json-test-b.json +47 -0
- orchestrator/fixtures/generated/fail-report-fail-task-1.json +47 -0
- orchestrator/fixtures/generated/fail-report-json-task-1.json +47 -0
- orchestrator/fixtures/generated/fail-report-success-task-1.json +47 -0
- orchestrator/fixtures/generated/fuzz-engine-design.json +63 -0
- orchestrator/fixtures/generated/fuzz-engine-impl.json +62 -0
- orchestrator/fixtures/generated/fuzz-engine-tests.json +62 -0
- orchestrator/fixtures/generated/fuzz-engine-verify.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-1.json +63 -0
- orchestrator/fixtures/generated/goal-orch-step-2.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-3.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-4.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-5.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-6.json +63 -0
- orchestrator/fixtures/generated/implement-a-thread-safe-token-bucket-rat-task-1.json +53 -0
- orchestrator/fixtures/generated/orchestrator-checkpoint-rollback-3.json +63 -0
- orchestrator/fixtures/generated/orchestrator-checkpoint-rollback.json +62 -0
- orchestrator/fixtures/generated/orchestrator-live-telemetry-2.json +62 -0
- orchestrator/fixtures/generated/orchestrator-live-telemetry.json +62 -0
- orchestrator/fixtures/generated/orchestrator-spec-synthesis-1.json +62 -0
- orchestrator/fixtures/generated/orchestrator-spec-synthesis.json +62 -0
- orchestrator/fixtures/generated/orchestrator-test-verification-4.json +62 -0
- orchestrator/fixtures/generated/orchestrator-test-verification.json +62 -0
- orchestrator/fixtures/generated/perf-step-1.json +61 -0
- orchestrator/fixtures/generated/perf-step-2.json +62 -0
- orchestrator/fixtures/generated/perf-step-3.json +62 -0
- orchestrator/fixtures/generated/perf-step-4.json +62 -0
- orchestrator/fixtures/generated/perf-step-5.json +63 -0
- orchestrator/fixtures/generated/phase2-proof-two-step-step-1.json +47 -0
- orchestrator/fixtures/generated/phase2-proof-two-step-step-2.json +47 -0
- orchestrator/fixtures/generated/planner-spec-synthesis-impl.json +59 -0
- orchestrator/fixtures/generated/self-evolution-ast-formatter.json +69 -0
- orchestrator/fixtures/generated/self-evolution-checkpoint-rollback.json +70 -0
- orchestrator/fixtures/generated/self-evolution-spec-synthesis.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-1.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-2.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-3.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-4.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-5.json +65 -0
- orchestrator/fixtures/generated/self-evolution-telemetry.json +70 -0
- orchestrator/fixtures/generated/self-evolution-tests.json +71 -0
- orchestrator/fixtures/generated/spec-telemetry-research-design.json +64 -0
- orchestrator/fixtures/generated/spec-telemetry-step-1.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-step-2.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-step-3.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-step-4.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-step-5.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-verification.json +58 -0
- orchestrator/fixtures/generated/token-bucket-impl.json +69 -0
- orchestrator/fixtures/generated/token-bucket-step-1.json +70 -0
- orchestrator/fixtures/generated/token-bucket-step-2.json +70 -0
- orchestrator/fixtures/generated/token-bucket-step-3.json +60 -0
- orchestrator/fixtures/generated/token-bucket-tests.json +70 -0
- orchestrator/fixtures/generated/token-bucket-verify.json +61 -0
- orchestrator/fixtures/generated/trace-ux-tests-step-1.json +64 -0
- orchestrator/fixtures/generated/trace-ux-tests-step-2.json +64 -0
- orchestrator/fixtures/generated/trace-ux-tests-step-3.json +62 -0
- orchestrator/fixtures/generated/tui-live-telemetry-impl.json +59 -0
- orchestrator/fixtures/phase1_proof_escalation_contract.json +41 -0
- orchestrator/fixtures/phase1_proof_happy_path_contract.json +83 -0
- orchestrator/fixtures/phase1_proof_qc_contract.json +41 -0
- orchestrator/fixtures/phase1_proof_repair_contract.json +41 -0
- orchestrator/fixtures/phase2_proof_two_step_goal.json +15 -0
- orchestrator/fixtures/run_proofs.py +299 -0
- orchestrator/fixtures/test_normalizer.py +16 -0
- orchestrator/generator.py +239 -0
- orchestrator/goal.py +245 -0
- orchestrator/handoff.py +86 -0
- orchestrator/hybrid_worker.py +840 -0
- orchestrator/impossibility.py +162 -0
- orchestrator/limits.py +60 -0
- orchestrator/live_evolution_engine.py +247 -0
- orchestrator/llm.py +291 -0
- orchestrator/local_tool_calling.py +285 -0
- orchestrator/lock.py +404 -0
- orchestrator/mcp_client.py +571 -0
- orchestrator/mcp_server.py +344 -0
- orchestrator/memory_bridge.py +182 -0
- orchestrator/metrics.py +159 -0
- orchestrator/micro_epoch.py +42 -0
- orchestrator/models.py +350 -0
- orchestrator/parsing.py +237 -0
- orchestrator/patch_applier.py +154 -0
- orchestrator/plan_preview.py +138 -0
- orchestrator/plan_quality.py +357 -0
- orchestrator/planner.py +532 -0
- orchestrator/preferences.py +115 -0
- orchestrator/preflight.py +141 -0
- orchestrator/process_guard.py +357 -0
- orchestrator/prometheus_exporter.py +207 -0
- orchestrator/prompts.py +275 -0
- orchestrator/proposal_ledger.py +194 -0
- orchestrator/provenance.py +263 -0
- orchestrator/provider_scheduler.py +394 -0
- orchestrator/qc/__init__.py +153 -0
- orchestrator/qc/aggregator.py +330 -0
- orchestrator/qc/parsing.py +287 -0
- orchestrator/qc/personas.py +242 -0
- orchestrator/qc/runner.py +569 -0
- orchestrator/qc_overrule.py +87 -0
- orchestrator/qc_review.py +282 -0
- orchestrator/quality_lenses.py +314 -0
- orchestrator/quality_plan.py +449 -0
- orchestrator/quality_plane.py +103 -0
- orchestrator/reconcile.py +191 -0
- orchestrator/replanner.py +433 -0
- orchestrator/research.py +176 -0
- orchestrator/review_artifact.py +672 -0
- orchestrator/safety.py +271 -0
- orchestrator/schemas.py +230 -0
- orchestrator/scope.py +466 -0
- orchestrator/sensory_radar.py +79 -0
- orchestrator/skill_installer.py +140 -0
- orchestrator/sse_server.py +160 -0
- orchestrator/state.py +871 -0
- orchestrator/subprocess_helper.py +131 -0
- orchestrator/supervisor/__init__.py +184 -0
- orchestrator/supervisor/_shared.py +164 -0
- orchestrator/supervisor/cleanup.py +185 -0
- orchestrator/supervisor/core.py +1680 -0
- orchestrator/supervisor/recovery.py +367 -0
- orchestrator/supervisor/reporting.py +251 -0
- orchestrator/surgical_extractor.py +119 -0
- orchestrator/telemetry.py +61 -0
- orchestrator/templates.py +268 -0
- orchestrator/token_gate.py +245 -0
- orchestrator/tui.py +649 -0
- orchestrator/verifier.py +1103 -0
- orchestrator/webhooks.py +168 -0
- orchestrator/worker.py +469 -0
- orchestrator/worker_adapters.py +815 -0
- orchestrator/worker_pool.py +121 -0
- orchestrator/worktree.py +364 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"""Server-Sent Events HTTP server streaming orchestrator events to local clients."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import queue
|
|
5
|
+
import threading
|
|
6
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
7
|
+
from typing import Any, Dict, Optional
|
|
8
|
+
|
|
9
|
+
from .events import EventBus, get_bus
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SSEServer:
|
|
13
|
+
"""Minimal SSE server exposing GET /events and GET /health.
|
|
14
|
+
|
|
15
|
+
A single bus subscription (created in start()) fans each event envelope out
|
|
16
|
+
into a per-connection queue; every connection thread writes SSE frames and
|
|
17
|
+
keepalive comments independently.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
HEARTBEAT_SECONDS = 15.0
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
host: str = "127.0.0.1",
|
|
25
|
+
port: int = 8080,
|
|
26
|
+
bus: Optional[EventBus] = None,
|
|
27
|
+
) -> None:
|
|
28
|
+
self.host = host
|
|
29
|
+
self.port = port
|
|
30
|
+
self.bus = bus if bus is not None else get_bus()
|
|
31
|
+
self.bound_port: Optional[int] = None
|
|
32
|
+
self._clients: Dict[int, "queue.Queue[Dict[str, Any]]"] = {}
|
|
33
|
+
self._lock = threading.Lock()
|
|
34
|
+
self._server: Optional[ThreadingHTTPServer] = None
|
|
35
|
+
self._thread: Optional[threading.Thread] = None
|
|
36
|
+
self._unsubscribe: Optional[Any] = None
|
|
37
|
+
outer = self
|
|
38
|
+
|
|
39
|
+
class Handler(BaseHTTPRequestHandler):
|
|
40
|
+
protocol_version = "HTTP/1.1"
|
|
41
|
+
|
|
42
|
+
def do_GET(self) -> None:
|
|
43
|
+
try:
|
|
44
|
+
if self.path == "/health":
|
|
45
|
+
body = b"ok"
|
|
46
|
+
self.send_response(200)
|
|
47
|
+
self.send_header("Content-Type", "text/plain")
|
|
48
|
+
self.send_header("Content-Length", str(len(body)))
|
|
49
|
+
self.end_headers()
|
|
50
|
+
self.wfile.write(body)
|
|
51
|
+
elif self.path == "/events":
|
|
52
|
+
outer._stream_events(self)
|
|
53
|
+
else:
|
|
54
|
+
self.send_response(404)
|
|
55
|
+
self.send_header("Content-Length", "0")
|
|
56
|
+
self.end_headers()
|
|
57
|
+
except (BrokenPipeError, ConnectionAbortedError, OSError):
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
def log_message(self, format: str, *args: Any) -> None:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
self._handler_cls = Handler
|
|
64
|
+
|
|
65
|
+
def start(self) -> None:
|
|
66
|
+
"""Bind the server, subscribe to the bus, and serve in a daemon thread."""
|
|
67
|
+
if self._thread is not None:
|
|
68
|
+
return
|
|
69
|
+
self._server = ThreadingHTTPServer((self.host, self.port), self._handler_cls)
|
|
70
|
+
self.bound_port = int(self._server.server_address[1])
|
|
71
|
+
fan_out = self._client_queues
|
|
72
|
+
self._unsubscribe = self.bus.subscribe(lambda env: fan_out(env))
|
|
73
|
+
self._thread = threading.Thread(
|
|
74
|
+
target=self._server.serve_forever,
|
|
75
|
+
kwargs={"poll_interval": 0.2},
|
|
76
|
+
daemon=True,
|
|
77
|
+
)
|
|
78
|
+
self._thread.start()
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def client_count(self) -> int:
|
|
82
|
+
"""Number of currently connected /events streams."""
|
|
83
|
+
with self._lock:
|
|
84
|
+
return len(self._clients)
|
|
85
|
+
|
|
86
|
+
def _client_queues(self, envelope: Dict[str, Any]) -> None:
|
|
87
|
+
with self._lock:
|
|
88
|
+
queues = list(self._clients.values())
|
|
89
|
+
for q in queues:
|
|
90
|
+
try:
|
|
91
|
+
q.put(envelope, block=False)
|
|
92
|
+
except queue.Full:
|
|
93
|
+
# Slow reader: drop the oldest envelope to make room for the freshest.
|
|
94
|
+
try:
|
|
95
|
+
q.get(block=False)
|
|
96
|
+
except queue.Empty:
|
|
97
|
+
pass
|
|
98
|
+
try:
|
|
99
|
+
q.put(envelope, block=False)
|
|
100
|
+
except queue.Full:
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
def shutdown(self) -> None:
|
|
104
|
+
"""Unsubscribe from the bus and stop serving; safe to call once after start."""
|
|
105
|
+
if self._unsubscribe is not None:
|
|
106
|
+
self._unsubscribe()
|
|
107
|
+
self._unsubscribe = None
|
|
108
|
+
server = self._server
|
|
109
|
+
thread = self._thread
|
|
110
|
+
self._server = None
|
|
111
|
+
self._thread = None
|
|
112
|
+
if server is not None:
|
|
113
|
+
server.shutdown()
|
|
114
|
+
if thread is not None:
|
|
115
|
+
thread.join(timeout=5.0)
|
|
116
|
+
server.server_close()
|
|
117
|
+
|
|
118
|
+
def _register_client(self) -> "queue.Queue[Dict[str, Any]]":
|
|
119
|
+
q: "queue.Queue[Dict[str, Any]]" = queue.Queue(maxsize=256)
|
|
120
|
+
with self._lock:
|
|
121
|
+
self._clients[id(q)] = q
|
|
122
|
+
return q
|
|
123
|
+
|
|
124
|
+
def _unregister_client(self, q: "queue.Queue[Dict[str, Any]]") -> None:
|
|
125
|
+
with self._lock:
|
|
126
|
+
self._clients.pop(id(q), None)
|
|
127
|
+
|
|
128
|
+
def _stream_events(self, handler: BaseHTTPRequestHandler) -> None:
|
|
129
|
+
q = self._register_client()
|
|
130
|
+
try:
|
|
131
|
+
handler.send_response(200)
|
|
132
|
+
handler.send_header("Content-Type", "text/event-stream")
|
|
133
|
+
handler.send_header("Cache-Control", "no-cache")
|
|
134
|
+
handler.send_header("Connection", "close")
|
|
135
|
+
handler.end_headers()
|
|
136
|
+
while True:
|
|
137
|
+
try:
|
|
138
|
+
envelope = q.get(timeout=self.HEARTBEAT_SECONDS)
|
|
139
|
+
frame = "event: {0}\ndata: {1}\n\n".format(
|
|
140
|
+
envelope.get("event", ""),
|
|
141
|
+
json.dumps(envelope, ensure_ascii=False),
|
|
142
|
+
)
|
|
143
|
+
except queue.Empty:
|
|
144
|
+
frame = ": keepalive\n\n"
|
|
145
|
+
handler.wfile.write(frame.encode("utf-8"))
|
|
146
|
+
handler.wfile.flush()
|
|
147
|
+
except (BrokenPipeError, ConnectionAbortedError, OSError):
|
|
148
|
+
pass
|
|
149
|
+
finally:
|
|
150
|
+
self._unregister_client(q)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def start_sse_server(
|
|
154
|
+
port: int = 0,
|
|
155
|
+
bus: Optional[EventBus] = None,
|
|
156
|
+
) -> SSEServer:
|
|
157
|
+
"""Convenience helper: construct and start an SSE server on an ephemeral port."""
|
|
158
|
+
server = SSEServer(port=port, bus=bus)
|
|
159
|
+
server.start()
|
|
160
|
+
return server
|