docs: record approved Huizhou notification design and plan
This commit is contained in:
1 parent
b673010b56
commit
38bc291781
2 files changed
+103
No files matched your search
@@ -0,0 +1,59 @@
|
||||
# Huizhou Additional Notification Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox syntax for tracking.
|
||||
|
||||
**Goal:** 为原15类增加可选择惠州模板的附加通知,沿用原收件人且两路结果独立。
|
||||
|
||||
**Architecture:** 先扩展模板模式和规则字段,再实现按明细筛选的惠州批次及独立通知预留。前端使用现有Tabler规则/模板/订单/批次页面,归档与权限服务复用。
|
||||
|
||||
**Tech Stack:** Node.js >=22.13, CommonJS, SQLite加密记录, Tabler 1.6.1, node:test, Playwright。
|
||||
|
||||
**Spec:** ../specs/2026-10-21-huizhou-notification-design.md
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- 仅开发现有modular-refactor工作树;不改原共享源码,不推送合并。
|
||||
- 自动处理、自动发信保持暂停,不发真实邮件、不办理BPM、不操作服务机。
|
||||
- 保留账号、密码、密钥、样本、草稿及历史;不读取account-recovery。
|
||||
- 旧数据默认普通模式/惠州关闭;已冻结快照保持;未知发送结果禁止自动重发。
|
||||
- 无新增依赖;安全投影、源权限、发布证据、全局门控、日历与原冻结期限继续有效。
|
||||
|
||||
### Task 1: 模板模式与规则契约
|
||||
|
||||
**Files:** src/modules/mail/{store,rule-template}.cjs, src/modules/order-rules/{catalog,validation,api}.cjs; tests/mail/huizhou-template.test.cjs, tests/order-rules/huizhou-config.test.cjs。
|
||||
|
||||
**Interfaces:** rule.huizhouEnabled (default false), rule.huizhouTemplateId (default empty); template.notificationMode ('normal'|'huizhou', legacy normal); ruleTemplate(store,categoryId,rule,mode='normal') resolves the mode's selected active template and rejects mismatches. Hui mode requires an explicit selected template when enabled. Existing templateResolver accepts fourth mode argument or call with mode-specific rule projection (record the chosen contract).
|
||||
|
||||
- [ ] Write failing real-store tests for legacy default, persisted settings, invalid booleans/template modes and selecting an inactive/wrong-mode template.
|
||||
- [ ] Run `node --test tests/mail/huizhou-template.test.cjs tests/order-rules/huizhou-config.test.cjs`; verify missing mode isolation causes assertions to fail.
|
||||
- [ ] Add templates.notification_mode column and rebuild active index over channel_id,scope,notification_mode. Use explicit insert columns. Preserve all old rows, payloads, and versions; normal and huizhou scopes no longer archive each other.
|
||||
- [ ] Extend validation and save/publish/resume checks, public summaries and resolver. No server accepts arbitrary To/Cc for Hui mode.
|
||||
- [ ] Run new tests plus existing mail/store and rule-validation slices; commit only task-owned changes.
|
||||
|
||||
### Task 2: 惠州识别、双路冻结与恢复
|
||||
|
||||
**Files:** src/modules/order-rules/{title,matching,batch,template,store,dispatcher,query,migrations,effects-preview}.cjs; src/modules/order-execution/coordinator.cjs; src/app/application.cjs; new src/modules/order-rules/huizhou.cjs and delivery helper if needed; tests/order-rules/huizhou-notification.test.cjs.
|
||||
|
||||
**Interfaces:** batches.notificationMode, order-specific independent Hui status/batch reservation, helper selecting titleOrders for mode; query detail exposes both notifications without raw source data. Task 1 resolver supports mode selection.
|
||||
|
||||
- [ ] Write failing tests with a mixed title containing ordinary O-100 and Hui H-200; assert Hui subject/text excludes O-100 and uses exact frozen normal To/Cc.
|
||||
- [ ] Add tests proving HA prefix alone does not trigger, disabled/legacy produces one batch, empty Hui produces no batch, repeated prepare produces exactly one batch per mode.
|
||||
- [ ] Run new test file and confirm expected red assertions before production edits.
|
||||
- [ ] Add segment-aware recognition, Hui-specific mail rendering, mode-aware batch identity and independent reservations. Reuse archive evidence, never create extra capture/archive tasks.
|
||||
- [ ] Forward mode in application templateResolver=(categoryId,rule,mode='normal')=>ruleTemplate(mail.store,categoryId,rule,mode). Normal sent/unknown must not stop archived runtime checks while Hui remains pending/batched. HA alone or contradictory customer/mode evidence is visible Hui-only uncertainty, never automatic Hui confirmation or silently forgotten potential Hui demand.
|
||||
- [ ] Extend begin/finish/resolve/manual resend and restart recovery for matching mode only; preserve normal legacy state behavior. Block stale rules, incomplete source evidence and unknown outcomes.
|
||||
- [ ] Verify normal sent + Hui failed can resend Hui once without normal send; normal unknown + Hui result remains independent; restart while Hui sending marks only Hui unknown. Verify no old frozen batches gain companions.
|
||||
- [ ] Expose mode and delivery summaries in authorized projections/preview; run dispatcher/query/migration/execution regression slices and commit.
|
||||
|
||||
### Task 3: Tabler页面、回归与本机交付
|
||||
|
||||
**Files:** web/modules/order-rules/{editor,resources,view,preview}.js; web/modules/mail templates views; web/modules/order-notifications/{records,detail}.js; related UI tests; docs/HANDOFF.md and current design/action guides.
|
||||
|
||||
**Interfaces:** Task 1 fields and Task 2 query/preview schema are binding; record concrete output shapes in task report.
|
||||
|
||||
- [ ] Write and run red UI tests exercising toggle -> mode-filtered selector -> save/reload, viewer read-only and leave-with-unsaved protection.
|
||||
- [ ] Add rule controls, default false, inherited recipient explanation, proper mode selection in template confirmation/list and independent delivery results in order/batch details. Use existing lifecycle/dirty/role/escaping helpers.
|
||||
- [ ] Verify mixed preview shows only Hui detail in supplemental email, unchanged normal contents, no Hui To/Cc inputs, and original navigation/pagination intact.
|
||||
- [ ] Run scoped UI/backend tests and fresh full npm test; node --check changed JS/CJS; git diff --check; inspect staged files for private artifacts.
|
||||
- [ ] Final review against spec and independent delivery recovery, resolve findings, commit code/docs.
|
||||
- [ ] Stop original local test instance, create/verify backup, npm start; verify both ports/login/static assets, preserved accounts/keys/sample/draft/history summaries, and both automatic switches false. Do not enable business operations. Record evidence and final commit.
|
||||
@@ -0,0 +1,44 @@
|
||||
# 惠州附加通知设计
|
||||
|
||||
用户已在对话确认实施。本设计扩展原15类规则,不新增类别或导航。
|
||||
|
||||
## 已确认行为
|
||||
|
||||
- 每类增加 `huizhouEnabled` 开关及 `huizhouTemplateId` 模板选择;旧规则默认关闭。
|
||||
- 原类别邮件照常。开启且包含惠州订单明细时,额外发送一封惠州邮件,主送/抄送直接取同一冻结规则快照,不另存名单。
|
||||
- 每天两个时点,按原类别、接收时段、通知模式分别汇总;空惠州集合不发。
|
||||
- 惠州正文和主题的订单号只来自惠州明细。一个BPM事件可能包含普通/惠州多个明细,仍只生成和归档一次PDF。
|
||||
- 模板可选择普通/惠州模式,规则只能为对应通知选择相应模式的已确认模板。
|
||||
- 惠州模板正文可维护截图所示的业务访问链接;不增加SPMS上传或节点操作。
|
||||
- 惠州附件继承原类别的PDF附件要求;此次不增加独立附件策略。
|
||||
- 两路通知结果、失败、unknown核验、受控补发、重启恢复独立;任何一路重试不能重发另一路。
|
||||
- 规则草稿、检查、发布和启停契约保留。已冻结邮件不随模板/规则变更而重写。旧订单/批次不补生成惠州邮件。
|
||||
|
||||
## 识别
|
||||
|
||||
标准标题提取保留每个订单段落的业务模式和客户信息。明确的惠州业务模式、已知惠州客户全称可作为正向依据,HA前缀本身不足以确认。混合标题按段落筛选,不以整段出现“惠州”判定所有明细。缺失或冲突证据需呈现,不能静默漏掉惠州需求。
|
||||
|
||||
## 数据与执行边界
|
||||
|
||||
规则字段为 `huizhouEnabled:boolean`、`huizhouTemplateId:string`,省略等同关闭/空选择。
|
||||
模板公开字段 `notificationMode` 为 `normal` 或 `huizhou`,旧模板为normal;同邮箱/范围的两个模式分别确认,不互相归档。
|
||||
批次 `notificationMode` 同上,旧批次为normal。冻结唯一性包含原类别、cutoff、模式。
|
||||
普通通知继续兼容原订单status/batchId;附加通知独立持久化结果,查询安全投影展示两路通知。所有恢复和人工补发读取对应模式的预留状态。
|
||||
归档证据共用,文件校验、来源权限、冻结屏障、30分钟发送期限、unknown禁止自动重发均继续适用。
|
||||
模板缺失/停用/模式错误须阻塞受影响的通知并可见,原通知不被误报为成功或被惠州状态覆盖。
|
||||
|
||||
## 界面
|
||||
|
||||
分类规则通知内容区增加开关和条件展示的惠州模板选择,无独立惠州To/Cc表单。
|
||||
模板确认区增加模式选择,列表显示模式及各模式实际使用情况。
|
||||
规则真实订单预览分别显示原邮件与惠州邮件、惠州入选明细和无匹配说明。
|
||||
订单详情分别显示两路结果;批次列表/详情标明模式及原类别。
|
||||
管理员可编辑,其他角色只读;禁重、离页保护和已保存版本恢复沿用现有逻辑。
|
||||
|
||||
## 验收及约束
|
||||
|
||||
只在 C:/Users/ABS/.codex/worktrees/modular-refactor/Order Notification Automation 的 codex/modular-refactor 开发。
|
||||
自动处理、自动发信保持暂停,不发送真实邮件、不办理BPM、不操作服务机、不推送合并。
|
||||
使用隔离状态及本地假SMTP或注入传输验证,不读取account-recovery。
|
||||
验证关闭/旧数据、混合明细/仅惠州/HA误判、相同To/Cc、分类/时段分组、重复扫描/prepare、两路各种发送结果、独立补发/核验、重启、权限、模板模式隔离、已冻结不变及界面保存失败。
|
||||
完成专项和全量测试后提交,停服备份并更新原本机测试实例;保持原数据及两个自动开关。
|
||||
Reference in new issue
Block a user