Fix alpha generation pipeline runnable-output blockers
Browse files
alpha_factory/orchestration/pipeline.py
CHANGED
|
@@ -17,10 +17,10 @@ from ..deterministic.expression_mutator import generate_mutations
|
|
| 17 |
from ..personas import (
|
| 18 |
generate_hypothesis,
|
| 19 |
compile_expression,
|
| 20 |
-
scout_novelty,
|
| 21 |
diagnose_performance,
|
| 22 |
gate_alpha,
|
| 23 |
)
|
|
|
|
| 24 |
from ..schemas import Verdict, BrainMetrics, Component, Neutralization, AnomalyTag
|
| 25 |
from ..data.brain_groups import get_group_for_expression
|
| 26 |
from ..local.brain_sim import simulate_alpha_local, sign_sweep_local
|
|
@@ -267,8 +267,12 @@ class AlphaPipeline:
|
|
| 267 |
console.print(f" [yellow]Warnings:[/] {lint_result.warnings}")
|
| 268 |
|
| 269 |
# STEP 2: Dedup
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
alpha_id = quick_dedup_hash(expr, blueprint.neutralization.value, blueprint.decay)
|
| 271 |
-
if alpha_id in
|
| 272 |
console.print(f" [red]DEDUP:[/] Already exists")
|
| 273 |
return Verdict.KILL
|
| 274 |
existing_hashes.add(alpha_id)
|
|
@@ -318,7 +322,7 @@ class AlphaPipeline:
|
|
| 318 |
expression=expression,
|
| 319 |
lint_result=lint_result,
|
| 320 |
alpha_id=alpha_id,
|
| 321 |
-
existing_hashes=
|
| 322 |
existing_anomaly_tags=existing_tags,
|
| 323 |
max_corr_to_library=max_corr,
|
| 324 |
local_sim_sharpe=local_metrics.sharpe if local_metrics else 1.5,
|
|
@@ -333,7 +337,7 @@ class AlphaPipeline:
|
|
| 333 |
console.print(f" [green]CHECKLIST PASS[/]")
|
| 334 |
|
| 335 |
# STEP 6: Crowd Scout — novelty check
|
| 336 |
-
crowd_result = await scout_novelty(
|
| 337 |
self.llm, expr, blueprint.theme,
|
| 338 |
blueprint.anomaly_tag.value, existing_tags, max_corr
|
| 339 |
)
|
|
@@ -418,8 +422,14 @@ class AlphaPipeline:
|
|
| 418 |
|
| 419 |
try:
|
| 420 |
result = await self.brain.submit_alpha(expression, neutralization, decay)
|
| 421 |
-
|
| 422 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
self._daily_submissions += 1
|
| 424 |
metrics = self.brain.parse_metrics(result, alpha_id)
|
| 425 |
self.store.update_metrics(alpha_id, metrics, 0.0)
|
|
|
|
| 17 |
from ..personas import (
|
| 18 |
generate_hypothesis,
|
| 19 |
compile_expression,
|
|
|
|
| 20 |
diagnose_performance,
|
| 21 |
gate_alpha,
|
| 22 |
)
|
| 23 |
+
from ..personas import crowd_scout
|
| 24 |
from ..schemas import Verdict, BrainMetrics, Component, Neutralization, AnomalyTag
|
| 25 |
from ..data.brain_groups import get_group_for_expression
|
| 26 |
from ..local.brain_sim import simulate_alpha_local, sign_sweep_local
|
|
|
|
| 267 |
console.print(f" [yellow]Warnings:[/] {lint_result.warnings}")
|
| 268 |
|
| 269 |
# STEP 2: Dedup
|
| 270 |
+
# Keep a snapshot for the checklist. The live set is updated immediately
|
| 271 |
+
# so later candidates in the same batch still deduplicate correctly, but
|
| 272 |
+
# the current candidate must not fail its own checklist as a duplicate.
|
| 273 |
+
pre_existing_hashes = set(existing_hashes)
|
| 274 |
alpha_id = quick_dedup_hash(expr, blueprint.neutralization.value, blueprint.decay)
|
| 275 |
+
if alpha_id in pre_existing_hashes:
|
| 276 |
console.print(f" [red]DEDUP:[/] Already exists")
|
| 277 |
return Verdict.KILL
|
| 278 |
existing_hashes.add(alpha_id)
|
|
|
|
| 322 |
expression=expression,
|
| 323 |
lint_result=lint_result,
|
| 324 |
alpha_id=alpha_id,
|
| 325 |
+
existing_hashes=pre_existing_hashes,
|
| 326 |
existing_anomaly_tags=existing_tags,
|
| 327 |
max_corr_to_library=max_corr,
|
| 328 |
local_sim_sharpe=local_metrics.sharpe if local_metrics else 1.5,
|
|
|
|
| 337 |
console.print(f" [green]CHECKLIST PASS[/]")
|
| 338 |
|
| 339 |
# STEP 6: Crowd Scout — novelty check
|
| 340 |
+
crowd_result = await crowd_scout.scout_novelty(
|
| 341 |
self.llm, expr, blueprint.theme,
|
| 342 |
blueprint.anomaly_tag.value, existing_tags, max_corr
|
| 343 |
)
|
|
|
|
| 422 |
|
| 423 |
try:
|
| 424 |
result = await self.brain.submit_alpha(expression, neutralization, decay)
|
| 425 |
+
status = str(result.get("status", "")).upper()
|
| 426 |
+
sim_id = result.get("id") or result.get("simulationId") or result.get("simulation_id")
|
| 427 |
+
if status in {"PENDING", "RUNNING", "SUBMITTED", "IN_PROGRESS"} and sim_id:
|
| 428 |
+
console.print(f" [cyan]BRAIN POLL:[/] Simulation {sim_id} status={status}")
|
| 429 |
+
result = await self.brain.poll_simulation(str(sim_id))
|
| 430 |
+
status = str(result.get("status", "")).upper()
|
| 431 |
+
|
| 432 |
+
if status == "DONE":
|
| 433 |
self._daily_submissions += 1
|
| 434 |
metrics = self.brain.parse_metrics(result, alpha_id)
|
| 435 |
self.store.update_metrics(alpha_id, metrics, 0.0)
|