@memberjunction/task-graph 6.1.0-edge.1 → 6.1.0-edge.3
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/LICENSE +180 -4
- package/README.md +214 -0
- package/dist/TaskClaimStore.d.ts +387 -4
- package/dist/TaskClaimStore.d.ts.map +1 -1
- package/dist/TaskClaimStore.js +605 -20
- package/dist/TaskClaimStore.js.map +1 -1
- package/dist/TaskGraphDispatcher.d.ts +668 -5
- package/dist/TaskGraphDispatcher.d.ts.map +1 -1
- package/dist/TaskGraphDispatcher.js +2942 -127
- package/dist/TaskGraphDispatcher.js.map +1 -1
- package/dist/TaskGraphService.d.ts +364 -5
- package/dist/TaskGraphService.d.ts.map +1 -1
- package/dist/TaskGraphService.js +1039 -43
- package/dist/TaskGraphService.js.map +1 -1
- package/dist/TaskGraphSubmitterImpl.d.ts.map +1 -1
- package/dist/TaskGraphSubmitterImpl.js +5 -0
- package/dist/TaskGraphSubmitterImpl.js.map +1 -1
- package/dist/TaskLoopExecutor.d.ts +62 -0
- package/dist/TaskLoopExecutor.d.ts.map +1 -0
- package/dist/TaskLoopExecutor.js +248 -0
- package/dist/TaskLoopExecutor.js.map +1 -0
- package/dist/WorkflowSpecSync.d.ts +28 -2
- package/dist/WorkflowSpecSync.d.ts.map +1 -1
- package/dist/WorkflowSpecSync.js +83 -2
- package/dist/WorkflowSpecSync.js.map +1 -1
- package/dist/condition-gate.d.ts +128 -0
- package/dist/condition-gate.d.ts.map +1 -0
- package/dist/condition-gate.js +257 -0
- package/dist/condition-gate.js.map +1 -0
- package/dist/debug-state.d.ts +102 -0
- package/dist/debug-state.d.ts.map +1 -0
- package/dist/debug-state.js +135 -0
- package/dist/debug-state.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/operations/TaskGraphDebugOperations.d.ts +99 -0
- package/dist/operations/TaskGraphDebugOperations.d.ts.map +1 -0
- package/dist/operations/TaskGraphDebugOperations.js +310 -0
- package/dist/operations/TaskGraphDebugOperations.js.map +1 -0
- package/dist/operations/TaskGraphOperations.d.ts +20 -2
- package/dist/operations/TaskGraphOperations.d.ts.map +1 -1
- package/dist/operations/TaskGraphOperations.js +51 -8
- package/dist/operations/TaskGraphOperations.js.map +1 -1
- package/dist/operations/WorkflowDraftOperation.d.ts +37 -0
- package/dist/operations/WorkflowDraftOperation.d.ts.map +1 -0
- package/dist/operations/WorkflowDraftOperation.js +141 -0
- package/dist/operations/WorkflowDraftOperation.js.map +1 -0
- package/dist/settlement-rescue.d.ts +85 -0
- package/dist/settlement-rescue.d.ts.map +1 -0
- package/dist/settlement-rescue.js +119 -0
- package/dist/settlement-rescue.js.map +1 -0
- package/dist/task-graph-kick.d.ts +3 -0
- package/dist/task-graph-kick.d.ts.map +1 -0
- package/dist/task-graph-kick.js +17 -0
- package/dist/task-graph-kick.js.map +1 -0
- package/dist/task-predicates.d.ts +77 -0
- package/dist/task-predicates.d.ts.map +1 -0
- package/dist/task-predicates.js +75 -0
- package/dist/task-predicates.js.map +1 -0
- package/dist/types.d.ts +224 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +12 -8
package/LICENSE
CHANGED
|
@@ -1,7 +1,183 @@
|
|
|
1
|
-
|
|
1
|
+
Business Source License 1.1
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# @memberjunction/task-graph
|
|
2
|
+
|
|
3
|
+
Durable execution of task graphs: submission, the dispatcher, the claim protocol, and the runners
|
|
4
|
+
that turn a node into work.
|
|
5
|
+
|
|
6
|
+
> **New to workflows?** Start with the [Workflows and Task Graphs
|
|
7
|
+
> Guide](../../guides/WORKFLOW_AND_TASK_GRAPH_GUIDE.md), which covers what a workflow is, when to
|
|
8
|
+
> use one, and every rule that decides what happens next. To **step a live run**, see the
|
|
9
|
+
> [Workflow Debugger Guide](../../guides/WORKFLOW_DEBUGGER_GUIDE.md). This README is the package tour.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What this package is for
|
|
14
|
+
|
|
15
|
+
A task graph is work that has to **outlive the thing that asked for it**. Before durable execution,
|
|
16
|
+
a multi-step agent plan lived inside one agent run: a page reload lost it, a server restart orphaned
|
|
17
|
+
it, and no channel other than the one that started it could see it.
|
|
18
|
+
|
|
19
|
+
This package is the other half of that split. Something else *produces* a graph; this package makes
|
|
20
|
+
it durable and runs it.
|
|
21
|
+
|
|
22
|
+
```mermaid
|
|
23
|
+
graph TB
|
|
24
|
+
subgraph Producers["Producers — anyone"]
|
|
25
|
+
P1["Flow agent<br/><i>compiled</i>"]
|
|
26
|
+
P2["Loop agent<br/><i>emitted</i>"]
|
|
27
|
+
P3["Entity action"]
|
|
28
|
+
P4["TaskGraph.Submit<br/><i>remote op</i>"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
P1 & P2 & P3 & P4 --> SVC["<b>TaskGraphService.Submit</b><br/>validate · resolve · persist"]
|
|
32
|
+
SVC --> ROWS["Task + TaskDependency"]
|
|
33
|
+
ROWS --> DISP["<b>TaskGraphDispatcher</b><br/>poll · claim · execute · settle"]
|
|
34
|
+
|
|
35
|
+
DISP --> R1["TaskAgentRunner"]
|
|
36
|
+
DISP --> R2["TaskActionRunner"]
|
|
37
|
+
DISP --> R3["TaskLoopExecutor"]
|
|
38
|
+
DISP --> R4["a person"]
|
|
39
|
+
|
|
40
|
+
style SVC fill:#7c5295,stroke:#563a6b,color:#fff
|
|
41
|
+
style ROWS fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
42
|
+
style DISP fill:#b8762f,stroke:#8a5722,color:#fff
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Submission never waits for execution.** `Submit` returns as soon as the graph is durable. That
|
|
46
|
+
split is what makes the engine invocation-agnostic: an agent, a scheduled job, a Slack message and a
|
|
47
|
+
manual UI all call the same method, and whichever dispatcher instance is running picks the work up.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## What it deliberately does not do
|
|
52
|
+
|
|
53
|
+
**It does not decide graph semantics.** Eligibility, failure propagation, parent rollup, skip
|
|
54
|
+
cascade, exclusive-group resolution and stall detection all come from pure, dependency-free
|
|
55
|
+
functions in [`@memberjunction/ai-core-plus`](../AI/CorePlus). That is not tidiness — it is what
|
|
56
|
+
stops the in-run executor and the durable executor from drifting apart. Neither owns the rules.
|
|
57
|
+
|
|
58
|
+
**It does not import MJServer.** Provider minting and agent execution arrive as injected seams
|
|
59
|
+
(`ProviderFactory`, `TaskAgentRunner`, `TaskActionRunner`), so the dependency runs
|
|
60
|
+
MJServer → task-graph and never the reverse. That is also what keeps the dispatcher unit-testable
|
|
61
|
+
without standing up the agent framework.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## The pieces
|
|
66
|
+
|
|
67
|
+
| File | Responsibility |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `TaskGraphService.ts` | Validate a spec, resolve names to IDs, write parent + children + edges. The only write path. |
|
|
70
|
+
| `TaskGraphDispatcher.ts` | Poll, claim, execute, evaluate edges, propagate, roll up, settle, credit cost. |
|
|
71
|
+
| `TaskClaimStore.ts` | The atomic claim protocol — guarded writes so two instances cannot run the same task. |
|
|
72
|
+
| `TaskLoopExecutor.ts` | `ForEach` / `While` semantics: bounds, ordering, concurrency, delay, failure. |
|
|
73
|
+
| `DispatcherConditionEvaluator.ts` | Edge conditions, over the superset context both dialects can read. |
|
|
74
|
+
| `TaskGraphSubmitterImpl.ts` | Registers the durable submitter under the `ClassFactory` seam. |
|
|
75
|
+
| `operations/` | The `TaskGraph.*` remote operations. |
|
|
76
|
+
| `debug-state.ts` | Durable `$.debug` bag — pause, breakpoints, step allowance, `skipBreakpointTaskID`, edge overrides. Pure claim-gate. |
|
|
77
|
+
| `task-graph-kick.ts` | Process-local kick set. `Start()` registers; `Submit` pokes every running dispatcher so the first pass is immediate. |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Claiming: why a task runs exactly once
|
|
82
|
+
|
|
83
|
+
Multiple dispatcher instances poll the same table. Correctness comes from a **guarded write**, not
|
|
84
|
+
from coordination: claiming is an update that only succeeds if the row still looks the way the
|
|
85
|
+
claimer expects.
|
|
86
|
+
|
|
87
|
+
```mermaid
|
|
88
|
+
sequenceDiagram
|
|
89
|
+
participant A as Instance A
|
|
90
|
+
participant B as Instance B
|
|
91
|
+
participant DB as Task row
|
|
92
|
+
|
|
93
|
+
A->>DB: claim if unclaimed / expired
|
|
94
|
+
B->>DB: claim if unclaimed / expired
|
|
95
|
+
DB-->>A: 1 row updated ✅
|
|
96
|
+
DB-->>B: 0 rows updated ❌
|
|
97
|
+
Note over B: defers — no lock, no retry storm
|
|
98
|
+
loop while running
|
|
99
|
+
A->>DB: heartbeat (extends ClaimExpiresAt)
|
|
100
|
+
end
|
|
101
|
+
A->>DB: complete IF still owned by A
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If A dies, its claim expires and reconciliation makes the task claimable again. If A finishes but
|
|
105
|
+
the row changed underneath it (cancelled, reassigned, reclaimed), the guarded completion refuses and
|
|
106
|
+
A defers — overwriting would undo a newer, deliberate decision.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Runners are seams, not implementations
|
|
111
|
+
|
|
112
|
+
| Seam | Implemented by | Absent means |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| `TaskAgentRunner` | `TaskGraphAgentRunner` (MJServer) | agent nodes cannot run here |
|
|
115
|
+
| `TaskActionRunner` | `TaskGraphActionRunner` (MJServer) | action nodes stay `Pending`, **not** Failed |
|
|
116
|
+
| `ProviderFactory` | `TaskGraphProviderFactory` (MJServer) | required |
|
|
117
|
+
| `TaskContinuationDeliverer` | `TaskGraphContinuationDeliverer` (MJServer) | outcomes are recorded but not announced |
|
|
118
|
+
| `TaskGraphObserver` | the frame resolver (MJServer) | nobody is watching; behaviour identical |
|
|
119
|
+
|
|
120
|
+
**A host with no runner is limited, not broken.** "Nobody here can run this" is not the same as
|
|
121
|
+
"this ran and did not work", so those tasks stay visible and claimable by an instance that can.
|
|
122
|
+
|
|
123
|
+
> **An Agent node starts a brand-new `AIAgentRun`** — a root run, linked from `Task.AgentRunID`
|
|
124
|
+
> rather than nested under the submitting run. The relationship is expressed by the Task row.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Starting a dispatcher
|
|
129
|
+
|
|
130
|
+
MJAPI does this for you (`StartTaskGraphDispatcher`). For a custom host:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { TaskGraphDispatcher, LoadTaskGraphOperations } from '@memberjunction/task-graph';
|
|
134
|
+
|
|
135
|
+
LoadTaskGraphOperations(); // registers the remote operations + the durable submitter
|
|
136
|
+
|
|
137
|
+
const dispatcher = new TaskGraphDispatcher(
|
|
138
|
+
providerFactory,
|
|
139
|
+
agentRunner,
|
|
140
|
+
contextUser,
|
|
141
|
+
{ InstanceID: `worker-${process.pid}` },
|
|
142
|
+
continuationDeliverer, // optional
|
|
143
|
+
observer, // optional
|
|
144
|
+
actionRunner, // optional
|
|
145
|
+
);
|
|
146
|
+
await dispatcher.Start();
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Without `LoadTaskGraphOperations()` nothing registers the submitter, and
|
|
150
|
+
`GetTaskGraphSubmitter()` returns `null` — which callers must report rather than swallow.
|
|
151
|
+
|
|
152
|
+
`Start()` registers a kick and fires one immediately. Do not wait for the first `setInterval`
|
|
153
|
+
tick — that is a 5s dead pause after Debug/Run. Submit cannot import the dispatcher instance
|
|
154
|
+
(submit and execute are separate halves), so it calls `KickTaskGraphDispatchers()` instead.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Debugging a live graph
|
|
159
|
+
|
|
160
|
+
Every control is a **gate on claiming**, never on running. State lives under `$.debug` on the
|
|
161
|
+
parent task's `InputPayload`. The debugger UI and the dispatcher never talk directly — they
|
|
162
|
+
rendezvous on the row. See [`debug-state.ts`](src/debug-state.ts) and the
|
|
163
|
+
[Workflow Debugger Guide](../../guides/WORKFLOW_DEBUGGER_GUIDE.md).
|
|
164
|
+
|
|
165
|
+
- **Start-paused.** Submit writes `paused: true` before any dispatcher has seen the graph.
|
|
166
|
+
- **Breakpoints.** The claim gate treats an armed, eligible task like a hold. Resume from a
|
|
167
|
+
breakpoint stamps `skipBreakpointTaskID` so that one claim is allowed through; without it the
|
|
168
|
+
next poll re-hits the same Pending row. `ForEach` is one task — one Continue runs the loop.
|
|
169
|
+
- **Edge overrides.** Authored `'true'` / `'false'` on a `TaskDependency` id, honored by every
|
|
170
|
+
instance, survive a restart.
|
|
171
|
+
- **Kick.** After Submit (and on `Start()`), `KickTaskGraphDispatchers()` runs a pass now.
|
|
172
|
+
|
|
173
|
+
The Angular drop-in is `<mj-task-graph-debugger>` in
|
|
174
|
+
[`@memberjunction/ng-task-graph-editor`](../Angular/Generic/task-graph-editor/README.md).
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Cost rollup
|
|
179
|
+
|
|
180
|
+
When a graph settles, the dispatcher credits its spending back to the run that submitted it, writing
|
|
181
|
+
the `…Rollup` columns on `AIAgentRun`:
|
|
182
|
+
|
|
183
|
+
- `TotalCost` — what the submitting run itself spent. **Never rewritten here.**
|
|
184
|
+
- `TotalCostRollup` — that run plus everything it caused.
|
|
185
|
+
|
|
186
|
+
This cannot happen during the run: a submitting run *ends at submission*, so at the moment it
|
|
187
|
+
computes its own totals the graph has not spent anything yet. See the guide's [cost
|
|
188
|
+
section](../../guides/WORKFLOW_AND_TASK_GRAPH_GUIDE.md#cost-and-tokens-the-seam).
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Testing
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
cd packages/TaskGraph && pnpm test
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Unit tests cover the pure pieces — loop semantics, dispatchable kinds, configuration persistence,
|
|
199
|
+
parent metadata. The dispatcher driving **real rows against SQL Server** is covered by the `IT74`
|
|
200
|
+
bundle in `@memberjunction/integration-test-suite`, which uses a stub agent runner so it stays in
|
|
201
|
+
the deterministic tier: no model calls, no tokens, real claim protocol, real condition evaluator,
|
|
202
|
+
real rollup.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Related
|
|
207
|
+
|
|
208
|
+
- [Workflows and Task Graphs Guide](../../guides/WORKFLOW_AND_TASK_GRAPH_GUIDE.md) — start here
|
|
209
|
+
- [Workflow Debugger Guide](../../guides/WORKFLOW_DEBUGGER_GUIDE.md) — step a live run
|
|
210
|
+
- [`@memberjunction/ng-task-graph-editor`](../Angular/Generic/task-graph-editor/README.md) — canvas and drop-in debugger
|
|
211
|
+
- [`@memberjunction/ai-core-plus`](../AI/CorePlus) — the spec, validator, compiler, pure algorithms,
|
|
212
|
+
payload mapping and layout
|
|
213
|
+
- [`@memberjunction/ai-agents`](../AI/Agents) — the agent framework and `FlowAgentType`
|
|
214
|
+
- [`packages/Actions/CLAUDE.md`](../Actions/CLAUDE.md) — Actions as boundaries
|