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.
Files changed (175) hide show
  1. letitloop-0.2.0.dist-info/METADATA +232 -0
  2. letitloop-0.2.0.dist-info/RECORD +175 -0
  3. letitloop-0.2.0.dist-info/WHEEL +5 -0
  4. letitloop-0.2.0.dist-info/entry_points.txt +4 -0
  5. letitloop-0.2.0.dist-info/licenses/LICENSE +21 -0
  6. letitloop-0.2.0.dist-info/top_level.txt +1 -0
  7. orchestrator/SKILL.md +292 -0
  8. orchestrator/__init__.py +151 -0
  9. orchestrator/anti_ouroboros.py +78 -0
  10. orchestrator/approval.py +139 -0
  11. orchestrator/ast_node_splicer.py +130 -0
  12. orchestrator/ast_splicer.py +94 -0
  13. orchestrator/audit.py +88 -0
  14. orchestrator/budget.py +195 -0
  15. orchestrator/checkpoint.py +248 -0
  16. orchestrator/cli.py +1971 -0
  17. orchestrator/codebase_introspector.py +66 -0
  18. orchestrator/component_slicer.py +185 -0
  19. orchestrator/config.py +152 -0
  20. orchestrator/contract.py +404 -0
  21. orchestrator/dag_validator.py +172 -0
  22. orchestrator/elasticity_governor.py +80 -0
  23. orchestrator/env_doctor.py +166 -0
  24. orchestrator/errors.py +211 -0
  25. orchestrator/events.py +120 -0
  26. orchestrator/evidence.py +203 -0
  27. orchestrator/exceptions.py +37 -0
  28. orchestrator/experimental/arena_arbiter.py +260 -0
  29. orchestrator/experimental/fuzz_engine.py +206 -0
  30. orchestrator/experimental/mutation_tester.py +382 -0
  31. orchestrator/failure.py +226 -0
  32. orchestrator/fast_sandbox.py +126 -0
  33. orchestrator/feasibility_gate.py +115 -0
  34. orchestrator/feedback.py +302 -0
  35. orchestrator/fixtures/__init__.py +0 -0
  36. orchestrator/fixtures/example_contract.json +50 -0
  37. orchestrator/fixtures/generated/evidence-cli-run-test-step-1.json +47 -0
  38. orchestrator/fixtures/generated/evidence-cli-run-test-step-2.json +47 -0
  39. orchestrator/fixtures/generated/evidence-inject-test-a.json +47 -0
  40. orchestrator/fixtures/generated/evidence-inject-test-b.json +47 -0
  41. orchestrator/fixtures/generated/evidence-inject-test-c.json +47 -0
  42. orchestrator/fixtures/generated/evidence-json-test-a.json +47 -0
  43. orchestrator/fixtures/generated/evidence-json-test-b.json +47 -0
  44. orchestrator/fixtures/generated/fail-report-fail-task-1.json +47 -0
  45. orchestrator/fixtures/generated/fail-report-json-task-1.json +47 -0
  46. orchestrator/fixtures/generated/fail-report-success-task-1.json +47 -0
  47. orchestrator/fixtures/generated/fuzz-engine-design.json +63 -0
  48. orchestrator/fixtures/generated/fuzz-engine-impl.json +62 -0
  49. orchestrator/fixtures/generated/fuzz-engine-tests.json +62 -0
  50. orchestrator/fixtures/generated/fuzz-engine-verify.json +62 -0
  51. orchestrator/fixtures/generated/goal-orch-step-1.json +63 -0
  52. orchestrator/fixtures/generated/goal-orch-step-2.json +62 -0
  53. orchestrator/fixtures/generated/goal-orch-step-3.json +62 -0
  54. orchestrator/fixtures/generated/goal-orch-step-4.json +62 -0
  55. orchestrator/fixtures/generated/goal-orch-step-5.json +62 -0
  56. orchestrator/fixtures/generated/goal-orch-step-6.json +63 -0
  57. orchestrator/fixtures/generated/implement-a-thread-safe-token-bucket-rat-task-1.json +53 -0
  58. orchestrator/fixtures/generated/orchestrator-checkpoint-rollback-3.json +63 -0
  59. orchestrator/fixtures/generated/orchestrator-checkpoint-rollback.json +62 -0
  60. orchestrator/fixtures/generated/orchestrator-live-telemetry-2.json +62 -0
  61. orchestrator/fixtures/generated/orchestrator-live-telemetry.json +62 -0
  62. orchestrator/fixtures/generated/orchestrator-spec-synthesis-1.json +62 -0
  63. orchestrator/fixtures/generated/orchestrator-spec-synthesis.json +62 -0
  64. orchestrator/fixtures/generated/orchestrator-test-verification-4.json +62 -0
  65. orchestrator/fixtures/generated/orchestrator-test-verification.json +62 -0
  66. orchestrator/fixtures/generated/perf-step-1.json +61 -0
  67. orchestrator/fixtures/generated/perf-step-2.json +62 -0
  68. orchestrator/fixtures/generated/perf-step-3.json +62 -0
  69. orchestrator/fixtures/generated/perf-step-4.json +62 -0
  70. orchestrator/fixtures/generated/perf-step-5.json +63 -0
  71. orchestrator/fixtures/generated/phase2-proof-two-step-step-1.json +47 -0
  72. orchestrator/fixtures/generated/phase2-proof-two-step-step-2.json +47 -0
  73. orchestrator/fixtures/generated/planner-spec-synthesis-impl.json +59 -0
  74. orchestrator/fixtures/generated/self-evolution-ast-formatter.json +69 -0
  75. orchestrator/fixtures/generated/self-evolution-checkpoint-rollback.json +70 -0
  76. orchestrator/fixtures/generated/self-evolution-spec-synthesis.json +70 -0
  77. orchestrator/fixtures/generated/self-evolution-step-1.json +70 -0
  78. orchestrator/fixtures/generated/self-evolution-step-2.json +70 -0
  79. orchestrator/fixtures/generated/self-evolution-step-3.json +70 -0
  80. orchestrator/fixtures/generated/self-evolution-step-4.json +70 -0
  81. orchestrator/fixtures/generated/self-evolution-step-5.json +65 -0
  82. orchestrator/fixtures/generated/self-evolution-telemetry.json +70 -0
  83. orchestrator/fixtures/generated/self-evolution-tests.json +71 -0
  84. orchestrator/fixtures/generated/spec-telemetry-research-design.json +64 -0
  85. orchestrator/fixtures/generated/spec-telemetry-step-1.json +62 -0
  86. orchestrator/fixtures/generated/spec-telemetry-step-2.json +62 -0
  87. orchestrator/fixtures/generated/spec-telemetry-step-3.json +62 -0
  88. orchestrator/fixtures/generated/spec-telemetry-step-4.json +62 -0
  89. orchestrator/fixtures/generated/spec-telemetry-step-5.json +62 -0
  90. orchestrator/fixtures/generated/spec-telemetry-verification.json +58 -0
  91. orchestrator/fixtures/generated/token-bucket-impl.json +69 -0
  92. orchestrator/fixtures/generated/token-bucket-step-1.json +70 -0
  93. orchestrator/fixtures/generated/token-bucket-step-2.json +70 -0
  94. orchestrator/fixtures/generated/token-bucket-step-3.json +60 -0
  95. orchestrator/fixtures/generated/token-bucket-tests.json +70 -0
  96. orchestrator/fixtures/generated/token-bucket-verify.json +61 -0
  97. orchestrator/fixtures/generated/trace-ux-tests-step-1.json +64 -0
  98. orchestrator/fixtures/generated/trace-ux-tests-step-2.json +64 -0
  99. orchestrator/fixtures/generated/trace-ux-tests-step-3.json +62 -0
  100. orchestrator/fixtures/generated/tui-live-telemetry-impl.json +59 -0
  101. orchestrator/fixtures/phase1_proof_escalation_contract.json +41 -0
  102. orchestrator/fixtures/phase1_proof_happy_path_contract.json +83 -0
  103. orchestrator/fixtures/phase1_proof_qc_contract.json +41 -0
  104. orchestrator/fixtures/phase1_proof_repair_contract.json +41 -0
  105. orchestrator/fixtures/phase2_proof_two_step_goal.json +15 -0
  106. orchestrator/fixtures/run_proofs.py +299 -0
  107. orchestrator/fixtures/test_normalizer.py +16 -0
  108. orchestrator/generator.py +239 -0
  109. orchestrator/goal.py +245 -0
  110. orchestrator/handoff.py +86 -0
  111. orchestrator/hybrid_worker.py +840 -0
  112. orchestrator/impossibility.py +162 -0
  113. orchestrator/limits.py +60 -0
  114. orchestrator/live_evolution_engine.py +247 -0
  115. orchestrator/llm.py +291 -0
  116. orchestrator/local_tool_calling.py +285 -0
  117. orchestrator/lock.py +404 -0
  118. orchestrator/mcp_client.py +571 -0
  119. orchestrator/mcp_server.py +344 -0
  120. orchestrator/memory_bridge.py +182 -0
  121. orchestrator/metrics.py +159 -0
  122. orchestrator/micro_epoch.py +42 -0
  123. orchestrator/models.py +350 -0
  124. orchestrator/parsing.py +237 -0
  125. orchestrator/patch_applier.py +154 -0
  126. orchestrator/plan_preview.py +138 -0
  127. orchestrator/plan_quality.py +357 -0
  128. orchestrator/planner.py +532 -0
  129. orchestrator/preferences.py +115 -0
  130. orchestrator/preflight.py +141 -0
  131. orchestrator/process_guard.py +357 -0
  132. orchestrator/prometheus_exporter.py +207 -0
  133. orchestrator/prompts.py +275 -0
  134. orchestrator/proposal_ledger.py +194 -0
  135. orchestrator/provenance.py +263 -0
  136. orchestrator/provider_scheduler.py +394 -0
  137. orchestrator/qc/__init__.py +153 -0
  138. orchestrator/qc/aggregator.py +330 -0
  139. orchestrator/qc/parsing.py +287 -0
  140. orchestrator/qc/personas.py +242 -0
  141. orchestrator/qc/runner.py +569 -0
  142. orchestrator/qc_overrule.py +87 -0
  143. orchestrator/qc_review.py +282 -0
  144. orchestrator/quality_lenses.py +314 -0
  145. orchestrator/quality_plan.py +449 -0
  146. orchestrator/quality_plane.py +103 -0
  147. orchestrator/reconcile.py +191 -0
  148. orchestrator/replanner.py +433 -0
  149. orchestrator/research.py +176 -0
  150. orchestrator/review_artifact.py +672 -0
  151. orchestrator/safety.py +271 -0
  152. orchestrator/schemas.py +230 -0
  153. orchestrator/scope.py +466 -0
  154. orchestrator/sensory_radar.py +79 -0
  155. orchestrator/skill_installer.py +140 -0
  156. orchestrator/sse_server.py +160 -0
  157. orchestrator/state.py +871 -0
  158. orchestrator/subprocess_helper.py +131 -0
  159. orchestrator/supervisor/__init__.py +184 -0
  160. orchestrator/supervisor/_shared.py +164 -0
  161. orchestrator/supervisor/cleanup.py +185 -0
  162. orchestrator/supervisor/core.py +1680 -0
  163. orchestrator/supervisor/recovery.py +367 -0
  164. orchestrator/supervisor/reporting.py +251 -0
  165. orchestrator/surgical_extractor.py +119 -0
  166. orchestrator/telemetry.py +61 -0
  167. orchestrator/templates.py +268 -0
  168. orchestrator/token_gate.py +245 -0
  169. orchestrator/tui.py +649 -0
  170. orchestrator/verifier.py +1103 -0
  171. orchestrator/webhooks.py +168 -0
  172. orchestrator/worker.py +469 -0
  173. orchestrator/worker_adapters.py +815 -0
  174. orchestrator/worker_pool.py +121 -0
  175. orchestrator/worktree.py +364 -0
