argo-search 2.14.1 → 2.15.0

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 (171) hide show
  1. package/AGENTS.md +8 -6
  2. package/README.es.md +54 -832
  3. package/README.ja.md +53 -833
  4. package/README.ko.md +53 -831
  5. package/README.md +126 -769
  6. package/README.zh.md +124 -893
  7. package/SKILL.md +17 -18
  8. package/assets/readme/counts.json +1 -1
  9. package/assets/readme/hero.svg +23 -23
  10. package/backends/concept_vectors.bin +0 -0
  11. package/backends/domain_profiles.json +42 -0
  12. package/backends/engine_concept_vectors.json +1525 -1525
  13. package/backends/engine_registry.yaml +124 -28
  14. package/backends/quota_profiles.json +70 -0
  15. package/bin/argo +30 -17
  16. package/config.yaml +173 -33
  17. package/docs/ADDING_NEW_ENGINE.md +10 -0
  18. package/docs/ARGO_INTRO.md +1 -1
  19. package/docs/CHANGELOG.md +23 -0
  20. package/docs/ENGINE_CATALOG.md +97 -85
  21. package/docs/MCP_SETUP.md +1 -1
  22. package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
  23. package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
  24. package/docs/RELEASING.md +1 -1
  25. package/engines/specs/ai_labs.yaml +89 -0
  26. package/engines/specs/bilibili_hot.yaml +11 -1
  27. package/engines/specs/brave.yaml +3 -3
  28. package/engines/specs/cisa_alerts.yaml +40 -0
  29. package/engines/specs/cn_ai_news.yaml +10 -8
  30. package/engines/specs/digup.yaml +11 -6
  31. package/engines/specs/douyin_hot.yaml +11 -1
  32. package/engines/specs/dw_news.yaml +4 -2
  33. package/engines/specs/eng_blogs.yaml +63 -0
  34. package/engines/specs/europeana.yaml +3 -4
  35. package/engines/specs/felo.yaml +3 -3
  36. package/engines/specs/firecrawl.yaml +3 -0
  37. package/engines/specs/fourget.yaml +5 -2
  38. package/engines/specs/france24.yaml +6 -4
  39. package/engines/specs/fxtwitter.yaml +29 -6
  40. package/engines/specs/grepapp_mcp.yaml +62 -0
  41. package/engines/specs/guardian_rss.yaml +6 -4
  42. package/engines/specs/itotii.yaml +13 -1
  43. package/engines/specs/lobsters.yaml +41 -0
  44. package/engines/specs/local_seek.yaml +6 -0
  45. package/engines/specs/open_meteo.yaml +1 -1
  46. package/engines/specs/redskill.yaml +2 -0
  47. package/engines/specs/searxng.yaml +4 -2
  48. package/engines/specs/sec_edgar.yaml +8 -3
  49. package/engines/specs/tinyfish.yaml +2 -0
  50. package/engines/specs/tinyfish_news.yaml +2 -0
  51. package/engines/specs/tinyfish_paper.yaml +2 -0
  52. package/engines/specs/toutiao_hot.yaml +11 -1
  53. package/engines/specs/train.yaml +3 -0
  54. package/engines/specs/twitter.yaml +4 -0
  55. package/engines/specs/unpaywall.yaml +6 -0
  56. package/engines/specs/vam.yaml +17 -3
  57. package/engines/specs/weibo_hot.yaml +11 -1
  58. package/engines/specs/wolframalpha.yaml +3 -3
  59. package/engines/specs/xiaohongshu.yaml +2 -0
  60. package/engines/specs/zhihu.yaml +3 -18
  61. package/engines/specs/zhihu_kb.yaml +18 -0
  62. package/engines/specs/zhihu_questions.yaml +19 -0
  63. package/package.json +3 -2
  64. package/packages/dsh-plugin/README.md +9 -14
  65. package/packages/dsh-plugin/dsh/client.js +467 -1024
  66. package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
  67. package/packages/dsh-plugin/dsh/runner.js +2 -0
  68. package/packages/dsh-plugin/package.json +8 -3
  69. package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
  70. package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
  71. package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
  72. package/packages/dsh-plugin/test/size-gate.test.js +2 -9
  73. package/scripts/adaptive.py +7 -1
  74. package/scripts/archive_run.py +112 -53
  75. package/scripts/argo_paths.py +40 -3
  76. package/scripts/badcase_ledger.py +108 -9
  77. package/scripts/build_concept_table.py +112 -55
  78. package/scripts/cache.py +5 -1
  79. package/scripts/caliber_isolation.py +60 -23
  80. package/scripts/circuit_breaker.py +56 -8
  81. package/scripts/cli_io.py +20 -2
  82. package/scripts/config_cache.py +31 -0
  83. package/scripts/daemon.py +146 -51
  84. package/scripts/dormant_ledger.py +23 -9
  85. package/scripts/engine_dispatch.py +3 -3
  86. package/scripts/engine_env.py +182 -1
  87. package/scripts/engine_families.py +50 -7
  88. package/scripts/engine_states.py +3 -50
  89. package/scripts/engine_validate.py +13 -45
  90. package/scripts/engines.py +15 -31
  91. package/scripts/engines_base.py +42 -58
  92. package/scripts/engines_builders.py +0 -15
  93. package/scripts/engines_builders_batch10.py +346 -100
  94. package/scripts/engines_builders_batch11.py +2 -75
  95. package/scripts/engines_builders_batch9.py +15 -24
  96. package/scripts/engines_builders_cn.py +0 -194
  97. package/scripts/engines_builders_feeds.py +55 -5
  98. package/scripts/engines_builders_intl.py +15 -115
  99. package/scripts/engines_builders_pixiv.py +2 -16
  100. package/scripts/engines_builders_search.py +7 -14
  101. package/scripts/engines_builders_tech.py +5 -14
  102. package/scripts/engines_builders_weather.py +236 -0
  103. package/scripts/engines_fields.py +91 -0
  104. package/scripts/engines_http.py +135 -0
  105. package/scripts/engines_mcp.py +383 -0
  106. package/scripts/engines_parsers.py +13 -369
  107. package/scripts/engines_schema_drift.py +260 -0
  108. package/scripts/evidence.py +13 -0
  109. package/scripts/evidence_loop.py +4 -3
  110. package/scripts/fetch_jsrun.py +15 -11
  111. package/scripts/fetch_v3.py +28 -28
  112. package/scripts/fulltext_store.py +42 -1
  113. package/scripts/fxtwitter_api.py +8 -7
  114. package/scripts/gen_engine_catalog.py +2 -2
  115. package/scripts/general_pool.py +15 -4
  116. package/scripts/health_check.py +1 -1
  117. package/scripts/link_source.py +65 -24
  118. package/scripts/local_seek_adapter.py +57 -17
  119. package/scripts/mcp_handlers.py +53 -31
  120. package/scripts/mcp_handlers_surface.py +6 -18
  121. package/scripts/mcp_transport.py +1 -1
  122. package/scripts/min_version_scan.py +7 -3
  123. package/scripts/network_aware.py +7 -13
  124. package/scripts/pre-commit +45 -43
  125. package/scripts/query_understanding.py +30 -6
  126. package/scripts/quota.py +6 -1
  127. package/scripts/rank_signals.py +9 -0
  128. package/scripts/recompute.py +15 -5
  129. package/scripts/recovery.py +21 -15
  130. package/scripts/release.py +14 -26
  131. package/scripts/release_check.py +5 -25
  132. package/scripts/replay_eval.py +2 -2
  133. package/scripts/research_cli.py +40 -0
  134. package/scripts/research_notes.py +368 -0
  135. package/scripts/route.py +32 -70
  136. package/scripts/route_audit.py +259 -0
  137. package/scripts/route_combo.py +10 -4
  138. package/scripts/route_domains.py +150 -23
  139. package/scripts/route_lang.py +20 -7
  140. package/scripts/route_log.py +26 -9
  141. package/scripts/route_policy.py +85 -6
  142. package/scripts/route_telemetry_export.py +199 -0
  143. package/scripts/rrf_classic.py +5 -22
  144. package/scripts/search.py +2 -1
  145. package/scripts/search_attribution.py +33 -10
  146. package/scripts/search_entry.py +5 -1
  147. package/scripts/search_output.py +5 -4
  148. package/scripts/search_pipeline.py +12 -0
  149. package/scripts/search_rank.py +21 -11
  150. package/scripts/semantic_evidence.py +375 -168
  151. package/scripts/settings_page.py +3 -3
  152. package/scripts/social_engines/xiaohongshu_engine.py +2 -1
  153. package/scripts/social_engines/zhihu_engine.py +251 -43
  154. package/scripts/sogou_weixin_browser.py +5 -6
  155. package/scripts/source_audit.py +2 -2
  156. package/scripts/source_ledger.py +2 -15
  157. package/scripts/source_selection.py +45 -20
  158. package/scripts/straggler_policy.py +1 -2
  159. package/scripts/sync_backends.py +17 -0
  160. package/scripts/tfidf_router.py +23 -11
  161. package/scripts/time_utils.py +54 -1
  162. package/scripts/train.py +68 -2
  163. package/scripts/usage_log.py +26 -1
  164. package/sub-skills/argo-wide-research/SKILL.md +68 -0
  165. package/sub-skills/ego-search/SKILL.md +1 -1
  166. package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
  167. package/scripts/caliber_dedupe.py +0 -66
  168. package/scripts/engines_builders_batch16.py +0 -13
  169. package/scripts/health_probe.py +0 -253
  170. package/scripts/social_engines/twitter_engine.py +0 -514
  171. package/scripts/sync_installs.py +0 -29
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python3
2
- """semantic_evidence.py — 可选的语义证据层(classifier.dev,默认关闭)。
2
+ """semantic_evidence.py — 可选的语义证据层(三级阶梯降级,默认关闭)。
3
3
 
