From 705cbe249abd8e8701487be69f6709dd75bd0ae6 Mon Sep 17 00:00:00 2001 From: Zhang Chengdong Date: Fri, 18 Sep 2026 13:11:37 +0000 Subject: [PATCH] docs: record the deferred promotion-window invariant and test-isolation rules Add the shared promotion-window EXCLUDE-constraint idea to the deferred designs so the flash/group overlap ordering problem has a recorded structural fix. Note in AGENTS.md that suite assertions must be scoped to fixtures the test created, that a list endpoint warrants two consecutive green runs, and that a piped test command hides the real exit code. --- AGENTS.md | 2 ++ docs/TBD-marketing.md | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index a5f7006..2b15b8f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,6 +32,8 @@ pnpm --filter @vmall/<改动过的前端> build ``` - 修 bug:先复现,修完确认复现不再触发;有价值的场景补成集成测试(放 `apps/api/tests/`,复用 `tests/common/mod.rs` 夹具)。 +- 测试隔离:测试库不截断,夹具靠唯一 slug/email。**断言不要假设全局集合为空或恰好 N**——只对自己创建的 id 过滤后断言。新增列表/发现类接口时,`cargo test -p vmall-api` 需**连跑两次**都全绿(单次可能只是库恰好干净)。 +- 管道跑测试时注意退出码:`cargo test | grep` 返回的是 grep 的状态,用 `set -o pipefail` 或显式取 `$?`,否则会漏掉 `FAILED`。 - UI 变更:起 dev server 用浏览器实际点一遍改动路径,视觉确认才算完成。 - 不要跑与改动无关的全仓命令(`pnpm -r build`、lint 全仓等)。 diff --git a/docs/TBD-marketing.md b/docs/TBD-marketing.md index ac83c94..41e6a8f 100644 --- a/docs/TBD-marketing.md +++ b/docs/TBD-marketing.md @@ -116,6 +116,13 @@ transaction rules before implementation. - [ ] **Withdrawals / 提现** — model a payout request with account, amount minor, fee minor, destination snapshot, and `requested → approved | rejected | paid` transitions. Funds must be frozen and released or debited atomically with the transition. +- [ ] **Promotion window exclusivity as a database invariant** — flash sales and group buying + currently keep one SKU out of overlapping activity windows with cross-table queries, and the + flash-sales guard stays inert until the group-buying table exists. A shared + `promotion_windows(sku_id, kind, starts_at, ends_at)` table with + `EXCLUDE USING gist (sku_id WITH =, tstzrange(starts_at, ends_at) WITH &&)` would make an + overlap impossible to insert and remove the creation-order problem. Deferred because it + retrofits the archived flash-sales schema; revisit if a third timed activity type appears. ## Deliberately out of scope — does not block deleting this file