Commit Graph

1011 Commits

Author SHA1 Message Date
ZhuLinsen
917061ad13 fix: enforce dashboard review region scope 2026-08-30 21:45:17 +08:00
ZhuLinsen
e45898a052 fix: reject partial scoped dashboard snapshots 2026-08-30 21:13:42 +08:00
ZhuLinsen
64378f1968 fix: preserve dashboard snapshot integrity after main sync 2026-08-30 21:01:54 +08:00
zhulinsen
ee2c113a1b feat: rebuild partial-data stock profile contract (#2308)
* feat: add partial-data stock profile contract

* fix: query stock profile aliases

* fix: converge US stock profile aliases

* fix: preserve stock profile intelligence coverage

* fix: preserve JP and KR profile identities

* fix: disambiguate profile persisted identities

* fix: complete offshore profile identities

* fix: isolate offshore profile identities

* fix: preserve Taiwan profile aliases

* fix: preserve explicit profile market identity

* fix: preserve market in history candidates

* fix: preserve stock profile research evidence

* fix: complete stock profile history evidence

* fix: reject conflicting stock profile identities

* fix: normalize persisted profile symbol filters

* fix: exclude ambiguous global stock aliases

* fix: deduplicate profile alias queries

* fix: exclude ambiguous profile history aliases

* fix: break stock profile import cycle

* fix: preserve market-unique legacy aliases
2026-08-30 20:38:33 +08:00
zhanghao56666-svg
d55e4c310d Fix/tavily credit usage (#2314)
* Reduce Tavily search credit usage

Use basic Tavily search by default to reduce excessive credit consumption.

* Limit intelligence searches per stock

* Update test_search_tavily_provider.py

* Update pipeline.py
2026-08-30 19:45:00 +08:00
Kun Zhu
77cc9ec30f fix(web): 选股结果持久化恢复 - 新增历史记录入口并支持刷新恢复 (#2154)
* fix(web): 选股历史结果持久化恢复(方案A)

- 选股页新增历史记录区块:加载时展示最近 10 次选股运行,点击条目
  通过 history API 加载并展示该次完整结果
- 任务完成后将 runId 持久化到 sessionStorage(不再清空),刷新后
  优先从 history API 按 run_id 恢复结果,避免依赖内存态 task 队列
- task 恢复失败(服务重启/任务过期)时回退到原有 task 轮询逻辑
- 失败/未知状态任务仍清理持久化记录

* docs: 记录选股结果持久化恢复修复到 CHANGELOG

* fix(web): 闭合选股恢复状态清理的两个正确性 blocker

- 不可恢复任务分支补 clearPersistedScreenTask(),避免刷新后反复恢复同一失效任务
- clearScreeningResults() 同步清理持久化的 runId/taskId,切换筛选条件后刷新不再恢复旧结果
- 新增两条回归测试覆盖上述场景

* fix(web): 选股历史条目展示筛选条件,切换筛选条件不清除恢复状态

- 撤销场景2错误修复:clearScreeningResults() 不再清除持久化 runId/taskId,
  切换筛选条件后历史与刷新恢复能力完整保留
- 历史条目展示筛选条件:策略中文名(formatHistoryStrategyName)、
  市场标签(formatHistoryMarketLabel)、返回数量(该次 run 实际候选数 candidateCount)
- 重写对应回归测试 + 新增历史条件展示测试

* fix(web): 历史记录区块移到选股结果下方,符合先看结果再看历史的浏览顺序

* fix(web): 历史 run 恢复时同步策略与市场上下文;changelog 条目移入 Unreleased

- handleHistoryRunSelect 与挂载时 runId 恢复分支现在会从 history detail
  同步 strategy/market 到页面 state,结果区文案和后续深度分析的
  analysisSkills 使用该历史 run 对应的策略,而非当前表单选择
  (关闭 Codex P2 + OR-COR-6c1e5d27)
- CHANGELOG 选股持久化恢复条目从 [3.30.0] 文档小节移至 [Unreleased] 段
- 新增回归测试:点击历史条目后结果区展示同步后的策略/市场上下文

* fix(web): 忽略过期历史详情响应,修复快速切换历史条目的竞态

- handleHistoryRunSelect 用 historyRunRequestIdRef 追踪最新请求,
  响应返回时校验仍是最新请求才应用结果/错误/loading 状态,
  避免 run A 晚到覆盖 run B 的结果(关闭 Codex P2)
- 新增回归测试:先点 run-a 再点 run-b,run-a 迟到返回不覆盖
  run-b 的结果与策略上下文

* fix(web): 历史恢复与手动选择互斥,自动恢复接入竞态保护

- handleHistoryRunSelect 选择历史记录时取消运行中的选股任务轮询(setActiveTaskId(null)),避免任务完成后把当前任务候选回写到历史上下文
- 页面初始自动恢复 effect 接入 historyRunRequestIdRef 竞态保护:若自动恢复返回前用户已手动选择历史记录,则放弃自动恢复响应,避免较晚返回的旧 run 覆盖用户最新选择
- 自动恢复失败回退 task 轮询时也校验用户未手动选择历史记录
- 补充两条回归测试:晚到自动恢复不覆盖手动选择、选择历史时取消进行中的任务

* fix(web): 修复历史恢复链路三处竞态(OpenReview 2026-08-24 复审反馈)

- OR-COR-9b1f8c4e: 过期自动恢复请求的 finally 不再无条件清共享
  loading;setLoading(false) 复用 request-id 守卫,setRestoreResolved(true)
  保持无条件执行,避免提前放开"运行选股"入口
- OR-COR-2c71d8af: handleSubmit 递增 historyRunRequestIdRef 作废飞行中
  的历史/恢复响应并解除 restoreResolved 门闩,新任务轮询立即启动,
  迟到响应不再覆盖新任务状态
- 策略列表竞态: 新增 historyContextStrategyRef,历史选择/自动恢复写入
  的策略跳过 loadStrategies 的归一化回退,迟到的 /strategies 响应不再把
  历史自定义策略改写回默认策略

验证: StockScreeningPage 测试 35 passed(新增 3 条回归)、screening API
测试 13 passed、tsc -b && vite build 通过

* fix(web): 手动选中历史记录后同步持久化恢复指针(OR-COR-4d1a7e90)

handleHistoryRunSelect 成功加载历史详情时调用 persistScreenTask 记录当前
选中的 runId/strategy/market,刷新后自动恢复用户刚查看的历史 run,
而不是停留在更早的 task/run。历史详情不携带 taskId,以 runId 作为占位:
正常路径刷新走 getRun(runId) 恢复、不会触发轮询;若该 run 恢复失败,
占位轮询会命中不可恢复错误并清理过期指针。useCallback 依赖同步补全,
确保持久化使用当前表单值。

验证: StockScreeningPage 测试 36 passed(新增 1 条回归:选中历史后刷新
仍恢复该 run)、screening API 测试 13 passed、tsc -b && vite build 通过

---------

Co-authored-by: ariesy <ariesy.bleiben@gmail.com>
2026-08-30 17:42:38 +08:00
ZhuLinsen
6993692a4d fix: reject repeated snapshot region tokens 2026-08-30 17:36:27 +08:00
ZhuLinsen
43eab6c4ae fix: reject malformed snapshot containers 2026-08-30 17:30:07 +08:00
ZhuLinsen
f6aac4758a fix: validate dashboard snapshot region keys 2026-08-30 17:25:03 +08:00
ZhuLinsen
48b7af90c8 fix: split dashboard review region scopes 2026-08-30 17:16:35 +08:00
ZhuLinsen
41cf407e79 fix: scope malformed dashboard containers 2026-08-30 17:09:49 +08:00
ZhuLinsen
6e4dec4ceb fix: report malformed dashboard regions 2026-08-30 17:01:17 +08:00
ZhuLinsen
ca36ab561d fix: scope dashboard snapshot failures 2026-08-30 16:54:57 +08:00
ZhuLinsen
fc49613608 fix: read dashboard history from one snapshot 2026-08-30 16:41:42 +08:00
ZhuLinsen
678f6e148f fix: stabilize dashboard recent reports 2026-08-30 16:33:43 +08:00
ZhuLinsen
f055417762 fix: stabilize dashboard history comparisons 2026-08-29 22:33:33 +08:00
ZhuLinsen
bd2fc0aa3c fix: canonicalize dashboard snapshot dates 2026-08-29 22:25:49 +08:00
ZhuLinsen
4a4a585151 fix: select canonical latest market reviews 2026-08-29 22:16:56 +08:00
ZhuLinsen
b91d73781f fix: preserve malformed region snapshot failures 2026-08-29 22:02:08 +08:00
ZhuLinsen
8adb598c14 fix: reject malformed market snapshot containers 2026-08-29 21:53:39 +08:00
ZhuLinsen
80e06ee062 fix: reject malformed dashboard snapshot context 2026-08-29 21:34:53 +08:00
ZhuLinsen
3cb22e913b perf: batch dashboard snapshot reads 2026-08-29 21:24:20 +08:00
ZhuLinsen
2d7eafdf85 fix: reject mismatched dashboard snapshot regions 2026-08-29 21:14:20 +08:00
ZhuLinsen
e453028d0f fix: preserve dashboard snapshot identity 2026-08-29 20:52:25 +08:00
ZhuLinsen
546a03d743 chore: sync dashboard OpenAPI contract 2026-08-29 20:52:25 +08:00
ZhuLinsen
8846f53b4d fix: bound dashboard activity history 2026-08-29 20:52:25 +08:00
ZhuLinsen
9261a72e09 fix: bound dashboard comparison history 2026-08-29 20:52:25 +08:00
ZhuLinsen
82d6b7f988 fix: paginate dashboard history summaries 2026-08-29 20:52:25 +08:00
ZhuLinsen
3001fb1490 feat: add read-only dashboard overview contract 2026-08-29 20:52:25 +08:00
TimingAlmostMet
03e11fe35c fix: US daily routing consumes per-source fetcher priorities (#2250)
The US daily-kline branch ignored fetcher priorities and used a fixed
Finnhub/AlphaVantage/Yfinance/Longbridge order, so per-source knobs
like YFINANCE_PRIORITY=0 never affected US routing. The chain is now
ordered by each fetcher's current priority (stable): defaults match
the builtin chain exactly, single-source *_PRIORITY tweaks take
effect immediately, and the deliberate first-position semantics
(index -> Yfinance, Longbridge-preferred) stay pinned.
2026-08-29 20:48:40 +08:00
zhulinsen
0cf61c637f fix: sync research artifact OpenAPI contract (#2311)
* fix: sync research artifact OpenAPI contract

* chore: reduce follow-up merge conflicts
2026-08-29 18:35:58 +08:00
zhulinsen
86bbf01535 fix: align US index realtime capability (#2310)
* fix: align US index realtime capability

* fix: enforce YFinance-only US index quotes

* chore: reduce follow-up merge conflicts
2026-08-29 18:29:48 +08:00
zhulinsen
0b5f9a6e31 feat: add research artifact contract (#2291)
* feat: add research artifact contract

* fix: preserve research artifact identity and falsey values

* fix: correct research artifact evidence quality
2026-08-29 17:20:25 +08:00
zhulinsen
0709b17ed1 feat: add data capability contract (#2289)
* feat: add data capability contract

* fix(review-feedback-2289): preserve unknown status until availability is checked and Make

* fix(review-feedback-2289): Aggregate daily quality across supported markets and add kline

* fix(review-feedback-2289): Honor daily-source circuit breakers in quality selection and Make

* fix(review-feedback-2289): Scope market-overview quality by market and Do not select a news

* fix: align data capability with runtime routes

* fix: align data capability runtime coverage

* fix: align source and index capability routes

* fix: preserve runtime capability uncertainty

* fix: include US index capability routes

* fix: align realtime and monitor capabilities

* fix: remove unsupported Tushare index capability

* fix: align capabilities with runtime routes

* fix: model realtime and breaker routes

* fix: align US realtime request priority

* fix: align realtime circuit coverage

* fix: filter unavailable daily priorities

* fix: align US realtime capability claims

* fix: align executable US data routes
2026-08-29 17:19:18 +08:00
Elvis Wang
eb1333a678 feat: 支持通过 --stocks 一次性分析板块指数 (#2300)
* feat: add one-shot index analysis via --stocks with structured AnalysisTarget pipeline

* fix: render index data sources in aggregate reports

* fix: refresh index registry before --stocks parsing and filter indices on CN holidays

---------

Co-authored-by: zhulinsen <42829555+ZhuLinsen@users.noreply.github.com>
2026-08-28 21:56:48 +08:00
SPEC
ee635a35bf feat: 桌面端右上角增加更新入口 (#2274)
* feat: add a global desktop update entry in the shell

Expose a top-right DesktopUpdateIndicator in Electron runtime that
shares update state with Settings, without triggering extra background
checks or showing the control in ordinary browser WebUI.

Co-authored-by: SPEC <zt1y17@soton.ac.uk>

* fix: restore changelog header and honor desktop update deep links

Keep the Unreleased section intact, show download progress in the
shell tooltip, and open Settings version info from the search/hash.

Co-authored-by: SPEC <zt1y17@soton.ac.uk>

* fix: share desktop update checking state across header and settings

Keep a module-level update store so the shell indicator and settings
page disable together, and reject overlapping manual checks in the
Electron main process.

Co-authored-by: SPEC <zt1y17@soton.ac.uk>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-08-28 21:10:48 +08:00
zhulinsen
e75c4bb657 docs: link arXiv paper and add citation metadata (#2301) 2026-08-28 21:08:20 +08:00
sunkai174634
fb4735a105 feat: add Futu OpenD as optional HK realtime and fundamental data source (#2269)
* feat: add Futu OpenD as an optional HK realtime and fundamental data source

Add FutuFetcher and FutuFundamentalAdapter behind FUTU_OPEND_HOST/PORT,
register the settings in Config and config_registry so the Web settings
page can expose host, port and HK realtime priority, and route HK
realtime quotes through a configurable futu/longbridge/akshare/yfinance
order while keeping A-share priority untouched. Include offline tests
for the adapter, config schema and HK routing/fallback, plus docs and
CHANGELOG entries.

* fix: wire Futu fundamentals into HK pipeline and restore quote supplementation

- _fetch_offshore_fundamental_bundle() prefers the Futu fundamental
  adapter for HK when FUTU_OPEND_HOST is configured, and falls back to
  yfinance when Futu is absent or returns no usable content.
- HK realtime priority loop now supplements missing quote fields
  (volume_ratio / turnover_rate / pe/pb / market cap) from later
  configured sources instead of returning after the first non-empty
  quote, matching the US path's _supplement_quote behavior.
- capital_flow / boards blocks are filled from the Futu bundle for HK
  instead of being hard-coded not_supported; status and missing_fields
  aggregation updated accordingly.
- Add regression tests for partial-quote supplementation and Futu
  fundamental bundle routing/fallback.

* test: expect boards block ok when bundle provides belong_boards

The Futu integration made the offshore boards block data-driven instead
of hard-coded not_supported; update the existing US/HK fundamental
context test to match (belong_boards from the bundle now surface as an
ok boards block).

* fix: preserve HK fallback_from metadata and normalize Futu quote timestamps

- HK realtime priority loop now records the failed preferred source token
  and passes it as fallback_from when a later source takes over, so the
  pipeline and analysis context can mark the quote as degraded.
- Futu snapshot update_time is a naive Beijing-time (UTC+8) string; attach
  the +08:00 offset before storing provider_timestamp so stale_seconds /
  is_stale / provider_timestamp freshness semantics are correct instead of
  being parsed as UTC.
- Add regression tests for fallback_from propagation and timestamp
  normalization.

* fix: normalize Futu belong_boards to name/type/code contract

OpenD owner_plate returns plate_code / plate_name / plate_type, but DSA
downstream consumers (notification, extract_board_detail_fields, market
structure) only read name/type/code. Map the fields in
FutuFundamentalAdapter._boards so HK Futu boards are actually consumed
instead of silently dropped, and add regression tests including an
end-to-end check through extract_board_detail_fields.

* fix: merge yfinance bundle when Futu fundamental returns partial blocks

Futu partial success (e.g. statements failed but static info worked) used
to short-circuit the whole bundle, silently dropping the growth/earnings
that the existing yfinance path could still provide. Now, when Futu
returns content but is missing growth or earnings, fetch the yfinance
bundle within the remaining budget and merge the missing blocks
(growth/earnings/institution/capital_flow/belong_boards), keeping
Futu-preferred values where both exist. Add regression test for the
partial-success merge path.

* fix: use field-level checks when deciding Futu-vs-yfinance growth/earnings

The previous merge condition only checked dict truthiness, so a truthy
growth/earnings shell (all-None core values or metadata-only keys such
as report_date/period/currency) would skip the yfinance supplement and
silently downgrade existing HK fundamentals. Add _earnings_block_has_values
(a core numeric field or a populated dividend is required) and reuse the
existing _has_meaningful_payload for growth; both the missing_core check
and the merge loop now use these. Add regression test for the
all-None-shell scenario.

* fix: fill HK fundamental field gaps from yfinance instead of block-level checks

Block-level meaningful checks still skipped the yfinance supplement when
Futu hit only part of the growth/earnings fields (e.g. revenue_yoy but
None net_profit_yoy, or earnings with only basic_eps), silently dropping
fields the main branch used to provide. Replace the missing_core decision
with a per-field gap list (growth: revenue_yoy/net_profit_yoy/gross_margin;
earnings.financial_report: revenue/net_profit_parent/basic_eps/gross_profit)
and make the merge field-level: keep Futu values, fill each missing field
from yfinance. Add regression tests for partial-hit and all-None shells.

* fix: normalize Futu dividends to the repo contract and treat dividend gaps as supplement triggers

Futu OpenD dividend_list carries raw fields (statement/ex_date/record_date)
which the notification/data_processing market-structure consumers do not
read; the repo contract is ttm_cash_dividend_per_share,
ttm_dividend_yield_pct and events[].cash_dividend_per_share /
ex_dividend_date / event_date. Normalize events in
FutuFundamentalAdapter._dividends_and_splits, compute TTM count/cash and
yield from the latest quote, and teach _field_gaps/_merge_bundles to treat
a dividend block that does not satisfy the contract as a gap so yfinance
supplements it. Also dedupe FUTU_OPEND_HOST/PORT in full-guide_EN.

* fix: read dividend yield price from UnifiedRealtimeQuote objects

FutuFetcher.get_realtime_quote returns a UnifiedRealtimeQuote dataclass,
not a dict, so the yield branch in _dividends_and_splits that guarded on
isinstance(quote, dict) never ran on the live Futu path, silently dropping
ttm_dividend_yield_pct while the contract check considered the dividend
block complete. Read price via getattr(quote, 'price', None) and keep the
dict fallback for other fetchers; add a regression test driving the real
UnifiedRealtimeQuote shape.

* fix: treat dividend blocks with TTM cash but no yield as supplement gaps

The repo contract consumes ttm_cash_dividend_per_share and
ttm_dividend_yield_pct together. When the Futu dividend path has events
and TTM cash but the extra realtime price snapshot failed (quote None /
no price), ttm_dividend_yield_pct cannot be computed and the block was
previously treated as complete, so yfinance was never consulted and the
notification rendered the yield as N/A.

_dividend_contract_has_values() now requires the paired yield whenever
TTM cash is present, so _field_gaps() triggers the yfinance supplement
and _merge_bundles() replaces the incomplete dividend block.

Add regression tests for the adapter-level gap shape (quote unavailable
leaves no yield) and the manager-level supplement path (Futu cash
without yield pulls yfinance and fills the yield).

* fix: skip unconfigured Futu in HK realtime routing

When FUTU_OPEND_HOST is not configured, the HK realtime priority loop
used to still attempt the futu source, record it as the failed primary,
and attach fallback_from='futu' to a successful quote from the next
enabled source (longbridge/akshare/yfinance). Consumers then wrongly
treated an enabled source's first success as degraded fallback data,
contradicting the documented contract that Futu only participates when
OpenD is configured.

The HK loop now checks FutuFetcher.has_configured_endpoint() once and
skips the futu token entirely when it is disabled, so no fallback_from
is written. Existing configured-Futu routing tests explicitly patch the
endpoint check; a new regression test asserts an unconfigured Futu is
never called and the enriched quote carries fallback_from=None.

* fix: release cached HK Futu fundamental fetcher in DataFetcherManager.close()

The HK Futu fundamental path lazily creates and caches its own
FutuFetcher (an OpenQuoteContext-backed OpenD connection) on
_futu_fundamental_fetcher, but close() only released the TickFlow
fetcher and the default fetchers snapshot. Explicit close / reload
paths therefore left the OpenD connection hanging.

close() now takes the cached _futu_fundamental_fetcher, clears the
reference and calls its close() best-effort. A regression test injects
an observable fetcher into _futu_fundamental_fetcher and asserts
close() invokes it and clears the attribute.

---------

Co-authored-by: BayMax local review <baymax-local@invalid>
2026-08-25 22:54:01 +08:00
Gach-Coder
f92ad2e7d4 feat:分词模块 (#2272) 2026-08-25 22:39:11 +08:00
Elvis Wang
1b42907605 feat: 扩展 A 股指数注册表与 CSI provider 路由 (#2267)
* feat: add JSON-backed index registry

* fix: address index registry review feedback

* fix: validate raw duplicate index aliases

* fix: converge CSI task identities and registry fallback

* docs: align index identity terminology
2026-08-25 22:32:04 +08:00
zhulinsen
262cf5d5de ci: skip heavy checks for docs-only changes (#2255)
* ci: skip heavy checks for docs-only changes

* test: cover docs-only CI path filters

* fix: preserve CI checks for contract assets

* fix: preserve CI checks for license notices
2026-08-25 22:03:03 +08:00
Anupam Mediratta
8d5b9628ab fix: CVE-2026-25639 security vulnerability (#2256)
Automated dependency upgrade by OrbisAI Security
2026-08-25 21:56:24 +08:00
zhulinsen
e45d5ce202 fix: 修复 Linux 分享图中文缺失 (#2270)
* fix: render CJK text in Linux share images

* fix(review-feedback-2270): 补到 PR 附件或评论里,和本次渲染修复说明保持一致

* fix: preserve report language contract in share images
2026-08-24 23:20:56 +08:00
wvyan
5bb3139209 fix: isolate runtime scheduler with portable watchdog (#2219)
* fix: isolate runtime scheduler with portable watchdog

* fix: harden runtime scheduler watchdog shutdown

* fix: prevent scheduled analysis after shutdown

* fix: fence scheduler shutdown and harden watchdog

---------

Co-authored-by: wvyan <13724623+wvyan@users.noreply.github.com>
2026-08-24 22:43:46 +08:00
zhulinsen
9ab79b8299 docs: prepare v3.31.0 release (#2260)
* docs: prepare v3.31.0 release

* fix(review-feedback-2260): add the v3
v3.31.0
2026-08-23 22:32:59 +08:00
Elvis Wang
55ad446855 feat: 增加 A 股指数多数据源 fallback 路由 (#2258)
* feat: add A-share index fallback routing

* docs: clarify index priority configuration scope
2026-08-23 21:42:07 +08:00
Anupam Mediratta
b477022551 fix: CVE-2026-54673 security vulnerability (#2253)
Automated dependency upgrade by OrbisAI Security
2026-08-22 21:56:55 +08:00
青玉案
d0e66a1dc3 feat: 新闻检索为空时在报告中如实标注 (#2229)
* feat: 新闻检索为空时在报告中如实标注

消息面章节此前是「有内容才渲染」,检索一条没拿到时整段直接消失,
读报告的人无从判断是确实没新闻,还是检索静默失败了(搜索源限流、
未配置可用渠道等)。这把「抓取失败」呈现成了「确实没有新闻」。

- src/analyzer.py: AnalysisResult 新增 news_result_count,默认 None
- src/core/pipeline.py: 把 Step 4 已算好的计数交给结果对象
  (此前只进了 diagnostic context snapshot,报告层拿不到)
- src/notification.py: news_lines 为空且计数为 0 时,渲染明确提示,
  并说明结论未纳入新闻维度证据
- tests: 新增 5 条用例,含两条负例——计数为 None 时不得报警
  (那是未配置搜索渠道,不是失败)、拿到新闻时行为与改动前一致

不触碰任何检索路径,纯展示层增量。

* fix: 把新闻缺失提示放进真实渲染路径,并独立于模型输出判定

按 review 三条意见修正:

P1-1 提示只存在于 generate_daily_report,而正常流程从不调用它——
_send_single_stock_notification 与聚合报告走的是 dashboard / brief /
single_stock。原实现对所有标准 REPORT_TYPE 都不生效。
改为抽出共享判定 _empty_news_disclosure,四个渲染器统一接入。

P2 检索零命中但模型按 schema 写出了 market_sentiment / hot_topics 时,
原 elif 分支被跳过,报告会展示模型生成的情绪判断却隐瞒无新闻证据。
改为独立判定 news_result_count == 0,与模型是否产出文字无关。

P1-2 补 docs/CHANGELOG.md [Unreleased] 条目,并在
docs/data-source-stability.md 的「用户可见提示建议」一节记录该行为,
含 None / 0 / >0 三态语义表。

测试从 5 条增至 10 条,新增覆盖 dashboard、brief、single_stock 三个真实
渲染器,以及「模型有输出但检索为空」这一最糟组合。39 passed

* fix: 把新闻零命中披露覆盖到模板链路与企业微信入口

按 review 指出的 blocker 修正。此前只接了字符串拼接分支,遗漏两类活路径:

1. REPORT_RENDERER_ENABLED=true 时,generate_dashboard_report /
   generate_brief_report / generate_wechat_dashboard 会先 return render(...),
   模板链路一路不渲染披露;
2. generate_wechat_dashboard 的非模板 fallback 从未接入,而 pipeline 在
   企业微信非 brief 场景会直接调用它。

后果是同一份分析结果在部分渠道披露、在另一些渠道沉默。

改法不再逐点打补丁,而是抽出单一事实来源:

- 新增 src/services/empty_news.py 持有判定与中英文案
- src/notification.py 的 _empty_news_disclosure 改为委托该模块
- src/services/report_renderer.py 为每条结果预计算 empty_news_disclosure,
  三个平台模板共用
- templates/report_markdown.j2 / report_brief.j2 / report_wechat.j2 各加渲染分支
- generate_wechat_dashboard 的 fallback 正文接入披露

新增 6 条回归测试:模板链路三个平台各一条、企业微信入口一条,
外加两条负例(未执行检索时模板与企业微信均不得提示)。

本文件测试 10 → 16 全过;全量 5824 passed,9 个既有失败与本 PR 无关
(干净 main 上同样失败,属测试顺序依赖)。

* fix: 修正计数源头的两处缺口(自查发现)

按 review 的 merge-base..HEAD 方法自查全链路,发现此前几轮都只盯着渲染出口,
从未核对计数源头,而源头本身在两条路径上是错的:

1. src/core/pipeline.py: news_result_count 只在 intel_results 非空时赋值,
   搜索服务整体失败(正是所有搜索源限流全挂的场景)时停留在 None,
   语义为「未执行检索」,于是本 PR 想解决的头号场景反而不提示。
   改为检索一发起即置 0。

2. _analyze_with_agent: Agent 模式自行调用 search_stock_news 完成检索,
   却从不回写计数,该路径下零命中永远静默。改为按检索结果回写 0 或实际条数。

渲染层再周全,源头数据不对则全部落空。

新增 2 条测试锁住这两处语义(18 passed,此前 16)。
全量 5826 passed,9 个既有失败与本 PR 无关。

* fix: disclose missing news search configuration

* chore: remove unrelated agent guidance

* test: run all empty news tests directly

* fix: preserve empty news disclosure across reports

* fix: 让 Agent 模式的新闻披露跟随实际消费的证据

原问题:agent_arch=multi 等受支持的 Agent 配置下,报告可能声称「未纳入新闻
面证据」而分析其实用了新闻,或反过来该提示而不提示。

根因:news_result_count 取自 executor.run() 结束后为持久化情报补打的一次
search_stock_news()。真实情报由 IntelAgent 通过 search_comprehensive_intel
取得,两者不等价,因此披露与真实证据链可能相反。

修复点:新增 src/agent/news_evidence.py,以运行期证据作用域收集 Agent 搜索
工具的真实返回条数;搜索渠道不可用为 None(未执行检索),可用则从 0 起步、
拿到多少算多少。pipeline 在 executor.run() 前后开启并读取该作用域,事后的
持久化补查不再回写计数。

回归风险:工具在 ThreadPoolExecutor 中执行,runner.py 以
contextvars.copy_context() 提交,故作用域中必须是可变累加器对象,换成不可变
值会让父线程读不到;已加回归测试锁住该机制。原 test_agent_path_records_count
断言的正是被修复的错误行为,已替换为反向断言。

Refs #2225

* fix: 让新闻披露以实际证据为准而非搜索命中数

原问题:本地已落库的资讯池或社交情绪进入 news_context 参与分析后,报告仍可能
声称「未配置搜索渠道,本次分析未纳入新闻面证据」或「零命中」。

根因:news_context 由三路来源拼成——实时检索、社交情绪(美股)、本地资讯池,
但只有实时检索会更新 news_result_count。披露断言的是「结论有没有用到新闻面
证据」,而计数只是「搜索命中了几条」,两者是不同命题,后两路参与时必然失真。

修复点:AnalysisResult 新增 news_evidence_present,由 news_context 是否非空
得出,pipeline 两条路径共用 src/services/empty_news.news_evidence_present()
这一个判定函数。披露改为先看有无证据;确无证据时才用计数解释原因
(None=未配置渠道,0=检索零命中)。历史重建同步恢复该字段。

回归风险:旧记录没有该字段,按计数回退推断,与该记录当时的报告表现一致,不会
追溯改变旧报告;已有用例锁住。review 只点名了本地资讯池,社交情绪属同一缺陷类,
本次一并修复并加测试。另加源码断言:任一 pipeline 路径改回只传计数即失败。

Refs #2225

* fix: 按来源登记新闻证据,不让零命中占位文本冒充证据

原问题:普通分析链路在「搜索已执行但一条证据都没拿到」时,报告不再显示零命中
披露——正是本 PR 要修的核心场景,反而比改动前更差。

根因:src/search_service.py 的 format_intel_report() 即使所有维度失败或为空,
也会输出「【XX 情报搜索结果】」标题和每个维度的「未找到相关信息」占位文本,
整段永远非空。上一版把拼好的 news_context 整段交给 news_evidence_present()
判定,于是 news_result_count == 0 时 evidence 被翻成 true,披露被吞掉,错误
状态还会经 to_dict() 持久化,继续影响历史、详情 API 与 Web。

修复点:判定改为按来源逐个登记——实时检索的真实命中数、社交情绪内容、本地
资讯池内容,任一为真才算有证据;两条 pipeline 路径都不再传拼好的整段。
news_evidence_present() 的契约随之改为接收各来源,并在文档串里写明为什么不能
传整段。

回归风险:新增反例用真实的 format_intel_report() 产出占位文本(不用 mock),
断言其不得被判成证据、且报告必须出现零命中披露。另有源码断言:谁把整段
news_context 交回判定函数即失败。上一版两条测试实际在保护该缺陷(一条名为
「任何非空 context 都算证据」,一条要求必须传入 news_context),已一并纠正。

Refs #2225

---------

Co-authored-by: Mach-Chan <zz-b240@zz-b240deMacBook-Air.local>
2026-08-22 21:27:04 +08:00
Gach-Coder
f6b719d1fe 股票实体解析增强 (#2245)
Co-authored-by: zhulinsen <42829555+ZhuLinsen@users.noreply.github.com>
2026-08-22 21:23:55 +08:00
Elvis Wang
cd1fd2229c feat: 数据库 stock_daily 新增 canonical_id 列与双写(#2207) (#2251)
* feat: add canonical_id column and dual-write for stock daily data (#2207)

* fix: unify bare index codes to index canonical_id via matched_index (review OR-COR-4f9ffc38)

* docs: update docstrings for index-aware derivation and fix orphaned inspection-failure test (review OR-COR-4f9ffc38)
2026-08-22 21:21:15 +08:00