4
4
  ## 为什么存在
5
5
 
@@ -47,11 +47,17 @@ logger = logging.getLogger("unified_search.semantic_evidence")
47
47
 
48
48
  DEFAULT_ENDPOINT = "https://classifier.dev"
49
49
  DEFAULT_TIMEOUT_S = 5.0
50
- # 未声明 transport 时的默认通道。jev = TypeSafe System One(当前唯一可用);
51
- # classifier.dev 的匿名路径 2026-10-22 起回 403 proxy_requires_payment。
52
- DEFAULT_TRANSPORT = "jev"
50
+ # 未声明 transport 时的默认通道。优先级:Gemini Decision 1 ➔ TypeSafe JEV ➔
51
+ # 本地启发式(allow_heuristic=True 时);classifier.dev 匿名路径自 2026-10-22 起回 403。
52
+ DEFAULT_TRANSPORT = "gemini"
53
+ VALID_TRANSPORTS = ("gemini", "jev", "classify")
53
54
 
54
- # ── JEV / System One 通道(TypeSafe)──────────────────────────────────────
55
+ # ── Google Gemini Decision 1 通道(首选优先通道)─────────────────────────
56
+ DEFAULT_GEMINI_ENDPOINT = "https://generativelanguage.googleapis.com/v1beta/decisions"
57
+ DEFAULT_GEMINI_MODEL = "gemini-decision-1"
58
+ GEMINI_KEY_ENV = ("ARGO_GEMINI_API_KEY", "GEMINI_API_KEY")
59
+
60
+ # ── JEV / System One 通道(TypeSafe 备选通道)───────────────────────────
55
61
  # 官方 API:POST https://api.typesafe.ai/v1/systemone,Bearer 鉴权
56
62
  # (docs.typesafe.ai/api/system-one)。与 classifier.dev 的 /v1/classify 是
57
63
  # **两种形状**:那边一次发 N 条文本 + 一组标签;这边一次发一个 state + 若干
@@ -71,8 +77,16 @@ JEV_LONG_CONTEXT_CHARS = 24000
71
77
  # 并发上限。官方 cookbook(classifying_rag_passages)取 4,理由是端点限流;
72
78
  # 429/529 要求指数退避,所以不铺大。
73
79
  JEV_MAX_WORKERS = 4
74
- # 多并发整体截止时间(秒):实测冷调用在 0.55s 左右,提高到 1.2s(覆盖 p95),防止网络抖动导致的误杀 fail-open
80
+ # 多并发**整批**硬截止(秒):实测冷调用在 0.55s 左右,取 1.2s(覆盖 p95),
81
+ # 防止网络抖动导致的误杀 fail-open,也防止某条卡死把整批拖住。
82
+ # 注意与 config 的 `timeout_s` 区分:那是**每条请求**的超时,这是整批预算。
75
83
  DEFAULT_JEV_DEADLINE_S = 1.2