@@ -0,0 +1,66 @@
1
+ """
2
+ orchestrator/codebase_introspector.py
3
+ Min-Max Normalized UCB1 Autonomous Discovery Engine.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import math
9
+ from dataclasses import dataclass
10
+ from typing import List, Optional
11
+
12
+
13
+ @dataclass
14
+ class ModuleProfile:
15
+ path: str
16
+ symbol: str
17
+ raw_complexity: float
18
+ visits: int = 0
19
+ cooldown_remaining: int = 0
20
+ quarantined: bool = False
21
+
22
+
23
+ class NormalizedExplorationEngine:
24
+ """Selects mutation hotspots using Min-Max Normalized UCB1."""
25
+
26
+ def __init__(self, exploration_constant: float = 1.414):
27
+ self.c = exploration_constant
28
+ self.total_iterations = 0
29
+
30
+ def select_hotspot(self, modules: List[ModuleProfile]) -> Optional[ModuleProfile]:
31
+ self.total_iterations += 1
32
+ available = [m for m in modules if not m.quarantined and m.cooldown_remaining == 0]
33
+ if not available:
34
+ return None
35
+
36
+ # Min-Max Normalization of Complexity
37
+ complexities = [m.raw_complexity for m in available]
38
+ min_c = min(complexities)
39
+ max_c = max(complexities)
40
+ span = (max_c - min_c) if (max_c - min_c) > 0 else 1.0
41
+
42
+ best_score = -float("inf")
43
+ best_module = None
44
+
45
+ for m in available:
46
+ norm_complexity = (m.raw_complexity - min_c) / span
47
+ exploration_bonus = self.c * math.sqrt(math.log(self.total_iterations + 1) / (m.visits + 1))
48
+ score = norm_complexity + exploration_bonus
49
+
50
+ if score > best_score:
51
+ best_score = score
52
+ best_module = m
53
+
54
+ if best_module:
55
+ best_module.visits += 1
56
+ return best_module
57
+
58
+ def record_success(self, module: ModuleProfile, cooldown_cycles: int = 5):
59
+ """Put successfully modified module on cooldown to prevent target lock-in."""
60
+ module.cooldown_remaining = cooldown_cycles
61
+
62
+ def tick_cooldowns(self, modules: List[ModuleProfile]):
63
+ """Tick down active cooldowns across all modules."""
64
+ for m in modules:
65
+ if m.cooldown_remaining > 0:
66
+ m.cooldown_remaining -= 1
@@ -0,0 +1,185 @@
1
+ """Deterministic component slicing for the quality plane.
2
+
3
+ Splits output files into up to `max_components` groups purely by
4
+ directory structure. Zero LLM calls. Zero side effects.
5
+
6
+ A ComponentSlice groups files that share a directory root, so each
7
+ reviewer sees a coherent subset of the output.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ from typing import List, Optional
14
+
15
+
16
+ class ComponentSlice:
17
+ """A group of output files reviewed together by one reviewer.
18
+
19
+ Attributes:
20
+ id: Unique string identifier (component_0, component_1, ...).
21
+ files: File paths assigned to this component.
22
+ description: Human-readable summary of what this component covers.
23
+ total_lines: Sum of file sizes in bytes (simple stat, not git-aware).
24
+ """
25
+
26
+ def __init__(
27
+ self,
28
+ id: str,
29
+ files: List[str],
30
+ description: str = "",
31
+ total_lines: int = 0,
32
+ ):
33
+ self.id = id
34
+ self.files = sorted(files)
35
+ self.description = description
36
+ self.total_lines = total_lines
37
+
38
+ def to_dict(self) -> dict:
39
+ return {
40
+ "id": self.id,
41
+ "files": list(self.files),
42
+ "description": self.description,
43
+ "total_lines": self.total_lines,
44
+ }
45
+
46
+ @classmethod
47
+ def from_dict(cls, d: dict) -> ComponentSlice:
48
+ return cls(
49
+ id=d["id"],
50
+ files=d.get("files", []),
51
+ description=d.get("description", ""),
52
+ total_lines=d.get("total_lines", 0),
53
+ )
54
+
55
+
56
+ def _group_key(path: str) -> str:
57
+ """Return the grouping key for a file path.
58
+
59
+ - Files inside a directory: use the top-level directory name.
60
+ - Files in the working root: use the file extension (or "__root__" if no ext).
61
+ - Absolute paths: the drive letter / leading separator is stripped first,
62
+ so absolute and relative paths group identically.
63
+ """
64
+ normalised = path.replace("\\", "/")
65
+ parts = [p for p in normalised.split("/") if p]
66
+ if parts and len(parts[0]) == 2 and parts[0][1] == ":":
67
+ parts = parts[1:]
68
+ if len(parts) >= 2:
69
+ return parts[0]
70
+ _, ext = os.path.splitext(parts[0]) if parts else ("", "")
71
+ return ext if ext else "__root__"
72
+
73
+
74
+ def slice_components(
75
+ output_paths: List[str],
76
+ max_components: int = 5,
77
+ base_dir: Optional[str] = None,
78
+ ) -> List[ComponentSlice]:
79
+ """Split output files into at most *max_components* groups.
80
+
81
+ The algorithm groups files by their top-level directory, then merges
82
+ smallest groups when there are too many. Deterministic for the same
83
+ input list.
84
+
85
+ When *base_dir* is provided (e.g. the workspace root), paths are made
86
+ relative to it before grouping so absolute paths group by their
87
+ workspace-relative directory rather than the drive letter.
88
+ """
89
+ if not output_paths:
90
+ return [ComponentSlice(id="component_0", files=[], description="no files")]
91
+
92
+ # 1. Group by directory/extension key
93
+ groups: dict = {}
94
+ for p in output_paths:
95
+ if base_dir:
96
+ try:
97
+ rel = os.path.relpath(p, base_dir)
98
+ except ValueError:
99
+ # Cross-drive (Windows C: vs D:) — fall back to the raw path;
100
+ # _group_key still strips the drive letter.
101
+ rel = p
102
+ else:
103
+ rel = p
104
+ key = _group_key(rel)
105
+ groups.setdefault(key, []).append(p)
106
+
107
+ # 2. Convert to list of (key, files, total_lines) sorted by file count desc
108
+ sorted_groups = sorted(
109
+ [(key, files, _estimate_lines(files)) for key, files in groups.items()],
110
+ key=lambda x: (len(x[1]), x[0]),
111
+ reverse=True,
112
+ )
113
+
114
+ # 3. Merge smallest groups until within limit
115
+ while len(sorted_groups) > max(max_components, 1):
116
+ merged_key = sorted_groups[-1][0]
117
+ merged_files = list(sorted_groups[-1][1])
118
+ merged_lines = sorted_groups[-1][2]
119
+ del sorted_groups[-1]
120
+
121
+ target_key, target_files, target_lines = sorted_groups[-1]
122
+ sorted_groups[-1] = (
123
+ f"{target_key}+{merged_key}",
124
+ target_files + merged_files,
125
+ target_lines + merged_lines,
126
+ )
127
+
128
+ # 4. Sort final groups by file count desc, then key for stability
129
+ sorted_groups.sort(key=lambda x: (len(x[1]), x[0]), reverse=True)
130
+
131
+ # 5. Build ComponentSlice objects
132
+ components: List[ComponentSlice] = []
133
+ for i, (key, files, lines) in enumerate(sorted_groups):
134
+ desc = _describe_component(key, files)
135
+ components.append(
136
+ ComponentSlice(
137
+ id=f"component_{i}",
138
+ files=files,
139
+ description=desc,
140
+ total_lines=lines,
141
+ )
142
+ )
143
+
144
+ return components
145
+
146
+
147
+ def _estimate_lines(file_paths: List[str]) -> int:
148
+ """Estimate total lines from file paths (byte count via stat).
149
+
150
+ If a file doesn't exist or stat fails, it contributes 0 lines.
151
+ This is acceptable because the slicer is purely advisory for
152
+ grouping — line counts are a heuristic, not an audit trail.
153
+ """
154
+ total = 0
155
+ for p in file_paths:
156
+ try:
157
+ total += os.path.getsize(p)
158
+ except OSError:
159
+ pass
160
+ return total
161
+
162
+
163
+ def _describe_component(key: str, files: List[str]) -> str:
164
+ """Build a short human-readable description for a component."""
165
+ exts: set = set()
166
+ for f in files:
167
+ _, ext = os.path.splitext(f)
168
+ if ext:
169
+ exts.add(ext.lstrip("."))
170
+ ext_str = ", ".join(sorted(exts)) if exts else "no extension"
171
+ return f"{len(files)} file(s) in {key!r} ({ext_str})"
172
+
173
+
174
+ def merge_component_results(
175
+ components: List[ComponentSlice],
176
+ ) -> List[str]:
177
+ """Flatten merged component keys back into a single file list.
178
+
179
+ Useful when a component was created by merging multiple directory
180
+ groups — returns the original directory keys.
181
+ """
182
+ all_files: List[str] = []
183
+ for c in components:
184
+ all_files.extend(c.files)
185
+ return sorted(set(all_files))
orchestrator/config.py ADDED
@@ -0,0 +1,152 @@
1
+ """Centralized configuration for the orchestrator.
2
+
3
+ Supports env vars, JSON config file, and programmatic overrides.
4
+ All settings fall back to sensible defaults.
5
+ """
6
+
7
+ import json
8
+ import os
9
+ from dataclasses import asdict, dataclass, field
10
+ from typing import Any, Dict, List
11
+
12
+ from .models import ModelRegistry
13
+
14
+ WORKSPACE_ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(__file__))))
15
+ DEFAULT_RUN_DIR = os.path.join(WORKSPACE_ROOT, "scratch", "orchestrator_runs")
16
+
17
+
18
+ @dataclass
19
+ class WorkerConfig:
20
+ model: str = ModelRegistry.default_worker()
21
+ max_attempts: int = 3
22
+ timeout_sec: int = 300
23
+ max_output_size: int = 524288
24
+
25
+
26
+ @dataclass
27
+ class PoolConfig:
28
+ enabled: bool = False
29
+ max_workers: int = 3
30
+
31
+
32
+ @dataclass
33
+ class ScopeConfig:
34
+ allow: List[str] = field(default_factory=lambda: ["scratch/"])
35
+ deny: List[str] = field(default_factory=lambda: ["AGENTS.md", "memory/", ".opencode/"])
36
+
37
+
38
+ @dataclass
39
+ class QCConfig:
40
+ required: bool = False
41
+ lens: str = "code_correctness"
42
+
43
+
44
+ @dataclass
45
+ class LockConfig:
46
+ stale_timeout_sec: int = 300
47
+
48
+
49
+ @dataclass
50
+ class OrchestratorConfig:
51
+ workspace_root: str = WORKSPACE_ROOT
52
+ run_dir: str = ""
53
+ worker: WorkerConfig = field(default_factory=WorkerConfig)
54
+ pool: PoolConfig = field(default_factory=PoolConfig)
55
+ scope: ScopeConfig = field(default_factory=ScopeConfig)
56
+ qc: QCConfig = field(default_factory=QCConfig)
57
+ lock: LockConfig = field(default_factory=LockConfig)
58
+
59
+ def __post_init__(self):
60
+ if not self.run_dir:
61
+ self.run_dir = DEFAULT_RUN_DIR
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ return asdict(self)
65
+
66
+ @classmethod
67
+ def from_dict(cls, d: Dict[str, Any]) -> "OrchestratorConfig":
68
+ worker_d = d.get("worker", {})
69
+ pool_d = d.get("pool", {})
70
+ scope_d = d.get("scope", {})
71
+ qc_d = d.get("qc", {})
72
+ lock_d = d.get("lock", {})
73
+
74
+ cfg = cls(
75
+ workspace_root=d.get("workspace_root", WORKSPACE_ROOT),
76
+ run_dir=d.get("run_dir", ""),
77
+ )
78
+ cfg.worker = WorkerConfig(**worker_d) if worker_d else cfg.worker
79
+ cfg.pool = PoolConfig(**pool_d) if pool_d else cfg.pool
80
+ cfg.scope = ScopeConfig(**scope_d) if scope_d else cfg.scope
81
+ cfg.qc = QCConfig(**qc_d) if qc_d else cfg.qc
82
+ cfg.lock = LockConfig(**lock_d) if lock_d else cfg.lock
83
+ return cfg
84
+
85
+ @classmethod
86
+ def load(cls, path: str = "") -> "OrchestratorConfig":
87
+ cfg = cls()
88
+ if path and os.path.isfile(path):
89
+ try:
90
+ with open(path, "r", encoding="utf-8") as f:
91
+ data = json.load(f)
92
+ cfg = cls.from_dict(data)
93
+ except (OSError, json.JSONDecodeError):
94
+ pass
95
+
96
+ cfg._apply_env()
97
+ return cfg
98
+
99
+ def _apply_env(self):
100
+ if "ORCHESTRATOR_RUN_DIR" in os.environ:
101
+ self.run_dir = os.environ["ORCHESTRATOR_RUN_DIR"]
102
+ if "ORCHESTRATOR_MODEL" in os.environ:
103
+ self.worker.model = os.environ["ORCHESTRATOR_MODEL"]
104
+ if "ORCHESTRATOR_MAX_ATTEMPTS" in os.environ:
105
+ try:
106
+ self.worker.max_attempts = int(os.environ["ORCHESTRATOR_MAX_ATTEMPTS"])
107
+ except ValueError:
108
+ pass
109
+ if "ORCHESTRATOR_TIMEOUT" in os.environ:
110
+ try:
111
+ self.worker.timeout_sec = int(os.environ["ORCHESTRATOR_TIMEOUT"])
112
+ except ValueError:
113
+ pass
114
+ if "ORCHESTRATOR_PARALLEL" in os.environ:
115
+ val = os.environ["ORCHESTRATOR_PARALLEL"].lower()
116
+ self.pool.enabled = val in ("1", "true", "yes")
117
+ if "ORCHESTRATOR_MAX_WORKERS" in os.environ:
118
+ try:
119
+ self.pool.max_workers = int(os.environ["ORCHESTRATOR_MAX_WORKERS"])
120
+ except ValueError:
121
+ pass
122
+
123
+ def display(self) -> str:
124
+ def _fmt(v):
125
+ if isinstance(v, list):
126
+ return ", ".join(v) if v else "(none)"
127
+ return str(v)
128
+
129
+ lines = ["=== Orchestrator Configuration ==="]
130
+ lines.append(f" workspace: {self.workspace_root}")
131
+ lines.append(f" run_dir: {self.run_dir}")
132
+ lines.append("")
133
+ lines.append(" Worker:")
134
+ lines.append(f" model: {self.worker.model}")
135
+ lines.append(f" max_attempts: {self.worker.max_attempts}")
136
+ lines.append(f" timeout_sec: {self.worker.timeout_sec}")
137
+ lines.append("")
138
+ lines.append(" Pool:")
139
+ lines.append(f" enabled: {self.pool.enabled}")
140
+ lines.append(f" max_workers: {self.pool.max_workers}")
141
+ lines.append("")
142
+ lines.append(" Scope:")
143
+ lines.append(f" allow: {_fmt(self.scope.allow)}")
144
+ lines.append(f" deny: {_fmt(self.scope.deny)}")
145
+ lines.append("")
146
+ lines.append(" QC:")
147
+ lines.append(f" required: {self.qc.required}")
148
+ lines.append(f" lens: {self.qc.lens}")
149
+ lines.append("")
150
+ lines.append(" Lock:")
151
+ lines.append(f" stale_timeout: {self.lock.stale_timeout_sec}s")
152
+ return "\n".join(lines)