Conversation
- 额度 OCR 失败时以告警原因中止并走 skip - 修正调度券 OCR 对小数和万单位的解析 - 收紧保留调度券与价位阈值的配置校验
- 缓存当前选品与数量决策,支持按详情页价格重新计算 - Pipeline 增加复核重试、中继和回退重选链路 - 补充价格修正提示文案,并加入识别阶段测试价格覆盖
- 识别与选择阶段统一读取 Region 参数 - 为 ValleyIV 与 Wuling 拆分独立决策入口 - 调整购买前稳定检测与滑动回退链路
- 补充全局开关与 attach 键说明 - 更正新增地区时的 Region 配置要求 - 更新阈值校验与保留调度券前置条件
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些总体反馈:
- 新增的全局
decisionState(位于state.go)在整个进程中是共享的;请考虑在多个 AutoStockpile 任务并发或交错运行时,它的行为会如何,并确保在所有终止路径上都能可靠地清理该状态,以避免不同运行之间的决策信息发生泄漏。 - 新增的
AbortReason.isFatal/isWarn/isSkip辅助方法完全依赖字符串后缀来判断;更安全的做法可能是集中校验后缀的正确性,或者改用显式分类机制(例如使用 map),从而避免未来新增原因时可以悄然绕过预期的分流逻辑。
给 AI 代理的提示
请根据本次代码评审中的评论进行修改:
## 综合评论
- 新增的全局 `decisionState`(位于 `state.go`)在整个进程中是共享的;请考虑在多个 AutoStockpile 任务并发或交错运行时,它的行为会如何,并确保在所有终止路径上都能可靠地清理该状态,以避免不同运行之间的决策信息发生泄漏。
- 新增的 `AbortReason.isFatal/isWarn/isSkip` 辅助方法完全依赖字符串后缀来判断;更安全的做法可能是集中校验后缀的正确性,或者改用显式分类机制(例如使用 map),从而避免未来新增原因时可以悄然绕过预期的分流逻辑。帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- The new global
decisionStateinstate.gois shared process-wide; consider how this behaves if multiple AutoStockpile tasks can run concurrently or interleave, and ensure the state is reliably cleared on all terminal paths to avoid leaking decisions between runs. - The new
AbortReason.isFatal/isWarn/isSkiphelpers rely purely on string suffixes; it might be safer to either validate suffix correctness centrally or move to an explicit classification (e.g., a map) so adding new reasons in the future can’t silently bypass the intended routing logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new global `decisionState` in `state.go` is shared process-wide; consider how this behaves if multiple AutoStockpile tasks can run concurrently or interleave, and ensure the state is reliably cleared on all terminal paths to avoid leaking decisions between runs.
- The new `AbortReason.isFatal/isWarn/isSkip` helpers rely purely on string suffixes; it might be safer to either validate suffix correctness centrally or move to an explicit classification (e.g., a map) so adding new reasons in the future can’t silently bypass the intended routing logic.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 旨在改进 AutoStockpile 的“识别 + 购买决策”链路:将识别/选择共用同一份决策状态,并在详情页 OCR 价格变化后重新计算购买决策,通过 Pipeline 回退链路实现继续/重试/跳过;同时拆分地区入口、增强调度券与阈值解析健壮性,并同步更新维护文档与多语言文案。
Changes:
- Pipeline:按 Region 拆分 ValleyIV/Wuling 决策入口,新增详情页价格复核与重试/回退链路,并加入命中计数清理节点。
- Go:引入共享决策状态与“复核后重算决策”自定义 Action;Region 解析改为读取节点 custom_action_param;阈值/调度券解析更严格、更稳健。
- 文档与本地化:补齐 Region/attach 键说明、价格修正提示与新的配置约束,多语言文案同步更新。
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/zh_cn/developers/auto-stockpile-maintain.md | 更新中文维护文档:任务选项、attach 键、Region 扩展与注意事项说明 |
| docs/en_us/developers/auto-stockpile-maintain.md | 更新英文维护文档,与中文内容对齐 |
| assets/resource/pipeline/AutoStockpile/Task.json | 新增/重构地区决策节点、详情页价格复核与重试链路,调整部分节点命名与 next |
| assets/resource/pipeline/AutoStockpile/Main.json | 调整入口/地区节点与 anchor,用于地区化决策节点路由 |
| assets/locales/go-service/zh_tw.json | 新增价格修正文案与细分 abort reason 文案键 |
| assets/locales/go-service/zh_cn.json | 同上(简中) |
| assets/locales/go-service/ko_kr.json | 同上(韩语) |
| assets/locales/go-service/ja_jp.json | 同上(日语) |
| assets/locales/go-service/en_us.json | 同上(英文) |
| agent/go-service/autostockpile/types.go | 细分 AbortReason(Warn/Skip/Fatal)并通过后缀判断路由策略 |
| agent/go-service/autostockpile/thresholds.go | 调整价格阈值 override 解析路径 |
| agent/go-service/autostockpile/stockbill.go | 调度券 OCR 解析增强:支持“万”单位小数并增加溢出保护 |
| agent/go-service/autostockpile/state.go | 新增共享 DecisionState(识别产出、选择/复核消费) |
| agent/go-service/autostockpile/selector.go | 选择阶段使用统一 computeDecision,并写入 DecisionState 供复核使用 |
| agent/go-service/autostockpile/register.go | 注册新的自定义 Action:AutoStockpile.ReconcileDecision |
| agent/go-service/autostockpile/reconcile.go | 新增详情页价格复核后重算决策逻辑与对应 Pipeline override |
| agent/go-service/autostockpile/recognition.go | Region 解析改为读节点参数;溢出/额度解析更严格;加入可选测试价格重写 |
| agent/go-service/autostockpile/options.go | 保留调度券输入解析改为严格正整数并增加上限校验 |
| agent/go-service/autostockpile/decision.go | 抽取 computeDecision 复用选择与数量决策计算 |
Contributor
There was a problem hiding this comment.
Hey - 我给出了一些整体性的反馈:
applyTestPricesIfEnabled辅助函数在没有固定种子的情况下使用了rand.Shuffle,这削弱了“测试可重复、确定性”的目标;建议在测试环境变量被设置时,为math/rand使用一个固定常量种子,或者以确定性的方式生成选择结果(例如通过排序后的索引)。AbortReason.isFatal/isWarn/isSkip仅依赖字符串后缀判断,这在新增原因类型时很容易被破坏;你可能需要通过健全性检查来强制执行后缀约定(例如在init()中遍历knownAbortReasons),以便在引入命名不规范的原因时快速失败。
用于 AI Agent 的提示词
Please address the comments from this code review:
## Overall Comments
- The `applyTestPricesIfEnabled` helper uses `rand.Shuffle` without a fixed seed, which undermines the goal of deterministic testing; consider seeding `math/rand` with a constant or deriving the selection deterministically (e.g., via sorted indices) when the test env var is set.
- `AbortReason.isFatal/isWarn/isSkip` rely solely on string suffixes, which is easy to break when adding new reasons; you might want to enforce suffix conventions via a sanity check (e.g., in an init() over `knownAbortReasons`) to fail fast if an incorrectly named reason is introduced.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码评审。
Original comment in English
Hey - I've left some high level feedback:
- The
applyTestPricesIfEnabledhelper usesrand.Shufflewithout a fixed seed, which undermines the goal of deterministic testing; consider seedingmath/randwith a constant or deriving the selection deterministically (e.g., via sorted indices) when the test env var is set. AbortReason.isFatal/isWarn/isSkiprely solely on string suffixes, which is easy to break when adding new reasons; you might want to enforce suffix conventions via a sanity check (e.g., in an init() overknownAbortReasons) to fail fast if an incorrectly named reason is introduced.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `applyTestPricesIfEnabled` helper uses `rand.Shuffle` without a fixed seed, which undermines the goal of deterministic testing; consider seeding `math/rand` with a constant or deriving the selection deterministically (e.g., via sorted indices) when the test env var is set.
- `AbortReason.isFatal/isWarn/isSkip` rely solely on string suffixes, which is easy to break when adding new reasons; you might want to enforce suffix conventions via a sanity check (e.g., in an init() over `knownAbortReasons`) to fail fast if an incorrectly named reason is introduced.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary:
close #1577
Summary by Sourcery
优化 AutoStockpile 的区域/配置处理、决策流程与对账逻辑,并更新文档与本地化内容以匹配新行为。
Bug 修复:
功能增强:
custom_action_param.Region驱动区域解析,并通过物品映射校验替代硬编码锚点,同时注册单独的对账操作入口。computeDecision辅助方法,使识别、选择与对账保持一致,并简化决策复用。文档:
Original summary in English
Summary by Sourcery
Refine AutoStockpile region/config handling, decision flow, and reconciliation, and update documentation and localization to match the new behavior.
Bug Fixes:
Enhancements:
Documentation:
Summary by Sourcery
改进 AutoStockpile 的区域处理、共享决策状态以及决策对账逻辑,以便在价格被更正时能够做出响应,同时加强对进货单与配额的解析,并更新相关文档与本地化内容。
Bug 修复:
增强功能:
custom_action_param.Region驱动区域解析,并配合商品映射校验,替换硬编码锚点;在识别、选择和对账流程之间复用共享的决策计算辅助方法。ReconcileDecision动作,当用户更正商品价格时重新计算选择和数量,并据此在继续、重试或跳过路径之间进行路由。Fatal/Warn/Skip后缀对终止原因按严重程度分类,并更新跳过/停止的路由、日志记录以及 relay 节点覆盖逻辑,包括新增“decision-ready” relay 节点,以及在跳过或重试时清理 relay/selection 节点。文档:
Original summary in English
Summary by Sourcery
Refine AutoStockpile region handling, shared decision state, and decision reconciliation to react to price corrections, while tightening stock bill and quota parsing and updating related documentation and localization.
Bug Fixes:
Enhancements:
Documentation: