yaml-flow 2.8.0 → 3.1.0
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/README.md +189 -3
- package/dist/{constants-BEbO2_OK.d.ts → constants-B2zqu10b.d.ts} +32 -52
- package/dist/{constants-BNjeIlZ8.d.cts → constants-DJZU1pwJ.d.cts} +32 -52
- package/dist/continuous-event-graph/index.cjs +1388 -52
- package/dist/continuous-event-graph/index.cjs.map +1 -1
- package/dist/continuous-event-graph/index.d.cts +643 -5
- package/dist/continuous-event-graph/index.d.ts +643 -5
- package/dist/continuous-event-graph/index.js +1374 -53
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/event-graph/index.cjs +6817 -53
- package/dist/event-graph/index.cjs.map +1 -1
- package/dist/event-graph/index.d.cts +15 -6
- package/dist/event-graph/index.d.ts +15 -6
- package/dist/event-graph/index.js +6808 -51
- package/dist/event-graph/index.js.map +1 -1
- package/dist/index.cjs +1827 -441
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +1808 -440
- package/dist/index.js.map +1 -1
- package/dist/inference/index.cjs +46 -13
- package/dist/inference/index.cjs.map +1 -1
- package/dist/inference/index.d.cts +2 -2
- package/dist/inference/index.d.ts +2 -2
- package/dist/inference/index.js +46 -13
- package/dist/inference/index.js.map +1 -1
- package/dist/step-machine/index.cjs +6600 -0
- package/dist/step-machine/index.cjs.map +1 -1
- package/dist/step-machine/index.d.cts +26 -1
- package/dist/step-machine/index.d.ts +26 -1
- package/dist/step-machine/index.js +6596 -1
- package/dist/step-machine/index.js.map +1 -1
- package/dist/{types-C2lOwquM.d.cts → types-BwvgvlOO.d.cts} +2 -2
- package/dist/{types-mS_pPftm.d.ts → types-ClRA8hzC.d.ts} +2 -2
- package/dist/{types-DAI_a2as.d.ts → types-DEj7OakX.d.cts} +29 -10
- package/dist/{types-DAI_a2as.d.cts → types-DEj7OakX.d.ts} +29 -10
- package/dist/validate-DEZ2Ymdb.d.ts +53 -0
- package/dist/validate-DqKTZg_o.d.cts +53 -0
- package/package.json +1 -1
- package/schema/event-graph.schema.json +254 -0
package/README.md
CHANGED
|
@@ -280,7 +280,9 @@ That's the entire integration. ~30 lines. The engine is pure; your loop owns the
|
|
|
280
280
|
| Conditional routing | `on: { positive: [pos-result], negative: [neg-result] }` | Different outputs based on task result |
|
|
281
281
|
| Failure tokens | `on_failure: [data-unavailable]` | Inject tokens on failure so downstream alternatives can activate |
|
|
282
282
|
| Retry | `retry: { max_attempts: 3 }` | Auto-retry on failure (task resets to not-started) |
|
|
283
|
-
|
|
|
283
|
+
| Refresh strategy | `refreshStrategy: 'data-changed'` (default) | When a completed task should re-run: `data-changed`, `epoch-changed`, `time-based`, `manual`, `once` |
|
|
284
|
+
| Max executions | `maxExecutions: 5` | Cap how many times a task can execute |
|
|
285
|
+
| Refresh interval | `refreshInterval: 300` | Seconds between re-runs (for `time-based` strategy) |
|
|
284
286
|
| Circuit breaker | `circuit_breaker: { max_executions: 10, on_break: [stop-token] }` | Inject tokens after N executions |
|
|
285
287
|
| External events | `apply(state, { type: 'inject-tokens', tokens: ['user-approved'] })` | Unblock tasks waiting on external input |
|
|
286
288
|
| Dynamic tasks | `apply(state, { type: 'task-creation', taskName: 'new', taskConfig: {...} })` | Add tasks at runtime |
|
|
@@ -352,11 +354,55 @@ tasks:
|
|
|
352
354
|
revise:
|
|
353
355
|
requires: [needs-revision]
|
|
354
356
|
provides: [draft-answer]
|
|
355
|
-
|
|
357
|
+
refreshStrategy: epoch-changed
|
|
358
|
+
maxExecutions: 3
|
|
356
359
|
```
|
|
357
360
|
|
|
358
361
|
The three searches run in parallel. `synthesize` waits for all three. `verify` can produce different token sets depending on its result. If rejected, `revise` picks up and feeds back into `verify` (up to 3 times). If verify itself fails, `verification-skipped` unblocks any downstream task waiting on it.
|
|
359
362
|
|
|
363
|
+
### Refresh Strategies
|
|
364
|
+
|
|
365
|
+
| Strategy | Behavior |
|
|
366
|
+
|---|---|
|
|
367
|
+
| `data-changed` (default) | Re-run when upstream output content changes (tracked via `dataHash`) |
|
|
368
|
+
| `epoch-changed` | Re-run when upstream task execution count increases (classic "inputs refreshed") |
|
|
369
|
+
| `time-based` | Re-run after `refreshInterval` seconds since last completion |
|
|
370
|
+
| `manual` | Never auto-eligible; only via external `inject-tokens` or explicit push |
|
|
371
|
+
| `once` | Run once, never re-run (classic one-shot task) |
|
|
372
|
+
|
|
373
|
+
Set a board-level default in `settings.refreshStrategy`, then override per-task:
|
|
374
|
+
|
|
375
|
+
```yaml
|
|
376
|
+
settings:
|
|
377
|
+
completion: manual
|
|
378
|
+
refreshStrategy: epoch-changed # board default
|
|
379
|
+
tasks:
|
|
380
|
+
fetch_prices:
|
|
381
|
+
provides: [price-data]
|
|
382
|
+
refreshStrategy: time-based # override: poll every 60s
|
|
383
|
+
refreshInterval: 60
|
|
384
|
+
compute:
|
|
385
|
+
requires: [price-data]
|
|
386
|
+
provides: [indicators]
|
|
387
|
+
# inherits epoch-changed from settings
|
|
388
|
+
alert:
|
|
389
|
+
requires: [indicators]
|
|
390
|
+
provides: [alert-sent]
|
|
391
|
+
refreshStrategy: data-changed # override: only if indicators actually changed
|
|
392
|
+
maxExecutions: 10 # safety cap
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Handlers can return a `dataHash` with completion events to enable content-aware freshness:
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
apply(state, {
|
|
399
|
+
type: 'task-completed',
|
|
400
|
+
taskName: 'fetch_prices',
|
|
401
|
+
dataHash: crypto.createHash('md5').update(JSON.stringify(data)).digest('hex'),
|
|
402
|
+
timestamp: new Date().toISOString(),
|
|
403
|
+
}, graph);
|
|
404
|
+
```
|
|
405
|
+
|
|
360
406
|
### Pattern: Order Processing Pipeline (Step Machine)
|
|
361
407
|
|
|
362
408
|
```yaml
|
|
@@ -839,6 +885,37 @@ Use `validateGraphConfig()` for structural checks (JSON shape) and `validateGrap
|
|
|
839
885
|
|
|
840
886
|
---
|
|
841
887
|
|
|
888
|
+
## JSON Schema Validation
|
|
889
|
+
|
|
890
|
+
Full structural validation using AJV against the JSON Schema definitions. Catches malformed configs before they reach the engine.
|
|
891
|
+
|
|
892
|
+
```typescript
|
|
893
|
+
import { validateGraphSchema } from 'yaml-flow/event-graph';
|
|
894
|
+
import { validateFlowSchema } from 'yaml-flow/step-machine';
|
|
895
|
+
import { validateLiveCardSchema } from 'yaml-flow/card-compute';
|
|
896
|
+
|
|
897
|
+
// Event graph
|
|
898
|
+
const r1 = validateGraphSchema(config);
|
|
899
|
+
r1.ok; // true | false
|
|
900
|
+
r1.errors; // AJV error objects (when invalid)
|
|
901
|
+
|
|
902
|
+
// Step machine
|
|
903
|
+
const r2 = validateFlowSchema(config);
|
|
904
|
+
|
|
905
|
+
// Live cards
|
|
906
|
+
const r3 = validateLiveCardSchema(config);
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
| Validator | Schema file | What it checks |
|
|
910
|
+
|---|---|---|
|
|
911
|
+
| `validateGraphSchema` | `schema/event-graph.schema.json` | Tasks, settings, refreshStrategy, retry, circuit_breaker, inference hints |
|
|
912
|
+
| `validateFlowSchema` | `schema/flow.schema.json` | Steps, transitions, retry, terminal states |
|
|
913
|
+
| `validateLiveCardSchema` | `schema/live-cards.schema.json` | Cards, sources, elements, compute, data bindings |
|
|
914
|
+
|
|
915
|
+
All validators are synchronous, pure functions. They return `{ ok: boolean, errors?: ErrorObject[] }`.
|
|
916
|
+
|
|
917
|
+
---
|
|
918
|
+
|
|
842
919
|
## Continuous Event Graph
|
|
843
920
|
|
|
844
921
|
A **long-lived, evolving** event-graph where both the graph config and execution state mutate over time. Ideal for dashboards, monitoring systems, and any scenario where the workflow has no fixed endpoint.
|
|
@@ -980,6 +1057,100 @@ const restored = restore(data); // → LiveGraph (validates shape)
|
|
|
980
1057
|
| `getUnreachableNodes(live)` | Nodes that can never become eligible |
|
|
981
1058
|
| `snapshot(live)` | Serialize to a JSON-safe snapshot |
|
|
982
1059
|
| `restore(data)` | Restore a LiveGraph from a snapshot |
|
|
1060
|
+
| `applyEvents(live, events)` | Apply multiple events atomically (batch reduce) |
|
|
1061
|
+
|
|
1062
|
+
### Reactive Graph (Push-based Execution)
|
|
1063
|
+
|
|
1064
|
+
The reactive layer adds **self-sustaining execution** on top of the pure LiveGraph. Register handlers, push one event, and the graph drives itself to completion. No daemon, no polling — each handler callback triggers the next wave.
|
|
1065
|
+
|
|
1066
|
+
```typescript
|
|
1067
|
+
import { createReactiveGraph, MemoryJournal } from 'yaml-flow/continuous-event-graph';
|
|
1068
|
+
|
|
1069
|
+
// 1. Create with handlers
|
|
1070
|
+
const rg = createReactiveGraph(config, {
|
|
1071
|
+
handlers: {
|
|
1072
|
+
fetch: async ({ callbackToken }) => { /* ... */ return 'task-initiated'; },
|
|
1073
|
+
transform: async ({ callbackToken }) => { /* ... */ return 'task-initiated'; },
|
|
1074
|
+
notify: async ({ callbackToken }) => { /* ... */ return 'task-initiated'; },
|
|
1075
|
+
},
|
|
1076
|
+
onDrain: (events, live, schedule) => console.log(`${events.length} events, ${schedule.eligible.length} eligible`),
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
// 2. Push one event — the chain sustains itself
|
|
1080
|
+
rg.push({ type: 'inject-tokens', tokens: [], timestamp: new Date().toISOString() });
|
|
1081
|
+
// fetch runs -> completes -> transform becomes eligible -> runs -> notify -> done
|
|
1082
|
+
|
|
1083
|
+
// 3. Add nodes at runtime
|
|
1084
|
+
rg.addNode('alert', { requires: ['anomaly'], provides: ['alerted'], taskHandlers: ['alert'] });
|
|
1085
|
+
rg.registerHandler('alert', async ({ callbackToken }) => {
|
|
1086
|
+
// ... do work, then resolve the callback
|
|
1087
|
+
rg.resolveCallback(callbackToken, { alerted: true });
|
|
1088
|
+
return 'task-initiated';
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
// 4. Dynamic wiring mutations
|
|
1092
|
+
rg.addRequires('alert', ['sentiment']); // add a new dependency
|
|
1093
|
+
rg.removeRequires('alert', ['sentiment']); // detach it
|
|
1094
|
+
rg.addProvides('fetch', ['market-data']); // produce a new token
|
|
1095
|
+
rg.removeProvides('fetch', ['market-data']); // stop producing it
|
|
1096
|
+
|
|
1097
|
+
// 5. Batch events + selective retrigger
|
|
1098
|
+
rg.pushAll([event1, event2]); // atomic multi-event push
|
|
1099
|
+
rg.retrigger('fetch'); // re-run a single task
|
|
1100
|
+
rg.retriggerAll(['fetch', 'transform']); // re-run multiple tasks
|
|
1101
|
+
|
|
1102
|
+
// 6. Read state
|
|
1103
|
+
rg.getState(); // LiveGraph snapshot
|
|
1104
|
+
rg.getSchedule(); // current ScheduleResult
|
|
1105
|
+
|
|
1106
|
+
// 7. Cleanup
|
|
1107
|
+
rg.dispose();
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
**How it works internally:**
|
|
1111
|
+
|
|
1112
|
+
```
|
|
1113
|
+
push(event)
|
|
1114
|
+
-> applyEvent (pure state change)
|
|
1115
|
+
-> schedule (what's eligible?)
|
|
1116
|
+
-> dispatch handlers (fire-and-forget)
|
|
1117
|
+
-> handler completes -> appends to journal
|
|
1118
|
+
-> drain journal -> applyEvents (batch) -> schedule -> dispatch
|
|
1119
|
+
-> repeat until nothing is eligible
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
The journal serializes concurrent callbacks — multiple handlers complete simultaneously, their events batch into a single `applyEvents()` call. No race conditions.
|
|
1123
|
+
|
|
1124
|
+
**Handler model:** Handlers are initiators. They receive a `callbackToken` and return `'task-initiated'` or `'task-initiate-failure'`. When work completes, call `rg.resolveCallback(token, data, errors?)` to push the result back through the engine.
|
|
1125
|
+
|
|
1126
|
+
**ReactiveGraph API:**
|
|
1127
|
+
|
|
1128
|
+
| Method | Description |
|
|
1129
|
+
|---|---|
|
|
1130
|
+
| `push(event)` | Push a single event into the engine |
|
|
1131
|
+
| `pushAll(events)` | Push multiple events atomically |
|
|
1132
|
+
| `resolveCallback(token, data, errors?)` | Resolve a handler's callback token |
|
|
1133
|
+
| `addNode(name, config)` | Add a task to the live graph |
|
|
1134
|
+
| `removeNode(name)` | Remove a task from the live graph |
|
|
1135
|
+
| `addRequires(name, tokens)` | Add require tokens to a task |
|
|
1136
|
+
| `removeRequires(name, tokens)` | Remove require tokens from a task |
|
|
1137
|
+
| `addProvides(name, tokens)` | Add provide tokens to a task |
|
|
1138
|
+
| `removeProvides(name, tokens)` | Remove provide tokens from a task |
|
|
1139
|
+
| `registerHandler(name, fn)` | Register a named handler |
|
|
1140
|
+
| `unregisterHandler(name)` | Unregister a handler |
|
|
1141
|
+
| `retrigger(name)` | Reset and re-run a single task |
|
|
1142
|
+
| `retriggerAll(names)` | Reset and re-run multiple tasks |
|
|
1143
|
+
| `getState()` | Current LiveGraph snapshot |
|
|
1144
|
+
| `getSchedule()` | Current ScheduleResult |
|
|
1145
|
+
| `dispose()` | Shut down the reactive graph |
|
|
1146
|
+
|
|
1147
|
+
**Options:**
|
|
1148
|
+
|
|
1149
|
+
| Option | Default | Description |
|
|
1150
|
+
|---|---|---|
|
|
1151
|
+
| `handlers` | (required) | `Record<string, TaskHandlerFn>` |
|
|
1152
|
+
| `journal` | `MemoryJournal` | Event log adapter (`MemoryJournal` or `FileJournal`) |
|
|
1153
|
+
| `onDrain` | — | Called after each drain cycle (observability) |
|
|
983
1154
|
|
|
984
1155
|
---
|
|
985
1156
|
|
|
@@ -1234,15 +1405,25 @@ import { resolveVariables, resolveConfigTemplates } from 'yaml-flow/config';
|
|
|
1234
1405
|
|
|
1235
1406
|
// Continuous Event Graph (long-lived evolving workflows)
|
|
1236
1407
|
import {
|
|
1237
|
-
createLiveGraph, applyEvent, addNode, removeNode,
|
|
1408
|
+
createLiveGraph, applyEvent, applyEvents, addNode, removeNode,
|
|
1238
1409
|
addRequires, removeRequires, addProvides, removeProvides,
|
|
1239
1410
|
injectTokens, drainTokens, schedule, inspect,
|
|
1240
1411
|
resetNode, disableNode, enableNode, getNode,
|
|
1241
1412
|
snapshot, restore,
|
|
1242
1413
|
getUnreachableTokens, getUnreachableNodes,
|
|
1243
1414
|
getUpstream, getDownstream,
|
|
1415
|
+
createReactiveGraph, MemoryJournal, FileJournal,
|
|
1416
|
+
} from 'yaml-flow/continuous-event-graph';
|
|
1417
|
+
import type {
|
|
1418
|
+
ReactiveGraph, TaskHandler, TaskHandlerContext, TaskHandlerResult,
|
|
1419
|
+
DispatchEntry, Journal,
|
|
1244
1420
|
} from 'yaml-flow/continuous-event-graph';
|
|
1245
1421
|
|
|
1422
|
+
// JSON Schema Validators
|
|
1423
|
+
import { validateGraphSchema } from 'yaml-flow/event-graph';
|
|
1424
|
+
import { validateFlowSchema } from 'yaml-flow/step-machine';
|
|
1425
|
+
import { validateLiveCardSchema } from 'yaml-flow/card-compute';
|
|
1426
|
+
|
|
1246
1427
|
// LLM Inference (AI-assisted completion detection)
|
|
1247
1428
|
import {
|
|
1248
1429
|
buildInferencePrompt, inferCompletions, applyInferences, inferAndApply,
|
|
@@ -1321,6 +1502,11 @@ See the [examples/](./examples) directory:
|
|
|
1321
1502
|
| [URL Pipeline](./examples/graph-of-graphs/url-processing-pipeline.ts) | Graph-of-Graphs | Outer event-graph → batch × inner event-graph per item |
|
|
1322
1503
|
| [Multi-Stage ETL](./examples/graph-of-graphs/multi-stage-etl.ts) | Graph-of-Graphs | Mixed modes: event-graph outer → step-machine + event-graph subs |
|
|
1323
1504
|
| [Stock Dashboard](./examples/continuous-event-graph/stock-dashboard.ts) | Continuous Event Graph | Runtime mutations, token drain, upstream/downstream, snapshot |
|
|
1505
|
+
| [Reactive Pipeline](./examples/continuous-event-graph/reactive-pipeline.ts) | Reactive Graph | Self-driving ETL — push once, 4 tasks complete automatically |
|
|
1506
|
+
| [Reactive Monitoring](./examples/continuous-event-graph/reactive-monitoring.ts) | Reactive Graph | Conditional routing, on_failure escalation, runtime addNode |
|
|
1507
|
+
| [Live Portfolio Dashboard](./examples/continuous-event-graph/live-portfolio-dashboard.ts) | Reactive Graph + Live Cards | 15+ cards, disk roundtrip, addRequires/removeRequires, addProvides/removeProvides, pushAll, retriggerAll |
|
|
1508
|
+
| [Executor Pipeline](./examples/event-graph/executor-pipeline.ts) | Event Graph (library) | You-drive-the-loop ETL with random async delays |
|
|
1509
|
+
| [Executor Diamond](./examples/event-graph/executor-diamond.ts) | Event Graph (library) | Parallel fan-out/fan-in diamond DAG with async executors |
|
|
1324
1510
|
| [Azure Deployment](./examples/inference/azure-deployment.ts) | Inference | LLM analyzes deployment logs, auto-completes checkpoints |
|
|
1325
1511
|
| [Data Pipeline](./examples/inference/data-pipeline.ts) | Inference | Iterative inference — evidence arrives in waves |
|
|
1326
1512
|
| [Pluggable Adapters](./examples/inference/pluggable-adapters.ts) | Inference | OpenAI, Anthropic, Azure, CLI, HTTP adapter factories |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GraphConfig, c as ExecutionState, S as SchedulerResult,
|
|
1
|
+
import { G as GraphConfig, c as ExecutionState, S as SchedulerResult, f as GraphEvent, T as TaskConfig, e as GraphEngineStore, R as RefreshStrategy, h as StuckDetection, C as CompletionStrategy, a as ConflictStrategy, b as ExecutionMode, d as ExecutionStatus, m as TaskStatus } from './types-DEj7OakX.js';
|
|
2
2
|
import { e as StepFlowConfig } from './types-FZ_eyErS.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -15,7 +15,7 @@ import { e as StepFlowConfig } from './types-FZ_eyErS.js';
|
|
|
15
15
|
declare function next(graph: GraphConfig, state: ExecutionState): SchedulerResult;
|
|
16
16
|
/**
|
|
17
17
|
* Get candidate tasks whose dependencies are all met.
|
|
18
|
-
*
|
|
18
|
+
* Uses refreshStrategy to determine re-execution eligibility.
|
|
19
19
|
* Pure function.
|
|
20
20
|
*/
|
|
21
21
|
declare function getCandidateTasks(graph: GraphConfig, state: ExecutionState): string[];
|
|
@@ -54,17 +54,22 @@ declare function getRequires(task: TaskConfig | undefined): string[];
|
|
|
54
54
|
declare function getAllTasks(graph: GraphConfig): Record<string, TaskConfig>;
|
|
55
55
|
declare function getTask(graph: GraphConfig, taskName: string): TaskConfig | undefined;
|
|
56
56
|
declare function hasTask(graph: GraphConfig, taskName: string): boolean;
|
|
57
|
-
declare function isNonActiveTask(taskState:
|
|
58
|
-
declare function isTaskCompleted(taskState:
|
|
59
|
-
declare function isTaskRunning(taskState:
|
|
60
|
-
declare function
|
|
61
|
-
|
|
57
|
+
declare function isNonActiveTask(taskState: GraphEngineStore | undefined): boolean;
|
|
58
|
+
declare function isTaskCompleted(taskState: GraphEngineStore | undefined): boolean;
|
|
59
|
+
declare function isTaskRunning(taskState: GraphEngineStore | undefined): boolean;
|
|
60
|
+
declare function getRefreshStrategy(taskConfig: TaskConfig, graphSettings?: {
|
|
61
|
+
refreshStrategy?: RefreshStrategy;
|
|
62
|
+
}): RefreshStrategy;
|
|
63
|
+
declare function isRerunnable(taskConfig: TaskConfig, graphSettings?: {
|
|
64
|
+
refreshStrategy?: RefreshStrategy;
|
|
65
|
+
}): boolean;
|
|
66
|
+
declare function getMaxExecutions(taskConfig: TaskConfig): number | undefined;
|
|
62
67
|
/**
|
|
63
68
|
* Dynamically compute available outputs from all completed tasks.
|
|
64
|
-
*
|
|
69
|
+
* Tasks with strategies other than 'once' may have completed and reset.
|
|
65
70
|
* Pure function.
|
|
66
71
|
*/
|
|
67
|
-
declare function computeAvailableOutputs(graph: GraphConfig, taskStates: Record<string,
|
|
72
|
+
declare function computeAvailableOutputs(graph: GraphConfig, taskStates: Record<string, GraphEngineStore>): string[];
|
|
68
73
|
/**
|
|
69
74
|
* Group candidate tasks by the outputs they provide.
|
|
70
75
|
* Used to detect conflicts (multiple tasks providing the same output).
|
|
@@ -85,7 +90,7 @@ declare function addDynamicTask(graph: GraphConfig, taskName: string, taskConfig
|
|
|
85
90
|
/**
|
|
86
91
|
* Create default task state for a new task.
|
|
87
92
|
*/
|
|
88
|
-
declare function
|
|
93
|
+
declare function createDefaultGraphEngineStore(): GraphEngineStore;
|
|
89
94
|
/**
|
|
90
95
|
* Create the initial execution state for a graph.
|
|
91
96
|
*/
|
|
@@ -254,54 +259,29 @@ declare function exportGraphConfig(config: GraphConfig, options?: ExportOptions)
|
|
|
254
259
|
declare function exportGraphConfigToFile(config: GraphConfig, filePath: string, options?: ExportOptions): Promise<void>;
|
|
255
260
|
|
|
256
261
|
/**
|
|
257
|
-
*
|
|
262
|
+
* schema-validator — Full JSON Schema validation for EventGraph configs.
|
|
258
263
|
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* - Dangling requires (tokens no task produces)
|
|
262
|
-
* - Circular dependencies
|
|
263
|
-
* - Provide conflicts (multiple tasks producing same token)
|
|
264
|
-
* - Unreachable goal tokens
|
|
265
|
-
* - Dead-end tasks (no provides)
|
|
266
|
-
* - Self-dependencies
|
|
267
|
-
* - Orphaned tasks (disconnected from the graph)
|
|
264
|
+
* Uses AJV to validate against the published event-graph.schema.json.
|
|
265
|
+
* For a lightweight sync check without AJV, use `validateGraphConfig()` instead.
|
|
268
266
|
*
|
|
269
|
-
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* import { validateGraphSchema } from 'yaml-flow/event-graph';
|
|
270
|
+
*
|
|
271
|
+
* const result = validateGraphSchema(config);
|
|
272
|
+
* if (!result.ok) console.error(result.errors);
|
|
273
|
+
* ```
|
|
270
274
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
/** Severity: error = will break execution, warning = may cause problems, info = notable */
|
|
275
|
-
severity: IssueSeverity;
|
|
276
|
-
/** Machine-readable issue code */
|
|
277
|
-
code: string;
|
|
278
|
-
/** Human-readable description */
|
|
279
|
-
message: string;
|
|
280
|
-
/** Affected task names (if applicable) */
|
|
281
|
-
tasks?: string[];
|
|
282
|
-
/** Affected tokens (if applicable) */
|
|
283
|
-
tokens?: string[];
|
|
284
|
-
}
|
|
285
|
-
interface GraphValidationResult {
|
|
286
|
-
/** true if no errors (warnings/info are allowed) */
|
|
287
|
-
valid: boolean;
|
|
288
|
-
/** All issues found */
|
|
289
|
-
issues: GraphIssue[];
|
|
290
|
-
/** Just the errors */
|
|
291
|
-
errors: GraphIssue[];
|
|
292
|
-
/** Just the warnings */
|
|
293
|
-
warnings: GraphIssue[];
|
|
275
|
+
interface SchemaValidationResult {
|
|
276
|
+
ok: boolean;
|
|
277
|
+
errors: string[];
|
|
294
278
|
}
|
|
295
279
|
/**
|
|
296
|
-
* Validate
|
|
297
|
-
*
|
|
298
|
-
* Checks for logical issues that would cause execution failures, stuck states,
|
|
299
|
-
* or unexpected behavior. Does NOT check JSON structure (use validateGraphConfig for that).
|
|
280
|
+
* Validate an event-graph config against the full event-graph.schema.json (draft-07).
|
|
300
281
|
*
|
|
301
|
-
*
|
|
302
|
-
* @returns Validation result with categorized issues
|
|
282
|
+
* Requires `ajv` and `ajv-formats` to be installed.
|
|
303
283
|
*/
|
|
304
|
-
declare function
|
|
284
|
+
declare function validateGraphSchema(config: unknown): SchemaValidationResult;
|
|
305
285
|
|
|
306
286
|
/**
|
|
307
287
|
* Event Graph — Constants
|
|
@@ -319,4 +299,4 @@ declare const DEFAULTS: {
|
|
|
319
299
|
readonly MAX_ITERATIONS: 1000;
|
|
320
300
|
};
|
|
321
301
|
|
|
322
|
-
export {
|
|
302
|
+
export { isRerunnable as A, isTaskCompleted as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, isTaskRunning as F, loadGraphConfig as G, next as H, planExecution as I, validateGraphConfig as J, validateGraphSchema as K, addKeyToProvides as L, type MermaidOptions as M, addKeyToRequires as N, groupTasksByProvides as O, hasOutputConflict as P, removeKeyFromProvides as Q, removeKeyFromRequires as R, TASK_STATUS as T, CONFLICT_STRATEGIES as a, type CompletionResult as b, EXECUTION_STATUS as c, type ExecutionPlan as d, type ExportOptions as e, addDynamicTask as f, apply as g, applyAll as h, computeAvailableOutputs as i, createDefaultGraphEngineStore as j, createInitialExecutionState as k, detectStuckState as l, exportGraphConfig as m, exportGraphConfigToFile as n, flowToMermaid as o, getAllTasks as p, getCandidateTasks as q, getMaxExecutions as r, getProvides as s, getRefreshStrategy as t, getRequires as u, getTask as v, graphToMermaid as w, hasTask as x, isExecutionComplete as y, isNonActiveTask as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GraphConfig, c as ExecutionState, S as SchedulerResult,
|
|
1
|
+
import { G as GraphConfig, c as ExecutionState, S as SchedulerResult, f as GraphEvent, T as TaskConfig, e as GraphEngineStore, R as RefreshStrategy, h as StuckDetection, C as CompletionStrategy, a as ConflictStrategy, b as ExecutionMode, d as ExecutionStatus, m as TaskStatus } from './types-DEj7OakX.cjs';
|
|
2
2
|
import { e as StepFlowConfig } from './types-FZ_eyErS.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -15,7 +15,7 @@ import { e as StepFlowConfig } from './types-FZ_eyErS.cjs';
|
|
|
15
15
|
declare function next(graph: GraphConfig, state: ExecutionState): SchedulerResult;
|
|
16
16
|
/**
|
|
17
17
|
* Get candidate tasks whose dependencies are all met.
|
|
18
|
-
*
|
|
18
|
+
* Uses refreshStrategy to determine re-execution eligibility.
|
|
19
19
|
* Pure function.
|
|
20
20
|
*/
|
|
21
21
|
declare function getCandidateTasks(graph: GraphConfig, state: ExecutionState): string[];
|
|
@@ -54,17 +54,22 @@ declare function getRequires(task: TaskConfig | undefined): string[];
|
|
|
54
54
|
declare function getAllTasks(graph: GraphConfig): Record<string, TaskConfig>;
|
|
55
55
|
declare function getTask(graph: GraphConfig, taskName: string): TaskConfig | undefined;
|
|
56
56
|
declare function hasTask(graph: GraphConfig, taskName: string): boolean;
|
|
57
|
-
declare function isNonActiveTask(taskState:
|
|
58
|
-
declare function isTaskCompleted(taskState:
|
|
59
|
-
declare function isTaskRunning(taskState:
|
|
60
|
-
declare function
|
|
61
|
-
|
|
57
|
+
declare function isNonActiveTask(taskState: GraphEngineStore | undefined): boolean;
|
|
58
|
+
declare function isTaskCompleted(taskState: GraphEngineStore | undefined): boolean;
|
|
59
|
+
declare function isTaskRunning(taskState: GraphEngineStore | undefined): boolean;
|
|
60
|
+
declare function getRefreshStrategy(taskConfig: TaskConfig, graphSettings?: {
|
|
61
|
+
refreshStrategy?: RefreshStrategy;
|
|
62
|
+
}): RefreshStrategy;
|
|
63
|
+
declare function isRerunnable(taskConfig: TaskConfig, graphSettings?: {
|
|
64
|
+
refreshStrategy?: RefreshStrategy;
|
|
65
|
+
}): boolean;
|
|
66
|
+
declare function getMaxExecutions(taskConfig: TaskConfig): number | undefined;
|
|
62
67
|
/**
|
|
63
68
|
* Dynamically compute available outputs from all completed tasks.
|
|
64
|
-
*
|
|
69
|
+
* Tasks with strategies other than 'once' may have completed and reset.
|
|
65
70
|
* Pure function.
|
|
66
71
|
*/
|
|
67
|
-
declare function computeAvailableOutputs(graph: GraphConfig, taskStates: Record<string,
|
|
72
|
+
declare function computeAvailableOutputs(graph: GraphConfig, taskStates: Record<string, GraphEngineStore>): string[];
|
|
68
73
|
/**
|
|
69
74
|
* Group candidate tasks by the outputs they provide.
|
|
70
75
|
* Used to detect conflicts (multiple tasks providing the same output).
|
|
@@ -85,7 +90,7 @@ declare function addDynamicTask(graph: GraphConfig, taskName: string, taskConfig
|
|
|
85
90
|
/**
|
|
86
91
|
* Create default task state for a new task.
|
|
87
92
|
*/
|
|
88
|
-
declare function
|
|
93
|
+
declare function createDefaultGraphEngineStore(): GraphEngineStore;
|
|
89
94
|
/**
|
|
90
95
|
* Create the initial execution state for a graph.
|
|
91
96
|
*/
|
|
@@ -254,54 +259,29 @@ declare function exportGraphConfig(config: GraphConfig, options?: ExportOptions)
|
|
|
254
259
|
declare function exportGraphConfigToFile(config: GraphConfig, filePath: string, options?: ExportOptions): Promise<void>;
|
|
255
260
|
|
|
256
261
|
/**
|
|
257
|
-
*
|
|
262
|
+
* schema-validator — Full JSON Schema validation for EventGraph configs.
|
|
258
263
|
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* - Dangling requires (tokens no task produces)
|
|
262
|
-
* - Circular dependencies
|
|
263
|
-
* - Provide conflicts (multiple tasks producing same token)
|
|
264
|
-
* - Unreachable goal tokens
|
|
265
|
-
* - Dead-end tasks (no provides)
|
|
266
|
-
* - Self-dependencies
|
|
267
|
-
* - Orphaned tasks (disconnected from the graph)
|
|
264
|
+
* Uses AJV to validate against the published event-graph.schema.json.
|
|
265
|
+
* For a lightweight sync check without AJV, use `validateGraphConfig()` instead.
|
|
268
266
|
*
|
|
269
|
-
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* import { validateGraphSchema } from 'yaml-flow/event-graph';
|
|
270
|
+
*
|
|
271
|
+
* const result = validateGraphSchema(config);
|
|
272
|
+
* if (!result.ok) console.error(result.errors);
|
|
273
|
+
* ```
|
|
270
274
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
/** Severity: error = will break execution, warning = may cause problems, info = notable */
|
|
275
|
-
severity: IssueSeverity;
|
|
276
|
-
/** Machine-readable issue code */
|
|
277
|
-
code: string;
|
|
278
|
-
/** Human-readable description */
|
|
279
|
-
message: string;
|
|
280
|
-
/** Affected task names (if applicable) */
|
|
281
|
-
tasks?: string[];
|
|
282
|
-
/** Affected tokens (if applicable) */
|
|
283
|
-
tokens?: string[];
|
|
284
|
-
}
|
|
285
|
-
interface GraphValidationResult {
|
|
286
|
-
/** true if no errors (warnings/info are allowed) */
|
|
287
|
-
valid: boolean;
|
|
288
|
-
/** All issues found */
|
|
289
|
-
issues: GraphIssue[];
|
|
290
|
-
/** Just the errors */
|
|
291
|
-
errors: GraphIssue[];
|
|
292
|
-
/** Just the warnings */
|
|
293
|
-
warnings: GraphIssue[];
|
|
275
|
+
interface SchemaValidationResult {
|
|
276
|
+
ok: boolean;
|
|
277
|
+
errors: string[];
|
|
294
278
|
}
|
|
295
279
|
/**
|
|
296
|
-
* Validate
|
|
297
|
-
*
|
|
298
|
-
* Checks for logical issues that would cause execution failures, stuck states,
|
|
299
|
-
* or unexpected behavior. Does NOT check JSON structure (use validateGraphConfig for that).
|
|
280
|
+
* Validate an event-graph config against the full event-graph.schema.json (draft-07).
|
|
300
281
|
*
|
|
301
|
-
*
|
|
302
|
-
* @returns Validation result with categorized issues
|
|
282
|
+
* Requires `ajv` and `ajv-formats` to be installed.
|
|
303
283
|
*/
|
|
304
|
-
declare function
|
|
284
|
+
declare function validateGraphSchema(config: unknown): SchemaValidationResult;
|
|
305
285
|
|
|
306
286
|
/**
|
|
307
287
|
* Event Graph — Constants
|
|
@@ -319,4 +299,4 @@ declare const DEFAULTS: {
|
|
|
319
299
|
readonly MAX_ITERATIONS: 1000;
|
|
320
300
|
};
|
|
321
301
|
|
|
322
|
-
export {
|
|
302
|
+
export { isRerunnable as A, isTaskCompleted as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, isTaskRunning as F, loadGraphConfig as G, next as H, planExecution as I, validateGraphConfig as J, validateGraphSchema as K, addKeyToProvides as L, type MermaidOptions as M, addKeyToRequires as N, groupTasksByProvides as O, hasOutputConflict as P, removeKeyFromProvides as Q, removeKeyFromRequires as R, TASK_STATUS as T, CONFLICT_STRATEGIES as a, type CompletionResult as b, EXECUTION_STATUS as c, type ExecutionPlan as d, type ExportOptions as e, addDynamicTask as f, apply as g, applyAll as h, computeAvailableOutputs as i, createDefaultGraphEngineStore as j, createInitialExecutionState as k, detectStuckState as l, exportGraphConfig as m, exportGraphConfigToFile as n, flowToMermaid as o, getAllTasks as p, getCandidateTasks as q, getMaxExecutions as r, getProvides as s, getRefreshStrategy as t, getRequires as u, getTask as v, graphToMermaid as w, hasTask as x, isExecutionComplete as y, isNonActiveTask as z };
|