@x12i/graphenix-trace-format 1.0.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.
Files changed (54) hide show
  1. package/README.md +242 -0
  2. package/dist/index.d.ts +11 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +11 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/internal/trace-v2-utils.d.ts +10 -0
  7. package/dist/internal/trace-v2-utils.d.ts.map +1 -0
  8. package/dist/internal/trace-v2-utils.js +65 -0
  9. package/dist/internal/trace-v2-utils.js.map +1 -0
  10. package/dist/trace/append-execution-event.d.ts +5 -0
  11. package/dist/trace/append-execution-event.d.ts.map +1 -0
  12. package/dist/trace/append-execution-event.js +6 -0
  13. package/dist/trace/append-execution-event.js.map +1 -0
  14. package/dist/trace/append-trace-event.d.ts +5 -0
  15. package/dist/trace/append-trace-event.d.ts.map +1 -0
  16. package/dist/trace/append-trace-event.js +6 -0
  17. package/dist/trace/append-trace-event.js.map +1 -0
  18. package/dist/trace/create-empty-execution-trace.d.ts +10 -0
  19. package/dist/trace/create-empty-execution-trace.d.ts.map +1 -0
  20. package/dist/trace/create-empty-execution-trace.js +133 -0
  21. package/dist/trace/create-empty-execution-trace.js.map +1 -0
  22. package/dist/trace/create-execution-trace.d.ts +5 -0
  23. package/dist/trace/create-execution-trace.d.ts.map +1 -0
  24. package/dist/trace/create-execution-trace.js +53 -0
  25. package/dist/trace/create-execution-trace.js.map +1 -0
  26. package/dist/trace/derive-graph-status.d.ts +4 -0
  27. package/dist/trace/derive-graph-status.d.ts.map +1 -0
  28. package/dist/trace/derive-graph-status.js +59 -0
  29. package/dist/trace/derive-graph-status.js.map +1 -0
  30. package/dist/trace/summarize-execution-trace.d.ts +3 -0
  31. package/dist/trace/summarize-execution-trace.d.ts.map +1 -0
  32. package/dist/trace/summarize-execution-trace.js +60 -0
  33. package/dist/trace/summarize-execution-trace.js.map +1 -0
  34. package/dist/validators/validate-execution-trace-v1.d.ts +4 -0
  35. package/dist/validators/validate-execution-trace-v1.d.ts.map +1 -0
  36. package/dist/validators/validate-execution-trace-v1.js +155 -0
  37. package/dist/validators/validate-execution-trace-v1.js.map +1 -0
  38. package/dist/validators/validate-execution-trace-v2-structural.d.ts +3 -0
  39. package/dist/validators/validate-execution-trace-v2-structural.d.ts.map +1 -0
  40. package/dist/validators/validate-execution-trace-v2-structural.js +215 -0
  41. package/dist/validators/validate-execution-trace-v2-structural.js.map +1 -0
  42. package/dist/validators/validate-execution-trace-v2.d.ts +6 -0
  43. package/dist/validators/validate-execution-trace-v2.d.ts.map +1 -0
  44. package/dist/validators/validate-execution-trace-v2.js +40 -0
  45. package/dist/validators/validate-execution-trace-v2.js.map +1 -0
  46. package/dist/validators/validate-execution-trace.d.ts +7 -0
  47. package/dist/validators/validate-execution-trace.d.ts.map +1 -0
  48. package/dist/validators/validate-execution-trace.js +31 -0
  49. package/dist/validators/validate-execution-trace.js.map +1 -0
  50. package/dist/validators/validate-trace-against-plan.d.ts +4 -0
  51. package/dist/validators/validate-trace-against-plan.d.ts.map +1 -0
  52. package/dist/validators/validate-trace-against-plan.js +200 -0
  53. package/dist/validators/validate-trace-against-plan.js.map +1 -0
  54. package/package.json +51 -0
