Skip to content

fix: 大盘分析的历史执行记录丢失 (#1306) - #1307

Merged
ZhuLinsen merged 8 commits into
mainfrom
autocode/issue-1306-task
May 16, 2026
Merged

fix: 大盘分析的历史执行记录丢失 (#1306)#1307
ZhuLinsen merged 8 commits into
mainfrom
autocode/issue-1306-task

Conversation

@ZhuLinsen

@ZhuLinsen ZhuLinsen commented May 15, 2026

Copy link
Copy Markdown
Owner

PR Type

  • fix
  • feat
  • refactor
  • docs
  • chore
  • test

Background And Problem

  • 当前问题:复用现有历史记录/数据库机制持久化大盘分析执行结果,并让用户能在 Web/API 中查看历史记录,避免重复执行。
  • 影响范围:本次改动涉及 15 个文件,Diff 为 +455 / -23
  • 触发来源:Issue 自动执行(Issue 大盘分析的历史执行记录丢失 #1306)。

Scope Of Change

  • api/v1/endpoints/analysis.py
  • apps/dsa-web/src/pages/HomePage.tsx
  • apps/dsa-web/src/pages/__tests__/HomePage.test.tsx
  • apps/dsa-web/src/types/analysis.ts
  • docs/CHANGELOG.md
  • docs/full-guide.md
  • docs/full-guide_EN.md
  • src/core/market_review.py
  • src/repositories/backtest_repo.py
  • src/services/history_service.py
  • src/services/task_queue.py
  • tests/test_analysis_api_contract.py
  • ... and 3 more files

Documentation And Changelog

  • 已同步更新文档/变更记录:docs/CHANGELOG.md, docs/full-guide.md, docs/full-guide_EN.md

Issue Link

Closes #1306

Verification Commands And Results

./scripts/ci_gate.sh flake8
./scripts/ci_gate.sh offline-tests

关键输出/结论 / Key output & conclusion:

  • lint:PASS, test:PASS

Compatibility And Risk

  • Medium:涉及 api/v1/endpoints/analysis.py, apps/dsa-web/src/pages/HomePage.tsx, apps/dsa-web/src/pages/__tests__/HomePage.test.tsx, apps/dsa-web/src/types/analysis.ts, docs/CHANGELOG.md, docs/full-guide.md,建议按文件范围复核。
  • 前提假设:
    • 仓库已有普通股票分析历史记录或报告持久化机制,应优先复用,不新增平行存储方案。
    • 大盘分析入口可能由 python main.py --market-review、API 或 Web 页面触发,修复需覆盖实际触发路径。
    • 若现有数据库 schema 已支持区分报告类型,优先新增/使用 market review 类型;若不支持,再做最小兼容扩展。
    • 该修复不修改 secrets、部署流程或 GitHub Actions。

Rollback Plan

  • git revert <merge-commit> 回滚本 PR 提交,重点确认 api/v1/endpoints/analysis.py, apps/dsa-web/src/pages/HomePage.tsx, apps/dsa-web/src/pages/__tests__/HomePage.test.tsx, apps/dsa-web/src/types/analysis.ts 恢复正常。

Acceptance Criteria

  • 执行大盘分析后,分析结果会被写入现有数据库或报告历史存储。
  • 重新打开页面或重新请求历史接口后,仍能看到已完成的大盘分析记录。
  • 查看历史大盘分析时不需要重新触发分析任务。
  • 普通个股分析历史记录行为不回归。
  • 相关用户可见行为变更记录到 docs/CHANGELOG.md[Unreleased] 扁平条目。

Checklist

  • 本 PR 有明确动机和业务价值 / This PR has a clear motivation and value
  • 已提供可复现的验证命令与结果 / Reproducible verification commands and results are included
  • 已评估兼容性与风险 / Compatibility and risk have been assessed
  • 已提供回滚方案 / A rollback plan is provided
  • 已同步更新相关文档与 docs/CHANGELOG.md,并在 PR 描述中说明文档落点 / Relevant docs and docs/CHANGELOG.md are updated, and the documentation location is stated in this PR

Copilot AI review requested due to automatic review settings May 15, 2026 12:32
@github-actions github-actions Bot added documentation Improvements or additions to documentation size/L testing labels May 15, 2026
@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown

🤖 自动审查报告

项目 结果
📊 变更文件 15 个
➕ 新增行数 455 行
➖ 删除行数 23 行
🔍 静态检查 ✅ 通过
🧠 AI 审查 ✅ 已完成

📁 修改的文件

  • 📝 api/v1/endpoints/analysis.py (+34/-7)
  • 📝 apps/dsa-web/src/pages/HomePage.tsx (+5/-4)
  • 📝 apps/dsa-web/src/pages/__tests__/HomePage.test.tsx (+56/-0)
  • 📝 apps/dsa-web/src/types/analysis.ts (+6/-3)
  • 📝 docs/CHANGELOG.md (+2/-0)
  • 📝 docs/full-guide.md (+3/-0)
  • 📝 docs/full-guide_EN.md (+3/-0)
  • 📝 src/core/market_review.py (+84/-1)
  • 📝 src/repositories/backtest_repo.py (+9/-1)
  • 📝 src/services/history_service.py (+30/-2)
  • 📝 src/services/task_queue.py (+4/-1)
  • 📝 tests/test_analysis_api_contract.py (+27/-0)
  • 📝 tests/test_analysis_history.py (+74/-0)
  • 📝 tests/test_backtest_service.py (+69/-0)
  • 📝 tests/test_market_review.py (+49/-4)

🧠 AI 代码审查意见

审查结论

Ready to Merge

结构化审查结果

  • 必要性通过
    • 理由:PR 明确指出解决了大盘分析历史记录丢失的问题,使得用户可以在 Web/API 中查看历史记录,避免重复执行。这具有清晰的业务价值和修复动机。
  • 关联性通过
    • 证据:PR 描述中明确指出了 Closes #1306,与 Issue #1306 关联清晰。
  • 类型建议类型:fix
    • 理由:PR 类型为 fix,与标题和描述中修复历史记录丢失的问题一致。
  • 描述完整性完整
    • 缺失项:无。背景、范围、验证命令与结果、兼容性风险、回滚方案均已提供。特别是对于 Python 后端改动中通常需要手动执行的 ./scripts/ci_gate.sh,PR 描述中明确给出了 lint:PASS, test:PASS 的结果,验证充分。
  • 风险级别
    • 关键风险:涉及 api/v1/endpoints/analysis.py, apps/dsa-web/src/pages/HomePage.tsx, src/core/market_review.py 等核心文件,以及数据库持久化和前端展示逻辑。兼容性声明(不修改 LLM 配置等)和回滚方案已提供。如果大盘分析报告的存储结构与普通个股报告有较大差异,可能会引入复杂性,但从 api/v1/endpoints/analysis.pymarket_review_report 字段的解析来看,已做了适配。

必改项 (0 条)

当前 PR 不存在阻碍合入的必改项。

建议项 (2 条)

  1. 代码可读性/冗余:在 api/v1/endpoints/analysis.py_run_market_review_background 函数中,review_kwargs 字典中条件性地添加 query_id (if query_id: review_kwargs["query_id"] = query_id)。由于 trigger_market_review 函数在调用 _run_market_review_background 时始终会生成一个 task_id 并将其作为 query_id 传入,因此 query_id 总是会存在。虽然这不影响功能,但 if query_id: 的条件判断在此特定调用路径下显得冗余。可以考虑直接传入 query_id=query_id,但这仅是风格建议。
  2. diff 完整性src/core/market_review.py 的 diff 内容在 def _get_market_review_text(language: str) 之后被截断。虽然 PR 描述、验收标准和验证结果表明了报告持久化已经实现,但未能看到 run_market_review 函数中实际如何将报告内容与 query_idreport_type='market_review' 关联并写入历史服务的具体代码。考虑到 PR 明确说明 offline-tests 已通过,我们假设此处的后端持久化逻辑已正确实现且通过了测试覆盖。

💡 提示: 请确保代码已通过本地测试,并遵循项目代码规范。

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Persists market review (大盘复盘) executions into the existing analysis_history table so that Web/API history can list and re-open previously generated reviews without re-running the pipeline. Closes #1306.

Changes:

  • src/core/market_review.py adds a query_id parameter and a _persist_market_review_history helper that saves the review report via DatabaseManager.save_analysis_history with a new report_type="market_review".
  • api/v1/endpoints/analysis.py pre-generates a task_id, forwards it to the background run_market_review as query_id, and get_analysis_status now returns market_review_report reconstructed from DB rows with report_type == "market_review".
  • src/services/task_queue.py accepts an externally provided task_id in submit_background_task (with duplicate-ID guard); src/services/history_service.py returns the persisted Markdown directly for market review rows; tests added/updated.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/core/market_review.py Adds query_id param and _persist_market_review_history helper writing into AnalysisHistory.
api/v1/endpoints/analysis.py Pre-allocates task_id, forwards as query_id, returns market review report from DB lookup.
src/services/task_queue.py submit_background_task accepts external task_id with duplicate check.
src/services/history_service.py get_markdown_report short-circuits for market_review records.
docs/CHANGELOG.md Adds Unreleased flat fix entry for market review history persistence.
tests/test_market_review.py Patches new persistence helper and adds DB persistence test.
tests/test_analysis_history.py Asserts persisted market review report returned verbatim.
tests/test_analysis_api_contract.py Asserts /status returns market_review_report from DB.

@ZhuLinsen
ZhuLinsen force-pushed the autocode/issue-1306-task branch from 2d72848 to b750cf2 Compare May 15, 2026 12:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d72848111

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

record_id=record_id
)

if getattr(record, "report_type", None) == "market_review":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return market review content from history detail

When a persisted market review row appears in the Web history list, clicking it follows stockPoolStore.selectHistoryItem -> historyApi.getDetail -> /api/v1/history/{id}, not the Markdown drawer endpoint. This branch only special-cases get_markdown_report, so the initial history view still renders the new market_review row as a stock-style report with just the short summary/empty sections; users must discover the separate full-report drawer to see the recap, which leaves the advertised direct Web history viewing path incomplete. Please also special-case the history detail/client path to surface the saved recap content.

Useful? React with 👍 / 👎.

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过 + 修复 #1306 中大盘复盘结果不入历史、导致 Web/API 侧重复触发的问题,业务价值明确。
  • 是否有对应 issue:有,Closes #1306
  • PR 类型:fix + 复用现有分析历史机制持久化并查询大盘复盘结果。
  • description 完整性:不完整 + 背景、范围、验证、风险和回滚已给出,但文档同步 checklist 未闭环,且未说明中英文专题文档是否需要同步;结构化提示中的 LLM/provider 风险经 diff 复核未见实际运行时模型、provider、Base URL 或配置清理逻辑变更。
  • 是否可直接合入:不可 + 需先补齐 Web 历史查看链路对 market_review 的实际展示/回归验证,并按 AGENTS.md 补齐用户可见 API/Web 行为文档。

主要问题

  1. [Correctness blocker] src/core/market_review.pysrc/services/history_service.pyapi/v1/endpoints/history.pyapps/dsa-web/src/stores/stockPoolStore.ts:本 PR 已把完整复盘 Markdown 存入历史,并让 /history/{id}/markdown 可返回正文,但 Web 历史列表点击仍走 selectHistoryItem -> historyApi.getDetail -> GET /api/v1/history/{id},默认主视图拿到的是通用 AnalysisReport 摘要字段。当前没有为 report_type=market_review 在历史详情响应或前端渲染中提供专门正文展示,用户点击历史项后仍可能只看到摘要、空策略点位/空新闻区,需要再点“完整报告”才进入 Markdown 路径;这与 PR 声明的“Web 历史列表可直接查看已生成复盘”不完全一致。建议补齐该路径的 API/前端契约,并增加 Web 或 API 合约回归覆盖。
  2. [Process blocker] docs/CHANGELOG.md 已更新且格式符合 [Unreleased] 扁平条目,但本次属于用户可见的 API/Web 历史语义变更。仓库 AGENTS.md 要求涉及用户可见能力、CLI/API 行为、报告结构变化时同步相关文档;当前 docs/full-guide.md / docs/full-guide_EN.md 已有大盘复盘 API 与历史记录的通用说明,但本次新增的“大盘复盘写入历史、历史详情/Markdown/status 可复用已生成复盘”的语义未说明,也未解释英文文档是否无需同步。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen
ZhuLinsen force-pushed the autocode/issue-1306-task branch from b750cf2 to 98c6829 Compare May 15, 2026 13:21

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过 + 修复大盘复盘结果不入历史导致 Web/API 侧重复触发的问题,业务价值明确。
  • 是否有对应 issue:有,Closes #1306
  • PR 类型:fix + 复用现有 analysis_history 机制持久化并查询大盘复盘结果。
  • description 完整性:不完整 + 背景、范围、验证、风险和回滚已给出,docs/CHANGELOG.md 也已更新;但未闭环用户可见历史语义的专题文档/中英文同步说明,也未说明 market_review 作为历史 report_type 新取值对 Web 类型契约的兼容性。结构化提示中的 LLM/provider 风险经完整 diff 复核,未见实际模型名、provider、Base URL、依赖默认值或运行时配置清理变更。
  • 是否可直接合入:不可 + 当前 CI 为 success,但 web-gate skipped;需先补齐大盘复盘历史记录的 Web/API 契约闭环与对应文档落点。

主要问题

  1. [Compatibility blocker] api/v1/endpoints/history.py / src/services/history_service.py 现在会向历史详情返回 report_type="market_review",但 Web 端现有 apps/dsa-web/src/types/analysis.tsReportMeta.reportType 仍只允许 simple | detailed | full | brief。本 PR 实际新增了历史报告类型语义,却没有更新客户端类型或补充 Web 侧选择大盘复盘历史记录的验证;按 AGENTS.md 的 API / Web 兼容护栏,这类枚举语义变化需要覆盖受影响客户端构建或测试。
  2. [Process blocker] 已有 docs/full-guide.md / docs/full-guide_EN.md 对大盘复盘任务状态和历史接口有通用说明,但本次新增的“大盘复盘结果会写入历史、历史详情/Markdown 可直接打开且不重新触发分析”的用户可见语义没有同步说明。AGENTS.md 要求用户可见能力、API 行为或报告结构变化同步相关文档与 docs/CHANGELOG.md;当前只更新了 Changelog,PR checklist 也未闭环文档同步。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 845752c4a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/market_review.py
trend_prediction = "大盘复盘"

result = AnalysisResult(
code=MARKET_REVIEW_HISTORY_CODE,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Disable stock rerun for market-review history rows

When a persisted market-review row is opened from history, this synthetic MARKET code is returned as selectedReport.meta.stockCode; the existing HomePage rerun action submits that value to the stock-analysis endpoint (submitAnalysis({ stockCode: selectedReport.meta.stockCode, ... })). In that context, clicking “重新分析” on a market-review history item attempts to analyze the pseudo-symbol MARKET instead of re-triggering the market-review endpoint or disabling the action, so users hit an invalid/wrong analysis path from the newly added history rows.

Useful? React with 👍 / 👎.

@ZhuLinsen
ZhuLinsen force-pushed the autocode/issue-1306-task branch from 845752c to e667e13 Compare May 15, 2026 14:08

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e667e13b59

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

variant="home-action-ai"
size="sm"
disabled={isAnalyzing || selectedReport.meta.id === undefined}
disabled={isAnalyzing || selectedReport.meta.id === undefined || isMarketReviewHistoryReport}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Disable follow-up for market-review history rows

When a persisted market-review row is selected, this new isMarketReviewHistoryReport guard is only applied to the reanalysis button; the adjacent “追问 AI” action still navigates with the synthetic stock=MARKET. ChatPage then calls sanitizeFollowUpStockCode, whose ticker pattern only accepts 1–5 letter US symbols, so MARKET is rejected and the follow-up context is discarded. For market-review history rows, either disable this action too or pass a dedicated market-review context instead of the pseudo-symbol.

Useful? React with 👍 / 👎.

@ZhuLinsen
ZhuLinsen force-pushed the autocode/issue-1306-task branch from e667e13 to 8ebbd17 Compare May 15, 2026 14:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ebbd17dce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/market_review.py
saved = DatabaseManager.get_instance().save_analysis_history(
result=result,
query_id=history_query_id,
report_type=MARKET_REVIEW_REPORT_TYPE,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude market review rows from backtests

When a persisted market-review row ages past backtest_min_age_days, the backtest candidate query still selects every AnalysisHistory row by age and optional stock code only (src/repositories/backtest_repo.py::get_candidates has no report_type filter). Saving these pseudo-stock rows with code=MARKET therefore makes /api/v1/backtest/run without a code try to backtest MARKET, creating insufficient/error results and polluting global summaries. Please exclude market_review records from backtest candidates or keep them out of the stock-analysis candidate set.

Useful? React with 👍 / 👎.

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过 + 修复 #1306 中大盘复盘结果不入历史、Web/API 侧需重复触发的问题,业务价值明确。
  • 是否有对应 issue:有,Closes #1306
  • PR 类型:fix + 复用现有分析历史机制持久化并查询大盘复盘结果。
  • description 完整性:不完整 + 背景、范围、文档、验证和回滚已给出,但未说明新增 market_review 历史记录对回测候选/汇总链路的兼容影响;结构化提示中的模型/provider/Base URL/运行时配置迁移风险经 diff 复核未见实际运行时配置变更。
  • 是否可直接合入:不可 + 需先避免大盘复盘历史被整体回测当作普通股票分析记录处理。

主要问题

  1. [Correctness blocker] src/core/market_review.py 新增将大盘复盘写入 analysis_history,记录形态为 code="MARKET"report_type="market_review";但 src/repositories/backtest_repo.py 的回测候选查询仍只按创建时间、可选股票代码和已回测记录过滤,没有排除 market_review。整体回测或定时回测开启后,这类非个股报告会被 src/services/backtest_service.py 当作股票 MARKET 拉取行情并写入 backtest_results,产生 insufficient_data/error 噪音,并污染 overall/stock 回测汇总。建议在候选查询或回测服务入口排除 report_type="market_review",并补充回归测试覆盖整体回测不会处理大盘复盘历史。
  2. [Nice to have] apps/dsa-web/src/types/analysis.tsmarket_review 纳入 AnalysisRequest.reportType,但后端 /api/v1/analysis/analyzeAnalyzeRequest.report_type 仍限制为 simple|detailed|full|brief,大盘复盘实际走独立 /market-review 端点。当前 HomePage 已拦截大盘复盘历史的重新分析,直接风险有限,但类型契约会误导后续调用方提交后端不接受的请求;建议拆分股票分析请求类型与历史/报告展示类型。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen
ZhuLinsen force-pushed the autocode/issue-1306-task branch from 8ebbd17 to 19918df Compare May 15, 2026 14:44

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过 + 修复 #1306 中大盘复盘结果不入历史、导致 Web/API 侧重复触发的问题,业务价值明确。
  • 是否有对应 issue:有,Closes #1306
  • PR 类型:fix + 复用现有分析历史机制持久化并查询大盘复盘结果。
  • description 完整性:基本完整 + 背景、范围、验证、风险、文档落点和回滚方案已给出;但结构化检测提示涉及外部模型/API 或运行时配置相关变更,PR 描述未补充官方来源、当前依赖/运行时兼容验证、旧配置迁移/回退路径的说明。
  • 是否可直接合入:不可 + CI 已通过,mergeable_state=blocked 不单独构成阻断;但需先澄清结构化检测提示中的外部模型/API 与运行时配置迁移风险是否为误报,或补齐对应兼容性证据。

主要问题

  1. [Process blocker] 结构化事实提示本 PR 检测到模型名、provider、Base URL、LiteLLM/LLM 配置或保存前清理逻辑相关改动;但 PR 描述和当前证据包只说明大盘复盘历史持久化,未提供官方来源链接、当前锁定依赖/运行时兼容验证、旧配置迁移与回退路径。按本仓库 AGENTS.md 对配置语义、外部依赖和用户运行时配置迁移的稳定性要求,这部分不能仅凭 CI 成功判低风险;需要明确说明这是误报并给出 diff 依据,或补齐兼容性/迁移证据后再合入。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 277b9f30af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/repositories/backtest_repo.py Outdated
conditions = [AnalysisHistory.created_at <= cutoff_dt]
if code:
conditions.append(AnalysisHistory.code == code)
conditions.append(AnalysisHistory.report_type != MARKET_REVIEW_REPORT_TYPE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve legacy backtest candidates with null report types

When an existing database contains older stock AnalysisHistory rows with report_type left NULL (the column is nullable), this new != 'market_review' predicate excludes them as well because SQL comparisons against NULL evaluate to unknown. In that environment, /api/v1/backtest/run silently skips legitimate legacy stock analyses, so the exclusion should explicitly keep NULL report types, e.g. report_type IS NULL OR report_type != 'market_review'.

Useful? React with 👍 / 👎.

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过 + 修复大盘复盘结果未进入历史记录、导致 Web/API 侧重复触发的问题,业务价值明确。
  • 是否有对应 issue:有,Closes #1306
  • PR 类型:fix + 复用现有分析历史机制持久化并查询大盘复盘结果。
  • description 完整性:不完整 + 背景、范围、验证、文档和回滚方案已给出,但未说明历史库中 report_type 为空的旧个股记录在回测候选查询中的兼容影响。
  • 是否可直接合入:不可 + CI 已通过,当前 mergeable_state=blocked 本身不作为阻断;阻断点是回测候选过滤会漏掉旧历史数据,需先修复普通个股历史不回归问题。

主要问题

  1. [Correctness blocker] src/repositories/backtest_repo.py:为排除大盘复盘记录新增的 report_type != 'market_review' 过滤会在 SQL 中同时排除 report_type IS NULL 的旧个股分析历史。该列在既有库中可能为空,本 PR 会让这些旧记录不再进入回测候选,违反“普通个股分析历史记录行为不回归”的验收标准。建议改为显式保留空类型记录,例如 report_type IS NULL OR report_type != 'market_review',并补一条旧数据 report_type=None 仍可被回测选中的回归测试。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过 + 修复 #1306 中大盘复盘结果未进入历史记录、导致 Web/API 侧重复触发的问题,业务价值明确。
  • 是否有对应 issue:有,Closes #1306
  • PR 类型:fix + 复用现有分析历史机制持久化并查询大盘复盘结果。
  • description 完整性:完整 + 背景、范围、验证、文档落点、兼容性风险和回滚方案均已说明;结构化提示中的模型/provider/Base URL/运行时配置风险经本地 diff 复核为否定性说明,未见实际运行时配置迁移。
  • 是否可直接合入:可 + CI 已通过,当前 mergeable_state=blocked 本身不作为阻断;本地 diff 已覆盖大盘复盘历史持久化、Web 历史查看、禁用个股重分析/追问入口、回测候选排除 market review 且保留旧 report_type=NULL 个股记录的回归测试。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen
ZhuLinsen merged commit fb98a62 into main May 16, 2026
10 checks passed
Anyone878 pushed a commit to Anyone878/daily_stock_analysis that referenced this pull request May 17, 2026
* fix(issue-1306): 大盘分析的历史执行记录丢失

* fix(review-feedback-1307): also special-case the history detail/client path to surface the saved

* fix(review-feedback-1307): 补齐大盘复盘历史记录的 Web/API 契约闭环与对应文档落点

* fix(review-feedback-1307): Disable stock rerun for market-review history rows

* fix(review-feedback-1307): Disable follow-up for market-review history rows

* fix(review-feedback-1307): 避免大盘复盘历史被整体回测当作普通股票分析记录处理

* fix(review-feedback-1307): 澄清结构化检测提示中的外部模型/API 与运行时配置迁移风险是否为误报,或补齐对应兼容性证据

* fix(review-feedback-1307): 修复普通个股历史不回归问题
EchoingFootsteps pushed a commit to EchoingFootsteps/daily_stock_analysis that referenced this pull request Jul 4, 2026
* fix(issue-1306): 大盘分析的历史执行记录丢失

* fix(review-feedback-1307): also special-case the history detail/client path to surface the saved

* fix(review-feedback-1307): 补齐大盘复盘历史记录的 Web/API 契约闭环与对应文档落点

* fix(review-feedback-1307): Disable stock rerun for market-review history rows

* fix(review-feedback-1307): Disable follow-up for market-review history rows

* fix(review-feedback-1307): 避免大盘复盘历史被整体回测当作普通股票分析记录处理

* fix(review-feedback-1307): 澄清结构化检测提示中的外部模型/API 与运行时配置迁移风险是否为误报,或补齐对应兼容性证据

* fix(review-feedback-1307): 修复普通个股历史不回归问题
bmwu pushed a commit to bmwu/daily_stock_analysis that referenced this pull request Aug 24, 2026
* fix(issue-1306): 大盘分析的历史执行记录丢失

* fix(review-feedback-1307): also special-case the history detail/client path to surface the saved

* fix(review-feedback-1307): 补齐大盘复盘历史记录的 Web/API 契约闭环与对应文档落点

* fix(review-feedback-1307): Disable stock rerun for market-review history rows

* fix(review-feedback-1307): Disable follow-up for market-review history rows

* fix(review-feedback-1307): 避免大盘复盘历史被整体回测当作普通股票分析记录处理

* fix(review-feedback-1307): 澄清结构化检测提示中的外部模型/API 与运行时配置迁移风险是否为误报,或补齐对应兼容性证据

* fix(review-feedback-1307): 修复普通个股历史不回归问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/L testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

大盘分析的历史执行记录丢失

2 participants