feat(ratewise): 刷卡估算模式 Phase 1(ADR-002) - #665
Merged
s123104 merged 1 commit intoJul 7, 2026
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
s123104
force-pushed
the
feat/651-card-rate-phase1
branch
from
July 7, 2026 01:03
b703b14 to
498de92
Compare
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
|
✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。
|
- card 建模為 RateSource 層級:registry 外虛擬 provider card-estimate,公開 API metadata 零污染 - 估算引擎:銀行賣出腿 ×(1+手續費),兩方向共用單一 effective rate;resolveRateTypeForSource 將 card 基準固定即期賣出(persisted cash 不再高估),即期缺失誠實回落現金且揭露同判準 - 手續費 0–3% 可調、步進 0.1%、預設 1.5%,persist 進 ratewise-converter(storage-keys 慣例) - UI:RateSelector 第四 pill+估算卡(估算 badge、計算式揭露、卡片內 stepper、清算日免責連結) - card-rate-flag:URL override > store > 預設 off;flag off SSG 與 UI 零暴露;?cardRate 列入 還原導向深連結豁免(persisted multi 不吞掉 Phase 1 唯一啟用入口) - v2 版面 Phase 1 缺估算揭露收斂回 bank(不做半套,完整揭露併 E8 wave-B);多幣別 Phase 1.5 - 歷史記錄新增 card 分類;i18n 四語系同步 測試:pnpm --filter @app/ratewise exec vitest run 4902 passed(含 spot 正規化、深連結豁免、 v2 收斂與值-標籤耦合);typecheck 通過;SSG 零暴露 grep=0;320–1024 六尺寸截圖驗證 Co-authored-by: Cursor <cursoragent@cursor.com>
s123104
force-pushed
the
feat/651-card-rate-phase1
branch
from
July 7, 2026 01:26
498de92 to
7498151
Compare
Contributor
|
✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。
|
This was referenced Jul 7, 2026
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.
Refs #651(Phase 1,不 close epic)
摘要
依 ADR-002(Accepted)交付 Phase 1 刷卡估算模式:零爬蟲、零新資料源,估算匯率 = 台銀即期賣出 ×(1+手續費),feature flag 控制、flag off 前端零暴露。
審查修正(APPROVE 後三項 Should-fix,PM 裁決隨本 PR 收斂)
S1:card 強制即期基準
resolveRateTypeForSource對 registry 外 provider(getDefaultProvider('card')為 null)隱式放行 persistedrateType='cash',切刷卡後估算以現金賣出計算,高估 1–2%,偏離 ADR「即期賣出 ×(1+手續費)」resolveRateTypeForSource補 card 特例固定回傳'spot'——切換、hydrate sanitize、setRateType 三路徑全部收斂;引擎既有 spot→cash 缺失回落保留(KRW 情境不變)resolveCardBasisRateType(availability)供計算式標籤消費(即期可用標「即期賣出」,缺失誠實標「現金賣出」),與引擎賣出腿 fallback 同一判準,值-標籤耦合有測試鎖定(persisted cash+切 card+即期存在 → 30.97×1.015 非 31.4×1.015)S2:
?cardRate深連結豁免RememberedHomeRoute的hasDeepLink豁免加入cardRate(Phase 1 URL 是唯一啟用入口,persisted multi 不得吞掉);RateWise的isDeepLink(偏好寫入豁免)同步同一契約,臨時進入不覆寫 lastConverterView/?cardRate=on進站 → 停留單幣別且isCardRateEnabled()生效S3:v2 變體 Phase 1 禁用 card(誠實最小解)
isCardRateAvailableInContext加入!isConverterV2Active條件(與換錢所不可用同一 SSOT 收斂 effect),v2 下 effective source 與 persisted 偏好均收斂回 bank;SingleConverterV2完整還原 base 狀態(移除「刷卡估算」chip 標籤分支與四語系 key)Nit
實作
RateSource 建模
RATE_SOURCES新增'card'(RateSource 層級,同 exchange-shop;非 RateType)card-estimate):無 API endpoint,不進RATE_PROVIDERS,公開 API metadata(api/latest.json、OpenData 頁)零污染;getDefaultProviderRef/isProviderSupportedForPair特例支援(僅涉及 TWD 的貨幣對)PublicRateProvider.sourceKind顯式收斂為'bank' | 'exchange-shop',型別層防止 card 滲入公開 schema兩方向估算語意定案(誠實原則)
R = 銀行即期賣出 ×(1+手續費%),互為倒數:單位匯率 = sell × (1 + fee)單位匯率 = (1 / sell) / (1 + fee)手續費
clampCardFeePercent消除浮點誤差ratewise-converter(storage-keys 慣例,不新增 key);hydrate sanitize 修復損毀值UI(韓系扁平)
getCardFeeMultiplier同源)/card-rate-guide/Feature flag(converter-v2-flag 模式)
card-rate-flag.ts:URL?cardRate=on|offoverride > storecardRateEnabled> 預設 offrg 'card-estimate|切換到刷卡估算' dist --glob '*.html'= 0 hits)rateSource='card'自動收斂回 bank(useCurrencyConverter 單一 fallback effect)多幣別(Phase 1.5 申報延後)
resolveEffectiveRateSourceForConversion於 multi 模式一律將 card 回落 bank,且進入多幣別時 store 自動收斂,無錯值風險驗收證據
pnpm --filter @app/ratewise exec vitest run:187 檔 4902 tests 全綠(含 S1 spot 正規化×4、S2 深連結豁免×1、S3 v2 收斂×3、值-標籤耦合、flag、persist、pill)text-primary-on-surface、text-text-muted、bg-primary/10純色 tint),fix(ratewise): 內建主題 AA 對比批次修復(nitro/kawaii+alpha 稀釋收斂) #640 alpha-composite 守門自動咬截圖矩陣(本機
screenshots/,QA 暫存不入 repo)剩餘範圍(不在本 PR)