refactor(autostockpile): 拆分 Pipeline 和 Go Service 职责边界#1635
Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我发现了 1 个问题
给 AI 代理的提示
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/en_us/developers/auto-stockpile-maintain.md" line_range="105" />
<code_context>
> [!TIP]
>
-> Threshold-related task inputs and attach values must be **positive integers**. Empty strings, `0`, and negative values do not trigger fallback; they are rejected by task input validation or by the Go-side config parser.
+> Threshold-related task inputs and attach values must be **positive integers**. Empty strings, `0`, and negative values do not trigger fallback; they are rejected by task input validation or the Go-side config parser.
## Reserve Stock Bill
</code_context>
<issue_to_address>
**issue (typo):** 为了语法正确,请在这个句子中补上缺失的 "by"。
可以考虑将句子的结尾部分改写为:
`...they are rejected by task input validation or by the Go-side config parser.`
```suggestion
> Threshold-related task inputs and attach values must be **positive integers**. Empty strings, `0`, and negative values do not trigger fallback; they are rejected by task input validation or by the Go-side config parser.
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/en_us/developers/auto-stockpile-maintain.md" line_range="105" />
<code_context>
> [!TIP]
>
-> Threshold-related task inputs and attach values must be **positive integers**. Empty strings, `0`, and negative values do not trigger fallback; they are rejected by task input validation or by the Go-side config parser.
+> Threshold-related task inputs and attach values must be **positive integers**. Empty strings, `0`, and negative values do not trigger fallback; they are rejected by task input validation or the Go-side config parser.
## Reserve Stock Bill
</code_context>
<issue_to_address>
**issue (typo):** Add a missing "by" for correct grammar in this sentence.
Consider rewriting the end of the sentence as:
`...they are rejected by task input validation or by the Go-side config parser.`
```suggestion
> Threshold-related task inputs and attach values must be **positive integers**. Empty strings, `0`, and negative values do not trigger fallback; they are rejected by task input validation or by the Go-side config parser.
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- 抽出节点常量、地区参数解析和 pipeline override 构造 - 分离额度解析、商品扫描与 RecognitionDetail 读取 helper - 收窄 recognition、quantity 和 types 的职责边界
- 将 Task.json 拆为 Entry、DecisionLoop 和 Purchase - 保留决策锚点、attach 合同节点和地区节点命名 - 维持购买链与统一退出链的原有连通关系
- 同步中英文维护文档到当前 Pipeline 拆分结构 - 补充 attach、阈值回退、保留调度券与运行时覆盖说明 - 修正 QuantizedSliding 文档中的 AutoStockpile 示例路径
8be6e2e to
cc852ab
Compare
Contributor
|
@sourcery-ai review |
Contributor
There was a problem hiding this comment.
Hey - 我已经审查了你的修改,看起来非常棒!
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've reviewed your changes and they look great!
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 进行结构性重构:将原先单体 Pipeline 拆分为更清晰的 Entry / DecisionLoop / Purchase 三段,并将 go-service 的 autostockpile 识别与决策逻辑按职责拆分到多个文件中,同时收紧识别来源到 Best/Filtered 结果以降低误识别;相应维护文档与 QuantizedSliding 接入示例也同步更新到新的 Pipeline 结构。
Changes:
- 拆分 AutoStockpile Pipeline:移除
Task.json,新增Entry.json/DecisionLoop.json/Purchase.json并保持锚点/连通关系。 - 重构 go-service/autostockpile:抽离商品扫描、识别结果、配额、参数解析、override、节点常量等模块,缩小文件职责边界。
- 更新中英文开发/维护文档:修正文档引用路径与运行时覆盖/阈值回退/attach 说明。
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| docs/zh_cn/developers/quantized-sliding.md | 更新 QuantizedSliding 在 AutoStockpile 中的接入示例位置引用到 Purchase.json 节点。 |
| docs/zh_cn/developers/auto-stockpile-maintain.md | 同步 AutoStockpile Pipeline 拆分后的维护说明,并补充 attach/阈值回退/override 行为描述。 |
| docs/en_us/developers/quantized-sliding.md | 英文版同步更新 QuantizedSliding 接入示例引用到 Purchase.json 节点。 |
| docs/en_us/developers/auto-stockpile-maintain.md | 英文版同步更新 Pipeline 拆分与运行时行为说明。 |
| assets/resource/pipeline/AutoStockpile/Task.json | 删除旧的单体流程定义,为拆分后的三段流程让路。 |
| assets/resource/pipeline/AutoStockpile/Entry.json | 新增“进入与滚动到底部”等入口阶段节点。 |
| assets/resource/pipeline/AutoStockpile/DecisionLoop.json | 新增“识别-决策-复核-跳过”等核心决策循环节点与 attach 合同节点。 |
| assets/resource/pipeline/AutoStockpile/Purchase.json | 新增“调整数量-购买-取消-返回”等购买分支节点,并承接 QuantizedSliding 节点示例。 |
| agent/go-service/autostockpile/types.go | 精简类型文件:移除与阈值解析/runner 声明等无关内容,使其聚焦数据契约与配置类型。 |
| agent/go-service/autostockpile/stockbill.go | OCR 文本来源收敛为 Best-only,并复用统一的 OCR 文本候选提取逻辑。 |
| agent/go-service/autostockpile/selector.go | SelectItem 自定义动作逻辑保留,改用新的识别详情 JSON 提取函数,并移动接口断言到类型附近。 |
| agent/go-service/autostockpile/register.go | 使用集中定义的 action/recognition 名称常量注册 runner。 |
| agent/go-service/autostockpile/reconcile.go | 复核阶段 OCR 文本来源收敛为 Best-only,日志字段改进(Strs)。 |
| agent/go-service/autostockpile/recognition_results.go | 新增识别结果/候选提取工具:Best-only/Filtered-only OCR 文本与模板命中提取、detail JSON 解包等。 |
| agent/go-service/autostockpile/recognition.go | 识别主流程瘦身:将商品扫描/配额/参数/override 等拆出,模板命中取 Best 结果。 |
| agent/go-service/autostockpile/quota.go | 抽离配额 OCR 与解析逻辑,且 OCR 文本来源改为 Filtered-only。 |
| agent/go-service/autostockpile/quantity.go | 移除与 override/param 解析相关的杂项实现(迁移到专用文件),保留数量决策与展示文本格式化。 |
| agent/go-service/autostockpile/params.go | 新增参数解析/归一化:Region 解析与 custom_action_param 兼容 map/JSON string。 |
| agent/go-service/autostockpile/overrides.go | 新增集中 override 构造与跳过分支重置/重定向逻辑。 |
| agent/go-service/autostockpile/options.go | 阈值/输入解析错误模型与数值解析函数迁移至此,使 options 聚焦配置解析与校验。 |
| agent/go-service/autostockpile/nodes.go | 新增节点名/动作名/识别名常量集中管理,减少散落字符串。 |
| agent/go-service/autostockpile/itemmap.go | 增补 item_map 校验与 region/未绑定条目收集等辅助逻辑(从识别文件迁移)。 |
| agent/go-service/autostockpile/goods_scan.go | 抽离商品扫描:模板匹配、OCR 绑定、ROI 调整、测试价注入等逻辑独立成模块。 |
Comments suppressed due to low confidence (2)
agent/go-service/autostockpile/selector.go:37
- 这里的日志字段
component仍在使用字符串字面量 "autostockpile"。当前包已在nodes.go定义了autoStockpileComponent常量,建议统一改用该常量,避免后续改名/拼写不一致导致日志聚合维度分裂。
detailJSON := extractCustomRecognitionDetailJSON(arg.RecognitionDetail)
if detailJSON == "" {
log.Error().
Str("component", "autostockpile").
Msg("recognition detail json is empty")
agent/go-service/autostockpile/reconcile.go:44
- 这里的日志字段
component仍在使用字符串字面量 "autostockpile"。当前包已提供autoStockpileComponent常量(见nodes.go),建议统一改用常量,减少重复字面量并避免未来出现不一致。
ocrTexts := ocrTextCandidates(arg.RecognitionDetail, ocrTextPolicyBestOnly)
if len(ocrTexts) == 0 {
log.Error().
Str("component", "autostockpile").
Msg("reconcile recognition detail contains no ocr text")
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:
Summary by Sourcery
通过拆分流水线职责与 Go 服务逻辑为更聚焦的组件,对 AutoStockpile 模块进行重构,同时收紧识别行为并更新维护文档。
增强内容:
文档:
Original summary in English
Summary by Sourcery
Refactor the AutoStockpile module by splitting pipeline responsibilities and Go service logic into focused components while tightening recognition behavior and updating maintenance documentation.
Enhancements:
Documentation:
Original summary in English
Summary by Sourcery
通过拆分流水线职责与 Go 服务逻辑为更聚焦的组件,对 AutoStockpile 模块进行重构,同时收紧识别行为并更新维护文档。
增强内容:
文档:
Original summary in English
Summary by Sourcery
Refactor the AutoStockpile module by splitting pipeline responsibilities and Go service logic into focused components while tightening recognition behavior and updating maintenance documentation.
Enhancements:
Documentation: