thread-master/docs/product/scout-topic-quality/tasks/T033-run-post-pagination-le...

58 lines
1.7 KiB
Markdown
Raw Normal View History

2026-08-13 02:22:24 +00:00
# T033 — 結果分頁與 legacy run
> Status: `done`
> Milestone: `M3`
> Est. change: `~190 lines`
## Goal
完成後,新 run 結果與缺 run_id 的舊貼文都能按 Spec 依 score 穩定分頁,且同分未知 posted_at 置底。
## Depends on
- T032
## Inputs
- 讀取 / 依賴:
- 檔案:`apps/backend/internal/module/scout/repository/{memory,mongo}.go`
- 既有能力 / APIPost.RunID、canonical identity、run query contract
- Spec 段落§4 流程 E、§6.1、§9 #8#11
## Outputs
### 程式變更(預期路徑)
| 路徑 | 動作 | 說明 |
|------|------|------|
| `apps/backend/internal/module/scout/repository/memory.go` | edit | 實作 score同分時間排序、legacy synthetic grouping 與 page total。 |
| `apps/backend/internal/module/scout/repository/mongo.go` | edit | 實作等價 Mongo query/aggregation 與 stable tie-breaker。 |
| `apps/backend/internal/module/scout/repository/run_paging_contract_test.go` | add | 同案例驗證 memory/Mongo 契約。 |
### 行為變更
- legacy 同 ownertheme 只形成一個 synthetic runcanonical duplicates 只顯示偏好項。
### API / 契約(若有)
- score desc同分 posted_at > 0 在未知前,再以 created_atID desc。
## Out of scope
- 不猜測 legacy 同 theme 的歷史執行次數。
## Acceptance
- [x] 27 筆跨頁 unique count 等於 total重複查詢順序一致。
- [ ] 指令:
```bash
cd apps/backend && go test ./internal/module/scout/repository -run RunPaging -count=1
```
驗收結果Memory RunPaging 驗證 27 筆跨頁唯一、legacy synthetic run、未知時間置底與穩定 tie-breakerMongo 查詢含 posted/created/id 排序。
## Notes
Mongo 若需兩段排序,行為結果必須與 memory contract 一致。