84
+ # Gemini 通道的**整批**硬截止(秒):与 JEV 分开,因为两者延迟特征不同。
85
+ # 2026-11-13 本机实测(gemini-decision-1,10 条冷调用):单条中位 689ms、
86
+ # p95 2251ms;4 条并发批量 670~1652ms、8 条 910~1534ms。取 5.0s 覆盖 8 条
87
+ # 两波的最坏情况(2×2.3s)并留抖动余量。沿用 1.2s 会截断:实测 6 组 4 条里
88
+ # 1 组只回 3/4(静默丢结果),故独立取值。
89
+ DEFAULT_GEMINI_DEADLINE_S = 5.0
76
90
 
77
91
  # 结果级缓存(TTL 7 天):常见事实与热点二次判定 0ms 响应,API 消耗清零
78
92
  _JEV_MEMORY_CACHE: dict[str, tuple[float, dict[str, Any]]] = {}
@@ -164,11 +178,13 @@ def _normalize_cache_text(text: str) -> str:
164
178
 
165
179
  def _get_cache_key(text: str, labels: tuple[str, ...] | list[str],
166
180
  instructions: str | None,
167
- criteria: dict[str, str] | None = None) -> str:
181
+ criteria: dict[str, str] | None = None,
182
+ salt: str = "") -> str:
168
183
  import hashlib
169
184
  crit_repr = str(sorted((criteria or {}).items())) if criteria else str(sorted(str(l) for l in labels))
170
185
  norm_text = _normalize_cache_text(text)
171
- raw = f"{instructions or ''}::{crit_repr}::{norm_text}"
186
+ prefix = f"{salt}::" if salt else ""
187
+ raw = f"{prefix}{instructions or ''}::{crit_repr}::{norm_text}"
172
188
  return hashlib.sha256(raw.encode("utf-8")).hexdigest()
173
189
 
174
190
 
@@ -200,8 +216,8 @@ def _get_cached_result(key: str) -> Optional[dict[str, Any]]:
200
216
  if isinstance(res, dict):
201
217
  _JEV_MEMORY_CACHE[key] = (rec.get("ts", time.time()), res)
202
218
  return dict(res)
203
- except Exception:
204
- pass
219
+ except (OSError, json.JSONDecodeError, TypeError, ValueError) as e:
220
+ logger.debug("读取语义缓存失败: %s", type(e).__name__)
205
221
  return None
206
222
 
207
223
 
@@ -217,15 +233,15 @@ def _set_cached_result(key: str, result: dict[str, Any]) -> None:
217
233
  if p.is_file():
218
234
  try:
219
235
  data_map = json.loads(p.read_text(encoding="utf-8"))
220
- except Exception:
236
+ except (OSError, json.JSONDecodeError, ValueError):
221
237
  data_map = {}
222
238
  if len(data_map) > 500:
223
239
  data_map.clear()
224
240
  data_map[key] = {"ts": now, "result": result}
225
241
  p.parent.mkdir(parents=True, exist_ok=True)
226
242
  p.write_text(json.dumps(data_map, ensure_ascii=False), encoding="utf-8")
227
- except Exception:
228
- pass
243
+ except (OSError, TypeError, ValueError) as e:
244
+ logger.debug("写入语义缓存失败: %s", type(e).__name__)
229
245
 
230
246
 
231
247
  def _config() -> dict[str, Any]:
@@ -264,34 +280,41 @@ def _timeout() -> float:
264
280
  return DEFAULT_TIMEOUT_S
265
281
 
266
282
 
267
- def jev_api_key() -> str:
268
- """JEV(TypeSafe)key:os.environ 优先,~/.config/argo/env 热读保底。"""
283
+ def _read_env_key(names: tuple[str, ...]) -> str:
284
+ """按候选名读取密钥:os.environ 优先,~/.config/argo/env 热读保底。"""
269
285
  try:
270
286
  from engine_env import get_env
271
- return (get_env(list(JEV_KEY_ENV)) or "").strip()
287
+ return (get_env(list(names)) or "").strip()
272
288
  except Exception: # pragma: no cover - 环境层不可用时不冒险
273
- import os
274
- for _n in JEV_KEY_ENV:
289
+ for _n in names:
275
290
  _v = (os.environ.get(_n) or "").strip()
276
291
  if _v:
277
292
  return _v
278
293
  return ""
279
294
 
280
295
 
281
- def _transport() -> str:
282
- """通道选择:`jev`(TypeSafe System One)或 `classify`(classifier.dev)。
296
+ def jev_api_key() -> str:
297
+ """JEV(TypeSafe)key:os.environ 优先,~/.config/argo/env 热读保底。"""
298
+ return _read_env_key(JEV_KEY_ENV)
283
299
 
284
- **纯配置驱动,不做「按键就绪自动选」**。初版按 jev_api_key() 是否就绪自动
285
- 选,结果是通道取决于本机 ~/.config/argo/env 里有没有那把 key——同一份代码
286
- 在开发机与 CI 上走不同分支,既有测试在开发机上会静默改道(实测:写进 key
287
- 后 test_semantic_evidence 的 5 条 HttpClient 桩里 1 条改走 JEV 路径而挂)。
288
- 机器状态不该改变代码路径。
289
300
 
290
- 未声明时的默认是 jev:classifier.dev 的匿名路径 2026-10-22 起回 403
291
- proxy_requires_payment,JEV 是当前可用的那条。
292
- """
301
+ def gemini_api_key() -> str:
302
+ """Gemini Decision 1 key:os.environ 优先,~/.config/argo/env 热读保底。"""
303
+ return _read_env_key(GEMINI_KEY_ENV)
304
+
305
+
306
+ def _gemini_endpoint() -> str:
307
+ return str(_config().get("gemini_endpoint") or DEFAULT_GEMINI_ENDPOINT).rstrip("/")
308
+
309
+
310
+ def _gemini_model() -> str:
311
+ return str(_config().get("gemini_model") or DEFAULT_GEMINI_MODEL)
312
+
313
+
314
+ def _transport() -> str:
315
+ """通道选择:`gemini`(Gemini Decision 1,默认)、`jev`(TypeSafe System One)或 `classify`。"""
293
316
  declared = str(_config().get("transport") or "").strip().lower()
