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
orchestrator/feedback.py
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"""Feedback loop — captures execution failures for self-healing replanning."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
from typing import Any, Dict, List, Optional
|
|
7
|
+
|
|
8
|
+
from .errors import from_failure_class
|
|
9
|
+
from .failure import classify_failure
|
|
10
|
+
from .state import State
|
|
11
|
+
|
|
12
|
+
FEEDBACK_DIR_NAME = "feedback"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FeedbackRecord:
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
task_id: str,
|
|
19
|
+
goal_id: str,
|
|
20
|
+
failure_class: str,
|
|
21
|
+
error_code: str,
|
|
22
|
+
stderr_snippet: str = "",
|
|
23
|
+
approach: str = "",
|
|
24
|
+
attempt: int = 0,
|
|
25
|
+
status: str = "",
|
|
26
|
+
):
|
|
27
|
+
self.task_id = task_id
|
|
28
|
+
self.goal_id = goal_id
|
|
29
|
+
self.failure_class = failure_class
|
|
30
|
+
self.error_code = error_code
|
|
31
|
+
self.stderr_snippet = stderr_snippet
|
|
32
|
+
self.approach = approach
|
|
33
|
+
self.attempt = attempt
|
|
34
|
+
self.status = status
|
|
35
|
+
self.timestamp = datetime.now(timezone.utc).isoformat()
|
|
36
|
+
|
|
37
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
38
|
+
return {
|
|
39
|
+
"task_id": self.task_id,
|
|
40
|
+
"goal_id": self.goal_id,
|
|
41
|
+
"failure_class": self.failure_class,
|
|
42
|
+
"error_code": self.error_code,
|
|
43
|
+
"stderr_snippet": self.stderr_snippet,
|
|
44
|
+
"approach": self.approach,
|
|
45
|
+
"attempt": self.attempt,
|
|
46
|
+
"status": self.status,
|
|
47
|
+
"timestamp": self.timestamp,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_dict(cls, d: Dict[str, Any]) -> "FeedbackRecord":
|
|
52
|
+
rec = cls(
|
|
53
|
+
task_id=d["task_id"],
|
|
54
|
+
goal_id=d.get("goal_id", ""),
|
|
55
|
+
failure_class=d.get("failure_class", "unknown"),
|
|
56
|
+
error_code=d.get("error_code", "E999"),
|
|
57
|
+
stderr_snippet=d.get("stderr_snippet", ""),
|
|
58
|
+
approach=d.get("approach", ""),
|
|
59
|
+
attempt=d.get("attempt", 0),
|
|
60
|
+
status=d.get("status", ""),
|
|
61
|
+
)
|
|
62
|
+
rec.timestamp = d.get("timestamp", rec.timestamp)
|
|
63
|
+
return rec
|
|
64
|
+
|
|
65
|
+
def __repr__(self) -> str:
|
|
66
|
+
return f"[{self.error_code}] {self.task_id}:{self.failure_class} (attempt {self.attempt})"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _feedback_path(goal_id: str, run_dir: str) -> str:
|
|
70
|
+
if run_dir.rstrip("/\\").endswith(goal_id):
|
|
71
|
+
return os.path.join(run_dir, FEEDBACK_DIR_NAME, "feedback.json")
|
|
72
|
+
return os.path.join(run_dir, goal_id, FEEDBACK_DIR_NAME, "feedback.json")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def collect_feedback(
|
|
76
|
+
task_id: str,
|
|
77
|
+
goal_id: str,
|
|
78
|
+
state: State,
|
|
79
|
+
stderr: str = "",
|
|
80
|
+
approach: str = "",
|
|
81
|
+
) -> Optional[FeedbackRecord]:
|
|
82
|
+
"""Create a FeedbackRecord from a failed task's state."""
|
|
83
|
+
if state.is_terminal() and state.status not in ("COMPLETE", "complete", "VERIFIED", "QC_PASSED"):
|
|
84
|
+
fclass = state.data.get("last_failure_class", "") or classify_failure(state)
|
|
85
|
+
err = from_failure_class(fclass, task_id=task_id)
|
|
86
|
+
from .qc_review import _redact_secrets
|
|
87
|
+
|
|
88
|
+
snippet = _redact_secrets((stderr or "")[:200])
|
|
89
|
+
return FeedbackRecord(
|
|
90
|
+
task_id=task_id,
|
|
91
|
+
goal_id=goal_id,
|
|
92
|
+
failure_class=fclass,
|
|
93
|
+
error_code=err.code,
|
|
94
|
+
stderr_snippet=snippet,
|
|
95
|
+
approach=approach,
|
|
96
|
+
attempt=state.attempt,
|
|
97
|
+
status=state.status,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
if state.status in ("VERIFICATION_FAILED", "PREFLIGHT_FAILED", "BLOCKED", "ESCALATED", "RETRY_PENDING"):
|
|
101
|
+
fclass = state.data.get("last_failure_class", "") or classify_failure(state)
|
|
102
|
+
err = from_failure_class(fclass, task_id=task_id)
|
|
103
|
+
if state.worker_results:
|
|
104
|
+
last = state.worker_results[-1]
|
|
105
|
+
from .qc_review import _redact_secrets
|
|
106
|
+
|
|
107
|
+
raw_snip = (last.get("stderr", "") or last.get("stdout", "") or "")[:200]
|
|
108
|
+
snippet = _redact_secrets(raw_snip)
|
|
109
|
+
else:
|
|
110
|
+
snippet = ""
|
|
111
|
+
return FeedbackRecord(
|
|
112
|
+
task_id=task_id,
|
|
113
|
+
goal_id=goal_id,
|
|
114
|
+
failure_class=fclass,
|
|
115
|
+
error_code=err.code,
|
|
116
|
+
stderr_snippet=snippet,
|
|
117
|
+
approach=approach,
|
|
118
|
+
attempt=state.attempt,
|
|
119
|
+
status=state.status,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
return None
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def store_feedback(goal_id: str, run_dir: str, records: List[FeedbackRecord]) -> None:
|
|
126
|
+
"""Persist feedback records to disk, appending to existing data."""
|
|
127
|
+
if not records:
|
|
128
|
+
return
|
|
129
|
+
path = _feedback_path(goal_id, run_dir)
|
|
130
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
131
|
+
|
|
132
|
+
existing = []
|
|
133
|
+
if os.path.isfile(path):
|
|
134
|
+
try:
|
|
135
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
136
|
+
data = json.load(f)
|
|
137
|
+
existing = [FeedbackRecord.from_dict(r) for r in data.get("records", [])]
|
|
138
|
+
except (OSError, json.JSONDecodeError):
|
|
139
|
+
pass
|
|
140
|
+
|
|
141
|
+
seen_ids = {(r.task_id, r.attempt) for r in existing}
|
|
142
|
+
new_records = [r for r in records if (r.task_id, r.attempt) not in seen_ids]
|
|
143
|
+
all_records = existing + new_records
|
|
144
|
+
|
|
145
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
146
|
+
json.dump(
|
|
147
|
+
{
|
|
148
|
+
"goal_id": goal_id,
|
|
149
|
+
"count": len(all_records),
|
|
150
|
+
"records": [r.to_dict() for r in all_records],
|
|
151
|
+
},
|
|
152
|
+
f,
|
|
153
|
+
indent=2,
|
|
154
|
+
ensure_ascii=False,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
store_global_feedback(new_records)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def store_global_feedback(records: List[FeedbackRecord], scratch_dir: Optional[str] = None) -> None:
|
|
161
|
+
"""Persist sanitized feedback records to global cross-goal feedback store."""
|
|
162
|
+
if not records:
|
|
163
|
+
return
|
|
164
|
+
import re
|
|
165
|
+
|
|
166
|
+
try:
|
|
167
|
+
workspace_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
|
168
|
+
base_dir = scratch_dir or os.environ.get("LIL_SCRATCH_DIR") or os.path.join(workspace_root, "scratch")
|
|
169
|
+
global_dir = os.path.join(base_dir, "orchestrator_feedback")
|
|
170
|
+
os.makedirs(global_dir, exist_ok=True)
|
|
171
|
+
global_file = os.path.join(global_dir, "global_feedback.jsonl")
|
|
172
|
+
|
|
173
|
+
secret_pat = re.compile(r"(?i)(key|secret|token|password|auth)=['\"]?\S+['\"]?")
|
|
174
|
+
|
|
175
|
+
lines_to_write = []
|
|
176
|
+
for r in records:
|
|
177
|
+
d = r.to_dict()
|
|
178
|
+
if d.get("stderr_snippet"):
|
|
179
|
+
d["stderr_snippet"] = secret_pat.sub(r"\1=<redacted>", d["stderr_snippet"])
|
|
180
|
+
lines_to_write.append(json.dumps(d, ensure_ascii=False) + "\n")
|
|
181
|
+
|
|
182
|
+
with open(global_file, "a", encoding="utf-8") as f:
|
|
183
|
+
for line in lines_to_write:
|
|
184
|
+
f.write(line)
|
|
185
|
+
|
|
186
|
+
if os.path.isfile(global_file):
|
|
187
|
+
with open(global_file, "r", encoding="utf-8") as f:
|
|
188
|
+
all_lines = f.readlines()
|
|
189
|
+
if len(all_lines) > 1000:
|
|
190
|
+
with open(global_file, "w", encoding="utf-8") as f:
|
|
191
|
+
f.writelines(all_lines[-500:])
|
|
192
|
+
except (OSError, PermissionError):
|
|
193
|
+
pass
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def load_feedback(goal_id: str, run_dir: str) -> List[FeedbackRecord]:
|
|
197
|
+
"""Load persisted feedback records for a goal."""
|
|
198
|
+
path = _feedback_path(goal_id, run_dir)
|
|
199
|
+
if not os.path.isfile(path):
|
|
200
|
+
return []
|
|
201
|
+
try:
|
|
202
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
203
|
+
data = json.load(f)
|
|
204
|
+
return [FeedbackRecord.from_dict(r) for r in data.get("records", [])]
|
|
205
|
+
except (OSError, json.JSONDecodeError):
|
|
206
|
+
return []
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def detect_patterns(records: List[FeedbackRecord]) -> List[Dict[str, Any]]:
|
|
210
|
+
"""Analyze feedback records for repeated failure patterns."""
|
|
211
|
+
patterns = []
|
|
212
|
+
by_task: Dict[str, List[FeedbackRecord]] = {}
|
|
213
|
+
for r in records:
|
|
214
|
+
by_task.setdefault(r.task_id, []).append(r)
|
|
215
|
+
|
|
216
|
+
for task_id, recs in by_task.items():
|
|
217
|
+
if len(recs) >= 2:
|
|
218
|
+
classes = [r.failure_class for r in recs]
|
|
219
|
+
if len(set(classes)) == 1:
|
|
220
|
+
patterns.append(
|
|
221
|
+
{
|
|
222
|
+
"task_id": task_id,
|
|
223
|
+
"pattern": "repeated_same_class",
|
|
224
|
+
"failure_class": classes[0],
|
|
225
|
+
"count": len(recs),
|
|
226
|
+
"suggestion": "split task or change approach",
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
else:
|
|
230
|
+
patterns.append(
|
|
231
|
+
{
|
|
232
|
+
"task_id": task_id,
|
|
233
|
+
"pattern": "varied_failures",
|
|
234
|
+
"failure_classes": list(set(classes)),
|
|
235
|
+
"count": len(recs),
|
|
236
|
+
"suggestion": "review task definition",
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
by_class: Dict[str, int] = {}
|
|
241
|
+
for r in records:
|
|
242
|
+
by_class[r.failure_class] = by_class.get(r.failure_class, 0) + 1
|
|
243
|
+
for fc, count in by_class.items():
|
|
244
|
+
if count >= 3:
|
|
245
|
+
patterns.append(
|
|
246
|
+
{
|
|
247
|
+
"task_id": "(global)",
|
|
248
|
+
"pattern": "pervasive_failure_class",
|
|
249
|
+
"failure_class": fc,
|
|
250
|
+
"count": count,
|
|
251
|
+
"suggestion": "re-evaluate approach for this failure type",
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
return patterns
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def feedback_for_replan(goal_id: str, run_dir: str) -> str:
|
|
259
|
+
"""Build a formatted string of failure feedback for planner/generator prompts."""
|
|
260
|
+
records = load_feedback(goal_id, run_dir)
|
|
261
|
+
if not records:
|
|
262
|
+
return ""
|
|
263
|
+
|
|
264
|
+
lines = [f"Previous failures for goal {goal_id} ({len(records)} record(s)):"]
|
|
265
|
+
from .qc_review import _redact_secrets
|
|
266
|
+
|
|
267
|
+
for r in records:
|
|
268
|
+
raw_snippet = r.stderr_snippet.replace("\n", " | ")[:120]
|
|
269
|
+
snippet = _redact_secrets(raw_snippet)
|
|
270
|
+
lines.append(f" - [{r.error_code}] {r.task_id}: {r.failure_class} (attempt {r.attempt}, status {r.status})")
|
|
271
|
+
if snippet:
|
|
272
|
+
lines.append(f" stderr: {snippet}")
|
|
273
|
+
|
|
274
|
+
patterns = detect_patterns(records)
|
|
275
|
+
if patterns:
|
|
276
|
+
lines.append("Patterns detected:")
|
|
277
|
+
for p in patterns:
|
|
278
|
+
lines.append(f" - {p['task_id']}: {p['pattern']} ({p.get('failure_class', '')}) — {p['suggestion']}")
|
|
279
|
+
|
|
280
|
+
return "\n".join(lines)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def format_feedback(records: List[FeedbackRecord]) -> str:
|
|
284
|
+
"""Format feedback records as human-readable string."""
|
|
285
|
+
if not records:
|
|
286
|
+
return "No feedback records found."
|
|
287
|
+
lines = [f"Feedback records ({len(records)}):"]
|
|
288
|
+
from .qc_review import _redact_secrets
|
|
289
|
+
|
|
290
|
+
for r in records:
|
|
291
|
+
item = f" [{r.error_code}] {r.task_id}: {r.failure_class} (attempt {r.attempt})"
|
|
292
|
+
if r.stderr_snippet:
|
|
293
|
+
item += f" — {_redact_secrets(r.stderr_snippet[:80])}"
|
|
294
|
+
lines.append(item)
|
|
295
|
+
|
|
296
|
+
patterns = detect_patterns(records)
|
|
297
|
+
if patterns:
|
|
298
|
+
lines.append("")
|
|
299
|
+
lines.append("Patterns:")
|
|
300
|
+
for p in patterns:
|
|
301
|
+
lines.append(f" - {p['task_id']}: {p['pattern']} ({p.get('failure_class', '')})")
|
|
302
|
+
return "\n".join(lines)
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"task_id": "phase1-20260723-hello-fixture",
|
|
3
|
+
"title": "Create hello_fixture.py with pytest test",
|
|
4
|
+
"status": "drafted",
|
|
5
|
+
"risk_tier": "auto",
|
|
6
|
+
"workspace_scope": {
|
|
7
|
+
"allow": ["orchestrator/fixtures/phase1_task/"],
|
|
8
|
+
"deny": ["AGENTS.md", "memory/", ".opencode/"]
|
|
9
|
+
},
|
|
10
|
+
"objective": "Create orchestrator/fixtures/phase1_task/hello_fixture.py containing a function greet(name) that returns 'Hello, {name}!' and a pytest test_greet that asserts greet('World') == 'Hello, World!'",
|
|
11
|
+
"worker": {
|
|
12
|
+
"model": "openai:gpt-4o-mini",
|
|
13
|
+
"max_attempts": 3
|
|
14
|
+
},
|
|
15
|
+
"inputs": [],
|
|
16
|
+
"outputs": [
|
|
17
|
+
{"path": "orchestrator/fixtures/phase1_task/hello_fixture.py"}
|
|
18
|
+
],
|
|
19
|
+
"acceptance_checks": [
|
|
20
|
+
{
|
|
21
|
+
"id": "file_exists",
|
|
22
|
+
"kind": "file_exists",
|
|
23
|
+
"path": "orchestrator/fixtures/phase1_task/hello_fixture.py",
|
|
24
|
+
"expected": "nonempty"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "pytest_pass",
|
|
28
|
+
"kind": "command",
|
|
29
|
+
"command": "python -m pytest orchestrator/fixtures/phase1_task/hello_fixture.py -v",
|
|
30
|
+
"expected": 0
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "greet_function",
|
|
34
|
+
"kind": "content_regex",
|
|
35
|
+
"path": "orchestrator/fixtures/phase1_task/hello_fixture.py",
|
|
36
|
+
"expected": "def greet"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "test_function",
|
|
40
|
+
"kind": "content_regex",
|
|
41
|
+
"path": "orchestrator/fixtures/phase1_task/hello_fixture.py",
|
|
42
|
+
"expected": "def test_greet"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"qc": {
|
|
46
|
+
"required": false,
|
|
47
|
+
"lens": "code_correctness"
|
|
48
|
+
},
|
|
49
|
+
"next_action": "preflight"
|
|
50
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"task_id": "evidence-cli-run-test-step-1",
|
|
3
|
+
"title": "Step 1",
|
|
4
|
+
"status": "DRAFTED",
|
|
5
|
+
"risk_tier": "auto",
|
|
6
|
+
"workspace_scope": {
|
|
7
|
+
"allow": [
|
|
8
|
+
"scratch/"
|
|
9
|
+
],
|
|
10
|
+
"deny": []
|
|
11
|
+
},
|
|
12
|
+
"objective": "Test",
|
|
13
|
+
"worker": {
|
|
14
|
+
"model": "hybrid:gemini:gemini-3.7-flash",
|
|
15
|
+
"max_attempts": 3,
|
|
16
|
+
"hybrid_critic_model": "gemini:gemini-3.7-flash",
|
|
17
|
+
"hybrid_max_repair_turns": 3,
|
|
18
|
+
"hybrid_max_tokens": 32000,
|
|
19
|
+
"hybrid_max_cost_usd": 0.3,
|
|
20
|
+
"hybrid_max_identical_verdicts": 2
|
|
21
|
+
},
|
|
22
|
+
"inputs": [],
|
|
23
|
+
"outputs": [
|
|
24
|
+
{
|
|
25
|
+
"path": "scratch/test_evidence_cli_1.txt"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"acceptance_checks": [
|
|
29
|
+
{
|
|
30
|
+
"id": "chk-min_size",
|
|
31
|
+
"kind": "min_size",
|
|
32
|
+
"path": "scratch/test_evidence_cli_1.txt",
|
|
33
|
+
"expected": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "chk-content",
|
|
37
|
+
"kind": "content_regex",
|
|
38
|
+
"path": "scratch/test_evidence_cli_1.txt",
|
|
39
|
+
"expected": ".+"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"qc": {
|
|
43
|
+
"required": false,
|
|
44
|
+
"lens": "code_correctness"
|
|
45
|
+
},
|
|
46
|
+
"quality_spec": {}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"task_id": "evidence-cli-run-test-step-2",
|
|
3
|
+
"title": "Step 2",
|
|
4
|
+
"status": "DRAFTED",
|
|
5
|
+
"risk_tier": "auto",
|
|
6
|
+
"workspace_scope": {
|
|
7
|
+
"allow": [
|
|
8
|
+
"scratch/"
|
|
9
|
+
],
|
|
10
|
+
"deny": []
|
|
11
|
+
},
|
|
12
|
+
"objective": "Test",
|
|
13
|
+
"worker": {
|
|
14
|
+
"model": "hybrid:gemini:gemini-3.7-flash",
|
|
15
|
+
"max_attempts": 3,
|
|
16
|
+
"hybrid_critic_model": "gemini:gemini-3.7-flash",
|
|
17
|
+
"hybrid_max_repair_turns": 3,
|
|
18
|
+
"hybrid_max_tokens": 32000,
|
|
19
|
+
"hybrid_max_cost_usd": 0.3,
|
|
20
|
+
"hybrid_max_identical_verdicts": 2
|
|
21
|
+
},
|
|
22
|
+
"inputs": [],
|
|
23
|
+
"outputs": [
|
|
24
|
+
{
|
|
25
|
+
"path": "scratch/test_evidence_cli_2.txt"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"acceptance_checks": [
|
|
29
|
+
{
|
|
30
|
+
"id": "chk-min_size",
|
|
31
|
+
"kind": "min_size",
|
|
32
|
+
"path": "scratch/test_evidence_cli_2.txt",
|
|
33
|
+
"expected": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "chk-content",
|
|
37
|
+
"kind": "content_regex",
|
|
38
|
+
"path": "scratch/test_evidence_cli_2.txt",
|
|
39
|
+
"expected": ".+"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"qc": {
|
|
43
|
+
"required": false,
|
|
44
|
+
"lens": "code_correctness"
|
|
45
|
+
},
|
|
46
|
+
"quality_spec": {}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"task_id": "evidence-inject-test-a",
|
|
3
|
+
"title": "Step A",
|
|
4
|
+
"status": "DRAFTED",
|
|
5
|
+
"risk_tier": "auto",
|
|
6
|
+
"workspace_scope": {
|
|
7
|
+
"allow": [
|
|
8
|
+
"scratch/"
|
|
9
|
+
],
|
|
10
|
+
"deny": []
|
|
11
|
+
},
|
|
12
|
+
"objective": "Create",
|
|
13
|
+
"worker": {
|
|
14
|
+
"model": "hybrid:gemini:gemini-3.7-flash",
|
|
15
|
+
"max_attempts": 3,
|
|
16
|
+
"hybrid_critic_model": "gemini:gemini-3.7-flash",
|
|
17
|
+
"hybrid_max_repair_turns": 3,
|
|
18
|
+
"hybrid_max_tokens": 32000,
|
|
19
|
+
"hybrid_max_cost_usd": 0.3,
|
|
20
|
+
"hybrid_max_identical_verdicts": 2
|
|
21
|
+
},
|
|
22
|
+
"inputs": [],
|
|
23
|
+
"outputs": [
|
|
24
|
+
{
|
|
25
|
+
"path": "scratch/test_inject_a.txt"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"acceptance_checks": [
|
|
29
|
+
{
|
|
30
|
+
"id": "chk-min_size",
|
|
31
|
+
"kind": "min_size",
|
|
32
|
+
"path": "scratch/test_inject_a.txt",
|
|
33
|
+
"expected": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "chk-content",
|
|
37
|
+
"kind": "content_regex",
|
|
38
|
+
"path": "scratch/test_inject_a.txt",
|
|
39
|
+
"expected": ".+"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"qc": {
|
|
43
|
+
"required": false,
|
|
44
|
+
"lens": "code_correctness"
|
|
45
|
+
},
|
|
46
|
+
"quality_spec": {}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"task_id": "evidence-inject-test-b",
|
|
3
|
+
"title": "Step B",
|
|
4
|
+
"status": "DRAFTED",
|
|
5
|
+
"risk_tier": "auto",
|
|
6
|
+
"workspace_scope": {
|
|
7
|
+
"allow": [
|
|
8
|
+
"scratch/"
|
|
9
|
+
],
|
|
10
|
+
"deny": []
|
|
11
|
+
},
|
|
12
|
+
"objective": "Use A",
|
|
13
|
+
"worker": {
|
|
14
|
+
"model": "hybrid:gemini:gemini-3.7-flash",
|
|
15
|
+
"max_attempts": 3,
|
|
16
|
+
"hybrid_critic_model": "gemini:gemini-3.7-flash",
|
|
17
|
+
"hybrid_max_repair_turns": 3,
|
|
18
|
+
"hybrid_max_tokens": 32000,
|
|
19
|
+
"hybrid_max_cost_usd": 0.3,
|
|
20
|
+
"hybrid_max_identical_verdicts": 2
|
|
21
|
+
},
|
|
22
|
+
"inputs": [],
|
|
23
|
+
"outputs": [
|
|
24
|
+
{
|
|
25
|
+
"path": "scratch/test_inject_b.txt"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"acceptance_checks": [
|
|
29
|
+
{
|
|
30
|
+
"id": "chk-min_size",
|
|
31
|
+
"kind": "min_size",
|
|
32
|
+
"path": "scratch/test_inject_b.txt",
|
|
33
|
+
"expected": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "chk-content",
|
|
37
|
+
"kind": "content_regex",
|
|
38
|
+
"path": "scratch/test_inject_b.txt",
|
|
39
|
+
"expected": ".+"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"qc": {
|
|
43
|
+
"required": false,
|
|
44
|
+
"lens": "code_correctness"
|
|
45
|
+
},
|
|
46
|
+
"quality_spec": {}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"task_id": "evidence-inject-test-c",
|
|
3
|
+
"title": "Step C",
|
|
4
|
+
"status": "DRAFTED",
|
|
5
|
+
"risk_tier": "auto",
|
|
6
|
+
"workspace_scope": {
|
|
7
|
+
"allow": [
|
|
8
|
+
"scratch/"
|
|
9
|
+
],
|
|
10
|
+
"deny": []
|
|
11
|
+
},
|
|
12
|
+
"objective": "Use A too",
|
|
13
|
+
"worker": {
|
|
14
|
+
"model": "hybrid:gemini:gemini-3.7-flash",
|
|
15
|
+
"max_attempts": 3,
|
|
16
|
+
"hybrid_critic_model": "gemini:gemini-3.7-flash",
|
|
17
|
+
"hybrid_max_repair_turns": 3,
|
|
18
|
+
"hybrid_max_tokens": 32000,
|
|
19
|
+
"hybrid_max_cost_usd": 0.3,
|
|
20
|
+
"hybrid_max_identical_verdicts": 2
|
|
21
|
+
},
|
|
22
|
+
"inputs": [],
|
|
23
|
+
"outputs": [
|
|
24
|
+
{
|
|
25
|
+
"path": "scratch/test_inject_c.txt"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"acceptance_checks": [
|
|
29
|
+
{
|
|
30
|
+
"id": "chk-min_size",
|
|
31
|
+
"kind": "min_size",
|
|
32
|
+
"path": "scratch/test_inject_c.txt",
|
|
33
|
+
"expected": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "chk-content",
|
|
37
|
+
"kind": "content_regex",
|
|
38
|
+
"path": "scratch/test_inject_c.txt",
|
|
39
|
+
"expected": ".+"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"qc": {
|
|
43
|
+
"required": false,
|
|
44
|
+
"lens": "code_correctness"
|
|
45
|
+
},
|
|
46
|
+
"quality_spec": {}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"task_id": "evidence-json-test-a",
|
|
3
|
+
"title": "A",
|
|
4
|
+
"status": "DRAFTED",
|
|
5
|
+
"risk_tier": "auto",
|
|
6
|
+
"workspace_scope": {
|
|
7
|
+
"allow": [
|
|
8
|
+
"scratch/"
|
|
9
|
+
],
|
|
10
|
+
"deny": []
|
|
11
|
+
},
|
|
12
|
+
"objective": "A",
|
|
13
|
+
"worker": {
|
|
14
|
+
"model": "hybrid:gemini:gemini-3.7-flash",
|
|
15
|
+
"max_attempts": 3,
|
|
16
|
+
"hybrid_critic_model": "gemini:gemini-3.7-flash",
|
|
17
|
+
"hybrid_max_repair_turns": 3,
|
|
18
|
+
"hybrid_max_tokens": 32000,
|
|
19
|
+
"hybrid_max_cost_usd": 0.3,
|
|
20
|
+
"hybrid_max_identical_verdicts": 2
|
|
21
|
+
},
|
|
22
|
+
"inputs": [],
|
|
23
|
+
"outputs": [
|
|
24
|
+
{
|
|
25
|
+
"path": "scratch/test_json_a.txt"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"acceptance_checks": [
|
|
29
|
+
{
|
|
30
|
+
"id": "chk-min_size",
|
|
31
|
+
"kind": "min_size",
|
|
32
|
+
"path": "scratch/test_json_a.txt",
|
|
33
|
+
"expected": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "chk-content",
|
|
37
|
+
"kind": "content_regex",
|
|
38
|
+
"path": "scratch/test_json_a.txt",
|
|
39
|
+
"expected": ".+"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"qc": {
|
|
43
|
+
"required": false,
|
|
44
|
+
"lens": "code_correctness"
|
|
45
|
+
},
|
|
46
|
+
"quality_spec": {}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"task_id": "evidence-json-test-b",
|
|
3
|
+
"title": "B",
|
|
4
|
+
"status": "DRAFTED",
|
|
5
|
+
"risk_tier": "auto",
|
|
6
|
+
"workspace_scope": {
|
|
7
|
+
"allow": [
|
|
8
|
+
"scratch/"
|
|
9
|
+
],
|
|
10
|
+
"deny": []
|
|
11
|
+
},
|
|
12
|
+
"objective": "B",
|
|
13
|
+
"worker": {
|
|
14
|
+
"model": "hybrid:gemini:gemini-3.7-flash",
|
|
15
|
+
"max_attempts": 3,
|
|
16
|
+
"hybrid_critic_model": "gemini:gemini-3.7-flash",
|
|
17
|
+
"hybrid_max_repair_turns": 3,
|
|
18
|
+
"hybrid_max_tokens": 32000,
|
|
19
|
+
"hybrid_max_cost_usd": 0.3,
|
|
20
|
+
"hybrid_max_identical_verdicts": 2
|
|
21
|
+
},
|
|
22
|
+
"inputs": [],
|
|
23
|
+
"outputs": [
|
|
24
|
+
{
|
|
25
|
+
"path": "scratch/test_json_b.txt"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"acceptance_checks": [
|
|
29
|
+
{
|
|
30
|
+
"id": "chk-min_size",
|
|
31
|
+
"kind": "min_size",
|
|
32
|
+
"path": "scratch/test_json_b.txt",
|
|
33
|
+
"expected": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "chk-content",
|
|
37
|
+
"kind": "content_regex",
|
|
38
|
+
"path": "scratch/test_json_b.txt",
|
|
39
|
+
"expected": ".+"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"qc": {
|
|
43
|
+
"required": false,
|
|
44
|
+
"lens": "code_correctness"
|
|
45
|
+
},
|
|
46
|
+
"quality_spec": {}
|
|
47
|
+
}
|