package/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # @x12i/graphenix-trace-format
2
+
3
+ **GraphExecutionTrace** format — append-only run evidence for a single graph execution.
4
+
5
+ Covers node traces, execution unit traces, model invocation attempts, fallback events, and final output. Does not depend on authoring graphs.
6
+
7
+ **Canonical vocabulary:** [GLOSSARY.md](../../GLOSSARY.md) — task run phases map to trace `unit.*` events in plan order.
8
+ **Finalization brief:** [EXECUTE-TRACE-FORMAT-FINALIZATION.md](../../docs/EXECUTE-TRACE-FORMAT-FINALIZATION.md).
9
+
10
+ Do not use **“Synthesis PRE”** in trace docs — use PRE-phase utility / `externalPreUtility` with `strategyKey`.
11
+
12
+ ---
13
+
14
+ ## Who should use this
15
+
16
+ | Role | Use this package? |
17
+ | ---- | ----------------- |
18
+ | Execution engine | **Yes** — create and append events during a run |
19
+ | Run history / observability / analytics | **Yes** — validate and read traces |
20
+ | Graph designer / Studio | **No** (unless displaying run history) |
21
+
22
+ ---
23
+
24
+ ## Lifecycle position
25
+
26
+ ```txt
27
+ ExecutableGraphPlan + GraphRuntimeObject
28
+ │ engine executes executionUnits[] (prePhase → mainPhase → postPhase)
29
+
30
+ GraphExecutionTrace ← THIS PACKAGE
31
+ ```
32
+
33
+ Reference domain: content pipeline plan (`graph:content-pipeline`) — three parallel tasks with PRE synthesis + MAIN skill, no POST on reference tasks.
34
+
35
+ ---
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ npm install @x12i/graphenix-trace-format
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Trace document shape
46
+
47
+ ```txt
48
+ GraphExecutionTrace
49
+ ├─ traceId, jobId, status, createdAt, completedAt
50
+ ├─ source — graphId, graphHash (from plan)
51
+ ├─ plan — planId, planHash (bind trace to frozen plan)
52
+ ├─ runtime — mode, environment, inputHash (no credentials)
53
+ ├─ events[] — append-only, ordered
54
+ └─ nodeExecutions{} — per-node unit summaries
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Examples (JSON)
60
+
61
+ ### Trace header (bound to content pipeline plan)
62
+
63
+ ```json
64
+ {
65
+ "format": "graphenix.execution-trace/v1",
66
+ "traceId": "trace:job-001",
67
+ "jobId": "job-001",
68
+ "createdAt": "2026-06-06T12:00:00.000Z",
69
+ "status": "running",
70
+ "source": {
71
+ "graphId": "graph:content-pipeline",
72
+ "graphRevision": "1.0.0",
73
+ "graphHash": "sha256:…"
74
+ },
75
+ "plan": {
76
+ "planId": "plan:abc123",
77
+ "planHash": "sha256:…"
78
+ },
79
+ "runtime": {
80
+ "mode": "live",
81
+ "environment": "prod",
82
+ "inputHash": "sha256:…"
83
+ },
84
+ "events": [],
85
+ "nodeExecutions": {}
86
+ }
87
+ ```
88
+
89
+ ### Unit events for one content-pipeline task (PRE + MAIN)
90
+
91
+ After `node:audience-insights` runs PRE-phase utility `synthesis` then MAIN skill:
92
+
93
+ ```json
94
+ "events": [
95
+ {
96
+ "id": "evt:1",
97
+ "ts": "2026-06-06T12:00:01.000Z",
98
+ "level": "info",
99
+ "type": "node.started",
100
+ "nodeId": "node:audience-insights"
101
+ },
102
+ {
103
+ "id": "evt:2",
104
+ "ts": "2026-06-06T12:00:01.100Z",
105
+ "level": "info",
106
+ "type": "unit.started",
107
+ "nodeId": "node:audience-insights",
108
+ "unitId": "unit:node:audience-insights:pre:0",
109
+ "unitKind": "externalPreUtility"
110
+ },
111
+ {
112
+ "id": "evt:3",
113
+ "ts": "2026-06-06T12:00:02.500Z",
114
+ "level": "info",
115
+ "type": "model.invocation.completed",
116
+ "nodeId": "node:audience-insights",
117
+ "unitId": "unit:node:audience-insights:pre:0",
118
+ "modelSlot": "preActionModel"
119
+ },
120
+ {
121
+ "id": "evt:4",
122
+ "ts": "2026-06-06T12:00:02.600Z",
123
+ "level": "info",
124
+ "type": "unit.started",
125
+ "nodeId": "node:audience-insights",
126
+ "unitId": "unit:node:audience-insights:main:1",
127
+ "unitKind": "mainSkill"
128
+ },
129
+ {
130
+ "id": "evt:5",
131
+ "ts": "2026-06-06T12:00:05.000Z",
132
+ "level": "info",
133
+ "type": "node.completed",
134
+ "nodeId": "node:audience-insights"
135
+ }
136
+ ]
137
+ ```
138
+
139
+ Model profiles were resolved at **compile time** — trace records which `modelSlot` was invoked, not a re-selected case.
140
+
141
+ ---
142
+
143
+ ## Example (API)
144
+
145
+ ```ts
146
+ import {
147
+ createExecutionTrace,
148
+ appendExecutionEvent,
149
+ validateExecutionTrace,
150
+ deriveGraphStatus,
151
+ summarizeExecutionTrace
152
+ } from "@x12i/graphenix-trace-format";
153
+
154
+ const trace = createExecutionTrace(plan, runtime);
155
+
156
+ appendExecutionEvent(trace, {
157
+ id: "evt:1",
158
+ ts: new Date().toISOString(),
159
+ level: "info",
160
+ type: "graph.started",
161
+ message: "Graph execution started."
162
+ });
163
+
164
+ appendExecutionEvent(trace, {
165
+ id: "evt:2",
166
+ ts: new Date().toISOString(),
167
+ level: "info",
168
+ type: "node.started",
169
+ nodeId: "node:audience-insights"
170
+ });
171
+
172
+ const result = validateExecutionTrace(trace, plan.nodePlans);
173
+ const status = deriveGraphStatus(trace);
174
+ const summary = summarizeExecutionTrace(trace);
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Key exports
180
+
181
+ | API | Purpose |
182
+ | --- | ------- |
183
+ | `createExecutionTrace` | Initialize trace bound to a plan + runtime |
184
+ | `appendExecutionEvent` | Append-only event mutation |
185
+ | `validateExecutionTrace` | Validate trace against plan node plans |
186
+ | `deriveGraphStatus` | Overall run status from events |
187
+ | `deriveNodeStatusFromUnits` | Per-node status |
188
+ | `summarizeExecutionTrace` | Compact summary for dashboards |
189
+
190
+ Trace event types include graph/node lifecycle, execution unit lifecycle (`unit.started` / `unit.completed`), model invocation, fallback applied, validation failures, and warnings.
191
+
192
+ ---
193
+
194
+ ## Validation tier
195
+
196
+ | When | API |
197
+ | ---- | --- |
198
+ | Run end (engine) | `validateExecutionTrace(trace, plan.nodePlans)` |
199
+ | Index / analytics | `validateExecutionTrace` before storing |
200
+ | Dashboards | `deriveGraphStatus`, `summarizeExecutionTrace` |
201
+
202
+ Store `planHash` (or full plan snapshot) with each trace for strict replay validation.
203
+
204
+ ---
205
+
206
+ ## Format identifiers
207
+
208
+ ```ts
209
+ EXECUTION_TRACE_FORMAT // v1 — @x12i/graphenix-executable-contracts
210
+ EXECUTION_TRACE_FORMAT_V2 // v2 — when plan is v2
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Dependencies
216
+
217
+ - `@x12i/graphenix-executable-contracts` ^1.0.0
218
+
219
+ ---
220
+
221
+ ## Related packages
222
+
223
+ | Package | Role |
224
+ | ------- | ---- |
225
+ | [GLOSSARY.md](../../GLOSSARY.md) | Phase vocabulary for unit events |
226
+ | [`@x12i/graphenix-plan-format`](../plan-format) | Plan shape traces reference |
227
+ | [`@x12i/graphenix-plan-compiler`](../plan-compiler) | Produces the plan a trace is bound to |
228
+ | [EXECUTE-TRACE-FORMAT-FINALIZATION.md](../../docs/EXECUTE-TRACE-FORMAT-FINALIZATION.md) | Execute + trace phase brief |
229
+ | [observability role guide](../../docs/roles/observability.md) | Run history client guide |
230
+
231
+ ---
232
+
233
+ ## README sync policy
234
+
235
+ When documenting **task run phases** at execution/trace layer, update together:
236
+
237
+ | Layer | README / doc |
238
+ | ----- | ------------ |
239
+ | Compiled plan units | [plan-format/README.md](../plan-format/README.md) |
240
+ | Trace events | **this file** |
241
+ | Execute + trace brief | [EXECUTE-TRACE-FORMAT-FINALIZATION.md](../../docs/EXECUTE-TRACE-FORMAT-FINALIZATION.md) |
242
+ | Terms of record | [GLOSSARY.md](../../GLOSSARY.md) |
@@ -0,0 +1,11 @@
1
+ export { createExecutionTrace } from "./trace/create-execution-trace.js";
2
+ export { createEmptyExecutionTrace } from "./trace/create-empty-execution-trace.js";
3
+ export { appendExecutionEvent } from "./trace/append-execution-event.js";
4
+ export { appendTraceEvent } from "./trace/append-trace-event.js";
5
+ export { deriveGraphStatus, deriveNodeStatusFromUnits } from "./trace/derive-graph-status.js";
6
+ export { summarizeExecutionTrace } from "./trace/summarize-execution-trace.js";
7
+ export { validateExecutionTrace, assertExecutionTrace } from "./validators/validate-execution-trace.js";
8
+ export { validateExecutionTraceV1 } from "./validators/validate-execution-trace-v1.js";
9
+ export { validateExecutionTraceV2 } from "./validators/validate-execution-trace-v2.js";
10
+ export { validateTraceAgainstPlan } from "./validators/validate-trace-against-plan.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export { createExecutionTrace } from "./trace/create-execution-trace.js";
2
+ export { createEmptyExecutionTrace } from "./trace/create-empty-execution-trace.js";
3
+ export { appendExecutionEvent } from "./trace/append-execution-event.js";
4
+ export { appendTraceEvent } from "./trace/append-trace-event.js";
5
+ export { deriveGraphStatus, deriveNodeStatusFromUnits } from "./trace/derive-graph-status.js";
6
+ export { summarizeExecutionTrace } from "./trace/summarize-execution-trace.js";
7
+ export { validateExecutionTrace, assertExecutionTrace } from "./validators/validate-execution-trace.js";
8
+ export { validateExecutionTraceV1 } from "./validators/validate-execution-trace-v1.js";
9
+ export { validateExecutionTraceV2 } from "./validators/validate-execution-trace-v2.js";
10
+ export { validateTraceAgainstPlan } from "./validators/validate-trace-against-plan.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ExecutableGraphPlanV2 } from "@x12i/graphenix-executable-contracts";
2
+ import type { TracePlanRef } from "@x12i/graphenix-executable-contracts";
3
+ export declare function buildTracePlanRef(plan: ExecutableGraphPlanV2): TracePlanRef;
4
+ export declare function collectAllPlanUnitIds(plan: ExecutableGraphPlanV2): string[];
5
+ export declare function collectAllPlanNodeIds(plan: ExecutableGraphPlanV2): string[];
6
+ export declare function collectDeferredGateIds(plan: ExecutableGraphPlanV2): string[];
7
+ export declare function isTerminalNodeStatus(status: string): status is "completed" | "failed" | "skipped";
8
+ export declare function isTerminalUnitStatus(status: string): status is "completed" | "failed" | "skipped";
9
+ export declare function isAiBackedUnit(unitKind: string, executionClass: string): boolean;
10
+ //# sourceMappingURL=trace-v2-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-v2-utils.d.ts","sourceRoot":"","sources":["../../src/internal/trace-v2-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAIzE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,YAAY,CAY3E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAa3E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAM3E;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAY5E;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,GACb,MAAM,IAAI,WAAW,GAAG,QAAQ,GAAG,SAAS,CAE9C;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,GACb,MAAM,IAAI,WAAW,GAAG,QAAQ,GAAG,SAAS,CAE9C;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAST"}
@@ -0,0 +1,65 @@
1
+ import { EXECUTABLE_PLAN_FORMAT_V2 } from "@x12i/graphenix-executable-contracts";
2
+ import { defaultHashFunction } from "@x12i/graphenix-executable-contracts";
3
+ export function buildTracePlanRef(plan) {
4
+ const hash = defaultHashFunction;
5
+ return {
6
+ planId: plan.planId,
7
+ planFormat: EXECUTABLE_PLAN_FORMAT_V2,
8
+ planHash: hash(plan),
9
+ normalizedGraphHash: plan.normalizedGraph.graphHash,
10
+ schedulingPolicyHash: hash(plan.schedulingPolicy),
11
+ topologyHash: hash(plan.topology),
12
+ deferredGatesHash: hash(plan.deferredGates),
13
+ nodePlansHash: hash(plan.nodePlans)
14
+ };
15
+ }
16
+ export function collectAllPlanUnitIds(plan) {
17
+ const unitIds = [];
18
+ for (const nodePlan of Object.values(plan.nodePlans)) {
19
+ for (const unit of nodePlan.executionUnits) {
20
+ unitIds.push(unit.unitId);
21
+ }
22
+ }
23
+ for (const finalizerPlan of Object.values(plan.finalizerPlans)) {
24
+ for (const unit of finalizerPlan.executionUnits) {
25
+ unitIds.push(unit.unitId);
26
+ }
27
+ }
28
+ return unitIds;
29
+ }
30
+ export function collectAllPlanNodeIds(plan) {
31
+ const nodeIds = new Set();
32
+ for (const nodeRef of plan.topology.nodes) {
33
+ nodeIds.add(nodeRef.nodeId);
34
+ }
35
+ return [...nodeIds];
36
+ }
37
+ export function collectDeferredGateIds(plan) {
38
+ const gateIds = [];
39
+ for (const gate of plan.deferredGates.entryGates ?? []) {
40
+ gateIds.push(gate.gateId);
41
+ }
42
+ for (const gate of Object.values(plan.deferredGates.nodeGates)) {
43
+ gateIds.push(gate.gateId);
44
+ }
45
+ for (const gate of Object.values(plan.deferredGates.edgeGates)) {
46
+ gateIds.push(gate.gateId);
47
+ }
48
+ return gateIds;
49
+ }
50
+ export function isTerminalNodeStatus(status) {
51
+ return status === "completed" || status === "failed" || status === "skipped";
52
+ }
53
+ export function isTerminalUnitStatus(status) {
54
+ return status === "completed" || status === "failed" || status === "skipped";
55
+ }
56
+ export function isAiBackedUnit(unitKind, executionClass) {
57
+ if (executionClass === "localTask")
58
+ return false;
59
+ return (unitKind === "externalPreUtility" ||
60
+ unitKind === "mainSkill" ||
61
+ unitKind === "pipelinePhase" ||
62
+ unitKind === "externalPostUtility" ||
63
+ unitKind === "finalizer");
64
+ }
65
+ //# sourceMappingURL=trace-v2-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-v2-utils.js","sourceRoot":"","sources":["../../src/internal/trace-v2-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,MAAM,UAAU,iBAAiB,CAAC,IAA2B;IAC3D,MAAM,IAAI,GAAG,mBAAmB,CAAC;IACjC,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,UAAU,EAAE,yBAAyB;QACrC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC;QACpB,mBAAmB,EAAE,IAAI,CAAC,eAAe,CAAC,SAAS;QACnD,oBAAoB,EAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;QACjD,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QACjC,iBAA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IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAc;IAEd,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAc;IAEd,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,QAAgB,EAChB,cAAsB;IAEtB,IAAI,cAAc,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IACjD,OAAO,CACL,QAAQ,KAAK,oBAAoB;QACjC,QAAQ,KAAK,WAAW;QACxB,QAAQ,KAAK,eAAe;QAC5B,QAAQ,KAAK,qBAAqB;QAClC,QAAQ,KAAK,WAAW,CACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { GraphExecutionEvent, GraphExecutionTrace } from "@x12i/graphenix-executable-contracts";
2
+ export declare function appendExecutionEvent(trace: GraphExecutionTrace, event: GraphExecutionEvent, options?: {
3
+ mutate?: boolean;
4
+ }): GraphExecutionTrace;
5
+ //# sourceMappingURL=append-execution-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"append-execution-event.d.ts","sourceRoot":"","sources":["../../src/trace/append-execution-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,mBAAmB,CAIrB"}
@@ -0,0 +1,6 @@
1
+ export function appendExecutionEvent(trace, event, options = {}) {
2
+ const target = options.mutate ? trace : structuredClone(trace);
3
+ target.events = [...target.events, event];
4
+ return target;
5
+ }
6
+ //# sourceMappingURL=append-execution-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"append-execution-event.js","sourceRoot":"","sources":["../../src/trace/append-execution-event.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,oBAAoB,CAClC,KAA0B,EAC1B,KAA0B,EAC1B,UAAgC,EAAE;IAElC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC/D,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { GraphExecutionTraceV2, TraceEvent } from "@x12i/graphenix-executable-contracts";
2
+ export declare function appendTraceEvent(trace: GraphExecutionTraceV2, event: TraceEvent, options?: {
3
+ mutate?: boolean;
4
+ }): GraphExecutionTraceV2;
5
+ //# sourceMappingURL=append-trace-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"append-trace-event.d.ts","sourceRoot":"","sources":["../../src/trace/append-trace-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,UAAU,EACX,MAAM,sCAAsC,CAAC;AAE9C,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,qBAAqB,CAIvB"}
@@ -0,0 +1,6 @@
1
+ export function appendTraceEvent(trace, event, options = {}) {
2
+ const target = options.mutate ? trace : structuredClone(trace);
3
+ target.events = [...target.events, event];
4
+ return target;
5
+ }
6
+ //# sourceMappingURL=append-trace-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"append-trace-event.js","sourceRoot":"","sources":["../../src/trace/append-trace-event.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,gBAAgB,CAC9B,KAA4B,EAC5B,KAAiB,EACjB,UAAgC,EAAE;IAElC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC/D,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ExecutableGraphPlanV2 } from "@x12i/graphenix-executable-contracts";
2
+ import type { GraphExecutionTraceV2 } from "@x12i/graphenix-executable-contracts";
3
+ import type { GraphRuntimeObject } from "@x12i/graphenix-executable-contracts";
4
+ export declare function createEmptyExecutionTrace(args: {
5
+ traceId: string;
6
+ plan: ExecutableGraphPlanV2;
7
+ runtime: GraphRuntimeObject;
8
+ now?: string;
9
+ }): GraphExecutionTraceV2;
10
+ //# sourceMappingURL=create-empty-execution-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-empty-execution-trace.d.ts","sourceRoot":"","sources":["../../src/trace/create-empty-execution-trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,KAAK,EAEV,qBAAqB,EAEtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AA+D/E,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,qBAAqB,CAwFxB"}
@@ -0,0 +1,133 @@
1
+ import { EXECUTION_TRACE_FORMAT_V2 } from "@x12i/graphenix-executable-contracts";
2
+ import { buildTracePlanRef, collectAllPlanNodeIds } from "../internal/trace-v2-utils.js";
3
+ function buildUnitTrace(unit) {
4
+ return {
5
+ unitId: unit.unitId,
6
+ nodeId: unit.nodeId,
7
+ unitKind: unit.unitKind,
8
+ invokeMode: unit.invokeMode,
9
+ order: unit.order,
10
+ status: "pending",
11
+ plannedModelSelection: unit.modelSelection,
12
+ modelSlot: unit.modelSlot
13
+ };
14
+ }
15
+ function buildNodeTrace(plan, nodeId) {
16
+ const nodeRef = plan.topology.nodes.find((n) => n.nodeId === nodeId);
17
+ const nodePlan = plan.nodePlans[nodeId];
18
+ const finalizerPlan = plan.finalizerPlans[nodeId];
19
+ if (nodePlan) {
20
+ const unitIds = nodePlan.executionUnits.map((u) => u.unitId);
21
+ return {
22
+ nodeId,
23
+ nodeType: nodePlan.nodeType,
24
+ executionClass: nodePlan.executionClass,
25
+ status: "pending",
26
+ selectedCases: nodePlan.selectedCases,
27
+ gateEvaluationIds: nodePlan.deferredGateIds,
28
+ unitIds
29
+ };
30
+ }
31
+ if (finalizerPlan) {
32
+ const unitIds = finalizerPlan.executionUnits.map((u) => u.unitId);
33
+ return {
34
+ nodeId,
35
+ nodeType: "finalizer",
36
+ executionClass: "finalizer",
37
+ status: "pending",
38
+ unitIds
39
+ };
40
+ }
41
+ return {
42
+ nodeId,
43
+ nodeType: nodeRef?.nodeType ?? "special",
44
+ executionClass: nodeRef?.executionClass ?? "special",
45
+ status: "pending",
46
+ unitIds: []
47
+ };
48
+ }
49
+ export function createEmptyExecutionTrace(args) {
50
+ const now = args.now ?? new Date().toISOString();
51
+ const plan = args.plan;
52
+ const runtime = args.runtime;
53
+ const nodeExecutions = {};
54
+ const unitExecutions = {};
55
+ for (const nodeId of collectAllPlanNodeIds(plan)) {
56
+ nodeExecutions[nodeId] = buildNodeTrace(plan, nodeId);
57
+ }
58
+ for (const nodePlan of Object.values(plan.nodePlans)) {
59
+ for (const unit of nodePlan.executionUnits) {
60
+ unitExecutions[unit.unitId] = buildUnitTrace(unit);
61
+ }
62
+ }
63
+ for (const finalizerPlan of Object.values(plan.finalizerPlans)) {
64
+ for (const unit of finalizerPlan.executionUnits) {
65
+ unitExecutions[unit.unitId] = buildUnitTrace(unit);
66
+ }
67
+ }
68
+ return {
69
+ format: EXECUTION_TRACE_FORMAT_V2,
70
+ traceId: args.traceId,
71
+ jobId: runtime.jobId,
72
+ createdAt: now,
73
+ status: "created",
74
+ source: {
75
+ graphId: plan.source.graphId,
76
+ graphRevision: plan.source.graphRevision,
77
+ graphHash: plan.source.graphHash,
78
+ authoringFormatVersion: plan.source.formatVersion
79
+ },
80
+ plan: buildTracePlanRef(plan),
81
+ runtime: {
82
+ jobId: runtime.jobId,
83
+ mode: runtime.mode,
84
+ environment: plan.runtimeBinding.environment,
85
+ inputHash: plan.runtimeBinding.inputHash,
86
+ contextHash: plan.runtimeBinding.contextHash,
87
+ variablesHash: plan.runtimeBinding.variablesHash,
88
+ agentId: runtime.job?.agentId,
89
+ jobTypeId: runtime.job?.jobTypeId
90
+ },
91
+ profileRegistry: plan.profileRegistry,
92
+ events: [
93
+ {
94
+ id: `evt:${args.traceId}:created`,
95
+ ts: now,
96
+ sequence: 0,
97
+ level: "info",
98
+ type: "graph.created",
99
+ message: "Execution trace created."
100
+ }
101
+ ],
102
+ graphExecution: {
103
+ startedNodeIds: [],
104
+ completedNodeIds: [],
105
+ failedNodeIds: [],
106
+ skippedNodeIds: [],
107
+ startedUnitIds: [],
108
+ completedUnitIds: [],
109
+ failedUnitIds: [],
110
+ skippedUnitIds: [],
111
+ finalizerNodeIds: plan.topology.finalizerNodeIds
112
+ },
113
+ gateEvaluations: {},
114
+ nodeExecutions,
115
+ unitExecutions,
116
+ modelInvocations: {},
117
+ memory: {
118
+ reads: [],
119
+ writes: []
120
+ },
121
+ diagnostics: {
122
+ dataPolicy: {
123
+ storeFullInputs: false,
124
+ storeFullOutputs: false,
125
+ storePrompts: false,
126
+ storeProviderResponses: false,
127
+ maxPreviewChars: 512,
128
+ requireDataRefsForLargeValues: true
129
+ }
130
+ }
131
+ };
132
+ }
133
+ //# sourceMappingURL=create-empty-execution-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-empty-execution-trace.js","sourceRoot":"","sources":["../../src/trace/create-empty-execution-trace.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AAEvC,SAAS,cAAc,CACrB,IAA0E;IAE1E,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,SAAS;QACjB,qBAAqB,EAAE,IAAI,CAAC,cAAc;QAC1C,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CACrB,IAA2B,EAC3B,MAAc;IAEd,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,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import type { GraphExecutionTrace } from "@x12i/graphenix-executable-contracts";
3
+ import type { GraphRuntimeObject } from "@x12i/graphenix-executable-contracts";
4
+ export declare function createExecutionTrace(plan: ExecutableGraphPlan, runtime: GraphRuntimeObject): GraphExecutionTrace;
5
+ //# sourceMappingURL=create-execution-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-execution-trace.d.ts","sourceRoot":"","sources":["../../src/trace/create-execution-trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,KAAK,EAEV,mBAAmB,EAEpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AA4B/E,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,kBAAkB,GAC1B,mBAAmB,CAgCrB"}
@@ -0,0 +1,53 @@
1
+ import { EXECUTION_TRACE_FORMAT } from "@x12i/graphenix-executable-contracts";
2
+ import { defaultHashFunction } from "@x12i/graphenix-executable-contracts";
3
+ function buildNodeExecutionTrace(nodePlan) {
4
+ const units = {};
5
+ for (const unit of nodePlan.executionUnits) {
6
+ units[unit.unitId] = {
7
+ unitId: unit.unitId,
8
+ nodeId: unit.nodeId,
9
+ unitKind: unit.unitKind,
10
+ status: "pending",
11
+ plannedModelSelection: unit.modelSelection
12
+ };
13
+ }
14
+ return {
15
+ nodeId: nodePlan.nodeId,
16
+ nodeType: nodePlan.nodeType,
17
+ status: "pending",
18
+ selectedCases: nodePlan.selectedCases,
19
+ units
20
+ };
21
+ }
22
+ export function createExecutionTrace(plan, runtime) {
23
+ const now = new Date().toISOString();
24
+ const planHash = defaultHashFunction(plan);
25
+ const nodeExecutions = {};
26
+ for (const nodePlan of Object.values(plan.nodePlans)) {
27
+ nodeExecutions[nodePlan.nodeId] = buildNodeExecutionTrace(nodePlan);
28
+ }
29
+ return {
30
+ format: EXECUTION_TRACE_FORMAT,
31
+ traceId: `trace:${runtime.jobId}`,
32
+ jobId: runtime.jobId,
33
+ createdAt: now,
34
+ status: "queued",
35
+ source: {
36
+ graphId: plan.source.graphId,
37
+ graphRevision: plan.source.graphRevision,
38
+ graphHash: plan.source.graphHash
39
+ },
40
+ plan: {
41
+ planId: plan.planId,
42
+ planHash
43
+ },
44
+ runtime: {
45
+ mode: runtime.mode,
46
+ environment: plan.runtimeBinding.environment,
47
+ inputHash: plan.runtimeBinding.inputHash
48
+ },
49
+ events: [],
50
+ nodeExecutions
51
+ };
52
+ }
53
+ //# sourceMappingURL=create-execution-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-execution-trace.js","sourceRoot":"","sources":["../../src/trace/create-execution-trace.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,SAAS,uBAAuB,CAC9B,QAAkD;IAElD,MAAM,KAAK,GAAuC,EAAE,CAAC;IAErD,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC3C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,SAAS;YACjB,qBAAqB,EAAE,IAAI,CAAC,cAAc;SAC3C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,MAAM,EAAE,SAAS;QACjB,aAAa,EAAE,QAAQ,CAAC,aAAa;QACrC,KAAK;KACN,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,IAAyB,EACzB,OAA2B;IAE3B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAuC,EAAE,CAAC;IAE9D,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACrD,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;IAED,OAAO;QACL,MAAM,EAAE,sBAAsB;QAC9B,OAAO,EAAE,SAAS,OAAO,CAAC,KAAK,EAAE;QACjC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,GAAG;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa;YACxC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;SACjC;QACD,IAAI,EAAE;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ;SACT;QACD,OAAO,EAAE;YACP,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,WAAW;YAC5C,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,SAAS;SACzC;QACD,MAAM,EAAE,EAAE;QACV,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ExecutionStatus, GraphExecutionTraceV2 } from "@x12i/graphenix-executable-contracts";
2
+ export declare function deriveGraphStatus(trace: GraphExecutionTraceV2): ExecutionStatus;
3
+ export declare function deriveNodeStatusFromUnits(trace: GraphExecutionTraceV2, nodeId: string): "pending" | "running" | "completed" | "failed" | "skipped";
4
+ //# sourceMappingURL=derive-graph-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive-graph-status.d.ts","sourceRoot":"","sources":["../../src/trace/derive-graph-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAM9C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,qBAAqB,GAAG,eAAe,CAsC/E;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,qBAAqB,EAC5B,MAAM,EAAE,MAAM,GACb,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CA+B5D"}