AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix(pipeline): isolate discovery worker config (#1160)
Ilia Alshanetsky11927f5ebbbc
diff --git a/changelog.d/+discovery-config-isolation.fixed.md b/changelog.d/+discovery-config-isolation.fixed.mdnew file mode 100644index 00000000..9e5cd859--- /dev/null+++ b/changelog.d/+discovery-config-isolation.fixed.md@@ -0,0 +1 @@+Discovery enrichment now hands each sub-run worker its own config copy, so one topic's financial-topic flag can no longer overwrite another's mid-run.diff --git a/skills/last30days/scripts/lib/pipeline.py b/skills/last30days/scripts/lib/pipeline.pyindex d4304b86..cd7bbd4c 100644--- a/skills/last30days/scripts/lib/pipeline.py+++ b/skills/last30days/scripts/lib/pipeline.py@@ -1021,9 +1021,14 @@ def enrich_nominations(return []def _run_one(nomination: Nomination) -> schema.Report:+ # Per-worker copy: run() mutates config in place+ # (config["_financial_topic"] = ...), so sharing one dict across+ # daemon threads lets topic A's flag overwrite topic B's mid-run,+ # with stragglers mutating past budget expiry. Same idiom as the+ # competitor runner (entity_config = dict(config)).return run(topic=nomination.name,- config=config,+ config=dict(config),depth=depth,requested_sources=requested_sources,mock=mock,diff --git a/tests/test_discover_enrich.py b/tests/test_discover_enrich.pyindex 62434b4f..b83fc5c9 100644--- a/tests/test_discover_enrich.py+++ b/tests/test_discover_enrich.py@@ -512,6 +512,40 @@ def test_enrichment_path_never_uses_thread_pool_executor():assert "Semaphore" in source+def test_enrich_workers_get_isolated_config_copies():+ """CR-020: run() mutates config in place (config["_financial_topic"] =+ ... in pipeline.run). The fan-out must hand each daemon worker its own+ dict(config) copy - same idiom as the competitor runner - or topic A's+ flag overwrites topic B's mid-run and abandoned stragglers keep mutating+ the shared dict after budget expiry."""+ import threading++ received: dict[str, dict] = {}+ lock = threading.Lock()+ barrier = threading.Barrier(2)++ def fake_run(*, topic, config, **_kwargs):+ # Mirror run()'s in-place write, forced to overlap via the barrier.+ barrier.wait(timeout=10)+ config["_financial_topic"] = f"flag-for-{topic}"+ barrier.wait(timeout=10)+ with lock:+ received[topic] = dict(config)+ return _report(topic)++ shared = {"BASE": "1"}+ nominations = [_nomination("Topic A"), _nomination("Topic B")]+ with mock.patch.object(pipeline, "run", side_effect=fake_run):+ enriched = pipeline.enrich_nominations(+ nominations, config=shared, max_workers=2,+ )++ assert all(entry.report is not None for entry in enriched)+ assert received["Topic A"]["_financial_topic"] == "flag-for-Topic A"+ assert received["Topic B"]["_financial_topic"] == "flag-for-Topic B"+ assert "_financial_topic" not in shared++def test_host_judged_name_becomes_enrichment_sub_run_topic():"""Relocated from the retired engine-judge suite, retargeted to thejudgments-file path: the host's applied name IS the enrichment sub-run