fix(account-lifecycle): close Phase 21 KEEP-VERIFY — 6 real defects + fake-green tests

KEEP-VERIFY re-audit of account lifecycle (EXTEND): STATUS marked ✅ but
contained hard Gate violations and dead code.

Real defects fixed:
- D-21-A: AuthService.checkAccountStatus did not reject CLOSED → closed
  account could still log in (Gate ❌→✅); added CLOSED branch before
  BANNED/SUSPENDED.
- D-21-B: notifyActiveMatches was a TODO stub → active Matches/conversations
  not closed on withdrawal (Gate ❌→✅); now finds active matches, sets
  UNMATCHED + closes conversation via chatService.closeConversationForMatch.
- D-21-C: cancelPendingActivityRegistrations was a TODO stub → future
  activity registrations not cancelled (Gate ❌→✅); now cancels pending/approved.
- D-21-D: anonymizeServiceHistory existed but was never wired into
  closeAccount → personal identity + counseling text leaked (Gate ❌→✅);
  wired in, anonymizes id_number/real_name with placeholder, plus
  counseling_followups content.
- D-21-E: closeAccount hard-threw on blockers → all cancelXxx unreachable
  (dead code contradiction); changed to informational log + continue cleanup.
- D-21-F: 7× assertTrue(true) fake-green tests → replaced with 11 real DB
  integration tests + 3 login-guard tests (Redis-decoupled via
  ReflectionTestUtils).

Cross-module defenses (RecommendationEngine/MatchEligibility/Capability
reject non-NORMAL) confirmed effective. Remaining (no silent scope creep):
matchmaker in-progress interception still hardcodes 0 (no table), data
retention delete flow is a product decision, privacy-settings endpoint stub.

Full regression: 650 tests / 0 failures / 0 errors / 3 skipped (baseline 648, +2).
This commit is contained in:
WorkBuddy
2026-09-18 10:12:34 +08:00
parent 22c778b111
commit 0580da0c62
7 changed files with 581 additions and 66 deletions
+13 -8
View File
@@ -554,15 +554,20 @@ MinIO: localhost:9003 (凭证由本地环境变量提供)
测试库补齐 `chk_elig_type` / `chk_elig_verify_status` 后立即暴露 `ActivityPhase14Test` 夹具违规。
新增 `LocalEligibilityStatusVocabularyGuardTest`(9)。
### Phase 21 — 账户生命周期增量 ✅ 已完成
| 任务 | 状态 |
### Phase 21 — 账户生命周期增量 ✅(KEEP-VERIFY 复验关闭,2026-09-18)
| 项 | 复验结论 |
|------|------|
| P21-T01 注销时取消服务预约 | ✅ (cancelServiceAppointments) |
| P21-T02 注销时取消咨询记录 | ✅ (cancelCounselingServices) |
| P21-T03 注销时退出专项项目 | ✅ (exitServicePrograms) |
| P21-T04 失效本地资格 | ✅ (invalidateLocalEligibility) |
| P21-T05 服务历史脱敏钩子 | ✅ (anonymizeServiceHistory) |
| checkCanWithdraw 扩展(V1.1业务检查) | ✅ |
| P21-T01~T05 + checkCanWithdraw(原声明「✅」) | 主体实现存在,但复验发现并修复 **6 处真实缺陷** |
| Gate:注销后不能登录 | ❌→✅ `AuthService.checkAccountStatus` 原不拒 `CLOSED` → 已修复 |
| Gate:注销后不能聊天 | ❌→✅ `notifyActiveMatches` 原是 TODO 桩 → 已实现关闭 Match + 通知对方 |
| Gate:关闭未来服务(活动报名) | ❌→✅ `cancelPendingActivityRegistrations` 原是 TODO 桩 → 已实现 |
| Gate:不暴露个人/咨询正文 | ❌→✅ `anonymizeServiceHistory` 已实现却**从未被调用(死代码)** → 已接线;身份证脱敏原是 TODO → 已覆盖占位符;并脱敏 `counseling_followups` 正文 |
| 死代码矛盾 | ❌→✅ `closeAccount` 在 blockers 处硬抛异常,使 `cancelXxx` 永远不可达 → 改为信息性日志 + 继续清理 |
| 测试保真度 | 删除 7×`assertTrue(true)` 假绿 → 替换为 11 用例真实 DB 集成测试 + 3 用例登录守卫 |
| 跨模块防线(既有) | ✅ 推荐引擎 / 匹配资格 / Capability 已拒绝非 `NORMAL`(含 `CLOSED`) |
| 后端全量回归 | **650 tests / 0 failures(起点 648,净 +2)** |
| 报告 | `docs/Phase-21-V11-Recovery-Completion-Report-2026-09-18.md` |
| 遗留(未静默扩权) | ① 红娘服务进行中拦截:数据模型无 `matchmaker_services` 表,仍硬编码 0(TODO);② 数据保留"配置+人工审核"删除流程属产品决策未实现;③ 隐私设置接口仍为 TODO 桩 |
**Phase 20(Analytics数据统计扩展)— 已完成** ✅