294
- return declared if declared in ("jev", "classify") else DEFAULT_TRANSPORT
317
+ return declared if declared in VALID_TRANSPORTS else DEFAULT_TRANSPORT
295
318
 
296
319
 
297
320
  def _jev_endpoint() -> str:
@@ -311,6 +334,23 @@ def _jev_model() -> str:
311
334
  or DEFAULT_JEV_MODEL)
312
335
 
313
336
 
337
+ def _post_json(url: str, body: dict[str, Any], headers: dict[str, str],
338
+ timeout: float, tag: str) -> Optional[dict[str, Any]]:
339
+ """统一 JSON POST 请求与 fail-open 错误处理。"""
340
+ try:
341
+ from http_client import HttpClient
342
+ resp = HttpClient(timeout=timeout, max_retries=1, jitter=False).post(
343
+ url, body, extra_headers=headers)
344
+ if resp.get("status") != 200:
345
+ logger.debug("%s 非 200: %s %s", tag, resp.get("status"),
346
+ str(resp.get("text") or resp.get("error") or "")[:160])
347
+ return None
348
+ return json.loads(resp.get("text") or "{}")
349
+ except Exception as e: # fail-open:语义层任何问题都不阻断核验
350
+ logger.debug("%s 请求失败: %s", tag, type(e).__name__)
351
+ return None
352
+
353
+
314
354
  def _jev_post(path_state: Any, questions: dict[str, Any], *,
315
355
  timeout: float) -> Optional[dict[str, Any]]:
316
356
  """一次 System One 请求;失败返回 None(fail-open 的全部出口都在这里)。"""
@@ -323,28 +363,13 @@ def _jev_post(path_state: Any, questions: dict[str, Any], *,
323
363
  "state": path_state,
324
364
  "questions": questions,
325
365
  }
326
- # Content-Type 必须显式给:HttpClient.post 会把 dict 做 json.dumps,
327
- # 但**从不设 Content-Type**(头只来自浏览器 UA 模板 + extra_headers)。
328
- # 缺它时 FastAPI 侧把 body 当字符串,回
329
- # 422 {"loc":["body"],"msg":"Input should be a valid dictionary…"}
330
- # ——报错指向「请求体不是对象」,而真因是少了一个头(2026-10-22 实测踩中)。
366
+ # Content-Type 必须显式给:HttpClient.post 从不自动设它;缺头时服务端把 body 当字符串返回 422。
331
367
  headers = {"Authorization": f"Bearer {key}",
332
368
  "Content-Type": "application/json"}
333
- # 长上下文要显式带头,否则 state 一过 32K tokens 就 400 max_tokens_exceeded
369
+ # 长上下文显式带头,避免 >32K tokens 时触发 400 max_tokens_exceeded。
334
370
  if len(json.dumps(path_state, ensure_ascii=False)) > JEV_LONG_CONTEXT_CHARS:
335
371
  headers["TypeSafe-Danger-Zone-Long-Context"] = "true"
336
- try:
337
- from http_client import HttpClient
338
- resp = HttpClient(timeout=timeout, max_retries=1, jitter=False).post(
339
- _jev_endpoint(), body, extra_headers=headers)
340
- if resp.get("status") != 200:
341
- logger.debug("JEV 非 200: %s %s", resp.get("status"),
342
- str(resp.get("text") or resp.get("error") or "")[:200])
343
- return None
344
- return json.loads(resp.get("text") or "{}")
345
- except Exception as e: # fail-open:语义层任何问题都不阻断核验
346
- logger.debug("JEV 请求失败: %s", type(e).__name__)
347
- return None
372
+ return _post_json(_jev_endpoint(), body, headers, timeout, "JEV")
348
373
 
349
374
 
