thread-master/docs/product/opportunity-inbox/tasks/T842-cost-preview-quota-gat...

1.6 KiB
Raw Blame History

T842 — cost preview quota gate

Status: done2026-08-11 Milestone: M4 Est. change: ~190 lines

Goal

完成後 provider 動作前可取得不扣點 CostPreview並由 owner、版本、期限、餘額與 CreditCeiling gate 阻擋不合格執行。

Depends on

  • T840、T841

Inputs

  • apps/backend/internal/module/usage/**
  • apps/backend/internal/module/radar/usecase/watch_quota.go
  • Spec §5.2§5.4、驗收 #13、#19、#20

Outputs

程式變更(預期路徑)

路徑 動作 說明
apps/backend/internal/module/radar/usecase/cost_preview.go add preview estimate、expiry、ceiling validation
apps/backend/internal/logic/radar/get_cost_preview_logic.go add read-only preview endpoint
apps/backend/internal/module/radar/usecase/cost_preview_test.go add expiry、version、quota、BYOK tests

行為變更

  • ceiling 小於固定成本、preview 過期或 context 變更時 provider 不被呼叫。
  • owner 當日剩餘額度與方案 soft cap 都須通過。

API / 契約(若有)

  • GET preview 不 commit usage回 fixed/min/max、key_mode、remaining、expires_at。

Out of scope

  • 不執行搜尋AI、不修改方案價格或新增 meter。

Acceptance

  • preview 可重現且不扣點platformBYOK 行為正確。
  • gate error 不回成功空資料。
  • 指令:
cd apps/backend && go test ./internal/module/radar/usecase ./internal/logic/radar -run 'CostPreview|Quota' -count=1

Notes

固定搜尋成本沿用既有 meter cost候選未知時回範圍。