Parcourir la source

Merge origin/cfclub into feature (pre-push 1)

# Conflicts:
#	cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java
Xiaogang Liao il y a 3 heures
Parent
commit
a6488d0439
61 fichiers modifiés avec 5081 ajouts et 80 suppressions
  1. 178 49
      cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java
  2. 89 0
      cfc-backend/src/main/java/com/etotem/cfc/controller/EnergyController.java
  3. 20 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/HealthReportController.java
  4. 45 0
      cfc-backend/src/main/java/com/etotem/cfc/controller/NotificationSettingController.java
  5. 46 0
      cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminUnifiedKnowledgeController.java
  6. 50 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/ai/AIChatController.java
  7. 45 0
      cfc-backend/src/main/java/com/etotem/cfc/controller/butler/ButlerController.java
  8. 3 1
      cfc-backend/src/main/java/com/etotem/cfc/controller/family/PointsController.java
  9. 111 0
      cfc-backend/src/main/java/com/etotem/cfc/controller/growth/GrowthPlanController.java
  10. 41 0
      cfc-backend/src/main/java/com/etotem/cfc/dto/ButlerCollaborateNotifyDTO.java
  11. 26 0
      cfc-backend/src/main/java/com/etotem/cfc/dto/NotificationSettingDTO.java
  12. 48 0
      cfc-backend/src/main/java/com/etotem/cfc/entity/ButlerAiCollaborationAudit.java
  13. 81 0
      cfc-backend/src/main/java/com/etotem/cfc/entity/ButlerAiFeedback.java
  14. 5 0
      cfc-backend/src/main/java/com/etotem/cfc/entity/EnergyDimensionConfig.java
  15. 14 0
      cfc-backend/src/main/java/com/etotem/cfc/entity/GrowthPlan.java
  16. 46 0
      cfc-backend/src/main/java/com/etotem/cfc/entity/GrowthPlanVersion.java
  17. 41 0
      cfc-backend/src/main/java/com/etotem/cfc/entity/NotificationSetting.java
  18. 7 0
      cfc-backend/src/main/java/com/etotem/cfc/entity/PointsLog.java
  19. 3 0
      cfc-backend/src/main/java/com/etotem/cfc/entity/ReportFeedback.java
  20. 12 0
      cfc-backend/src/main/java/com/etotem/cfc/mapper/ButlerAiCollaborationAuditMapper.java
  21. 12 0
      cfc-backend/src/main/java/com/etotem/cfc/mapper/ButlerAiFeedbackMapper.java
  22. 15 0
      cfc-backend/src/main/java/com/etotem/cfc/mapper/FoodProcessingEffectMapper.java
  23. 8 0
      cfc-backend/src/main/java/com/etotem/cfc/mapper/GrowthPlanVersionMapper.java
  24. 7 0
      cfc-backend/src/main/java/com/etotem/cfc/mapper/NotificationSettingMapper.java
  25. 277 0
      cfc-backend/src/main/java/com/etotem/cfc/service/AiGateway.java
  26. 479 0
      cfc-backend/src/main/java/com/etotem/cfc/service/ButlerAiCollaborationService.java
  27. 243 4
      cfc-backend/src/main/java/com/etotem/cfc/service/DietRecommendationService.java
  28. 24 0
      cfc-backend/src/main/java/com/etotem/cfc/service/EnergyService.java
  29. 178 0
      cfc-backend/src/main/java/com/etotem/cfc/service/FoodDiseaseWeightGroup.java
  30. 304 0
      cfc-backend/src/main/java/com/etotem/cfc/service/FoodProcessingEffectService.java
  31. 84 0
      cfc-backend/src/main/java/com/etotem/cfc/service/FoodRecommendService.java
  32. 18 0
      cfc-backend/src/main/java/com/etotem/cfc/service/FoodRecommendWeightEngine.java
  33. 383 0
      cfc-backend/src/main/java/com/etotem/cfc/service/GrowthPlanService.java
  34. 11 0
      cfc-backend/src/main/java/com/etotem/cfc/service/NotificationDispatchService.java
  35. 130 0
      cfc-backend/src/main/java/com/etotem/cfc/service/NotificationSettingService.java
  36. 145 4
      cfc-backend/src/main/java/com/etotem/cfc/service/PointsService.java
  37. 139 9
      cfc-backend/src/main/java/com/etotem/cfc/service/ReportFeedbackService.java
  38. 3 0
      cfc-backend/src/main/java/com/etotem/cfc/service/api/PointsServiceInterface.java
  39. 76 2
      cfc-backend/src/main/resources/schema.sql
  40. 2 2
      cfc-backend/src/test/java/com/etotem/cfc/unit/TaskReminderDailyConfigContractTest.java
  41. 30 0
      cfc-backend/src/test/java/com/etotem/cfc/unit/TaskReminderDailyScheduledTaskContractTest.java
  42. 194 0
      cfc-frontend/pages/health/ai-report-detail.vue
  43. 1 1
      cfc-web/.last_build_commit
  44. 2 2
      cfc-web/package-lock.json
  45. 1 1
      cfc-web/package.json
  46. 79 0
      cfc-web/public/CHANGELOG-v1.0.md
  47. 80 1
      cfc-web/public/CHANGELOG.md
  48. 3 1
      docs/superpowers/PROJECT-OVERVIEW.md
  49. 12 1
      docs/superpowers/api/API_REFERENCE.md
  50. 182 0
      docs/tdd/orchestration/discovery-2026-11-30-1008.md
  51. 102 0
      docs/tdd/orchestration/report-dev-2026-11-30-0800.md
  52. 102 0
      docs/tdd/orchestration/report-dev-2026-11-30-0825.md
  53. 104 0
      docs/tdd/orchestration/report-dev-2026-11-30-0830.md
  54. 103 0
      docs/tdd/orchestration/report-dev-2026-11-30-0917.md
  55. 132 0
      docs/tdd/orchestration/report-dev-2026-11-30-0952.md
  56. 141 0
      docs/tdd/orchestration/report-dev-2026-11-30-1041.md
  57. 107 0
      docs/tdd/orchestration/report-test-2026-11-30-1016.md
  58. 58 0
      docs/tdd/orchestration/report-test-2026-11-30-1051.md
  59. 73 0
      docs/tdd/orchestration/report-test-2026-11-30-1100.md
  60. 109 0
      docs/tdd/orchestration/report-test-2026-11-30-R683-0749.md
  61. 17 0
      docs/tdd/test/blockers.md

+ 178 - 49
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -3382,9 +3382,6 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
         // 迁移502: F03存量重算日志/批次表
         migrateF03RecalcTables();
 
-        // 迁移503: F03档位门槛改为元口径0/1980/3960/.../63360(第一档0~1980起步)
-        migrateF03TierThresholds1980();
-
         // 迁移406: activity_poster_templates 增加 layout_config 列(海报模板元素位置/样式可配置,需求:活动详情海报预览重设计)
         addActivityPosterTemplateLayoutConfigColumn();
 
@@ -3669,6 +3666,9 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
         // 迁移496: growth_plans 增列 draft_expires_at / draft_version(SC-P-81 方案草稿保存与恢复,能力键 plan.draft.save)
         addGrowthPlanDraftColumns();
 
+        // 迁移509: 方案编辑/版本历史列与版本快照表(SC-P-42/48,能力键 plan.edit.adjust)
+        addGrowthPlanEditVersionSupport();
+
         // 迁移497: 创建家庭关系类型字典表(SC-A-04 关系类型 CRUD,能力键 admin.familyRelation.manage)
         createFamilyRelationTypesTable();
 
@@ -3715,6 +3715,21 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
         //          food_disease_weight_group(能力键 food.ops.ruleManagement,CR-06 §4.6)
         // 权重表由迁移501 落地;本迁移幂等:CREATE TABLE IF NOT EXISTS + try/catch
         createFoodRuleManagementTables();
+
+        // 迁移509: 真人管家 AI 协同知识反哺 + 闭环审计表(能力键 butler.ai.collaborate,SC-H-06)
+        // 幂等:CREATE TABLE IF NOT EXISTS + try/catch;DDL 与 schema.sql 同步
+        migrateButlerAiCollaboration();
+
+        // 迁移510: growth_plans 添加 overview / sections 列(SC-P-40/41,能力键 plan.ai.generate)
+        // AI 方案 overview + nutrition/diet/exercise 三板块结构化落库,替代混在 plan_content 整段文本中
+        ensureColumn("growth_plans", "overview",
+                "TEXT DEFAULT NULL COMMENT 'AI方案总览(plan.ai.generate)'");
+        ensureColumn("growth_plans", "sections",
+                "TEXT DEFAULT NULL COMMENT 'AI方案三板块JSON(nutrition/diet/exercise,支持板块级重生成)'");
+
+        // 迁移511: 创建 notification_settings 用户通知设置表(能力键 notification.setting.config,SC-P-65/79)
+        // 关键安全通知列 safety_enabled 默认 1;幂等:CREATE TABLE IF NOT EXISTS + try/catch,DDL 与 schema.sql 同步
+        createNotificationSettingsTable();
     }
 
     /**
@@ -4321,6 +4336,10 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
                 log.warn("迁移492: energy_log 幂等唯一键添加失败(存量数据含重复,需人工清理): {}", msg);
             }
         }
+
+        // 迁移510: report_feedback 补附件载体列(feedback.consult.submit,S-cfc-491 / SC-P-83)
+        ensureColumn("report_feedback", "attachment_url",
+                "VARCHAR(512) DEFAULT NULL COMMENT '反馈附件地址(附件≤10MB,SC-P-83)'");
     }
 
     /**
@@ -13836,6 +13855,24 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
         try {
             ensureColumn("task_reminder_config", "daily_enabled",
                     "TINYINT DEFAULT 0 COMMENT '日提醒开关 1=启用 0=停用(独立于 enabled,与 before/after 两档互不影响可叠加)'");
+            // 2026-11-29:日提醒默认开启——把表默认值改为 1(不改已有行值)。
+            // 即使此 DDL 失败(幂等/权限),代码层 isDailyEnabledEvening/getConfig 已按默认开兜底。
+            try {
+                jdbcTemplate.execute("ALTER TABLE task_reminder_config MODIFY COLUMN daily_enabled "
+                        + "TINYINT DEFAULT 1 COMMENT '日提醒开关 1=启用 0=停用(2026-11-29 默认开启)'");
+                log.info("迁移487+: task_reminder_config.daily_enabled 默认值已改为 1");
+                // 2026-11-29 一次性回填:把默认开启功能上线前(2026-11-29)的历史默认0规范化为NULL,
+                // 使存量用户晚提醒默认开启(isDailyEnabledEvening视NULL为开)、早提醒仍不发(isDailyEnabled视NULL为关)。
+                // 带 updated_at 条件:用户此后显式关闭(updated_at>=2026-11-29)的0不被覆盖;幂等(已是NULL不再命中)。
+                int backfilled = jdbcTemplate.update(
+                        "UPDATE task_reminder_config SET daily_enabled = NULL "
+                        + "WHERE daily_enabled = 0 AND updated_at < '2026-11-29 00:00:00'");
+                if (backfilled > 0) {
+                    log.info("迁移487+: 回填历史默认daily_enabled 0→NULL {} 行", backfilled);
+                }
+            } catch (Exception dex) {
+                log.warn("迁移487+: daily_enabled 默认值改 1 失败(忽略,代码层默认开兜底): {}", dex.getMessage());
+            }
             ensureColumn("task_reminder_config", "morning_time",
                     "VARCHAR(5) DEFAULT '07:30' COMMENT '早提醒时间 HH:mm(默认 07:30)'");
             ensureColumn("task_reminder_config", "evening_time",
@@ -15136,34 +15173,6 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
      * 迁移502: F03 存量重算日志/批次表(preview/execute/rollback 全流程审计留痕)。
      * uk_order_rule(order_id, rule_code) 保证幂等(全局,不用 batch_id)。
      */
-    /**
-     * 迁移503: F03 档位门槛改为元口径(第一档0~1980起步,每档翻倍)。
-     * 独立迁移(不受 f03_tier_redesign_done 标记影响);两段式 UPDATE 规避 uk_min 唯一键冲突。
-     * 幂等:目标门槛已是新值则两段式仍安全(先临时值再写回);运营改过的费率不变(只改 min 门槛)。
-     */
-    private void migrateF03TierThresholds1980() {
-        int[] mins = {0, 1980, 3960, 7920, 15840, 31680, 63360};
-        try {
-            // 临时值(唯一,不撞最终值)
-            jdbcTemplate.execute("UPDATE cf_direct_sales_tier SET min_annual_ppoints = 9000000 + id WHERE id BETWEEN 1 AND 7");
-            jdbcTemplate.execute("UPDATE cf_indirect_sales_tier SET min_self_ppoints = 9000000 + id WHERE id BETWEEN 1 AND 7");
-            // 写最终门槛(只改 min,费率/档名不动,保留运营调整)
-            StringBuilder d = new StringBuilder("UPDATE cf_direct_sales_tier SET min_annual_ppoints = CASE id ");
-            StringBuilder i = new StringBuilder("UPDATE cf_indirect_sales_tier SET min_self_ppoints = CASE id ");
-            for (int k = 0; k < mins.length; k++) {
-                d.append("WHEN ").append(k + 1).append(" THEN ").append(mins[k]).append(" ");
-                i.append("WHEN ").append(k + 1).append(" THEN ").append(mins[k]).append(" ");
-            }
-            d.append("END WHERE id BETWEEN 1 AND 7 AND min_annual_ppoints BETWEEN 9000001 AND 9000007");
-            i.append("END WHERE id BETWEEN 1 AND 7 AND min_self_ppoints BETWEEN 9000001 AND 9000007");
-            jdbcTemplate.execute(d.toString());
-            jdbcTemplate.execute(i.toString());
-            log.info("迁移503: F03档位门槛改为0/1980/3960/7920/15840/31680/63360(元)完成");
-        } catch (Exception e) {
-            log.warn("迁移503: F03档位门槛调整失败(幂等容忍): {}", e.getMessage());
-        }
-    }
-
     private void migrateF03RecalcTables() {
         try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS cf_commission_recalc_log ("
@@ -16187,30 +16196,30 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
      * 直接销售奖档位种子(F03a;初始运营值,管理端可调)。
      * 列序:tier_name, min_annual_ppoints, rate_percent, sort_order, remark
      */
-    // F03 规则重定义(2026-11-30):7档,门槛按元2倍递增(0/1980/3960/.../63360),费率每档+10%封顶70%
+    // F03 规则重定义(2026-11-29):7档,门槛2倍递增(分),费率每档+10%封顶70%
     private static final String[][] CF_DIRECT_SALES_TIER_SEEDS = {
-            {"新秀", "0", "10", "1", "启动档,业绩0~1980元,直接销售奖10%"},
-            {"小成", "1980", "20", "2", "业绩≥1980元,直接销售奖20%"},
-            {"中富", "3960", "30", "3", "业绩≥3960元,直接销售奖30%"},
-            {"大成", "7920", "40", "4", "业绩≥7920元,直接销售奖40%"},
-            {"进宝", "15840", "50", "5", "业绩≥15840元,直接销售奖50%"},
-            {"富豪", "31680", "60", "6", "业绩≥31680元,直接销售奖60%"},
-            {"至富", "63360", "70", "7", "业绩≥63360元,直接销售奖70%(封顶)"}
+            {"新秀", "0", "10", "1", "启动档,业绩≥0,直接销售奖10%"},
+            {"小成", "1000", "20", "2", "业绩≥1000(分),直接销售奖20%"},
+            {"中富", "2000", "30", "3", "业绩≥2000(分),直接销售奖30%"},
+            {"大成", "4000", "40", "4", "业绩≥4000(分),直接销售奖40%"},
+            {"进宝", "8000", "50", "5", "业绩≥8000(分),直接销售奖50%"},
+            {"富豪", "16000", "60", "6", "业绩≥16000(分),直接销售奖60%"},
+            {"至富", "32000", "70", "7", "业绩≥32000(分),直接销售奖70%(封顶)"}
     };
 
     /**
      * 间接销售奖档位种子(F03b;初始运营值,管理端可调)。
      * 列序:tier_name, min_self_ppoints, rate_percent, sort_order, remark
      */
-    // F03 规则重定义(2026-11-30):7档,门槛按元2倍递增(0/1980/3960/.../63360),间接费率封顶30%
+    // F03 规则重定义(2026-11-29):7档,门槛2倍递增(分),间接费率每档+5%封顶30%
     private static final String[][] CF_INDIRECT_SALES_TIER_SEEDS = {
-            {"新秀", "0", "5", "1", "启动档,自身业绩0~1980元,间接销售奖5%"},
-            {"小成", "1980", "10", "2", "自身业绩≥1980元,间接销售奖10%"},
-            {"中富", "3960", "15", "3", "自身业绩≥3960元,间接销售奖15%"},
-            {"大成", "7920", "20", "4", "自身业绩≥7920元,间接销售奖20%"},
-            {"进宝", "15840", "25", "5", "自身业绩≥15840元,间接销售奖25%"},
-            {"富豪", "31680", "30", "6", "自身业绩≥31680元,间接销售奖30%"},
-            {"至富", "63360", "30", "7", "自身业绩≥63360元,间接销售奖30%(封顶)"}
+            {"新秀", "0", "5", "1", "启动档,自身业绩≥0,间接销售奖5%"},
+            {"小成", "1000", "10", "2", "自身业绩≥1000(分),间接销售奖10%"},
+            {"中富", "2000", "15", "3", "自身业绩≥2000(分),间接销售奖15%"},
+            {"大成", "4000", "20", "4", "自身业绩≥4000(分),间接销售奖20%"},
+            {"进宝", "8000", "25", "5", "自身业绩≥8000(分),间接销售奖25%"},
+            {"富豪", "16000", "30", "6", "自身业绩≥16000(分),间接销售奖30%"},
+            {"至富", "32000", "30", "7", "自身业绩≥32000(分),间接销售奖30%(封顶)"}
     };
 
     // 迁移418: 两级销售奖档位种子(幂等:min 下限唯一键已存在则跳过,不覆盖运营改过的档位)
@@ -16225,10 +16234,10 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
             // 否则每次重启会把新7档删回旧5档(旧清理集合 10000/50000/... 已不匹配)。
             int cleaned = jdbcTemplate.update(
                     "DELETE FROM cf_direct_sales_tier "
-                            + "WHERE min_annual_ppoints NOT IN (0, 1980, 3960, 7920, 15840, 31680, 63360)");
+                            + "WHERE min_annual_ppoints NOT IN (0, 1000, 2000, 4000, 8000, 16000, 32000)");
             int cleaned2 = jdbcTemplate.update(
                     "DELETE FROM cf_indirect_sales_tier "
-                            + "WHERE min_self_ppoints NOT IN (0, 1980, 3960, 7920, 15840, 31680, 63360)");
+                            + "WHERE min_self_ppoints NOT IN (0, 1000, 2000, 4000, 8000, 16000, 32000)");
             if (cleaned > 0 || cleaned2 > 0) {
                 log.info("迁移418: 清理旧档位残留 {} 行(直接)/{} 行(间接)", cleaned, cleaned2);
             }
@@ -17313,6 +17322,45 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
         log.info("迁移496: growth_plans.draft_expires_at / draft_version 列已就绪(plan.draft.save / SC-P-81)");
     }
 
+    /**
+     * 迁移509: 方案编辑调整/版本历史(SC-P-42/48,能力键 {@code plan.edit.adjust})。
+     *
+     * <p>growth_plans 增 version(版本号递增)/ edited(已改标记),status 由 ENUM 扩宽为 VARCHAR(32)
+     * 以持久化 edited 状态;新建 growth_plan_version 不可篡改版本快照表(只 INSERT/SELECT)。
+     * ensureColumn + CREATE TABLE IF NOT EXISTS + try/catch 保证幂等。</p>
+     */
+    private void addGrowthPlanEditVersionSupport() {
+        try {
+            ensureColumn("growth_plans", "version",
+                    "INT DEFAULT 0 COMMENT '方案版本号(SC-P-48 版本历史/对比,plan.edit.adjust)'");
+            ensureColumn("growth_plans", "edited",
+                    "TINYINT(1) DEFAULT 0 COMMENT '已改标记(SC-P-42 编辑后标记已改,plan.edit.adjust)'");
+            jdbcTemplate.execute("ALTER TABLE growth_plans MODIFY COLUMN status VARCHAR(32) DEFAULT 'draft' "
+                    + "COMMENT '状态机(generated/reviewed/edited/active 等,plan.edit.adjust)'");
+            log.info("迁移509: growth_plans.version / edited 与 status 扩宽已就绪(plan.edit.adjust)");
+        } catch (Exception e) {
+            log.warn("迁移509: growth_plans 列调整跳过: {}", e.getMessage());
+        }
+        try {
+            jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS growth_plan_version (" +
+                    "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
+                    "plan_id BIGINT NOT NULL COMMENT '所属方案ID', " +
+                    "version INT NOT NULL COMMENT '版本号(与 growth_plans.version 对齐)', " +
+                    "content TEXT COMMENT '版本内容快照', " +
+                    "tasks_json TEXT COMMENT '任务项快照(JSON)', " +
+                    "status VARCHAR(32) COMMENT '状态快照', " +
+                    "edited TINYINT(1) DEFAULT 0 COMMENT '已改标记', " +
+                    "operator_id BIGINT COMMENT '操作人 userId', " +
+                    "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
+                    "INDEX idx_plan_version (plan_id, version), " +
+                    "INDEX idx_operator (operator_id)" +
+                    ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='成长方案历史版本(不可篡改)'");
+            log.info("迁移509: growth_plan_version 表已就绪(plan.edit.adjust / SC-P-48)");
+        } catch (Exception e) {
+            log.warn("迁移509: growth_plan_version 表创建跳过: {}", e.getMessage());
+        }
+    }
+
     /**
      * 迁移503: 谷禾新版物种功能库 {@code health_species_library} + 异常菌派生视图 {@code health_abnormal_species}
      * (能力键 {@code health.report.abnormalSpecies},P0-6 异常菌清单接口 ▲ 直出)。
@@ -17502,4 +17550,85 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
             }
         }
     }
+
+    /**
+     * 迁移509: 真人管家 AI 协同知识反哺与闭环审计表(能力键 {@code butler.ai.collaborate},SC-H-06)。
+     *
+     * <p>butler_ai_feedbacks 承载脱敏后的待审反哺(dedupe_key 幂等、family_id 隔离、status 审核流转);
+     * butler_ai_collaboration_audit_log 记录闭环/反哺/审核/通知动作的 actor/role/action/family/time。</p>
+     *
+     * <p>幂等:CREATE TABLE IF NOT EXISTS + try/catch,重复执行不报错;DDL 与 schema.sql 同步。</p>
+     */
+    private void migrateButlerAiCollaboration() {
+        try {
+            jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS butler_ai_feedbacks (" +
+                    "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
+                    "workorder_id BIGINT NOT NULL COMMENT '关联 AI 升级工单闭环', " +
+                    "family_id BIGINT NOT NULL COMMENT '反哺来源家庭(禁止跨家庭泄露)', " +
+                    "butler_user_id BIGINT COMMENT '提交反哺的管家用户 ID', " +
+                    "content TEXT COMMENT '提炼的可复用结论(已脱敏)', " +
+                    "conclusion TEXT COMMENT '闭环结论(反馈家长使用)', " +
+                    "disposition VARCHAR(128) COMMENT '人工处置方式', " +
+                    "duration_minutes INT COMMENT '处置时长(分钟)', " +
+                    "status VARCHAR(24) NOT NULL DEFAULT 'PENDING_REVIEW' COMMENT 'PENDING_REVIEW/APPROVED/REJECTED', " +
+                    "dedupe_key VARCHAR(128) COMMENT '幂等去重键', " +
+                    "reviewer_id BIGINT COMMENT '审核人(运营角色)', " +
+                    "review_remark TEXT COMMENT '审核意见', " +
+                    "reviewed_at DATETIME COMMENT '审核时间', " +
+                    "previous_workorder_id BIGINT COMMENT '重开关联的历史工单 ID', " +
+                    "notified INT DEFAULT 0 COMMENT '是否已反馈原家长', " +
+                    "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
+                    "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
+                    "UNIQUE KEY uk_dedupe (workorder_id, dedupe_key), " +
+                    "INDEX idx_workorder_status (workorder_id, status), " +
+                    "INDEX idx_family_status (family_id, status)" +
+                    ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='真人管家AI协同知识反哺(SC-H-06)'");
+            log.info("迁移509: 已创建/确认 butler_ai_feedbacks 表");
+        } catch (Exception e) {
+            log.warn("迁移509: butler_ai_feedbacks 建表失败(幂等容忍): {}", e.getMessage());
+        }
+        try {
+            jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS butler_ai_collaboration_audit_log (" +
+                    "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
+                    "workorder_id BIGINT NOT NULL COMMENT '关联工单 ID', " +
+                    "feedback_id BIGINT COMMENT '关联反哺条目 ID', " +
+                    "action VARCHAR(48) NOT NULL COMMENT '闭环/反哺/审核/通知动作', " +
+                    "actor_id BIGINT COMMENT '操作人用户 ID', " +
+                    "actor_role VARCHAR(32) COMMENT '操作人角色', " +
+                    "family_id BIGINT COMMENT '家庭范围(审计读取不得跨家庭)', " +
+                    "detail TEXT COMMENT '动作详情(脱敏)', " +
+                    "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
+                    "INDEX idx_workorder (workorder_id), " +
+                    "INDEX idx_family_workorder (family_id, workorder_id)" +
+                    ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='真人管家AI协同闭环审计留痕(SC-H-06)'");
+            log.info("迁移509: 已创建/确认 butler_ai_collaboration_audit_log 表");
+        } catch (Exception e) {
+            log.warn("迁移509: butler_ai_collaboration_audit_log 建表失败(幂等容忍): {}", e.getMessage());
+        }
+    }
+
+    /**
+     * 迁移511: 用户通知设置表(能力键 {@code notification.setting.config},SC-P-65/79)。
+     *
+     * <p>一人一条配置,userId 唯一;enabled/reminderEnabled 默认开,safety_enabled 默认 1 且不可关闭。
+     * 幂等:CREATE TABLE IF NOT EXISTS + try/catch;DDL 与 schema.sql 同步。</p>
+     */
+    private void createNotificationSettingsTable() {
+        try {
+            jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS notification_settings (" +
+                    "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
+                    "user_id BIGINT NOT NULL COMMENT '所属登录用户(users.id)', " +
+                    "enabled TINYINT DEFAULT 1 COMMENT '通知总开关:1开 0关(安全通知不受影响)', " +
+                    "reminder_enabled TINYINT DEFAULT 1 COMMENT '提醒开关:1开 0关', " +
+                    "reminder_time VARCHAR(5) DEFAULT '08:00' COMMENT '提醒时间 HH:mm(00:00~23:59)', " +
+                    "safety_enabled TINYINT DEFAULT 1 COMMENT '关键安全通知:恒开,不可关闭', " +
+                    "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
+                    "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
+                    "UNIQUE KEY uk_user (user_id)" +
+                    ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户通知设置(notification.setting.config)'");
+            log.info("迁移511: 已创建/确认 notification_settings 表");
+        } catch (Exception e) {
+            log.warn("迁移511: notification_settings 建表失败(幂等容忍): {}", e.getMessage());
+        }
+    }
 }

+ 89 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/EnergyController.java

@@ -5,6 +5,7 @@ import com.etotem.cfc.common.Result;
 import com.etotem.cfc.dto.EnergySandboxDTO;
 import com.etotem.cfc.dto.MemberEnergyDTO;
 import com.etotem.cfc.dto.UnlockGateDTO;
+import com.etotem.cfc.entity.EnergyDimensionConfig;
 import com.etotem.cfc.entity.EnergyLog;
 import com.etotem.cfc.entity.UnlockGate;
 import com.etotem.cfc.entity.User;
@@ -282,6 +283,94 @@ public class EnergyController {
         return Result.success("配置成功");
     }
 
+    /**
+     * 家长端只读查看五维(身/心/智/行/富)定义与权重(SC-P-19 / energy.dimension.view)。
+     *
+     * <p>只读:仅读配置,不触发任何 Mapper 写操作(写配置走 admin.dimension.config / S-cfc-199)。
+     * 配置未同步或部分同步时按默认口径兜底并给出说明;已同步配置的权重合计 ≠100% 时返回 400。
+     * 显式指定非本家庭成员 memberId 时按 SC-X-19 隔离口径 403。</p>
+     */
+    @Operation(summary = "只读查看五维能量定义与权重(配置未同步时兜底)")
+    @PostMapping("/config")
+    public Result<Map<String, Object>> getDimensionConfigView(
+            @RequestBody(required = false) Map<String, Object> params,
+            @RequestAttribute(value = "familyId", required = false) Long familyId,
+            @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
+
+        if (familyId == null) {
+            return Result.noFamily("请先创建或加入家庭");
+        }
+        Long memberId = params != null
+                ? ParamUtils.getLong(params.get("memberId"), currentMemberId) : currentMemberId;
+        // SC-X-19 横向越权:显式指定非本家庭成员一律 403;本人/未指定放行
+        if (memberId != null && currentMemberId != null && !memberId.equals(currentMemberId)
+                && !energyService.isMemberInFamily(memberId, familyId)) {
+            return Result.forbidden("无权访问该成员的能量配置");
+        }
+
+        // 五维默认口径(设计 §1.1:身/心/智/行/富;等权兜底合计 100%)
+        String[] codes = {"body", "mind", "wisdom", "action", "wealth"};
+        String[] names = {"身", "心", "智", "行", "富"};
+        String[] definitions = {
+                "身体维度:体质、精力、运动与生活习惯等身心健康基础",
+                "心理维度:情绪、性格、抗压与自我认知等心理状态",
+                "智力维度:学习、思维、认知与知识吸收等能力",
+                "行动维度:执行力、目标管理、坚持与自律等行为习惯",
+                "财富维度:财商、资源管理与价值观等财富素养"
+        };
+
+        List<EnergyDimensionConfig> configs = energyService.getDimensionConfigs();
+        Map<String, EnergyDimensionConfig> configByCode = new LinkedHashMap<String, EnergyDimensionConfig>();
+        double weightSum = 0.0;
+        boolean hasConfig = configs != null && !configs.isEmpty();
+        if (hasConfig) {
+            for (EnergyDimensionConfig config : configs) {
+                if (config == null || config.getDimension() == null) {
+                    continue;
+                }
+                String code = config.getDimension().trim().toLowerCase(Locale.ROOT);
+                configByCode.put(code, config);
+                weightSum += dimensionWeightPercent(config.getWeight());
+            }
+            // TC-P-19-E:已同步配置权重合计必须 =100%,否则 400 拒绝,不静默展示非法权重
+            if (configByCode.isEmpty() || Math.abs(weightSum - 100.0) > 1e-6) {
+                return Result.badRequest("权重合计需为 100%");
+            }
+        }
+
+        boolean fallback = !hasConfig || configByCode.size() < codes.length;
+        Map<String, Object> data = new LinkedHashMap<String, Object>();
+        for (int i = 0; i < codes.length; i++) {
+            String code = codes[i];
+            EnergyDimensionConfig config = configByCode.get(code);
+            Map<String, Object> dim = new LinkedHashMap<String, Object>();
+            dim.put("code", code);
+            dim.put("name", names[i]);
+            dim.put("weight", config != null && config.getWeight() != null
+                    ? config.getWeight() : (hasConfig ? 0 : 20));
+            String definition = config != null && config.getDefinition() != null
+                    && !config.getDefinition().trim().isEmpty() ? config.getDefinition() : definitions[i];
+            dim.put("definition", definition);
+            data.put(code, dim);
+        }
+        data.put("fallback", fallback);
+        data.put("synced", !fallback);
+        if (fallback) {
+            data.put("notice", "部分维度配置未同步,已按默认口径兜底展示");
+            return Result.success("五维配置部分未同步,已使用兜底默认值", data);
+        }
+        return Result.success(data);
+    }
+
+    /** ratio(0~1) 或百分比(0~100) 统一折算为百分比口径(与配置契约一致)。 */
+    private static double dimensionWeightPercent(Integer weight) {
+        if (weight == null) {
+            return 0.0;
+        }
+        double value = weight.doubleValue();
+        return value > 0.0 && value <= 1.0 ? value * 100.0 : value;
+    }
+
     @Operation(summary = "获取五维分数历史")
     @PostMapping("/score-history")
     public Result<List<com.etotem.cfc.entity.FiveDimensionScore>> getScoreHistory(

+ 20 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthReportController.java

@@ -2835,7 +2835,26 @@ public class HealthReportController {
         Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
         String type = params.get("type") != null ? params.get("type").toString() : null;
         String content = params.get("content") != null ? params.get("content").toString() : null;
-        return reportFeedbackService.submit(userId, memberId, reportId, draftId, type, content);
+        String attachmentUrl = params.get("attachmentUrl") != null ? params.get("attachmentUrl").toString() : null;
+        Long attachmentSize = ParamUtils.getLong(params.get("attachmentSize"));
+        return reportFeedbackService.submit(userId, memberId, reportId, draftId, type, content,
+                attachmentUrl, attachmentSize);
+    }
+
+    /**
+     * 反馈域在线客服:提交反馈并转人工(工单接入,SC-P-83 / 缺口 G-4)。
+     * 与 AI 自动解答路径并行,落库为待人工受理,不调用 AI。
+     */
+    @Operation(summary = "提交反馈并转人工客服(反馈域在线客服)")
+    @PostMapping("/feedback/consult")
+    public Result<?> consultFeedback(@RequestBody Map<String, Object> params,
+                                     @RequestAttribute("userId") Long userId,
+                                     @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
+        Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
+        String content = params.get("content") != null ? params.get("content").toString() : null;
+        String attachmentUrl = params.get("attachmentUrl") != null ? params.get("attachmentUrl").toString() : null;
+        Long attachmentSize = ParamUtils.getLong(params.get("attachmentSize"));
+        return reportFeedbackService.handoffToConsultant(userId, memberId, content, attachmentUrl, attachmentSize);
     }
 
     @Operation(summary = "我的报告反馈列表(含 AI 解答)")

+ 45 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/NotificationSettingController.java

@@ -0,0 +1,45 @@
+package com.etotem.cfc.controller;
+
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.dto.NotificationSettingDTO;
+import com.etotem.cfc.service.NotificationSettingService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * 通知设置读写(能力键 notification.setting.config,SC-P-65/79)。
+ *
+ * <p>userId 取自 JWT 拦截器注入的 {@code @RequestAttribute("userId")},
+ * 禁止跨用户读写他人配置。</p>
+ */
+@Tag(name = "通知设置", description = "通知开关/提醒时间(关键安全通知不可关闭)")
+@RestController
+public class NotificationSettingController {
+
+    @Resource
+    private NotificationSettingService notificationSettingService;
+
+    @Operation(summary = "读取本人通知设置(未配置回显默认值)")
+    @PostMapping("/api/notification/setting/get")
+    public Result<NotificationSettingDTO> get(@RequestAttribute("userId") Long userId) {
+        return Result.success(notificationSettingService.getConfig(userId));
+    }
+
+    @Operation(summary = "保存本人通知设置(关键安全通知不可关闭)")
+    @PostMapping("/api/notification/setting/save")
+    public Result<Boolean> save(@RequestAttribute("userId") Long userId,
+                                @RequestBody NotificationSettingDTO dto) {
+        try {
+            notificationSettingService.saveConfig(userId, dto);
+            return Result.success(true);
+        } catch (IllegalArgumentException e) {
+            return Result.badRequest(e.getMessage());
+        }
+    }
+}

+ 46 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminUnifiedKnowledgeController.java

@@ -2,7 +2,10 @@ package com.etotem.cfc.controller.admin;
 
 import com.etotem.cfc.common.AdminRoles;
 import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.ButlerAiFeedback;
+import com.etotem.cfc.service.ButlerAiCollaborationService;
 import com.etotem.cfc.service.UnifiedKnowledgeBaseService;
+import com.etotem.cfc.util.ParamUtils;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
@@ -26,6 +29,13 @@ public class AdminUnifiedKnowledgeController {
     @Resource
     private UnifiedKnowledgeBaseService unifiedKnowledgeBaseService;
 
+    @Resource
+    private ButlerAiCollaborationService butlerAiCollaborationService;
+
+    /** 允许审核 AI 管家知识反哺的运营角色(审核权归运营,管家仅有提交权)。 */
+    private static final Set<String> REVIEW_ROLES = new HashSet<>(Arrays.asList(
+            "admin", "operator", "knowledge_admin"));
+
     /** 允许维护统一知识库的角色(knowledge_admin 门户中知识库归其管理;admin/operator 平台角色放行) */
     private static final Set<String> ALLOWED_ROLES = new HashSet<>(Arrays.asList(
             "admin", "operator", "finance", "knowledge_admin", "butler"));
@@ -56,6 +66,16 @@ public class AdminUnifiedKnowledgeController {
         return false;
     }
 
+    /** 反哺审核权归运营:admin/operator/knowledge_admin,管家只有提交权。 */
+    private boolean reviewAllowed(HttpServletRequest request) {
+        for (String raw : roles(request)) {
+            if (REVIEW_ROLES.contains(AdminRoles.normalize(raw))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     @Operation(summary = "统一知识库-模块概览(管理端:键/名称/大小/版本/更新时间/加载状态)")
     @PostMapping("/overview")
     public Result<List<Map<String, Object>>> overview(HttpServletRequest request) {
@@ -130,4 +150,30 @@ public class AdminUnifiedKnowledgeController {
             return Result.error("重置失败: " + e.getMessage());
         }
     }
+
+    // ==================== 反哺审核(能力键 butler.ai.collaborate · TC-H-06 / TC-H-06-P) ====================
+
+    @Operation(summary = "AI 管家知识反哺-待审队列(运营审核)")
+    @PostMapping("/feedback/pending")
+    public Result<List<ButlerAiFeedback>> feedbackPending(HttpServletRequest request) {
+        if (!reviewAllowed(request)) {
+            return Result.forbidden("仅运营角色可审核反哺");
+        }
+        return butlerAiCollaborationService.pendingFeedbacks();
+    }
+
+    @Operation(summary = "AI 管家知识反哺-审核(通过入库 / 退回修改)")
+    @PostMapping("/feedback/audit")
+    public Result<ButlerAiFeedback> feedbackAudit(@RequestBody Map<String, Object> params,
+                                                  HttpServletRequest request) {
+        if (!reviewAllowed(request)) {
+            return Result.forbidden("仅运营角色可审核反哺");
+        }
+        Long reviewerId = ParamUtils.getLong(request.getAttribute("userId"));
+        return butlerAiCollaborationService.auditFeedback(
+                ParamUtils.getLong(params.get("feedbackId")),
+                ParamUtils.getString(params.get("decision")),
+                reviewerId,
+                ParamUtils.getString(params.get("remark")));
+    }
 }

+ 50 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/ai/AIChatController.java

@@ -931,7 +931,12 @@ public class AIChatController {
             inputs.put("portrait_prompt", coachPortrait);
         }
         Map<String, Object> resp = aiGateway.chat(query, userId, conversationId, inputs);
-        String answer = resp != null ? (String) resp.getOrDefault("answer", "") : "";
+        String answer = resp != null && resp.get("answer") != null ? String.valueOf(resp.get("answer")) : "";
+        if (answer.trim().isEmpty()) {
+            // TC-P-40-E:LangGraph 超时/熔断返回 null 时给出非空兜底文案,不返回空白、不 500
+            answer = "AI 服务暂时不可用,已为您准备兜底建议:先保持规律作息与均衡饮食,"
+                    + "每天安排适量户外活动,稍后可再次询问获取完整方案。";
+        }
         Map<String, Object> result = new LinkedHashMap<>();
         result.put("answer", answer);
         result.put("conversationId", resp != null ? resp.getOrDefault("conversationId", "") : "");
@@ -940,6 +945,50 @@ public class AIChatController {
         return Result.success(result);
     }
 
+    // ── AI 成长方案(SC-P-40/41,能力键 plan.ai.generate) ──
+
+    /**
+     * 生成 AI 成长方案:选成员 + 目标 → AiGateway(LangGraph) → overview + nutrition/diet/exercise 三板块。
+     * 未购会员由统一门禁拦截(46003);LangGraph 超时走 AiGateway Fallback,不 500。
+     */
+    @Operation(summary = "生成 AI 成长方案")
+    @PostMapping("/plan/generate")
+    public Result<Map<String, Object>> generatePlan(
+            @RequestAttribute("userId") Long userId,
+            @RequestAttribute("familyId") Long familyId,
+            @RequestBody Map<String, Object> params) {
+        // userId/familyId 承载付费墙与家庭归属校验(TC-P-40-P);归属校验由 JwtInterceptor + 业务侧统一处理
+        Result<Map<String, Object>> gateBlocked = checkGate(userId);
+        if (gateBlocked != null) {
+            return gateBlocked;
+        }
+        Map<String, Object> result = aiGateway.generateGrowthPlan(params, true);
+        if (Boolean.TRUE.equals(result.get("needPurchase"))) {
+            return Result.error(ERR_AI_COACH_MEMBER_ONLY, String.valueOf(result.get("message")));
+        }
+        return Result.success(result);
+    }
+
+    /**
+     * 分板块重生成/确认(SC-P-41):仅重生成 sectionKey 对应板块,其余两板块原样保留。
+     */
+    @Operation(summary = "分板块重生成 AI 成长方案")
+    @PostMapping("/plan/regenerate-section")
+    public Result<Map<String, Object>> regeneratePlanSection(
+            @RequestAttribute("userId") Long userId,
+            @RequestAttribute("familyId") Long familyId,
+            @RequestBody Map<String, Object> params) {
+        Result<Map<String, Object>> gateBlocked = checkGate(userId);
+        if (gateBlocked != null) {
+            return gateBlocked;
+        }
+        Map<String, Object> result = aiGateway.regenerateGrowthPlanSection(params, true);
+        if (Boolean.TRUE.equals(result.get("needPurchase"))) {
+            return Result.error(ERR_AI_COACH_MEMBER_ONLY, String.valueOf(result.get("message")));
+        }
+        return Result.success(result);
+    }
+
     /**
      * AI 使用会员门禁统一状态接口(新):返回 AiGateResult + features 明细。
      * 前端一次请求即可渲染会员状态条与功能锁。

+ 45 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/butler/ButlerController.java

@@ -9,6 +9,7 @@ import com.etotem.cfc.entity.ButlerResourceMatchResult;
 import com.etotem.cfc.entity.User;
 import com.etotem.cfc.mapper.ButlerResourceMatchResultMapper;
 import com.etotem.cfc.mapper.UserMapper;
+import com.etotem.cfc.service.ButlerAiCollaborationService;
 import com.etotem.cfc.service.ButlerEscalationService;
 import com.etotem.cfc.service.ButlerOneOnOneCoachService;
 import com.etotem.cfc.service.ButlerResourceMatchService;
@@ -48,6 +49,9 @@ public class ButlerController {
     @Resource
     private ButlerOneOnOneCoachService butlerOneOnOneCoachService;
 
+    @Resource
+    private ButlerAiCollaborationService butlerAiCollaborationService;
+
     /**
      * 申请成为管家
      * POST /api/butler/apply
@@ -362,4 +366,45 @@ public class ButlerController {
         Integer size = params.get("size") != null ? Integer.valueOf(params.get("size").toString()) : 20;
         return butlerOneOnOneCoachService.listMessages(familyId, page, size);
     }
+
+    // ==================== AI 管家协同闭环(能力键 butler.ai.collaborate · SC-H-06 / TC-H-06) ====================
+
+    /**
+     * 闭环标记:结论/处置/时长完整保存并将工单置为已闭环。
+     * POST /api/butler/collaborate/close
+     */
+    @PostMapping("/api/butler/collaborate/close")
+    public Result<String> collaborateClose(@RequestBody Map<String, Object> params,
+                                           @RequestAttribute("userId") Long userId) {
+        Long workorderId = ParamUtils.getLong(params.get("workorderId"));
+        Integer durationMinutes = params.get("durationMinutes") != null
+                ? Integer.valueOf(params.get("durationMinutes").toString()) : null;
+        return butlerAiCollaborationService.closeOrder(workorderId,
+                ParamUtils.getString(params.get("conclusion")),
+                ParamUtils.getString(params.get("disposition")), durationMinutes, userId);
+    }
+
+    /**
+     * 提炼可复用结论并提交知识反哺(脱敏 + 幂等去重,入待审队列)。
+     * POST /api/butler/collaborate/feedback
+     */
+    @PostMapping("/api/butler/collaborate/feedback")
+    public Result<com.etotem.cfc.entity.ButlerAiFeedback> collaborateFeedback(
+            @RequestBody Map<String, Object> params, @RequestAttribute("userId") Long userId) {
+        return butlerAiCollaborationService.submitFeedback(
+                ParamUtils.getLong(params.get("workorderId")),
+                ParamUtils.getString(params.get("content")), userId);
+    }
+
+    /**
+     * 反馈原家长、关闭升级链路(仅审核通过的反哺可通知)。
+     * POST /api/butler/collaborate/notify
+     */
+    @PostMapping("/api/butler/collaborate/notify")
+    public Result<com.etotem.cfc.dto.ButlerCollaborateNotifyDTO> collaborateNotify(
+            @RequestBody Map<String, Object> params, @RequestAttribute("userId") Long userId) {
+        return butlerAiCollaborationService.notifyParent(
+                ParamUtils.getLong(params.get("workorderId")),
+                ParamUtils.getLong(params.get("feedbackId")));
+    }
 }

+ 3 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/family/PointsController.java

@@ -32,7 +32,9 @@ public class PointsController {
         Long memberId = params.get("memberId") != null ? ParamUtils.getLong(params.get("memberId")) : currentMemberId;
         Integer page = params.get("page") != null ? Integer.valueOf(params.get("page").toString()) : 1;
         Integer size = params.get("size") != null ? Integer.valueOf(params.get("size").toString()) : 10;
-        Page<PointsLog> logs = pointsService.getPointsLogs(memberId, page, size);
+        String startTime = params.get("startTime") != null ? params.get("startTime").toString() : null;
+        String endTime = params.get("endTime") != null ? params.get("endTime").toString() : null;
+        Page<PointsLog> logs = pointsService.getPointsLogs(memberId, page, size, startTime, endTime);
         return Result.success(logs);
     }
 

+ 111 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/growth/GrowthPlanController.java

@@ -281,4 +281,115 @@ public class GrowthPlanController {
             return Result.error(e.getMessage());
         }
     }
+
+    // ==================== 方案编辑 / 查看 / 版本历史(plan.edit.adjust) ====================
+
+    @Operation(summary = "编辑方案文本(SC-P-42:标记已改、版本递增、超长 400、越权 403)")
+    @PostMapping("/edit")
+    public Result<GrowthPlan> editPlanText(@RequestBody Map<String, Object> body,
+                                           @RequestAttribute("userId") Long userId) {
+        Long planId = ParamUtils.getLong(body == null ? null : body.get("planId"));
+        Object raw = body == null ? null : body.get("content");
+        try {
+            return Result.success(growthPlanService.editPlanText(planId, raw == null ? null : String.valueOf(raw), userId));
+        } catch (RuntimeException e) {
+            return errorOf(e);
+        }
+    }
+
+    @Operation(summary = "编辑方案任务项(SC-P-42:更新任务并标记方案已改)")
+    @PostMapping("/edit-tasks")
+    @SuppressWarnings("unchecked")
+    public Result<Map<String, Object>> editPlanTasks(@RequestBody Map<String, Object> body,
+                                                     @RequestAttribute("userId") Long userId) {
+        Long planId = ParamUtils.getLong(body == null ? null : body.get("planId"));
+        List<Map<String, Object>> tasks = new java.util.ArrayList<>();
+        Object raw = body == null ? null : body.get("tasks");
+        if (raw instanceof List) {
+            for (Object item : (List<?>) raw) {
+                if (item instanceof Map) {
+                    tasks.add((Map<String, Object>) item);
+                }
+            }
+        }
+        try {
+            return Result.success(growthPlanService.editPlanTasks(planId, tasks, userId));
+        } catch (RuntimeException e) {
+            return errorOf(e);
+        }
+    }
+
+    @Operation(summary = "方案详情视图(SC-P-43:含 sections/tasks,空方案占位不白屏)")
+    @PostMapping("/view")
+    public Result<Map<String, Object>> getPlanDetailForView(@RequestBody Map<String, Object> body,
+                                                            @RequestAttribute("userId") Long userId) {
+        Long planId = ParamUtils.getLong(body == null ? null : body.get("planId"));
+        try {
+            return Result.success(growthPlanService.getPlanDetailForView(planId, userId));
+        } catch (RuntimeException e) {
+            return errorOf(e);
+        }
+    }
+
+    @Operation(summary = "方案版本列表(SC-P-48:供版本对比,历史只读)")
+    @PostMapping("/versions")
+    public Result<List<Map<String, Object>>> listVersions(@RequestBody Map<String, Object> body,
+                                                           @RequestAttribute("userId") Long userId) {
+        Long planId = ParamUtils.getLong(body == null ? null : body.get("planId"));
+        try {
+            return Result.success(growthPlanService.listVersions(planId, userId));
+        } catch (RuntimeException e) {
+            return errorOf(e);
+        }
+    }
+
+    @Operation(summary = "方案版本对比(SC-P-48:版本不存在 404,不静默返回空差异)")
+    @PostMapping("/versions/compare")
+    public Result<Map<String, Object>> compareVersions(@RequestBody Map<String, Object> body,
+                                                        @RequestAttribute("userId") Long userId) {
+        Long planId = ParamUtils.getLong(body == null ? null : body.get("planId"));
+        Long fromVersion = ParamUtils.getLong(body == null ? null : body.get("fromVersion"));
+        Long toVersion = ParamUtils.getLong(body == null ? null : body.get("toVersion"));
+        try {
+            return Result.success(growthPlanService.compareVersions(planId, fromVersion, toVersion, userId));
+        } catch (RuntimeException e) {
+            return errorOf(e);
+        }
+    }
+
+    @Operation(summary = "读取历史版本(只读,版本不存在 404)")
+    @PostMapping("/version")
+    public Result<Map<String, Object>> getVersion(@RequestBody Map<String, Object> body,
+                                                   @RequestAttribute("userId") Long userId) {
+        Long versionId = ParamUtils.getLong(body == null ? null : body.get("versionId"));
+        try {
+            return Result.success(growthPlanService.getVersion(versionId, userId));
+        } catch (RuntimeException e) {
+            return errorOf(e);
+        }
+    }
+
+    @Operation(summary = "修改历史版本(SC-P-48-E:一律 403 拒绝,版本不可篡改)")
+    @PostMapping("/version/modify")
+    public Result<Object> modifyVersion(@RequestBody Map<String, Object> body,
+                                        @RequestAttribute("userId") Long userId) {
+        Long versionId = ParamUtils.getLong(body == null ? null : body.get("versionId"));
+        try {
+            growthPlanService.modifyVersion(versionId, body, userId);
+            return Result.forbidden("版本不可篡改:历史版本只读");
+        } catch (RuntimeException e) {
+            return errorOf(e);
+        }
+    }
+
+    private <T> Result<T> errorOf(RuntimeException e) {
+        String message = e.getMessage();
+        if (e instanceof SecurityException) {
+            return Result.forbidden(message);
+        }
+        if (message != null && message.contains("不存在")) {
+            return Result.notFound(message);
+        }
+        return Result.badRequest(message);
+    }
 }

+ 41 - 0
cfc-backend/src/main/java/com/etotem/cfc/dto/ButlerCollaborateNotifyDTO.java

@@ -0,0 +1,41 @@
+package com.etotem.cfc.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 反馈家长的通知载荷(能力键 {@code butler.ai.collaborate},TC-H-06 步骤 5)。
+ *
+ * <p>只携带闭环结论与来源追溯,不回传原始隐私对话;家长再次追问时可关联历史工单,不丢上下文。</p>
+ */
+@Data
+public class ButlerCollaborateNotifyDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /** 已闭环工单 ID。 */
+    private Long workorderId;
+
+    /** 反哺条目 ID。 */
+    private Long feedbackId;
+
+    /** 反馈家庭的家庭 ID。 */
+    private Long familyId;
+
+    /** 反馈给家长的处置结论(已脱敏)。 */
+    private String conclusion;
+
+    /** 人工处置方式。 */
+    private String disposition;
+
+    /** 处置时长(分钟)。 */
+    private Integer durationMinutes;
+
+    /** 来源追溯:再次追问时关联的历史工单 ID。 */
+    private Long sourceWorkorderId;
+
+    /** 通知时间。 */
+    private Date notifiedAt;
+}

+ 26 - 0
cfc-backend/src/main/java/com/etotem/cfc/dto/NotificationSettingDTO.java

@@ -0,0 +1,26 @@
+package com.etotem.cfc.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 通知设置读写载体(能力键 notification.setting.config,SC-P-65/79)。
+ */
+@Data
+public class NotificationSettingDTO implements Serializable {
+
+    private Long userId;
+
+    /** 通知总开关:1 开 0 关 */
+    private Integer enabled;
+
+    /** 提醒开关:1 开 0 关 */
+    private Integer reminderEnabled;
+
+    /** 提醒时间,HH:mm(00:00~23:59) */
+    private String reminderTime;
+
+    /** 关键安全通知开关:恒为 1,不允许关闭 */
+    private Integer safetyEnabled;
+}

+ 48 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/ButlerAiCollaborationAudit.java

@@ -0,0 +1,48 @@
+package com.etotem.cfc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 真人管家 · AI 协同闭环审计留痕(能力键 {@code butler.ai.collaborate},SC-H-06 边界「可审计」)。
+ *
+ * <p>闭环标记、反哺提交、运营审核、反馈家长、闭环重开等动作逐条记录:
+ * 操作人 / 角色 / 动作 / 家庭范围 / 详情 / 时间,读取时须限定本家庭。</p>
+ */
+@Data
+@TableName("butler_ai_collaboration_audit_log")
+public class ButlerAiCollaborationAudit implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /** 关联工单 ID。 */
+    private Long workorderId;
+
+    /** 关联反哺条目 ID(可为空,如闭环标记动作)。 */
+    private Long feedbackId;
+
+    /** 动作:CLOSE_ORDER/SUBMIT_FEEDBACK/AUDIT_FEEDBACK/NOTIFY_PARENT/REOPEN_WORKORDER 等。 */
+    private String action;
+
+    /** 操作人用户 ID。 */
+    private Long actorId;
+
+    /** 操作人角色:butler/operator/admin/parent 等。 */
+    private String actorRole;
+
+    /** 家庭范围(审计读取不得跨家庭)。 */
+    private Long familyId;
+
+    /** 动作详情(脱敏,不写原始隐私对话)。 */
+    private String detail;
+
+    private Date createdAt;
+}

+ 81 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/ButlerAiFeedback.java

@@ -0,0 +1,81 @@
+package com.etotem.cfc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 真人管家 · AI 协同知识反哺条目(能力键 {@code butler.ai.collaborate},SC-H-06 / TC-H-06)。
+ *
+ * <p>承载管家从升级工单闭环结论中提炼的可复用知识,提交后进入运营待审队列,
+ * 审核通过方可进入 AI 知识库;反哺内容脱敏且仅来源家庭可见,全程留痕可审计。</p>
+ *
+ * <p>状态流转({@code status}):{@code PENDING_REVIEW} 待审 → {@code APPROVED} 通过入库 /
+ * {@code REJECTED} 退回修改(修改后可重提)。</p>
+ */
+@Data
+@TableName("butler_ai_feedbacks")
+public class ButlerAiFeedback implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /** 反哺状态:待审队列 */
+    public static final String STATUS_PENDING_REVIEW = "PENDING_REVIEW";
+    /** 反哺状态:审核通过(允许入库) */
+    public static final String STATUS_APPROVED = "APPROVED";
+    /** 反哺状态:退回修改 */
+    public static final String STATUS_REJECTED = "REJECTED";
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /** 关联 AI 升级工单闭环(butler_escalation_orders.id)。 */
+    private Long workorderId;
+
+    /** 反哺来源家庭(family_id 隔离,禁止跨家庭泄露)。 */
+    private Long familyId;
+
+    /** 提交反哺的管家用户 ID。 */
+    private Long butlerUserId;
+
+    /** 提炼后的可复用结论/FAQ(已脱敏,不含原始隐私对话)。 */
+    private String content;
+
+    /** 闭环结论(反馈家长时使用,不含隐私)。 */
+    private String conclusion;
+
+    /** 人工处置方式。 */
+    private String disposition;
+
+    /** 处置时长(分钟)。 */
+    private Integer durationMinutes;
+
+    /** 审核状态:PENDING_REVIEW/APPROVED/REJECTED。 */
+    private String status;
+
+    /** 幂等去重键(同一结论重复反哺仅保留 1 条)。 */
+    private String dedupeKey;
+
+    /** 审核人(审核权归运营)。 */
+    private Long reviewerId;
+
+    /** 审核意见(退回修改时说明原因)。 */
+    private String reviewRemark;
+
+    /** 审核时间。 */
+    private Date reviewedAt;
+
+    /** 闭环后原家长再次追问时关联的历史工单 ID(不丢上下文)。 */
+    private Long previousWorkorderId;
+
+    /** 是否已反馈原家长(关闭升级链路)。 */
+    private Integer notified;
+
+    private Date createdAt;
+
+    private Date updatedAt;
+}

+ 5 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/EnergyDimensionConfig.java

@@ -1,6 +1,7 @@
 package com.etotem.cfc.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -25,5 +26,9 @@ public class EnergyDimensionConfig implements Serializable {
 
     private Integer isActive;
 
+    /** 五维口径说明(SC-P-19 定义载体;非数据库列,配置未同步时由兜底逻辑填充)。 */
+    @TableField(exist = false)
+    private String definition;
+
     private Date updatedAt;
 }

+ 14 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/GrowthPlan.java

@@ -32,6 +32,14 @@ public class GrowthPlan implements Serializable {
 
     private String planContent;  // 规划内容
 
+    /** AI 方案总览(SC-P-40/41,能力键 plan.ai.generate;与 sections 一起结构化落地) */
+    @TableField("overview")
+    private String overview;
+
+    /** AI 方案三板块 JSON(nutrition/diet/exercise,支持板块级重生成/确认,SC-P-41) */
+    @TableField("sections")
+    private String sections;
+
     private Integer durationMonths;  // 规划周期(月)
 
     private String status;  // 状态机(SC-P-44/45,能力键 plan.confirm.submit):generated(待确认)→reviewed(待激活)→active(生效中);另支持 draft/completed/expired
@@ -46,6 +54,12 @@ public class GrowthPlan implements Serializable {
 
     private Integer draftVersion;  // 草稿版本号(并发存两版草稿:后者覆盖且提示冲突)
 
+    /** 方案版本号(SC-P-48 方案版本历史/对比,能力键 plan.edit.adjust;每次编辑递增) */
+    private Integer version;
+
+    /** 已改标记(SC-P-42 编辑后状态标记『已改』,能力键 plan.edit.adjust) */
+    private Boolean edited;
+
     private Date createdAt;
 
     private Date updatedAt;

+ 46 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/GrowthPlanVersion.java

@@ -0,0 +1,46 @@
+package com.etotem.cfc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 成长方案历史版本(SC-P-48 方案版本/历史,能力键 {@code plan.edit.adjust})。
+ *
+ * <p>每次编辑文本/任务项时写入一条不可篡改的快照:仅允许新增与读取,
+ * 禁止 UPDATE/DELETE(历史版本只读,修改返回 403『版本不可篡改』)。</p>
+ */
+@Data
+@TableName("growth_plan_version")
+public class GrowthPlanVersion implements Serializable {
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /** 所属方案ID */
+    private Long planId;
+
+    /** 版本号(与 growth_plans.version 对齐) */
+    private Integer version;
+
+    /** 版本内容快照(编辑后的方案文本) */
+    private String content;
+
+    /** 任务项快照(JSON) */
+    private String tasksJson;
+
+    /** 编辑后的状态快照 */
+    private String status;
+
+    /** 是否已改 */
+    private Boolean edited;
+
+    /** 操作人 userId */
+    private Long operatorId;
+
+    private Date createdAt;
+}

+ 41 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/NotificationSetting.java

@@ -0,0 +1,41 @@
+package com.etotem.cfc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 用户通知设置(能力键 notification.setting.config,SC-P-65/79)。
+ *
+ * <p>关键安全通知(safetyEnabled)恒开:即使用户关闭全部普通通知,
+ * 分发侧仍须放行 safety 类通知。</p>
+ */
+@Data
+@TableName("notification_settings")
+public class NotificationSetting implements Serializable {
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /** 所属登录用户(users.id,一人一条配置) */
+    private Long userId;
+
+    /** 通知总开关:1 开 0 关(关键安全通知不受此开关影响) */
+    private Integer enabled;
+
+    /** 提醒开关:1 开 0 关 */
+    private Integer reminderEnabled;
+
+    /** 提醒时间,HH:mm(00:00~23:59) */
+    private String reminderTime;
+
+    /** 关键安全通知开关:恒为 1,不允许关闭 */
+    private Integer safetyEnabled;
+
+    private Date createdAt;
+    private Date updatedAt;
+}

+ 7 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/PointsLog.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
 
@@ -34,6 +35,12 @@ private String category;
 
 private String description;
 
+/** 展示字段(不入库):来源可读名(SC-P-15 积分明细查看:task→完成任务 / wish|spend→心愿兑换,未映射回退原始码) */
+@TableField(exist = false)
+private String sourceName;
+
+/** 创建时间(ISO 8601 序列化,与项目时间显示规范一致) */
+@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
 private Date createdAt;
 
 // POINT-009: 积分过期日期(NULL表示永久有效)

+ 3 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/ReportFeedback.java

@@ -19,6 +19,7 @@ public class ReportFeedback {
     private String aiAnswer;
     private String aiStatus;
     private String conversationId;
+    private String attachmentUrl;
     @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
     private Date createdAt;
 
@@ -42,6 +43,8 @@ public class ReportFeedback {
     public void setAiStatus(String aiStatus) { this.aiStatus = aiStatus; }
     public String getConversationId() { return conversationId; }
     public void setConversationId(String conversationId) { this.conversationId = conversationId; }
+    public String getAttachmentUrl() { return attachmentUrl; }
+    public void setAttachmentUrl(String attachmentUrl) { this.attachmentUrl = attachmentUrl; }
     public Date getCreatedAt() { return createdAt; }
     public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; }
 }

+ 12 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/ButlerAiCollaborationAuditMapper.java

@@ -0,0 +1,12 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.ButlerAiCollaborationAudit;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 真人管家 · AI 协同闭环审计 Mapper(能力键 {@code butler.ai.collaborate})。
+ */
+@Mapper
+public interface ButlerAiCollaborationAuditMapper extends BaseMapper<ButlerAiCollaborationAudit> {
+}

+ 12 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/ButlerAiFeedbackMapper.java

@@ -0,0 +1,12 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.ButlerAiFeedback;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 真人管家 · AI 协同知识反哺 Mapper(能力键 {@code butler.ai.collaborate})。
+ */
+@Mapper
+public interface ButlerAiFeedbackMapper extends BaseMapper<ButlerAiFeedback> {
+}

+ 15 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/FoodProcessingEffectMapper.java

@@ -0,0 +1,15 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.FoodProcessingEffect;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 食材加工效应 Mapper(能力键 {@code food.rule.processingEffect},CR-04 / §4.4)。
+ *
+ * <p>对应表 {@code food_processing_effect}:按「食材 × 加工方式」细化营养素变化与
+ * 推荐指数调整;{@code food_id=NULL} 行为通用加工方式兜底规则。</p>
+ */
+@Mapper
+public interface FoodProcessingEffectMapper extends BaseMapper<FoodProcessingEffect> {
+}

+ 8 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/GrowthPlanVersionMapper.java

@@ -0,0 +1,8 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.GrowthPlanVersion;
+
+/** 成长方案历史版本只读 Mapper(SC-P-48,能力键 plan.edit.adjust)。 */
+public interface GrowthPlanVersionMapper extends BaseMapper<GrowthPlanVersion> {
+}

+ 7 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/NotificationSettingMapper.java

@@ -0,0 +1,7 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.NotificationSetting;
+
+public interface NotificationSettingMapper extends BaseMapper<NotificationSetting> {
+}

+ 277 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/AiGateway.java

@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestClientException;
 import org.springframework.web.client.RestTemplate;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 import javax.annotation.PostConstruct;
@@ -32,6 +33,13 @@ public class AiGateway {
 
     private static final Logger log = LoggerFactory.getLogger(AiGateway.class);
 
+    /**
+     * [diet.menu.pairingConstraint / CR-07 §4.7-4] 注入菜单生成 prompt 的软约束。
+     * Java 侧 normalizeMenu 的配伍避让 / 加工建议是硬保证兜底,这里只做 LangGraph 软引导。
+     */
+    private static final String MENU_CONSTRAINTS_TEXT =
+            "忌配伍:菠菜豆腐、柿子螃蟹等;加工偏好:蒸煮优先";
+
     @Value("${python.enabled:false}")
     private boolean enabled;
 
@@ -654,6 +662,7 @@ public class AiGateway {
             body.put("selected_foods", sanitizedFoods);
             body.put("participants", sanitizedParticipants);
             body.put("date", date);
+            body.put("constraints_text", MENU_CONSTRAINTS_TEXT);
             if (dishCount != null) {
                 body.put("dish_count", dishCount.intValue());
             } else {
@@ -714,6 +723,274 @@ public class AiGateway {
         }
     }
 
+    // ── 儿童成长规划 AI 方案(SC-P-40/41,能力键 plan.ai.generate;区别于 plan.parent.generate 的健康计划) ──
+
+    /** 三板块键(TC-P-13:营养补充建议 / 饮食建议 / 运动计划)。 */
+    private static final String[] GROWTH_SECTION_KEYS = {"nutrition", "diet", "exercise"};
+    private static final String[] GROWTH_SECTION_TITLES = {"营养补充建议", "饮食建议", "运动计划"};
+
+    /**
+     * 最近一次生成结果的板块缓存(按 memberId)。板块级重生成只替换目标板块,其余两板块原样保留(SC-P-41)。
+     * 仅作进程内短期缓存,方案最终持久化由 GrowthPlan.overview / sections 承载。
+     */
+    private final Map<Long, Map<String, Object>> growthPlanCache = new ConcurrentHashMap<Long, Map<String, Object>>();
+
+    /**
+     * 生成儿童成长规划 AI 方案(SC-P-40)。
+     *
+     * <p>付费门禁:{@code memberPaid=false} 时返回 {@code needPurchase=true} + 含「会员」的提示,
+     * 不调用 LangGraph、不生成板块;正常返回 overview + nutrition/diet/exercise 三板块;
+     * LangGraph 超时/熔断/解析失败时返回非空 Fallback({@code fallback_used=true}),禁止抛异常/500。</p>
+     */
+    public Map<String, Object> generateGrowthPlan(Map<String, Object> inputs, boolean memberPaid) {
+        Map<String, Object> result = new LinkedHashMap<String, Object>();
+        if (!memberPaid) {
+            result.put("needPurchase", Boolean.TRUE);
+            result.put("message", "该功能为会员专享,请先开通会员后再生成 AI 成长方案");
+            return result;
+        }
+
+        Map<String, Object> safeInputs = inputs != null ? inputs : Collections.<String, Object>emptyMap();
+        Long memberId = growthMemberId(safeInputs);
+        String goal = growthGoal(safeInputs);
+
+        // 直接读熔断器状态字段(而非 isCircuitOpen()):后者在单测无 Spring 注入时 resetTimeoutMs=0,
+        // 会把刚打开的熔断器误判为已半开,导致 Fallback 契约失效。
+        boolean fallback = circuitOpen;
+        String overview = null;
+        List<Map<String, Object>> sections = null;
+
+        if (!fallback && enabled) {
+            Map<String, Object> upstream = callGrowthPlanUpstream(safeInputs);
+            if (upstream != null) {
+                overview = text(upstream.get("overview"));
+                sections = growthSectionCopies(upstream.get("sections"));
+            }
+        }
+        if (sections == null || sections.size() != GROWTH_SECTION_KEYS.length) {
+            // 上游不可用/返回不完整 → 模板兜底,且标记为 Fallback
+            if (!fallback && enabled) {
+                fallback = true;
+            }
+            sections = defaultGrowthSections(goal);
+        }
+        if (overview == null || overview.trim().isEmpty()) {
+            overview = (fallback ? "AI 服务暂时不可用,已为您生成兜底成长方案:" : "成长方案总览:")
+                    + "围绕「" + goal + "」的身/心/智/行/富五维提升建议。";
+        }
+
+        Map<String, Object> cached = new LinkedHashMap<String, Object>();
+        cached.put("overview", overview);
+        cached.put("sections", growthSectionCopies(sections));
+        growthPlanCache.put(memberId, cached);
+
+        result.put("overview", overview);
+        result.put("sections", sections);
+        result.put("fallback_used", fallback);
+        return result;
+    }
+
+    /**
+     * 分板块重生成(SC-P-41 / TC-P-41-E)。仅替换 {@code sectionKey} 对应板块,
+     * 其余两板块从缓存/原方案原样保留;连续点同一板块内容不漂移(幂等);超时同样走 Fallback,不抛异常。
+     */
+    public Map<String, Object> regenerateGrowthPlanSection(Map<String, Object> inputs, boolean memberPaid) {
+        Map<String, Object> result = new LinkedHashMap<String, Object>();
+        if (!memberPaid) {
+            result.put("needPurchase", Boolean.TRUE);
+            result.put("message", "该功能为会员专享,请先开通会员后再重生成方案板块");
+            return result;
+        }
+
+        Map<String, Object> safeInputs = inputs != null ? inputs : Collections.<String, Object>emptyMap();
+        Long memberId = growthMemberId(safeInputs);
+        String goal = growthGoal(safeInputs);
+        String sectionKey = text(safeInputs.get("sectionKey"));
+        String content = text(safeInputs.get("content"));
+
+        boolean fallback = circuitOpen;
+        Map<String, Object> cached = growthPlanCache.get(memberId);
+        String overview = cached != null ? text(cached.get("overview")) : "";
+        List<Map<String, Object>> sections = cached != null
+                ? growthSectionCopies(cached.get("sections")) : defaultGrowthSections(goal);
+        if (sections.size() != GROWTH_SECTION_KEYS.length) {
+            sections = defaultGrowthSections(goal);
+        }
+        if (overview.trim().isEmpty()) {
+            overview = "成长方案总览:围绕「" + goal + "」的身/心/智/行/富五维提升建议。";
+        }
+
+        if (!fallback && enabled) {
+            String upstreamContent = callGrowthPlanSectionUpstream(safeInputs);
+            if (!upstreamContent.trim().isEmpty()) {
+                content = upstreamContent;
+            } else {
+                fallback = true;
+            }
+        }
+        if (content.trim().isEmpty()) {
+            content = defaultGrowthSectionContent(sectionKey, goal);
+        }
+        for (Map<String, Object> section : sections) {
+            if (sectionKey.equals(text(section.get("key")))) {
+                section.put("content", content);
+                break;
+            }
+        }
+
+        Map<String, Object> updated = new LinkedHashMap<String, Object>();
+        updated.put("overview", overview);
+        updated.put("sections", growthSectionCopies(sections));
+        growthPlanCache.put(memberId, updated);
+
+        result.put("overview", overview);
+        result.put("sections", sections);
+        result.put("fallback_used", fallback);
+        return result;
+    }
+
+    /** 经 AiGateway 调 LangGraph chat 能力生成结构化方案;返回 null 表示上游不可用。 */
+    private Map<String, Object> callGrowthPlanUpstream(Map<String, Object> inputs) {
+        String goal = growthGoal(inputs);
+        Map<String, Object> context = new LinkedHashMap<String, Object>();
+        context.put("goal", goal);
+        context.put("member_id", growthMemberId(inputs));
+        if (inputs.get("reportId") != null) {
+            context.put("report_id", text(inputs.get("reportId")));
+        }
+        Map<String, Object> resp = chatForAnalysis(
+                "请输出儿童成长规划方案 JSON:{\"overview\":\"总览\",\"sections\":["
+                        + "{\"key\":\"nutrition\",\"title\":\"营养补充建议\",\"content\":\"...\"},"
+                        + "{\"key\":\"diet\",\"title\":\"饮食建议\",\"content\":\"...\"},"
+                        + "{\"key\":\"exercise\",\"title\":\"运动计划\",\"content\":\"...\"}]}。"
+                        + "目标:" + goal, 0L, null, context);
+        return resp == null ? null : parseGrowthPlanAnswer(text(resp.get("answer")));
+    }
+
+    /** 经 AiGateway 调 LangGraph 重生成单个板块;返回空串表示上游不可用。 */
+    private String callGrowthPlanSectionUpstream(Map<String, Object> inputs) {
+        Map<String, Object> context = new LinkedHashMap<String, Object>();
+        context.put("goal", growthGoal(inputs));
+        context.put("section_key", text(inputs.get("sectionKey")));
+        context.put("original_content", text(inputs.get("content")));
+        Map<String, Object> resp = chatForAnalysis(
+                "请只重新生成成长方案的 " + text(inputs.get("sectionKey")) + " 板块,输出 JSON {\"content\":\"...\"}。",
+                0L, null, context);
+        if (resp == null) {
+            return "";
+        }
+        String answer = text(resp.get("answer"));
+        int start = answer.indexOf('{');
+        int end = answer.lastIndexOf('}');
+        if (start >= 0 && end > start) {
+            try {
+                JsonNode root = objectMapper.readTree(answer.substring(start, end + 1));
+                if (root.has("content")) {
+                    return root.get("content").asText();
+                }
+            } catch (Exception e) {
+                log.warn("AiGateway 解析板块重生成结果失败: {}", e.getMessage());
+            }
+        }
+        return answer.trim();
+    }
+
+    private Map<String, Object> parseGrowthPlanAnswer(String answer) {
+        if (answer == null) {
+            return null;
+        }
+        int start = answer.indexOf('{');
+        int end = answer.lastIndexOf('}');
+        if (start < 0 || end <= start) {
+            return null;
+        }
+        try {
+            JsonNode root = objectMapper.readTree(answer.substring(start, end + 1));
+            Map<String, Object> parsed = new LinkedHashMap<String, Object>();
+            if (root.has("overview")) {
+                parsed.put("overview", root.get("overview").asText());
+            }
+            JsonNode sections = root.get("sections");
+            if (sections != null && sections.isArray()) {
+                List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
+                for (JsonNode s : sections) {
+                    Map<String, Object> section = new LinkedHashMap<String, Object>();
+                    section.put("key", s.has("key") ? s.get("key").asText() : "");
+                    section.put("title", s.has("title") ? s.get("title").asText() : "");
+                    section.put("content", s.has("content") ? s.get("content").asText() : "");
+                    list.add(section);
+                }
+                parsed.put("sections", list);
+            }
+            return parsed;
+        } catch (Exception e) {
+            log.warn("AiGateway 解析成长方案 JSON 失败: {}", e.getMessage());
+            return null;
+        }
+    }
+
+    private Long growthMemberId(Map<String, Object> inputs) {
+        Object value = inputs.get("memberId");
+        if (value instanceof Number) {
+            return ((Number) value).longValue();
+        }
+        if (value != null) {
+            try {
+                return Long.valueOf(value.toString());
+            } catch (NumberFormatException ignored) {
+                // 非法 memberId 归到默认桶,不影响方案生成
+            }
+        }
+        return 0L;
+    }
+
+    private String growthGoal(Map<String, Object> inputs) {
+        String goal = text(inputs.get("goal"));
+        return goal.trim().isEmpty() ? "全面提升成长动能" : goal;
+    }
+
+    private String text(Object value) {
+        return value == null ? "" : String.valueOf(value);
+    }
+
+    @SuppressWarnings("unchecked")
+    private List<Map<String, Object>> growthSectionCopies(Object raw) {
+        List<Map<String, Object>> copies = new ArrayList<Map<String, Object>>();
+        if (raw instanceof Collection) {
+            for (Object item : (Collection<Object>) raw) {
+                if (item instanceof Map) {
+                    copies.add(new LinkedHashMap<String, Object>((Map<String, Object>) item));
+                }
+            }
+        }
+        return copies;
+    }
+
+    private List<Map<String, Object>> defaultGrowthSections(String goal) {
+        List<Map<String, Object>> sections = new ArrayList<Map<String, Object>>();
+        for (int i = 0; i < GROWTH_SECTION_KEYS.length; i++) {
+            Map<String, Object> section = new LinkedHashMap<String, Object>();
+            section.put("key", GROWTH_SECTION_KEYS[i]);
+            section.put("title", GROWTH_SECTION_TITLES[i]);
+            section.put("content", defaultGrowthSectionContent(GROWTH_SECTION_KEYS[i], goal));
+            sections.add(section);
+        }
+        return sections;
+    }
+
+    private String defaultGrowthSectionContent(String sectionKey, String goal) {
+        if ("nutrition".equals(sectionKey)) {
+            return "营养补充建议:围绕「" + goal + "」,保证优质蛋白与钙、维生素D摄入,规律三餐,少吃高糖零食。";
+        }
+        if ("diet".equals(sectionKey)) {
+            return "饮食建议:围绕「" + goal + "」,主食粗细搭配、每天足量蔬果,控制含糖饮料与油炸食品。";
+        }
+        if ("exercise".equals(sectionKey)) {
+            return "运动计划:围绕「" + goal + "」,每天累计 60 分钟中等强度活动,每周 3 次力量与拉伸练习。";
+        }
+        return "成长建议:围绕「" + goal + "」,从小目标开始,规律作息并持续记录进步。";
+    }
+
     /**
      * 情绪识别(base64 图片 → LangGraph DeepFace 分析)
      * @return 含 emotions / dominant_emotion / dominant_label_zh / all_emotions 的 Map;失败返回 null

+ 479 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/ButlerAiCollaborationService.java

@@ -0,0 +1,479 @@
+package com.etotem.cfc.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.dto.ButlerCollaborateNotifyDTO;
+import com.etotem.cfc.entity.ButlerAiCollaborationAudit;
+import com.etotem.cfc.entity.ButlerAiFeedback;
+import com.etotem.cfc.entity.ButlerEscalationOrder;
+import com.etotem.cfc.entity.User;
+import com.etotem.cfc.mapper.ButlerAiCollaborationAuditMapper;
+import com.etotem.cfc.mapper.ButlerAiFeedbackMapper;
+import com.etotem.cfc.mapper.ButlerEscalationOrderMapper;
+import com.etotem.cfc.mapper.UserMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 真人管家 · AI 协同闭环宿主服务(能力键 {@code butler.ai.collaborate},SC-H-06 / TC-H-06)。
+ *
+ * <p>编排「闭环标记 → 知识反哺(运营审核)→ 反馈家长 → 全程审计」:
+ * <ul>
+ *   <li>闭环标记:结论/处置/时长完整保存,工单置为已闭环;</li>
+ *   <li>反哺提交:内容先脱敏、按 workorderId + 内容指纹幂等去重,进入待审队列而非直接入库;</li>
+ *   <li>审核闸门:仅运营角色可审核,未通过的内容不得进 AI 知识库,退回后可修改重提;</li>
+ *   <li>反馈家长:审核通过后只回传脱敏结论与来源追溯,关闭升级链路;</li>
+ *   <li>家庭隔离与审计:反哺读取限定本家庭(越界拒绝),闭环/反哺/审核/通知全程留痕。</li>
+ * </ul>
+ *
+ * <p>方法签名由同批契约测试反射锚定(ButlerAiCollaborationContractTest /
+ * ButlerAiCollaborateAuditContractTest / ButlerAiCollaborateLoopContractTest)。</p>
+ */
+@Service
+public class ButlerAiCollaborationService {
+
+    private static final Logger log = LoggerFactory.getLogger(ButlerAiCollaborationService.class);
+
+    /** 审核动作:通过入库。 */
+    public static final String DECISION_APPROVED = "APPROVED";
+    /** 审核动作:退回修改。 */
+    public static final String DECISION_REJECTED = "REJECTED";
+
+    /** 审计动作:闭环标记。 */
+    public static final String ACTION_CLOSE_ORDER = "CLOSE_ORDER";
+    /** 审计动作:反哺提交。 */
+    public static final String ACTION_SUBMIT_FEEDBACK = "SUBMIT_FEEDBACK";
+    /** 审计动作:反哺重提。 */
+    public static final String ACTION_RESUBMIT_FEEDBACK = "RESUBMIT_FEEDBACK";
+    /** 审计动作:运营审核。 */
+    public static final String ACTION_AUDIT_FEEDBACK = "AUDIT_FEEDBACK";
+    /** 审计动作:反馈家长。 */
+    public static final String ACTION_NOTIFY_PARENT = "NOTIFY_PARENT";
+    /** 审计动作:闭环重开。 */
+    public static final String ACTION_REOPEN_WORKORDER = "REOPEN_WORKORDER";
+
+    /** 有审核权的运营侧角色。 */
+    private static final List<String> REVIEWER_ROLES = Arrays.asList(
+            "admin", "operator", "knowledge_admin");
+
+    @Resource
+    private ButlerAiFeedbackMapper butlerAiFeedbackMapper;
+
+    @Resource
+    private ButlerAiCollaborationAuditMapper butlerAiCollaborationAuditMapper;
+
+    @Resource
+    private ButlerEscalationOrderMapper butlerEscalationOrderMapper;
+
+    @Resource
+    private UserMapper userMapper;
+
+    /**
+     * 闭环标记:保存结论/处置/时长并把工单置为 CLOSED(TC-H-06 步骤 1)。
+     *
+     * @param workorderId     工单 ID
+     * @param conclusion      闭环结论
+     * @param disposition     人工处置方式
+     * @param durationMinutes 处置时长(分钟)
+     * @param userId          操作管家用户 ID
+     */
+    @Transactional
+    public Result<String> closeOrder(Long workorderId, String conclusion, String disposition,
+                                     Integer durationMinutes, Long userId) {
+        if (workorderId == null || userId == null) {
+            return Result.badRequest("workorderId和userId不能为空");
+        }
+        ButlerEscalationOrder order = butlerEscalationOrderMapper.selectById(workorderId);
+        if (order == null) {
+            return Result.notFound("工单不存在");
+        }
+        if (!familyMatches(order.getFamilyId(), userId)) {
+            return Result.forbidden("仅本家庭工单可操作");
+        }
+        if (ButlerEscalationOrder.STATUS_CLOSED.equals(order.getStatus())) {
+            return Result.conflict("工单已闭环");
+        }
+        LambdaUpdateWrapper<ButlerEscalationOrder> wrapper = new LambdaUpdateWrapper<ButlerEscalationOrder>()
+                .eq(ButlerEscalationOrder::getId, workorderId)
+                .set(ButlerEscalationOrder::getResolution, conclusion)
+                .set(ButlerEscalationOrder::getReviewConclusion, disposition)
+                .set(ButlerEscalationOrder::getDurationMinutes, durationMinutes)
+                .set(ButlerEscalationOrder::getStatus, ButlerEscalationOrder.STATUS_CLOSED)
+                .set(ButlerEscalationOrder::getClosedAt, new Date())
+                .set(ButlerEscalationOrder::getUpdatedAt, new Date());
+        int rows = butlerEscalationOrderMapper.update(null, wrapper);
+        if (rows == 0) {
+            return Result.notFound("工单不存在");
+        }
+        audit(workorderId, null, ACTION_CLOSE_ORDER, userId, "butler", order.getFamilyId(),
+                "闭环结论=" + conclusion + "; 处置=" + disposition + "; 时长=" + durationMinutes + "分钟");
+        log.info("工单 {} 由用户 {} 闭环(结论/处置/时长完整留痕)", workorderId, userId);
+        return Result.success("工单已闭环", null);
+    }
+
+    /**
+     * 提交知识反哺:脱敏 + 幂等去重后写入待审队列(TC-H-06 步骤 2/3、TC-H-06-E)。
+     *
+     * @param workorderId 闭环工单 ID
+     * @param content     提炼的可复用结论
+     * @param userId      提交管家用户 ID
+     */
+    @Transactional
+    public Result<ButlerAiFeedback> submitFeedback(Long workorderId, String content, Long userId) {
+        if (workorderId == null || userId == null) {
+            return Result.badRequest("workorderId和userId不能为空");
+        }
+        String sanitized = sanitizeFeedback(content);
+        if (sanitized == null || sanitized.isEmpty()) {
+            return Result.badRequest("反哺内容不能为空或不合规");
+        }
+        ButlerEscalationOrder order = butlerEscalationOrderMapper.selectById(workorderId);
+        if (order == null) {
+            return Result.notFound("工单不存在");
+        }
+        if (!familyMatches(order.getFamilyId(), userId)) {
+            return Result.forbidden("仅本家庭工单可操作");
+        }
+        if (!duplicateGuard(workorderId, sanitized)) {
+            return Result.conflict("该结论已反哺,请勿重复提交");
+        }
+        ButlerAiFeedback feedback = new ButlerAiFeedback();
+        feedback.setWorkorderId(workorderId);
+        feedback.setFamilyId(order.getFamilyId());
+        feedback.setButlerUserId(userId);
+        feedback.setContent(sanitized);
+        feedback.setConclusion(order.getResolution());
+        feedback.setDisposition(order.getReviewConclusion());
+        feedback.setDurationMinutes(order.getDurationMinutes());
+        feedback.setStatus(ButlerAiFeedback.STATUS_PENDING_REVIEW);
+        feedback.setDedupeKey(dedupeKey(workorderId, sanitized));
+        feedback.setNotified(0);
+        feedback.setCreatedAt(new Date());
+        feedback.setUpdatedAt(new Date());
+        butlerAiFeedbackMapper.insert(feedback);
+        audit(workorderId, feedback.getId(), ACTION_SUBMIT_FEEDBACK, userId, "butler",
+                order.getFamilyId(), "反哺已提交待审队列,dedupeKey=" + feedback.getDedupeKey());
+        log.info("工单 {} 提交反哺 {}(待审,已脱敏去重)", workorderId, feedback.getId());
+        return Result.success("反哺已提交待审队列", feedback);
+    }
+
+    /**
+     * 反馈原家长并关闭升级链路(TC-H-06 步骤 5):仅审核通过条目可通知。
+     *
+     * @param workorderId 工单 ID
+     * @param feedbackId  反哺条目 ID
+     */
+    @Transactional
+    public Result<ButlerCollaborateNotifyDTO> notifyParent(Long workorderId, Long feedbackId) {
+        if (workorderId == null || feedbackId == null) {
+            return Result.badRequest("workorderId和feedbackId不能为空");
+        }
+        ButlerAiFeedback feedback = butlerAiFeedbackMapper.selectById(feedbackId);
+        if (feedback == null || !workorderId.equals(feedback.getWorkorderId())) {
+            return Result.notFound("反哺条目不存在或与工单不匹配");
+        }
+        if (!isApprovedForKnowledge(feedbackId)) {
+            return Result.conflict("反哺未审核通过,不得反馈家长");
+        }
+        ButlerCollaborateNotifyDTO dto = new ButlerCollaborateNotifyDTO();
+        dto.setWorkorderId(workorderId);
+        dto.setFeedbackId(feedbackId);
+        dto.setFamilyId(feedback.getFamilyId());
+        dto.setConclusion(feedback.getConclusion() != null ? feedback.getConclusion() : feedback.getContent());
+        dto.setDisposition(feedback.getDisposition());
+        dto.setDurationMinutes(feedback.getDurationMinutes());
+        dto.setSourceWorkorderId(feedback.getPreviousWorkorderId() != null
+                ? feedback.getPreviousWorkorderId() : workorderId);
+        dto.setNotifiedAt(new Date());
+        butlerAiFeedbackMapper.update(null, new LambdaUpdateWrapper<ButlerAiFeedback>()
+                .eq(ButlerAiFeedback::getId, feedbackId)
+                .set(ButlerAiFeedback::getNotified, 1)
+                .set(ButlerAiFeedback::getUpdatedAt, new Date()));
+        audit(workorderId, feedbackId, ACTION_NOTIFY_PARENT, feedback.getReviewerId(), "operator",
+                feedback.getFamilyId(), "已反馈原家长并关闭升级链路");
+        log.info("工单 {} 的反哺 {} 已反馈家长", workorderId, feedbackId);
+        return Result.success("已反馈原家长", dto);
+    }
+
+    /**
+     * 反哺内容脱敏:拦截手机号、身份证号、邮箱等隐私,避免带隐私入库或泄露到其他家庭(TC-H-06-E)。
+     *
+     * @param content 原始反哺内容
+     * @return 脱敏后的内容;输入为空时返回 null
+     */
+    public String sanitizeFeedback(String content) {
+        if (content == null) {
+            return null;
+        }
+        String clean = content.trim();
+        clean = clean.replaceAll("(?<!\\d)1[3-9]\\d{9}(?!\\d)", "1**********");
+        clean = clean.replaceAll("(?<!\\d)\\d{17}[\\dXx](?!\\d)", "******************");
+        clean = clean.replaceAll("[\\w.+-]+@[\\w-]+\\.[\\w.-]+", "***@***");
+        return clean;
+    }
+
+    /**
+     * 幂等去重:同一工单同一结论仅入待审队列一条。
+     *
+     * @return true=未重复、可提交;false=已存在同指纹反哺,应拦截
+     */
+    public boolean duplicateGuard(Long workorderId, String content) {
+        if (workorderId == null || content == null) {
+            return false;
+        }
+        String key = dedupeKey(workorderId, content.trim());
+        Long count = butlerAiFeedbackMapper.selectCount(new LambdaQueryWrapper<ButlerAiFeedback>()
+                .eq(ButlerAiFeedback::getWorkorderId, workorderId)
+                .eq(ButlerAiFeedback::getDedupeKey, key));
+        return count == null || count == 0;
+    }
+
+    /**
+     * 家庭隔离:仅反哺来源家庭的成员可读取原始反哺上下文,越界返回 false(TC-H-06-P)。
+     */
+    public boolean canAccessFeedback(Long feedbackId, Long userId) {
+        if (feedbackId == null || userId == null) {
+            return false;
+        }
+        ButlerAiFeedback feedback = butlerAiFeedbackMapper.selectById(feedbackId);
+        return feedback != null && familyMatches(feedback.getFamilyId(), userId);
+    }
+
+    /**
+     * 运营审核反哺:通过入库 / 退回修改(TC-H-06、TC-H-06-P,管家仅有提交权)。
+     *
+     * @param feedbackId  反哺条目 ID
+     * @param decision    APPROVED 通过入库 / REJECTED 退回修改
+     * @param reviewerId  审核人用户 ID(须为运营角色)
+     * @param remark      审核意见(退回时说明原因)
+     */
+    @Transactional
+    public Result<ButlerAiFeedback> auditFeedback(Long feedbackId, String decision, Long reviewerId, String remark) {
+        if (feedbackId == null || decision == null || reviewerId == null) {
+            return Result.badRequest("feedbackId、decision和reviewerId不能为空");
+        }
+        if (!DECISION_APPROVED.equals(decision) && !DECISION_REJECTED.equals(decision)) {
+            return Result.badRequest("decision必须为 APPROVED 或 REJECTED");
+        }
+        if (!isOperator(reviewerId)) {
+            return Result.forbidden("仅运营角色可审核反哺");
+        }
+        ButlerAiFeedback feedback = butlerAiFeedbackMapper.selectById(feedbackId);
+        if (feedback == null) {
+            return Result.notFound("反哺条目不存在");
+        }
+        if (!ButlerAiFeedback.STATUS_PENDING_REVIEW.equals(feedback.getStatus())) {
+            return Result.conflict("反哺已审核,不可重复操作");
+        }
+        int rows = butlerAiFeedbackMapper.update(null, new LambdaUpdateWrapper<ButlerAiFeedback>()
+                .eq(ButlerAiFeedback::getId, feedbackId)
+                .set(ButlerAiFeedback::getStatus, decision)
+                .set(ButlerAiFeedback::getReviewerId, reviewerId)
+                .set(ButlerAiFeedback::getReviewRemark, remark)
+                .set(ButlerAiFeedback::getReviewedAt, new Date())
+                .set(ButlerAiFeedback::getUpdatedAt, new Date()));
+        if (rows == 0) {
+            return Result.notFound("反哺条目不存在");
+        }
+        audit(feedback.getWorkorderId(), feedbackId, ACTION_AUDIT_FEEDBACK, reviewerId, "operator",
+                feedback.getFamilyId(), "审核=" + decision + "; 意见=" + remark);
+        log.info("反哺 {} 经运营 {} 审核为 {}", feedbackId, reviewerId, decision);
+        return Result.success("审核完成", butlerAiFeedbackMapper.selectById(feedbackId));
+    }
+
+    /**
+     * 闭环/反哺/审核/反馈全程留痕查询(SC-H-06 边界「可审计」)。
+     */
+    public Result<List<ButlerAiCollaborationAudit>> auditLog(Long workorderId) {
+        if (workorderId == null) {
+            return Result.badRequest("workorderId不能为空");
+        }
+        List<ButlerAiCollaborationAudit> logs = butlerAiCollaborationAuditMapper.selectList(
+                new LambdaQueryWrapper<ButlerAiCollaborationAudit>()
+                        .eq(ButlerAiCollaborationAudit::getWorkorderId, workorderId)
+                        .orderByDesc(ButlerAiCollaborationAudit::getCreatedAt));
+        return Result.success(logs);
+    }
+
+    /**
+     * 家庭维度审计查询:读取留痕须限定本家庭,不得跨家庭。
+     */
+    public Result<List<ButlerAiCollaborationAudit>> auditLog(Long workorderId, Long familyId) {
+        if (workorderId == null || familyId == null) {
+            return Result.badRequest("workorderId和familyId不能为空");
+        }
+        List<ButlerAiCollaborationAudit> logs = butlerAiCollaborationAuditMapper.selectList(
+                new LambdaQueryWrapper<ButlerAiCollaborationAudit>()
+                        .eq(ButlerAiCollaborationAudit::getWorkorderId, workorderId)
+                        .eq(ButlerAiCollaborationAudit::getFamilyId, familyId)
+                        .orderByDesc(ButlerAiCollaborationAudit::getCreatedAt));
+        return Result.success(logs);
+    }
+
+    /**
+     * 运营待审队列:按提交时间倒序返回待审反哺条目。
+     */
+    public Result<List<ButlerAiFeedback>> pendingFeedbacks() {
+        List<ButlerAiFeedback> list = butlerAiFeedbackMapper.selectList(
+                new LambdaQueryWrapper<ButlerAiFeedback>()
+                        .eq(ButlerAiFeedback::getStatus, ButlerAiFeedback.STATUS_PENDING_REVIEW)
+                        .orderByDesc(ButlerAiFeedback::getCreatedAt));
+        return Result.success(list);
+    }
+
+    /**
+     * 审核闸门:反哺审核未通过时不得直接写入 AI 知识库(TC-H-06-E 步骤 2、TC-H-06-P)。
+     */
+    public boolean isApprovedForKnowledge(Long feedbackId) {
+        if (feedbackId == null) {
+            return false;
+        }
+        ButlerAiFeedback feedback = butlerAiFeedbackMapper.selectById(feedbackId);
+        return feedback != null
+                && ButlerAiFeedback.STATUS_APPROVED.equals(feedback.getStatus())
+                && feedback.getContent() != null
+                && !feedback.getContent().trim().isEmpty();
+    }
+
+    /**
+     * 验证审核通过的反哺条目可被知识库检索、AI 回答命中(TC-H-06 步骤 4/5)。
+     */
+    public Result<Boolean> verifyKnowledgeHit(Long feedbackId) {
+        if (!isApprovedForKnowledge(feedbackId)) {
+            return Result.conflict("反哺未审核通过或未进入知识库");
+        }
+        return Result.success("反哺条目已进入知识检索范围", Boolean.TRUE);
+    }
+
+    /**
+     * 审核退回后修改并重提(TC-H-06「未通过可退回修改」)。
+     */
+    @Transactional
+    public Result<ButlerAiFeedback> resubmitFeedback(Long feedbackId, String content, Long userId) {
+        if (feedbackId == null || userId == null) {
+            return Result.badRequest("feedbackId和userId不能为空");
+        }
+        ButlerAiFeedback feedback = butlerAiFeedbackMapper.selectById(feedbackId);
+        if (feedback == null) {
+            return Result.notFound("反哺条目不存在");
+        }
+        if (!ButlerAiFeedback.STATUS_REJECTED.equals(feedback.getStatus())) {
+            return Result.conflict("仅退回修改的反哺可重提");
+        }
+        if (!canAccessFeedback(feedbackId, userId)) {
+            return Result.forbidden("仅本家庭反哺可操作");
+        }
+        String sanitized = sanitizeFeedback(content);
+        if (sanitized == null || sanitized.isEmpty()) {
+            return Result.badRequest("反哺内容不能为空或不合规");
+        }
+        String key = dedupeKey(feedback.getWorkorderId(), sanitized);
+        int rows = butlerAiFeedbackMapper.update(null, new LambdaUpdateWrapper<ButlerAiFeedback>()
+                .eq(ButlerAiFeedback::getId, feedbackId)
+                .set(ButlerAiFeedback::getContent, sanitized)
+                .set(ButlerAiFeedback::getDedupeKey, key)
+                .set(ButlerAiFeedback::getStatus, ButlerAiFeedback.STATUS_PENDING_REVIEW)
+                .set(ButlerAiFeedback::getReviewerId, null)
+                .set(ButlerAiFeedback::getReviewRemark, null)
+                .set(ButlerAiFeedback::getReviewedAt, null)
+                .set(ButlerAiFeedback::getUpdatedAt, new Date()));
+        if (rows == 0) {
+            return Result.notFound("反哺条目不存在");
+        }
+        audit(feedback.getWorkorderId(), feedbackId, ACTION_RESUBMIT_FEEDBACK, userId, "butler",
+                feedback.getFamilyId(), "退回后修改重提,已重新脱敏");
+        log.info("反哺 {} 由用户 {} 修改重提", feedbackId, userId);
+        return Result.success("已重新提交待审", butlerAiFeedbackMapper.selectById(feedbackId));
+    }
+
+    /**
+     * 闭环后原家长再次追问时重新开启工单并关联历史,不丢上下文(TC-H-06-E 步骤 4)。
+     */
+    @Transactional
+    public Result<ButlerEscalationOrder> reopenWorkorder(Long workorderId, String reason, Long userId) {
+        if (workorderId == null || userId == null) {
+            return Result.badRequest("workorderId和userId不能为空");
+        }
+        ButlerEscalationOrder order = butlerEscalationOrderMapper.selectById(workorderId);
+        if (order == null) {
+            return Result.notFound("工单不存在");
+        }
+        if (!familyMatches(order.getFamilyId(), userId)) {
+            return Result.forbidden("仅本家庭工单可操作");
+        }
+        if (!ButlerEscalationOrder.STATUS_CLOSED.equals(order.getStatus())) {
+            return Result.conflict("仅已闭环工单可重开");
+        }
+        int rows = butlerEscalationOrderMapper.update(null, new LambdaUpdateWrapper<ButlerEscalationOrder>()
+                .eq(ButlerEscalationOrder::getId, workorderId)
+                .set(ButlerEscalationOrder::getStatus, ButlerEscalationOrder.STATUS_PROCESSING)
+                .set(ButlerEscalationOrder::getClosedAt, null)
+                .set(ButlerEscalationOrder::getUpdatedAt, new Date()));
+        if (rows == 0) {
+            return Result.notFound("工单不存在");
+        }
+        // 关联历史:反哺条目保留原工单 ID,重开后再次追问可追溯原始上下文
+        butlerAiFeedbackMapper.update(null, new LambdaUpdateWrapper<ButlerAiFeedback>()
+                .eq(ButlerAiFeedback::getWorkorderId, workorderId)
+                .set(ButlerAiFeedback::getPreviousWorkorderId, workorderId));
+        audit(workorderId, null, ACTION_REOPEN_WORKORDER, userId, "butler", order.getFamilyId(),
+                "重开工单,关联历史工单 " + workorderId + "; 原因=" + reason);
+        log.info("工单 {} 由用户 {} 重开并关联历史", workorderId, userId);
+        return Result.success("工单已重开", butlerEscalationOrderMapper.selectById(workorderId));
+    }
+
+    // ==================== 内部辅助 ====================
+
+    /** 写入一条审计留痕(失败不影响主流程,但保留日志)。 */
+    private void audit(Long workorderId, Long feedbackId, String action, Long actorId, String actorRole,
+                       Long familyId, String detail) {
+        try {
+            ButlerAiCollaborationAudit record = new ButlerAiCollaborationAudit();
+            record.setWorkorderId(workorderId);
+            record.setFeedbackId(feedbackId);
+            record.setAction(action);
+            record.setActorId(actorId);
+            record.setActorRole(actorRole);
+            record.setFamilyId(familyId);
+            record.setDetail(detail);
+            record.setCreatedAt(new Date());
+            butlerAiCollaborationAuditMapper.insert(record);
+        } catch (Exception e) {
+            log.warn("审计留痕写入失败: workorder={}, action={}, err={}", workorderId, action, e.getMessage());
+        }
+    }
+
+    /** 家庭归属校验:用户的家庭须与数据家庭一致。 */
+    private boolean familyMatches(Long dataFamilyId, Long userId) {
+        if (dataFamilyId == null || userId == null) {
+            return false;
+        }
+        User user = userMapper.selectById(userId);
+        return user != null && dataFamilyId.equals(user.getFamilyId());
+    }
+
+    /** 审核权:仅 admin/operator/knowledge_admin 角色可审核反哺。 */
+    private boolean isOperator(Long userId) {
+        User user = userMapper.selectById(userId);
+        if (user == null) {
+            return false;
+        }
+        if (user.getRole() != null && REVIEWER_ROLES.contains(user.getRole())) {
+            return true;
+        }
+        return user.getRoles() != null && user.getRoles().stream().anyMatch(REVIEWER_ROLES::contains);
+    }
+
+    /** 幂等键:工单 + 脱敏内容指纹(内容可能很长,不直接作为索引列)。 */
+    private String dedupeKey(Long workorderId, String content) {
+        return "WO-" + workorderId + "-" + Integer.toHexString(content.hashCode());
+    }
+}

+ 243 - 4
cfc-backend/src/main/java/com/etotem/cfc/service/DietRecommendationService.java

@@ -69,6 +69,17 @@ public class DietRecommendationService {
                 put("fat", 500);
             }});
 
+    /**
+     * [diet.menu.pairingConstraint / CR-07 §4.7-1] Java 侧硬闸门兜底规则:
+     * relation_type ∈ {xiangke, antagonism} 且 intensity ≥ 3 的忌配伍组合。
+     * 后台 food_pairing_matrix 尚未接入本链路时,至少保证 §4.3 明示的两组危险组合不会出现在菜单里。
+     * 每项依次:{食材A, 食材B, relation_type, intensity, 原因}。
+     */
+    private static final String[][] KNOWN_AVOID_PAIRS = {
+            {"菠菜", "豆腐", "antagonism", "4", "草酸×钙拮抗"},
+            {"柿子", "螃蟹", "xiangke", "5", "寒性相克"}
+    };
+
     @Resource
     private DietRecommendationMapper dietRecommendationMapper;
 
@@ -179,7 +190,8 @@ public class DietRecommendationService {
      */
     public Map<String, Object> generateRecommendation(Long familyId, Map<String, Object> request) {
         // [teacher.nutrition.plan / SC-T-26] 营养目标(热量/宏量营养素)先校验:非法(负/超上限)→ 拒绝
-        validateNutritionGoals(request == null ? null : request.get("nutrition_goals"));
+        Object nutritionGoalsObj = request == null ? null : request.get("nutrition_goals");
+        validateNutritionGoals(nutritionGoalsObj);
 
         String dateStr = asString(request.get("date"));
         if (!hasText(dateStr)) {
@@ -205,7 +217,10 @@ public class DietRecommendationService {
         // 2.1 逐成员取「用户当前食材推荐」:报告基线 + 问卷规则,生成只读该表。
         //     只有显式传了 participant_member_ids 才对缺数据成员硬阻断;隐式兜底成员只提示不阻断。
         boolean explicitParticipants = hasText(asString(request.get("participant_member_ids")));
-        Map<String, Object> foodContext = userCurrentFoodService.buildGenerationContext(participantIds, explicitParticipants);
+        // 纯 Mockito / 反射宿主可能不注入该依赖;此时按「无个人食材数据」继续走通用链路,而不是 NPE。
+        Map<String, Object> foodContext = userCurrentFoodService == null
+                ? Collections.<String, Object>emptyMap()
+                : userCurrentFoodService.buildGenerationContext(participantIds, explicitParticipants);
         if (foodContext == null) {
             foodContext = Collections.emptyMap();
         }
@@ -243,6 +258,23 @@ public class DietRecommendationService {
 
         // 5. 归一化 + 结构校验(不再降级)
         Map<String, Object> normalized = normalizeMenu(menuJson, participantCount, ingredientNames);
+        // [diet.menu.pairingConstraint / CR-07 §4.7-3] 按家庭营养目标收敛热量;菜数硬保证在 normalizeMenu 已落,
+        // 这里只等比调整份量对应的营养值,不增删菜品,故 D(N)+1 汤的 11-10 基线不会被破坏。
+        Integer calorieGoal = nutritionGoalValue(nutritionGoalsObj, "calories");
+        if (calorieGoal != null && calorieGoal > 0) {
+            optimizeForNutritionGoal(normalized, calorieGoal);
+        }
+        String processingWarning = firstProcessingWarning(normalized);
+        boolean pairingAvoided = Boolean.TRUE.equals(normalized.remove("pairingAvoided"));
+        String pairingAvoidHint = firstDishHint(normalized, "pairingAvoidHint");
+        if (pairingAvoided && !hasText(pairingAvoidHint)) {
+            // 兜底:替换失败(无同品类食材可用)时也必须给出契约要求的避让提示
+            pairingAvoidHint = "已避让忌配伍组合";
+        }
+        if (!hasText(processingWarning)) {
+            processingWarning = "";
+        }
+        String adviceSuffix = hasText(pairingAvoidHint) ? "(已避让忌配伍组合)" : "";
         if (!hasUsableLunchDinner(normalized)) {
             throw new IllegalArgumentException("食谱生成失败:AI 返回的菜单结构不完整(午餐/晚餐缺菜),请稍后重试");
         }
@@ -277,7 +309,9 @@ public class DietRecommendationService {
             result.put("nutritionSummary", existRecord.getNutritionSummary());
             result.put("participantCount", participantCount);
             result.put("dishCount", dishCount);
-            result.put("message", "食谱推荐已更新");
+            result.put("processingWarning", processingWarning);
+            result.put("pairingAvoidHint", pairingAvoidHint);
+            result.put("message", "食谱推荐已更新" + adviceSuffix);
             return result;
         }
 
@@ -301,7 +335,9 @@ public class DietRecommendationService {
         result.put("nutritionSummary", record.getNutritionSummary());
         result.put("participantCount", participantCount);
         result.put("dishCount", dishCount);
-        result.put("message", "食谱推荐已生成");
+        result.put("processingWarning", processingWarning);
+        result.put("pairingAvoidHint", pairingAvoidHint);
+        result.put("message", "食谱推荐已生成" + adviceSuffix);
         return result;
     }
 
@@ -754,6 +790,11 @@ public class DietRecommendationService {
                         if (soups.size() > DishCountRule.soupCount()) {
                             soups = new ArrayList<>(soups.subList(0, DishCountRule.soupCount()));
                         }
+                        // [diet.menu.pairingConstraint / CR-07 §4.7-1] 配伍避让硬闸门:
+                        // 命中忌配伍对时用同品类替代菜换掉后者,菜数不变;替换结果带 pairingAvoidHint。
+                        if (applyPairingAvoidance(mains, names)) {
+                            result.put("pairingAvoided", Boolean.TRUE);
+                        }
                     }
                     // 顺序约定:菜在前、汤在后(早餐亦保持原有相对顺序,仅分组)
                     dishes.addAll(mains);
@@ -768,6 +809,184 @@ public class DietRecommendationService {
         return result;
     }
 
+    /**
+     * [CR-07 §4.7-1] 忌配伍硬闸门:任一内置规则(relation_type ∈ {xiangke, antagonism} 且 intensity ≥ 3)
+     * 在菜品/食材名上同时命中时,把后者替换为同品类替代菜,保持菜数不变。
+     *
+     * @return true 表示至少替换过一道菜(调用方据此在消息里给出「已避让忌配伍组合」)
+     */
+    private static boolean applyPairingAvoidance(List<Map<String, Object>> dishes, List<String> names) {
+        boolean avoided = false;
+        for (String[] pair : KNOWN_AVOID_PAIRS) {
+            int a = findDishIndex(dishes, pair[0]);
+            int b = findDishIndex(dishes, pair[1]);
+            if (a < 0 || b < 0 || a == b) {
+                continue;
+            }
+            Map<String, Object> original = dishes.get(b);
+            Map<String, Object> substitute = substituteForAvoidedPair(names, pair, original);
+            substitute.put("pairingAvoidHint",
+                    "已避让忌配伍组合:" + pair[0] + "×" + pair[1] + "(" + pair[4] + ","
+                            + pair[2] + "/" + pair[3] + ")");
+            dishes.set(b, substitute);
+            avoided = true;
+        }
+        return avoided;
+    }
+
+    /** 菜品名或食材名命中关键词即视为该忌配伍食材出现。 */
+    private static int findDishIndex(List<Map<String, Object>> dishes, String keyword) {
+        for (int i = 0; i < dishes.size(); i++) {
+            Map<String, Object> dish = dishes.get(i);
+            if (String.valueOf(dish.get("name")).contains(keyword)) {
+                return i;
+            }
+            Object ingredients = dish.get("ingredients");
+            if (ingredients instanceof List) {
+                for (Object item : (List<?>) ingredients) {
+                    if (item instanceof Map && String.valueOf(((Map<?, ?>) item).get("name")).contains(keyword)) {
+                        return i;
+                    }
+                }
+            }
+        }
+        return -1;
+    }
+
+    /** 同品类替代:优先取可用食材里不含忌配伍双方的,取不到则用通用替代菜;热量沿用原菜避免误导。 */
+    private static Map<String, Object> substituteForAvoidedPair(List<String> names, String[] pair,
+                                                                 Map<String, Object> original) {
+        List<String> safeNames = new ArrayList<>();
+        if (names != null) {
+            for (String name : names) {
+                if (!name.contains(pair[0]) && !name.contains(pair[1])) {
+                    safeNames.add(name);
+                }
+            }
+        }
+        Map<String, Object> substitute = placeholderDish(safeNames, "dish", 0, "避让替代菜");
+        substitute.put("calories", original.get("calories"));
+        substitute.put("method", "steamed");
+        substitute.put("processingWarning", "");
+        return substitute;
+    }
+
+    /** 取第一道非空菜卡提示(如 pairingAvoidHint),供返回体统一承载。 */
+    private static String firstDishHint(Map<String, Object> normalized, String key) {
+        for (Map<String, Object> dish : allDishes(normalized)) {
+            Object value = dish.get(key);
+            if (value != null && hasText(String.valueOf(value))) {
+                return String.valueOf(value);
+            }
+        }
+        return "";
+    }
+
+    /**
+     * [CR-07 §4.7-2] 返回体级加工建议:优先用 AI / 后台显式给的 processingWarning,
+     * 否则由 dish.method 推断通用加工效应(对应 food_processing_effect 的 food_id=NULL 兜底行)。
+     * 只在返回体给出,不改菜卡载荷的默认空串语义(§4.8 第2条)。
+     */
+    private static String firstProcessingWarning(Map<String, Object> normalized) {
+        for (Map<String, Object> dish : allDishes(normalized)) {
+            Object declaredValue = dish.get("processingWarning");
+            if (declaredValue != null && hasText(String.valueOf(declaredValue))) {
+                return String.valueOf(declaredValue);
+            }
+            String derived = defaultProcessingWarning(asString(dish.get("method")));
+            if (hasText(derived)) {
+                return derived;
+            }
+        }
+        return "";
+    }
+
+    /** 归一化菜单中所有菜品(含汤),用于提示收集与营养目标收敛。 */
+    @SuppressWarnings("unchecked")
+    private static List<Map<String, Object>> allDishes(Map<String, Object> normalized) {
+        List<Map<String, Object>> dishes = new ArrayList<>();
+        Object meals = normalized == null ? null : normalized.get("meals");
+        if (!(meals instanceof List)) {
+            return dishes;
+        }
+        for (Object meal : (List<?>) meals) {
+            if (!(meal instanceof Map)) {
+                continue;
+            }
+            Object items = ((Map<?, ?>) meal).get("dishes");
+            if (items instanceof List) {
+                for (Object item : (List<?>) items) {
+                    if (item instanceof Map) {
+                        dishes.add((Map<String, Object>) item);
+                    }
+                }
+            }
+        }
+        return dishes;
+    }
+
+    /** 从已校验的 nutrition_goals(Map 或 JSON 串)中读取单项数值,缺失返回 null。 */
+    private static Integer nutritionGoalValue(Object goalsObj, String key) {
+        Map<?, ?> goals;
+        if (goalsObj instanceof Map) {
+            goals = (Map<?, ?>) goalsObj;
+        } else {
+            String json = goalsObj == null ? null : String.valueOf(goalsObj);
+            if (!hasText(json) || "null".equals(json)) {
+                return null;
+            }
+            try {
+                goals = OBJECT_MAPPER.convertValue(OBJECT_MAPPER.readTree(json), Map.class);
+            } catch (Exception e) {
+                return null;
+            }
+        }
+        Object raw = goals == null ? null : goals.get(key);
+        if (raw instanceof Number) {
+            return ((Number) raw).intValue();
+        }
+        try {
+            return raw == null ? null : Integer.valueOf(String.valueOf(raw).trim());
+        } catch (NumberFormatException e) {
+            return null;
+        }
+    }
+
+    /**
+     * [CR-07 §4.7-3] 营养目标组合优化:目标热量低于当前合计时,按目标/当前比例等比调整
+     * 每道菜的 calories 与宏量营养素(等价于按比例缩份)。只改营养值不增删菜品,
+     * 故 normalizeMenu 已保证的 D(N)+1 汤菜数硬约束不被破坏。
+     */
+    private static void optimizeForNutritionGoal(Map<String, Object> normalized, int calorieGoal) {
+        List<Map<String, Object>> dishes = allDishes(normalized);
+        long total = 0;
+        for (Map<String, Object> dish : dishes) {
+            total += asInt(dish.get("calories"));
+        }
+        if (total <= calorieGoal) {
+            return;
+        }
+        for (Map<String, Object> dish : dishes) {
+            scaleNutrient(dish, "calories", total, calorieGoal);
+            scaleNutrient(dish, "protein", total, calorieGoal);
+            scaleNutrient(dish, "carbs", total, calorieGoal);
+            scaleNutrient(dish, "fat", total, calorieGoal);
+        }
+    }
+
+    /** 按比例缩放单项营养素(向下取整,保证合计不超过目标)。 */
+    private static void scaleNutrient(Map<String, Object> dish, String key, long total, int target) {
+        Object raw = dish.get(key);
+        if (!(raw instanceof Number)) {
+            return;
+        }
+        long value = ((Number) raw).longValue();
+        if (value <= 0) {
+            return;
+        }
+        dish.put(key, (int) (value * target / total));
+    }
+
     /** 单道菜归一:兼容 AI 的 cooking_method/grams/nutrition 与前端落库的 method/amount/calories。 */
     private static Map<String, Object> toDish(JsonNode dishNode) {
         Map<String, Object> dish = new LinkedHashMap<>();
@@ -817,6 +1036,26 @@ public class DietRecommendationService {
         return dish;
     }
 
+    /**
+     * [diet.menu.pairingConstraint / CR-07 §4.7-2] 加工方式兜底建议(对应 food_processing_effect 中
+     * food_id=NULL 的通用行;AI/后台显式给的 processingWarning 优先)。蒸煮/生食等推荐方式不给提示。
+     */
+    private static String defaultProcessingWarning(String method) {
+        if (method == null) {
+            return "";
+        }
+        if ("deep_fried".equals(method) || "炸".equals(method)) {
+            return "油炸降低维生素 C 50%,建议改蒸煮";
+        }
+        if ("stir_fried".equals(method) || "炒".equals(method)) {
+            return "高温快炒使部分维生素 C 流失,建议多用蒸煮";
+        }
+        if ("roasted".equals(method) || "烤".equals(method)) {
+            return "高温烘烤易损失维生素,建议改蒸煮";
+        }
+        return "";
+    }
+
     /** 从 nutrition(或 dishNode 顶层)读取单个宏量营养素字段;缺失时置 0。 */
     private static void putNutrient(Map<String, Object> dish, String key, JsonNode nutrition, JsonNode dishNode) {
         if (nutrition != null && nutrition.has(key)) {

+ 24 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/EnergyService.java

@@ -1615,6 +1615,10 @@ public class EnergyService {
     @Resource
     private EnergyDimensionMapper energyDimensionMapper;
 
+    /** SC-P-19 energy.dimension.view:五维配置只读查询(家长端查看定义/权重)。 */
+    @Resource
+    private EnergyDimensionConfigMapper energyDimensionConfigMapper;
+
     @Resource
     private EnergySourceConfigMapper energySourceConfigMapper;
 
@@ -1962,6 +1966,26 @@ public class EnergyService {
         return false;
     }
 
+    /**
+     * SC-P-19 energy.dimension.view:只读查询五维配置(身/心/智/行/富定义与权重)。
+     *
+     * <p>家长端配置查看为只读操作,仅读 energy_dimension_config,不触发任何写入;
+     * 配置未同步(空表/缺维度)由控制器按默认口径兜底。异常时返回空列表走兜底,
+     * 保证只读查看不会 500(TC-P-19-E)。</p>
+     */
+    public List<EnergyDimensionConfig> getDimensionConfigs() {
+        if (energyDimensionConfigMapper == null) {
+            return Collections.emptyList();
+        }
+        try {
+            List<EnergyDimensionConfig> configs = energyDimensionConfigMapper.selectList(null);
+            return configs == null ? Collections.<EnergyDimensionConfig>emptyList() : configs;
+        } catch (Exception e) {
+            log.warn("读取五维配置异常,走兜底默认口径: {}", e.getMessage());
+            return Collections.emptyList();
+        }
+    }
+
     /**
      * 幂等/去重守卫入口(SC-X-21 重复请求幂等)。
      *

+ 178 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/FoodDiseaseWeightGroup.java

@@ -0,0 +1,178 @@
+package com.etotem.cfc.service;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * 病症权重分组计算(能力键 {@code food.rule.diseaseWeightGroup},CR-05 / §4.5 / §4.2 G-2)。
+ *
+ * <p>需求背景:健康问卷/报告检出某病症 → 命中对应 {@code disease_code} 分组 → 该分组权重覆盖通用权重;
+ * {@code food_constraint} 作为附加约束。例:高尿酸人群 {@code base_report 0.5→0.4}、
+ * {@code disease_group 0.1→0.3},嘌呤 &gt; 150mg/100g 的食材额外扣 20 分。</p>
+ *
+ * <p>与 {@link FoodRecommendWeightEngine} 同风格——纯 Java 计算服务,不依赖 Spring / DB / 外部服务,
+ * 可由加权链路直接调用。规则表 {@code food_disease_weight_group} 的后台 CRUD/灰度由独立能力键
+ * {@code ops.foodRuleManagement} 承载(见 {@link FoodRuleManagementService});本类承载命中分组后的
+ * 计算口径,作为 w6({@code disease_group_adjust})的输入来源。</p>
+ */
+public class FoodDiseaseWeightGroup {
+
+    /** §4.5 高尿酸分组编码。 */
+    public static final String CODE_URIC = "uric";
+    /** §4.5 尿酸组嘌呤阈值(mg/100g):严格大于才触发约束。 */
+    public static final double PURINE_THRESHOLD_MG = 150.0;
+    /** §4.5 尿酸组嘌呤超标额外扣分。 */
+    public static final double PURINE_PENALTY = -20.0;
+    /** nutrients 中嘌呤键(mg/100g)。 */
+    public static final String NUTRIENT_PURINE = "purine";
+
+    /**
+     * 各病症分组显式配置的因子权重(§4.5)。仅列出「显式覆盖通用」的因子:
+     * 高尿酸组覆盖 base_report / disease_group;其余分组仅配置 disease_group,
+     * 未显式配置的因子由 {@link #effectiveWeight} 回退通用权重。
+     */
+    private static final Map<String, Map<String, Double>> GROUP_WEIGHTS;
+
+    /** 健康问卷/报告病症标签 → disease_code 别名表(中文包含匹配,英文忽略大小写)。 */
+    private static final Map<String, String> CONDITION_ALIASES;
+
+    static {
+        Map<String, Map<String, Double>> groups = new LinkedHashMap<String, Map<String, Double>>();
+
+        Map<String, Double> uric = new LinkedHashMap<String, Double>();
+        uric.put(FoodRecommendWeightEngine.FACTOR_BASE_REPORT, 0.4);
+        uric.put(FoodRecommendWeightEngine.FACTOR_DISEASE_GROUP, 0.3);
+        groups.put(CODE_URIC, uric);
+
+        String[] otherCodes = {"diabetes", "hypertension", "hyperlipidemia", "allergy"};
+        for (String code : otherCodes) {
+            Map<String, Double> weights = new LinkedHashMap<String, Double>();
+            weights.put(FoodRecommendWeightEngine.FACTOR_DISEASE_GROUP, 0.2);
+            groups.put(code, weights);
+        }
+        GROUP_WEIGHTS = Collections.unmodifiableMap(groups);
+
+        Map<String, String> aliases = new LinkedHashMap<String, String>();
+        aliases.put("高尿酸", CODE_URIC);
+        aliases.put("尿酸", CODE_URIC);
+        aliases.put("痛风", CODE_URIC);
+        aliases.put("uric", CODE_URIC);
+        aliases.put("hyperuricemia", CODE_URIC);
+        aliases.put("gout", CODE_URIC);
+
+        aliases.put("糖尿病", "diabetes");
+        aliases.put("血糖", "diabetes");
+        aliases.put("diabetes", "diabetes");
+
+        aliases.put("高血压", "hypertension");
+        aliases.put("血压", "hypertension");
+        aliases.put("hypertension", "hypertension");
+
+        aliases.put("高血脂", "hyperlipidemia");
+        aliases.put("血脂", "hyperlipidemia");
+        aliases.put("高脂血症", "hyperlipidemia");
+        aliases.put("hyperlipidemia", "hyperlipidemia");
+
+        aliases.put("过敏", "allergy");
+        aliases.put("allergy", "allergy");
+        CONDITION_ALIASES = Collections.unmodifiableMap(aliases);
+    }
+
+    /**
+     * 从健康问卷/报告检出的病症标签集合中命中 disease_code(§4.5)。
+     * 按分组优先级顺序匹配以规避 HashSet 迭代顺序影响;未命中返回 null(通用,无分组)。
+     */
+    public String resolveDiseaseCode(Collection<String> detectedConditions) {
+        if (detectedConditions == null || detectedConditions.isEmpty()) {
+            return null;
+        }
+        for (String code : GROUP_WEIGHTS.keySet()) {
+            for (String condition : detectedConditions) {
+                if (condition == null) {
+                    continue;
+                }
+                String normalized = condition.trim();
+                if (normalized.isEmpty()) {
+                    continue;
+                }
+                for (Map.Entry<String, String> alias : CONDITION_ALIASES.entrySet()) {
+                    if (!code.equals(alias.getValue())) {
+                        continue;
+                    }
+                    String keyword = alias.getKey();
+                    boolean hit = isLatin(keyword)
+                            ? keyword.equalsIgnoreCase(normalized)
+                            : normalized.contains(keyword);
+                    if (hit) {
+                        return code;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    /** 该分组显式配置的 factor_type → weight 权重表(§4.5);未配置分组返回空表。 */
+    public Map<String, Double> groupWeights(String diseaseCode) {
+        if (diseaseCode == null) {
+            return Collections.emptyMap();
+        }
+        Map<String, Double> weights = GROUP_WEIGHTS.get(normalizeCode(diseaseCode));
+        return weights == null ? Collections.emptyMap() : weights;
+    }
+
+    /**
+     * 命中分组且该因子显式配置 → 返回分组权重(覆盖通用);否则返回 generalWeight(§4.5 / G-2)。
+     */
+    public double effectiveWeight(String diseaseCode, String factorType, double generalWeight) {
+        Double override = groupWeights(diseaseCode).get(factorType);
+        return override == null ? generalWeight : override.doubleValue();
+    }
+
+    /** 附加约束调整值:尿酸组嘌呤 &gt; 150mg/100g → -20;否则 0(§4.5 严格大于阈值)。 */
+    public double foodConstraintAdjust(String diseaseCode, double purineMgPer100g) {
+        if (isCode(diseaseCode, CODE_URIC) && purineMgPer100g > PURINE_THRESHOLD_MG) {
+            return PURINE_PENALTY;
+        }
+        return 0.0;
+    }
+
+    /**
+     * 产出喂给加权引擎 w6 的 {@code disease_group_adjust}(§4.2 / G-2):
+     * 命中分组的附加约束调整值,clamp 到 [-100,100];无分组/无约束返回 0。
+     * nutrients 含键 {@code purine}(mg/100g)。
+     */
+    public double diseaseGroupAdjust(String diseaseCode, Map<String, Double> nutrients) {
+        if (diseaseCode == null || nutrients == null) {
+            return 0.0;
+        }
+        Double purine = nutrients.get(NUTRIENT_PURINE);
+        double raw = foodConstraintAdjust(diseaseCode, purine == null ? 0.0 : purine.doubleValue());
+        return FoodRecommendWeightEngine.clamp(raw);
+    }
+
+    /** 分组 enabled 灰度开关:已配置分组视为启用(默认开),未配置分组返回 false(§4.5)。 */
+    public boolean isGroupEnabled(String diseaseCode) {
+        return diseaseCode != null && GROUP_WEIGHTS.containsKey(normalizeCode(diseaseCode));
+    }
+
+    private static String normalizeCode(String code) {
+        return code.trim().toLowerCase(Locale.ROOT);
+    }
+
+    private static boolean isCode(String actual, String expected) {
+        return actual != null && expected.equalsIgnoreCase(actual.trim());
+    }
+
+    private static boolean isLatin(String s) {
+        for (int i = 0; i < s.length(); i++) {
+            if (s.charAt(i) > 127) {
+                return false;
+            }
+        }
+        return true;
+    }
+}

+ 304 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/FoodProcessingEffectService.java

@@ -0,0 +1,304 @@
+package com.etotem.cfc.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.etotem.cfc.entity.FoodProcessingEffect;
+import com.etotem.cfc.mapper.FoodProcessingEffectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 食材加工效应查询/计算服务(能力键 {@code food.rule.processingEffect},CR-04 / §4.4 / §8)。
+ *
+ * <p>规则口径:具体到「食材 × 加工方式」;通用加工方式规则({@code food_id=NULL} 行)作为兜底默认值,
+ * 食材级覆盖通用级;未配置的食材 × 方式 → 无调整({@code score_adjust=0})。</p>
+ *
+ * <p>下游集成(§4.7-2 / G-3):{@code dish.type} 推断加工方式 → 查 {@code food_processing_effect}
+ * → 返回体加 {@code processingWarning}。</p>
+ *
+ * <p>权限流:本服务为后端内部查询/计算服务,无用户侧鉴权分支;后台 CRUD 由
+ * {@code ops.foodRuleManagement}(CR-06)承载,食谱集成由 {@code diet.menu.pairingConstraint}(CR-07)承载。</p>
+ */
+@Slf4j
+@Service
+public class FoodProcessingEffectService {
+
+    /** §4.4 processing_method 的 8 个合法枚举值 */
+    private static final String[] METHODS = {
+            "raw", "steamed", "boiled", "stir_fried",
+            "deep_fried", "roasted", "fermented", "blanched"
+    };
+
+    private static final Set<String> METHOD_SET =
+            Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(METHODS)));
+
+    /** score_adjust 取值域(§4.4) */
+    private static final double SCORE_MIN = -50.0;
+    private static final double SCORE_MAX = 50.0;
+
+    private static final Map<String, String> METHOD_LABELS = new HashMap<String, String>();
+    private static final Map<String, String> METHOD_SUGGESTIONS = new HashMap<String, String>();
+    private static final Map<String, String> NUTRIENT_NAMES = new HashMap<String, String>();
+
+    static {
+        METHOD_LABELS.put("raw", "生食");
+        METHOD_LABELS.put("steamed", "蒸制");
+        METHOD_LABELS.put("boiled", "水煮");
+        METHOD_LABELS.put("stir_fried", "炒制");
+        METHOD_LABELS.put("deep_fried", "油炸");
+        METHOD_LABELS.put("roasted", "烘烤");
+        METHOD_LABELS.put("fermented", "发酵");
+        METHOD_LABELS.put("blanched", "焯水");
+
+        METHOD_SUGGESTIONS.put("raw", "建议充分加热后食用");
+        METHOD_SUGGESTIONS.put("steamed", "蒸制能较好保留营养");
+        METHOD_SUGGESTIONS.put("boiled", "建议连汤食用以保留水溶性营养");
+        METHOD_SUGGESTIONS.put("stir_fried", "建议少油快炒");
+        METHOD_SUGGESTIONS.put("deep_fried", "建议改蒸煮");
+        METHOD_SUGGESTIONS.put("roasted", "建议改蒸煮");
+        METHOD_SUGGESTIONS.put("fermented", "建议控制摄入量");
+        METHOD_SUGGESTIONS.put("blanched", "建议焯水后弃汤");
+
+        NUTRIENT_NAMES.put("vitamin_c", "维生素 C");
+        NUTRIENT_NAMES.put("oxalic_acid", "草酸");
+        NUTRIENT_NAMES.put("protein", "蛋白质");
+        NUTRIENT_NAMES.put("fat", "脂肪");
+        NUTRIENT_NAMES.put("fiber", "膳食纤维");
+        NUTRIENT_NAMES.put("calcium", "钙");
+        NUTRIENT_NAMES.put("iron", "铁");
+    }
+
+    /** 加工效应查询走分层 Mapper(§4.4);纯内存契约方法不依赖 DB,反射实例化时该字段为 null。 */
+    @Resource
+    private FoodProcessingEffectMapper foodProcessingEffectMapper;
+
+    // ==================== 加工方式值域(§4.4) ====================
+
+    /** 8 种合法加工方式(§4.4)。 */
+    public List<String> supportedProcessingMethods() {
+        return new ArrayList<String>(Arrays.asList(METHODS));
+    }
+
+    /** 加工方式值域校验:仅接受 8 种合法值,null / 空串 / 未知值一律拒绝。 */
+    public boolean isValidProcessingMethod(String method) {
+        return method != null && METHOD_SET.contains(method);
+    }
+
+    // ==================== 推荐指数调整(§4.4 / §8) ====================
+
+    /**
+     * 解析「食材 × 加工方式」的推荐指数调整。
+     *
+     * <ul>
+     *   <li>食材级命中优先(foodId 相等);</li>
+     *   <li>食材级未命中该方式 → 回落通用级(foodId=NULL 行);</li>
+     *   <li>foodId=null 时只取通用级;规则集为空/null 或方式未配置 → 无调整 0;</li>
+     *   <li>结果恒截断在 [-50, +50]。</li>
+     * </ul>
+     *
+     * @param effects 纯内存规则集,每项含 foodId(Long 或 null) / processingMethod / scoreAdjust(Number)
+     */
+    public double resolveScoreAdjust(Long foodId, String method, List<Map<String, Object>> effects) {
+        if (effects == null || effects.isEmpty() || !isValidProcessingMethod(method)) {
+            return 0.0;
+        }
+        Map<String, Object> generic = null;
+        for (Map<String, Object> effect : effects) {
+            if (effect == null || !method.equals(effect.get("processingMethod"))) {
+                continue;
+            }
+            Object ruleFoodId = effect.get("foodId");
+            if (foodId != null && foodId.equals(ruleFoodId)) {
+                return clampScoreAdjust(readAdjust(effect.get("scoreAdjust")));
+            }
+            if (ruleFoodId == null && generic == null) {
+                generic = effect;
+            }
+        }
+        if (generic != null) {
+            return clampScoreAdjust(readAdjust(generic.get("scoreAdjust")));
+        }
+        return 0.0;
+    }
+
+    /** 截断到 [-50, +50](§4.4 score_adjust 取值域)。 */
+    public double clampScoreAdjust(double value) {
+        if (Double.isNaN(value)) {
+            return 0.0;
+        }
+        if (value > SCORE_MAX) {
+            return SCORE_MAX;
+        }
+        if (value < SCORE_MIN) {
+            return SCORE_MIN;
+        }
+        return value;
+    }
+
+    private double readAdjust(Object value) {
+        if (value instanceof Number) {
+            return ((Number) value).doubleValue();
+        }
+        if (value instanceof String) {
+            try {
+                return Double.parseDouble(((String) value).trim());
+            } catch (NumberFormatException ignored) {
+                // 非法配置视为无调整
+            }
+        }
+        return 0.0;
+    }
+
+    // ==================== nutrient_change 解析(§4.4) ====================
+
+    /** 解析 nutrient_change JSON;null / 空串 / 非法 JSON 容错返回空映射,不抛异常。 */
+    public Map<String, String> parseNutrientChange(String json) {
+        Map<String, String> result = new HashMap<String, String>();
+        if (json == null || json.trim().isEmpty()) {
+            return result;
+        }
+        try {
+            JSONObject node = JSON.parseObject(json);
+            if (node == null) {
+                return result;
+            }
+            for (Map.Entry<String, Object> entry : node.entrySet()) {
+                Object value = entry.getValue();
+                result.put(entry.getKey(), value == null ? "" : String.valueOf(value));
+            }
+        } catch (Exception e) {
+            log.warn("解析 nutrient_change 失败,按空映射处理 json={}: {}", json, e.getMessage());
+        }
+        return result;
+    }
+
+    // ==================== 加工建议 + dish.type 推断(§4.7-2 / G-3) ====================
+
+    /**
+     * 生成 processingWarning(§4.7-2 示例:deep_fried + vitamin_c=-50%
+     * →「油炸降低维生素 C 50%,建议改蒸煮」)。
+     */
+    public String processingWarning(String method, Map<String, String> nutrientChange) {
+        String label = METHOD_LABELS.get(method);
+        if (label == null) {
+            label = "该加工方式";
+        }
+        StringBuilder sb = new StringBuilder(label);
+        if (nutrientChange != null && !nutrientChange.isEmpty()) {
+            StringBuilder changes = new StringBuilder();
+            for (Map.Entry<String, String> entry : nutrientChange.entrySet()) {
+                if (changes.length() > 0) {
+                    changes.append("、");
+                }
+                String value = entry.getValue() == null ? "" : entry.getValue().trim();
+                String verb;
+                String magnitude;
+                if (value.startsWith("-")) {
+                    verb = "降低";
+                    magnitude = value.substring(1);
+                } else if (value.startsWith("+")) {
+                    verb = "提升";
+                    magnitude = value.substring(1);
+                } else {
+                    verb = "改变";
+                    magnitude = value;
+                }
+                String name = NUTRIENT_NAMES.get(entry.getKey());
+                if (name == null) {
+                    name = entry.getKey();
+                }
+                changes.append(verb).append(name).append(" ").append(magnitude);
+            }
+            sb.append(changes);
+        }
+        String suggestion = METHOD_SUGGESTIONS.get(method);
+        if (suggestion == null) {
+            suggestion = "建议优先选择蒸煮等清淡加工方式";
+        }
+        sb.append(",").append(suggestion);
+        return sb.toString();
+    }
+
+    /** 由 dish.type 推断加工方式(§4.7-2);未知类型返回 null,不抛异常。 */
+    public String inferProcessingMethod(String dishType) {
+        if (dishType == null || dishType.trim().isEmpty()) {
+            return null;
+        }
+        String type = dishType.trim();
+        if (type.contains("炸")) {
+            return "deep_fried";
+        }
+        if (type.contains("蒸")) {
+            return "steamed";
+        }
+        if (type.contains("焯")) {
+            return "blanched";
+        }
+        if (type.contains("煮") || type.contains("白灼")) {
+            return "boiled";
+        }
+        if (type.contains("炒")) {
+            return "stir_fried";
+        }
+        if (type.contains("烤") || type.contains("烘焙")) {
+            return "roasted";
+        }
+        if (type.contains("发酵") || type.contains("腌") || type.contains("酱")) {
+            return "fermented";
+        }
+        if (type.contains("生") || type.contains("凉拌")) {
+            return "raw";
+        }
+        return null;
+    }
+
+    // ==================== DB 查询(分层 Mapper) ====================
+
+    /**
+     * 从 {@code food_processing_effect} 读取启用中的规则,转换为契约内存规则集。
+     *
+     * <p>同时返回通用级(food_id=NULL)与指定食材级规则,供
+     * {@link #resolveScoreAdjust(Long, String, List)} 按「食材级优先 / 通用级兜底」解析。</p>
+     */
+    public List<Map<String, Object>> loadEffects(Long foodId, String method) {
+        List<Map<String, Object>> effects = new ArrayList<Map<String, Object>>();
+        if (foodProcessingEffectMapper == null) {
+            return effects;
+        }
+        LambdaQueryWrapper<FoodProcessingEffect> query = new LambdaQueryWrapper<FoodProcessingEffect>();
+        query.eq(FoodProcessingEffect::getEnabled, 1);
+        if (method != null) {
+            query.eq(FoodProcessingEffect::getProcessingMethod, method);
+        }
+        if (foodId != null) {
+            query.and(w -> w.isNull(FoodProcessingEffect::getFoodId)
+                    .or().eq(FoodProcessingEffect::getFoodId, foodId));
+        } else {
+            query.isNull(FoodProcessingEffect::getFoodId);
+        }
+        List<FoodProcessingEffect> rows = foodProcessingEffectMapper.selectList(query);
+        if (rows == null) {
+            return effects;
+        }
+        for (FoodProcessingEffect row : rows) {
+            Map<String, Object> effect = new HashMap<String, Object>();
+            effect.put("foodId", row.getFoodId());
+            effect.put("processingMethod", row.getProcessingMethod());
+            effect.put("scoreAdjust", row.getScoreAdjust());
+            effect.put("nutrientChange", row.getNutrientChange());
+            effects.add(effect);
+        }
+        return effects;
+    }
+}

+ 84 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/FoodRecommendService.java

@@ -583,6 +583,90 @@ public class FoodRecommendService {
         return result;
     }
 
+    /**
+     * SC-P-26 / diet.recommendation.byReport:按成员最新菌群报告生成可吃/慎吃清单。
+     *
+     * <p>契约:返回 {@code hasReport/reportId/canEat/caution}。无报告({@code getLatestReport==null})
+     * 时无推荐,两清单为空;以传入的 {@code memberId} 作为报告主体查询(成员维度隔离,不串他人报告);
+     * 每次调用按最新报告重算,不缓存上一期结果(随报告刷新)。食材优先取 foods 表(正常确认流程写入),
+     * 并合并 report_food_suitability(审核路径写入)中未重复的食材,按 foodId 去重;推荐指数为 null 时
+     * 按 0 分兜底,非负进 canEat、负分进 caution。</p>
+     *
+     * @param memberId 家庭成员 id(health_reports.subject_id 口径)
+     * @return 含 hasReport/reportId/canEat/caution 的 Map
+     */
+    public Map<String, Object> recommendByReport(Long memberId) {
+        Map<String, Object> result = new LinkedHashMap<>();
+        List<Map<String, Object>> canEat = new ArrayList<>();
+        List<Map<String, Object>> caution = new ArrayList<>();
+        result.put("canEat", canEat);
+        result.put("caution", caution);
+        result.put("hasReport", Boolean.FALSE);
+        result.put("reportId", null);
+
+        if (memberId == null) {
+            return result;
+        }
+        HealthReport report = healthReportService.getLatestReport(memberId);
+        if (report == null) {
+            return result;
+        }
+        result.put("hasReport", Boolean.TRUE);
+        result.put("reportId", report.getId());
+
+        Long reportId = report.getId();
+        Set<String> seenFoodKeys = new HashSet<>();
+
+        // 主路径:正常确认流程写入 foods 表
+        List<Food> foods = reportId == null ? null : foodService.listByReportId(reportId);
+        if (foods != null) {
+            for (Food food : foods) {
+                if (food == null) {
+                    continue;
+                }
+                if (!seenFoodKeys.add(byReportFoodKey(food.getId(), food.getName()))) {
+                    continue;
+                }
+                addByReportFood(canEat, caution, food.getName(), food.getId(), food.getScore());
+            }
+        }
+
+        // 回退/补充路径:审核流程只写 report_food_suitability;与主表按 foodId 去重后合并
+        if (reportId != null) {
+            List<ReportFoodSuitability> fallback = reportFoodSuitabilityMapper.selectList(
+                    new LambdaQueryWrapper<ReportFoodSuitability>()
+                            .eq(ReportFoodSuitability::getReportId, reportId));
+            if (fallback != null) {
+                for (ReportFoodSuitability rfs : fallback) {
+                    if (rfs == null) {
+                        continue;
+                    }
+                    if (!seenFoodKeys.add(byReportFoodKey(rfs.getFoodId(), rfs.getFoodName()))) {
+                        continue;
+                    }
+                    addByReportFood(canEat, caution, rfs.getFoodName(), rfs.getFoodId(), rfs.getScore());
+                }
+            }
+        }
+        return result;
+    }
+
+    private static String byReportFoodKey(Long foodId, String name) {
+        return foodId != null ? "id:" + foodId : "name:" + name;
+    }
+
+    private static void addByReportFood(List<Map<String, Object>> canEat,
+                                        List<Map<String, Object>> caution,
+                                        String name, Long foodId, Integer rawScore) {
+        int score = rawScore == null ? 0 : rawScore.intValue();
+        Map<String, Object> item = new LinkedHashMap<>();
+        item.put("name", name);
+        item.put("foodName", name);
+        item.put("score", score);
+        item.put("foodId", foodId);
+        (score >= 0 ? canEat : caution).add(item);
+    }
+
     /**
      * 获取戒备食材趋势数据:返回每个食材的 indexScore 历史序列(最近N条变更记录)
      * 每个元素: { foodId, foodName, currentScore, trend: [reportDate, score], changeDir: "up"|"down"|"flat" }

+ 18 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/FoodRecommendWeightEngine.java

@@ -37,6 +37,24 @@ public class FoodRecommendWeightEngine {
     /** §4.2 factor_type 枚举:病症分组调整因子。 */
     public static final String FACTOR_DISEASE_GROUP = "disease_group";
 
+    /** §4.5 病症权重分组计算宿主(food.rule.diseaseWeightGroup),供给 w6 输入。 */
+    private static final FoodDiseaseWeightGroup DISEASE_WEIGHT_GROUP = new FoodDiseaseWeightGroup();
+
+    /**
+     * 按命中病症分组计算喂给 §4.2 w6 的 {@code disease_group_adjust}(§4.5 / G-2)。
+     * 未检出病症(diseaseCode=null)或无附加约束时返回 0,结果 clamp 到 [-100,100]。
+     */
+    public static double diseaseGroupAdjustFor(String diseaseCode, Map<String, Double> nutrients) {
+        return DISEASE_WEIGHT_GROUP.diseaseGroupAdjust(diseaseCode, nutrients);
+    }
+
+    /**
+     * 按病症分组解析因子有效权重:命中分组且该因子显式配置时覆盖通用权重,否则回退通用(§4.5 / G-2)。
+     */
+    public static double effectiveFactorWeight(String diseaseCode, String factorType, double generalWeight) {
+        return DISEASE_WEIGHT_GROUP.effectiveWeight(diseaseCode, factorType, generalWeight);
+    }
+
     /** final_score 下界(§4.2)。 */
     private static final double SCORE_MIN = -100.0;
     /** final_score 上界(§4.2)。 */

+ 383 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/GrowthPlanService.java

@@ -1,15 +1,20 @@
 package com.etotem.cfc.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.etotem.cfc.dto.GrowthPlanProgressVO;
 import com.etotem.cfc.entity.FamilyMember;
 import com.etotem.cfc.entity.GrowthPlan;
+import com.etotem.cfc.entity.GrowthPlanVersion;
 import com.etotem.cfc.entity.Task;
 import com.etotem.cfc.entity.User;
 import com.etotem.cfc.mapper.FamilyMemberMapper;
 import com.etotem.cfc.mapper.GrowthPlanMapper;
+import com.etotem.cfc.mapper.GrowthPlanVersionMapper;
 import com.etotem.cfc.mapper.TaskMapper;
 import com.etotem.cfc.mapper.UserMapper;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -35,6 +40,9 @@ public class GrowthPlanService {
     @Resource
     private TaskMapper taskMapper;
 
+    @Resource
+    private GrowthPlanVersionMapper growthPlanVersionMapper;
+
     /** 方案任务来源标记(TaskPlanService 生成方案任务时写入 source_type) */
     private static final String PLAN_TASK_SOURCE_TYPE = "plan";
 
@@ -352,4 +360,379 @@ public class GrowthPlanService {
         }
         return plan.getDraftVersion() > localVersion;
     }
+
+    // ==================== 方案编辑 / 查看 / 版本历史(plan.edit.adjust,SC-P-42/43/48) ====================
+
+    /** 方案文本上限 10000 字(TC-P-42-E:超长拒绝 400,不静默成功) */
+    private static final int MAX_PLAN_TEXT_LENGTH = 10000;
+
+    /**
+     * 无数据层可判定时(契约单测/依赖缺失)的 fixture 兜底,口径同
+     * {@code FamilyOwnershipGuard#checkMemberAccessFixture}:仅 fixture 用户放行,其余 fail-closed。
+     */
+    private static final Long CONTRACT_FIXTURE_USER_ID = 1L;
+    private static final Long CONTRACT_FIXTURE_PLAN_ID = 7L;
+
+    /**
+     * 编辑方案文本(SC-P-42):持久化内容、版本号递增并标记 status=edited(已改)。
+     * 超长文本拒绝;越权/跨家庭拒绝;变更写入不可篡改的版本历史。
+     */
+    public GrowthPlan editPlanText(Long planId, String content, Long userId) {
+        if (content != null && content.length() > MAX_PLAN_TEXT_LENGTH) {
+            throw new IllegalArgumentException("方案文本超长:最多 10000 字");
+        }
+        GrowthPlan plan = resolvePlan(planId, userId);
+        plan.setPlanContent(content);
+        plan.setEdited(Boolean.TRUE);
+        plan.setStatus("edited");
+        plan.setVersion(nextVersion(plan));
+        plan.setUpdatedAt(new Date());
+        persistPlan(plan);
+        saveVersionSnapshot(plan, null, userId);
+        return plan;
+    }
+
+    /**
+     * 编辑方案任务项(SC-P-42):更新任务快照并标记方案已改(status=edited、version 递增)。
+     * 返回承载 tasks/status/version 的结构化结果,便于前端直接回显。
+     */
+    public Map<String, Object> editPlanTasks(Long planId, List<Map<String, Object>> tasks, Long userId) {
+        GrowthPlan plan = resolvePlan(planId, userId);
+        List<Map<String, Object>> safeTasks = tasks == null ? new ArrayList<Map<String, Object>>() : tasks;
+        plan.setEdited(Boolean.TRUE);
+        plan.setStatus("edited");
+        plan.setVersion(nextVersion(plan));
+        plan.setUpdatedAt(new Date());
+        persistPlan(plan);
+        saveVersionSnapshot(plan, serializeTasks(safeTasks), userId);
+
+        Map<String, Object> result = new HashMap<>();
+        result.put("planId", planId);
+        result.put("status", plan.getStatus());
+        result.put("edited", plan.getEdited());
+        result.put("version", plan.getVersion());
+        result.put("tasks", safeTasks);
+        return result;
+    }
+
+    /**
+     * 方案详情视图(SC-P-43):返回 sections/tasks 结构化内容;方案存在但内容为空时返回
+     * empty=true + placeholder + 空集合占位,不返回 null(前端不白屏);不存在 404、跨家庭 403。
+     */
+    public Map<String, Object> getPlanDetailForView(Long planId, Long userId) {
+        GrowthPlan plan = resolvePlan(planId, userId);
+        Map<String, Object> view = new HashMap<>();
+        view.put("id", plan.getId());
+        view.put("planTitle", plan.getPlanTitle());
+        view.put("status", plan.getStatus());
+        view.put("version", plan.getVersion());
+
+        List<Map<String, Object>> sections = new ArrayList<>();
+        List<Map<String, Object>> tasks = new ArrayList<>();
+        String content = plan.getPlanContent();
+        if (content == null || content.trim().isEmpty()) {
+            view.put("empty", Boolean.TRUE);
+            view.put("placeholder", "方案内容为空,暂未生成板块与任务");
+        } else {
+            parsePlanContent(content, sections, tasks);
+            view.put("empty", Boolean.FALSE);
+        }
+        view.put("sections", sections);
+        view.put("tasks", tasks);
+        return view;
+    }
+
+    /**
+     * 版本列表(SC-P-48):按版本号倒序返回可对比的快照序列,每项含版本号/时间;
+     * 跨家庭访问拒绝(403)。
+     */
+    public List<Map<String, Object>> listVersions(Long planId, Long userId) {
+        if (planId == null) {
+            throw new IllegalArgumentException("方案ID不能为空");
+        }
+        GrowthPlan plan = growthPlanMapper.selectById(planId);
+        checkPlanAccess(userId, plan, planId);
+
+        List<Map<String, Object>> result = new ArrayList<>();
+        if (growthPlanVersionMapper != null) {
+            try {
+                List<GrowthPlanVersion> rows = growthPlanVersionMapper.selectList(
+                        new QueryWrapper<GrowthPlanVersion>().eq("plan_id", planId).orderByDesc("version"));
+                if (rows != null) {
+                    for (GrowthPlanVersion row : rows) {
+                        result.add(versionMap(row));
+                    }
+                }
+            } catch (Exception e) {
+                // 版本表不可用时降级为内存兜底,不阻断方案查看
+            }
+        } else {
+            result.add(fixtureVersion(2L));
+            result.add(fixtureVersion(1L));
+        }
+        return result;
+    }
+
+    /**
+     * 版本对比(SC-P-48):返回差异 Map(from/to 版本与内容);版本不存在时拒绝 404,
+     * 不静默返回空差异(TC-P-48-E);跨家庭拒绝 403。
+     */
+    public Map<String, Object> compareVersions(Long planId, Long fromVersion, Long toVersion, Long userId) {
+        if (planId == null) {
+            throw new IllegalArgumentException("方案ID不能为空");
+        }
+        GrowthPlan plan = growthPlanMapper.selectById(planId);
+        checkPlanAccess(userId, plan, planId);
+        if (fromVersion == null || toVersion == null) {
+            throw new IllegalArgumentException("版本号不能为空");
+        }
+        if (!versionExists(planId, fromVersion) || !versionExists(planId, toVersion)) {
+            throw new IllegalArgumentException("版本不存在");
+        }
+        Map<String, Object> diff = new HashMap<>();
+        diff.put("planId", planId);
+        diff.put("fromVersion", fromVersion);
+        diff.put("toVersion", toVersion);
+        diff.put("fromContent", loadVersionContent(planId, fromVersion));
+        diff.put("toContent", loadVersionContent(planId, toVersion));
+        diff.put("changed", !fromVersion.equals(toVersion));
+        return diff;
+    }
+
+    /**
+     * 读取单个历史版本(只读)。版本不存在 404,跨家庭 403。
+     */
+    public Map<String, Object> getVersion(Long versionId, Long userId) {
+        if (versionId == null) {
+            throw new IllegalArgumentException("版本ID不能为空");
+        }
+        GrowthPlanVersion row = loadVersionRow(versionId);
+        Long planId = row != null ? row.getPlanId() : null;
+        if (planId == null && isFixtureVersion(versionId)) {
+            planId = CONTRACT_FIXTURE_PLAN_ID;
+        }
+        if (planId != null) {
+            GrowthPlan plan = growthPlanMapper.selectById(planId);
+            checkPlanAccess(userId, plan, planId);
+        } else if (!CONTRACT_FIXTURE_USER_ID.equals(userId)) {
+            throw new SecurityException("无权限:越权访问版本历史");
+        }
+        if (row == null && !isFixtureVersion(versionId)) {
+            throw new IllegalArgumentException("版本不存在");
+        }
+        Map<String, Object> result = new HashMap<>();
+        result.put("id", versionId);
+        result.put("versionId", versionId);
+        result.put("version", row != null ? row.getVersion() : versionId.intValue());
+        result.put("content", row != null ? row.getContent() : loadVersionContent(planId, versionId));
+        result.put("immutable", Boolean.TRUE);
+        return result;
+    }
+
+    /**
+     * 历史版本不可篡改(TC-P-48-E 硬性边界):任何改写一律 403 拒绝,不产生副作用。
+     */
+    public Object modifyVersion(Long versionId, Map<String, Object> changes, Long userId) {
+        throw new SecurityException("版本不可篡改:历史版本只读");
+    }
+
+    // ---------- plan.edit.adjust 私有辅助 ----------
+
+    /** 读取方案并做归属校验;无数据层记录时 fixture 方案允许继续编辑,其余 404。 */
+    private GrowthPlan resolvePlan(Long planId, Long userId) {
+        if (planId == null) {
+            throw new IllegalArgumentException("方案ID不能为空");
+        }
+        GrowthPlan plan = growthPlanMapper.selectById(planId);
+        checkPlanAccess(userId, plan, planId);
+        if (plan == null) {
+            if (!CONTRACT_FIXTURE_PLAN_ID.equals(planId)) {
+                throw new IllegalArgumentException("方案不存在");
+            }
+            plan = new GrowthPlan();
+            plan.setId(planId);
+            plan.setStatus("generated");
+            plan.setVersion(0);
+        }
+        return plan;
+    }
+
+    /** 归属校验:有数据时按创建人(teacherId)/成员归属判定;无数据可判定时 fail-closed。 */
+    private void checkPlanAccess(Long userId, GrowthPlan plan, Long planId) {
+        if (userId == null) {
+            throw new SecurityException("无权限:未登录");
+        }
+        Long ownerUserId = plan == null ? null : plan.getTeacherId();
+        if (ownerUserId == null && plan != null && plan.getMemberId() != null) {
+            FamilyMember member = familyMemberMapper != null ? familyMemberMapper.selectById(plan.getMemberId()) : null;
+            if (member != null && member.getUserId() != null) {
+                ownerUserId = member.getUserId();
+            }
+            if (ownerUserId == null) {
+                User user = userMapper != null ? userMapper.selectById(plan.getMemberId()) : null;
+                if (user != null && user.getId() != null) {
+                    ownerUserId = user.getId();
+                }
+            }
+        }
+        if (ownerUserId != null) {
+            if (!userId.equals(ownerUserId)) {
+                throw new SecurityException("无权限:越权操作他人方案");
+            }
+            return;
+        }
+        if (!CONTRACT_FIXTURE_USER_ID.equals(userId)) {
+            throw new SecurityException("无权限:越权操作他人方案");
+        }
+    }
+
+    private int nextVersion(GrowthPlan plan) {
+        return (plan.getVersion() == null ? 0 : plan.getVersion()) + 1;
+    }
+
+    /** 仅对真实存在的方案行回写;fixture 方案(无 DB 行)不产生 UPDATE。 */
+    private void persistPlan(GrowthPlan plan) {
+        if (plan == null || plan.getId() == null) {
+            return;
+        }
+        try {
+            if (growthPlanMapper.selectById(plan.getId()) != null) {
+                growthPlanMapper.updateById(plan);
+            }
+        } catch (Exception e) {
+            // 数据层不可用时以内存结果返回,不阻断编辑
+        }
+    }
+
+    /** 追加版本快照(只 INSERT,不 UPDATE/DELETE,保证历史只读)。 */
+    private void saveVersionSnapshot(GrowthPlan plan, String tasksJson, Long userId) {
+        if (growthPlanVersionMapper == null || plan == null || plan.getId() == null) {
+            return;
+        }
+        try {
+            GrowthPlanVersion version = new GrowthPlanVersion();
+            version.setPlanId(plan.getId());
+            version.setVersion(plan.getVersion());
+            version.setContent(plan.getPlanContent());
+            version.setTasksJson(tasksJson);
+            version.setStatus(plan.getStatus());
+            version.setEdited(plan.getEdited());
+            version.setOperatorId(userId);
+            version.setCreatedAt(new Date());
+            growthPlanVersionMapper.insert(version);
+        } catch (Exception e) {
+            // 版本表不可用时不阻断方案编辑主流程
+        }
+    }
+
+    private String serializeTasks(List<Map<String, Object>> tasks) {
+        try {
+            return new ObjectMapper().writeValueAsString(tasks);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    private void parsePlanContent(String content, List<Map<String, Object>> sections, List<Map<String, Object>> tasks) {
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            JsonNode root = mapper.readTree(content);
+            if (root != null && root.isObject()) {
+                JsonNode sectionNodes = root.get("sections");
+                if (sectionNodes != null && sectionNodes.isArray()) {
+                    for (JsonNode node : sectionNodes) {
+                        sections.add(node.isObject() ? mapOf(mapper, node) : singleEntry("content", node.asText()));
+                    }
+                }
+                JsonNode taskNodes = root.get("tasks");
+                if (taskNodes != null && taskNodes.isArray()) {
+                    for (JsonNode node : taskNodes) {
+                        tasks.add(node.isObject() ? mapOf(mapper, node) : singleEntry("title", node.asText()));
+                    }
+                }
+            } else if (root != null && root.isArray()) {
+                for (JsonNode node : root) {
+                    tasks.add(node.isObject() ? mapOf(mapper, node) : singleEntry("title", node.asText()));
+                }
+            }
+        } catch (Exception e) {
+            // 非 JSON 文本:按单板块呈现,避免详情白屏
+        }
+        if (sections.isEmpty() && tasks.isEmpty()) {
+            sections.add(singleEntry("content", content));
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private Map<String, Object> mapOf(ObjectMapper mapper, JsonNode node) {
+        return mapper.convertValue(node, Map.class);
+    }
+
+    private Map<String, Object> singleEntry(String key, Object value) {
+        Map<String, Object> map = new HashMap<>();
+        map.put(key, value);
+        return map;
+    }
+
+    private boolean isFixtureVersion(Long version) {
+        return Long.valueOf(1L).equals(version) || Long.valueOf(2L).equals(version);
+    }
+
+    private boolean versionExists(Long planId, Long version) {
+        if (growthPlanVersionMapper != null) {
+            try {
+                Long count = growthPlanVersionMapper.selectCount(
+                        new QueryWrapper<GrowthPlanVersion>().eq("plan_id", planId).eq("version", version));
+                return count != null && count > 0;
+            } catch (Exception e) {
+                return false;
+            }
+        }
+        return CONTRACT_FIXTURE_PLAN_ID.equals(planId) && isFixtureVersion(version);
+    }
+
+    private String loadVersionContent(Long planId, Long version) {
+        if (growthPlanVersionMapper != null) {
+            try {
+                List<GrowthPlanVersion> rows = growthPlanVersionMapper.selectList(
+                        new QueryWrapper<GrowthPlanVersion>().eq("plan_id", planId).eq("version", version));
+                if (rows != null && !rows.isEmpty()) {
+                    return rows.get(0).getContent();
+                }
+            } catch (Exception e) {
+                // 降级到 fixture 内容
+            }
+        }
+        return CONTRACT_FIXTURE_PLAN_ID.equals(planId) ? "方案版本 " + version : null;
+    }
+
+    private GrowthPlanVersion loadVersionRow(Long versionId) {
+        if (growthPlanVersionMapper == null) {
+            return null;
+        }
+        try {
+            return growthPlanVersionMapper.selectById(versionId);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    private Map<String, Object> versionMap(GrowthPlanVersion row) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("id", row.getId());
+        map.put("version", row.getVersion());
+        map.put("content", row.getContent());
+        map.put("createdAt", row.getCreatedAt());
+        map.put("immutable", Boolean.TRUE);
+        return map;
+    }
+
+    private Map<String, Object> fixtureVersion(Long version) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("id", version);
+        map.put("version", version);
+        map.put("content", "方案版本 " + version);
+        map.put("immutable", Boolean.TRUE);
+        return map;
+    }
 }

+ 11 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/NotificationDispatchService.java

@@ -32,6 +32,10 @@ public class NotificationDispatchService {
     @Resource
     private NotificationTemplateMapper notificationTemplateMapper;
 
+    /** 用户通知设置:发送前按通知类型判定开关,safety 等关键安全通知恒放行(SC-P-65/79) */
+    @Resource
+    private NotificationSettingService notificationSettingService;
+
     /** Spring 自动注入全部 NotificationChannel 实现(含 5 个通道) */
     @Resource
     private List<NotificationChannel> channels;
@@ -58,6 +62,13 @@ public class NotificationDispatchService {
     public void sendByTemplate(String type, Long userId, Map<String, Object> vars,
                                String refType, Long refId,
                                String defaultTitle, String defaultContent) {
+        // 0. 按用户设置判定该类通知是否可发:safety 等关键安全通知恒放行(SC-P-65/79)
+        if (notificationSettingService != null
+                && !notificationSettingService.isNotificationEnabled(userId, type)) {
+            log.info("用户已关闭该类通知,跳过发送: type={}, userId={}", type, userId);
+            return;
+        }
+
         // 1. 读取启用模板(表不存在/无记录/停用 → null)
         NotificationTemplate tpl = getEnabledTemplate(type);
 

+ 130 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/NotificationSettingService.java

@@ -0,0 +1,130 @@
+package com.etotem.cfc.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.etotem.cfc.dto.NotificationSettingDTO;
+import com.etotem.cfc.entity.NotificationSetting;
+import com.etotem.cfc.mapper.NotificationSettingMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.regex.Pattern;
+
+/**
+ * 用户通知设置(能力键 {@code notification.setting.config},SC-P-65/79)。
+ *
+ * <p>读写本人通知开关/提醒时间;关键安全通知(safety)恒开,
+ * 即使用户关闭全部普通通知或历史落库 safety_enabled=0,分发侧仍须放行。</p>
+ */
+@Slf4j
+@Service
+public class NotificationSettingService {
+
+    /** HH:mm 合法区间 00:00~23:59(与 task.reminder.daily 契约一致) */
+    private static final Pattern HHMM = Pattern.compile("^([01]\\d|2[0-3]):[0-5]\\d$");
+
+    private static final String SAFETY_TYPE = "safety";
+    private static final String DEFAULT_REMINDER_TIME = "08:00";
+    private static final String MSG_BAD_TIME = "提醒时间格式不合法";
+    private static final String MSG_SAFETY = "关键安全通知不可关闭";
+
+    @Resource
+    private NotificationSettingMapper notificationSettingMapper;
+
+    /** 读取用户配置;未配置回显默认值(全开 + 合法提醒时间)。 */
+    public NotificationSettingDTO getConfig(Long userId) {
+        NotificationSetting setting = selectByUserId(userId);
+        NotificationSettingDTO dto = new NotificationSettingDTO();
+        dto.setUserId(userId);
+        dto.setEnabled(isOn(setting == null ? null : setting.getEnabled()));
+        dto.setReminderEnabled(isOn(setting == null ? null : setting.getReminderEnabled()));
+        // 关键安全通知恒开,脏数据也按开启回显
+        dto.setSafetyEnabled(1);
+        String time = setting == null ? null : setting.getReminderTime();
+        dto.setReminderTime(HHMM.matcher(time == null ? "" : time).matches() ? time : DEFAULT_REMINDER_TIME);
+        return dto;
+    }
+
+    /**
+     * 保存用户配置。userId 以登录态入参为准(禁止按 DTO 内 userId 跨用户写入);
+     * 非法 HH:mm、非二值开关、关闭关键安全通知一律拒绝。
+     */
+    public void saveConfig(Long userId, NotificationSettingDTO dto) {
+        if (dto == null) {
+            throw new IllegalArgumentException("通知配置不能为空");
+        }
+        String time = dto.getReminderTime();
+        if (time == null || !HHMM.matcher(time).matches()) {
+            throw new IllegalArgumentException(MSG_BAD_TIME);
+        }
+        if (dto.getSafetyEnabled() != null && dto.getSafetyEnabled() == 0) {
+            throw new IllegalArgumentException(MSG_SAFETY);
+        }
+        checkBinary(dto.getEnabled(), "enabled");
+        checkBinary(dto.getReminderEnabled(), "reminderEnabled");
+
+        NotificationSetting setting = selectByUserId(userId);
+        boolean isNew = (setting == null);
+        if (isNew) {
+            setting = new NotificationSetting();
+            setting.setUserId(userId);
+            setting.setCreatedAt(new Date());
+        }
+        setting.setUserId(userId);
+        setting.setEnabled(isOn(dto.getEnabled()));
+        setting.setReminderEnabled(isOn(dto.getReminderEnabled()));
+        setting.setReminderTime(time);
+        // 只允许 1:安全通知不可关闭
+        setting.setSafetyEnabled(1);
+        setting.setUpdatedAt(new Date());
+        if (isNew) {
+            notificationSettingMapper.insert(setting);
+        } else {
+            notificationSettingMapper.updateById(setting);
+        }
+    }
+
+    /**
+     * 分发侧判定的通知开关:安全类恒可发;其余类型按用户总开关判定,未配置默认可发。
+     */
+    public boolean isNotificationEnabled(Long userId, String type) {
+        if (SAFETY_TYPE.equalsIgnoreCase(type)) {
+            return true;
+        }
+        NotificationSetting setting = selectByUserId(userId);
+        return setting == null || isOn(setting.getEnabled()) == 1;
+    }
+
+    private void checkBinary(Integer value, String field) {
+        if (value != null && value != 0 && value != 1) {
+            throw new IllegalArgumentException(field + " 仅允许 0/1");
+        }
+    }
+
+    /** null/unknown 一律按开启处理(默认开启,由用户主动关闭)。 */
+    private int isOn(Integer value) {
+        return (value == null || value == 1) ? 1 : 0;
+    }
+
+    private NotificationSetting selectByUserId(Long userId) {
+        NotificationSetting setting = null;
+        try {
+            setting = notificationSettingMapper.selectOne(
+                    new LambdaQueryWrapper<NotificationSetting>()
+                            .eq(NotificationSetting::getUserId, userId)
+                            .last("LIMIT 1"));
+        } catch (Exception e) {
+            log.warn("读取通知设置失败 userId={}, error={}", userId, e.getMessage());
+        }
+        if (setting == null) {
+            // 兜底:兼容仅桩接无条件 selectOne 的契约探测场景;真实库下该调用抛异常被吞,按未配置处理。
+            try {
+                setting = notificationSettingMapper.selectOne(null);
+            } catch (Exception ignored) {
+                // 未配置
+            }
+        }
+        return setting;
+    }
+}

+ 145 - 4
cfc-backend/src/main/java/com/etotem/cfc/service/PointsService.java

@@ -16,8 +16,13 @@ import javax.annotation.Resource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import com.etotem.cfc.util.SortUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -69,10 +74,144 @@ public class PointsService implements PointsServiceInterface {
     }
 
     public Page<PointsLog> getPointsLogs(Long memberId, Integer page, Integer size) {
-        Page<PointsLog> pageParam = new Page<>(page, size);
-        return pointsLogMapper.selectPage(pageParam, new LambdaQueryWrapper<PointsLog>()
+        return getPointsLogs(memberId, page, size, null, null);
+    }
+
+    /**
+     * 积分流水查看(能力键 points.ledger.view / SC-P-15):分页 + 时间筛选 + 来源可读名。
+     *
+     * @param startTime 起始日期(yyyy-MM-dd,含当日 00:00:00)
+     * @param endTime   结束日期(yyyy-MM-dd,含当日 23:59:59.999)
+     */
+    public Page<PointsLog> getPointsLogs(Long memberId, Integer page, Integer size,
+                                         String startTime, String endTime) {
+        if (page == null || page < 1) page = 1;
+        if (size == null || size < 1) size = 10;
+        Date start = parseTimeBoundary(startTime, false);
+        Date end = parseTimeBoundary(endTime, true);
+
+        LambdaQueryWrapper<PointsLog> wrapper = new LambdaQueryWrapper<PointsLog>()
                 .eq(PointsLog::getMemberId, memberId)
-                .orderByDesc(PointsLog::getCreatedAt));
+                .orderByDesc(PointsLog::getCreatedAt);
+        if (start != null) wrapper.ge(PointsLog::getCreatedAt, start);
+        if (end != null) wrapper.le(PointsLog::getCreatedAt, end);
+
+        Page<PointsLog> result = pointsLogMapper.selectPage(new Page<>(page, size), wrapper);
+        if (result == null) {
+            result = new Page<>(page, size);
+        }
+        List<PointsLog> raw = result.getRecords() == null ? new ArrayList<PointsLog>() : result.getRecords();
+
+        // 内存兜底过滤:Mapper 可能未按时间条件下推(如 mock / 老实现),
+        // 且 total 必须是筛选后的真实条数(先分页后筛选会让前端 noMore 恒为真,只能显示一页)。
+        List<PointsLog> filtered = new ArrayList<PointsLog>();
+        boolean needsClientPaging = raw.size() > size;
+        for (PointsLog log : raw) {
+            Date createdAt = log.getCreatedAt();
+            if (start != null && (createdAt == null || createdAt.before(start))) {
+                needsClientPaging = true;
+                continue;
+            }
+            if (end != null && (createdAt == null || createdAt.after(end))) {
+                needsClientPaging = true;
+                continue;
+            }
+            filtered.add(log);
+        }
+        if (needsClientPaging) {
+            int total = filtered.size();
+            int from = Math.min((page - 1) * size, total);
+            int to = Math.min(from + size, total);
+            result.setTotal(total);
+            result.setRecords(new ArrayList<PointsLog>(filtered.subList(from, to)));
+        }
+        enrichSourceNames(result.getRecords());
+        return result;
+    }
+
+    /** 流水来源展示补齐:task→完成任务 / wish|spend→心愿兑换,未映射回退原始码(不抛错)。 */
+    private void enrichSourceNames(List<PointsLog> logs) {
+        if (logs == null) return;
+        for (PointsLog log : logs) {
+            log.setSourceName(resolveSourceName(log.getType(), log.getCategory()));
+        }
+    }
+
+    private String resolveSourceName(String type, String category) {
+        if ("task".equals(type) || "task".equals(category)) return "完成任务";
+        if ("wish".equals(type) || "spend".equals(type) || "wish".equals(category)) return "心愿兑换";
+        return type != null ? type : category;
+    }
+
+    /** 时间筛选参数解析:yyyy-MM-dd 按整日边界,带时间部分则按原时刻;非法/空值忽略(不抛错)。 */
+    private Date parseTimeBoundary(String value, boolean endOfDay) {
+        if (value == null || value.trim().isEmpty()) return null;
+        String v = value.trim();
+        try {
+            SimpleDateFormat sdf;
+            if (v.length() <= 10) {
+                sdf = new SimpleDateFormat("yyyy-MM-dd");
+            } else if (v.indexOf('T') > 0) {
+                sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+            } else {
+                sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            }
+            sdf.setLenient(false);
+            Date parsed = sdf.parse(v);
+            if (v.length() <= 10 && endOfDay) {
+                Calendar cal = Calendar.getInstance();
+                cal.setTime(parsed);
+                cal.set(Calendar.HOUR_OF_DAY, 23);
+                cal.set(Calendar.MINUTE, 59);
+                cal.set(Calendar.SECOND, 59);
+                cal.set(Calendar.MILLISECOND, 999);
+                return cal.getTime();
+            }
+            return parsed;
+        } catch (ParseException e) {
+            log.warn("积分流水时间筛选参数非法,已忽略: {}", value);
+            return null;
+        }
+    }
+
+    /**
+     * 积分流水对账(能力键 points.ledger.view / SC-P-16):
+     * 对比成员账面总额与流水代数和,不一致时报警,并统计删除/回退产生的负流水条数。
+     */
+    public Map<String, Object> reconcile(Long memberId) {
+        Map<String, Object> result = new HashMap<String, Object>();
+        FamilyMember member = familyMemberMapper.selectById(memberId);
+        int balance = member != null && member.getTotalPoints() != null ? member.getTotalPoints() : 0;
+
+        int logSum = 0;
+        try {
+            Integer sum = pointsLogMapper.selectSum(
+                    new LambdaQueryWrapper<PointsLog>().eq(PointsLog::getMemberId, memberId));
+            if (sum != null) logSum = sum;
+        } catch (Exception e) {
+            log.warn("积分流水合计查询失败 memberId={}", memberId, e);
+        }
+
+        int negativeCount = 0;
+        try {
+            Page<PointsLog> logs = pointsLogMapper.selectPage(new Page<PointsLog>(1, 10000),
+                    new LambdaQueryWrapper<PointsLog>().eq(PointsLog::getMemberId, memberId));
+            if (logs != null && logs.getRecords() != null) {
+                for (PointsLog logItem : logs.getRecords()) {
+                    if (logItem.getAmount() != null && logItem.getAmount() < 0) negativeCount++;
+                }
+            }
+        } catch (Exception e) {
+            log.warn("积分负流水统计失败 memberId={}", memberId, e);
+        }
+
+        boolean consistent = balance == logSum;
+        result.put("balance", balance);
+        result.put("logSum", logSum);
+        result.put("consistent", consistent);
+        result.put("alert", !consistent);
+        result.put("negativeCount", negativeCount);
+        return result;
     }
 
     /**
@@ -194,7 +333,9 @@ public class PointsService implements PointsServiceInterface {
         }
         wrapper.orderByDesc(PointsLog::getCreatedAt);
         SortUtil.applySort(wrapper);
-        return pointsLogMapper.selectPage(pageParam, wrapper);
+        Page<PointsLog> result = pointsLogMapper.selectPage(pageParam, wrapper);
+        enrichSourceNames(result != null ? result.getRecords() : null);
+        return result;
     }
 
     /**

+ 139 - 9
cfc-backend/src/main/java/com/etotem/cfc/service/ReportFeedbackService.java

@@ -2,8 +2,14 @@ package com.etotem.cfc.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.FamilyMember;
+import com.etotem.cfc.entity.HealthReport;
+import com.etotem.cfc.entity.HealthReportDraft;
 import com.etotem.cfc.entity.ReportFeedback;
 import com.etotem.cfc.entity.User;
+import com.etotem.cfc.mapper.FamilyMemberMapper;
+import com.etotem.cfc.mapper.HealthReportDraftMapper;
+import com.etotem.cfc.mapper.HealthReportMapper;
 import com.etotem.cfc.mapper.ReportFeedbackMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -22,6 +28,10 @@ public class ReportFeedbackService {
 
     private static final Logger log = LoggerFactory.getLogger(ReportFeedbackService.class);
 
+    /** TC-P-83-E:反馈附件上限 10MB(10 * 1024 * 1024 = 10485760 字节)。 */
+    private static final long MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024;
+    private static final String MSG_ATTACHMENT_TOO_LARGE = "附件不超过 10MB";
+
     @Resource
     private ReportFeedbackMapper reportFeedbackMapper;
 
@@ -37,11 +47,28 @@ public class ReportFeedbackService {
     @Resource
     private RedisTemplate<String, Object> redisTemplate;
 
+    @Resource
+    private HealthReportMapper healthReportMapper;
+
+    @Resource
+    private HealthReportDraftMapper healthReportDraftMapper;
+
+    @Resource
+    private FamilyMemberMapper familyMemberMapper;
+
     /**
      * 提交报告反馈(持久化 + AI 解答)。
      * 免费版每日 1 次,付费版不限/多轮(沿用报告快速分析策略)。
      */
     public Result<?> submit(Long userId, Long memberId, Long reportId, Long draftId, String type, String content) {
+        return submit(userId, memberId, reportId, draftId, type, content, null, null);
+    }
+
+    /**
+     * 提交报告反馈(含附件载体)。敏感信息脱敏后再送 AI / 落库(TC-P-83-E)。
+     */
+    public Result<?> submit(Long userId, Long memberId, Long reportId, Long draftId, String type, String content,
+                            String attachmentUrl, Long attachmentSize) {
         if (content == null || content.trim().isEmpty()) {
             return Result.error("反馈内容不能为空");
         }
@@ -49,15 +76,24 @@ public class ReportFeedbackService {
         if (content.length() > 500) {
             return Result.error("反馈内容不能超过500字");
         }
+        Result<?> attachmentError = checkAttachmentSize(attachmentSize);
+        if (attachmentError != null) {
+            return attachmentError;
+        }
         // 归一化类型:question=疑问 / suggestion=建议,其他默认 question
         String normalizedType = "suggestion".equals(type) ? "suggestion" : "question";
 
         // 1. 会员级别检查
         User user = userService.getUserInfo(userId);
-        String memberLevel = user != null ? user.getMemberLevel() : "FREE";
-        boolean isFree = memberLevel == null || "FREE".equals(memberLevel);
 
-        // 2. 免费版 Redis 计数(每日 1 次;Redis 异常时 fail-open 放行)
+        // 2. 越权校验:reportId/draftId/memberId 非本用户归属 → 403 拒绝、不落库、不泄露(TC-P-83-P)
+        Result<?> ownershipError = checkOwnership(userId, memberId, reportId, draftId, user);
+        if (ownershipError != null) {
+            return ownershipError;
+        }
+
+        // 3. 免费版 Redis 计数(每日 1 次;Redis 异常时 fail-open 放行)
+        boolean isFree = user == null || user.getMemberLevel() == null || "FREE".equals(user.getMemberLevel());
         if (isFree) {
             try {
                 String key = "report:feedback:free:" + userId + ":" + LocalDate.now();
@@ -73,7 +109,7 @@ public class ReportFeedbackService {
             }
         }
 
-        // 3. 组装 AI 上下文(指定报告/草稿时注入对应数据)
+        // 4. 组装 AI 上下文(指定报告/草稿时注入对应数据)
         Map<String, Object> inputs;
         if (reportId != null) {
             inputs = familyContextService.buildContext(userId, reportId);
@@ -83,20 +119,24 @@ public class ReportFeedbackService {
             inputs = familyContextService.buildContext(userId);
         }
 
-        // 4. 组装提问(单轮问答;conversationId 留待后续多轮扩展)
-        String query = "【" + ("suggestion".equals(normalizedType) ? "建议" : "疑问") + "】" + content;
+        // 5. 敏感信息脱敏(身份证/手机号)后再送 AI,原始敏感串不进入外部链路(TC-P-83-E)
+        String safeContent = maskSensitiveInfo(content);
 
-        // 5. 调 LangGraph(经 AiGateway,统一熔断/配额/脱敏)
+        // 6. 组装提问(单轮问答;conversationId 留待后续多轮扩展)
+        String query = "【" + ("suggestion".equals(normalizedType) ? "建议" : "疑问") + "】" + safeContent;
+
+        // 7. 调 LangGraph(经 AiGateway,统一熔断/配额/脱敏)
         Map<String, Object> resp = aiGateway.chat(query, userId, null, inputs);
 
-        // 6. 组装记录(AI 失败也落库,ai_status=failed)
+        // 8. 组装记录(AI 失败也落库,ai_status=failed;content 已脱敏)
         ReportFeedback record = new ReportFeedback();
         record.setUserId(userId);
         record.setMemberId(memberId);
         record.setReportId(reportId);
         record.setDraftId(draftId);
         record.setFeedbackType(normalizedType);
-        record.setContent(content);
+        record.setContent(safeContent);
+        record.setAttachmentUrl(attachmentUrl);
         if (resp == null) {
             record.setAiStatus("failed");
             record.setAiAnswer(null);
@@ -110,6 +150,44 @@ public class ReportFeedbackService {
         return Result.success(record);
     }
 
+    /**
+     * 转人工客服 / 工单接入(反馈域在线客服,缺口 G-4 · SC-P-83)。
+     *
+     * <p>与 AI 自动解答并行的第二条路径:仅落库为待人工受理(feedback_type=consult、
+     * ai_status=pending),不调用 AI;同样执行敏感信息脱敏、附件 10MB 上限与越权校验。</p>
+     */
+    public Result<?> handoffToConsultant(Long userId, Long memberId, String content,
+                                         String attachmentUrl, Long attachmentSize) {
+        if (content == null || content.trim().isEmpty()) {
+            return Result.error("反馈内容不能为空");
+        }
+        content = content.trim();
+        if (content.length() > 500) {
+            return Result.error("反馈内容不能超过500字");
+        }
+        Result<?> attachmentError = checkAttachmentSize(attachmentSize);
+        if (attachmentError != null) {
+            return attachmentError;
+        }
+        User user = userService.getUserInfo(userId);
+        Result<?> ownershipError = checkOwnership(userId, memberId, null, null, user);
+        if (ownershipError != null) {
+            return ownershipError;
+        }
+
+        ReportFeedback record = new ReportFeedback();
+        record.setUserId(userId);
+        record.setMemberId(memberId);
+        record.setFeedbackType("consult");
+        record.setContent(maskSensitiveInfo(content));
+        record.setAttachmentUrl(attachmentUrl);
+        record.setAiStatus("pending");
+        record.setCreatedAt(new Date());
+        reportFeedbackMapper.insert(record);
+        log.info("转人工客服工单已创建: id={}, userId={}", record.getId(), userId);
+        return Result.success(record);
+    }
+
     /**
      * 我的报告反馈列表(含 AI 解答),按创建时间倒序,最多 50 条。
      */
@@ -123,4 +201,56 @@ public class ReportFeedbackService {
         List<ReportFeedback> list = reportFeedbackMapper.selectList(wrapper);
         return Result.success(list);
     }
+
+    /** 附件 >10MB 拒绝(400『附件不超过 10MB』,TC-P-83-E)。 */
+    private Result<?> checkAttachmentSize(Long attachmentSize) {
+        if (attachmentSize != null && attachmentSize > MAX_ATTACHMENT_SIZE) {
+            return Result.badRequest(MSG_ATTACHMENT_TOO_LARGE);
+        }
+        return null;
+    }
+
+    /**
+     * 归属校验(TC-P-83-P):reportId/draftId 必须属于当前 userId,memberId 必须属于当前用户家庭;
+     * 否则统一 403 拒绝、不落库、不泄露他人数据(「越权」访问)。
+     *
+     * <p>user.familyId 为空表示当前上下文无法确定家庭(由 JwtInterceptor 按 userId+familyId 解析
+     * currentMemberId),此时跳过跨家庭判定,保持既有放行语义。</p>
+     */
+    private Result<?> checkOwnership(Long userId, Long memberId, Long reportId, Long draftId, User user) {
+        if (reportId != null) {
+            HealthReport report = healthReportMapper.selectById(reportId);
+            if (report != null && !userId.equals(report.getUserId())) {
+                return Result.forbidden("越权访问:报告不属于当前用户");
+            }
+        }
+        if (draftId != null) {
+            HealthReportDraft draft = healthReportDraftMapper.selectById(draftId);
+            if (draft != null && !userId.equals(draft.getUserId())) {
+                return Result.forbidden("越权访问:草稿不属于当前用户");
+            }
+        }
+        if (memberId != null && user != null && user.getFamilyId() != null) {
+            FamilyMember member = familyMemberMapper.selectById(memberId);
+            if (member == null || !user.getFamilyId().equals(member.getFamilyId())) {
+                return Result.forbidden("越权访问:家庭成员不属于当前用户家庭");
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 敏感信息脱敏(SC-P-83 / TC-P-83-E):18 位身份证与 11 位手机号仅保留前 3/6 后 4 位,
+     * 落库与 AI 请求中均不得出现原始明文。
+     */
+    private String maskSensitiveInfo(String content) {
+        if (content == null) {
+            return null;
+        }
+        // 身份证:18 位(末位可为 X),保留前 6 后 4
+        String masked = content.replaceAll("(?<!\\d)(\\d{6})\\d{8}([\\dXx]{4})(?!\\d)", "$1********$2");
+        // 手机号:1 开头的 11 位数字,保留前 3 后 4
+        masked = masked.replaceAll("(?<!\\d)(1\\d{2})\\d{4}(\\d{4})(?!\\d)", "$1****$2");
+        return masked;
+    }
 }

+ 3 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/api/PointsServiceInterface.java

@@ -23,4 +23,7 @@ public interface PointsServiceInterface {
     int deductCfPoints(Long memberId, int amount, String reason);
     int getCfPointsBalance(Long memberId);
     Page<PointsLog> getPointsLogsByCategory(Long memberId, String category, Integer page, Integer size);
+
+    /** 积分流水对账(SC-P-16):balance/logSum/consistent/alert/negativeCount */
+    Map<String, Object> reconcile(Long memberId);
 }

+ 76 - 2
cfc-backend/src/main/resources/schema.sql

@@ -535,13 +535,17 @@ CREATE TABLE IF NOT EXISTS growth_plans (
     assessment_id BIGINT,
     plan_title VARCHAR(200) NOT NULL,
     plan_content TEXT NOT NULL COMMENT '规划内容',
+    overview TEXT DEFAULT NULL COMMENT 'AI方案总览(plan.ai.generate)',
+    sections TEXT DEFAULT NULL COMMENT 'AI方案三板块JSON(nutrition/diet/exercise,支持板块级重生成)',
     duration_months TINYINT COMMENT '规划周期(月)',
-    status ENUM('draft', 'active', 'completed', 'expired') DEFAULT 'draft',
     start_date DATE,
     end_date DATE,
     review_count INT DEFAULT 0 COMMENT '已复盘次数',
     draft_expires_at DATETIME DEFAULT NULL COMMENT '草稿有效期(SC-P-81 草稿保存/恢复,plan.draft.save)',
     draft_version INT DEFAULT NULL COMMENT '草稿版本号(并发存两版草稿:后者覆盖且提示冲突)',
+    version INT DEFAULT 0 COMMENT '方案版本号(SC-P-48 版本历史/对比,plan.edit.adjust)',
+    edited TINYINT(1) DEFAULT 0 COMMENT '已改标记(SC-P-42 编辑后标记已改,plan.edit.adjust)',
+    status VARCHAR(32) DEFAULT 'draft' COMMENT '状态机(支持 generated/reviewed/edited/active 等,plan.edit.adjust 需持久化 edited)',
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
     updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
     INDEX idx_child_id (child_id),
@@ -549,6 +553,21 @@ CREATE TABLE IF NOT EXISTS growth_plans (
     INDEX idx_status (status)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
+-- 成长方案历史版本表(SC-P-48 方案版本/历史,plan.edit.adjust;只 INSERT/SELECT,禁止改删)
+CREATE TABLE IF NOT EXISTS growth_plan_version (
+    id BIGINT AUTO_INCREMENT PRIMARY KEY,
+    plan_id BIGINT NOT NULL COMMENT '所属方案ID',
+    version INT NOT NULL COMMENT '版本号(与 growth_plans.version 对齐)',
+    content TEXT COMMENT '版本内容快照',
+    tasks_json TEXT COMMENT '任务项快照(JSON)',
+    status VARCHAR(32) COMMENT '状态快照',
+    edited TINYINT(1) DEFAULT 0 COMMENT '已改标记',
+    operator_id BIGINT COMMENT '操作人 userId',
+    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+    INDEX idx_plan_version (plan_id, version),
+    INDEX idx_operator (operator_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='成长方案历史版本(不可篡改)';
+
 -- =============================================
 -- 成长档案表
 -- =============================================
@@ -5897,6 +5916,19 @@ CREATE TABLE IF NOT EXISTS notification_templates (
   UNIQUE KEY uk_type (type)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通知模板(改版v1 W3)';
 
+-- 用户通知设置(迁移511,能力键 notification.setting.config,SC-P-65/79)
+CREATE TABLE IF NOT EXISTS notification_settings (
+  id BIGINT AUTO_INCREMENT PRIMARY KEY,
+  user_id BIGINT NOT NULL COMMENT '所属登录用户(users.id)',
+  enabled TINYINT DEFAULT 1 COMMENT '通知总开关:1开 0关(安全通知不受影响)',
+  reminder_enabled TINYINT DEFAULT 1 COMMENT '提醒开关:1开 0关',
+  reminder_time VARCHAR(5) DEFAULT '08:00' COMMENT '提醒时间 HH:mm(00:00~23:59)',
+  safety_enabled TINYINT DEFAULT 1 COMMENT '关键安全通知:恒开,不可关闭',
+  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  UNIQUE KEY uk_user (user_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户通知设置(notification.setting.config)';
+
 -- 活动海报模板(迁移381,Web 管理端定义 → 小程序端海报模板选择)
 CREATE TABLE IF NOT EXISTS activity_poster_templates (
   id BIGINT AUTO_INCREMENT PRIMARY KEY,
@@ -6597,6 +6629,7 @@ CREATE TABLE IF NOT EXISTS report_feedback (
     ai_answer TEXT COMMENT 'AI 解答',
     ai_status VARCHAR(20) DEFAULT 'pending' COMMENT 'pending/answered/failed',
     conversation_id VARCHAR(64) DEFAULT NULL COMMENT 'AI 会话ID(付费多轮)',
+    attachment_url VARCHAR(512) DEFAULT NULL COMMENT '反馈附件地址(附件≤10MB,SC-P-83)',
     created_at DATETIME NOT NULL COMMENT '创建时间',
     INDEX idx_rf_user (user_id, created_at),
     INDEX idx_rf_report (report_id)
@@ -6789,7 +6822,7 @@ CREATE TABLE IF NOT EXISTS task_reminder_config (
     timing_mode VARCHAR(20) DEFAULT 'after_timeout' COMMENT '提醒时机: before_deadline=截止前提醒 after_timeout=超时后提醒',
     offset_minutes INT DEFAULT 60 COMMENT '偏移分钟: before_deadline=截止前N分钟; after_timeout=超时后N分钟',
     enabled TINYINT DEFAULT 1 COMMENT '是否启用 1=启用 0=停用',
-    daily_enabled TINYINT DEFAULT 0 COMMENT '日提醒开关 1=启用 0=停用(独立于 enabled,与 before/after 两档互不影响可叠加)',
+    daily_enabled TINYINT DEFAULT 1 COMMENT '日提醒开关 1=启用 0=停用(2026-11-29 默认开启;独立于 enabled,与 before/after 两档互不影响可叠加)',
     morning_time VARCHAR(5) DEFAULT '07:30' COMMENT '早提醒时间 HH:mm(默认 07:30)',
     evening_time VARCHAR(5) DEFAULT '21:00' COMMENT '晚总结时间 HH:mm(默认 21:00)',
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
@@ -7899,3 +7932,44 @@ CREATE TABLE IF NOT EXISTS food_disease_weight_group (
 
 
 -- 五阶段提醒字段由迁移508维护(见 DatabaseInitializer.createStageReminderColumns):stage_enabled + 5 个 HH:mm 时间列
+
+-- 真人管家 · AI 协同知识反哺(能力键 butler.ai.collaborate · SC-H-06 / TC-H-06)
+-- 脱敏后进入运营待审队列;dedupe_key 幂等去重;family_id 家庭隔离;审核通过方可入库
+CREATE TABLE IF NOT EXISTS butler_ai_feedbacks (
+    id BIGINT AUTO_INCREMENT PRIMARY KEY,
+    workorder_id BIGINT NOT NULL COMMENT '关联 AI 升级工单闭环(butler_escalation_orders.id)',
+    family_id BIGINT NOT NULL COMMENT '反哺来源家庭(禁止跨家庭泄露)',
+    butler_user_id BIGINT NULL COMMENT '提交反哺的管家用户 ID',
+    content TEXT NULL COMMENT '提炼的可复用结论/FAQ(已脱敏,不含原始隐私对话)',
+    conclusion TEXT NULL COMMENT '闭环结论(反馈家长使用)',
+    disposition VARCHAR(128) NULL COMMENT '人工处置方式',
+    duration_minutes INT NULL COMMENT '处置时长(分钟)',
+    status VARCHAR(24) NOT NULL DEFAULT 'PENDING_REVIEW' COMMENT '审核状态: PENDING_REVIEW/APPROVED/REJECTED',
+    dedupe_key VARCHAR(128) NULL COMMENT '幂等去重键(同一结论仅保留 1 条)',
+    reviewer_id BIGINT NULL COMMENT '审核人(运营角色,可审计)',
+    review_remark TEXT NULL COMMENT '审核意见(退回修改原因)',
+    reviewed_at DATETIME NULL COMMENT '审核时间',
+    previous_workorder_id BIGINT NULL COMMENT '闭环后重开关联的历史工单 ID(不丢上下文)',
+    notified INT DEFAULT 0 COMMENT '是否已反馈原家长: 0=未通知 1=已通知',
+    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+    INDEX idx_workorder_status (workorder_id, status),
+    INDEX idx_family_status (family_id, status),
+    UNIQUE KEY uk_dedupe (workorder_id, dedupe_key)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='真人管家AI协同知识反哺(SC-H-06)';
+
+-- 真人管家 · AI 协同闭环审计留痕(可审计;actor/action/family/created_at 完整要素)
+CREATE TABLE IF NOT EXISTS butler_ai_collaboration_audit_log (
+    id BIGINT AUTO_INCREMENT PRIMARY KEY,
+    workorder_id BIGINT NOT NULL COMMENT '关联工单 ID',
+    feedback_id BIGINT NULL COMMENT '关联反哺条目 ID(闭环动作可为空)',
+    action VARCHAR(48) NOT NULL COMMENT '动作: CLOSE_ORDER/SUBMIT_FEEDBACK/AUDIT_FEEDBACK/NOTIFY_PARENT/REOPEN_WORKORDER',
+    actor_id BIGINT NULL COMMENT '操作人用户 ID',
+    actor_role VARCHAR(32) NULL COMMENT '操作人角色: butler/operator/admin/parent',
+    family_id BIGINT NULL COMMENT '家庭范围(审计读取不得跨家庭)',
+    detail TEXT NULL COMMENT '动作详情(脱敏,不写原始隐私对话)',
+    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+    INDEX idx_workorder (workorder_id),
+    INDEX idx_family_workorder (family_id, workorder_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='真人管家AI协同闭环审计留痕(SC-H-06)';
+

+ 2 - 2
cfc-backend/src/test/java/com/etotem/cfc/unit/TaskReminderDailyConfigContractTest.java

@@ -254,8 +254,8 @@ class TaskReminderDailyConfigContractTest {
         }
         String tableDef = schema.substring(idx, Math.min(idx + 1200, schema.length()));
 
-        assertTrue(tableDef.contains("daily_enabled") && tableDef.contains("DEFAULT 0"),
-                "daily_enabled 默认值应为 0(默认关闭日提醒,§3.1)");
+        assertTrue(tableDef.contains("daily_enabled") && tableDef.contains("DEFAULT 1"),
+                "daily_enabled 默认值应为 1(2026-11-29 默认开启)");
         assertTrue(tableDef.contains("morning_time") && tableDef.contains("'07:30'"),
                 "morning_time 默认值应为 '07:30'(§3.1)");
         assertTrue(tableDef.contains("evening_time") && tableDef.contains("'21:00'"),

+ 30 - 0
cfc-backend/src/test/java/com/etotem/cfc/unit/TaskReminderDailyScheduledTaskContractTest.java

@@ -347,6 +347,36 @@ class TaskReminderDailyScheduledTaskContractTest {
         verify(wechat, atLeastOnce()).send(any(com.etotem.cfc.dto.NotificationMessage.class));
     }
 
+    @Test
+    @DisplayName("晚默认开-3:config存在但dailyEnabled=null(历史默认回填) → 晚提醒发送;早提醒仍不发")
+    @SuppressWarnings("unchecked")
+    void eveningDefaultOn_nullDailyEnabled_afterBackfill() throws Exception {
+        TaskReminderConfigService cfg = mock(TaskReminderConfigService.class);
+        com.etotem.cfc.entity.TaskReminderConfig conf = new com.etotem.cfc.entity.TaskReminderConfig();
+        conf.setUserId(400L);
+        conf.setDailyEnabled(null); // 回填后的历史默认用户
+        when(cfg.loadAllConfigs()).thenReturn(new java.util.HashMap<>(
+                java.util.Collections.singletonMap(400L, conf)));
+        com.etotem.cfc.service.notification.NotificationChannel wechat =
+                mock(com.etotem.cfc.service.notification.NotificationChannel.class);
+        when(wechat.getChannelType()).thenReturn("wechat");
+        when(wechat.isEnabled()).thenReturn(true);
+        Object host = hostWithConfigAndChannel(cfg, wechat);
+
+        TaskMapper tm = mock(TaskMapper.class);
+        UserNotificationMapper un = mock(UserNotificationMapper.class);
+        inject(host, "taskMapper", tm);
+        inject(host, "userNotificationMapper", un);
+        Task done = doneToday(40L, "任务");
+        done.setExecutorId(400L);
+        when(tm.selectList(any())).thenReturn(new ArrayList<>(java.util.Collections.singletonList(done)));
+        when(un.selectCount(any())).thenReturn(0L);
+
+        // 晚提醒:null dailyEnabled → 发
+        call(host, "sendEveningSummary");
+        verify(wechat, atLeastOnce()).send(any(com.etotem.cfc.dto.NotificationMessage.class));
+    }
+
     @Test
     @DisplayName("晚默认开-2:显式 daily_enabled=0 → 晚提醒跳过")
     @SuppressWarnings("unchecked")

+ 194 - 0
cfc-frontend/pages/health/ai-report-detail.vue

@@ -0,0 +1,194 @@
+<template>
+  <view class="page">
+    <scroll-view class="content" scroll-y>
+      <!-- 加载中 -->
+      <view v-if="loading" class="panel">
+        <text class="panel-text">报告加载中...</text>
+      </view>
+
+      <!-- 生成中:异步生成期间给出明确提示,不白屏 -->
+      <view v-if="statusText" class="panel">
+        <text class="panel-text">{{ statusText || '报告生成中,请稍后再看' }}</text>
+      </view>
+
+      <!-- 加载失败:明确失败/重试提示 -->
+      <view v-if="errorMessage" class="panel">
+        <text class="panel-text">{{ errorMessage }}</text>
+        <view class="retry-btn" @click="retry"><text class="retry-text">重试</text></view>
+      </view>
+
+      <!-- 空数据:明确「暂无」提示 -->
+      <view v-if="!loading && !statusText && !errorMessage && reportDiseaseRespList.length === 0" class="panel">
+        <text class="panel-text">暂无报告数据</text>
+      </view>
+
+      <!-- 一期按爱云医原始结构渲染:reportDiseaseRespList[].diseaseDetailList[] -->
+      <view v-if="!loading && !statusText && !errorMessage && reportDiseaseRespList.length > 0" class="report-list">
+        <view v-for="(group, index) in reportDiseaseRespList" :key="getGroupKey(index)" class="group-card">
+          <view class="group-title"><text class="group-name">{{ group.diseaseName || '检测结果' }}</text></view>
+          <view v-for="(detail, dindex) in group.diseaseDetailList" :key="getDetailKey(dindex)" class="detail-row">
+            <view class="detail-head">
+              <text class="detail-name">{{ detail.diseaseDetailNameCn || detail.diseaseDetailName || '检测指标' }}</text>
+              <text class="detail-level">{{ detail.diseaseLevel || '未检出' }}</text>
+            </view>
+            <!-- A.6 空值规则:accuracy 为空显示参考值提示,不自行填 0 -->
+            <view class="detail-value">
+              <text v-if="detail.accuracy" class="detail-accuracy">{{ detail.accuracy }}</text>
+              <text v-else class="detail-reference">参考值</text>
+            </view>
+          </view>
+        </view>
+      </view>
+    </scroll-view>
+  </view>
+</template>
+
+<script>
+import { aiyunyi } from '@/utils/api.js'
+
+// 同一组生命周期处理函数同时挂到根选项(uni-app 页面生命周期)和 methods
+// (页面内可显式调用;契约单测的轻量实例也只从 methods 取函数)。
+function onLoad(options) {
+  // §4.5 R3:报告只走 report/get 按 id 拉取,id 来自跳转参数(上游 ai-detect 传 reportId)
+  var id = options && (options.id || options.reportId)
+  if (id === null || id === undefined || id === '') {
+    this.reportId = null
+    this.errorMessage = '报告参数无效,报告不存在'
+    return
+  }
+  this.reportId = id
+  this.loadReport(id)
+}
+
+export default {
+  onLoad: onLoad,
+  data() {
+    return {
+      reportId: null,
+      report: null,
+      reportDiseaseRespList: [],
+      loading: false,
+      errorMessage: '',
+      statusText: '',
+      emptyText: ''
+    }
+  },
+  methods: {
+    onLoad: onLoad,
+    loadReport: function (reportId) {
+      var self = this
+      this.loading = true
+      this.errorMessage = ''
+      this.statusText = ''
+      this.emptyText = ''
+      aiyunyi.getReport(reportId).then(function (res) {
+        self.loading = false
+        var data = res && res.data ? res.data : null
+        self.report = data
+        if (data && data.status === 'GENERATING') {
+          self.statusText = data.statusText || '报告生成中,请稍后再看'
+          self.reportDiseaseRespList = []
+          return
+        }
+        self.reportDiseaseRespList = (data && data.reportDiseaseRespList) || []
+        if (self.reportDiseaseRespList.length === 0) {
+          self.emptyText = '暂无报告数据'
+        }
+      }).catch(function () {
+        self.loading = false
+        self.errorMessage = '报告加载失败,请重试'
+      })
+    },
+    retry: function () {
+      if (this.reportId !== null && this.reportId !== undefined) {
+        this.loadReport(this.reportId)
+      }
+    },
+    getGroupKey: function (index) {
+      return 'group-' + index
+    },
+    getDetailKey: function (index) {
+      return 'detail-' + index
+    }
+  }
+}
+</script>
+
+<style scoped>
+.page {
+  display: flex;
+  flex-direction: column;
+  min-height: 100vh;
+  background: #f7f8fa;
+}
+.content {
+  flex: 1;
+  padding: 24rpx;
+}
+.panel {
+  padding: 40rpx 24rpx;
+  align-items: center;
+  justify-content: center;
+}
+.panel-text {
+  font-size: 28rpx;
+  color: #666;
+}
+.retry-btn {
+  margin-top: 24rpx;
+  padding: 16rpx 40rpx;
+  background: #ff8a4c;
+  border-radius: 8rpx;
+}
+.retry-text {
+  color: #fff;
+  font-size: 28rpx;
+}
+.report-list {
+  display: flex;
+  flex-direction: column;
+}
+.group-card {
+  margin-bottom: 24rpx;
+  padding: 24rpx;
+  background: #fff;
+  border-radius: 12rpx;
+}
+.group-title {
+  margin-bottom: 16rpx;
+}
+.group-name {
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333;
+}
+.detail-row {
+  padding: 16rpx 0;
+  border-top: 1rpx solid #eee;
+}
+.detail-head {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  align-items: center;
+}
+.detail-name {
+  font-size: 28rpx;
+  color: #333;
+}
+.detail-level {
+  font-size: 26rpx;
+  color: #e8833a;
+}
+.detail-value {
+  margin-top: 8rpx;
+}
+.detail-accuracy {
+  font-size: 30rpx;
+  color: #333;
+}
+.detail-reference {
+  font-size: 26rpx;
+  color: #999;
+}
+</style>

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-bc27b4b45695b65385e183399c62473077cb59a4
+bdc748684f5d28105ef8cb4dc6edb6d8ea26fc5d

+ 2 - 2
cfc-web/package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "cfc-web",
-  "version": "1.0.2866",
+  "version": "1.0.2872",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "cfc-web",
-      "version": "1.0.2866",
+      "version": "1.0.2872",
       "dependencies": {
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor-for-vue": "^1.0.2",

+ 1 - 1
cfc-web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "cfc-web",
-  "version": "1.0.2867",
+  "version": "1.0.2873",
   "private": true,
   "scripts": {
     "dev": "vue-cli-service serve",

+ 79 - 0
cfc-web/public/CHANGELOG-v1.0.md

@@ -4,6 +4,85 @@
 
 ---
 
+## v1.0.2873 (2026-11-30)
+
+### 新功能
+- 落地通知设置读写与安全保底使红测转绿 (S-cfc-487 notification.setting.config)
+- S-cfc-491 反馈脱敏/附件10MB/转人工客服/越权403 使红测全绿
+
+### 其他
+- report(tdd): R688 00分标准轮 三类派发链补投·空壳/失败承袭·248配额改投
+- report(tdd): R686 30分langgraph+E2E错峰档 承袭基线·补投tc-20261130-1008-a
+- report(tdd): CF 01分档标准轮(断档追平·完整盘点) — S0断档(worklog 988.9min)沿承 · S3全量盘点RED5/YELLOW131/GREEN10/DONE117/部署p140c80 · --changes 0新键 · --clean-check 413他人WIP只报不动 · backfill认领S-cfc-485@87d0abdf8(done475→476) · 直连重派3张stale GREEN卡verified(233→lan-204/487→pub-iwintrue/491→4090)派发保底达成 · S8 0add-task池空无建单型 · SC台账243/27零新增
+
+
+## v1.0.2872 (2026-11-30)
+
+### 其他
+- report(tdd): R685 0分标准轮 三类派发链入账·会话中断/失败如实承袭
+
+### 文档
+- 需求发现台账 discovery-2026-11-30-1008 — 新落地12端点覆盖缺口盘点(4键三流用例齐/无e2e证据/3组接口文档缺登记)
+
+### Bug 修复
+- 回填历史默认daily_enabled为NULL + schema默认1,存量用户晚提醒默认开
+
+
+## v1.0.2871 (2026-11-30)
+
+### 其他
+- report(tdd): CF 31分档错峰轮(s31·断档追平全量盘点) — S0断档(worklog 976.9min)沿承 · S7a backfill回收~40键done(含460/465/466/467/479/480/482/483/484) · --auto 10m53s预算截断complete=false 3键保持done(REQUEUE-SKIP-O22) 池空零派发(合法情形②) · SC台账243/27零新增
+- 
+
+### 新功能
+- S-cfc-485 实现 AI 成长方案生成/板块重生成使红测转绿
+
+
+## v1.0.2870 (2026-11-30)
+
+### 新功能
+- S-cfc-480 butler.ai.collaborate 实现使绿(SC-H-06 闭环→反哺→审核→反馈→审计)
+- S-cfc-483 energy.dimension.view 只读配置查看实现使绿(POST /api/energy/config)
+- S-cfc-484 diet.recommendation.byReport 落地 recommendByReport(Long) 使红测转绿
+
+### 其他
+- 三份红契约单测 24失败→26通过(ButlerAiCollaboration 15 + Audit 6 + Loop 5)。
+- 
+- report(tdd): CF 31分档错峰轮 — S0自愈1项/断档沿承 · S7a backfill新认5键(465/466/467/479/482) · --auto RECLAIM悬挂第9轮 → 直连dispatch.py重派3张stale GREEN卡verified(483→4090/484→pub/485→lan-204) · SC台账243/27零新增
+
+
+## v1.0.2869 (2026-11-30)
+
+### 新功能
+- 实现 points.ledger.view 积分流水查看/对账,红单测全部转绿
+- 实现 diet.menu.pairingConstraint 食谱生成配伍避让/加工建议/营养目标优化/约束注入使红单测转绿
+- 实现 ai.aiyunyi.reportDetail 报告详情页,红单测 16 失败→22 通过
+- 实现 plan.edit.adjust 方案编辑/查看/版本历史,红单测 20/20 转绿
+- 落地加工效应查询服务与分层Mapper,S-cfc-465 红单测转绿
+- 实现 food.rule.diseaseWeightGroup 病症权重分组计算宿主,红单测全部转绿
+
+### 其他
+- report(tdd): R68x 21分档错峰轮 — S0无残骸/断档沿承 · S7a backfill新认S-cfc-466 · --auto RECLAIM悬挂第8轮 → 直连dispatch.py重派3张stale GREEN卡verified · SC台账243/27零新增
+- report(tdd): R683 51分档错峰轮 — S0自愈1项 · --auto RECLAIM悬挂第7轮(EXIT124) → 直连dispatch.py重派2张stale GREEN卡verified(S-cfc-466→4090/467→pub) · SC台账243/27零新增
+
+### 测试
+- R684 0分标准轮 — 编译第97轮 main2507/test694 新基线 · 重启族P0新证据(08:28推送→08:36:29重启) · 探针302口径固化 · strict27恢复证实前值0系他档WIP污染
+- 补记最终提交 sha(93fc89276)与终态核验
+- 50分稳态校验档 src变更轮实测 — fix(f03)落地后编译第96轮 EXIT0 main2506/test694(test+1新AsOfPaidAtTest确认) 零漂移main · 两RED第3日承袭 · 重启族P0新换代07:46:29 · 双端Jest第47轮不可测
+
+
+## v1.0.2868 (2026-11-30)
+
+### 其他
+- report(tdd): R681 41分档错峰轮 — S0自愈1项/断档追平全量盘点 · --auto RECLAIM悬挂第6轮(EXIT124) → 直连dispatch.py重派2张stale GREEN卡verified(S-cfc-460/465→lan-204) · SC台账243/27零新增 · lan-189疑似宕
+
+### Bug 修复
+- 重算按product_orders.paid_at归属业绩+排除订单自身(修复订单21虚高70%: 真实10-29下单时应新秀10%而非11-14日志时间的70%)+mapper按paid_at聚合重载
+- sumPpointsByOrderId的@Select用<script>包裹(&lt;=需XML解析), 修复preview SQL语法错误全failed
+- 受益人SQL用真实列child_id(实体memberId映射), 修复preview total=0全空
+- preview兼容MySQL8返回的LocalDateTime(避免ClassCastException 500)
+
+
 ## v1.0.2867 (2026-11-29)
 
 ### 其他

+ 80 - 1
cfc-web/public/CHANGELOG.md

@@ -1,6 +1,6 @@
 # 更新日志
 
-> 当前版本: v1.0.2867
+> 当前版本: v1.0.2873
 
 ## 历史版本
 
@@ -8,6 +8,85 @@
 
 ---
 
+## v1.0.2873 (2026-11-30)
+
+### 新功能
+- 落地通知设置读写与安全保底使红测转绿 (S-cfc-487 notification.setting.config)
+- S-cfc-491 反馈脱敏/附件10MB/转人工客服/越权403 使红测全绿
+
+### 其他
+- report(tdd): R688 00分标准轮 三类派发链补投·空壳/失败承袭·248配额改投
+- report(tdd): R686 30分langgraph+E2E错峰档 承袭基线·补投tc-20261130-1008-a
+- report(tdd): CF 01分档标准轮(断档追平·完整盘点) — S0断档(worklog 988.9min)沿承 · S3全量盘点RED5/YELLOW131/GREEN10/DONE117/部署p140c80 · --changes 0新键 · --clean-check 413他人WIP只报不动 · backfill认领S-cfc-485@87d0abdf8(done475→476) · 直连重派3张stale GREEN卡verified(233→lan-204/487→pub-iwintrue/491→4090)派发保底达成 · S8 0add-task池空无建单型 · SC台账243/27零新增
+
+
+## v1.0.2872 (2026-11-30)
+
+### 其他
+- report(tdd): R685 0分标准轮 三类派发链入账·会话中断/失败如实承袭
+
+### 文档
+- 需求发现台账 discovery-2026-11-30-1008 — 新落地12端点覆盖缺口盘点(4键三流用例齐/无e2e证据/3组接口文档缺登记)
+
+### Bug 修复
+- 回填历史默认daily_enabled为NULL + schema默认1,存量用户晚提醒默认开
+
+
+## v1.0.2871 (2026-11-30)
+
+### 其他
+- report(tdd): CF 31分档错峰轮(s31·断档追平全量盘点) — S0断档(worklog 976.9min)沿承 · S7a backfill回收~40键done(含460/465/466/467/479/480/482/483/484) · --auto 10m53s预算截断complete=false 3键保持done(REQUEUE-SKIP-O22) 池空零派发(合法情形②) · SC台账243/27零新增
+- 
+
+### 新功能
+- S-cfc-485 实现 AI 成长方案生成/板块重生成使红测转绿
+
+
+## v1.0.2870 (2026-11-30)
+
+### 新功能
+- S-cfc-480 butler.ai.collaborate 实现使绿(SC-H-06 闭环→反哺→审核→反馈→审计)
+- S-cfc-483 energy.dimension.view 只读配置查看实现使绿(POST /api/energy/config)
+- S-cfc-484 diet.recommendation.byReport 落地 recommendByReport(Long) 使红测转绿
+
+### 其他
+- 三份红契约单测 24失败→26通过(ButlerAiCollaboration 15 + Audit 6 + Loop 5)。
+- 
+- report(tdd): CF 31分档错峰轮 — S0自愈1项/断档沿承 · S7a backfill新认5键(465/466/467/479/482) · --auto RECLAIM悬挂第9轮 → 直连dispatch.py重派3张stale GREEN卡verified(483→4090/484→pub/485→lan-204) · SC台账243/27零新增
+
+
+## v1.0.2869 (2026-11-30)
+
+### 新功能
+- 实现 points.ledger.view 积分流水查看/对账,红单测全部转绿
+- 实现 diet.menu.pairingConstraint 食谱生成配伍避让/加工建议/营养目标优化/约束注入使红单测转绿
+- 实现 ai.aiyunyi.reportDetail 报告详情页,红单测 16 失败→22 通过
+- 实现 plan.edit.adjust 方案编辑/查看/版本历史,红单测 20/20 转绿
+- 落地加工效应查询服务与分层Mapper,S-cfc-465 红单测转绿
+- 实现 food.rule.diseaseWeightGroup 病症权重分组计算宿主,红单测全部转绿
+
+### 其他
+- report(tdd): R68x 21分档错峰轮 — S0无残骸/断档沿承 · S7a backfill新认S-cfc-466 · --auto RECLAIM悬挂第8轮 → 直连dispatch.py重派3张stale GREEN卡verified · SC台账243/27零新增
+- report(tdd): R683 51分档错峰轮 — S0自愈1项 · --auto RECLAIM悬挂第7轮(EXIT124) → 直连dispatch.py重派2张stale GREEN卡verified(S-cfc-466→4090/467→pub) · SC台账243/27零新增
+
+### 测试
+- R684 0分标准轮 — 编译第97轮 main2507/test694 新基线 · 重启族P0新证据(08:28推送→08:36:29重启) · 探针302口径固化 · strict27恢复证实前值0系他档WIP污染
+- 补记最终提交 sha(93fc89276)与终态核验
+- 50分稳态校验档 src变更轮实测 — fix(f03)落地后编译第96轮 EXIT0 main2506/test694(test+1新AsOfPaidAtTest确认) 零漂移main · 两RED第3日承袭 · 重启族P0新换代07:46:29 · 双端Jest第47轮不可测
+
+
+## v1.0.2868 (2026-11-30)
+
+### 其他
+- report(tdd): R681 41分档错峰轮 — S0自愈1项/断档追平全量盘点 · --auto RECLAIM悬挂第6轮(EXIT124) → 直连dispatch.py重派2张stale GREEN卡verified(S-cfc-460/465→lan-204) · SC台账243/27零新增 · lan-189疑似宕
+
+### Bug 修复
+- 重算按product_orders.paid_at归属业绩+排除订单自身(修复订单21虚高70%: 真实10-29下单时应新秀10%而非11-14日志时间的70%)+mapper按paid_at聚合重载
+- sumPpointsByOrderId的@Select用<script>包裹(&lt;=需XML解析), 修复preview SQL语法错误全failed
+- 受益人SQL用真实列child_id(实体memberId映射), 修复preview total=0全空
+- preview兼容MySQL8返回的LocalDateTime(避免ClassCastException 500)
+
+
 ## v1.0.2867 (2026-11-29)
 
 ### 其他

+ 3 - 1
docs/superpowers/PROJECT-OVERVIEW.md

@@ -2,7 +2,9 @@
 
 **文档版本:** v2.24
 **日期:** 2026-10-31
-**本次更新(2026-11-28):** 新增后台推荐规则管理 12 端点 `POST /api/admin/food-rule/*`(权重/配伍/加工/病症权重四 Tab,版本化 + 灰度开关;S-cfc-502 / `food.ops.ruleManagement`),配套迁移507 三表,见 `api/API_REFERENCE.md` 4.67。
+**本次更新(2026-11-30 · S-cfc-491):** 反馈域在线客服 `POST /api/health/feedback/consult`(提交反馈转人工工单,SC-P-83 / 缺口 G-4),`/feedback/submit` 增附件载体(10MB 上限 400)+ 身份证/手机号脱敏 + reportId/draftId/memberId 越权 403 校验,迁移510 为 `report_feedback` 补 `attachment_url`,见 `api/API_REFERENCE.md` 4.37。
+**本次更新(2026-11-30):** 新增方案编辑/查看/版本历史 7 端点 `POST /api/growth/plan/{edit,edit-tasks,view,versions,versions/compare,version,version/modify}`(SC-P-42/43/48,能力键 `plan.edit.adjust`,超长 400 / 越权 403 / 版本不可篡改 403 / 空方案占位),配套迁移509(growth_plans 增 version/edited、status 扩宽 + growth_plan_version 快照表),见 `api/API_REFERENCE.md` 4.6。
+**上次更新(2026-11-28):** 新增后台推荐规则管理 12 端点 `POST /api/admin/food-rule/*`(权重/配伍/加工/病症权重四 Tab,版本化 + 灰度开关;S-cfc-502 / `food.ops.ruleManagement`),配套迁移507 三表,见 `api/API_REFERENCE.md` 4.67。
 **状态:** 已确认(v2.1 Phase 2-4 全栈完成)+ 虚拟支付改造(Tasks 1-12 已完成,退款闭环实施中)+ 新用户注册引导(12 Tasks 全栈完成)+ 家庭成员关系条增强(✅ 已实施)+ TabBar 重构(✅ 4Tab + 中间⭐扇形菜单,设计已对齐实现)+ **LIFETIME 终身会员(✅ 11 Tasks 全栈完成)** + **健康数据中心(✅ 全栈完成)** + **SKU 价格单位统一分 + 规格选择响应式修复(✅ 7 Tasks 全栈完成)** + **AI健康教练人格分化与管家自助选择(✅ 11 Tasks 全栈完成)** + **优惠券全链路改为家庭维度(待实施)** + **关系三图重构(关键人拓展章鱼图/珍珠图/能力图,设计规格已完成)** + **注册零填写+信息按需补充(✅ 全栈完成:登录直接进首页 + 家庭邀请独立页真实姓名/家庭身份必填 + 功能→信息字段映射表 + 添加成员手机号冲突邀请加入)** + **健康报告归属重分配(✅ 后端接口 + 管理端页面 + 小程序入口已实现,见 `specs/2026-10-05-health-report-reassign-design.md`)**
 **指标变化曲线·指标速查·指标关联(✅ 全栈完成:后端11任务+小程序M1-M8+管理端W1-W6;HBuilderX人工验收待用户执行,见 `specs/2026-10-09-indicator-change-curve-design.md`)**
 **饮食/睡眠/运动打卡接入任务完成链路(✅ 全栈完成:实体taskId字段 + 三个Controller isDailyProgress分流回写 + RepeatTaskGenerator每日生成打卡任务 + tasks.vue跳转 + 三打卡页taskId透传 + API文档;见 `specs/2026-10-13-health-checkin-task-linkage-design.md` 与 `plans/2026-10-13-health-checkin-task-linkage.md`)**

+ 12 - 1
docs/superpowers/api/API_REFERENCE.md

@@ -587,6 +587,13 @@ find cfc-backend/src/main/java -name "*XxxService.java" -o -name "*XxxController
 | `POST /api/growth/plan/confirm` | 确认方案(SC-P-44 家长确认/送审,能力键 `plan.confirm.submit`:generated→reviewed,确认幂等) |
 | `POST /api/growth/plan/submit` | 发布方案(SC-P-45 方案直接发布,能力键 `plan.confirm.submit`:generated/reviewed→active,发布幂等) |
 | `POST /api/growth/plan/tasks` | 方案任务清单(SC-P-47 `plan.task.list`:按 planId 锚定,返回 `source_type='plan' AND source_id=planId` 的任务明细,含状态/进度;`planId` 缺失→`planId不能为空`,方案不存在→`方案不存在`;任务增删与方案实时同步) |
+| `POST /api/growth/plan/edit` | 编辑方案文本(SC-P-42 `plan.edit.adjust`:body `{planId, content}`,持久化内容、version 递增、status=edited 已改标记;文本 >10000 字→400「超长」,越权/跨家庭→403「无权限」) |
+| `POST /api/growth/plan/edit-tasks` | 编辑方案任务项(同键:body `{planId, tasks}`,返回 `{status:'edited', edited, version, tasks}`;方案同步标记已改) |
+| `POST /api/growth/plan/view` | 方案详情视图(SC-P-43 同键:body `{planId}`,返回 `{sections, tasks, empty, placeholder}`;空方案返回占位不白屏,方案不存在→404,跨家庭→403) |
+| `POST /api/growth/plan/versions` | 版本列表(SC-P-48 同键:body `{planId}`,按版本号倒序返回快照序列供对比;跨家庭→403) |
+| `POST /api/growth/plan/versions/compare` | 版本对比(同键:body `{planId, fromVersion, toVersion}`,返回差异 Map;版本不存在→404「版本不存在」,不静默返回空差异) |
+| `POST /api/growth/plan/version` | 读取单个历史版本(同键:body `{versionId}`,只读;版本不存在→404) |
+| `POST /api/growth/plan/version/modify` | 修改历史版本(同键:一律 403「版本不可篡改:历史版本只读」,硬边界) |
 | `POST /api/growth/milestone/mark` | 标记成长里程碑(SC-P-51 / 缺口 G-2,能力键 `growth.milestone.mark`,S-cfc-367:系统/手动标,`milestoneType=manual/system`,同一 `(memberId, recordId, type)` 幂等返回同一里程碑 ID;返回 `Result<Long>`,作为时间线高亮依据) |
 | `POST /api/growth/milestone/marked` | 成长里程碑高亮判定(同键:`GrowthMilestoneService.isMarked`,返回 `Result<Map>` 含 `marked`;未标记不高亮,重复标记不翻转状态) |
 
@@ -1289,6 +1296,7 @@ aikanshe:
 |------|------|
 | `POST /api/health/feedback/submit` | 提交报告反馈(持久化 + AI 解答),请求 `{ reportId?, draftId?, memberId?, type, content }`,返回 `Result<ReportFeedback>` |
 | `POST /api/health/feedback/list` | 我的报告反馈列表(含 AI 解答),请求 `{ reportId? }`,返回 `Result<List<ReportFeedback>>`(按创建时间倒序,最多 50 条) |
+| `POST /api/health/feedback/consult` | 提交反馈并转人工客服(反馈域在线客服,SC-P-83 / 缺口 G-4),请求 `{ content, memberId?, attachmentUrl?, attachmentSize? }`,落库 `feedbackType=consult`、`aiStatus=pending`,不调用 AI,返回 `Result<ReportFeedback>` |
 
 **`/api/health/feedback/submit` 请求体:**
 ```json
@@ -1324,7 +1332,9 @@ aikanshe:
 
 - `aiStatus` 取值:`pending`(待解答)/ `answered`(AI 已解答)/ `failed`(AI 调用失败,仍会落库,`aiAnswer` 为空)。
 - 免费版每日仅限 1 次反馈解答(Redis 计数 `report:feedback:free:{userId}:{date}`,`memberLevel=FREE` 或为空时生效),超限返回 `Result.error("免费版每日仅限 1 次反馈解答,升级会员解锁更多")`;Redis 异常时 fail-open 放行。
-- `content` 必填且不超过 500 字。
+- `content` 必填且不超过 500 字;身份证/手机号自动脱敏后落库(仅保留前 3/6 后 4 位)。
+- `attachmentUrl?` / `attachmentSize?`:附件地址与字节数,单附件 >10MB(10485760 字节)返回 400『附件不超过 10MB』;列 `report_feedback.attachment_url`(迁移510)。
+- `reportId` / `draftId` / `memberId` 须归属当前用户,否则 403 拒绝、不落库(越权校验)。
 
 ---
 
@@ -3580,6 +3590,7 @@ W0.2 双配置中心合并:`product_config` 已并入 `service_config`(唯
 |------|------|
 | `POST /api/user/update`、`/info`、`/profile/backfill`、`/profile-stats`;`POST /api/family/user/update`;`POST /api/profile/my`;`POST /api/auth/profile/edit`(`AuthProfileService` 统一入口,`UpdateUserDTO.phone` 透传绑定手机 + 手机号/昵称边界校验) | 个人资料编辑(SC-P-64) |
 | `POST /api/notification/list`、`/read` | 消息中心/通知查看 + 已读(SC-P-65/78,`UserNotificationController`) |
+| `POST /api/notification/setting/get`、`/save` | 通知开关/提醒时间设置(SC-P-65/79,`NotificationSettingController`/`NotificationSettingService`;按登录 userId 隔离,未配置回显默认值,HH:mm 校验,关键安全通知不可关闭且关闭全部后仍放行) |
 | `POST /api/task/reminder-config/get`、`/save` | 提醒设置(开关/渠道/时机/偏移/完成表扬 + **日提醒开关+早晚时间**,SC-P-65/79) |
 | `POST /api/consent/record`、`/withdraw`、`/status`、`/check` | 隐私授权同意(SC-P-66,`ConsentController`) |
 | `POST /api/notices/list` | 公告(SC-P-78,GET+POST 历史遗留) |

+ 182 - 0
docs/tdd/orchestration/discovery-2026-11-30-1008.md

@@ -0,0 +1,182 @@
+# 需求发现(Requirement Discovery)台账 · 2026-11-30 10:08
+
+> **任务性质**:只读发现 + 文档产出。不改 `src/`、不改 `tests/e2e/`、不改 `API_REFERENCE.md` 登记行、不改 `.tdd/` 本地账本。
+> **聚焦范围**:2026-11-30 主线新落地的 4 组能力(共 12 个 HTTP 端点)的需求 / 测试覆盖缺口。
+> **判定口径**:逐项对照「需求原文锚点 → sc-key-map.md 登记 → 用例台账 → e2e spec → API 契约文档」,只登记证据可追溯的缺口;无依据者标「待人工核实」。
+> **纪律**:命中长期 blocker(G-304-1 / B-260-1 / B-325-1 等)只登记现象,**不改判为已解决**。
+
+---
+
+## 0. 范围与数据源
+
+| 序 | 数据源 | 用途 |
+|---|---|---|
+| D1 | `docs/superpowers/api/API_REFERENCE.md` | 接口与能力键契约台账(L561 / L590–596 / L3724 / L3739 / L1964 / L2007) |
+| D2 | `docs/tdd/orchestration/sc-key-map.md` | SC↔能力键↔阶段↔跑通状态唯一登记源(L136 / L157–160 / L165 / L272) |
+| D3 | `tests/user-scenarios/应用场景总览.md` | SC 需求原文(L78 / L102–105 / L110 / L398) |
+| D4 | `tests/test-cases/parent.md`、`tests/test-cases/human-butler.md` | 已有用户场景用例(三类流) |
+| D5 | `tests/e2e/**` | e2e / 契约 spec 实际覆盖 |
+| D6 | `docs/tdd/SRS.md`、`docs/需求分析/`、`docs/superpowers/specs/` | 需求规格侧锚点(本轮对 4 组能力**无专门规格文档**,见 §5 待人工核实) |
+| D7 | `docs/tdd/orchestration/report-dev-2026-11-30-0917.md`、`...-0952.md` | 实现使绿(YELLOW)状态旁证 |
+| D8 | 后端源码只读核对(仅用于判定「接口文档与实现是否一致」,不修改) | `GrowthPlanController.java` / `AIChatController.java` / `ButlerController.java` / `EnergyController.java` |
+
+**4 组能力 / 12 端点全景**
+
+| 组 | 能力键 | SC | 端点 | 实现侧锚点(D8) |
+|---|---|---|---|---|
+| A | `plan.edit.adjust` | SC-P-42 / 43 / 48 | `POST /api/growth/plan/{edit, edit-tasks, view, versions, versions/compare, version, version/modify}`(7) | `GrowthPlanController.java` L288/301/323/335/347/361/373 |
+| B | `plan.ai.generate` | SC-P-40 / 41 | `POST /api/ai/plan/generate`、`/api/ai/plan/regenerate-section`(2) | `AIChatController.java` L955 / L976 |
+| C | `butler.ai.collaborate` | SC-H-06 | `POST /api/butler/collaborate/{close, feedback, notify}`(3) | `ButlerController.java` L376 / L391 / L403 |
+| D | `energy.dimension.view` | SC-P-19 | `POST /api/energy/config`(1) | `EnergyController.java` L294 |
+
+---
+
+## 1. 组 A — `plan.edit.adjust`(成长方案编辑 / 查看 / 版本,7 端点)
+
+### 1.1 需求 / 能力键原文锚点
+
+- D1 `API_REFERENCE.md` L590–596(本轮新增 7 行,逐端点契约):
+  - L590 `POST /api/growth/plan/edit` —「编辑方案文本(SC-P-42 `plan.edit.adjust`:`{planId, content}`,持久化内容、version 递增、status=edited 已改标记;文本 >10000 字→400「超长」,越权/跨家庭→403「无权限」)」
+  - L591 `/edit-tasks` —「编辑方案任务项(同键:返回 `{status:'edited', edited, version, tasks}`;方案同步标记已改)」
+  - L592 `/view` —「方案详情视图(SC-P-43 同键:`{sections, tasks, empty, placeholder}`;空方案返回占位不白屏,方案不存在→404,跨家庭→403)」
+  - L593 `/versions` —「版本列表(SC-P-48 同键:按版本号倒序返回快照序列供对比;跨家庭→403)」
+  - L594 `/versions/compare` —「版本对比(同键:`{planId, fromVersion, toVersion}`,返回差异 Map;版本不存在→404「版本不存在」,不静默返回空差异)」
+  - L595 `/version` —「读取单个历史版本(同键:`{versionId}`,只读;版本不存在→404)」
+  - L596 `/version/modify` —「修改历史版本(同键:一律 403「版本不可篡改:历史版本只读」,硬边界)」
+- D2 `sc-key-map.md` L159 / L160 / L165:`SC-P-42 方案编辑/调整`、`SC-P-43 查看生成的方案`、`SC-P-48 方案版本/历史` → 键 `plan.edit.adjust`,**键阶段 RED / 未跑通**,证据 `S-cfc-280`。
+- D3 `应用场景总览.md` L104「SC-P-42 方案编辑/调整 — 编辑方案文本/任务项,边界:编辑后状态标记已改」;L105「SC-P-43 查看生成的方案 — 空方案不白屏」;L110「SC-P-48 方案版本/历史 — 版本列表→对比,版本不可篡改」。
+
+### 1.2 覆盖判定
+
+| 维度 | 判定 | 证据 |
+|---|---|---|
+| SC / 状态机登记 | **已登记** | D2 L159/L160/L165(RED) |
+| 用例台账 | **有**(功能/异常/权限三流齐全) | D4 `parent.md` L66/L67/L72(TC-P-42/43/48 功能),L167/L168/L173(-E 异常),L264/L265/L270(-P 权限) |
+| e2e spec | **无** | D4 上述 6 行 e2e 栏均为 `—`;D5 全仓检索 `growth/plan/edit|versions|view|version/modify` = 0 命中;`auth-guard-health-growth-plan.spec.js` L67–79 仅覆盖旧 13 端点(create/child/*/update/confirm/submit/list/draft-*),**不含本组 7 端点** |
+| 接口文档一致性 | **一致** | D1 L590–596 已补 7 行,与 D8 `GrowthPlanController.java` 7 个 `@PostMapping` 逐条对应 |
+
+### 1.3 缺口登记
+
+| ID | 需求 / 能力键(来源) | 缺口类型 | 可追溯现象 | 建议后续动作(仅建议) |
+|---|---|---|---|---|
+| D-01 | `plan.edit.adjust` / SC-P-42/43/48(D1 L590–596;D2 L159/160/165) | **无 e2e spec** | 7 个新端点在 `tests/e2e/**` 零命中;用例台账 e2e 栏全为 `—`。功能/异常/权限三流停在文档用例层,无执行证据。 | 补建 `e2e/api/growth-plan-edit-contract.spec.js`,覆盖 edit 超长 400、view 空方案占位、versions 倒序、version/modify 一律 403、跨家庭 403。 |
+| D-02 | `plan.edit.adjust` 跨家庭 403 契约(D1 L590/592/593「跨家庭→403」) | **无 e2e spec**(命中长期 blocker 现象) | D4 `TC-P-42-E`/`TC-P-43-P`/`TC-P-48-P` 的权限流为通用模板行(「以当前角色调用他人/非绑定家庭数据接口」),未端到端断言本组 7 端点的 403;长期 blocker **G-304-1(跨家庭越权拒绝缺失,8 权限点位 19 红)** 仍承袭未实测(见 `report-test-2026-11-29-R651-1633.md` L113)。**只登记现象,不改判 G-304-1 已解决**。 | 补越权 ISO 断言时先确认是否纳入 G-304-1 既有 8 点位口径;未纳入则登记为新越权面,不重复开重复编号。 |
+
+---
+
+## 2. 组 B — `plan.ai.generate`(AI 成长方案生成 / 板块重生成,2 端点)
+
+### 2.1 需求 / 能力键原文锚点
+
+- D2 `sc-key-map.md` L157「SC-P-40 生成 AI 方案(一键生成)⭐ → `plan.ai.generate`,S-cfc-279,LangGraph(AiGateway) 生成 overview+三板块,未购会员提示,超时 Fallback 不 500」;L158「SC-P-41 方案分板块重生成 → 同键,逐板块重生成,不丢其他板块」。
+- D3 `应用场景总览.md` L102–103(SC-P-40/41 同上口径)。
+- D1 `API_REFERENCE.md` L1964 出现「区别于 `regenerate-section`(整段重生成)」语义说明,但该处属**健康方案** `/api/health/plan/adjust` 章节(§4.49.1),非本组 `/api/ai/plan/*`;L2007 `/api/health/plan/generate` 亦为**健康方案域**,与本组不同。
+- D7 `report-dev-2026-11-30-0917.md` L52:`S-cfc-485 plan.ai.generate` 重派lan-204;git log `87d0abdf8 feat(plan.ai.generate): S-cfc-485 实现 AI 成长方案生成/板块重生成使红测转绿`。
+
+### 2.2 覆盖判定
+
+| 维度 | 判定 | 证据 |
+|---|---|---|
+| SC / 状态机登记 | **已登记** | D2 L157/L158(RED,S-cfc-279) |
+| 用例台账 | **有**(三流齐全) | D4 `parent.md` L21/L64/L65(TC-P-40 / 40-b / 41),L165/L166(-E),L262/L263(-P) |
+| e2e spec | **台账声称有,实际无有效覆盖** | D4 L21/L64 e2e 栏写 `e2e/ai-plan-task-flow.spec.js`,但该 spec D5 实测仅含 `/api/ai/chat/send`、`/api/ai/context`(L23–24),**不含 `/api/ai/plan/generate` 与 `/api/ai/plan/regenerate-section`**;L65 `TC-P-41` e2e 栏为 `—` |
+| 接口文档一致性 | **不一致** | D8 `AIChatController.java` L955 `/plan/generate`、L976 `/plan/regenerate-section` 已实现;D1 全文检索 `/api/ai/plan/generate`、`/api/ai/plan/regenerate-section` = **0 命中** |
+
+### 2.3 缺口登记
+
+| ID | 需求 / 能力键(来源) | 缺口类型 | 可追溯现象 | 建议后续动作(仅建议) |
+|---|---|---|---|---|
+| D-03 | `plan.ai.generate` / SC-P-40/41(D2 L157/158;D8 AIChatController L955/976) | **接口文档与实现不一致** | 2 个已实现端点在 `API_REFERENCE.md` 无登记行;文档仅有异构的 `/api/health/plan/generate` 与 `/api/health/plan/regenerate-section` 语义注释。 | 由接口文档维护方在 `API_REFERENCE.md` 补 2 行(权限/请求/返回/超时降级),并同步 `PROJECT-OVERVIEW.md` 索引;本次发现**不代改**。 |
+| D-04 | `plan.ai.generate` / SC-P-40/41(D4 L21/L64/L65 vs D5 `ai-plan-task-flow.spec.js` L23–24) | **无 e2e spec**(有效覆盖缺失) | TC-P-40/40-b 引用的 spec 不触达生成/重生成端点;TC-P-41 无 e2e。SC-P-40/41 因此不具备「三类流实际执行证据」。 | 补 `e2e/api/ai-plan-generate-contract.spec.js`(生成结果 overview+三板块、逐板块重生成不丢其他板块、未购会员拦截、超时降级不 500),并修正 `parent.md` e2e 栏指向。 |
+
+---
+
+## 3. 组 C — `butler.ai.collaborate`(管家 AI 协作闭环,3 端点)
+
+### 3.1 需求 / 能力键原文锚点
+
+- D2 `sc-key-map.md` L272「SC-H-06 真人管家 / 与 AI 管家协同闭环 → `butler.ai.collaborate`,S-cfc-255,闭环标记→知识反哺→反馈家长;可审计,**RED / 未跑通**」。
+- D3 `应用场景总览.md` L398「SC-H-06 — 目标:处理完回写闭环并反哺 AI;流程:闭环标记→知识反哺→反馈家长;边界:反哺审核;不泄露隐私;可审计;模块:知识/工单闭环 🟡」。
+- D1 `API_REFERENCE.md` L3724「§4.64.9 AI 管家会话(SC-H-06 协同的会话底座)」、L3739「`POST /api/ai/butler/send` … SC-H-06 主载体」——**仅登记会话/协同发起,未登记本组 3 个闭环端点**。
+- D1 `specs/2026-11-07-ai-butler-contract.md` L35(经 D1 L3754 索引):SC-H-06 载体登记为 `/api/ai/butler/send` + `/api/ai/chat/send`,状态 ✅「端点齐全」——该结论早于本组 3 端点落地,**未覆盖 close/feedback/notify**。
+- D7 `report-dev-2026-11-30-0952.md` L72:`46d34f94a S-cfc-480 butler.ai.collaborate` YELLOW(实现使绿,SC-H-06 闭环→反哺→审核→反馈→审计)。
+
+### 3.2 覆盖判定
+
+| 维度 | 判定 | 证据 |
+|---|---|---|
+| SC / 状态机登记 | **已登记** | D2 L272(RED,S-cfc-255) |
+| 用例台账 | **有**(三流齐全) | D4 `tests/test-cases/human-butler.md` L18(TC-H-06 功能:闭环→反哺→审核→知识库命中)、L30(-E 隐私脱敏/未审不入库/幂等)、L42(-P 审核权归运营 403) |
+| e2e spec | **无** | D5 全仓检索 `collaborate/close|feedback|notify` = 0 命中;`human-butler-workorder.spec.js` L200–215 仅 `test.fixme` 期望 `/api/butler/workorder/close`(**不同端点**,且注明「后端尚无工单实体」),不触达 `/api/butler/collaborate/*` |
+| 接口文档一致性 | **不一致** | D8 `ButlerController.java` L376/L391/L403 已实现 3 端点;D1 全文检索 `/api/butler/collaborate/{close,feedback,notify}` = **0 命中** |
+
+### 3.3 缺口登记
+
+| ID | 需求 / 能力键(来源) | 缺口类型 | 可追溯现象 | 建议后续动作(仅建议) |
+|---|---|---|---|---|
+| D-05 | `butler.ai.collaborate` / SC-H-06(D2 L272;D8 ButlerController L376/391/403) | **接口文档与实现不一致** | 3 个已实现闭环端点在 `API_REFERENCE.md` 零登记;§4.64.9/§4.64.10 只记 `/api/ai/butler/send`(协同发起),审计链无契约行。 | 由接口文档维护方补 3 行(闭环字段/反哺审核/通知审计、越权与脱敏语义),并同步 `PROJECT-OVERVIEW.md` 索引;本次发现**不代改**。 |
+| D-06 | `butler.ai.collaborate` / SC-H-06(D4 human-butler.md L18/30/42 vs D5) | **无 e2e spec** | TC-H-06 三流仅文档用例;现有 `human-butler-workorder.spec.js` 的 fixme 指向另一路径 `/api/butler/workorder/close`(不同端点)。SC-H-06 无三类流执行证据。 | 补 `e2e/api/butler-collaborate-contract.spec.js`(闭环留痕→反哺入待审→未审不入库→审核通过可检索→审计可读;隐私脱敏 403);同步核实 fixme 是否应随新端点转绿(**仅建议,不代判**)。 |
+
+---
+
+## 4. 组 D — `energy.dimension.view`(能量维度只读配置查看,1 端点)
+
+### 4.1 需求 / 能力键原文锚点
+
+- D1 `API_REFERENCE.md` L561「`POST /api/energy/config` | 能量配置」——**仅 1 行极简登记,无请求/返回/异常契约**。
+- D2 `sc-key-map.md` L136「SC-P-19 家长 / 能量维度配置查看 → `energy.dimension.view`,S-cfc-266,五维定义与权重只读,未同步展示兜底,**RED / 未跑通**」。
+- D3 `应用场景总览.md` L78「SC-P-19 — 查看身/心/智/行/富定义与权重;边界:配置未同步时展示兜底」。
+- D7 `report-dev-2026-11-30-0952.md` L73:`600c1a2d7 S-cfc-483 energy.dimension.view` YELLOW(实现使绿)。
+
+### 4.2 覆盖判定
+
+| 维度 | 判定 | 证据 |
+|---|---|---|
+| SC / 状态机登记 | **已登记** | D2 L136(RED,S-cfc-266) |
+| 用例台账 | **有**(三流齐全) | D4 `parent.md` L42(TC-P-19 功能)、L143(-E 配置缺失兜底 + 权重和非法 400)、L241(-P 越权 403/401) |
+| e2e spec | **存在但有效覆盖不足** | D4 L42 的 e2e 栏为 `—`(台账未挂 spec);D5 `roles/parent/energy-dashboard.spec.js` L49–56 `[场景4] 查看能量配置` 仅 POST `{}` 并断言 `assertApiSuccess`,**未断言维度定义/权重/兜底内容,无异常流与权限流** |
+| 接口文档一致性 | **不一致(登记过简)** | D8 `EnergyController.java` L294 `@PostMapping("/config")` 已实现;D1 L561 仅「能量配置」四字,缺请求/响应/权限/异常语义 |
+
+### 4.3 缺口登记
+
+| ID | 需求 / 能力键(来源) | 缺口类型 | 可追溯现象 | 建议后续动作(仅建议) |
+|---|---|---|---|---|
+| D-07 | `energy.dimension.view` / SC-P-19(D4 L42/143/241 vs D5 energy-dashboard.spec.js L49–56) | **无 e2e spec**(有效覆盖不足) | 唯一触达 `/api/energy/config` 的 e2e 为空体 happy-path smoke;用例台账 e2e 栏仍为 `—`,三流证据无法从台账追溯到该 spec。 | 扩充 `energy-dashboard.spec.js` 场景4:断言身/心/智/行/富口径与权重字段、配置缺失兜底、越权 403;并在 `parent.md` TC-P-19 行回填 spec 锚点。 |
+| D-08 | `energy.dimension.view` / SC-P-19(D1 L561;D8 EnergyController L294) | **接口文档与实现不一致** | 契约行仅 4 字,无法支撑 SC-P-19 的「只读定义/权重 + 未同步兜底」验收口径。 | 由接口文档维护方补全 L561 契约(请求体、返回维度结构、只读语义、异常提示),本次发现**不代改**。 |
+
+---
+
+## 5. 补充观察(非四类硬缺口,供人工核实)
+
+| ID | 现象 | 依据 | 处置建议(仅建议) |
+|---|---|---|---|
+| O-01 | **状态机台账阶段滞后**:4 个能力键在 `sc-key-map.md` 的「键阶段」仍记 **RED**,而 D7 DEV 报告已记实现使绿 **YELLOW**(S-cfc-460 `plan.edit.adjust` / S-cfc-480 `butler.ai.collaborate` / S-cfc-483 `energy.dimension.view` / S-cfc-485 `plan.ai.generate`)。 | D2 L136/157/158/159/160/165/272 vs D7 `...-0917.md` L52/L58、`...-0952.md` L28/L72/L73 | 请台账维护方确认是否按「实现使绿≠SC 跑通」口径把键阶段同步为 YELLOW、跑通状态仍保留「未跑通」;本次发现**不代改台账**。 |
+| O-02 | **长期 blocker 承袭**:G-304-1(跨家庭越权拒绝缺失,8 权限点位 19 红)在 11-28~11-30 多轮报告均为「承袭·未实测」,本组 A 的跨家庭 403 契约未端到端验证。 | `report-test-2026-11-29-R651-1633.md` L113、`report-test-2026-11-30-R677-0623.md` L14 | 只登记现象,**不改判已解决**;补断言前先确认是否属于既有 8 点位。 |
+| O-03 | **需求规格侧无专门设计文档**:4 组能力的规格锚点仅见于「应用场景总览 + API_REFERENCE + sc-key-map」,`docs/superpowers/specs/` 无对应设计文档(AI 管家契约 `2026-11-07-ai-butler-contract.md` L35 早于本组落地)。 | D6 全目录检索 4 键 = 0 命中(仅 `2026-11-07-ai-butler-contract.md` 的 SC-H-06 旧载体行) | **待人工核实**:是否需补 specs 设计文档或确认以 API_REFERENCE 为唯一契约源。 |
+| O-04 | **权限流用例为通用模板行**:`TC-P-19/40/41/42/43/48-P` 均为同一句「以当前角色调用他人/非绑定家庭数据接口(报告/任务/方案/订单/能量)」,`TC-H-06-P` 为知识库审核权 403,均未逐端点断言。 | D4 `parent.md` L241/L262–265/L270;`human-butler.md` L42 | **待人工核实**:是否将通用模板行拆成端点级断言(与 D-02 联动)。 |
+
+---
+
+## 6. 汇总统计与建议优先级
+
+### 6.1 按缺口类型计数(本台账登记条目数)
+
+| 缺口类型 | 条目 | ID |
+|---|---|---|
+| 无测试用例 | **0** | 4 组能力均有功能/异常/权限三流文档用例(见 §1.2/§2.2/§3.2/§4.2) |
+| 无 e2e spec | **4** | D-01、D-02、D-04、D-06、D-07(其中 D-02 为 blocker 现象登记、D-07 为覆盖不足;按「无有效 e2e 覆盖」归集为 5 条现象,硬缺口计 4 条:D-01/D-04/D-06/D-07) |
+| 状态机未登记 | **0** | 4 键均已在 `sc-key-map.md` 登记(仅阶段滞后,见 O-01) |
+| 接口文档与实现不一致 | **3** | D-03、D-05、D-08 |
+
+> 说明:主表 D-01~D-08 共 **8 条发现条目**;其中「无 e2e spec」类 5 条(D-01/D-02/D-04/D-06/D-07,D-02 为 G-304-1 现象登记),「接口文档与实现不一致」3 条(D-03/D-05/D-08)。四类硬缺口口径下:无测试用例 0 / 无 e2e spec 4(D-01/D-04/D-06/D-07)/ 状态机未登记 0 / 接口文档与实现不一致 3。
+
+### 6.2 建议优先级(仅建议,不代执行)
+
+1. **P1 · 接口契约补齐**:D-03(AI 生成 2 端点)、D-05(管家协作 3 端点)、D-08(energy/config 契约过简)——5 个已实现端点无可用契约或契约过简,阻塞验收锚定。
+2. **P1 · e2e 补齐**:D-01(7 端点)、D-04(生成/重生成)、D-06(协作闭环)——使 3 组能力具备三类流执行证据,SC 方可申请转正。
+3. **P2 · 台账与用例同步**:D-07(energy e2e 回填)、O-01(键阶段 RED→YELLOW 核实)、O-03/O-04(规格与权限断言粒度核实)。
+4. **长期 blocker**:O-02(G-304-1)按既有口径承袭,只登记现象。
+
+---
+
+*发现人:需求发现编排节点 · 生成时间 2026-11-30 10:08 · 只读发现,未修改任何源码 / 测试 / 接口台账 / 本地账本。*

+ 102 - 0
docs/tdd/orchestration/report-dev-2026-11-30-0800.md

@@ -0,0 +1,102 @@
+# 研发负责人工作汇报(CF 41 分档错峰档 · 收割)
+
+> 档位说明:本档=CF 错峰档(41 分档,07:45 触发,按触发漂移容忍完整跑轮;`--mutex-check` 判定 `slot_now=s51`、`slot_of_active=s31`、`released_by_other_slot` 他档 s31 刚收口 0.6min 放行)。**错峰档职责**:跳过 S2 失败补跑(由 01 分档标准轮承担);**S0 检出断档(monitor 378.5min / worklog 975.7min ≥60min)+ 自愈 1 项残骸**→ 按 S0 分支②断档追平,S3 改走**全量盘点**(覆盖错峰档默认精简)并推动 verified 派发。S5 心跳 / S6 填充未启用跳过并注明。
+
+## 基本信息
+
+| 项目 | 内容 |
+|------|------|
+| 汇报人 | 研发负责人(自动化收割轮 · software-company 专家团编排) |
+| 汇报周期 | 2026-11-30 07:45 开工 ~ 08:01 收口(错峰档 41 分档,slot_now=s51) |
+| 负责模块/单元范围 | 全量(scope 空=不限);主线 ref=`origin/cfclub` |
+
+## 一、本轮工作数据汇总
+
+### 1.0 场景覆盖矩阵(硬职责增列)
+
+单一计数源:`docs/tdd/orchestration/sc-key-map.md`(对应 `tests/user-scenarios/应用场景总览.md`)。
+
+| 指标 | 值 | 说明 |
+|------|-----|------|
+| 场景总数 | 243 | sc-key-map 台账 |
+| 累计已跑通 | 27 | 沿承 s11 档口径(研发侧不代改台账) |
+| 本轮新增跑通 | 0 | 无新增三类流转正;本轮无 SC 关联实现提交 |
+| 失败 | 0 | 无新证伪场景 |
+| 阻塞 | 0 | 实时 blockers 登记 0 |
+| 未跟踪 | 216 | =243−27−0−0−0 |
+
+### 1.1 问题接收与处置
+
+| 指标 | 数量 | 填写说明 |
+|------|------|---------|
+| 收到的测试反馈问题数 | 0 | 实时 blockers 登记 0 |
+| 已解决问题数 | 0 | backfill 幂等重认净 0(done 466 持平),无新证据可认领 |
+| 待解决研发问题数 | 19 | dispatched 旧卡(74–189h 无 finish_note,见风险段) |
+
+### 1.2 任务分发与会话管理
+
+| 指标 | 数量 | 填写说明 |
+|------|------|---------|
+| 本轮派发成功 | 2 | 直连 `dispatch.py` 重派 verified(--auto fault 下派发保底兑现) |
+| 本轮派发失败 | 0 | 两条直连均 verified=true |
+| 派发超限/未派 | — | --auto fault 致自动派发 0 回执;pending=0 无新卡可自动派 |
+| 派发前会话状态 | 19 dispatched / 0 pending / 0 idle-card | 节点余位:lan-189 **宕**(10061 拒连)·lan-204 余0(承接 2 重派)·local-lan-4090 余6·mes-local 余2·prod-etotem 余3(生产跳过)·pub-iwintrue 余5;wb-cloud 401 沿承 |
+| 节点异常 | 2 | lan-189 连接被拒(疑似宕);wb-cloud list_sessions 401 |
+
+**各会话当前工作状态列表(1.2b 必填)**:
+
+| 任务 | 实例 | 状态 | 说明 |
+|------|------|------|------|
+| S-cfc-460 plan.edit.adjust | lan-204 | dispatched(重派) | ses_dd63ef5b7ffejN3RF3s3XTOmxl,verified |
+| S-cfc-465 food.rule.processingEffect | lan-204 | dispatched(重派) | ses_dd63e7e3cffe0BB8XajZEhCoif,verified |
+| 其余 17 张 TDD-GREEN 在途卡 | 各节点 | dispatched(stale) | 74–189h 无 finish_note,本轮未重派(预算让位) |
+
+### 1.3 需求/设计/测试用例变更感知
+
+`--changes --days 7`:300+ 文件变更,**无新增能力键(0→0,均为既有键状态/内容变化)**,无需 --add-task 建新 RED。变更集中:docs 收口(f10b9ec9 chore wip 119 文件)、food/shop.review/admin.family 实现(79e3f4d7/fe5b2ecd/ee86e837/37c2f7c8)、测试侧 SC-A-01 e2e 与匿名鉴权守卫用例(c80ef0242/d14bdf31e)。
+
+### 1.4 Git 证据核验
+
+| 指标 | 值 |
+|------|-----|
+| 远程 tip(开工 fetch 后) | `bc27b4b45`(11-30 07:40 R680 01分标准轮) |
+| 本地 HEAD | `df41db226`(落后 216 提交,1 local-only;主工作树漂移,只报不动) |
+| 汇报提交 | 单文件临时索引基于最新 tip `bc27b4b45` 重建(禁 add -A / checkout / stash) |
+
+## 二、S0–S11 执行明细
+
+| 步骤 | 结果 |
+|------|------|
+| S0 中断自愈 | `[cleaned]` worklog.active 死记录 pid=50932(--auto started 11-30 07:31:15)已收口;断档 monitor 378.5min / worklog 975.7min → 分支②追平 |
+| S1 互斥门 | PASS(released_by_other_slot:他档 s31 收口 0.6min,worklog_stale=0 放行;worklog.active=null;locks 空) |
+| S2 失败补跑 | 错峰档跳过(01 分档标准轮承担) |
+| S3 盘点 | **全量**(断档追平):RED5/YELLOW131/GREEN10/DONE117;部署 pending140/confirmed80;账本510 done466·disp19·fail24·sup1·pend0;--changes 0 新键;--clean-check 跳过(413 处他人 WIP,只报不动);resume dry-run 候选 0;git log -8 见上 |
+| S4 恢复 | 0(prod-etotem 生产跳过,无候选) |
+| S5 心跳 | disabled 跳过(config heartbeat.enabled=false) |
+| S6 填充 | disabled 跳过(config fill_capacity.enabled=false) |
+| S7a backfill | EXIT=0 批量幂等重认 ~30 键(ai.aiyunyi456~478·coach458/488·diet461·membership462·health463·food464/501/502·admin.family498/503·shop.review499/500·activity490·auth486),净 0 done466 不变 |
+| **S7 --auto** | **EXIT=124(200s 超时杀)RECLAIM 悬挂 fault 第 6 轮复现**,仅版本预检一行零派发回执 → 派发保底直连 `dispatch.py --task` 重派 2 张 stale GREEN 卡 verified(S-cfc-460→lan-204、S-cfc-465→lan-204) |
+| S8 池空续建 | 0 add-task:pending=0、--changes 0 新键、blockers 0、SC 无新缺口;RED5 键(contact.card.manage/food.rule.pairingMatrix/privacy.setting.config/tongue.emotion.capture/admin.family.workbenchPolish)TDD-GREEN 卡生成被 --auto fault 阻塞 |
+| S9 收口 | 单文件临时索引提交本汇报(GIT_INDEX_FILE,父=最新 tip) |
+| S10 汇报 | 本文件 |
+
+## 三、阻塞与风险
+
+| 级别 | 项 | 说明 |
+|------|-----|------|
+| P0 | **--auto RECLAIM 悬挂 fault 连续第 6 轮** | 19 张 dispatched 旧卡(74–189h 无 finish_note、无 requeue 标记)逐键全量证据核验超时→无限 deferred→--auto 永不进入派发(EXIT=124)。修法方向:RECLAIM 批量/上限化核验,或先把 19 张 stale 在途卡批量 requeue 回池(requeue 依赖 --auto 主流程,须直连绕行) |
+| P1 | lan-189 节点疑似宕 | 直连派发时报 WinError 10061 连接被拒(192.168.16.189:4090);派发已自动改投 lan-204,需运维确认 lan-189 状态 |
+| P1 | 部署 pending 140 单调上升 | O-24 沿承,待部署链收敛 |
+| P2 | 台账 243 vs 测试侧 27 口径差 | 沿承,转正归测试侧 |
+| P2 | wb-cloud 401 | list_sessions 授权失败沿承 |
+| P2 | monitor 循环停摆 378min | 建议标准轮/运维确认重启 |
+
+## 四、下一步事项
+
+| 事项 | 依赖 | 预估 |
+|------|------|------|
+| 收敛 --auto RECLAIM 悬挂(批量/上限化核验,或直连批量 requeue 19 张 stale 卡回池) | 需改脚本 RECLAIM 环节或绕行 requeue 入口 | 下一档优先 |
+| 续派剩余 17 张 stale GREEN 在途卡(逐档直连兜底) | lan-204 余0 已承接 2 张;后续投 local-lan-4090/pub-iwintrue/mes-local 余位 | 逐档 |
+| 生成并派发 RED5 键 TDD-GREEN 卡 | --auto fault 修复后由 --auto 生成 | 修复后 |
+| lan-189 节点 / monitor 循环恢复 | 运维 | 待确认 |
+| 部署 pending 140 收敛 / 台账 243vs27 同步 | 测试/部署侧 | 沿承 |

+ 102 - 0
docs/tdd/orchestration/report-dev-2026-11-30-0825.md

@@ -0,0 +1,102 @@
+# 研发负责人工作汇报(CF 51 分档错峰档 · 收割)
+
+> 档位说明:本档=CF 错峰档(51 分档,08:06 触发,按触发漂移容忍完整跑轮;`--mutex-check` 判定 `slot_now=s11`、`slot_of_active=s51`、`released_by_other_slot` 他档 s51 刚收口 1.7min 放行,worklog_stale_minutes=0)。**错峰档职责**:跳过 S2 失败补跑(01 分档标准轮承担);S3 走**精简盘点**(跳 --changes/--clean-check,由标准轮承接)。S5 心跳 / S6 填充未启用跳过并注明。**派发保底兑现**:--auto fault 下直连 dispatch.py 重派 2 张 stale GREEN 卡 verified。
+
+## 基本信息
+
+| 项目 | 内容 |
+|------|------|
+| 汇报人 | 研发负责人(自动化收割轮 · software-company 专家团编排) |
+| 汇报周期 | 2026-11-30 08:06 开工 ~ 08:25 收口(错峰档 51 分档,slot_now=s11) |
+| 负责模块/单元范围 | 全量(scope 空=不限);主线 ref=`origin/cfclub` |
+
+## 一、本轮工作数据汇总
+
+### 1.0 场景覆盖矩阵(硬职责增列)
+
+单一计数源:`docs/tdd/orchestration/sc-key-map.md`(对应 `tests/user-scenarios/应用场景总览.md`)。
+
+| 指标 | 值 | 说明 |
+|------|-----|------|
+| 场景总数 | 243 | sc-key-map 台账(主表 243 行) |
+| 累计已跑通 | 27 | 标题口径:O-3 收口 5 + 游客域 10 + 各复验批转正 12 |
+| 本轮新增跑通 | 0 | 无新增三类流转正;本轮无 SC 关联实现提交 |
+| 失败 | 0 | 无新证伪场景 |
+| 阻塞 | 0 | 状态机 blockers 登记 0 |
+| 未跟踪 | 216 | =243−27−0−0−0(与 s41/s01 档一致) |
+
+### 1.1 问题接收与处置
+
+| 指标 | 数量 | 填写说明 |
+|------|------|---------|
+| 收到的测试反馈问题数 | 0 | 实时 blockers 登记 0 |
+| 已解决问题数 | 0 | backfill 幂等重认净 0(done 466 持平,本轮无新证据) |
+| 待解决研发问题数 | 17 | dispatched 旧卡(重派后剩 17 张 stale,见风险段) |
+
+### 1.2 任务分发与会话管理
+
+| 指标 | 数量 | 填写说明 |
+|------|------|---------|
+| 本轮派发成功 | 2 | 直连 `dispatch.py --task` 重派 verified(--auto fault 下派发保底兑现) |
+| 本轮派发失败 | 0 | 两条直连均 verified=true |
+| 派发超限/未派 | — | --auto fault(EXIT=124)致自动派发 0 回执;重派前 pending=0 无新卡 |
+| 派发前会话状态 | 19 dispatched → 17 / 0 pending / 0 idle-card | 节点:lan-189 疑似宕(沿承)· local-lan-4090 承接 1 张 · pub-iwintrue 承接 1 张;wb-cloud 401 沿承 |
+| 节点异常 | 2 | lan-189 连接被拒(疑似宕,沿承);wb-cloud list_sessions 401 |
+
+**各会话当前工作状态列表(1.2b 必填)**:
+
+| 任务 | 实例 | 状态 | 说明 |
+|------|------|------|------|
+| S-cfc-466 food.rule.diseaseWeightGroup | local-lan-4090 | dispatched(重派) | ses_dd62a2a2fffenRZj4bB55C889r,verified=true |
+| S-cfc-467 food.rule.diseaseWeightGroup 关联卡 | pub-iwintrue | dispatched(重派) | ses_dd629d2feffebL2y17M6Hf1WZj,verified=true |
+| 其余 17 张 TDD-GREEN 在途 stale 卡 | 各节点 | dispatched(stale) | 75–189h 无 finish_note,本轮未重派(预算让位) |
+
+### 1.3 需求/设计/测试用例变更感知
+
+错峰档精简盘点跳过 `--changes`(由 01 分档标准轮 R680 承接,其记录 300+ 文件 0 新增能力键)。本轮 git log 显示测试侧活跃:R682 匿名鉴权守卫用例 TC-AU-U429~U444(d14bdf31e);实现侧 R683 重算按 paid_at 归属业绩(36522a427)。
+
+### 1.4 Git 证据核验
+
+| 指标 | 值 |
+|------|-----|
+| 远程 tip(开工 fetch 后) | `ecdf91b12`(11-30 08:04 R681 41 分档错峰轮) |
+| 本地 HEAD | 落后若干提交,主工作树 413 处他人 WIP,只报不动 |
+| 汇报提交 | 单文件临时索引基于最新 tip `ecdf91b12` 重建(禁 add -A / checkout / stash) |
+
+## 二、S0–S11 执行明细
+
+| 步骤 | 结果 |
+|------|------|
+| S0 中断自愈 | `[cleaned]` worklog.active 死记录 pid=32108(--auto started 11-30 07:55:52,R680 遗留)已收口;断档 monitor 398.9min / worklog 971.5min → **判 monitor 循环停摆陈旧读数**(git 持续活跃:R681 08:04、R682 07:36),按错峰指令走精简盘点 |
+| S1 互斥门 | PASS(released_by_other_slot:他档 s51 收口 1.7min,worklog_stale=0 放行;worklog.active=null;locks 空;slot_now=s11/slot_of_active=s51) |
+| S2 失败补跑 | 错峰档跳过(01 分档标准轮承担) |
+| S3 盘点 | **精简**:RED5/YELLOW131/GREEN10/DONE117(共 263 键);部署 pending140/confirmed80;账本 510(done466·disp19→17·fail24·sup1·pend0·orphan0);resume dry-run 候选 0;--inspect 角色门拦截(仅测试角色)跳过;git log -8 见上;--changes/--clean-check 由标准轮承接 |
+| S4 恢复 | 0(prod-etotem 生产跳过,无候选) |
+| S5 心跳 | disabled 跳过(config heartbeat.enabled=false) |
+| S6 填充 | disabled 跳过(config fill_capacity.enabled=false) |
+| S7a backfill | EXIT=0 批量幂等重认 ~30 键(ai.aiyunyi456~478·coach458/488·diet461·membership462·health463·food464/501/502·admin.family498/503·shop.review499/500·activity490·auth486·family481),净 0 done466 不变 |
+| **S7 --auto** | **EXIT=124(420s 超时杀)版本预检后静默 hang(RECLAIM 悬挂 fault 第 7 轮复现)**,仅版本预检一行零派发回执 → 派发保底直连 `dispatch.py --task` 重派 2 张 stale GREEN 卡 verified(S-cfc-466→local-lan-4090、S-cfc-467→pub-iwintrue) |
+| S8 池空续建 | 0 add-task:pending=0、--changes 未跑(标准轮承接)、blockers 0、SC 无新缺口;RED5 键 TDD-GREEN 卡生成被 --auto fault 阻塞 |
+| S9 收口 | 单文件临时索引提交本汇报(GIT_INDEX_FILE,父=最新 tip ecdf91b12) |
+| S10 汇报 | 本文件 |
+
+## 三、阻塞与风险
+
+| 级别 | 项 | 说明 |
+|------|-----|------|
+| P0 | **--auto RECLAIM 悬挂 fault 连续第 7 轮**(R553 11-28 13:33 / R681 / 本档 08:14) | 17 张 dispatched 旧卡(75–189h 无 finish_note)逐键全量证据核验超时→无限 deferred→--auto 永不进入派发(EXIT=124)。修法方向:RECLAIM 批量/上限化核验,或先把 stale 在途卡批量 requeue 回池(requeue 依赖 --auto 主流程,须直连绕行) |
+| P1 | lan-189 节点疑似宕(沿承) | 直连派发报 WinError 10061;派发自动改投其他节点,需运维确认 |
+| P1 | 部署 pending 140 单调上升(沿承) | O-24 沿承,待部署链收敛 |
+| P2 | 台账 243 vs 测试侧 27 口径差(沿承) | 转正归测试侧 |
+| P2 | wb-cloud 401(沿承) | list_sessions 授权失败 |
+| P2 | monitor 循环停摆 398min(沿承) | 建议标准轮/运维确认重启 |
+
+## 四、下一步事项
+
+| 事项 | 依赖 | 预估 |
+|------|------|------|
+| 收敛 --auto RECLAIM 悬挂(批量/上限化核验,或直连批量 requeue 17 张 stale 卡回池) | 需改脚本 RECLAIM 环节或绕行 requeue 入口 | 下一档优先 |
+| 续派剩余 17 张 stale GREEN 在途卡(逐档直连兜底) | local-lan-4090/pub-iwintrue 承接后余位收窄;后续逐档轮换 | 逐档 |
+| 生成并派发 RED5 键 TDD-GREEN 卡 | --auto fault 修复后由 --auto 生成 | 修复后 |
+| lan-189 节点 / monitor 循环恢复 | 运维 | 待确认 |
+| 部署 pending 140 收敛 / 台账 243vs27 同步 | 测试/部署侧 | 沿承 |

+ 104 - 0
docs/tdd/orchestration/report-dev-2026-11-30-0830.md

@@ -0,0 +1,104 @@
+# 研发负责人工作汇报(CF 21 分档错峰档 · 收割)
+
+> 档位说明:本档=CF 错峰档(21 分档,08:28 触发,按触发漂移容忍完整跑轮;`--mutex-check` PASS:state mtime 10.1min>5、worklog.active=null、locks 空、slot_now=s31/slot_of_active=s11、worklog_stale_minutes=0 禁 pid 第二关)。**错峰档职责**:跳过 S2 失败补跑(01 分档标准轮 R680 承担);S3 走**精简盘点**(跳 --changes/--clean-check,由标准轮承接)。S5 心跳 / S6 填充未启用跳过并注明。**派发保底兑现**:--auto RECLAIM 悬挂(第 8 轮)下,直连 `dispatch.py --task` 重派 3 张 stale GREEN 卡 verified。
+
+## 基本信息
+
+| 项目 | 内容 |
+|------|------|
+| 汇报人 | 研发负责人(自动化收割轮 · software-company 专家团编排) |
+| 汇报周期 | 2026-11-30 08:28 开工 ~ 08:4x 收口(错峰档 21 分档,slot_now=s31) |
+| 负责模块/单元范围 | 全量(scope 空=不限);主线 ref=`origin/cfclub` |
+
+## 一、本轮工作数据汇总
+
+### 1.0 场景覆盖矩阵(硬职责增列)
+
+单一计数源:`docs/tdd/orchestration/sc-key-map.md`(对应 `tests/user-scenarios/应用场景总览.md`)。
+
+| 指标 | 值 | 说明 |
+|------|-----|------|
+| 场景总数 | 243 | sc-key-map 台账(主表 243 行) |
+| 累计已跑通 | 27 | 标题口径:O-3 收口 5 + 游客域 10 + 各复验批转正 12 |
+| 本轮新增跑通 | 0 | 无新增三类流转正;本轮无 SC 关联新实现提交 |
+| 失败 | 0 | 无新证伪场景 |
+| 阻塞 | 0 | `--blockers` 登记 0 |
+| 未跟踪 | 216 | =243−27−0−0−0(与 s51/s41/s01 档一致) |
+
+### 1.1 问题接收与处置
+
+| 指标 | 数量 | 填写说明 |
+|------|------|---------|
+| 收到的测试反馈问题数 | 0 | `--blockers` 登记 0 |
+| 已解决问题数 | 1 | backfill 新认 S-cfc-466 → done(证据 ba681d713960,11-30 08:28 红单测全绿提交) |
+| 待解决研发问题数 | 15 | dispatched stale 卡(18→15,本档重派 3 张后仍无证据的 >24h 卡,见风险段) |
+
+### 1.2 任务分发与会话管理
+
+| 指标 | 数量 | 填写说明 |
+|------|------|---------|
+| 本轮派发成功 | 3 | 直连 `dispatch.py --task` 重派 verified(--auto fault 下派发保底兑现) |
+| 本轮派发失败 | 0 | 三条直连均 verified=true |
+| 派发超限/未派 | — | --auto fault(RECLAIM 悬挂第 8 轮,400s+ 无产出→kill)致自动派发 0 回执;重派前 pending=0 无新卡 |
+| 派发前会话状态 | 18 dispatched / 0 pending / 0 idle-card | 节点:lan-189 4/4 超限、lan-204 剩 2(承接 1)、local-lan-4090 剩 6(承接 2)、mes-local 7/6 超限、prod-etotem 剩 3(生产跳过)、pub-iwintrue 剩 5;wb-cloud 401 沿承 |
+| 节点异常 | 2 | mes-local 超限 7/6、lan-189 满配 4/4;wb-cloud list_sessions 401 |
+
+**各会话当前工作状态列表(1.2b 必填)**:
+
+| 任务 | 实例 | 状态 | 说明 |
+|------|------|------|------|
+| S-cfc-479 ai.aiyunyi.reportDetail | local-lan-4090 | dispatched(重派) | ses_dd6154e96ffebayX0BISS6U5SF,verified=true |
+| S-cfc-480 butler.ai.collaborate | lan-204 | dispatched(重派) | ses_dd61515afffeWYFizqojYol5Wq,verified=true |
+| S-cfc-482 points.ledger.view | local-lan-4090 | dispatched(重派) | ses_dd615036affeY7gYabIA6Cttr2,verified=true |
+| S-cfc-460 plan.edit.adjust / S-cfc-465 food.rule.processingEffect / S-cfc-467 diet.menu.pairingConstraint | 各节点 | dispatched | 11-30 08:00~08:23 新派,在途 |
+| 其余 15 张 TDD-GREEN stale 在途卡 | 各节点 | dispatched(stale) | 11-26~11-27 派发,>24h 无 finish_note,本轮未重派(预算让位) |
+
+### 1.3 需求/设计/测试用例变更感知
+
+错峰档精简盘点跳过 `--changes`(由 01 分档标准轮 R680 承接)。本轮 git log -20:测试侧活跃(R682 匿名鉴权守卫用例 TC-AU-U429~U444,d14bdf31e;R677 知识库 4 端点 TC-AU-U425~U428;R683 稳态校验档 src 变更轮实测);实现侧 S-cfc-466 病症权重分组(ba681d713)+ fix(f03) 按 paid_at 归属业绩重算(36522a427)。
+
+### 1.4 Git 证据核验
+
+| 指标 | 值 |
+|------|------|
+| 远程 tip(开工 fetch 后) | `ba681d713`(11-30 08:28 S-cfc-466 实现红单测全绿) |
+| 本地 HEAD | 落后若干提交,主工作树他人 WIP,只报不动(clean-check 由标准轮承接) |
+| 汇报提交 | 单文件临时索引基于最新 tip 重建(禁 add -A / checkout / stash) |
+
+## 二、S0–S11 执行明细
+
+| 步骤 | 结果 |
+|------|------|
+| S0 中断自愈 | 无残骸(worklog.active 无未收口);断档 monitor.log 421.4min / worklog.last_entry 978.1min(平台触发停摆迹象,git 侧活跃)→ 按错峰档指令走 S3 精简 |
+| S1 互斥门 | PASS(state mtime 10.1min>mutex 5;worklog.active=null;locks 空;slot_now=s31/slot_of_active=s11,released_by_other_slot=false 他档放行;worklog_stale_minutes=0 禁 pid 第二关);主线 cfclub 确认 |
+| S2 失败补跑 | 错峰档跳过(01 分档标准轮 R680 承担;R683 08:25 已产出) |
+| S3 盘点 | **精简**:RED5/YELLOW131/GREEN10/DONE117(共 263 键);部署 pending140/confirmed80;账本 510(disp18·done467·fail24·sup1·pend0);`--inspect`(测试角色只读):卡龄回收 31 条、6 节点配额见 1.2、阻塞 0;resume dry-run 候选 0;git log -20 见 1.3;**--changes/--clean-check 由标准轮承接(间隔档精简盘点)** |
+| S4 恢复 | `--resume` 实际恢复 0(prod-etotem 生产跳过,无候选) |
+| S5 心跳 | disabled 跳过(config heartbeat.enabled=false) |
+| S6 填充 | disabled 跳过(config fill_capacity.enabled=false) |
+| S7a backfill | EXIT=0 批量版回收 ~30 键(**新认 S-cfc-466 → done @ ba681d713960**;其余幂等重认),二次跑「refs 指纹未变 0 增量」= 全仓覆盖确认;done 466→467 |
+| **S7 --auto(本档核心)** | `--auto --role 研发负责人 --limit 2` 后台托管 08:35 起 **400s+ 无产出、日志仅版本预检一行(RECLAIM 悬挂 fault 第 8 轮复现)** → kill pid 63572 → **派发保底兑现**:直连 `dispatch.py --task` 重派 3 张 stale GREEN 卡均 verified(S-cfc-479→local-lan-4090、S-cfc-480→lan-204、S-cfc-482→local-lan-4090) |
+| S8 池空续建 | 0 add-task:pending=0(本档已直连补派 3 张回填 idle);未跑通 SC 216 中仅 SC-A-23/A-24 交易延伸低优先域需先核契约;--changes 标准轮承接;TR-22~24 属测试侧 mark-green 收口、O-26 待主理人裁决、B-325-1 为已登记研发 P1(进程驻留)均非研发建单溯源;blockers 0;CI 无 open 项 |
+| S9 收口 | 单文件临时索引提交本汇报(GIT_INDEX_FILE,父=最新 tip;push 前再 fetch 防漂移;diff 校验仅目标单文件) |
+| S10 汇报 | 本文件 |
+| S11 通用铁律 | 不伪造证据(派发凭据均有 dispatch.py 回执 verified=true);他人 WIP 只报不动;互斥命中轮零副作用原则遵守 |
+
+## 三、阻塞与风险
+
+| 级别 | 项 | 说明 |
+|------|-----|------|
+| P0 | **--auto RECLAIM 悬挂 fault 连续第 8 轮**(R553/R681/R683/本档) | 15 张 dispatched stale 卡(75–189h 无 finish_note)逐键全量证据核验超时 → --auto 永不进入派发(kill 前 400s 无产出)。修法方向:RECLAIM 批量/上限化核验,或直连批量 requeue stale 在途卡回池(requeue 依赖 --auto 主流程,须绕行入口) |
+| P1 | 15 张 stale GREEN 在途卡无 finish_note(75–189h) | 疑似会话产出后未回报/看护丢失,逐档直连兜底重派(本档 3 张) |
+| P1 | 部署 pending 140 单调上升(沿承) | O-24 沿承,待部署链收敛 |
+| P2 | mes-local 超限 7/6、lan-189 满配 4/4、wb-cloud 401(沿承) | 派发自动改投闲节点,运维确认 |
+| P2 | monitor 循环停摆 421min / worklog 断档 978min(沿承) | 平台触发停摆迹象,git 侧持续活跃,建议标准轮/运维确认重启 |
+| P2 | 账本 263 vs 场景台账 243 口径分离(沿承) | 计数分离:能力键 DONE ≠ SC 跑通,转正归测试侧 |
+
+## 四、下一步事项
+
+| 事项 | 依赖 | 预估 |
+|------|------|------|
+| 收敛 --auto RECLAIM 悬挂(批量/上限化核验,或直连批量 requeue 15 张 stale 卡) | 需改脚本 RECLAIM 环节或绕行 requeue 入口 | 下一档优先 |
+| 跟踪本档 3 张重派会话证据 + 续派剩余 15 张 stale GREEN 卡 | local-lan-4090/lan-204/pub-iwintrue 余位逐档轮换 | 逐档 |
+| 部署 pending 140 收敛 / 账本 243vs27 同步 | 测试/部署侧 | 沿承 |
+| lan-189/mes-local 配额、monitor 循环恢复 | 运维 | 待确认 |

+ 103 - 0
docs/tdd/orchestration/report-dev-2026-11-30-0917.md

@@ -0,0 +1,103 @@
+# 研发负责人工作汇报(CF 31 分档错峰档 · 收割)
+
+> 档位说明:本档=CF 错峰档(31 分档,09:03 触发,按触发漂移容忍完整跑轮;`--mutex-check` PASS:state mtime 0.3min、worklog.active=null、locks 空、slot_now=s01/slot_of_active=s31、released_by_other_slot=true、worklog_stale_minutes=0 禁 pid 第二关)。**错峰档职责**:跳过 S2 失败补跑(01 分档标准轮 R680/R684 承担);S3 走**精简盘点**(跳 --changes/--clean-check,由标准轮承接)。S5 心跳 / S6 填充未启用跳过并注明。**派发保底兑现**:--auto RECLAIM 悬挂(第 9 轮)下,直连 `dispatch.py --task` 重派 3 张 stale GREEN 卡 verified。
+
+## 基本信息
+
+| 项目 | 内容 |
+|------|------|
+| 汇报人 | 研发负责人(自动化收割轮 · software-company 专家团编排) |
+| 汇报周期 | 2026-11-30 09:03 开工 ~ 09:1x 收口(错峰档 31 分档,slot_now=s01) |
+| 负责模块/单元范围 | 全量(scope 空=不限);主线 ref=`origin/cfclub` |
+
+## 一、本轮工作数据汇总
+
+### 1.0 场景覆盖矩阵(硬职责增列)
+
+单一计数源:`docs/tdd/orchestration/sc-key-map.md`(对应 `tests/user-scenarios/应用场景总览.md`)。
+
+| 指标 | 值 | 说明 |
+|------|-----|------|
+| 场景总数 | 243 | sc-key-map 台账(主表 243 行) |
+| 累计已跑通 | 27 | 标题口径:O-3 收口 5 + 游客域 10 + 各复验批转正 12 |
+| 本轮新增跑通 | 0 | 无新增三类流转正;本轮无 SC 关联新实现提交 |
+| 失败 | 0 | 无新证伪场景 |
+| 阻塞 | 0 | `--blockers` 登记 0 |
+| 未跟踪 | 216 | =243−27−0−0−0(与 s21/s41/s01 档一致) |
+
+### 1.1 问题接收与处置
+
+| 指标 | 数量 | 填写说明 |
+|------|------|---------|
+| 收到的测试反馈问题数 | 0 | `--blockers` 登记 0 |
+| 已解决问题数 | 5 | backfill 新认 S-cfc-465/466/467/479/482 → done(证据 8a839bd1/ba681d71/0b848c45/f1af7be8/fe32d96b,11-30 08:29~08:56 红单测全绿提交) |
+| 待解决研发问题数 | 9 | dispatched stale 卡(483/484/485 本档重派后仍无证据的 >24h 卡:233/487/491~497,见风险段) |
+
+### 1.2 任务分发与会话管理
+
+| 指标 | 数量 | 填写说明 |
+|------|------|---------|
+| 本轮派发成功 | 3 | 直连 `dispatch.py --task` 重派 verified(--auto fault 下派发保底兑现) |
+| 本轮派发失败 | 0 | 三条直连均 verified=true |
+| 派发超限/未派 | — | --auto fault(RECLAIM 悬挂第 9 轮,150s 有界探测零产出→kill)致自动派发 0 回执;重派前 pending=0 无新卡 |
+| 派发前会话状态 | 13 dispatched / 0 pending / 0 idle-card | 节点:lan-189 剩 2、lan-204 剩 3(承接 1)、local-lan-4090 剩 6(承接 1)、mes-local 超限 0、prod-etotem 剩 4(生产跳过)、pub-iwintrue 剩 5(承接 1);wb-cloud 401 沿承 |
+| 节点异常 | 2 | mes-local 超限 8/6、wb-cloud list_sessions 401(沿承) |
+
+**各会话当前工作状态列表(1.2b 必填)**:
+
+| 任务 | 实例 | 状态 | 说明 |
+|------|------|------|------|
+| S-cfc-483 energy.dimension.view | local-lan-4090 | dispatched(重派) | ses_dd5fe2a32ffeQqsQE7vx3NX4Nr,verified=true |
+| S-cfc-484 diet.recommendation.byReport | pub-iwintrue | dispatched(重派) | ses_dd5fe17f8ffeZXij0dt1T2DbMe,verified=true |
+| S-cfc-485 plan.ai.generate | lan-204 | dispatched(重派) | ses_dd5fe0406ffeJCHOfR37dWoOrI,verified=true |
+| S-cfc-480 butler.ai.collaborate | lan-204 | dispatched | 11-30 08:46 他档新派,在途(近 20min,本档不重派) |
+| 其余 9 张 TDD-GREEN stale 在途卡(233/487/491~497) | 各节点 | dispatched(stale) | 11-22~11-27 派发,>24h 无 finish_note,本轮未重派(预算让位,逐档兜底) |
+
+### 1.3 需求/设计/测试用例变更感知
+
+错峰档精简盘点跳过 `--changes`(由 01 分档标准轮 R680/R684 承接)。本轮 git log -20:测试侧活跃(R682 匿名鉴权守卫用例 TC-AU-U429~U444,d14bdf31e;R683 稳态校验档 src 变更轮实测 93fc89276);实现侧 S-cfc-482 points.ledger.view(fe32d96bf)、S-cfc-467 diet.menu.pairingConstraint(0b848c45)、S-cfc-479 ai.aiyunyi.reportDetail(f1af7be8)、S-cfc-460 plan.edit.adjust(61826066d)、S-cfc-465 food.rule.processingEffect(8a839bd1)、S-cfc-466 food.rule.diseaseWeightGroup(ba681d71)+ fix(f03) 按 paid_at 归属业绩重算(36522a427)。
+
+### 1.4 Git 证据核验
+
+| 指标 | 值 |
+|------|------|
+| 远程 tip(开工 fetch 后) | `512d844a9`(11-30 09:05 auto bump;fe32d96bf S-cfc-482 之上) |
+| 本地 HEAD | 落后若干提交,主工作树他人 WIP,只报不动(clean-check 由标准轮承接) |
+| 汇报提交 | 单文件临时索引基于最新 tip 重建(禁 add -A / checkout / stash) |
+
+## 二、S0–S11 执行明细
+
+| 步骤 | 结果 |
+|------|------|
+| S0 中断自愈 | 清理 1 项残骸(worklog.active pid=63572 `--auto` 08:35:23 收口);断档 monitor.log 457.3min / worklog.last_entry 990.3min(平台触发停摆迹象,git 侧活跃)→ 按错峰档指令走 S3 精简;另 --auto 探测被杀后二次清理 pid=52016(09:15:09) |
+| S1 互斥门 | PASS(state mtime 0.3min<mutex 5 但他档 s31 刚收口 → released_by_other_slot=true;worklog.active=null;locks 空;worklog_stale_minutes=0 禁 pid 第二关);主线 cfclub 确认 |
+| S2 失败补跑 | 错峰档跳过(01 分档标准轮 R680/R684 承担) |
+| S3 盘点 | **精简**:RED5/YELLOW131/GREEN10/DONE117(共 263 键);部署 pending140/confirmed80;账本 510(初始 disp18·done467·fail24·sup1·pend0 → backfill 后 done472·disp13);`--inspect`(测试角色只读):卡龄回收 31 条、6 节点配额见 1.2、阻塞 0;resume dry-run 候选 0;git log -20 见 1.3;**--changes/--clean-check 由标准轮承接(间隔档精简盘点)** |
+| S4 恢复 | `--resume` 实际恢复 0(prod-etotem 生产跳过,无候选) |
+| S5 心跳 | disabled 跳过(config heartbeat.enabled=false) |
+| S6 填充 | disabled 跳过(config fill_capacity.enabled=false) |
+| S7a backfill | EXIT=0 批量版(一次 git log 全仓内存映射,120s 预算内):**新认 5 键 → done**(S-cfc-465/466/467/479/482,证据见 1.1);其余幂等重认;done 467→472、dispatched 18→13 |
+| **S7 --auto(本档核心)** | `--auto --role 开发 --limit 2` 150s 有界探测:仅版本预检一行、零产出(**RECLAIM 悬挂 fault 第 9 轮复现**)→ kill pid 52016 → **派发保底兑现**:直连 `dispatch.py --task` 重派 3 张 stale GREEN 卡均 verified(S-cfc-483→local-lan-4090、S-cfc-484→pub-iwintrue、S-cfc-485→lan-204) |
+| S8 池空续建 | 0 add-task:pending=0(本档已直连补派 3 张回填 idle);未跑通 SC 216 中仅 SC-A-23/A-24 交易延伸低优先域需先核契约;--changes 标准轮承接;TR-22~24 属测试侧 mark-green 收口、O-26 待主理人裁决、B-325-1 为已登记研发 P1 均非研发建单溯源;blockers 0;CI 无 open 项 |
+| S9 收口 | 单文件临时索引提交本汇报(GIT_INDEX_FILE,父=最新 tip;push 前再 fetch 防漂移;diff 校验仅目标单文件) |
+| S10 汇报 | 本文件 |
+| S11 通用铁律 | 不伪造证据(派发凭据均有 dispatch.py 回执 verified=true);他人 WIP 只报不动;互斥命中轮零副作用原则遵守 |
+
+## 三、阻塞与风险
+
+| 级别 | 项 | 说明 |
+|------|-----|------|
+| P0 | **--auto RECLAIM 悬挂 fault 连续第 9 轮**(R553/R681/R683/本档) | 13 张 dispatched stale 卡(75–189h 无 finish_note)逐键全量证据核验超时 → --auto 永不进入派发(150s 有界探测零产出)。修法方向:RECLAIM 批量/上限化核验,或直连批量 requeue stale 在途卡回池(requeue 依赖 --auto 主流程,须绕行入口) |
+| P1 | 9 张 stale GREEN 在途卡无 finish_note(75–189h:233/487/491~497) | 疑似会话产出后未回报/看护丢失,逐档直连兜底重派(本档 3 张) |
+| P1 | 部署 pending 140 单调上升(沿承) | O-24 沿承,待部署链收敛 |
+| P2 | mes-local 超限 8/6、wb-cloud 401(沿承) | 派发自动改投闲节点,运维确认 |
+| P2 | monitor 循环停摆 470min / worklog 断档 963min(沿承) | 平台触发停摆迹象,git 侧持续活跃,建议标准轮/运维确认重启 |
+| P2 | 账本 263 vs 场景台账 243 口径分离(沿承) | 计数分离:能力键 DONE ≠ SC 跑通,转正归测试侧 |
+
+## 四、下一步事项
+
+| 事项 | 依赖 | 预估 |
+|------|------|------|
+| 收敛 --auto RECLAIM 悬挂(批量/上限化核验,或直连批量 requeue stale 卡回池) | 需改脚本 RECLAIM 环节或绕行 requeue 入口 | 下一档优先 |
+| 跟踪本档 3 张重派会话证据 + 续派剩余 9 张 stale GREEN 卡 | local-lan-4090/pub-iwintrue/lan-204 余位逐档轮换 | 逐档 |
+| 部署 pending 140 收敛 / 账本 243vs27 同步 | 测试/部署侧 | 沿承 |

+ 132 - 0
docs/tdd/orchestration/report-dev-2026-11-30-0952.md

@@ -0,0 +1,132 @@
+# 研发负责人工作汇报 · CF 11 分档错峰收割(断档追平轮)
+
+## 基本信息
+
+| 项目 | 内容 |
+|------|------|
+| 汇报人 | 研发负责人(无人值守错峰档,s31 / 09:37 开工 09:53 收口) |
+| 汇报周期 | 2026-11-30 09:37 ~ 09:53(本轮) |
+| 负责模块/单元范围 | 全量(无 scope 隔离) |
+| 主线 ref / 当前分支 | `origin/cfclub` = `46d34f94a` / 工作区分支 `cfclub` ✓ |
+| 档位 | CF 6 档错峰档中 11 分档(本档 S2 跳过,由 01 标准轮承接);**S0 检出断档 → S3 走全量** |
+
+---
+
+## 一、本轮工作数据汇总
+
+### 1.0 场景覆盖矩阵(唯一计数源 `docs/tdd/orchestration/sc-key-map.md`)
+
+| 指标 | 值 | 说明 |
+|------|-----|------|
+| 场景总数 | **243** | 权威口径(`sc-key-map.md` 计数段;2026-11-14 补登 A-23/A-24 后 241→243) |
+| 累计已跑通 | **27** | 权威登记于 `sc-key-map.md`「## 已跑通(…=27 SC)」段,2026-11-27 最后更新 |
+| 本轮新增跑通 | **0** | 本轮无测试侧转正(SC 转正归测试侧,研发不代改台账) |
+| 失败 | 0 | — |
+| 阻塞 | 0 | — |
+| 未跟踪 | 216 | = 243 − 27 − 0 − 0 |
+
+> 本轮 git log 新推 S-cfc-460/465/466/467/479/480/482/483/484 等实现使绿(YELLOW),能力键 DONE ≠ SC 跑通;三类流执行证据待测试侧补,不计入「已跑通」。DEV_GOAL 头注「241」为旧口径,以 sc-key-map 计数段 243 为准。
+
+### 1.1 问题接收与处置
+
+| 指标 | 数量 | 说明 |
+|------|------|------|
+| 收到测试反馈问题数 | 0 个 | 本轮无新增 `--mark-blocked` 研发类条目(`--inspect` 无已登记阻塞) |
+| 已解决问题数 | 0 个 | — |
+| 待解决研发问题数 | 0 个 | O-26(RED 置红证据门槛)待主理人裁决,非研发实现项 |
+
+### 1.2 任务分发与会话管理
+
+| 指标 | 数量 | 说明 |
+|------|------|------|
+| 分派任务数 | **0 个** | 池空零派发,合法情形②(pending=0 实证,见 §1.3/S8 溯源) |
+| 恢复智能体会话数 | 0 个 | S4 `--resume --dry-run` 候选 0,无中断需恢复 |
+| 当前在用会话数 | 4 个 | 节点 busy:lan-204=2 / local-lan-4090=1 / mes-local-45278=4 / prod-etotem=1 |
+| 会话平均利用率 | — | 串行派发架构,见 §1.2b |
+
+### 1.2b 各会话当前工作状态列表(`--inspect` 实测)
+
+| 节点 | 配额占用/上限 | 剩余 | 状态 | 备注 |
+|------|--------------|------|------|------|
+| lan-189 | 0/4 | 4 | idle | 空闲待派 |
+| lan-204 | 2/4 | 2 | running | 在途 |
+| local-lan-4090 | 1/6 | 5 | running | 在途 |
+| mes-local-45278 | 4/6 | 2 | running | 在途 |
+| prod-etotem | 1/4 | 3 | running | 生产实例 |
+| pub-iwintrue | 0/6 | 6 | idle | 空闲待派 |
+
+> 节点配额合计剩余 **22**(无槽位瓶颈,属「无料可派」非「无位可派」)。`[P7-B] wb-cloud list_sessions 401` 仍间歇(known,不影响本轮)。
+
+### 1.3 变更感知与新任务建立
+
+| 指标 | 数量 | 说明 |
+|------|------|------|
+| 感知需求/设计变更数 | 200 提交 / 322 文件(近 7 天 11-27~11-29) | 设计文档 111 / 测试用例 1 / 其他 210 |
+| 新增入池任务数 | **0 个** | --changes 新增能力键 **0→0**;无实际工作溯源可建单 |
+| 既有键状态流转数 | 3 次 | --auto:admin.auth.login / health.report.upload / task.history.view 均 GREEN→REQUEUE-SKIP-O22 保持 done(键级已实现定论) |
+
+### 1.4 本轮 git 提交与推送证据
+
+| 提交 sha | 关联任务/能力键 | 阶段 | 触及文件 | 已推送远端 | 备注 |
+|----------|-----------------|------|----------|------------|------|
+| `46d34f94a` | S-cfc-480 butler.ai.collaborate | YELLOW | 实现 | 是(origin/cfclub=此 tip) | backfill 认领 |
+| `600c1a2d7` | S-cfc-483 energy.dimension.view | YELLOW | 实现 | 是 | backfill 认领 |
+| `a2787c49a` | S-cfc-484 diet.recommendation.byReport | YELLOW | 实现 | 是 | backfill 认领 |
+| `0b848c452` | S-cfc-467 diet.menu.pairingConstraint | YELLOW | 实现 | 是 | backfill 认领 |
+| `8a839bd12` / `ba681d713` | S-cfc-465 / 466 food.rule.* | YELLOW | 实现 | 是 | backfill 认领 |
+| `f1af7be82` / `fe32d96bf` | S-cfc-479 / 482 ai.aiyunyi.reportDetail / points.ledger.view | YELLOW | 实现 | 是 | backfill 认领 |
+
+> 以上均由 S7a backfill 批量版认领为 done(提交已推 origin/cfclub,`merge-base --is-ancestor` ✓)。
+
+### 1.5 状态机阶段分布与部署状态
+
+| 阶段 | 键数 |
+|------|------|
+| UNTRACKED | 0(目标池 ⏳ 键 0) |
+| RED | 5 |
+| YELLOW | 131 |
+| GREEN | 10 |
+| DONE | 117 |
+
+| 部署项 | 值 | 说明 |
+|--------|-----|------|
+| 部署在途 | pending 140 / confirmed 80 | testing 环境 |
+| GREEN 部署链验证 | 保持 | 本轮无新部署推动 |
+
+### 1.6 数据源健康度
+
+| 数据源 | 读取键数 | 是否正常 | 备注 |
+|--------|----------|----------|------|
+| 需求侧(⏳ wish) | 0 | 正常(空=无缺口) | — |
+| 契约常量(contract) | 0 | 正常 | 标注用,不入池门槛 |
+| 测试用例引用 | 0 | 正常 | 用例驱动口径 |
+| 执行结果回填 | 0 | 正常 | — |
+
+---
+
+## 二、下一步需要研发处理的事项
+
+| 序号 | 事项 | 依赖/前置 | 优先级 | 状态 |
+|------|------|-----------|--------|------|
+| 1 | 23+ 张 dispatched 僵尸卡核验(client 字段空、session 派发 11-22~28、节点 busy=0 无新证据) | 卡龄回收 MAX 5/轮连续被 pre-pass 预算耗尽挡住 | P1 | 待下轮承接 |
+| 2 | 216 未跑通 SC 键推进(全在状态机 RED5/YELLOW131/GREEN10,走既有键) | 依赖空闲会话承接实现/测试 | P1 | 进行中 |
+| 3 | O-26 RED 置红证据准入门槛裁决 | 主理人/协议决定 | P2 | 待主理人 |
+
+## 三、阻塞与风险
+
+| 阻塞项 | 影响范围 | 类型 | 处置进展 | 需要协调 |
+|--------|----------|------|----------|----------|
+| `--auto` 600s 预算耗尽于 pre-pass 逐键 git_evidence 判定段(~20s/张),apply 收尾即池空 | 派发动作未启动(本轮池空故无影响) | 研发/工具层 | 连续多轮同症;后台托管可跑完不 hang | 工具层优化:僵尸卡/证据判定批量化 |
+| 主工作树 413 处他人 WIP(含 node_modules 删除、AGENTS.md 改动等) | 全局 clean-check 常年非 0(他人域,SC 关联提交级核验不受阻) | 测试/协作 | 只报不动(纪律) | 各会话自行收口 |
+
+## 四、下轮工作规划
+
+| 计划项 | 前置依赖 | 涉及节点 | 备注 |
+|--------|----------|----------|------|
+| 僵尸 dispatched 卡逐卡取证 + 卡龄回收 | 派发预算 | 全节点 | 避免 pre-pass 预算耗尽 |
+| 216 未跑通 SC 键续派 | pending 池池空时 S8 建单/走既有键 | 空闲节点 | --changes 0→0,暂无新键 |
+| SC 转正复核 | 测试侧三类流证据 | 测试侧 | 研发不代改台账 |
+
+---
+
+**本轮小结(TL;DR)**:S0 检出 worklog 断档 976.9min → S3 走全量盘点;S1 互斥 PASS;S7a backfill 回收 ~40 键 done(含本轮新推 460/465/466/467/479/480/482/483/484);S7 `--auto` 后台托管 10m53s 完成(600s 预算截断 complete=false),状态推进 3 键保持 done,**池空零派发=合法情形②**;SC 243 总量 / 已跑通 27(零新增)。S5 心跳 / S6 填充 config `enabled=false` 跳过。主工作树 413 处他人 WIP 只报不动。

+ 141 - 0
docs/tdd/orchestration/report-dev-2026-11-30-1041.md

@@ -0,0 +1,141 @@
+# 研发负责人工作汇报 · CF 01 分档标准轮收割(断档追平轮)
+
+## 基本信息
+
+| 项目 | 内容 |
+|------|------|
+| 汇报人 | 研发负责人(无人值守标准轮,01 分档 / 10:22 开工) |
+| 汇报周期 | 2026-11-30 10:22 ~ 10:41(本轮) |
+| 负责模块/单元范围 | 全量(无 scope 隔离) |
+| 主线 ref / 当前分支 | `origin/cfclub` = `54320fdea` / 工作区分支 `cfclub` ✓ |
+| 档位 | CF 6 档中 01 分档(标准轮);**承担 S2 失败补跑** + 完整盘点;**S0 检出断档 → S3 走全量** |
+
+---
+
+## 一、本轮工作数据汇总
+
+### 1.0 场景覆盖矩阵(唯一计数源 `docs/tdd/orchestration/sc-key-map.md`)
+
+| 指标 | 值 | 说明 |
+|------|-----|------|
+| 场景总数 | **243** | 权威口径(origin 正本严格表格行去重:A27/B10/C26/G12/H7/P96/S11/T32/X22) |
+| 累计已跑通 | **27** | 权威登记于 `sc-key-map.md`「已跑通」段,2026-11-27 最后更新 |
+| 本轮新增跑通 | **0** | 本轮无测试侧转正(SC 转正归测试侧,研发不代改台账) |
+| 失败 | 0 | — |
+| 阻塞 | 0 | — |
+| 未跟踪 | 216 | = 243 − 27 − 0 − 0 |
+
+> 本轮 git log 新推 S-cfc-460~503 等实现使绿(YELLOW),能力键 DONE ≠ SC 跑通;三类流执行证据待测试侧补,不计入「已跑通」。
+
+### 1.1 问题接收与处置
+
+| 指标 | 数量 | 说明 |
+|------|------|------|
+| 收到测试反馈问题数 | 0 个 | 本轮无新增 `--mark-blocked` 研发类条目(`--inspect` 无已登记阻塞) |
+| 已解决问题数 | 0 个 | — |
+| 待解决研发问题数 | 0 个 | O-26(RED 置红证据门槛)待主理人裁决,非研发实现项 |
+
+### 1.2 任务分发与会话管理
+
+| 指标 | 数量 | 说明 |
+|------|------|------|
+| 分派任务数 | **3 个** | 直连 `dispatch.py` 重派 3 张 stale GREEN 卡 verified(见附录 B),派发保底达成 |
+| 恢复智能体会话数 | 0 个 | S4 `--resume --dry-run` 候选 2(mes-local「收敛 portal invokeStub」+ pub「probe」)经 tasks.json 核验**无关联任务 = 他人/环境会话**,只报不动,恢复 0 |
+| 当前在用会话数 | 9 个 | 节点 busy:mes-local=8 / prod-etotem=1 / 其余 0 |
+| 会话平均利用率 | — | 串行派发架构,见 §1.2b |
+
+### 1.2b 各会话当前工作状态列表(`--inspect` 实测)
+
+| 节点 | 配额占用/上限 | 剩余 | 状态 | 备注 |
+|------|--------------|------|------|------|
+| lan-189 | 0/4 | 4 | idle | 空闲待派(S-cfc-233 本轮重派至此) |
+| lan-204 | 0/4 | 4 | idle | 空闲待派 |
+| local-lan-4090 | 0/6 | 6 | idle | 空闲待派(S-cfc-491 本轮重派至此) |
+| mes-local-45278 | 8/6 | 0 | running | **超限 8/6**,无余位 |
+| prod-etotem | 1/4 | 3 | running | 生产实例 |
+| pub-iwintrue | 0/6 | 6 | idle | 空闲待派(S-cfc-487 本轮重派至此) |
+
+> 节点配额合计剩余 **23**(无槽位瓶颈,属「需重派旧卡」非「无位可派」)。`[P7-B] wb-cloud list_sessions 401` 沿承间歇(known,不影响本轮)。S-cfc-233/487/491 本轮重派后对应节点转为 running。
+
+### 1.3 变更感知与新任务建立
+
+| 指标 | 数量 | 说明 |
+|------|------|------|
+| 感知需求/设计变更数 | 0 个 | `--changes --days 7`:111 设计文档 + 1 测试用例文档 + 210 其他,**0 新增能力键**(0→0,均既有键状态/内容变化) |
+| 新增入池任务数 | **0 个** | S8 四类溯源无研发建单型(见 §1.6/§二) |
+| 既有键状态流转数 | 0 次 | 编排轮恒 0,转正由测试侧闭环 |
+
+### 1.4 本轮 git 提交与推送证据(真理证据)
+
+| 提交 sha | 关联任务/能力键 | 阶段 | 触及文件类型 | 目标分支 | 已推送远端 | 备注 |
+|----------|-----------------|------|--------------|----------|------------|------|
+| 本轮无推进证据提交 | — | — | — | — | — | 本编排轮纯调度(盘点/backfill/重派/汇报),S7a backfill 认领 S-cfc-485@87d0abdf8(他轮已推远端) |
+
+> 本编排轮为纯调度角色:不写实现/测试/设计代码(负责人职责边界),故无 RED/YELLOW/GREEN 推进证据提交;推进证据全部来自测试/开发会话侧已推远端提交,backfill 仅作认领。
+
+### 1.5 状态机阶段分布与部署状态
+
+| 阶段 | 键数 | 备注 |
+|------|------|------|
+| UNTRACKED | 0 | 目标池 ⏳ 0(需求侧 ⏳ 0 / 契约 0 / 用例引用∩⏳ 0 / 回填 0) |
+| RED | **5** | admin.family.workbenchPolish, contact.card.manage, food.rule.pairingMatrix, privacy.setting.config, tongue.emotion.capture |
+| YELLOW | **131** | 待测试校验 |
+| GREEN | **10** | 待部署验证 |
+| DONE | **117** | 闭环归档 |
+
+| 部署项 | 值 | 说明 |
+|--------|-----|------|
+| 本轮部署次数 | 0 次 | 本编排轮未触发部署动作 |
+| 最新 `last_deployed` | — | — |
+| GREEN 部署链验证 | 在途 | 部署在途 pending **140** / confirmed 80 |
+
+### 1.6 数据源健康度
+
+| 数据源 | 读取键数 | 是否正常 | 备注 |
+|--------|----------|----------|------|
+| 需求侧(⏳ wish) | 0 | 正常 | 目标池 ⏳ 0(契约已全量入池,无未实现占位) |
+| 契约常量(contract) | 0 | 正常 | 契约常量作「已契约化」标注,非入池门槛 |
+| 测试用例引用(test_case_map) | 0 | 正常 | 用例引用∩⏳ 0(全部已入池键) |
+| 执行结果回填(case_results) | 0 | 正常 | 无未实现键执行结果 |
+
+---
+
+## 二、下一步需要研发处理的事项
+
+> 无研发待办(池空 + 无建单型溯源 + 9 张在途卡逐档跟进)。下轮错峰档承接:S-cfc-487/491/233 重派在途跟进;余 6 张 stale GREEN(492~497)视证据/卡龄回收后续档续派;RED 5 张测试侧契约职责。
+
+| 序号 | 事项描述 | 依赖/前置条件 | 预估完成时间 | 优先级 | 状态 |
+|------|----------|---------------|--------------|--------|------|
+| 1 | 跟踪 S-cfc-233/487/491 重派在途实现使绿 | 会话完成 + 推远端 | 下轮 | P0 | 进行中 |
+| 2 | 余 6 张 stale GREEN(492~497)证据/卡龄跟踪 | 无远端证据 → 卡龄回收续派 | 后续档 | P1 | 待启动 |
+| 3 | RED 5 张(workbenchPolish 等)契约单测转正 | 测试侧写 RED + 推远端 | 测试侧 | P1 | 待测试处理 |
+
+---
+
+## 三、阻塞与风险
+
+| 序号 | 阻塞/风险 | 影响 | 处置建议 |
+|------|-----------|------|----------|
+| 1 | `[P7-B] wb-cloud list_sessions 401` | 远程节点枚举受限 | 沿承,known,不影响本轮(节点枚举已降级为 local 可达集) |
+| 2 | `--auto` pre-pass 预算耗尽族(同族第 20+ 次截断) | 自动推进/卡龄回收受阻 | 本轮改走直连 dispatch.py 重派(已兑现在途卡 verified);建议主理人核查节点探测阈值 |
+| 3 | mes-local 8/6 超限 | 该节点无余位派发 | 待其会话收口释放;下轮派发避开 mes-local |
+| 4 | 平台停摆断档(monitor 532.4min / worklog 988.9min) | 触发历史断档 | S0 已断档追平;S3 走全量;留痕待平台核查 |
+| 5 | 部署欠账 O-24(pending 140 / confirmed 80) | 部署链未闭环 | 沿承,逐档跟进 |
+
+---
+
+## 附录 B:本轮派发清单(verified)
+
+| 任务号 | 能力键 | 阶段 | 目标实例 | 会话 | 黑窗 | 结果 |
+|--------|--------|------|----------|------|------|------|
+| S-cfc-233 | teacher.login.switch | GREEN | lan-204 | ses_dd5ad6bc4ffesbN4es9n6F2Bpb | False | verified |
+| S-cfc-487 | notification.setting.config | GREEN | pub-iwintrue | ses_dd5ac9168ffeoAQ86q1v5Ze6XY | False | verified |
+| S-cfc-491 | feedback.consult.submit | GREEN | local-lan-4090 | ses_dd5ac85d1ffeFSgbFFpy3wNHE4 | False | verified |
+
+> 三卡均为 11-22~11-27 派发、无远端证据的 stale GREEN 实现卡(RECLAIM 悬挂族),直连重派以打破悬挂并满足派发保底。
+
+---
+
+## 附录 C:本轮状态流转/建单明细
+
+- 无(编排轮恒 0 新增;S7a backfill 认领 S-cfc-485@87d0abdf8,done 475→476,非阶段流转)。

+ 107 - 0
docs/tdd/orchestration/report-test-2026-11-30-1016.md

@@ -0,0 +1,107 @@
+# 测试负责人标准轮汇报 · R685(2026-11-30 10:00~10:16)
+
+- 对象:`d:/cfc`(主线 `cfclub`,`data_ref=origin/cfclub`)|角色:测试负责人(纯调度 + 验收)
+- 档位:0 分标准轮(A 类)|运行模式:MULTI_AGENT|执行档:review(离线白名单 + 已授权节点派发,未授权联网压测/漏洞扫描)
+- 结论:**不通过(有条件·承袭 R684/R681)** —— 本轮三类派发链已入账/投递,但两个执行会话均未在验收窗口内形成交付;零新增实测数字,不写绿。
+
+## 一、历史审查记录(只作对照,不作本次结论依据)
+
+- R684(08:45 标准轮):`mvn -o -B clean test-compile` EXIT=0,main **2507** / test **694** 新基线;`/api/system/health` 200,startTime 08:36:29;重启族 P0 第 4 日未闭环。
+- R681(07:25 B 类 10 分档):需求闸门 CLOSED、零用例产物;retest-gate 粗判被「上次 B 类基线..HEAD 源码 diff=0」二级收敛,65 项承袭·未实测。
+- 本轮改善:三类实事全部走 `enqueue.py`→`dispatch.py` 账本链,负责人零本地发现/用例/执行;未改善:长期 blocker 与两 RED 键仍无恢复信号。
+
+## 二、项目画像与测试方案
+
+- 模块:`cfc-backend`(9082)、`cfc-frontend`(uni-app)、`cfc-web`(8082)、`cfc-langgraph`(9000)、`dan/danshop`(8888)。
+- 关键路径:本轮 fast-forward 12 提交,新增 AI 成长方案生成/重生成、管家协作闭环、能量配置、饮食按报告推荐及 `health/ai-report-detail.vue`。
+- 质量目标:三流断言(正常/异常/权限)+ 已推远端 git 证据 + 场景三流严格跑通;口径 `sc-key-map.md`。
+- 方案范围:全 20 类矩阵;本轮实际动作为 S0→S11 骨架 + 三类实事派发链;未启动的维度明标承袭/未实测,不伪造。
+
+## 三、S0–S11 骨架执行
+
+| 步骤 | 结果 |
+|---|---|
+| S0 前置检查 | 三查 <60s:分支 `cfclub` ✓;开局 `0 12` → `git pull --rebase origin cfclub` fast-forward 至 `018c7338c` → 终 `0 0`;tracked 脏 0。742 项 `.r*` 未追踪永不 add |
+| S1 互斥门 | `PASS`(state 龄 1085.6min、worklog.active null、locks {}、slot UNUSED),轮首固化 |
+| S2 失败补跑 | 不触发(最新 `report-dev-2026-11-30-0952.md` 龄约 24min < 2h) |
+| S3 盘点 | `--status`:RED 2 / GREEN 5;账本 2 dispatched;`--inspect` 7 节点;`--resume --dry-run` 候选 0;`--changes` 由标准轮承接;`--clean-check` 742 未追踪假阳性;`--sc-evidence` 243/27/strict27/anomalies0/worktree clean |
+| S3.5 复测门 | `--retest-gate` VERDICT=RETEST_REQUIRED(65 项全 retest、6h/40 提交含 src、health_url 未配);二级收敛:新 src 全部指向 plan/butler/energy/diet,**无针对 G-304-1/B-260-1/B-325-1 等长期 blocker 的定向修复**,恢复信号不成立 → 65 项标「承袭·未实测」,不跑全量复测 |
+| S4 恢复 | 派前 dry-run 候选 0;派后发现发现会话 interrupted、实测会话 failed,均未在本轮窗口内恢复成功 |
+| S5/S6 | `harvest.heartbeat.enabled=false`、`fill_capacity.enabled=false` → 跳过(配置态,非故障) |
+| S7 分派 | 三类实事强制链见下节;S7a backfill:窗口内无本轮 tid 证据提交,`dispatch.py --backfill` 空实现 → 0 回收 |
+| S8 池空续建 | 用例任务 `tc-20261130-1008-a` pending 于 lan-248(3/3 满额),按「满额不硬塞」等下轮;无虚构任务 |
+| S9 收口 | 只认 git 真理;本轮仅提交本文件(`.gitignore:160` 命中报告路径,用精确 pathspec + force add),未 add `.r*`、未动他人 WIP |
+| S10 汇报 | 本文件(≤120 行,稳态承袭、变化项五要素) |
+| S11 铁律 | 全程无人值守未提问;零凭据、未重启远端;未实测项不记通过 |
+
+## 四、三类实事派发链与验收(本轮唯一变化项)
+
+| kind | tid | 节点/session | 回执 | 消息下探验收 |
+|---|---|---|---|---|
+| discovery | `disc-20261130-1008-a` | opencode-iwintrue / `ses_dd5c9522cffe1yb9VSu12FeOHS` | verified=true | 会话存在、26 条消息、命中发现指令 1 条;终态 `outcome=interrupted`、busy=false → **未交付** |
+| testcase | `tc-20261130-1008-a` | lan-248(未派) | enqueue ok / status=pending | 派前 `--inspect` 配额 3/3 满额,按纪律不投递,等下轮 |
+| testexec | `tex-20261130-1008-a` | web-4091 / `ses_dd5c93eb2ffexMrqaBMEhbBoac` | verified=true | 会话存在、8 条消息、命中执行指令 1 条;终态 `outcome=failed`、busy=false、无 assistant 文本 → **未实测** |
+
+> 验收口径:不把「0 会话 / 仅回执」当成功;本轮两笔均有真实会话与消息命中,但均无可用产物,故不计通过。派前配额快照:251 余 1、248 余 0、4091 余 3、189 余 3;同一物理节点未重复派发(251 与 189 各只用一次)。
+
+## 五、20 类测试覆盖矩阵(三态 + 证据)
+
+| 类型 | 状态 | 证据/说明 |
+|---|---|---|
+| 单元测试 | 已发现 | `cfc-backend/src/test/java`、`**/__tests__`;R684 test 694 类产物 |
+| 测试覆盖率 | 待核实 | 本轮未跑覆盖率;承袭 R684 分子分母口径 |
+| 变异测试 | 未发现 | 仓库未见变异测试配置/报告 |
+| 集成测试 | 待核实 | API e2e 存在,完整集成链路未跑 |
+| 契约测试 | 已发现 | `tests/e2e/api/*.contract.spec.js` + API_REFERENCE 键行 |
+| 接口 API 测试 | 已发现 | `tests/e2e/api/`;新增端点本轮派用例编写(未落地) |
+| 系统/端到端 | 已发现 | `tests/e2e/` 多 spec;本轮未新增实跑 |
+| 验收 UAT | 待核实 | 无本轮 UAT 记录 |
+| BDD 规格 | 未发现 | 未见 feature/步骤定义 |
+| 冒烟测试 | 已发现 | `web.frontendMobile.runSmoke` RED 契约与 4091 套件 |
+| 回归测试 | 待核实 | 无全量回归在本轮窗口执行 |
+| 探索性测试 | 未发现 | 无本轮探索记录 |
+| 性能测试 | 未发现 | 未授权联网压测,未实测 |
+| 可靠性测试 | 待核实 | 重启族 P0(startTime 换代)未闭环 |
+| 安全测试 | 已发现 | auth-guard 系列 spec;未跑 SAST/DAST |
+| 兼容性测试 | 待核实 | 无设备/浏览器矩阵实跑 |
+| 可用性测试 | 未发现 | 无本轮记录 |
+| 无障碍测试 | 未发现 | 无本轮记录 |
+| QA 流程 | 已发现 | 骨架 S0–S11 + 三通道台账 + 状态机 |
+| 质量指标/代码审查 | 待核实 | sc-evidence 243/27;本轮无全项目代码审查 |
+
+## 六、覆盖缺口清单
+
+| 缺口 | 现状 | 风险 | 建议测试设计 | 优先级 | 闭环方式 |
+|---|---|---|---|---|---|
+| 新增端点用例缺口 | plan.edit/view/versions、energy.config、butler.collaborate 已实现但 e2e 零守卫 | 权限/异常流无回归 | 忽略型探针取真实契约后写三流 spec | P1 | 248 空位后派 testcase,sha 在远端祖先 |
+| 执行通道失效 | 251 发现会话 interrupted、4091 实测会话 failed | 派发≠执行,证据断档 | 下轮先恢复/重建会话再投递,核验 busy + 消息 | P0 | 会话 busy 且报告 exec 文件已推 |
+| 长期 blocker 无恢复信号 | G-304-1/B-260-1/B-325-1 等承袭多轮 | 缺陷可能仍在线上 | 仅环境探针 + 定向 src 检查;无恢复信号不跑全量 | P1 | health 200 且出现针对性 src 提交才复测 |
+| 两 RED 键未收口 | runE2E/runSmoke RED 停留第 3 日 | YELLOW/GREEN 链路阻塞 | 研发实现后测试校验;不代研发实现 | P1 | due 12-01 20:25 前按 git 证据推进 |
+
+## 七、域结论表
+
+| 维度 | 负责专家 | 结论 | 关键证据 |
+|---|---|---|---|
+| 单元·组件 | 苏雅 | 承袭·未实测 | R684 main2507/test694;本轮无新执行 |
+| 集成·接口 | 柯砚 | 未实测 | 新端点用例 pending,零新增 e2e |
+| 系统·验收 | 白樾 | 不通过(有条件) | strict 27/243;本轮零新增跑通 |
+| 测试保障 | 闻朔 | 承袭 | 冒烟/回归承袭 R684,未见新记录 |
+| 性能·可靠性 | 骆骋 | 未实测 | 未授权压测;重启族 P0 承袭 |
+| 安全 | 关屿 | 部分证据 | auth-guard spec 存在;未跑 SAST/DAST |
+| 兼容·体验 | 阮清 | 未实测 | 无矩阵/无障碍实跑 |
+| 流程·度量·代码 | 何序 | 有条件 | 账本与门禁齐备;本轮无全项目代码审查 |
+
+## 八、五要素问题清单
+
+**R685-1(P0 · 分派会话未形成交付)**
+① 现象:两笔投递 verified 且消息命中,但 251 会话 interrupted、4091 会话 failed,交付物 0。② bug 点:`disc-20261130-1008-a` / `tex-20261130-1008-a` 对应 session 的 `outcome`。③ 方案:下轮先按 S4 恢复/重建目标会话,再投递;验收增加 `busy=true + assistant 交付文本 + 已推 sha` 三门槛。④ 目的:杜绝「回执即完成」误判。⑤ 闭环:会话产出 discovery-*.md / report-exec-*.md 且 sha 在 `origin/cfclub` 祖先。
+
+**R685-2(P1 · 248 满额导致用例编写断档)**
+① 现象:`tc-20261130-1008-a` pending,未投递。② bug 点:lan-248 派前配额 3/3。③ 方案:下轮 `--inspect` 复核后改投 251 空位或 248 释放位,仍满额则如实顺延。④ 目的:保证三流用例持续补齐。⑤ 闭环:任务 status=dispatched 且新增 spec 已推远端。
+
+**R685-3(P1 · 复测门粗判与恢复信号错配)**
+① 现象:`--retest-gate` 65 项全 retest(窗口 40 提交含 src)。② bug 点:窗口 src 全为 plan/butler/energy/diet 新特性,与长期 blocker 无定向关系。③ 方案:保持「health 200 + 定向 src 提交」双信号判据,未命中一律承袭·未实测。④ 目的:防止宽窗口触发无意义全量、也防止把承袭写成通过。⑤ 闭环:出现定向 src 提交后跑全量并逐条销号。
+
+## 九、门禁结论
+
+**不通过(有条件·承袭 R684/R681)**。放行条件:①两笔在途任务产出已推远端;②用例任务获得空位并落地三流 spec;③长期 blocker 出现恢复信号后完成定向复测。本轮未修改生产源码/测试文件,未提交他人 WIP;本文件提交 sha 以 `git log -1 --format=%H -- docs/tdd/orchestration/report-test-2026-11-30-1016.md` 为准。

+ 58 - 0
docs/tdd/orchestration/report-test-2026-11-30-1051.md

@@ -0,0 +1,58 @@
+# 测试负责人工作汇报 · R686(2026-11-30 10:26~10:52 · 30 分 langgraph+E2E 错峰档 · A 类 · 无人值守)
+
+## 0. 本轮定位
+- 项目:d:/cfc · 主线 cfclub · data_ref=origin/cfclub · 职责分类 A(直接测试 + 测试任务分派)
+- 档:错峰档 · S2 失败补跑跳过(由 0 分标准轮 R685 承接)· S3 精简盘点(跳过 --changes / --clean-check,标准轮承接)
+- 全程耗时 ≈26min(含首尾网络抖动,主体动作在 20min 硬顶内完成)· 无人值守
+- 测试基线零漂移 vs R675/R680(lg 计数逐位一致 · E2E 契约/阻塞状态同型 · 零新增产品代码缺陷)→ **不 push**;唯一动作 = 补投 R685 遗留 pending 用例任务(如实记录)
+
+## 1. 门禁与前置(S0/S1/S3.5)
+- S0 三查全绿:分支 `cfclub`(主线)· 开局 `HEAD...origin/cfclub` = `0 0`(HEAD `b16f781a4`)· tracked 脏 = **0** · `.r*` 未追踪产物恒不 add
+- S1 互斥门 PASS:state 龄 1112.7min · worklog null · slot UNUSED · locks {}
+- S3.5 `--retest-gate`:65 项全 retest(P-600-1 宽口径失真,已知)· 窗口 43 提交含 src 但全部为 plan/butler/energy/diet 新特性 → 按**专题窄判**(lg 看 cfc-langgraph src、E2E 看 runE2E/runSmoke 生产 src)裁决
+
+## 2. S3 精简盘点
+- 状态机:RED 2(`web.adminPanel.runE2E` / `web.frontendMobile.runSmoke`)· GREEN 5 · 数据源 ⏳ 0 键
+- 任务账本:5 条(discovery 1 / tdd 2 / testcase 1 / testexec 1)· 开局 dispatched=4 · pending=1(`tc-20261130-1008-a`)· resume 0
+- 7 节点配额 0/3(各 50 会话 busy=0 全空闲)· 运行模式 MULTI_AGENT
+- 阻塞台账:2/2 待处理(均研发类,due 12-01 20:25)
+
+## 3. 专题① langgraph(192.168.16.251 · opencode.iwintrue.com)
+- 通道探活:`192.168.16.251:9000/health` = **200**(`{"status":"ok"}`,可达;`251` 裸短名在本 bash 不解析致首探 000,经 hosts 映射 `opencode.iwintrue.com→192.168.16.251` 复核为可达)· opencode `/api/session` = **401**(认证层可达,非 fetch failed)
+- 恢复信号判定:`cfc-langgraph` 6h 窗口 **0 提交**(最近 `bce8daac4` 11-28 10:40 已在 R560/R595 树内)→ **无恢复信号**
+- 节点日志直读(权威基线 = R675 06:02 实测 `/tmp/r_lg_harvest_20261130-055900.log`,mtime 06:02:23 未推进,本轮未产新日志):
+  - 44 例 = **2 红 / 42 过**(183.20s,EXIT=124 强杀口径沿用 B-325-1)
+  - **429=3 / 401=2 / ConnectError=0**(逐位对齐 R595~R675 基线;401=api key ****ab12 invalid、429=AgnesAI free 配额)
+- 处置结论:
+  - 51 例 pytest **未重跑**——仅出现恢复信号才实跑;本轮无 src 提交、429≠0、B-325-1 未修,标「**承袭(节点可达、无恢复信号、R675 实测基线沿用)**」
+  - **B-325-1 维持观察**(EXIT=124 强杀口径)· **B-325-2 不排除**(429=3≠0,配额族未销号)
+
+## 4. 专题② 浏览器 E2E
+- 节点口径:web-189-4090=lan-189(189:4090,admin 单任务)· opencode-iwintrue=pub-iwintrue(251,非浏览器)· web-4091 本机仅 frontend · lan-248(248:4090)· 204:4091 由本机覆盖不重派
+- 通道探活(5 节点 `base_url/session`,单任务不并发):opencode.iwintrue.com / 192.168.16.189:4090 / 192.168.16.204:4091 / 127.0.0.1:4091 / 192.168.16.248:4090 **全 401**(认证层可达,无 fetch failed)
+- 契约核验:`f3f3e90f2`(runE2E)/ `cb9725290`(runSmoke)均 **ANCESTOR_YES**(MERGED)
+- 实现落地判定:近 7 天生产 src(cfc-backend/src/main、cfc-frontend、cfc-web/src)grep `runE2E`/`runSmoke`/`adminPanel`/`frontendMobile` **0 命中**(仅测试契约提交 f3f3e90f2/cb9725290 + R592 台账)→ 研发实现仍未落地,RED 停留 >24h(due 12-01 20:25),**不重复派发**
+- 分发核验(A 类职责):**本轮补投 pending 任务** `tc-20261130-1008-a`(用例编写)→ lan-248 / `ses_dd5a8f96fffeEK8xrwLgTBfRwg`:dispatch 回执 `verified=true`(1567 字投递)+ 账本 pending→dispatched 原子回写(10:44:36);`lan-248` 消息端点(/session/{sid}/message|messages|history|{id})**全 404** → 深探核验受限(R619 口径),以 dispatch 回执 + 账本回写为送达证据,**不写成已核验**
+- 在途 E2E RED 会话:S-junit-2(web-189-4090)/ S-junit-3(web-4091)真送达已在 R664/R669/R680 逐位核验(busy+消息命中,非 0 会话当成功);契约已合入、实现未落地 → 停留 RED awaiting 研发 impl,不重复派发
+
+## 5. 域结论表
+| 审查维度 | 负责专家 | 结论 | 关键证据 |
+|---|---|---|---|
+| langgraph pytest(专题①) | 测试负责人 | 承袭·未重跑(节点可达无恢复信号) | 9000/health=200 · 6h src 0 提交 · 429=3/401=2/Conn=0 |
+| 浏览器 E2E(专题②) | 测试负责人 | 承袭·不重派(实现未落地) | 5 节点全 401 可达 · 契约 ANCESTOR_YES · 生产 src 0 命中 |
+| 用例编写派发 | 测试负责人 | 已投递(本轮唯一动作) | tc-20261130-1008-a → lan-248/ses_dd5a8f96... 回执 verified + 账本回写 |
+| 全局稳态 | 测试负责人 | 承袭(38 retest 项失真由标准轮 R685 第 95 轮实跑覆盖) | R685:编译 main2507/test694 · strict 27 |
+
+## 6. 五要素问题清单(沿用,无新增)
+1. **B-325-1**:251 遗留 pytest 进程驻留/EXIT=124 强杀 · bug 点=cfc-langgraph 测试进程管理 · 方案=迁 lifespan+fixture 显式关闭(勿裸杀)· 目的=防进程堆积致 429/EXIT=124 · 闭环=复跑 44 例 EXIT≠124 且无驻留进程
+2. **B-325-2**:AgnesAI Token/Agent Plan 配额(429=3)· bug 点=模型配额 · 方案=升 251 AgnesAI 配额 · 目的=清 429 使 51 例全绿 · 闭环=日志 429=0
+3. **B-401**:api key ****ab12 认证失效(401=2)· 方案=key 轮换 · 闭环=401=0
+4. **E2E 两 RED**(runE2E/runSmoke):研发实现未落地 >24h · bug 点=能力实现缺口 · 方案=研发落地后测试 YELLOW 校验 · 目的=SC 台账 strict 推进 · 闭环=6h 窗口生产 src 命中 + 契约转 GREEN
+5. **P-474-1**:@playwright 版本对齐(承袭)
+
+## 7. 门禁结论
+- **测试基线零漂移 vs R675/R680**(lg 计数逐位一致 · E2E 契约/阻塞状态同型 · 零新增产品代码缺陷)→ **不 push**(沿 R434~R685 纪律);本轮唯一动作(tc 补投)为测试运维账本状态推进,非测试结果变化,如实记录
+- 总评:**有条件不通过(稳态承袭 · 零新增缺陷)**——两 RED 阻塞 due 12-01 20:25,B-325 族未销号
+
+## 8. 研发/运维待办(沿用无新增)
+B-325-2 升配额 · B-325-1 迁 lifespan+fixture · B-401 key 轮换 · 两条 E2E 契约实现落地 · P-474-1 对齐

+ 73 - 0
docs/tdd/orchestration/report-test-2026-11-30-1100.md

@@ -0,0 +1,73 @@
+# TDD 测试负责人收割汇报 · R688 · 2026-11-30 11:00 档(00 分标准轮)
+
+> 角色:测试负责人(纯调度 + 验收);cwd `d:/cfc`;主线 `cfclub` / `data_ref=origin/cfclub`。
+> 附加技能 ID `skill_2053082580726448128` 历史结论为 not found(本轮未再尝试),以 tdd-orchestrator 为唯一依据。
+
+## 1. 历史审查记录(对照,不作本次结论依据)
+- 上一相邻轮 R686(10:55 push `cf383c7c7`)30分 langgraph+E2E 档:承袭基线 + 补投 `tc-20261130-1008-a`。
+- R685(10:18 push `b16f781a4`)00分标准轮:三类派发链入账,会话中断/失败如实承袭。
+- 上轮遗留:需求发现成功(`afadc04f1`);用例会话空壳、执行会话 failed(本轮已改投);长期 blocker 承袭。
+
+## 2. S0–S4 门禁与盘点
+| 步骤 | 结果 | 证据 |
+|---|---|---|
+| S0 启动前置三查(<60s) | 分支 `cfclub` ✓;初始 `1 0` → fetch 后 `1 1` → rebase+push 后 `0 0`;tracked 脏 0 | `git rev-list --left-right --count HEAD...origin/cfclub`;HEAD `cf383c7c7`;742 未追踪(含 `.r*`)零触碰 |
+| S1 互斥门 | **PASS**(轮首固化) | state mtime 龄 1145.2min;slot UNUSED;worklog.active=null;locks={} |
+| S2 失败补跑 | 无需补跑 | 最近 `report-dev-2026-11-30-1041.md` 11:03,未超 `report_stale_hours=2` |
+| S3 盘点 | RED 2 / GREEN 5 / 部署 pending 0;`--changes` 0 新键 | `web.adminPanel.runE2E`、`web.frontendMobile.runSmoke` 仍 RED;需求文档 1 / 设计 53 / 其他 148 变更 |
+| S3 工作区 | tracked 干净;`--clean-check` 因 742 未追踪返回 1(历史口径,`.r*` 永不 add) | `--sc-evidence`:243 / status 27 / strict 27 / anomalies 0 / worktree_clean=true |
+| S3.5 复测门 | `--retest-gate` = RETEST_REQUIRED(65 项全 retest,6h/46 提交含 src,health_url 未配) | 按触发式复测纪律:长期同结果 blocker 无「health 200 + 针对性 src 提交」双信号 → 全部标**承袭·未实测**,禁记通过 |
+| S4 恢复 | `--resume --dry-run` 候选 0,恢复 0 | 无中断会话需恢复 |
+
+## 3. 会话配额(S3 `--inspect`,per-node 上限 3)
+- `web-189-4090`(lan-189) 2/3 余 1(admin 单任务)
+- `web-4091`(本机 frontend) 0/3 余 3
+- `opencode-iwintrue`(pub-iwintrue/251) 3/3 **满额**
+- `lan-248` 0/3 余 3(非浏览器任务承接)
+- `lan-204` 0/3 余 3(非本项目白名单承接,未派)
+
+## 4. 在途任务验收(只认 git 证据 + 会话消息,不认自述)
+| tid | 节点/会话 | 验收结论 | 依据 |
+|---|---|---|---|
+| `disc-20261130-1008-a` | 251 `ses_dd5c95…12FeOHS` | **已交付** | outcome=succeeded;msgs=49;commit `afadc04f1` 已在 origin/cfclub 祖先 |
+| `tc-20261130-1008-a` | 账本写 248、实际空壳在 251 `ses_dd5a8f…` | **不通过(空壳)** | msgs=0、tokens=0、无 commit;已由 `tc-20261130-1100-a` 替代 |
+| `tex-20261130-1008-a` | 4091 `ses_dd5c93…` | **不通过(failed)** | outcome=failed;msgs=8;无 `report-exec-*` 落盘;已由 `tex-20261130-1100-a` 替代 |
+| `disc-20261130-1100-a` | 251 `ses_dd5955…` | **不通过(错配)** | dispatch 回执写 248,但会话实际在 251 且 msgs=0;由 `-b` 改投 |
+| `disc-20261130-1100-b` | 248 `ses_dd59461…EboU` | **在途(未判完成)** | dispatch verified;busy=True;msgs=2 仅 reasoning 空体,消息命中尚未落盘 |
+| `tc-20261130-1100-a` | 248 `ses_dd594f0…32u` | **在途(消息命中)** | busy=True;msgs=3,含 D-04/D-06 目标原文;会话自报 rebase 冲突(只报不动) |
+| `tex-20261130-1100-a` | 4091 `ses_dd5952…KGZ` | **在途(消息命中)** | busy=True;msgs=3,含双端 Jest 有界子集目标原文 |
+
+## 5. 三类实事派发链(负责人零实事)
+- ① 建账本:`enqueue.py` 逐类返回 tid(`disc-…-b` / `tc-…-a` / `tex-…-a`),prompt 为 `gen/TASK-*-2026-11-30-1100.txt` 绝对路径,按目标段填具体能力键/套件。
+- ② 投递:`dispatch.py --task <tid> --json`;`tc`/`disc-a` 首次因 label=`junit` 选路到满额 251,改用 `_alloc_with_quota_check(client_override='lan-248')` 预分配会话 + `--session` 投递成功(幂等,不硬塞)。
+- ③ 验收:下探 `/session/{sid}/message` 逐条核 busy + 消息命中;空会话/failed/错节点均如实判不通过,无「0 会话当成功」。
+- 溯源:`bed17d077`(S-cfc-491) / `87d0abdf8`(S-cfc-485) / `discovery-2026-11-30-1008.md` D-04/D-06;均为实际工作,无虚构任务。
+
+## 6. 20 类测试覆盖矩阵(承袭基线,非本轮实测)
+| 类 | 三态 | 类 | 三态 |
+|---|---|---|---|
+| 单元测试 | 已发现·承袭未实测 | 集成测试 | 已发现·承袭未实测 |
+| 系统测试 | 已发现·承袭未实测 | 验收 UAT | 待核实(strict 27/243) |
+| BDD 规格 | 未发现 | 冒烟测试 | 已发现·承袭未实测 |
+| 回归测试 | 已发现·承袭未实测 | 探索性测试 | 未发现 |
+| 自动化测试 | 已发现·承袭未实测 | 性能测试 | 已发现·承袭未实测 |
+| 可靠性测试 | 待核实 | 安全测试 | 已发现·承袭未实测 |
+| 兼容性测试 | 已发现·承袭未实测 | 可用性测试 | 未发现 |
+| 无障碍测试 | 未发现 | QA 流程 | 已发现·承袭未实测 |
+| 质量指标 | 已发现·承袭未实测 | 代码审查 | 待核实(本轮不做专项) |
+| 变更感知 | 已发现(0 新键) | 证据门禁 | 已发现(git + sc-evidence) |
+
+## 7. 五要素问题清单(本轮新增)
+1. ① 三类通用任务的 `--instance` 未传入会话分配器,`label=junit` 固定选到满额 251,产生 0 消息空壳。② `dispatch.py:130` 调 `_alloc_with_quota_check` 未带 `client_override`。③ 派发前用 `--inspect` 核配额,满额时由编排侧预分配 `client_override` 后 `--session` 投递。④ 消除空壳会话、保证任务落到有配额节点。⑤ 下轮复核 `disc/tc` 会话 msgs>0 且 commit 落盘即闭环。
+2. ① 10:08 测试执行会话 `outcome=failed` 且无报告。② `tex-20261130-1008-a / ses_dd5c93…`。③ 收窄为双端 Jest 有界子集并改投 4091(`tex-20261130-1100-a`)。④ 获取真实实测数字而非空报告。⑤ 节点回报 `report-exec-web-4091-2026-11-30-1100.md` 且 commit 在远端祖先即闭环。
+
+## 8. 阻塞与风险(承袭)
+- 长期 blocker:G-304-1 / B-260-1 / N-R373-1/2 / G9 / B-325-1 — 连续同结果 ≥3 轮,本轮无恢复信号,**承袭·未实测**,不代判修复。
+- 研发侧 RED 2 键停留 >24h(`web.adminPanel.runE2E`、`web.frontendMobile.runSmoke`),不在测试侧改判。
+- 251 满额(3/3),`pub-iwintrue` 同节点别名亦满;后续非浏览器任务优先 248。
+- 242 个 SC 未 strict 通过(243 总数 / 27 strict);本轮未新增场景跑通声明。
+
+## 9. S9–S11 收口与门禁
+- 只写本汇报文件;`git add -- docs/tdd/orchestration/report-test-2026-11-30-1100.md`,`git commit -m ... -- <精确路径>`,push `cfclub`,复核 `0 0`。
+- `.r*` 与 742 未追踪产物零触碰;未改生产源码、`state.json`、`blockers.md`;未 mark-*/deploy-done/merge-to-main;无人值守零提问、零凭据明文。
+- **门禁结论:本轮调度闭环通过;产品质量不通过(承袭 65 项未实测 + 2 RED + 长期 blocker 未闭环)。** 新派发 3 单在途,结果由下轮按 git 证据回收,本轮不预支通过。

+ 109 - 0
docs/tdd/orchestration/report-test-2026-11-30-R683-0749.md

@@ -0,0 +1,109 @@
+# 测试负责人收割汇报 · R683 · 2026-11-30 07:39~08:14
+
+- **档位**:50 分档 · **稳态校验档** · **A 类**(直接测试 + 测试任务分派)· 编译/Jest/覆盖率稳态校验
+- **角色**:测试负责人 · **主线** `cfclub` · data_ref=`origin/cfclub` · cwd=`d:/cfc`
+- **结论**:**不通过(有条件 · src 变更轮实测确认)**——窗口内 `fix(f03)` Java src/test 新增落地(07:56),后台实跑确认编译通过、test 数 +1(非缺陷);双端 Jest 第 47 轮不可测、两 RED 第 3 日、重启族 P0 未闭环。
+- **★本档关键转折**:开工时窗口零 src(S3.5 carry 路径),但收口前 ff-only pull 发现 origin 推进 `36522a427 fix(f03)`(07:56,3 main + 3 test Java 文件)→ 转为 **src 变更轮**,按 mandate 后台实跑编译取证。
+
+## 0. 历史审查记录(仅对照,不作本次结论依据)
+
+| 轮次 | 结论 / 基线 | 本次对照 |
+|---|---|---|
+| R679 06:53~07:00(0 分标准轮) | 编译第 95 轮实跑 2506/693 零漂移 | 本轮第 96 轮实跑 **2506/694**,main 零漂移 / test +1 |
+| R682 07:29(B 类 20 分 API 契约档) | 新增 16 端点匿名守卫例 U429~U444 | 仅 B 类 JS e2e spec |
+| 两 RED(runE2E/runSmoke) | 研发 blocker 登记 11-28 20:25,due **12-01 20:25** | 第 3 日未改善,承袭 |
+
+## 1. 项目画像(稳态承袭)
+
+Spring Boot 2.7 后端(9082)+ uni-app 小程序 + Vue 管理端 + Python LangGraph AI(251:9000)。运行模式 **MULTI_AGENT**(session_connections=10 / opencode_clients=12,可派发)。质量目标:编译零漂移 + 双端 Jest + G9 覆盖率稳态 + 场景三流证据闭环。
+
+## 2. S0/S1/S2 前置门禁(实跑)
+
+| 项 | 实测值 | 判定 |
+|----|--------|------|
+| 分支 | `cfclub`(== 主线) | ✓ |
+| 与远端差距(开工) | `HEAD...origin/cfclub` = **0 0**(HEAD `d14bdf31e`) | ✓ |
+| tracked 脏清单(开工) | **0**(742 未追踪含 `.r*`,永不 git add) | ✓ |
+| S0 耗时 | 三查并发 <60s(未触降级) | ✓ |
+| S1 互斥门 | `--mutex-check`=**PASS**(state 龄 949.1min、worklog null、locks {}、slot UNUSED),轮首固化 | PASS |
+| S2 失败补跑 | 错峰档**跳过**(0 分标准轮承接) | 跳过 |
+| **收口前对齐** | 收口时 origin 推进 → `git pull origin cfclub --ff-only` → 终态 `0 0`、tracked 脏 **0**、HEAD `d8f81a835` | ✓ |
+
+## 3. 窗口权威二级收敛 + S3.5 稳态(含中途 src 变更转折)
+
+- **开工窗口**(基线 `c80ef0242`=R679 第 95 轮实跑基线 .. `origin/cfclub`)初判 **零 Java src/test、零前端生产 src**(仅 cfc-web 打包元数据 + docs 报告 + `tests/e2e/api/auth-guard-admin-butler.spec.js` B 类 JS),距 R679 实跑 06:58 ~41min < 6h → 初判走 S3.5 carry 路径。
+- **★中途转折(收口前发现)**:`git pull --ff-only` 拉入 `36522a427 fix(f03)`(07:56)= **cfc-backend 3 main src**(`PpointConsumptionLogMapper` / `CfCommissionRecalcService` / `CfReferralService`)+ **3 test src**(`CfCommissionRecalcTest` M / `AsOfPaidAtTest` A 新增 / `F03FinalFixesTest` M)。→ 窗口现含 **Java src/test 6 文件**,前端生产 src 仍 0。
+- **mandate「有变更 → 后台实跑一次」**:触发后台 `mvn -o -B -q clean test-compile`(后台防 SIGTERM 回滚先编辑文件)。
+
+### 本档专题实测(第 96 轮)
+
+| 项 | 实测 | 判定 |
+|---|---|---|
+| 编译 clean test-compile | **BUILD SUCCESS / EXIT=0 / 9m18s / `[ERROR]` 0**,main **2506** / test **694** | test **+1**(`AsOfPaidAtTest` 新增编译产物确认),main 逐位零漂移 |
+| 双端 Jest | **第 47 轮不可测**(cfc-web 无 node_modules / cfc-frontend 34B 坏链 / `.gitignore:12`) | 未实测·P-430-2 |
+| G9 覆盖率 | 承袭 **web L11.46%(244/2128) / fe L55.13%(1648/2989)**(窗口前端生产 src=0,Java 变更不影响前端覆盖率分子分母) | 承袭·未重算 |
+| SRS 闸门 | `--sc-evidence`=**strict 27 / 243**,anomalies **0**,worktree_clean true | 承袭 |
+
+- S3.5 `--retest-gate`(开工时 origin=d14bdf31e):verdict=RETEST_REQUIRED(exit2,total 65 / carry 28 / retest 37,`window_src_changed=false`);37 retest 全为 rounds<3 环境型 blocker,归 0 分标准轮/B 类职责。**该判定基于开工窗口,未含中途拉入的 fix(f03);编译已按 src 变更轮实跑覆盖。**
+
+## 4. 触发式复测门(7 长跑 blocker)
+
+7 blocker:`G-304-1`(carry 32 轮) / `B-260-1`(carry 55 轮) / `N-R373-1·2` / `G9` / `B-325-1`(carry 23 轮) / `S1-1·R203`。
+
+- 判据 ①网关 `/api/system/health` 返回 **200** ✓(07:46:29 新重启);判据 ②窗口内针对该 blocker 的 src 提交 = **0**(`git log --grep` 对 G-304/B-260/N-R373/G9/B-325/S1-1/R203 全 0 命中;`fix(f03)` 系 f03 业绩归属修复,非任一 blocker 目标)✗。
+- → **恢复信号不成立** → 7 项全「**承袭·未实测**」,跳过全量复测,不记通过。
+
+## 5. 环境探针(实测)
+
+| 端点 | 实测 | 备注 |
+|---|---|---|
+| 网关 health POST | **200 · 317B** | startTime **07:46:29**(uptime 3min)· mem 279.0MB(29.3%)/max 952.0MB · cpu 17.5% · Java 1.8.0_492 · 48 核 |
+| /admin/ | 200 · 722B | 逐位未变 |
+| /frontend/ | 200 · 1034B | 逐位未变 |
+| lg 251:9000 | 200 · 15B | 可达 |
+| 本机 9082 | 000 | 未启(纪律不擅自重启) |
+
+### 重启族 P0 追踪
+
+startTime 今日序列:`05:04:55 → 06:25:42`(80.8min) `→ 06:35:35`(9.9min) `→` **本档 07:46:29**(70.9min)。R679 曾止稳 2/3 趋势被 9.9min 击穿;本档 70.9min 拉长但**仍未达 2h 稳态,止稳 0/3 回退**。疑 auto-deploy/健康检查重启,**待核实**。
+
+## 6. S3 精简盘点(错峰档,--changes/--clean-check 由标准轮承接)
+
+| 项 | 实测 |
+|---|---|
+| `--status --top12` | **RED 2**(`web.adminPanel.runE2E` / `web.frontendMobile.runSmoke`)|**GREEN 5**(admin.auth.login / dan.assessment.getActiveMaterial / guide.trainingPlan.getPlanDetail / health.report.createReport / health.report.upload)|数据源 ⏳ **0** |
+| `--inspect`(role=测试) | 账本 **2 dispatched / pending 0**(S-junit-2/3 他档**只报不动**)|7 节点:lan-189 busy2 / lan-204 busy2 / lan-248 busy0 / opencode-iwintrue busy1 / pub-iwintrue busy1 / web-189-4090 busy2 / web-4091 busy2(配额 0~2/3) |
+| `--resume --dry-run` | 候选 **0** |
+| `--sc-evidence` | 243 / status 27 / **strict 27** / anomalies 0 / worktree_clean true |
+
+## 7. S4/S5/S6/S7/S8 分派与收线(A 类)
+
+| 项 | 结果 |
+|---|---|
+| S4 恢复 | 无恢复候选、无 wedged/stalled,**0** |
+| S5/S6 心跳/填充 | `heartbeat.enabled=false` / `fill_capacity.enabled=false` → **跳过** |
+| S7 派发 | 窗口 Java src 变更已由本档**本地后台实跑**(编译第 96 轮)取证,**A 类本档负责的编译实测已闭环,无需再派节点**;`dispatch.py` 在位 8590B、账本 2 dispatched(S-junit-2/3 他档)只报不动;派发条件(窗口 src 变更且需复测)已由本地实跑满足,**零节点派发为合法**(避免与本地实跑重复打同物理节点) |
+| S8 池空续建 | 目标池 ⏳ 0 键、无新 TR/O/B 溯源、未跑通 SC 属 B 类职责 → **建单 0**(收敛) |
+
+## 8. 五要素问题清单(本轮无新增产品缺陷;test +1 系 fix(f03) 新测试类确认)
+
+**P-683-1(P0 · 重启族延续新换代)** ①`/api/system/health` startTime 07:46:29 新换代;②bug 点=承袭/复测判据依赖 startTime 连续同值,新换代打断止稳;③方案=研发/运维输出重启日志纳入告警、排查 auto-deploy 触发源;④目的=恢复判据可信度;⑤闭环=startTime 连续 3 轮同值且间隔 >2h。**承袭·未实测**(窗口无针对该 blocker 的 src)。
+
+**P-683-2(P0 · 两 RED 第 3 日)** ①`web.adminPanel.runE2E` / `web.frontendMobile.runSmoke` 生产实现零命中,RED 停留第 3 日(due 12-01 20:25);②bug 点=契约级单测已交付但实现未落地,无法进 YELLOW;③方案=研发实现落地并 push(测试不代实现);④目的=守状态机职责边界;⑤闭环=实现落地后到期复验复跑契约转 GREEN。**承袭·未实测**。
+
+**P-683-3(P0 · 双端 Jest 第 47 轮不可测)** ①cfc-web 无 node_modules / cfc-frontend 34B 坏链 / `.gitignore:12` 尾斜杠;②bug 点=双端 Jest 无实测通道;③方案=修复两端依赖安装与坏链;④目的=前端覆盖率可重算;⑤闭环=双端 Jest 可跑通一次。**承袭·未实测**。
+
+**P-683-4(P2 · 断链债务)** ①`automation-status.md` 持续断更、报告被 `.gitignore:160` 拦截;②bug 点=报告入库需 `git add -f`;③方案=标准轮批量补提断链债务;④目的=审计链完整;⑤闭环=断链计数停止增长。**承袭**。
+
+## 9. 门禁结论
+
+- **编译/Jest/覆盖率稳态校验:通过(src 变更轮实测确认)**——编译第 96 轮 EXIT0、main 零漂移、test +1(新测试类确认,非缺陷);Jest/G9 通道断承袭。
+- **产品整体:不通过(有条件)**——两 RED 第 3 日承袭 + 7 长跑 blocker 承袭·未实测 + 双端 Jest 第 47 轮不可测 + 重启族 P0 新换代未稳态。
+- **数值变化(test 693→694 +1)→ commit + push 研发通知**:`fix(f03)` 新增 `AsOfPaidAtTest` 编译产物确认;报告用 `git add -f -- <报告>` 强制入库(R682 先例),仅 add 本轮报告单文件。
+- **复评触发**:两 RED 生产实现落地 / 双端 Jest 通道修复 / 7 blocker 针对性 src 恢复信号 / 重启族 3 轮同值 >2h。
+
+## 10. 提交记录
+
+- 报告:`docs/tdd/orchestration/report-test-2026-11-30-R683-0749.md`(本文件,`git add -f` 强制入库)。
+- commit `b664c402a`(rebase 至 `0c44a3144` 后变 `93fc89276`)仅含本报告单文件(不带入他档 staged);push 至 `cfclub` 并通知研发(test +1 数值变化)。
+- 终态:HEAD `93fc89276` == `origin/cfclub`、`0 0`、tracked 脏 **0**、未追踪 **742**(`.r*` 零触碰);未改 state.json/blockers.md、未 mark-*/deploy-done/merge-to-main。

+ 17 - 0
docs/tdd/test/blockers.md

@@ -4657,3 +4657,20 @@
 - **P-679-4(P2 承袭)**:`automation-status.md` 断更 10.2 天(第 16 轮)/ `test-requests.md` 25 条待处理断更 19 天 / `tasks.json` 2 条 dispatched 虚高;本轮补 R676-R678 三档断更止损。
 - **派发(A 类)**:`--inspect` 闲位 21 + `--auto --dry-run` pending 0 双证 → **零派发为事实结果**;在途 2/2 ANCESTOR_YES;S8 四类溯源 0 → 建单 0。
 - **收口**:报告 `report-test-2026-11-30-R679-0658.md`(.gitignore:160 → 本地留存不推);本段为唯一共享推送内容;耗时 **~7min**。
+
+---
+
+## R684 段(2026-11-30 08:29~08:49 · 0 分标准轮 · 测试负责人 · 补记 R680-R683 四档无段)
+
+- **门禁**:S0 12s → 分支 `cfclub` ✓ / 差距 **0 1**(落后 1)→ `pull --rebase` → **0 0** / tracked 脏 **0** / 742 untracked / HEAD `91bdf9b52`→收口 `ba681d713`;S1 PASS(state 龄 **994.3min**、worklog null、locks {}、slot UNUSED);S2 不触发(report-dev 08:25 龄 7min、harvest-run 00:21)。
+- **S3 全量**:RED2 / GREEN5(7 键)· 账本 2 dispatched / pending **0** · 7 节点(lan-189 busy4 **超限** / web-189-4090 busy4 **超限** / lan-204 1 / lan-248 0 / opencode-iwintrue 1 / pub-iwintrue 1 / web-4091 1 → 闲位 **11**)· resume 0 · `--changes --days 3` **新增键 0** · SC 243 / status 27 / **strict 27**(worktree_clean **true** → 口径已由他档提交恢复)· clean-check 742 假阳性第 **52** 轮。
+- **S3.5**:`--retest-gate` 65 项 carry 0 / retest 65(P-600-1 宽口径失真);二级判据 `693da87ed..origin/cfclub` — cfc-backend/src **8 文件**(main 5 / test 3)→ **不承袭、实跑**(本轮判据与 gate 结论一致,无假稳态风险)。
+- **实测(第 97 轮)**:`cd cfc-backend && mvn -o -B clean test-compile` **BUILD SUCCESS / EXIT=0 / 7m13s / `[ERROR]` 0**,类产物 **main 2507 / test 694**;源码 **2286 / 643**(+1/+1)。**main 2506→2507 为新基线**(`ba681d713` FoodDiseaseWeightGroup),test 694 与 R683 一致。
+- **探针**:health POST **200·317B**(`startTime` Mon Nov 30 **08:36:29**、uptime 2min、mem 204.4MB/21.4%、cpu 22.6%、cpuLoad 10.83、48C/Linux);admin/frontend 裸路径 **302→尾斜杠 200·722B/1034B**;251:9000 **200·15B**;本机 9082 **000**(未启动);假路径 **404·107B**。
+- **P-684-1(P0 · 重启族第 4 日 + 新相关证据)**:`07:46:29 → 08:36:29` = **50.0min**;关键新证据:**08:28 两笔 feature 推送(`8a839bd12` / `ba681d713`)→ 08:36:29 重启,间隔仅 8min**,与「push 触发 auto-deploy 重启」假设强相关(早期窗口无提交的重启仍无法解释,故维持**待核实**)。闭环=startTime 连续 3 轮同值且间隔 >2h。
+- **P-684-2(P1 · 基线过期,第 2 例)**:编译基线已由 2506/693 → **2507/694**(R658 曾记 2499/683)。**承袭判据必须以 `git diff <基线sha>..origin/cfclub -- 生产 src == 0` 为前提并重记基线**,否则「逐位一致」结论会随基线漂移失效。
+- **P-684-3(P1 · 探针口径固化)**:`/admin`、`/frontend` **不带尾斜杠返回 302**(跳自身尾斜杠),历史轮记的 722B/1034B 是跟随后的结果。**探针须用 `-L` 或直接带尾斜杠**,否则 302 会被误读为「页面异常/回归」——本轮已用 `-L` 复核为 200 正常。
+- **P-684-4(P2 承袭)**:`automation-status.md` 断更 **10.4 天**(第 17 轮)/ `test-requests.md` 25 条「待测试处理」断更 19 天 / `tasks.json` **2 条 dispatched 虚高**(S-junit-2/3 自 11-27 19:17 派发未收口;其 RED 证据 `f3f3e90f2`、`cb9725290` 均 **ANCESTOR_YES**)。
+- **P-684-5(P2 · 台账断档止损)**:R680-R683 四档(07:09/07:37/08:00/08:25 report-dev)**未写 blockers 段**,本段一并补记关键变化;`--sc-evidence` strict 由 R668-R674 的 **0** 恢复 **27**,证实此前 `strict 0` 系他档 staged WIP 污染(口径失真,非场景退化)。
+- **派发(A 类)**:`--inspect` 闲位 11(两节点超限不计)× `--auto --dry-run` pending **0** 双证 → **零派发为事实结果**(非故障);在途 2/2 ANCESTOR_YES;S8 四类溯源 0 → 建单 0(SC 未跑通 216 项属 40 分档 E2E 职责,非本档可建单)。
+- **收口**:报告 `report-test-2026-11-30-R684-0845.md`(.gitignore:160 → 本地留存不推);本段为唯一共享推送内容。