Просмотр исходного кода

feat(attribution): S-cfc-427 health.analysis.mediatorAudit 介导链路确定性因果审计使绿

- AttributionLowSideRules: +RULE_MEDIATOR_AUDIT(mediator_audit) +FORBIDDEN_MEDIATOR_WORDS
  (导致/治愈/改善/典型表现/正是/的根/拖了/后腿) +MEDIATOR_AUDIT_HINT(关联非因果改写建议);
  WORDING_WHITELIST 并入「待进一步确认」(§5.8 必用措辞)
- AttributionComplianceGate.scan(): 追加 matchMediatorAudit 回扫, L5 出文档前命中产出违规
- HealthAnalysisMediatorAuditContractTest 12/12 绿 (红基线 10/12 红); 相关 5 类测试 41 例零回归
Agnes Agent 3 дней назад
Родитель
Сommit
12234d8123

+ 16 - 1
cfc-backend/src/main/java/com/etotem/cfc/constant/AttributionLowSideRules.java

@@ -91,12 +91,27 @@ public final class AttributionLowSideRules {
             "U 型双向口径:偏离人群参考区间两端都可能关联异常,「越低越好不成立」;"
                     + "人群参考下限为 0 的报告不标注「偏低超标」,ND 仅表示低于检出丰度。";
 
+    /** P1-2 介导链路确定性因果审计规则码:输出侧拦截「导致/治愈/改善/典型表现/正是…的根/拖了…后腿」。 */
+    public static final String RULE_MEDIATOR_AUDIT = "mediator_audit";
+
+    /**
+     * §5.8 介导链路禁用词表(覆盖「导致/治愈/改善/典型表现/正是…的根/拖了…后腿」)。
+     * L5 出文档前 scan 回扫任意叙述/结论文本中的这些确定性因果措辞——命中即产出 mediator_audit 违规。
+     */
+    public static final List<String> FORBIDDEN_MEDIATOR_WORDS = Collections.unmodifiableList(Arrays.asList(
+            "导致", "治愈", "改善", "典型表现", "正是", "的根", "拖了", "后腿"));
+
+    /** §5.8 介导链路审计改写建议(关联非因果口径):命中禁用词时给下游的建议改写方向。 */
+    public static final String MEDIATOR_AUDIT_HINT =
+            "介导链只作上游信号、不判能力:请改用关联非因果措辞改写(相关联 / 报告提示 / 可能与…有关 / 待进一步确认),"
+                    + "禁「X导致Y」「这正是Z的典型表现」「正是…的根」「拖了…后腿」等确定性因果表述。";
+
     /**
      * 措辞白名单(关联非因果口径)。描述菌↔问题关联时,仅允许使用下列措辞;
      * 白名单外的因果表述(如「缺大肠杆菌→致病/需补充」)由门禁拦截并给出建议改写。
      */
     public static final List<String> WORDING_WHITELIST = Collections.unmodifiableList(Arrays.asList(
-            "相关联", "报告提示", "可能与…有关", "可能与", "有关"));
+            "相关联", "报告提示", "可能与…有关", "可能与", "有关", "待进一步确认"));
 
     /** 白名单兜底建议(命中违规时给下游的建议改写) */
     public static final String WHITELIST_HINT =

+ 28 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/attribution/AttributionComplianceGate.java

@@ -221,6 +221,10 @@ public class AttributionComplianceGate {
         if (!strainGranularity) {
             out.addAll(matchStrainRecommendation(text));
         }
+        // §三 P1-2 介导链路确定性因果审计(health.analysis.mediatorAudit,§5.8):
+        // L5 出文档前对解读/结论文本回扫「导致/治愈/改善/典型表现/正是…的根/拖了…后腿」,
+        // 命中即收集为违规(建议改写为 相关联/报告提示/可能与…有关/待进一步确认)。
+        out.addAll(matchMediatorAudit(text));
         return out;
     }
 
@@ -299,6 +303,30 @@ public class AttributionComplianceGate {
 
     // ==================== 内部 ====================
 
+    /**
+     * §三 P1-2 介导链路确定性因果审计(§5.8):对解读/结论文本回扫禁用措辞
+     * ({@link AttributionLowSideRules#FORBIDDEN_MEDIATOR_WORDS}),命中即产出
+     * {@code mediator_audit} 违规(报告侧暴露,建议改写为措辞白名单表述)。
+     */
+    private List<Violation> matchMediatorAudit(String text) {
+        if (text == null || text.trim().isEmpty()) {
+            return Collections.emptyList();
+        }
+        List<Violation> out = new ArrayList<>();
+        for (String word : AttributionLowSideRules.FORBIDDEN_MEDIATOR_WORDS) {
+            int from = 0;
+            int idx;
+            while ((idx = text.indexOf(word, from)) >= 0) {
+                out.add(new Violation(AttributionLowSideRules.RULE_MEDIATOR_AUDIT,
+                        "介导链路禁确定性因果措辞(§5.8):菌群→递质→情绪/认知链只作上游信号,不判能力",
+                        snippet(text, idx, idx + word.length()),
+                        AttributionLowSideRules.MEDIATOR_AUDIT_HINT));
+                from = idx + word.length();
+            }
+        }
+        return out;
+    }
+
     /** 非菌株级粒度下「菌名 + 菌株号」商品推荐拦截(T6 G-2) */
     private List<Violation> matchStrainRecommendation(String text) {
         if (text == null || text.trim().isEmpty()) {