feat(worker): 派发意图时按 asset_ids 自动纳入任务测试范围

- Execute 里复用已查出的目标资产,逐个 AddAutoScope(与 insertAssets 同一套
  保守粒度、source=auto)
- 去重由 upsertTaskScope 的 ON CONFLICT DO NOTHING + uq_task_scope 唯一索引
  保证,重跑/重试幂等 no-op

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Autumn-27andClaude Opus 4.8 committed 2026-08-08 12:59:58 -04:00
1 parent f80ed0b7fe
commit 6dce6317e8
1 file changed
+6
+6
View File
@@ -307,6 +307,12 @@ func (w *Worker) Execute(ctx context.Context, name string, taskID int64, as *db.
if b, err := json.Marshal(assets); err == nil {
input += "\n\n本意图 asset_ids 对应的目标资产:\n" + string(b)
}
// 意图明确针对的这些资产 → 自动纳入任务测试范围(与 insertAssets 同一套
// 保守粒度)。upsertTaskScope 的 ON CONFLICT DO NOTHING + uq_task_scope
// 唯一索引保证不会重复添加;重跑/重试同样是幂等 no-op。
for _, a := range assets {
_ = as.AddAutoScope(taskID, a.Type, a.Domain, a.URL, a.IP)
}
}
}
}