SearchAdd Legacy Canonical Rules

這份文件定義 search_add legacy audit 的判斷方式。

核心原則:先建立 legacy 本身的完整規則,再做 current 對照。
details/* 的 new / legacy 行號對照只能證明「已看到的點是否對齊」,不能證明 legacy 規則沒有漏。

文件分工

文件用途
legacy_canonical_rules.md定義 audit 方法、phase 順序、驗證面。
legacy_rule_matrix.md逐條列 legacy rule、狀態、source、current owner、測試與缺口。
legacy_alignment.md高層 topic 對齊摘要。
legacy_alignment_map.mdtopic-level mapping。
details/README.mdcurrent / legacy 分段對照與 code review 細節。

Audit Workflow

每次檢查或修改 search_add parity,照這個順序:

  1. 先看 legacy_rule_matrix.md 是否已有 rule。
  2. 如果沒有 rule,先新增 rule,狀態標 needs_legacy_reaudit
  3. 只讀 legacy code,補齊:
    • source 行號
    • precondition
    • 執行順序
    • sync / async 邊界
    • side effects
    • rollback / retry 邊界
  4. 再回 current 找 owner class / method。
  5. 補 test 或 baseline。
  6. 最後才更新 details/*legacy_alignment.md

禁止用 current 實作反推 legacy 完整規則。

Status

Status意義
needs_legacy_reaudit從既有 migration docs 反推,尚未從 legacy code 單向 audit 完成。
legacy_traced已從 legacy code 補齊 source、precondition、順序與 side effect。
current_mapped已完成 legacy trace,且已對到 current owner;測試或 helper 細節可能仍可補強。
verifiedlegacy trace、current mapping、測試或 baseline 都完成。
gap已知 current 行為或測試覆蓋不足。

Phase Timeline

phase number 是文件用的穩定排序,不代表 legacy 原始行號。

Phase名稱責任
000input normalizationraw request、form payload、summary、phone / landing / match type raw 值。
100actor resolutionsession、credential、social login、auto signup、login side effects。
200pre-create guardscategory / form / request conflict / risk 類建單前 guard。
300request fee and type preparationcategory 規則、match type、fee 欄位、request 建立前必要資料。
400quote request create建立 quote_requests 主表與直接依賴欄位。
500request side writersform submission、summary、tracking、abuse、abnormal scan、landing / actor side log。
600auto quote matchingprovider candidate、auto quote filter、narrow fallback、additional narrow 補位。
700bid finalizebid row、pricing、price note、activity、cache / counter。
800special flowspreserve、authorized contact、direct reserve、direct user、booking 類特殊入口。
900async fallbacknewQuoteRequestnewNarrowMatch、manual / related fallback。
1000response contractsuccess / warning / error response、public message mapping。
1100shared downstream methodscontact provider、payment、transaction、subscription log、notification、external event。

High-Risk Order

先 audit 這幾條,因為最容易漏 shared side effect 或順序:

PriorityRule風險
1SA-LEGACY-1101 shared contact provider methodpayment、transaction、notification、external event 都藏在 shared helper。
2SA-LEGACY-0802 authorized contact branchsearch_add special flow 會進 shared contact method。
3SA-LEGACY-0803 direct reserve branch有 match 前 budget、reserve rows、contact payment、fallback。
4SA-LEGACY-0804 direct user branchcaller fee / budget option 會影響 shared contact method。
5SA-LEGACY-0601 auto quote candidate and filter orderprovider pool 與 filter order 會影響後續所有 bid。
6SA-LEGACY-0701 bid finalize and pricing fieldspricing、activity、counter 容易只比到部分欄位。
7SA-LEGACY-0901 async fallbackresponse 成功不代表 worker side effect 已完成。

Verification Surface

每條 rule 不能只看 API response。最低驗證面如下:

類型必查內容
request materializationquote_requests、form submission、summary、match info
sync matchprovider pool、quote_bids、bid flags、pricing、activity、counter
payment / contacttransactionsquote_user_subscription_logs、wallet、credit card / TapPay result、application log
async / notificationqueue-or-log 任一存在、payload / template、worker log
external side effect對應 util / event log;若無法實送,需有 mock 或明確待確認