فهرست منبع

fix: support string values in additionalAuditDimensions

Book rules used string dimension names (e.g. "规则一致性") but
buildDimensionList only accepted numeric IDs, silently dropping
all custom audit dimensions. Now resolves strings via reverse
lookup against DIMENSION_MAP with fuzzy matching fallback.
majx_mac 8 ماه پیش
والد
کامیت
ed67328cdb
1فایلهای تغییر یافته به همراه24 افزوده شده و 2 حذف شده
  1. 24 2
      packages/core/src/agents/continuity.ts

+ 24 - 2
packages/core/src/agents/continuity.ts

@@ -61,10 +61,32 @@ function buildDimensionList(
 ): ReadonlyArray<{ readonly id: number; readonly name: string; readonly note: string }> {
 ): ReadonlyArray<{ readonly id: number; readonly name: string; readonly note: string }> {
   const activeIds = new Set(gp.auditDimensions);
   const activeIds = new Set(gp.auditDimensions);
 
 
-  // Add book-level additional dimensions
+  // Add book-level additional dimensions (supports both numeric IDs and name strings)
   if (bookRules?.additionalAuditDimensions) {
   if (bookRules?.additionalAuditDimensions) {
+    // Build reverse lookup: name → id
+    const nameToId = new Map<string, number>();
+    for (const [id, name] of Object.entries(DIMENSION_MAP)) {
+      nameToId.set(name, Number(id));
+    }
+
     for (const d of bookRules.additionalAuditDimensions) {
     for (const d of bookRules.additionalAuditDimensions) {
-      if (typeof d === "number") activeIds.add(d);
+      if (typeof d === "number") {
+        activeIds.add(d);
+      } else if (typeof d === "string") {
+        // Try exact match first, then substring match
+        const exactId = nameToId.get(d);
+        if (exactId !== undefined) {
+          activeIds.add(exactId);
+        } else {
+          // Fuzzy: find dimension whose name contains the string
+          for (const [name, id] of nameToId) {
+            if (name.includes(d) || d.includes(name)) {
+              activeIds.add(id);
+              break;
+            }
+          }
+        }
+      }
     }
     }
   }
   }