thread-master/docs/product/scout-topic-quality/tasks/T041-candidate-evaluation.md

58 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2026-08-13 02:22:24 +00:00
# T041 — 候選判定與品質計數
> Status: `done`
> Milestone: `M4`
> Est. change: `~190 lines`
## Goal
完成後,每個 raw candidate 都只經一條可測管線產生 eligibleduplicateirrelevant 等判定與 match reason。
## Depends on
- T040
## Inputs
- 讀取 / 依賴:
- 檔案:`apps/backend/internal/module/scout/usecase/service.go`、`planner.go`
- 既有能力 / APIcanonicalPermalink、classifyPost、stale rules、TopicSignature
- Spec 段落§4 流程 B/C、§2.1
## Outputs
### 程式變更(預期路徑)
| 路徑 | 動作 | 說明 |
|------|------|------|
| `apps/backend/internal/module/scout/usecase/candidate.go` | add | 定義 evaluator、decision reason 與 run counters accumulator。 |
| `apps/backend/internal/module/scout/usecase/service.go` | edit | persist 前改用 evaluator移除重複散落的 eligibility 判定。 |
| `apps/backend/internal/module/scout/usecase/candidate_test.go` | add | 覆蓋 URL、空文、stale、signature、classification 與 reason。 |
### 行為變更
- scoretrack 只能補充 reason 與排序權重,不得繞過 topic signature。
### API / 契約(若有)
- searched/duplicate/irrelevant/eligible 的計數定義固定且互斥可解釋。
## Out of scope
- 不做歷史 identity 查詢或多輪補量。
## Acceptance
- [x] 每個 candidate 有唯一終局 decisioneligible reason 含核心命中。
- [x] 指令:
```bash
cd apps/backend && go test ./internal/module/scout/usecase -run Candidate -count=1
```
驗收結果CandidateEvaluator 統一 canonical URL時效TopicSignature分類 gate產生 eligible、duplicate、irrelevant 與可解釋 reason既有 product/provider/demand/activity 回歸通過。
## Notes
provider/demand 模式既有分類行為必須回歸,不因 activity 改造被放寬。