argo-search 2.11.2 → 2.13.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.
- package/README.en.md +36 -21
- package/README.es.md +36 -21
- package/README.ja.md +39 -22
- package/README.ko.md +36 -21
- package/README.md +74 -51
- package/SKILL.md +8 -8
- package/assets/readme/counts.json +1 -0
- package/assets/readme/hero.svg +1 -1
- package/backends/domain_profiles.json +24 -0
- package/backends/engine_registry.yaml +59 -7
- package/backends/env_passthrough.txt +73 -0
- package/backends/quota_profiles.json +41 -1
- package/bin/argo +7 -0
- package/config.yaml +25 -3526
- package/docs/ARGO_INTRO.md +4 -3
- package/docs/CHANGELOG.md +314 -0
- package/docs/ENGINE_CATALOG.md +60 -56
- package/docs/MCP_SETUP.md +16 -4
- package/docs/QUALITY_OF_SLOW_SOURCES.md +115 -0
- package/docs/RELEASE_NOTES_v2.11.2.md +116 -0
- package/docs/RELEASE_NOTES_v2.12.0.md +65 -0
- package/docs/RELEASE_NOTES_v2.13.0.md +66 -0
- package/docs/RELEASING.md +47 -0
- package/docs//344/270/272/344/273/200/344/271/210/351/200/211/346/213/251argo.md +7 -7
- package/engines/specs/anysearch.yaml +33 -0
- package/engines/specs/archive_org.yaml +31 -0
- package/engines/specs/arxiv.yaml +18 -0
- package/engines/specs/baidu_baike.yaml +16 -0
- package/engines/specs/baidu_hot.yaml +19 -0
- package/engines/specs/bilibili.yaml +33 -0
- package/engines/specs/bilibili_hot.yaml +19 -0
- package/engines/specs/bing_rss.yaml +17 -0
- package/engines/specs/biorxiv.yaml +2 -0
- package/engines/specs/bocha.yaml +26 -0
- package/engines/specs/bocha_ai.yaml +27 -0
- package/engines/specs/brave.yaml +20 -0
- package/engines/specs/byted.yaml +33 -0
- package/engines/specs/clinicaltrials.yaml +15 -0
- package/engines/specs/cls_telegraph.yaml +19 -0
- package/engines/specs/cnii.yaml +16 -0
- package/engines/specs/cninfo.yaml +14 -0
- package/engines/specs/coingecko.yaml +25 -0
- package/engines/specs/courtlistener.yaml +15 -0
- package/engines/specs/crates.yaml +30 -0
- package/engines/specs/crossref.yaml +27 -0
- package/engines/specs/csdn.yaml +18 -0
- package/engines/specs/dblp.yaml +29 -0
- package/engines/specs/devto.yaml +26 -0
- package/engines/specs/dnb.yaml +17 -0
- package/engines/specs/doaj.yaml +17 -0
- package/engines/specs/docker_hub.yaml +30 -0
- package/engines/specs/douban_book.yaml +14 -0
- package/engines/specs/douyin_hot.yaml +21 -0
- package/engines/specs/eastmoney.yaml +16 -0
- package/engines/specs/ecosia.yaml +18 -0
- package/engines/specs/electricity_maps.yaml +17 -0
- package/engines/specs/em_flow.yaml +14 -0
- package/engines/specs/em_global_news.yaml +17 -0
- package/engines/specs/em_miaoxiang.yaml +14 -0
- package/engines/specs/eu_opendata.yaml +16 -0
- package/engines/specs/europeana.yaml +19 -0
- package/engines/specs/europepmc.yaml +29 -0
- package/engines/specs/eurostat.yaml +14 -0
- package/engines/specs/exa.yaml +20 -0
- package/engines/specs/felo.yaml +25 -0
- package/engines/specs/figshare.yaml +17 -0
- package/engines/specs/finviz.yaml +15 -0
- package/engines/specs/fr_opendata.yaml +28 -0
- package/engines/specs/frankfurter.yaml +21 -0
- package/engines/specs/fred.yaml +15 -0
- package/engines/specs/free_dictionary.yaml +16 -0
- package/engines/specs/fx_rate.yaml +14 -0
- package/engines/specs/gbfs_nyc.yaml +3 -0
- package/engines/specs/gbif.yaml +15 -0
- package/engines/specs/github.yaml +25 -0
- package/engines/specs/google_patents.yaml +16 -0
- package/engines/specs/google_scholar.yaml +16 -0
- package/engines/specs/gov_policy.yaml +31 -0
- package/engines/specs/gutenberg.yaml +15 -0
- package/engines/specs/hackernews.yaml +17 -0
- package/engines/specs/hal.yaml +16 -0
- package/engines/specs/hatena_bookmark.yaml +20 -0
- package/engines/specs/huggingface.yaml +31 -0
- package/engines/specs/imdb.yaml +18 -0
- package/engines/specs/itotii.yaml +17 -0
- package/engines/specs/itunes.yaml +19 -0
- package/engines/specs/jin10.yaml +15 -0
- package/engines/specs/juejin.yaml +16 -0
- package/engines/specs/know_your_meme.yaml +18 -0
- package/engines/specs/kor_law.yaml +17 -0
- package/engines/specs/lieu.yaml +18 -0
- package/engines/specs/listenbrainz.yaml +4 -0
- package/engines/specs/local_arxiv.yaml +18 -0
- package/engines/specs/local_baidu.yaml +30 -0
- package/engines/specs/local_bing.yaml +16 -0
- package/engines/specs/local_bing_news.yaml +22 -0
- package/engines/specs/local_crossref.yaml +23 -0
- package/engines/specs/local_github.yaml +27 -0
- package/engines/specs/local_gitlab.yaml +23 -0
- package/engines/specs/local_goodreads.yaml +16 -0
- package/engines/specs/local_google_news.yaml +15 -0
- package/engines/specs/local_imdb.yaml +17 -0
- package/engines/specs/local_npm.yaml +25 -0
- package/engines/specs/local_openstreetmap.yaml +36 -0
- package/engines/specs/local_pubmed.yaml +21 -0
- package/engines/specs/local_search.yaml +22 -0
- package/engines/specs/local_semantic_scholar.yaml +23 -0
- package/engines/specs/local_sogou.yaml +15 -0
- package/engines/specs/local_stackoverflow.yaml +26 -0
- package/engines/specs/local_wikipedia.yaml +26 -0
- package/engines/specs/local_wikiquote.yaml +26 -0
- package/engines/specs/local_wiktionary.yaml +26 -0
- package/engines/specs/marginalia.yaml +22 -0
- package/engines/specs/mdn.yaml +32 -0
- package/engines/specs/met_museum.yaml +4 -2
- package/engines/specs/metaso.yaml +19 -0
- package/engines/specs/models_dev.yaml +16 -0
- package/engines/specs/moegirl.yaml +19 -0
- package/engines/specs/musicbrainz.yaml +31 -0
- package/engines/specs/nasa_cmr.yaml +15 -0
- package/engines/specs/nbs_stats.yaml +16 -0
- package/engines/specs/ndl.yaml +17 -0
- package/engines/specs/noaa_swpc.yaml +3 -0
- package/engines/specs/npm.yaml +62 -0
- package/engines/specs/octen.yaml +16 -0
- package/engines/specs/open_library.yaml +15 -0
- package/engines/specs/open_meteo.yaml +17 -0
- package/engines/specs/openalex.yaml +27 -0
- package/engines/specs/opencitations.yaml +4 -1
- package/engines/specs/opencorporates.yaml +19 -0
- package/engines/specs/openfda.yaml +15 -0
- package/engines/specs/opensky.yaml +17 -0
- package/engines/specs/openverse.yaml +42 -0
- package/engines/specs/parallel.yaml +22 -0
- package/engines/specs/parallel_free.yaml +20 -0
- package/engines/specs/pixiv.yaml +52 -0
- package/engines/specs/polymarket.yaml +26 -0
- package/engines/specs/pubchem.yaml +15 -0
- package/engines/specs/pypi.yaml +16 -0
- package/engines/specs/qiita.yaml +28 -0
- package/engines/specs/qq_music.yaml +17 -0
- package/engines/specs/qwant.yaml +19 -0
- package/engines/specs/qweather.yaml +14 -0
- package/engines/specs/rcsb_pdb.yaml +15 -0
- package/engines/specs/reddit.yaml +28 -0
- package/engines/specs/redskill.yaml +24 -0
- package/engines/specs/rfc_editor.yaml +15 -0
- package/engines/specs/satnogs.yaml +5 -1
- package/engines/specs/searchmysite.yaml +18 -0
- package/engines/specs/searxng.yaml +18 -0
- package/engines/specs/sec_companyfacts.yaml +22 -0
- package/engines/specs/seeking_alpha.yaml +15 -0
- package/engines/specs/seltz.yaml +39 -0
- package/engines/specs/semantic_scholar.yaml +18 -0
- package/engines/specs/shenma.yaml +13 -0
- package/engines/specs/sina_quote.yaml +15 -0
- package/engines/specs/so.yaml +13 -0
- package/engines/specs/stackoverflow.yaml +18 -0
- package/engines/specs/steam.yaml +30 -0
- package/engines/specs/tatoeba.yaml +17 -0
- package/engines/specs/tavily.yaml +26 -0
- package/engines/specs/tencent_kline.yaml +18 -0
- package/engines/specs/tencent_quote.yaml +14 -0
- package/engines/specs/thesportsdb.yaml +18 -0
- package/engines/specs/ths_hot.yaml +19 -0
- package/engines/specs/tinyfish.yaml +36 -0
- package/engines/specs/tinyfish_news.yaml +34 -0
- package/engines/specs/tinyfish_paper.yaml +34 -0
- package/engines/specs/toutiao_hot.yaml +19 -0
- package/engines/specs/tracemoe.yaml +33 -0
- package/engines/specs/twitter.yaml +36 -0
- package/engines/specs/uapi.yaml +18 -0
- package/engines/specs/uniprot.yaml +16 -0
- package/engines/specs/urban_dictionary.yaml +25 -0
- package/engines/specs/usda.yaml +17 -0
- package/engines/specs/usgs.yaml +15 -0
- package/engines/specs/v2ex.yaml +33 -0
- package/engines/specs/vam.yaml +34 -0
- package/engines/specs/wallhaven.yaml +51 -0
- package/engines/specs/wallstreetcn.yaml +31 -0
- package/engines/specs/wayback_cdx.yaml +15 -0
- package/engines/specs/weather_cn.yaml +33 -0
- package/engines/specs/wechat_sogou.yaml +13 -0
- package/engines/specs/weibo.yaml +21 -0
- package/engines/specs/weibo_hot.yaml +21 -0
- package/engines/specs/wenshu.yaml +14 -0
- package/engines/specs/weread.yaml +14 -0
- package/engines/specs/wiby.yaml +18 -0
- package/engines/specs/wikidata.yaml +33 -0
- package/engines/specs/wikipedia.yaml +36 -0
- package/engines/specs/wolframalpha.yaml +18 -0
- package/engines/specs/worldbank.yaml +15 -0
- package/engines/specs/xiaohongshu.yaml +25 -0
- package/engines/specs/yahoo_finance.yaml +22 -0
- package/engines/specs/you.yaml +22 -0
- package/engines/specs/zh_wikipedia.yaml +35 -0
- package/engines/specs/zhihu.yaml +33 -0
- package/engines/specs/zhihu_global.yaml +18 -0
- package/engines/specs/zhihu_hot.yaml +36 -0
- package/engines/specs/zhihu_user.yaml +14 -0
- package/package.json +25 -24
- package/packages/dsh-plugin/README.md +28 -14
- package/packages/dsh-plugin/cordis.patch.yml +6 -2
- package/packages/dsh-plugin/dsh/client.js +67 -119
- package/packages/dsh-plugin/dsh/index.js +24 -178
- package/packages/dsh-plugin/dsh/runner.js +12 -2
- package/packages/dsh-plugin/dsh/specs.js +133 -0
- package/packages/dsh-plugin/package.json +10 -2
- package/packages/dsh-plugin/scripts/sync-local.sh +13 -11
- package/packages/dsh-plugin/test/client.test.js +20 -9
- package/packages/dsh-plugin/test/diagnostics.test.js +1 -1
- package/packages/dsh-plugin/test/index.test.js +28 -2
- package/packages/dsh-plugin/test/size-gate.test.js +2 -2
- package/scripts/ab_eval_p0p1.py +10 -4
- package/scripts/adaptive.py +101 -27
- package/scripts/archive_run.py +4 -2
- package/scripts/badcase_ledger.py +3 -1
- package/scripts/batch_probe.py +10 -8
- package/scripts/build_release_assets.sh +17 -5
- package/scripts/build_route_labels.py +122 -169
- package/scripts/cache.py +5 -5
- package/scripts/cache_guard.py +10 -5
- package/scripts/caliber_dedupe.py +4 -4
- package/scripts/caliber_isolation.py +17 -17
- package/scripts/candidate_envelope.py +7 -3
- package/scripts/circuit_breaker.py +220 -36
- package/scripts/concept_lookup.py +14 -1
- package/scripts/config.py +30 -13
- package/scripts/daemon.py +11 -2
- package/scripts/engine_add.py +32 -0
- package/scripts/engine_admission.py +35 -17
- package/scripts/engine_dispatch.py +65 -62
- package/scripts/engine_env.py +4 -0
- package/scripts/engine_failure.py +14 -18
- package/scripts/engine_families.py +6 -4
- package/scripts/engine_health.py +184 -0
- package/scripts/engine_states.py +604 -0
- package/scripts/engine_status.py +18 -11
- package/scripts/engines.py +7 -0
- package/scripts/engines_base.py +9 -9
- package/scripts/engines_builders.py +31 -19
- package/scripts/engines_builders_archive.py +303 -0
- package/scripts/engines_builders_batch11.py +63 -1
- package/scripts/engines_builders_batch9.py +9 -1
- package/scripts/engines_builders_data.py +69 -2090
- package/scripts/engines_builders_finance.py +354 -0
- package/scripts/engines_builders_intl.py +4 -1
- package/scripts/engines_builders_media.py +724 -0
- package/scripts/engines_builders_pixiv.py +633 -0
- package/scripts/engines_builders_reverse_image.py +175 -0
- package/scripts/engines_builders_science.py +784 -0
- package/scripts/env_store.py +216 -0
- package/scripts/extend_route_labels_by_capability.py +4 -4
- package/scripts/extend_route_labels_full_coverage.py +329 -0
- package/scripts/fetch_v3.py +88 -19
- package/scripts/gen_engine_catalog.py +58 -153
- package/scripts/gen_routing_snapshot.py +8 -6
- package/scripts/health_check.py +37 -4
- package/scripts/health_probe.py +28 -8
- package/scripts/install.ps1 +31 -15
- package/scripts/install.sh +266 -142
- package/scripts/job.py +35 -72
- package/scripts/lint_spec_contracts.py +7 -12
- package/scripts/local_image.py +22 -8
- package/scripts/mcp_compact.py +9 -1
- package/scripts/mcp_launch.sh +9 -17
- package/scripts/mcp_setup.py +85 -1
- package/scripts/mcp_transport.py +1 -1
- package/scripts/net_proxy.py +47 -0
- package/scripts/numeric_verify.py +20 -9
- package/scripts/output_transparency.py +21 -13
- package/scripts/plan.py +10 -7
- package/scripts/pre-commit +53 -23
- package/scripts/query_signals.py +35 -20
- package/scripts/quota.py +19 -10
- package/scripts/recovery.py +38 -13
- package/scripts/redskill/redskill_engine.py +36 -19
- package/scripts/release.py +60 -24
- package/scripts/release_check.py +20 -3
- package/scripts/research_dossier.py +10 -5
- package/scripts/research_gates.py +5 -1
- package/scripts/retry_policy.py +8 -7
- package/scripts/route.py +4 -26
- package/scripts/route_accuracy_eval.py +2 -2
- package/scripts/route_combo.py +33 -29
- package/scripts/route_domains.py +182 -50
- package/scripts/search.py +3 -12
- package/scripts/search_attribution.py +34 -3
- package/scripts/search_cli.py +12 -11
- package/scripts/search_entry.py +53 -45
- package/scripts/search_output.py +7 -2
- package/scripts/search_pipeline.py +17 -18
- package/scripts/search_rank.py +42 -66
- package/scripts/search_types.py +5 -0
- package/scripts/serp_guard.py +7 -16
- package/scripts/settings_page.py +486 -0
- package/scripts/social_engines/bilibili_engine.py +2 -30
- package/scripts/social_engines/hackernews_engine.py +4 -12
- package/scripts/social_engines/reddit_engine.py +4 -13
- package/scripts/social_engines/v2ex_engine.py +3 -12
- package/scripts/social_engines/weibo_engine.py +2 -30
- package/scripts/social_engines/zhihu_engine.py +4 -5
- package/scripts/stats_cli.py +17 -1
- package/scripts/straggler_policy.py +8 -4
- package/scripts/sync_backends.py +211 -8
- package/scripts/sync_requirements.py +159 -0
- package/scripts/tfidf_router.py +82 -24
- package/scripts/tweet.py +3 -6
- package/scripts/usage_log.py +28 -9
- package/scripts/video_fetch.py +2 -5
- package/scripts/watch.py +11 -6
- package/scripts/wechat_article.py +6 -9
- package/scripts/wx.py +6 -13
- package/sub-skills/local-search/SKILL.md +2 -2
- package/sub-skills/local-search/config.yaml +2 -1
- package/docs/DATA_SOURCE_GAPS.md +0 -81
- package/docs/DESIGN_LOCAL_DATA_FUSION.md +0 -90
- package/docs/PLATFORM_PATHS.md +0 -111
- package/docs/engines/bangumi.md +0 -27
- package/docs/engines/biorxiv.md +0 -27
- package/docs/engines/clawhub.md +0 -27
- package/docs/engines/crt_sh.md +0 -27
- package/docs/engines/datacite.md +0 -27
- package/docs/engines/deps_dev.md +0 -27
- package/docs/engines/douban_movie.md +0 -27
- package/docs/engines/endoflife.md +0 -27
- package/docs/engines/flk_law.md +0 -27
- package/docs/engines/fxtwitter.md +0 -27
- package/docs/engines/google_news.md +0 -27
- package/docs/engines/gov_regulations.md +0 -27
- package/docs/engines/guqian.md +0 -27
- package/docs/engines/hackernews.md +0 -27
- package/docs/engines/iplant.md +0 -27
- package/docs/engines/keenable.md +0 -27
- package/docs/engines/met_museum.md +0 -27
- package/docs/engines/nasa_images.md +0 -27
- package/docs/engines/netease_music.md +0 -27
- package/docs/engines/npm.md +0 -27
- package/docs/engines/nvd.md +0 -27
- package/docs/engines/openreview.md +0 -27
- package/docs/engines/openstd.md +0 -27
- package/docs/engines/parallel_free.md +0 -27
- package/docs/engines/people_daily.md +0 -27
- package/docs/engines/realtime_index.md +0 -27
- package/docs/engines/sec_edgar.md +0 -27
- package/docs/engines/seltz.md +0 -27
- package/docs/engines/skillsmp.md +0 -27
- package/docs/engines/sspai.md +0 -27
- package/docs/engines/std_samr.md +0 -27
- package/docs/engines/train.md +0 -27
- package/docs/engines/un_comtrade.md +0 -27
- package/docs/engines/wikisource.md +0 -27
- package/docs/engines/zdic.md +0 -27
- package/docs/engines/zenodo.md +0 -27
- package/docs/engines/zhihu_hot_app.md +0 -27
|
@@ -21,6 +21,8 @@ from __future__ import annotations
|
|
|
21
21
|
|
|
22
22
|
from typing import Any, Iterable
|
|
23
23
|
|
|
24
|
+
import engine_states # 状态词表唯一真源(2026-11-09 收口)
|
|
25
|
+
|
|
24
26
|
# 写进日志的慢源条数:日志是 append-only JSONL,超限会回缩,
|
|
25
27
|
# 慢源恒在前排,Top-3 足够定位瓶颈而不必留全量底。
|
|
26
28
|
DEFAULT_TOP_N = 3
|
|
@@ -47,7 +49,7 @@ def usage_log_attribution(engine_latency: dict[str, Any] | None,
|
|
|
47
49
|
top_n: int = DEFAULT_TOP_N,
|
|
48
50
|
engine_outcomes: Iterable[dict[str, Any]] | None = None
|
|
49
51
|
) -> dict[str, Any]:
|
|
50
|
-
"""usage_log query 流的归因字段(慢源 Top-N + 失败类别)。
|
|
52
|
+
"""usage_log query 流的归因字段(慢源 Top-N + 各引擎交付条数 + 失败类别)。
|
|
51
53
|
|
|
52
54
|
返回 dict 以便调用方 **展开进日志记录**,未来新增归因维度(如
|
|
53
55
|
「等待预算被谁耗掉」「缓存未命中的原因分布」)时只扩这里,
|
|
@@ -59,6 +61,9 @@ def usage_log_attribution(engine_latency: dict[str, Any] | None,
|
|
|
59
61
|
out: dict[str, Any] = {
|
|
60
62
|
"engine_latency_top": top_engine_latency(engine_latency, top_n),
|
|
61
63
|
}
|
|
64
|
+
counts = engine_result_counts(engine_outcomes)
|
|
65
|
+
if counts:
|
|
66
|
+
out["engine_results"] = counts
|
|
62
67
|
kinds = failure_kinds(engine_outcomes)
|
|
63
68
|
if kinds:
|
|
64
69
|
out["failure_kinds"] = kinds
|
|
@@ -83,8 +88,10 @@ def is_synthetic_run(engines: Iterable[str] | None) -> bool:
|
|
|
83
88
|
# 只收持续性状态(配额/缺 env/鉴权),不含 timeout/error——后者是本次
|
|
84
89
|
# 真的失败了,原表述已够用。
|
|
85
90
|
SKIPPED_SOURCE_STATUSES: frozenset[str] = frozenset({
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
engine_states.OUTCOME_SKIPPED_QUOTA,
|
|
92
|
+
engine_states.OUTCOME_SKIPPED_MISSING_ENV,
|
|
93
|
+
engine_states.OUTCOME_QUOTA_EXHAUSTED,
|
|
94
|
+
engine_states.OUTCOME_AUTH_FAILED,
|
|
88
95
|
})
|
|
89
96
|
|
|
90
97
|
|
|
@@ -135,6 +142,30 @@ def zero_result_recovery_note(recovery: Any,
|
|
|
135
142
|
)
|
|
136
143
|
|
|
137
144
|
|
|
145
|
+
def engine_result_counts(engine_outcomes: Iterable[dict[str, Any]] | None,
|
|
146
|
+
limit: int = 8) -> dict[str, int]:
|
|
147
|
+
"""每个引擎交付的有效结果条数 {引擎: 条数},与 engine_latency_top 配对读。
|
|
148
|
+
|
|
149
|
+
只有耗时回答不了「慢源是在拖尾,还是唯一出货的那个」(2026-11-08 实测:
|
|
150
|
+
wechat_sogou 580ms 返回 0 条、sogou_weixin_browser 2342ms 交付全部 10 条,
|
|
151
|
+
仅凭耗时会被误判成「白等慢源」)。条数取自 outcome.results_count(与
|
|
152
|
+
agent 档 engine_outcomes 同一口径);被跳过、取消、失败的引擎记 0。
|
|
153
|
+
同名引擎多次出现(如补搜)取最大值;畸形条目跳过;上限与 engines_used 一致。
|
|
154
|
+
"""
|
|
155
|
+
out: dict[str, int] = {}
|
|
156
|
+
for o in (engine_outcomes or []):
|
|
157
|
+
if not isinstance(o, dict) or not o.get("engine"):
|
|
158
|
+
continue
|
|
159
|
+
n = o.get("results_count")
|
|
160
|
+
n = n if isinstance(n, int) and not isinstance(n, bool) and n > 0 else 0
|
|
161
|
+
name = str(o["engine"])
|
|
162
|
+
if name in out:
|
|
163
|
+
out[name] = max(out[name], n)
|
|
164
|
+
elif len(out) < max(0, int(limit)):
|
|
165
|
+
out[name] = n
|
|
166
|
+
return out
|
|
167
|
+
|
|
168
|
+
|
|
138
169
|
def failure_kinds(engine_outcomes: Iterable[dict[str, Any]] | None,
|
|
139
170
|
limit: int = 6) -> list[str]:
|
|
140
171
|
"""本次调用的失败类别(去重、稳定排序),写进 usage_log 供长期归因。
|
package/scripts/search_cli.py
CHANGED
|
@@ -18,6 +18,7 @@ import time
|
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
20
|
from cli_io import dumps, ensure_utf8_stdio
|
|
21
|
+
import engine_states # 状态词表唯一真源(2026-11-09 收口)
|
|
21
22
|
from engine_env import env_flag
|
|
22
23
|
from stage_timing import StageTiming
|
|
23
24
|
from time_utils import WINDOW_FORMATS_HINT, is_valid_time_window
|
|
@@ -282,26 +283,26 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
282
283
|
# 不可自动路由的成因,顺序即优先级:一个源可能同时缺 env 又缺依赖,若把每种
|
|
283
284
|
# 成立的理由都计一次,分组之和会大于「不可路由总数」,自相矛盾。只认第一个。
|
|
284
285
|
_ENGINE_BLOCK_REASONS: tuple[tuple[str, str], ...] = (
|
|
285
|
-
(
|
|
286
|
-
(
|
|
287
|
-
(
|
|
288
|
-
(
|
|
289
|
-
(
|
|
286
|
+
(engine_states.ENGINE_BLOCK_DISABLED, "enabled=False(未启用)"),
|
|
287
|
+
(engine_states.ENGINE_BLOCK_MISSING_ENV, "缺环境变量(配好密钥即可用)"),
|
|
288
|
+
(engine_states.ENGINE_BLOCK_MISSING_DEPS, "缺可选依赖(装好即可用)"),
|
|
289
|
+
(engine_states.ENGINE_BLOCK_QUOTA_EXHAUSTED, "配额耗尽(等窗口重置)"),
|
|
290
|
+
(engine_states.ENGINE_BLOCK_NOT_ROUTABLE, "其它不可路由(见 --engine <名> 全量行)"),
|
|
290
291
|
)
|
|
291
292
|
|
|
292
293
|
|
|
293
294
|
def _engine_block_reason(row: dict[str, Any]) -> str | None:
|
|
294
295
|
"""一条引擎记录「不可自动路由」的成因;可自动路由返回 None。"""
|
|
295
296
|
if not row.get("enabled", True):
|
|
296
|
-
return
|
|
297
|
+
return engine_states.ENGINE_BLOCK_DISABLED
|
|
297
298
|
if row.get("missing_env"):
|
|
298
|
-
return
|
|
299
|
+
return engine_states.ENGINE_BLOCK_MISSING_ENV
|
|
299
300
|
if row.get("missing_deps"):
|
|
300
|
-
return
|
|
301
|
+
return engine_states.ENGINE_BLOCK_MISSING_DEPS
|
|
301
302
|
if row.get("quota_exhausted"):
|
|
302
|
-
return
|
|
303
|
+
return engine_states.ENGINE_BLOCK_QUOTA_EXHAUSTED
|
|
303
304
|
if not row.get("routable", True):
|
|
304
|
-
return
|
|
305
|
+
return engine_states.ENGINE_BLOCK_NOT_ROUTABLE
|
|
305
306
|
return None
|
|
306
307
|
|
|
307
308
|
|
|
@@ -597,7 +598,7 @@ def main():
|
|
|
597
598
|
# 本地命中并入已上移进 super_search(shape_response 统一出口,L1 并行),
|
|
598
599
|
# 这里不再串行补合并——双份合并会让同一批命中出现两次。
|
|
599
600
|
|
|
600
|
-
if args.archive and results.get("status") !=
|
|
601
|
+
if args.archive and results.get("status") != engine_states.PLAN_HANDOFF_REQUIRED:
|
|
601
602
|
try:
|
|
602
603
|
from archive_run import write_search_archive, resolve_archive_root
|
|
603
604
|
root = resolve_archive_root(args.archive_dir) if args.archive_dir else None
|
package/scripts/search_entry.py
CHANGED
|
@@ -36,6 +36,8 @@ from usage_log import emit as _emit_usage
|
|
|
36
36
|
from search_output import _collect_errors
|
|
37
37
|
from search_pipeline import _SearchRequest, _SearchRun
|
|
38
38
|
from search_types import Stage
|
|
39
|
+
# 状态词表唯一真源:缓存层级 / 精排结局(2026-11-09 收口)
|
|
40
|
+
import engine_states
|
|
39
41
|
from stage_timing import StageTiming, tick as _tick, tock as _tock
|
|
40
42
|
from time_utils import (
|
|
41
43
|
is_time_capable as _is_time_capable,
|
|
@@ -120,51 +122,9 @@ def prepare(query: str, decision: dict[str, Any], max_results: int,
|
|
|
120
122
|
engines = [e for e in engines_combo if e] or ["anysearch"]
|
|
121
123
|
parallel = decision.get("parallel", False) and len(engines) > 1
|
|
122
124
|
|
|
123
|
-
# P0-001:查询理解 — clean_query 用于检索,exclude_terms 用于融合后过滤
|
|
124
|
-
exclude_terms: list[str] = []
|
|
125
|
-
retrieval_query = query
|
|
126
|
-
qu = None
|
|
127
|
-
try:
|
|
128
|
-
from query_understanding import _understand_cached as understand
|
|
129
|
-
qu = understand(query)
|
|
130
|
-
exclude_terms = qu.exclude_terms
|
|
131
|
-
# 查询操作符 -词/-"短语" 的排除项汇合(2026-10-17 query_operators):
|
|
132
|
-
# 与否定理解共用同一「融合后过滤」通道,去重保序。
|
|
133
|
-
_op_excl = ((decision or {}).get("operators") or {}).get("exclude_terms") or []
|
|
134
|
-
for t in _op_excl:
|
|
135
|
-
if t and t not in exclude_terms:
|
|
136
|
-
exclude_terms.append(t)
|
|
137
|
-
# 仅当去否定片段后仍有实义内容时才替换检索词,避免空检索
|
|
138
|
-
if qu.clean_query and qu.clean_query.strip():
|
|
139
|
-
retrieval_query = qu.clean_query
|
|
140
|
-
except ImportError:
|
|
141
|
-
pass # query_understanding 不可用
|
|
142
|
-
except Exception as e:
|
|
143
|
-
_log(f"查询理解跳过: {type(e).__name__}")
|
|
144
|
-
|
|
145
|
-
# 词形规范化:全角→半角、拆斜杠、压多余空格(提升精确源命中,治型号/日期分隔符)
|
|
146
|
-
try:
|
|
147
|
-
from query_enhance import normalize_query
|
|
148
|
-
retrieval_query = normalize_query(retrieval_query)
|
|
149
|
-
except ImportError:
|
|
150
|
-
pass
|
|
151
|
-
|
|
152
125
|
if on_progress:
|
|
153
126
|
on_progress(Stage.START, {"query": query})
|
|
154
127
|
|
|
155
|
-
# 网络环境感知:慢网放大超时预算(避免误杀),快网收紧(更快响应)
|
|
156
|
-
_eff_timeout = timeout
|
|
157
|
-
try:
|
|
158
|
-
from network_aware import adjusted_timeout, network_profile
|
|
159
|
-
_eff_timeout = adjusted_timeout(timeout, engines)
|
|
160
|
-
if _eff_timeout != timeout:
|
|
161
|
-
_log(
|
|
162
|
-
f"网络感知超时: {timeout}s → {_eff_timeout}s "
|
|
163
|
-
f"({network_profile(engines).get('network')})",
|
|
164
|
-
)
|
|
165
|
-
except ImportError:
|
|
166
|
-
pass
|
|
167
|
-
|
|
168
128
|
# 时间窗归一化:下推/缓存键用归一化 ISO(相对值转绝对日期),
|
|
169
129
|
# 后过滤用 epoch 秒;非法输入保持原样下推、不参与后过滤。
|
|
170
130
|
since_iso, until_iso, since_ts, until_ts = _normalize_time_window(since, until)
|
|
@@ -232,7 +192,8 @@ def prepare(query: str, decision: dict[str, Any], max_results: int,
|
|
|
232
192
|
if hit:
|
|
233
193
|
cache_elapsed = int((time.time() - t_cache_start) * 1000)
|
|
234
194
|
if on_progress:
|
|
235
|
-
on_progress(Stage.CACHE_HIT, {"cache_level": hit.get(
|
|
195
|
+
on_progress(Stage.CACHE_HIT, {"cache_level": hit.get(
|
|
196
|
+
"_cache_level", engine_states.CACHE_LEVEL_UNKNOWN)})
|
|
236
197
|
tfidf_scores = decision.get("tfidf_scores", [])
|
|
237
198
|
if tfidf_scores and all(s.get("score", 0) == 0 for s in tfidf_scores):
|
|
238
199
|
tfidf_scores = []
|
|
@@ -249,7 +210,8 @@ def prepare(query: str, decision: dict[str, Any], max_results: int,
|
|
|
249
210
|
"query": query, "engine": (cached_combo or engines)[0],
|
|
250
211
|
"engines": cached_combo,
|
|
251
212
|
"engines_combo": cached_combo, "cached": True,
|
|
252
|
-
"cache_level": hit.get(
|
|
213
|
+
"cache_level": hit.get(
|
|
214
|
+
"_cache_level", engine_states.CACHE_LEVEL_UNKNOWN),
|
|
253
215
|
"domain": domain, "elapsed_ms": cache_elapsed,
|
|
254
216
|
"tfidf_scores": tfidf_scores,
|
|
255
217
|
"route_reason": hit.get("route_reason") or decision.get("reason"),
|
|
@@ -258,7 +220,7 @@ def prepare(query: str, decision: dict[str, Any], max_results: int,
|
|
|
258
220
|
"count": len(hit_results),
|
|
259
221
|
"engines_used": hit.get("engines_used") or engines,
|
|
260
222
|
"mode": mode, "depth": depth,
|
|
261
|
-
"reranker":
|
|
223
|
+
"reranker": engine_states.RERANK_SKIPPED_CACHE,
|
|
262
224
|
"engine_outcomes": hit.get("engine_outcomes") or [],
|
|
263
225
|
"errors": _collect_errors({}, hit.get("engine_outcomes") or []),
|
|
264
226
|
"time_filtered": 0,
|
|
@@ -280,7 +242,53 @@ def prepare(query: str, decision: dict[str, Any], max_results: int,
|
|
|
280
242
|
_hit["funnel"] = hit["funnel"]
|
|
281
243
|
if timing is not None:
|
|
282
244
|
_hit["timing"] = timing.summary()
|
|
245
|
+
# 缓存命中同样是「一次搜索的结束」:进度契约要求每次运行以
|
|
246
|
+
# DONE/ERROR 收尾(见 search_types.Stage)。此前这里直接 return,
|
|
247
|
+
# 消费方在命中路径上永远等不到终态事件——冷路径有、热路径没有,
|
|
248
|
+
# 而热路径恰恰是常驻进程里最常见的那种。
|
|
249
|
+
if on_progress:
|
|
250
|
+
on_progress(Stage.DONE, {"count": len(hit_results),
|
|
251
|
+
"elapsed_ms": cache_elapsed,
|
|
252
|
+
"cached": True})
|
|
283
253
|
return _Prepared(cached=_hit)
|
|
254
|
+
|
|
255
|
+
# 缓存未命中才拉起查询理解、词形规范化与网络感知超时(缓存命中热路径零开销)
|
|
256
|
+
exclude_terms: list[str] = []
|
|
257
|
+
retrieval_query = query
|
|
258
|
+
qu = None
|
|
259
|
+
try:
|
|
260
|
+
from query_understanding import _understand_cached as understand
|
|
261
|
+
qu = understand(query)
|
|
262
|
+
exclude_terms = qu.exclude_terms
|
|
263
|
+
_op_excl = ((decision or {}).get("operators") or {}).get("exclude_terms") or []
|
|
264
|
+
for t in _op_excl:
|
|
265
|
+
if t and t not in exclude_terms:
|
|
266
|
+
exclude_terms.append(t)
|
|
267
|
+
if qu.clean_query and qu.clean_query.strip():
|
|
268
|
+
retrieval_query = qu.clean_query
|
|
269
|
+
except ImportError:
|
|
270
|
+
pass
|
|
271
|
+
except Exception as e:
|
|
272
|
+
_log(f"查询理解跳过: {type(e).__name__}")
|
|
273
|
+
|
|
274
|
+
try:
|
|
275
|
+
from query_enhance import normalize_query
|
|
276
|
+
retrieval_query = normalize_query(retrieval_query)
|
|
277
|
+
except ImportError:
|
|
278
|
+
pass
|
|
279
|
+
|
|
280
|
+
_eff_timeout = timeout
|
|
281
|
+
try:
|
|
282
|
+
from network_aware import adjusted_timeout, network_profile
|
|
283
|
+
_eff_timeout = adjusted_timeout(timeout, engines)
|
|
284
|
+
if _eff_timeout != timeout:
|
|
285
|
+
_log(
|
|
286
|
+
f"网络感知超时: {timeout}s → {_eff_timeout}s "
|
|
287
|
+
f"({network_profile(engines).get('network')})",
|
|
288
|
+
)
|
|
289
|
+
except ImportError:
|
|
290
|
+
pass
|
|
291
|
+
|
|
284
292
|
try:
|
|
285
293
|
from circuit_breaker import get_breaker
|
|
286
294
|
breaker = get_breaker()
|
package/scripts/search_output.py
CHANGED
|
@@ -11,6 +11,7 @@ from __future__ import annotations
|
|
|
11
11
|
from search_rank import filter_results_by_domains
|
|
12
12
|
from search_types import slot_record as dataclass
|
|
13
13
|
from snippet_clean import clean_snippet
|
|
14
|
+
import engine_states # 状态词表唯一真源(2026-11-09 收口)
|
|
14
15
|
from typing import Any
|
|
15
16
|
from output_transparency import ( # noqa: F401
|
|
16
17
|
_AGGREGATOR_HOSTS,
|
|
@@ -70,6 +71,9 @@ _AGENT_RESULT_FIELDS = (
|
|
|
70
71
|
# 出现(backfill_results 回填),未核验结果不造假摘要。
|
|
71
72
|
"summary",
|
|
72
73
|
"image_url", "image_license",
|
|
74
|
+
# 双通道引擎(同一引擎名背后有匿名与认证两条取数通路)标出本条实际走的
|
|
75
|
+
# 通道:内容范围差异正是两条通路的区别,剥掉它就只能靠猜。
|
|
76
|
+
"channel",
|
|
73
77
|
"episode_count", "duration_minutes",
|
|
74
78
|
# 本地已有正文:是可操作提示而非观测数据——告诉 Agent 这条不必重新联网,
|
|
75
79
|
# 以及全文在哪(被截断时还给出 full_text_path)。剥掉它等于把「随时
|
|
@@ -380,7 +384,7 @@ def format_timing(t: dict[str, Any]) -> str:
|
|
|
380
384
|
def format_text_output(results: dict[str, Any]) -> str:
|
|
381
385
|
"""日常搜索人读格式:条目正文 + 底部「相关信源」链接(类传统 SERP)。"""
|
|
382
386
|
lines = []
|
|
383
|
-
if results.get("status") ==
|
|
387
|
+
if results.get("status") == engine_states.PLAN_HANDOFF_REQUIRED:
|
|
384
388
|
ho = results.get("handoff") or {}
|
|
385
389
|
lines.append("=== HANDOFF (known-url, search skipped) ===")
|
|
386
390
|
lines.append(f" url: {ho.get('url')}")
|
|
@@ -388,7 +392,8 @@ def format_text_output(results: dict[str, Any]) -> str:
|
|
|
388
392
|
for lim in (results.get("limitations") or [])[:4]:
|
|
389
393
|
lines.append(f" ! {lim}")
|
|
390
394
|
return "\n".join(lines)
|
|
391
|
-
if results.get("status")
|
|
395
|
+
if results.get("status") == engine_states.PLAN_READY \
|
|
396
|
+
and results.get("steps") and not results.get("results"):
|
|
392
397
|
# plan-only
|
|
393
398
|
lines.append(f"=== PLAN {results.get('status')} kind={results.get('input_kind')} ===")
|
|
394
399
|
route = results.get("route") or {}
|
|
@@ -74,6 +74,8 @@ from search_rank import (
|
|
|
74
74
|
rrf_merge,
|
|
75
75
|
)
|
|
76
76
|
from search_types import Stage
|
|
77
|
+
# 状态词表唯一真源:精排结局 / 缓存层级(2026-11-09 收口)
|
|
78
|
+
import engine_states
|
|
77
79
|
from stage_timing import tick as _tick, tock as _tock
|
|
78
80
|
from time_utils import apply_time_window as _apply_time_window
|
|
79
81
|
from time_utils import sort_results_by_time as _sort_results
|
|
@@ -140,7 +142,7 @@ class _SearchRun:
|
|
|
140
142
|
time_filter_warning: str | None = None
|
|
141
143
|
recovery_info: dict[str, Any] | None = None
|
|
142
144
|
rank_method: str = "none"
|
|
143
|
-
reranker_status: str =
|
|
145
|
+
reranker_status: str = engine_states.RERANK_SKIPPED_SHORT
|
|
144
146
|
local_rerank_on: bool = False
|
|
145
147
|
fact_alignment: dict[str, Any] | None = None
|
|
146
148
|
number_conflict: dict[str, Any] | None = None
|
|
@@ -580,14 +582,14 @@ def postprocess(req: _SearchRequest, run: _SearchRun, hooks: Any) -> _SearchRun:
|
|
|
580
582
|
_tock(timing, "recovery", _tk_recovery)
|
|
581
583
|
_tk_rerank = _tick(timing)
|
|
582
584
|
local_rerank_on = env_flag("ARGO_LOCAL_RERANK")
|
|
583
|
-
reranker_status =
|
|
585
|
+
reranker_status = engine_states.RERANK_SKIPPED_SHORT
|
|
584
586
|
rank_method = "none"
|
|
585
587
|
if mode == "fast" or depth == "fast":
|
|
586
|
-
reranker_status =
|
|
588
|
+
reranker_status = engine_states.RERANK_SKIPPED_FAST
|
|
587
589
|
elif merged and len(merged) > 1:
|
|
588
590
|
# 全量重排(top_n=len),由最终输出统一截断 max_results
|
|
589
591
|
merged, reranker_status = rerank_results(query, merged, top_n=len(merged))
|
|
590
|
-
if reranker_status ==
|
|
592
|
+
if reranker_status == engine_states.RERANK_OK:
|
|
591
593
|
rank_method = "bocha"
|
|
592
594
|
|
|
593
595
|
# 本地五维 rerank 保底:受 ARGO_LOCAL_RERANK 开关控制(可观测 rank_method)。
|
|
@@ -810,11 +812,12 @@ def finalize(req: _SearchRequest, run: _SearchRun, hooks: Any) -> dict[str, Any]
|
|
|
810
812
|
# 自适应学习(单事务批量写入 + cache_guard 统一状态态过滤)
|
|
811
813
|
try:
|
|
812
814
|
import contextlib
|
|
813
|
-
from adaptive import get_learner, scenario_of
|
|
815
|
+
from adaptive import get_learner, marginal_contribution, scenario_of
|
|
814
816
|
learner = get_learner()
|
|
815
817
|
_outcome_of = {o.get("engine"): o
|
|
816
818
|
for o in engine_outcomes if isinstance(o, dict)}
|
|
817
819
|
_batch_ctx = learner.batch() if hasattr(learner, "batch") else contextlib.nullcontext()
|
|
820
|
+
_shares = marginal_contribution(merged, max_results, [e for e, r in raw_results.items() if r]) # 终榜边际贡献,见 adaptive
|
|
818
821
|
with _batch_ctx:
|
|
819
822
|
for eng, res in raw_results.items():
|
|
820
823
|
outcome = _outcome_of.get(eng)
|
|
@@ -823,16 +826,12 @@ def finalize(req: _SearchRequest, run: _SearchRun, hooks: Any) -> dict[str, Any]
|
|
|
823
826
|
st = (outcome or {}).get("status")
|
|
824
827
|
success = bool(res and any(isinstance(r, dict) and "error" not in r for r in res))
|
|
825
828
|
# 空结果说明查询与源不匹配而非源故障,单独统计不拉低成功率(见 adaptive.get_score)。
|
|
826
|
-
empty = (not success) and st in (
|
|
829
|
+
empty = (not success) and st in (
|
|
830
|
+
engine_states.OUTCOME_NO_RESULTS,
|
|
831
|
+
engine_states.OUTCOME_NO_RESULTS_CACHED)
|
|
827
832
|
latency = engine_latency.get(eng, elapsed / max(len(raw_results), 1))
|
|
828
833
|
cost = get_cost_factor(eng)
|
|
829
|
-
quality = None
|
|
830
|
-
if success:
|
|
831
|
-
try:
|
|
832
|
-
from query_signals import result_relevance
|
|
833
|
-
quality = result_relevance(query, res)
|
|
834
|
-
except Exception:
|
|
835
|
-
quality = None
|
|
834
|
+
quality = _shares.get(eng) if success else None
|
|
836
835
|
learner.record(eng, success=success, latency_ms=latency,
|
|
837
836
|
cost=0.0 if cost >= 0.85 else 0.001, empty=empty,
|
|
838
837
|
quality=quality, **scenario_of(decision))
|
|
@@ -892,11 +891,11 @@ def finalize(req: _SearchRequest, run: _SearchRun, hooks: Any) -> dict[str, Any]
|
|
|
892
891
|
"count": len(merged),
|
|
893
892
|
"elapsed_ms": round(elapsed),
|
|
894
893
|
"engines_used": list(raw_results.keys())[:8],
|
|
895
|
-
#
|
|
896
|
-
#
|
|
897
|
-
#
|
|
898
|
-
#
|
|
899
|
-
|
|
894
|
+
# 曾写 top_urls(头部 5 条结果 URL,「留作采纳回放地基」)。实测
|
|
895
|
+
# 全仓零消费者:stats_cli 只读 count/elapsed_ms/engines_used/query,
|
|
896
|
+
# 该字段却占 query 流 26.8% 体积(3121 个 URL / 213 KB),且
|
|
897
|
+
# 9c60ded 又在同一行追加 engine_results,越堆越胖。日志只记有人
|
|
898
|
+
# 读的事实;真要回放从 --archive 落盘,别在每条查询里带全文。
|
|
900
899
|
**usage_log_attribution(engine_latency, engine_outcomes=engine_outcomes),
|
|
901
900
|
"errors": len(_collect_errors(raw_results, engine_outcomes)),
|
|
902
901
|
"recovered": bool(recovery_info.get("recovered")) if recovery_info else False,
|