350
375
  def _jev_choice(text: str, labels: tuple[str, ...] | list[str],
@@ -390,37 +415,40 @@ def _jev_choice(text: str, labels: tuple[str, ...] | list[str],
390
415
  return res
391
416
 
392
417
 
393
- def _classify_jev(texts: list[str], labels: tuple[str, ...] | list[str], *,
394
- instructions: str | None, criteria: dict[str, str] | None = None,
395
- keep: list[tuple[int, str]],
396
- timeout: float) -> Optional[list[dict[str, Any]]]:
397
- """JEV 通道:每条文本一个请求,并发 4,带总体时间硬截止预算。
418
+ def _run_choice_batch(texts_len: int,
419
+ keep: list[tuple[int, str]],
420
+ choice_fn: Any,
421
+ *,
422
+ timeout: float,
423
+ deadline_s: float | None = None) -> Optional[list[dict[str, Any]]]:
424
+ """每条文本一个请求,并发受限 + 总体硬截止预算(超时即取消未完成任务)。
425
+
426
+ `timeout` 是**每条请求**的超时(已通过 choice_fn 闭包传给 HttpClient),
427
+ 不是整批预算。整批预算取 `deadline_s`,缺省 DEFAULT_JEV_DEADLINE_S;
428
+ Gemini 通道传 DEFAULT_GEMINI_DEADLINE_S(实测延迟显著高于 JEV,见常量注释)。
429
+ 这是一条保护性硬上限,防止某条卡死把整批拖住(也防止调用方把 timeout_s
430
+ 调大后整批无上限等待)。
398
431
 
399
- 任一条失败就在该位留 None(与 classifier.dev 通道「整批失败即 None」
400
- 不同):一次核验有几条正文,坏一条不该把其余判定的价值也丢掉。全部失败
401
- 时仍返回 None,调用方行为与未开启时一致。
432
+ 保留 `timeout` 形参是为了兼容既有调用点与测试 patch,内部不再读它。
402
433
  """
403
434
  from concurrent.futures import ThreadPoolExecutor, as_completed
404
- texts_kept = [t[:MAX_TEXT_CHARS] for _i, t in keep]
405
- deadline_s = DEFAULT_JEV_DEADLINE_S
435
+ texts_kept = [(idx, t[:MAX_TEXT_CHARS]) for idx, t in keep]
436
+ budget_s = float(deadline_s) if deadline_s and deadline_s > 0 else DEFAULT_JEV_DEADLINE_S
406
437
  results: list[Optional[dict[str, Any]]] = [None] * len(texts_kept)
407
438
 
408
439
  # 不能用 `with ThreadPoolExecutor(...)`:with 退出时 shutdown(wait=True)
409
- # 会把 as_completed 超时后仍在跑的请求全部 join 完,硬截止形同虚设
410
- # (实测 sleep 3s 的任务让整轮耗时 3.01s)。这里显式建池、超时后
411
- # shutdown(wait=False, cancel_futures=True),只保留已完成的结果就返回。
412
- # 未完成的任务内部仍由 HttpClient 的 timeout 兜底,不阻塞调用方。
440
+ # 会把 as_completed 超时后仍在跑的请求全部 join 完,硬截止形同虚设。
413
441
  pool = ThreadPoolExecutor(max_workers=min(JEV_MAX_WORKERS, len(texts_kept)))
414
442
  try:
415
- futures = {pool.submit(_jev_choice, t, labels, instructions, timeout, criteria): idx
416
- for idx, t in enumerate(texts_kept)}
443
+ futures = {pool.submit(choice_fn, t): pos
444
+ for pos, (_orig_idx, t) in enumerate(texts_kept)}
417
445
  try:
418
- for fut in as_completed(futures, timeout=max(0.1, deadline_s)):
419
- orig_idx = futures[fut]
446
+ for fut in as_completed(futures, timeout=max(0.1, budget_s)):
447
+ pos = futures[fut]
420
448
  try:
421
- results[orig_idx] = fut.result()
449
+ results[pos] = fut.result()
422
450
  except Exception:
423
- results[orig_idx] = None
451
+ results[pos] = None
424
452
  except TimeoutError:
425
453
  pass
426
454
  finally:
@@ -428,25 +456,98 @@ def _classify_jev(texts: list[str], labels: tuple[str, ...] | list[str], *,
428
456
 
429
457
  if not any(r for r in results):
430
458
  return None
431
- out: list[Optional[dict[str, Any]]] = [None] * len(texts)
432
- for (idx, _t), r in zip(keep, results):
459
+ out: list[Optional[dict[str, Any]]] = [None] * texts_len
460
+ for (orig_idx, _t), r in zip(texts_kept, results):
433
461
  if isinstance(r, dict):
434
- out[idx] = r
462
+ out[orig_idx] = r
435
463
  return out # type: ignore[return-value]
436
464
 
437
465
 
466
+ def _classify_jev(texts: list[str], labels: tuple[str, ...] | list[str], *,
467
+ instructions: str | None, criteria: dict[str, str] | None = None,
468
+ keep: list[tuple[int, str]],
469
+ timeout: float) -> Optional[list[dict[str, Any]]]:
470
+ """JEV 通道:每条文本一个请求,并发 4,带总体时间硬截止预算。"""
471
+ return _run_choice_batch(
472
+ len(texts), keep,
473
+ lambda t: _jev_choice(t, labels, instructions, timeout, criteria),
474
+ timeout=timeout,
475
+ )
476
+
477
+
478
+ def _gemini_choice(text: str, labels: tuple[str, ...] | list[str],
479
+ instructions: str | None, timeout: float,
480
+ criteria: dict[str, str] | None = None) -> Optional[dict[str, Any]]:
481
+ key = gemini_api_key()
482
+ if not key:
483
+ logger.debug("Gemini key 未配置(%s),跳过 Gemini 通道", " / ".join(GEMINI_KEY_ENV))
484
+ return None
485
+ cache_key = _get_cache_key(text, labels, instructions, criteria=criteria,
486
+ salt=f"gemini:{_gemini_model()}")
487
+ cached = _get_cached_result(cache_key)
488
+ if cached is not None:
489
+ return cached
490
+ question_payload: dict[str, Any] = {
491
+ "type": "choice",
492
+ "instructions": instructions or ("Classify the text into one of: " + ", ".join(labels)),
493
+ "criteria": criteria if criteria else {str(l): str(l) for l in labels},
494
+ }
495
+ body = {
496
+ "model": _gemini_model(),
497
+ "input": text[:MAX_TEXT_CHARS],
498
+ "questions": {"eval": question_payload},
499
+ }
500
+ headers = {
501
+ "x-goog-api-key": key,
502
+ "Content-Type": "application/json",
503
+ }
504
+ data = _post_json(_gemini_endpoint(), body, headers, timeout, "Gemini")
505
+ if not isinstance(data, dict):
506
+ return None
507
+ ans = data.get("answers", {}).get("eval", {})
508
+ choice = ans.get("choice")
509
+ if not choice:
510
+ return None
511
+ probs = ans.get("probabilities", {})
512
+ res = {
513
+ "label": str(choice),
514
+ "confidence": float(ans.get("confidence", 0.0)),
515
+ "scores": probs,
516
+ "probabilities": probs,
517
+ }
518
+ _set_cached_result(cache_key, res)
519
+ return res
520
+
521
+
522
+ def _classify_gemini(texts: list[str], labels: tuple[str, ...] | list[str], *,
523
+ instructions: str | None = None,
524
+ criteria: dict[str, str] | None = None,
525
+ keep: list[tuple[int, str]],
526
+ timeout: float = 5.0) -> Optional[list[Optional[dict[str, Any]]]]:
527
+ """Gemini 通道:每条文本一个请求,并发 4,整批硬截止取 DEFAULT_GEMINI_DEADLINE_S。
528
+
529
+ 与 JEV 的 1.2s 分开取值:Gemini 单条 p95 实测 2251ms(见常量注释),
530
+ 沿用 1.2s 会在批量里静默截断(实测 6 组 4 条里 1 组只回 3/4)。
531
+ """
532
+ if not gemini_api_key():
533
+ return None
534
+ return _run_choice_batch(
535
+ len(texts), keep,
536
+ lambda t: _gemini_choice(t, labels, instructions, timeout, criteria),
537
+ timeout=timeout,
538
+ deadline_s=DEFAULT_GEMINI_DEADLINE_S,
539
+ )
540
+
541
+
438
542
  def classify(texts: list[str], labels: tuple[str, ...] | list[str], *,
439
543
  instructions: str | None = None,
440
544
  criteria: dict[str, str] | None = None,
441
545
  timeout: float | None = None,
442
546
  tier: str | None = None) -> Optional[list[dict[str, Any]]]:
443
- """一次批量分类。任何异常/非 200/条数不匹配 → None。
547
+ """一次批量远程语义分类。任何异常/非 200/条数不匹配 → None。
444
548
 
445
- 返回按输入顺序排列的 [{label, confidence, scores}];调用方负责判定阈值。
446
- 空文本会被过滤后再发(空串会让整批 400),返回列表与输入等长、空缺位为 None。
447
-
448
- 两个通道的实现分居 _classify_jev(TypeSafe,每条一请求)与下方内联的
449
- classifier.dev 路径(一次发 N 条);开关判定见 _transport。
549
+ 远程通道按优先级自适应:Gemini Decision 1 ➔ TypeSafe JEV(互为备选),
550
+ 或显式走 classify。本地启发式兜底由上层 assess_*(allow_heuristic=True)承担。
450
551
  """
451
552
  if not texts or len(labels) < 2:
452
553
  return None
@@ -454,9 +555,25 @@ def classify(texts: list[str], labels: tuple[str, ...] | list[str], *,
454
555
  if not keep:
455
556
  return None
456
557
  to = timeout or _timeout()
457
- if _transport() == "jev":
558
+
559
+ tp = _transport()
560
+ if tp == "gemini":
561
+ res = _classify_gemini(texts, labels, instructions=instructions,
562
+ criteria=criteria, keep=keep, timeout=to)
563
+ if res is not None:
564
+ return res
565
+ # 降级至 JEV 备用通道
458
566
  return _classify_jev(texts, labels, instructions=instructions,
459
567
  criteria=criteria, keep=keep, timeout=to)
568
+
569
+ if tp == "jev":
570
+ res = _classify_jev(texts, labels, instructions=instructions,
571
+ criteria=criteria, keep=keep, timeout=to)
572
+ if res is not None:
573
+ return res
574
+ # 降级至 Gemini 备用通道
575
+ return _classify_gemini(texts, labels, instructions=instructions,
576
+ criteria=criteria, keep=keep, timeout=to)
460
577
  body: dict[str, Any] = {
461
578
  "labels": [str(x) for x in labels],
462
579
  "inputs": [t[:MAX_TEXT_CHARS] for _i, t in keep],
@@ -490,31 +607,46 @@ def classify(texts: list[str], labels: tuple[str, ...] | list[str], *,
490
607
  return out # type: ignore[return-value]
491
608
 
492
609
 
493
- def assess_support(query: str, items: list[dict[str, Any]]) -> Optional[dict[str, dict]]:
494
- """对已抓取的正文批量判定「是否支持查询隐含的主张」。
495
-
496
- items: [{"url": str, "title": str, "text": str}]
497
- 返回 {url: {label, confidence, supports, contradicts}};未达阈值时
498
- supports/contradicts 均为 False(原始 label 与 confidence 仍原样保留,
499
- 调用方可自行换阈值)。失败返回 None。
500
- 自动剔除本地文件(is_local_target),严格物理阻断私域外发。
501
- """
502
- usable = [it for it in items if (it.get("text") or "").strip() and it.get("url")
503
- and not is_local_target(it.get("url", ""))]
610
+ def _prepare_usable_texts(
611
+ items: list[dict[str, Any]], *, require_text: bool = True
612
+ ) -> tuple[list[dict[str, Any]], list[str]]:
613
+ """过滤非本地目标并拼装截断文本,统一三路语义评估的前置隔离逻辑。"""
614
+ usable = []
615
+ for it in items:
616
+ url = it.get("url")
617
+ if not url or is_local_target(url):
618
+ continue
619
+ has_text = bool((it.get("text") or "").strip())
620
+ has_title = bool((it.get("title") or "").strip())
621
+ if has_text or (not require_text and has_title):
622
+ usable.append(it)
623
+ texts = [
624
+ f"{it.get('title') or ''}\n{(it.get('text') or '')[:MAX_TEXT_CHARS]}"
625
+ for it in usable
626
+ ]
627
+ return usable, texts
628
+
629
+
630
+ def _assess_batch(
631
+ items: list[dict[str, Any]],
632
+ *,
633
+ require_text: bool,
634
+ labels: tuple[str, ...],
635
+ instructions: str,
636
+ criteria: dict[str, str] | None = None,
637
+ heuristic_fn: Any,
638
+ allow_heuristic: bool,
639
+ build_extra: Any,
640
+ ) -> Optional[dict[str, dict]]:
641
+ """三路语义评估的统一批处理框架:隔离本地目标、调用远程分类、按需启发式兜底与阈值判定。"""
642
+ usable, texts = _prepare_usable_texts(items, require_text=require_text)
504
643
  if not usable:
505
644
  return None
506
- texts = [f"{it.get('title') or ''}\n{(it.get('text') or '')[:MAX_TEXT_CHARS]}"
507
- for it in usable]
508
- instructions = (
509
- f"Judge whether each passage supports the claim implied by this query: {query!r}. "
510
- "Answer 'supports the query' when the passage backs the claim, "
511
- "'contradicts the query' when it states the opposite or a conflicting figure, "
512
- "'neutral' when it is on-topic but neither supports nor contradicts, "
513
- "and 'none of these' when it is unrelated to the query."
514
- )
515
- results = classify(texts, SUPPORT_LABELS, instructions=instructions)
645
+ results = classify(texts, labels, instructions=instructions, criteria=criteria)
516
646
  if results is None:
517
- return None
647
+ if not allow_heuristic:
648
+ return None
649
+ results = [heuristic_fn(it) for it in usable]
518
650
  out: dict[str, dict] = {}
519
651
  for it, r in zip(usable, results):
520
652
  if not r:
@@ -522,85 +654,160 @@ def assess_support(query: str, items: list[dict[str, Any]]) -> Optional[dict[str
522
654
  label = str(r.get("label") or "")
523
655
  conf = r.get("confidence")
524
656
  conf_f = float(conf) if isinstance(conf, (int, float)) else 0.0
525
- out[str(it["url"])] = {
526
- "label": label,
527
- "confidence": conf_f,
528
- "supports": label == "supports the query" and conf_f >= SUPPORT_THRESHOLD,
529
- "contradicts": label == "contradicts the query" and conf_f >= SUPPORT_THRESHOLD,
530
- }
657
+ entry: dict[str, Any] = {"label": label, "confidence": conf_f}
658
+ entry.update(build_extra(label, conf_f))
659
+ out[str(it["url"])] = entry
531
660
  return out or None
532
661
 
533
662
 
534
- def assess_source_types(items: list[dict[str, Any]]) -> Optional[dict[str, dict]]:
535
- """来源类型分级(研究取证链路用):一手数据 / 二手报道 / 分析观点 / 社交叙事。
663
+ def assess_support(query: str, items: list[dict[str, Any]], *, allow_heuristic: bool = False) -> Optional[dict[str, dict]]:
664
+ """对已抓取的正文批量判定「是否支持查询隐含的主张」。"""
665
+ instructions = (
666
+ f"Judge whether each passage supports the claim implied by this query: {query!r}. "
667
+ "Answer 'supports the query' when the passage backs the claim, "
668
+ "'contradicts the query' when it states the opposite or a conflicting figure, "
669
+ "'neutral' when it is on-topic but neither supports nor contradicts, "
670
+ "and 'none of these' when it is unrelated to the query."
671
+ )
672
+ return _assess_batch(
673
+ items,
674
+ require_text=True,
675
+ labels=SUPPORT_LABELS,
676
+ instructions=instructions,
677
+ heuristic_fn=lambda it: heuristic_support(query, it.get("text") or "", it.get("title") or ""),
678
+ allow_heuristic=allow_heuristic,
679
+ build_extra=lambda label, conf_f: {
680
+ "supports": label == "supports the query" and conf_f >= SUPPORT_THRESHOLD,
681
+ "contradicts": label == "contradicts the query" and conf_f >= SUPPORT_THRESHOLD,
682
+ },
683
+ )
536
684
 
537
- items: [{"url": str, "title": str, "text": str}](text 可为摘要)
538
- 自动剔除本地文件(is_local_target),严格物理阻断私域外发。
539
- """
540
- usable = [it for it in items if it.get("url") and
541
- ((it.get("text") or "").strip() or (it.get("title") or "").strip())
542
- and not is_local_target(it.get("url", ""))]
543
- if not usable:
544
- return None
545
- texts = [f"{it.get('title') or ''}\n{(it.get('text') or '')[:MAX_TEXT_CHARS]}"
546
- for it in usable]
685
+
686
+ _NON_CJK_EAST_ASIAN_RE = re.compile(r"[\u3040-\u30ff]{2,}|[\uac00-\ud7af]{2,}")
687
+ _SENTENCE_SPLIT_RE = re.compile(r"[。!?.!?\n]+")
688
+
689
+
690
+ def _heuristic_tokens(text: str) -> list[str]:
691
+ """复用 cjk_tokens 切分中英信号,并扩展日文假名/韩文音节重叠 2-gram。"""
692
+ from cjk_tokens import cjk_ngrams, signal_tokens
693
+ tokens = signal_tokens(text)
694
+ for run in _NON_CJK_EAST_ASIAN_RE.findall(text or ""):
695
+ tokens.extend(cjk_ngrams(run))
696
+ deduped = list(dict.fromkeys(t for t in tokens if len(t) >= 2))
697
+ if not deduped and (text or "").strip():
698
+ return [(text or "").strip().lower()]
699
+ return deduped
700
+
701
+
702
+ def heuristic_substantive_discussion(topic: str, text: str, title: str = "") -> dict[str, Any]:
703
+ """本地高精度启发式深度判定:区分实质深入探讨 vs 顺带提及(零网络、零外部 Key 依赖)。"""
704
+ t_clean = (topic or "").strip().lower()
705
+ full_text = f"{title}\n{text}".lower()
706
+ if not t_clean or not full_text.strip():
707
+ return {"label": "none of these", "confidence": 0.5}
708
+
709
+ tokens = _heuristic_tokens(topic)
710
+ title_low = (title or "").lower()
711
+ title_hit = any(tok in title_low for tok in tokens)
712
+ sentences = [s.strip() for s in _SENTENCE_SPLIT_RE.split(text.lower()) if s.strip()]
713
+ sent_hits = sum(1 for s in sentences if any(tok in s for tok in tokens))
714
+ token_hits = sum(1 for tok in tokens if tok in full_text)
715
+ text_len = len(text.strip())
716
+
717
+ # 实质探讨:(标题明确命中且正文 >= 30 字) 或 (至少 2 个独立句命中主题且篇幅 >= 60 字)
718
+ if (title_hit and text_len >= 30) or (sent_hits >= 2 and text_len >= 60):
719
+ return {"label": "substantive in-depth discussion", "confidence": 0.88}
720
+ # 顺带提及:单句提及或篇幅不足
721
+ if token_hits >= 1 or sent_hits >= 1 or text_len >= 40:
722
+ return {"label": "passing mention or brief reference", "confidence": 0.78}
723
+ return {"label": "unrelated chatter", "confidence": 0.72}
724
+
725
+
726
+ def heuristic_source_type(url: str, title: str = "", text: str = "") -> dict[str, Any]:
727
+ """本地高精度启发式来源类型分级(零网络、零外部依赖)。"""
728
+ u_low = (url or "").lower()
729
+ full_text = f"{title}\n{text}".lower()
730
+
731
+ primary_domains = (
732
+ ".gov", ".edu", "sec.gov", "arxiv.org", "biorxiv.org", "github.com",
733
+ "rfc-editor.org", "federalregister.gov", "w3.org", "nature.com"
734
+ )
735
+ primary_keywords = ("official announcement", "press release", "filing", "whitepaper", "documentation", "公报", "公告", "官方发布")
736
+ if any(d in u_low for d in primary_domains) or any(k in full_text for k in primary_keywords):
737
+ return {"label": "primary data or official announcement", "confidence": 0.86}
738
+
739
+ social_domains = ("x.com", "twitter.com", "reddit.com", "weibo.com", "zhihu.com", "v2ex.com", "news.ycombinator.com")
740
+ if any(d in u_low for d in social_domains):
741
+ return {"label": "social narrative", "confidence": 0.82}
742
+
743
+ opinion_keywords = ("analysis", "opinion", "commentary", "review", "perspective", "评论", "专栏", "深度分析")
744
+ if any(k in full_text for k in opinion_keywords):
745
+ return {"label": "analysis or opinion", "confidence": 0.76}
746
+
747
+ return {"label": "secondary reporting", "confidence": 0.75}
748
+
749
+
750
+ def heuristic_support(query: str, text: str, title: str = "") -> dict[str, Any]:
751
+ """本地高精度启发式证据支持度初筛(零网络、零外部依赖,支持 CJK/多语 2-gram 与同句极性窗口)。"""
752
+ full_text = f"{title}\n{text}".lower()
753
+ tokens = _heuristic_tokens(query)
754
+ if not tokens:
755
+ return {"label": "neutral", "confidence": 0.70}
756
+ hits = sum(1 for tok in tokens if tok in full_text)
757
+ contra_words = (
758
+ "keep unchanged", "remain unchanged", "defying", "opposite", "denied", "contrary",
759
+ "未降息", "维持不变", "并未", "未如", "反驳", "并非", "否认",
760
+ )
761
+ sentences = [s.strip() for s in _SENTENCE_SPLIT_RE.split(full_text) if s.strip()]
762
+ has_contra = any(
763
+ any(w in s for w in contra_words) and any(tok in s for tok in tokens)
764
+ for s in sentences
765
+ )
766
+ if has_contra:
767
+ return {"label": "contradicts the query", "confidence": 0.85}
768
+ ratio = hits / len(tokens)
769
+ has_cjk = any(ord(c) > 0x2E80 for c in query)
770
+ min_hits = 2 if (has_cjk and len(tokens) > 2) else 1
771
+ threshold = 0.25 if has_cjk else 0.65
772
+ if ratio >= threshold and hits >= min_hits:
773
+ return {"label": "supports the query", "confidence": 0.80}
774
+ return {"label": "neutral", "confidence": 0.70}
775
+
776
+
777
+ def assess_source_types(items: list[dict[str, Any]], *, allow_heuristic: bool = False) -> Optional[dict[str, dict]]:
778
+ """来源类型分级(研究取证链路用):一手数据 / 二手报道 / 分析观点 / 社交叙事。"""
547
779
  instructions = (
548
780
  "Classify each source by its nature: 'primary data or official announcement' "
549
781
  "for original datasets, filings, official releases; 'secondary reporting' for "
550
782
  "news coverage of someone else's work; 'analysis or opinion' for commentary; "
551
783
  "'social narrative' for forum/social posts."
552
784
  )
553
- results = classify(texts, SOURCE_TYPE_LABELS, instructions=instructions)
554
- if results is None:
555
- return None
556
- out: dict[str, dict] = {}
557
- for it, r in zip(usable, results):
558
- if not r:
559
- continue
560
- label = str(r.get("label") or "")
561
- conf = r.get("confidence")
562
- conf_f = float(conf) if isinstance(conf, (int, float)) else 0.0
563
- out[str(it["url"])] = {
564
- "label": label,
565
- "confidence": conf_f,
566
- "is_primary": (label == "primary data or official announcement" and conf_f >= SUPPORT_THRESHOLD),
567
- }
568
- return out or None
569
-
785
+ return _assess_batch(
786
+ items,
787
+ require_text=False,
788
+ labels=SOURCE_TYPE_LABELS,
789
+ instructions=instructions,
790
+ heuristic_fn=lambda it: heuristic_source_type(it.get("url") or "", it.get("title") or "", it.get("text") or ""),
791
+ allow_heuristic=allow_heuristic,
792
+ build_extra=lambda label, conf_f: {
793
+ "is_primary": label == "primary data or official announcement" and conf_f >= SUPPORT_THRESHOLD,
794
+ },
795
+ )
570
796
 
571
- def assess_substantive_discussion(topic: str, items: list[dict[str, Any]]) -> Optional[dict[str, dict]]:
572
- """对正文/播客单集转录/长篇段落批量判定「是否对主题进行了实质性深入探讨」。
573
797
 
574
- 用于复杂需求与播客/音视频长文本场景,区分:
575
- - substantive in-depth discussion: 深入、实质性探讨或核心讲解
576
- - passing mention or brief reference: 顺带提及、比喻借用或偏题带过
577
- - unrelated chatter: 闲聊或偏离主题
578
- 自动剔除本地文件(is_local_target),严格物理阻断私域外发。
579
- """
580
- usable = [it for it in items if (it.get("text") or "").strip() and it.get("url")
581
- and not is_local_target(it.get("url", ""))]
582
- if not usable:
583
- return None
584
- texts = [f"{it.get('title') or ''}\n{(it.get('text') or '')[:MAX_TEXT_CHARS]}"
585
- for it in usable]
586
- instructions = f"Determine the depth of discussion regarding the topic {topic!r} in the text."
587
- results = classify(texts, SUBSTANTIVE_DISCUSSION_LABELS,
588
- instructions=instructions,
589
- criteria=SUBSTANTIVE_DISCUSSION_CRITERIA)
590
- if results is None:
591
- return None
592
- out: dict[str, dict] = {}
593
- for it, r in zip(usable, results):
594
- if not r:
595
- continue
596
- label = str(r.get("label") or "")
597
- conf = r.get("confidence")
598
- conf_f = float(conf) if isinstance(conf, (int, float)) else 0.0
599
- out[str(it["url"])] = {
600
- "label": label,
601
- "confidence": conf_f,
602
- "is_substantive": (label == "substantive in-depth discussion" and conf_f >= SUPPORT_THRESHOLD),
603
- "is_passing_mention": (label == "passing mention or brief reference" and conf_f >= SUPPORT_THRESHOLD),
604
- }
605
- return out or None
798
+ def assess_substantive_discussion(topic: str, items: list[dict[str, Any]], *, allow_heuristic: bool = False) -> Optional[dict[str, dict]]:
799
+ """批量判定正文对主题是否进行了实质性深入探讨(或顺带提及 / 闲聊)。"""
800
+ return _assess_batch(
801
+ items,
802
+ require_text=True,
803
+ labels=SUBSTANTIVE_DISCUSSION_LABELS,
804
+ instructions=f"Determine the depth of discussion regarding the topic {topic!r} in the text.",
805
+ criteria=SUBSTANTIVE_DISCUSSION_CRITERIA,
806
+ heuristic_fn=lambda it: heuristic_substantive_discussion(topic, it.get("text") or "", it.get("title") or ""),
807
+ allow_heuristic=allow_heuristic,
808
+ build_extra=lambda label, conf_f: {
809
+ "is_substantive": label == "substantive in-depth discussion" and conf_f >= SUPPORT_THRESHOLD,
810
+ "is_passing_mention": label == "passing mention or brief reference" and conf_f >= SUPPORT_THRESHOLD,
811
+ },
812
+ )
606
813