@longzai-intelligence-workflow/core 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { GateRuling, WORKFLOW_REF_PATTERN, WORK_ITEM_STATUSES, WorkItemStatus, WorkflowDocFrontmatter, WorkflowDocFrontmatterSchema, WorkflowEdge, WorkflowGate, WorkflowItem, actionContextSchema, actionResultSchema, actionSchema, actionTypeSchema, alertDtoSchema, alertTypeDtoSchema, auditLogDtoSchema, createDefinitionInputSchema, createInstanceInputSchema, createTriggerInputSchema, definitionDtoSchema, feedApplyTagsActionSchema, feedEventFilterSchema, feedEventNameSchema, feedEventPayloadSchema, feedEventTriggerSchema, feedSummarizeActionSchema, instanceDtoSchema, instanceQueryParamsSchema, instanceStatusDtoSchema, llmCompleteActionSchema, metricTypeDtoSchema, monitoringDashboardDtoSchema, nodeExecutionDtoSchema, nodeExecutionStatusDtoSchema, parseEdgeLine, parseGateLine, parseGateRuling, parseItemLine, performanceMetricDtoSchema, stateTransitionDtoSchema, trendPointDtoSchema, triggerDtoSchema, triggerTypeDtoSchema, updateDefinitionInputSchema, updateTriggerInputSchema, webhookSendActionSchema, workflowEdgeDtoSchema, workflowNodeDtoSchema } from "./schemas.js";
2
+ import { DependencyEdge, EdgeIssue, areAllDependenciesMet, dependenciesMet, detectCycle, detectCycles, downstreamOf, nodesOf, topologicalLevels, topologicalSort, validateEdges } from "@longzai-intelligence-dag/core";
2
3
  import { z } from "zod";
3
4
  //#region src/types/definition.d.ts
4
5
  type DefinitionDTO = {
@@ -333,34 +334,6 @@ type ParsedDeclaration = {
333
334
  */
334
335
  declare function parseDeclaration(documentText: string): ParsedDeclaration;
335
336
  //#endregion
336
- //#region src/utils/dag.utils.d.ts
337
- /**
338
- * DAG 机件(环检测 + 拓扑分层 + 依赖满足判定)
339
- *
340
- * 共享基础(设计对齐 scheduler workflow 域已验证机件;真源归本包,禁止再镜像)。
341
- */
342
- /**
343
- * 依赖边(from 完成后 to 可启)
344
- */
345
- type DependencyEdge = {
346
- readonly from: string;
347
- readonly to: string;
348
- };
349
- /**
350
- * 环检测(DFS 三色标记;返回首个环路径,无环为 null)
351
- *
352
- * @param edges - 依赖边集合
353
- */
354
- declare function detectCycle(edges: readonly DependencyEdge[]): readonly string[] | null;
355
- /**
356
- * 依赖满足判定(全部前置达完成/验收才算满足;无前置视为满足)
357
- *
358
- * @param node - 目标工作项 id
359
- * @param edges - 依赖边集合
360
- * @param settled - 已闭环(完成/验收)的工作项集合
361
- */
362
- declare function dependenciesMet(node: string, edges: readonly DependencyEdge[], settled: ReadonlySet<string>): boolean;
363
- //#endregion
364
337
  //#region src/utils/work-item-rules.utils.d.ts
365
338
  /**
366
339
  * 工作项合法状态转移表(状态机唯一注册点;供编辑工具与判定器共用的规则真源)
@@ -574,4 +547,4 @@ type ActionExecutorPort = {
574
547
  */
575
548
  declare const ACTION_EXECUTOR_PORT_TOKEN: unique symbol;
576
549
  //#endregion
577
- export { ACTION_EXECUTOR_PORT_TOKEN, ACTION_TYPES, ALERT_TYPES, ALLOWED_STATUS_TRANSITIONS, Action, ActionContext, ActionExecutorPort, ActionHandler, ActionResult, ActionType, AlertDTO, AlertTypeDTO, AuditLogDTO, CreateDefinitionInput, CreateInstanceInput, CreateTriggerInput, DEFAULT_PAGE_SIZE, DefinitionDTO, DependencyEdge, FEED_EVENT_NAMES, FEED_EVENT_PORT_TOKEN, FeedApplyTagsAction, FeedEventFilter, FeedEventHandler, FeedEventName, FeedEventPayload, FeedEventPort, FeedEventSubscription, FeedEventTrigger, FeedSummarizeAction, GateRuling, INSTANCE_STATUSES, InstanceDTO, InstanceQueryParams, InstanceStatusDTO, InvalidTransitionError, LlmCompleteAction, MAX_PAGE_SIZE, METRIC_TYPES, MetricTypeDTO, MonitoringDashboardDTO, NODE_EXECUTION_STATUSES, NODE_TYPES, NodeExecutionDTO, NodeExecutionStatusDTO, ParsedDeclaration, PendingRulingView, PerformanceMetricDTO, StateTransitionDTO, TRIGGER_TYPES, TrendPointDTO, TriggerDTO, TriggerTypeDTO, UpdateDefinitionInput, UpdateTriggerInput, WORKFLOW_REF_PATTERN, WORK_ITEM_STATUSES, WebhookSendAction, WorkItemStatus, WorkItemView, WorkflowDocFrontmatter, WorkflowDocFrontmatterSchema, WorkflowEdge, WorkflowEdgeDTO, WorkflowGate, WorkflowItem, WorkflowNodeDTO, WorkflowView, actionContextSchema, actionResultSchema, actionSchema, actionTypeSchema, alertDtoSchema, alertTypeDtoSchema, auditLogDtoSchema, checkStatusTransition, createDefinitionInputSchema, createInstanceInputSchema, createTriggerInputSchema, definitionDtoSchema, dependenciesMet, deriveWorkflowView, detectCycle, feedApplyTagsActionSchema, feedEventFilterSchema, feedEventNameSchema, feedEventPayloadSchema, feedEventTriggerSchema, feedSummarizeActionSchema, formatDate, getPagination, getTotalPages, instanceDtoSchema, instanceQueryParamsSchema, instanceStatusDtoSchema, llmCompleteActionSchema, metricTypeDtoSchema, monitoringDashboardDtoSchema, nodeExecutionDtoSchema, nodeExecutionStatusDtoSchema, parseDeclaration, parseEdgeLine, parseGateLine, parseGateRuling, parseItemLine, performanceMetricDtoSchema, stateTransitionDtoSchema, trendPointDtoSchema, triggerDtoSchema, triggerTypeDtoSchema, updateDefinitionInputSchema, updateTriggerInputSchema, webhookSendActionSchema, workflowEdgeDtoSchema, workflowNodeDtoSchema };
550
+ export { ACTION_EXECUTOR_PORT_TOKEN, ACTION_TYPES, ALERT_TYPES, ALLOWED_STATUS_TRANSITIONS, Action, ActionContext, ActionExecutorPort, ActionHandler, ActionResult, ActionType, AlertDTO, AlertTypeDTO, AuditLogDTO, CreateDefinitionInput, CreateInstanceInput, CreateTriggerInput, DEFAULT_PAGE_SIZE, DefinitionDTO, type DependencyEdge, type EdgeIssue, FEED_EVENT_NAMES, FEED_EVENT_PORT_TOKEN, FeedApplyTagsAction, FeedEventFilter, FeedEventHandler, FeedEventName, FeedEventPayload, FeedEventPort, FeedEventSubscription, FeedEventTrigger, FeedSummarizeAction, GateRuling, INSTANCE_STATUSES, InstanceDTO, InstanceQueryParams, InstanceStatusDTO, InvalidTransitionError, LlmCompleteAction, MAX_PAGE_SIZE, METRIC_TYPES, MetricTypeDTO, MonitoringDashboardDTO, NODE_EXECUTION_STATUSES, NODE_TYPES, NodeExecutionDTO, NodeExecutionStatusDTO, ParsedDeclaration, PendingRulingView, PerformanceMetricDTO, StateTransitionDTO, TRIGGER_TYPES, TrendPointDTO, TriggerDTO, TriggerTypeDTO, UpdateDefinitionInput, UpdateTriggerInput, WORKFLOW_REF_PATTERN, WORK_ITEM_STATUSES, WebhookSendAction, WorkItemStatus, WorkItemView, WorkflowDocFrontmatter, WorkflowDocFrontmatterSchema, WorkflowEdge, WorkflowEdgeDTO, WorkflowGate, WorkflowItem, WorkflowNodeDTO, WorkflowView, actionContextSchema, actionResultSchema, actionSchema, actionTypeSchema, alertDtoSchema, alertTypeDtoSchema, areAllDependenciesMet, auditLogDtoSchema, checkStatusTransition, createDefinitionInputSchema, createInstanceInputSchema, createTriggerInputSchema, definitionDtoSchema, dependenciesMet, deriveWorkflowView, detectCycle, detectCycles, downstreamOf, feedApplyTagsActionSchema, feedEventFilterSchema, feedEventNameSchema, feedEventPayloadSchema, feedEventTriggerSchema, feedSummarizeActionSchema, formatDate, getPagination, getTotalPages, instanceDtoSchema, instanceQueryParamsSchema, instanceStatusDtoSchema, llmCompleteActionSchema, metricTypeDtoSchema, monitoringDashboardDtoSchema, nodeExecutionDtoSchema, nodeExecutionStatusDtoSchema, nodesOf, parseDeclaration, parseEdgeLine, parseGateLine, parseGateRuling, parseItemLine, performanceMetricDtoSchema, stateTransitionDtoSchema, topologicalLevels, topologicalSort, trendPointDtoSchema, triggerDtoSchema, triggerTypeDtoSchema, updateDefinitionInputSchema, updateTriggerInputSchema, validateEdges, webhookSendActionSchema, workflowEdgeDtoSchema, workflowNodeDtoSchema };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as ee,J as te,K as c,L as l,M as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,b as E,c as D,d as O,f as k,g as A,h as j,i as M,j as N,k as P,l as F,m as ne,n as I,o as L,p as R,q as z,r as B,s as V,t as H,u as U,v as W,w as G,x as K,y as q,z as J}from"./schemas-D0Zuq8_5.js";function Y(e){return e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function X(e){if(!e.startsWith(`---
1
+ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as ee,I as te,J as ne,K as s,L as c,M as l,N as u,O as d,P as f,Q as p,R as m,S as h,T as g,U as _,V as v,W as y,X as b,Y as x,Z as S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,j as M,k as N,l as P,m as F,n as I,o as L,p as R,q as z,r as B,s as V,t as H,u as re,v as U,w as W,x as G,y as K,z as q}from"./schemas-D0Zuq8_5.js";import{areAllDependenciesMet as J,dependenciesMet as Y,dependenciesMet as X,detectCycle as ie,detectCycles as ae,downstreamOf as oe,nodesOf as se,topologicalLevels as ce,topologicalSort as le,validateEdges as ue}from"@longzai-intelligence-dag/core";function Z(e){return e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function de(e){if(!e.startsWith(`---
2
2
  `))return e;let t=e.indexOf(`
3
3
  ---
4
- `,4);return t===-1?e:e.slice(t+5)}function Z(e){let t={},n={},r=X(e);if(!e.startsWith(`---
4
+ `,4);return t===-1?e:e.slice(t+5)}function fe(e){let t={},n={},r=de(e);if(!e.startsWith(`---
5
5
  `))return{head:t,arrays:n,body:r};let i=e.indexOf(`
6
6
  ---
7
7
  `,4);if(i===-1)return{head:t,arrays:n,body:r};let a=e.slice(4,i).split(`
8
- `),o=null;for(let e of a){if(e.startsWith(` - `)&&o!==null){let t=Y(e.slice(4).trim());n[o]=[...n[o]??[],t];continue}if(o=null,e.endsWith(`: []`)){o=e.slice(0,-4),n[o]=[];continue}if(e.endsWith(`:`)){o=e.slice(0,-1),n[o]=[];continue}let r=e.indexOf(`: `);r>0&&!e.startsWith(` `)&&(t[e.slice(0,r)]=Y(e.slice(r+2)))}return{head:t,arrays:n,body:r}}function re(e){let t=new Map;for(let n of e)t.set(n.from,[...t.get(n.from)??[],n.to]);let n=new Map,r=[],i=e=>{let a=n.get(e)??0;if(a===1){let t=r.indexOf(e);return[...r.slice(t),e]}if(a===2)return null;n.set(e,1),r.push(e);for(let n of t.get(e)??[]){let e=i(n);if(e!==null)return e}return r.pop(),n.set(e,2),null},a=[...new Set(e.flatMap(e=>[e.from,e.to]))].sort((e,t)=>e<t?-1:1);for(let e of a){let t=i(e);if(t!==null)return t}return null}function ie(e,t,n){return t.filter(t=>t.to===e).every(e=>n.has(e.from))}const Q={todo:[`doing`,`blocked`,`dropped`],doing:[`blocked`,`done`,`dropped`],blocked:[`todo`,`doing`,`dropped`],done:[`todo`,`dropped`],dropped:[`todo`]};function ae(e,t){let n=Q[e];return n===void 0?{code:`INVALID_TRANSITION`,message:`未知状态:${e}`}:n.includes(t)?null:{code:`INVALID_TRANSITION`,message:`非法转移:${e} → ${t}(合法后继:${n.join(` / `)})`}}function oe(e){return e===`done`||e===`dropped`}function $(e,t,n){let r=new Set(e.filter(e=>oe(e.status)).map(e=>e.id)),i=new Set(n.filter(e=>e.ruling.status!==`approved`&&e.at!==`workflow`).map(e=>e.at));return{items:e.map(e=>{let n=t.filter(t=>t.to===e.id).every(e=>r.has(e.from));return{id:e.id,status:e.status,depsMet:n,blockedOnPrerequisite:e.status===`todo`&&!n,canStart:e.status===`todo`&&n&&!i.has(e.id)}}),pendingRulings:n.filter(e=>e.ruling.status===`pending`||e.ruling.status===`escalated`).map(e=>({key:`${e.at}:${e.kind}`,at:e.at,kind:e.kind,note:e.note,rulingStatus:e.ruling.status}))}}function se(e,t){let n=Math.min(t??20,100);return{offset:(Math.max(e??1,1)-1)*n,limit:n}}function ce(e,t){return Math.ceil(e/t)}function le(e){return new Date(e).toISOString()}const ue=Symbol(`FEED_EVENT_PORT_TOKEN`),de=Symbol(`ACTION_EXECUTOR_PORT_TOKEN`);export{de as ACTION_EXECUTOR_PORT_TOKEN,v as ACTION_TYPES,b as ALERT_TYPES,Q as ALLOWED_STATUS_TRANSITIONS,o as DEFAULT_PAGE_SIZE,c as FEED_EVENT_NAMES,ue as FEED_EVENT_PORT_TOKEN,z as INSTANCE_STATUSES,te as MAX_PAGE_SIZE,S as METRIC_TYPES,x as NODE_EXECUTION_STATUSES,C as NODE_TYPES,m as TRIGGER_TYPES,e as WORKFLOW_REF_PATTERN,N as WORK_ITEM_STATUSES,u as WorkflowDocFrontmatterSchema,H as actionContextSchema,I as actionResultSchema,B as actionSchema,M as actionTypeSchema,R as alertDtoSchema,ne as alertTypeDtoSchema,j as auditLogDtoSchema,ae as checkStatusTransition,l as createDefinitionInputSchema,G as createInstanceInputSchema,E as createTriggerInputSchema,h as definitionDtoSchema,ie as dependenciesMet,$ as deriveWorkflowView,re as detectCycle,T as feedApplyTagsActionSchema,F as feedEventFilterSchema,U as feedEventNameSchema,O as feedEventPayloadSchema,k as feedEventTriggerSchema,L as feedSummarizeActionSchema,le as formatDate,se as getPagination,ce as getTotalPages,_ as instanceDtoSchema,i as instanceQueryParamsSchema,r as instanceStatusDtoSchema,V as llmCompleteActionSchema,A as metricTypeDtoSchema,w as monitoringDashboardDtoSchema,f as nodeExecutionDtoSchema,P as nodeExecutionStatusDtoSchema,Z as parseDeclaration,d as parseEdgeLine,p as parseGateLine,a as parseGateRuling,ee as parseItemLine,W as performanceMetricDtoSchema,J as stateTransitionDtoSchema,q as trendPointDtoSchema,K as triggerDtoSchema,g as triggerTypeDtoSchema,t as updateDefinitionInputSchema,n as updateTriggerInputSchema,D as webhookSendActionSchema,y as workflowEdgeDtoSchema,s as workflowNodeDtoSchema};
8
+ `),o=null;for(let e of a){if(e.startsWith(` - `)&&o!==null){let t=Z(e.slice(4).trim());n[o]=[...n[o]??[],t];continue}if(o=null,e.endsWith(`: []`)){o=e.slice(0,-4),n[o]=[];continue}if(e.endsWith(`:`)){o=e.slice(0,-1),n[o]=[];continue}let r=e.indexOf(`: `);r>0&&!e.startsWith(` `)&&(t[e.slice(0,r)]=Z(e.slice(r+2)))}return{head:t,arrays:n,body:r}}const Q={todo:[`doing`,`blocked`,`dropped`],doing:[`blocked`,`done`,`dropped`],blocked:[`todo`,`doing`,`dropped`],done:[`todo`,`dropped`],dropped:[`todo`]};function pe(e,t){let n=Q[e];return n===void 0?{code:`INVALID_TRANSITION`,message:`未知状态:${e}`}:n.includes(t)?null:{code:`INVALID_TRANSITION`,message:`非法转移:${e} → ${t}(合法后继:${n.join(` / `)})`}}function $(e){return e===`done`||e===`dropped`}function me(e,t,n){let r=new Set(e.filter(e=>$(e.status)).map(e=>e.id)),i=new Set(n.filter(e=>e.ruling.status!==`approved`&&e.at!==`workflow`).map(e=>e.at));return{items:e.map(e=>{let n=X(e.id,t,r);return{id:e.id,status:e.status,depsMet:n,blockedOnPrerequisite:e.status===`todo`&&!n,canStart:e.status===`todo`&&n&&!i.has(e.id)}}),pendingRulings:n.filter(e=>e.ruling.status===`pending`||e.ruling.status===`escalated`).map(e=>({key:`${e.at}:${e.kind}`,at:e.at,kind:e.kind,note:e.note,rulingStatus:e.ruling.status}))}}function he(e,t){let n=Math.min(t??20,100);return{offset:(Math.max(e??1,1)-1)*n,limit:n}}function ge(e,t){return Math.ceil(e/t)}function _e(e){return new Date(e).toISOString()}const ve=Symbol(`FEED_EVENT_PORT_TOKEN`),ye=Symbol(`ACTION_EXECUTOR_PORT_TOKEN`);export{ye as ACTION_EXECUTOR_PORT_TOKEN,_ as ACTION_TYPES,y as ALERT_TYPES,Q as ALLOWED_STATUS_TRANSITIONS,o as DEFAULT_PAGE_SIZE,s as FEED_EVENT_NAMES,ve as FEED_EVENT_PORT_TOKEN,z as INSTANCE_STATUSES,ne as MAX_PAGE_SIZE,x as METRIC_TYPES,b as NODE_EXECUTION_STATUSES,S as NODE_TYPES,p as TRIGGER_TYPES,e as WORKFLOW_REF_PATTERN,M as WORK_ITEM_STATUSES,l as WorkflowDocFrontmatterSchema,H as actionContextSchema,I as actionResultSchema,B as actionSchema,j as actionTypeSchema,R as alertDtoSchema,F as alertTypeDtoSchema,J as areAllDependenciesMet,A as auditLogDtoSchema,pe as checkStatusTransition,c as createDefinitionInputSchema,W as createInstanceInputSchema,T as createTriggerInputSchema,m as definitionDtoSchema,Y as dependenciesMet,me as deriveWorkflowView,ie as detectCycle,ae as detectCycles,oe as downstreamOf,w as feedApplyTagsActionSchema,P as feedEventFilterSchema,re as feedEventNameSchema,D as feedEventPayloadSchema,O as feedEventTriggerSchema,L as feedSummarizeActionSchema,_e as formatDate,he as getPagination,ge as getTotalPages,g as instanceDtoSchema,i as instanceQueryParamsSchema,r as instanceStatusDtoSchema,V as llmCompleteActionSchema,k as metricTypeDtoSchema,C as monitoringDashboardDtoSchema,d as nodeExecutionDtoSchema,N as nodeExecutionStatusDtoSchema,se as nodesOf,fe as parseDeclaration,u as parseEdgeLine,f as parseGateLine,a as parseGateRuling,te as parseItemLine,U as performanceMetricDtoSchema,q as stateTransitionDtoSchema,ce as topologicalLevels,le as topologicalSort,K as trendPointDtoSchema,G as triggerDtoSchema,h as triggerTypeDtoSchema,t as updateDefinitionInputSchema,n as updateTriggerInputSchema,ue as validateEdges,E as webhookSendActionSchema,v as workflowEdgeDtoSchema,ee as workflowNodeDtoSchema};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-workflow/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,6 +31,7 @@
31
31
  "clean": "lzi-dev-cli clean"
32
32
  },
33
33
  "dependencies": {
34
+ "@longzai-intelligence-dag/core": "^0.0.2",
34
35
  "@longzai-intelligence-shared-kernel/core": "^0.1.4",
35
36
  "zod": "^4.4.3"
36
37
  },
@@ -1,95 +1,16 @@
1
1
  /**
2
- * DAG 机件(环检测 + 拓扑分层 + 依赖满足判定)
3
- *
4
- * 共享基础(设计对齐 scheduler workflow 域已验证机件;真源归本包,禁止再镜像)。
2
+ * DAG 机件转发出口(真源 = @longzai-intelligence-dag/core 基础能力域;消费方零改动兼容)
5
3
  */
6
-
7
- /**
8
- * 依赖边(from 完成后 to 可启)
9
- */
10
- export type DependencyEdge = { readonly from: string; readonly to: string };
11
-
12
- /**
13
- * 环检测(DFS 三色标记;返回首个环路径,无环为 null)
14
- *
15
- * @param edges - 依赖边集合
16
- */
17
- export function detectCycle(edges: readonly DependencyEdge[]): readonly string[] | null {
18
- /**
19
- * 邻接表
20
- */
21
- const adjacency = new Map<string, string[]>();
22
- for (const edge of edges) {
23
- adjacency.set(edge.from, [...(adjacency.get(edge.from) ?? []), edge.to]);
24
- }
25
-
26
- /**
27
- * 节点访问状态(0=未访问 1=在栈 2=完成)
28
- */
29
- const state = new Map<string, 0 | 1 | 2>();
30
-
31
- /**
32
- * 当前 DFS 路径
33
- */
34
- const path: string[] = [];
35
-
36
- /**
37
- * 单节点深搜(返回环路径或 null)
38
- */
39
- const visit = (node: string): readonly string[] | null => {
40
- /**
41
- * 当前节点状态
42
- */
43
- const current = state.get(node) ?? 0;
44
- if (current === 1) {
45
- /**
46
- * 环路径:当前路径中该节点之后的部分 + 首尾相接
47
- */
48
- const start = path.indexOf(node);
49
- return [...path.slice(start), node];
50
- }
51
- if (current === 2) {
52
- return null;
53
- }
54
- state.set(node, 1);
55
- path.push(node);
56
- for (const next of adjacency.get(node) ?? []) {
57
- /**
58
- * 后继环路径
59
- */
60
- const cycle = visit(next);
61
- if (cycle !== null) {
62
- return cycle;
63
- }
64
- }
65
- path.pop();
66
- state.set(node, 2);
67
- return null;
68
- };
69
-
70
- /**
71
- * 全部节点(确定性排序)
72
- */
73
- const nodes = [...new Set(edges.flatMap((edge) => [edge.from, edge.to]))].sort((left, right) => (left < right ? -1 : 1));
74
- for (const node of nodes) {
75
- /**
76
- * 各节点环检测
77
- */
78
- const cycle = visit(node);
79
- if (cycle !== null) {
80
- return cycle;
81
- }
82
- }
83
- return null;
84
- }
85
-
86
- /**
87
- * 依赖满足判定(全部前置达完成/验收才算满足;无前置视为满足)
88
- *
89
- * @param node - 目标工作项 id
90
- * @param edges - 依赖边集合
91
- * @param settled - 已闭环(完成/验收)的工作项集合
92
- */
93
- export function dependenciesMet(node: string, edges: readonly DependencyEdge[], settled: ReadonlySet<string>): boolean {
94
- return edges.filter((edge) => edge.to === node).every((edge) => settled.has(edge.from));
95
- }
4
+ export {
5
+ type DependencyEdge,
6
+ detectCycle,
7
+ detectCycles,
8
+ dependenciesMet,
9
+ areAllDependenciesMet,
10
+ downstreamOf,
11
+ nodesOf,
12
+ topologicalLevels,
13
+ topologicalSort,
14
+ validateEdges,
15
+ type EdgeIssue,
16
+ } from '@longzai-intelligence-dag/core';
@@ -15,5 +15,5 @@ export function formatDate(date: string | Date): string {
15
15
  }
16
16
 
17
17
  export * from './declaration-frontmatter.utils';
18
- export * from './dag.utils';
19
18
  export * from './work-item-rules.utils';
19
+ export * from './dag.utils';
@@ -4,6 +4,8 @@
4
4
  * 判定器契约:只判不动(对齐家族 verify 模式);执行状态归声明档由属主维护,
5
5
  * 本模块不做任何状态写入,仅依据声明现状派生视图与转移合法性。
6
6
  */
7
+ import { dependenciesMet } from '@longzai-intelligence-dag/core';
8
+
7
9
  import type { WorkflowEdge, WorkflowGate, WorkflowItem, WorkItemStatus } from '../schemas/workflow-doc.schema';
8
10
 
9
11
  /**
@@ -164,9 +166,9 @@ export function deriveWorkflowView(
164
166
  */
165
167
  const views: WorkItemView[] = items.map((item) => {
166
168
  /**
167
- * 依赖满足判定(全部前置闭环)
169
+ * 依赖满足判定(DAG 基础能力域机件,闭环定义由本域注入)
168
170
  */
169
- const depsMet = edges.filter((edge) => edge.to === item.id).every((edge) => settled.has(edge.from));
171
+ const depsMet = dependenciesMet(item.id, edges, settled);
170
172
 
171
173
  return {
172
174
  id: item.id,