Эх сурвалжийг харах

fix(s8): make N-2 orphan scan compatible with SqlSugar expression tree

S8FlowBizTypes was declared private static readonly in commit 842a2856.
SqlSugar's expression-tree resolver requires referenced fields to be
accessible (it threw 'Field S8FlowBizTypes can't be private' at runtime
inside ScanOrphanFlowInstancesAsync).

Two changes:
1. Promote S8FlowBizTypes to public static so external code paths can
   also use the canonical S8 BizType allow-list.
2. Capture into a local variable inside the scan method before the
   .Where() lambda — SqlSugar reliably handles closure-captured locals
   even when handling of static-field access is finicky.

Verified via B-02 stage 4 inject test (lwb/journals/S8/2026-04-27-S8-B02-stage4.md):
  - N-2 caught the freshly created orphan within 60s of next tick
  - Also surfaced a historical orphan from 2026-04-18 (instance
    id=795921804271685) — proves backfill detection works
  - Cooldown dedup honored (only 1 alert per orphan in 5+ minutes)
YY968XX 5 өдөр өмнө
parent
commit
ba8fbbac2a

+ 4 - 2
server/Plugins/Admin.NET.Plugin.AiDOP/Service/S8/S8ActiveFlowWatchService.cs

@@ -15,7 +15,7 @@ public class S8ActiveFlowWatchService : ITransient
     public const string AlertChannel = "s8-active-flow-stuck";
     public const string AlertChannelOrphan = "s8-orphan-flow-instance";
 
-    private static readonly string[] S8FlowBizTypes = new[] { "EXCEPTION_ESCALATION", "EXCEPTION_CLOSURE" };
+    public static readonly string[] S8FlowBizTypes = new[] { "EXCEPTION_ESCALATION", "EXCEPTION_CLOSURE" };
 
     private readonly SqlSugarRepository<AdoS8Exception> _exceptionRep;
     private readonly SqlSugarRepository<AdoS8NotificationLog> _notificationLogRep;
@@ -144,8 +144,10 @@ public class S8ActiveFlowWatchService : ITransient
         int thresholdHours,
         CancellationToken cancellationToken)
     {
+        // 本地副本:SqlSugar 表达式树不允许直接引用静态/私有字段,必须先拷到 lambda 闭包变量。
+        var bizTypes = S8FlowBizTypes;
         var candidates = await _flowInstanceRep.AsQueryable()
-            .Where(fi => S8FlowBizTypes.Contains(fi.BizType)
+            .Where(fi => bizTypes.Contains(fi.BizType)
                          && fi.Status == FlowInstanceStatusEnum.Running
                          && fi.StartTime < staleBefore)
             .OrderBy(fi => fi.StartTime, OrderByType.Asc)