@exellix/graph-engine 7.2.10 → 7.2.14

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.
@@ -37,6 +37,22 @@ function isRunLogScope(x) {
37
37
  x === 'logxer' ||
38
38
  x === 'pipeline');
39
39
  }
40
+ /** Read promoted diagnostic fields without importing @x12i/logxer at module load. */
41
+ function normalizeRunLogDiagnostics(row) {
42
+ const data = row.data != null && typeof row.data === 'object' && !Array.isArray(row.data)
43
+ ? row.data
44
+ : undefined;
45
+ const codeRaw = row.code ?? data?.code;
46
+ const code = typeof codeRaw === 'string' && codeRaw.length > 0 ? codeRaw : undefined;
47
+ const diagRaw = row.diagnostics ?? data?.diagnostics;
48
+ const diagnostics = diagRaw != null && typeof diagRaw === 'object' && !Array.isArray(diagRaw)
49
+ ? diagRaw
50
+ : undefined;
51
+ return {
52
+ ...(code ? { code } : {}),
53
+ ...(diagnostics ? { diagnostics } : {}),
54
+ };
55
+ }
40
56
  /** Normalize @exellix/ai-tasks epoch-ms or ISO `ts` to epoch ms for exellix-graph `RunLogEntry`. */
41
57
  export function parseRunLogEntryTs(v) {
42
58
  if (typeof v === 'number' && Number.isFinite(v))
@@ -68,6 +84,11 @@ export function normalizeExternalRunLogEntries(raw) {
68
84
  ? r.correlationIds
69
85
  : undefined;
70
86
  const data = 'data' in r ? r.data : undefined;
87
+ const { code, diagnostics } = normalizeRunLogDiagnostics(r);
88
+ const debugKind = typeof r.debugKind === 'string' && r.debugKind.length > 0
89
+ ? r.debugKind
90
+ : undefined;
91
+ const evidence = Array.isArray(r.evidence) ? r.evidence : undefined;
71
92
  out.push({
72
93
  ts,
73
94
  level,
@@ -78,6 +99,10 @@ export function normalizeExternalRunLogEntries(raw) {
78
99
  ...(correlationIds ? { correlationIds } : {}),
79
100
  message,
80
101
  ...(data !== undefined ? { data } : {}),
102
+ ...(code ? { code } : {}),
103
+ ...(diagnostics ? { diagnostics } : {}),
104
+ ...(debugKind ? { debugKind } : {}),
105
+ ...(evidence?.length ? { evidence } : {}),
81
106
  });
82
107
  }
83
108
  return out;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Graph-engine Logxer integration (@x12i/logxer 4.5.x).
3
+ * Dynamic import avoids Node ESM loading CJS logxer trails → nanoid@5 ERR_REQUIRE_ESM on some runtimes.
4
+ */
5
+ import type { GetJobLogsInput, GetJobLogsResult, Logxer, LogRuntimeContext, StackLoggingOptions } from '@x12i/logxer';
6
+ import type { LogxerQueryableClient, RuntimeObjects } from './runtimeObjects.js';
7
+ /** Env prefix for package-level log level: `GRAPH_ENGINE_LOGS_LEVEL` (canonical). */
8
+ export declare const GRAPH_ENGINE_LOGXER_ENV_PREFIX: "GRAPH_ENGINE";
9
+ /** Factory for a graph-engine Logxer instance (logxer 4.5+ stack pass-through). */
10
+ export declare function createGraphEngineLogxer(options?: {
11
+ logging?: StackLoggingOptions;
12
+ }): Logxer;
13
+ /** Default process logger (env / host registry). Lazily created without stack overrides. */
14
+ export declare function getGraphEngineLogxer(): Logxer;
15
+ export declare function bindGraphEngineRunLogxer(instance: Logxer): void;
16
+ export declare function clearGraphEngineRunLogxer(): void;
17
+ export declare function createGraphEngineLogxerClient(instance?: Logxer): LogxerQueryableClient;
18
+ export declare function ensureGraphEngineLogxerOnRuntimeObjects(runtimeObjects: RuntimeObjects | undefined, instance?: Logxer): void;
19
+ export declare function runGraphWithLogContext<T>(ctx: LogRuntimeContext, fn: () => T | Promise<T>): Promise<T>;
20
+ export declare function patchGraphNodeLogContext(nodeId: string): void;
21
+ export declare function traceExecutionMemory(scope: 'executeNode' | 'executeGraph', message: string, data?: Record<string, unknown>): void;
22
+ export declare function logGraphEngineErrorCode(code: string, _message: string, ctx: {
23
+ graphId?: string;
24
+ nodeId?: string;
25
+ jobId?: string;
26
+ taskId?: string;
27
+ error?: unknown;
28
+ evidence?: Record<string, unknown>;
29
+ }): void;
30
+ export declare const DebugLogAbstract: {
31
+ readonly STATE: "STATE";
32
+ readonly INTENT: "INTENT";
33
+ readonly EVENT: "EVENT";
34
+ readonly TRACE: "TRACE";
35
+ readonly ANOMALY: "ANOMALY";
36
+ };
37
+ export declare const fieldEvidence: typeof import("@x12i/logxer").fieldEvidence;
38
+ export declare const exceptionEvidence: typeof import("@x12i/logxer").exceptionEvidence;
39
+ export declare const runWithLogContext: typeof import("@x12i/logxer").runWithLogContext;
40
+ export declare const patchLogContext: typeof import("@x12i/logxer").patchLogContext;
41
+ export type { GetJobLogsInput, GetJobLogsResult, LogRuntimeContext, StackLoggingOptions };
@@ -0,0 +1,155 @@
1
+ const logxer = await import('@x12i/logxer');
2
+ import { ExellixGraphErrorCode } from '../errors/exellixGraphErrorCodes.js';
3
+ import { EXELLIX_GRAPH_RUNTIME_PACKAGE_NAME } from './runtimeObjects.js';
4
+ /** Env prefix for package-level log level: `GRAPH_ENGINE_LOGS_LEVEL` (canonical). */
5
+ export const GRAPH_ENGINE_LOGXER_ENV_PREFIX = 'GRAPH_ENGINE';
6
+ const GRAPH_ENGINE_DIAGNOSTIC_CATALOG = {
7
+ [ExellixGraphErrorCode.GRAPH_ENTRY_DATA_FILTERS_REJECTED]: {
8
+ defaultLevel: 'error',
9
+ title: 'Graph entry data filters rejected',
10
+ impact: 'The graph run cannot start because structured entry filters did not accept runtime input.',
11
+ possibleCauses: [
12
+ 'metadata.graphEntry.dataFilters shape is unsupported or evaluated false.',
13
+ 'runtime.executionMemory.input is missing expected fields for the filter contract.',
14
+ ],
15
+ remediation: [
16
+ 'Inspect metadata.graphEntry.dataFilters against exellix.dataFilters.v1.',
17
+ 'Verify runtime.executionMemory.input before executeGraph.',
18
+ ],
19
+ retryable: false,
20
+ userActionRequired: true,
21
+ confidence: 'high',
22
+ },
23
+ [ExellixGraphErrorCode.MAIN_READINESS_FAILED]: {
24
+ defaultLevel: 'error',
25
+ title: 'MAIN task readiness failed',
26
+ impact: 'The node MAIN runTask call was blocked before ai-tasks could execute.',
27
+ possibleCauses: [
28
+ 'Execution input or synthesized context did not satisfy MAIN readiness policy.',
29
+ 'Required smartInput paths or memory buckets are empty.',
30
+ ],
31
+ remediation: [
32
+ 'Inspect taskNodeMainReadiness evaluation for the node.',
33
+ 'Verify executionMemory input and xynthesized seeding.',
34
+ ],
35
+ retryable: false,
36
+ userActionRequired: true,
37
+ confidence: 'high',
38
+ },
39
+ [ExellixGraphErrorCode.NODE_EXECUTION_FAILED]: {
40
+ defaultLevel: 'error',
41
+ title: 'Graph node execution failed',
42
+ impact: 'The node did not complete successfully; downstream nodes may be skipped.',
43
+ possibleCauses: [
44
+ 'runTask returned an error or threw.',
45
+ 'Local skill execution failed.',
46
+ 'Engine PRE/POST strategy utility failed.',
47
+ ],
48
+ remediation: [
49
+ 'Inspect node runLog lines and aiTasksObservability.',
50
+ 'Check runTask response error and metadata.runLog.',
51
+ ],
52
+ retryable: true,
53
+ userActionRequired: false,
54
+ confidence: 'medium',
55
+ },
56
+ [ExellixGraphErrorCode.GRAPH_EXECUTION_FAILED]: {
57
+ defaultLevel: 'error',
58
+ title: 'Graph execution failed',
59
+ impact: 'The graph run ended in a failed state.',
60
+ possibleCauses: [
61
+ 'One or more nodes failed under failFast or finalizer failure.',
62
+ 'Graph entry gate or finalizer validation failed.',
63
+ ],
64
+ remediation: [
65
+ 'Inspect ExecuteGraphResult.errors and runLog.',
66
+ 'Use runtimeObjects.logxerClient.getJobLogs for in-process diagnostics.',
67
+ ],
68
+ retryable: true,
69
+ userActionRequired: false,
70
+ confidence: 'medium',
71
+ },
72
+ };
73
+ let defaultLogxer;
74
+ /** Active logger for the current `executeGraph` run (falls back to {@link defaultLogxer}). */
75
+ let activeRunLogxer;
76
+ function buildGraphEngineLogxerConfig(logging) {
77
+ return {
78
+ runtimeIdentity: { service: 'graph-engine' },
79
+ diagnostics: {
80
+ catalog: GRAPH_ENGINE_DIAGNOSTIC_CATALOG,
81
+ },
82
+ ...(logging ? { stack: logging } : {}),
83
+ };
84
+ }
85
+ /** Factory for a graph-engine Logxer instance (logxer 4.5+ stack pass-through). */
86
+ export function createGraphEngineLogxer(options) {
87
+ return logxer.createLogxer({
88
+ packageName: EXELLIX_GRAPH_RUNTIME_PACKAGE_NAME,
89
+ envPrefix: GRAPH_ENGINE_LOGXER_ENV_PREFIX,
90
+ debugNamespace: 'graph-engine',
91
+ }, buildGraphEngineLogxerConfig(options?.logging));
92
+ }
93
+ /** Default process logger (env / host registry). Lazily created without stack overrides. */
94
+ export function getGraphEngineLogxer() {
95
+ if (!defaultLogxer) {
96
+ defaultLogxer = createGraphEngineLogxer();
97
+ }
98
+ return activeRunLogxer ?? defaultLogxer;
99
+ }
100
+ export function bindGraphEngineRunLogxer(instance) {
101
+ activeRunLogxer = instance;
102
+ }
103
+ export function clearGraphEngineRunLogxer() {
104
+ activeRunLogxer = undefined;
105
+ }
106
+ export function createGraphEngineLogxerClient(instance) {
107
+ const target = instance ?? getGraphEngineLogxer();
108
+ return {
109
+ getJobLogs(input) {
110
+ return target.getJobLogs(input);
111
+ },
112
+ };
113
+ }
114
+ export function ensureGraphEngineLogxerOnRuntimeObjects(runtimeObjects, instance) {
115
+ if (!runtimeObjects || runtimeObjects.logxerClient != null)
116
+ return;
117
+ runtimeObjects.logxerClient = createGraphEngineLogxerClient(instance);
118
+ }
119
+ export function runGraphWithLogContext(ctx, fn) {
120
+ return logxer.runWithLogContext(ctx, fn);
121
+ }
122
+ export function patchGraphNodeLogContext(nodeId) {
123
+ logxer.patchLogContext({ nodeId });
124
+ }
125
+ export function traceExecutionMemory(scope, message, data) {
126
+ if (process.env.DEBUG_EXECUTION_MEMORY !== 'true' &&
127
+ process.env.DEBUG_OUTPUT_MAPPING !== 'true') {
128
+ return;
129
+ }
130
+ getGraphEngineLogxer().verbose(message, {
131
+ scope,
132
+ ...data,
133
+ debugKind: logxer.DebugLogAbstract.STATE,
134
+ });
135
+ }
136
+ export function logGraphEngineErrorCode(code, _message, ctx) {
137
+ const instance = getGraphEngineLogxer();
138
+ const evidence = [
139
+ ...(ctx.error != null ? [logxer.exceptionEvidence(ctx.error)] : []),
140
+ ...Object.entries(ctx.evidence ?? {}).map(([path, value]) => logxer.fieldEvidence(path, value)),
141
+ ];
142
+ instance.errorCode(code, {
143
+ graphId: ctx.graphId,
144
+ nodeId: ctx.nodeId,
145
+ jobId: ctx.jobId,
146
+ taskId: ctx.taskId,
147
+ debugKind: logxer.DebugLogAbstract.ANOMALY,
148
+ ...(evidence.length ? { evidence } : {}),
149
+ });
150
+ }
151
+ export const DebugLogAbstract = logxer.DebugLogAbstract;
152
+ export const fieldEvidence = logxer.fieldEvidence;
153
+ export const exceptionEvidence = logxer.exceptionEvidence;
154
+ export const runWithLogContext = logxer.runWithLogContext;
155
+ export const patchLogContext = logxer.patchLogContext;
@@ -28,5 +28,6 @@ export function mergeExellixGraphRuntimeInvocation(input, opts) {
28
28
  runtimeObjects: input.runtimeObjects ?? opts.runtimeObjects,
29
29
  stepRetryPolicy: input.stepRetryPolicy ?? opts.stepRetryPolicy,
30
30
  mainReadinessPolicy: input.mainReadinessPolicy ?? opts.mainReadinessPolicy,
31
+ logging: input.logging ?? opts.logging,
31
32
  };
32
33
  }
@@ -2,6 +2,7 @@
2
2
  * Runtime Objects Observability — types and composition for graph + downstream packages.
3
3
  * Callers (playground, UIs) use {@link RuntimeObjects} and queryable clients instead of reading Mongo directly.
4
4
  */
5
+ import type { GetJobLogsInput, GetJobLogsResult, QueryableLogLine } from '@x12i/logxer';
5
6
  /** Published npm name of this package (root layer in composed observability). */
6
7
  export declare const EXELLIX_GRAPH_RUNTIME_PACKAGE_NAME: "@exellix/graph-engine";
7
8
  /** Task layer package name in {@link RuntimeObjects.packagesRuntimeObjects}. */
@@ -18,25 +19,11 @@ export type ActivixQueryableClient = {
18
19
  activities: unknown[];
19
20
  }>;
20
21
  };
21
- export type LogxerLogLine = {
22
- ts?: number | string;
23
- level?: 'debug' | 'info' | 'warn' | 'error';
24
- scope?: string;
25
- packageName?: string;
26
- nodeId?: string;
27
- message: string;
28
- data?: unknown;
29
- };
22
+ /** Structured log envelope from `@x12i/logxer` `getJobLogs` (4.5.x). */
23
+ export type LogxerLogLine = QueryableLogLine;
24
+ /** Query surface aligned with `@x12i/logxer` `Logxer.getJobLogs` (diagnostic filters included). */
30
25
  export type LogxerQueryableClient = {
31
- getJobLogs(input: {
32
- jobId: string;
33
- graphId?: string;
34
- nodeId?: string;
35
- limit?: number;
36
- }): Promise<{
37
- jobId: string;
38
- lines: LogxerLogLine[];
39
- }>;
26
+ getJobLogs(input: GetJobLogsInput): Promise<GetJobLogsResult>;
40
27
  };
41
28
  export type PackageRuntimeObjects = {
42
29
  name: string;
@@ -1,7 +1,3 @@
1
- /**
2
- * Runtime Objects Observability — types and composition for graph + downstream packages.
3
- * Callers (playground, UIs) use {@link RuntimeObjects} and queryable clients instead of reading Mongo directly.
4
- */
5
1
  /** Published npm name of this package (root layer in composed observability). */
6
2
  export const EXELLIX_GRAPH_RUNTIME_PACKAGE_NAME = '@exellix/graph-engine';
7
3
  /** Task layer package name in {@link RuntimeObjects.packagesRuntimeObjects}. */
@@ -1,4 +1,5 @@
1
1
  import type { Activix } from '@x12i/activix';
2
+ import type { StackLoggingOptions } from '@x12i/logxer';
2
3
  import type { LlmCallConfig, RunTaskRequest as AiTasksRunTaskRequest, RunTaskResponse as AiTasksRunTaskResponse } from '@exellix/ai-tasks';
3
4
  import type { GraphModelAliasConfig, ModelConfigSelection, TaskNodeRuntimeObject } from './refs.js';
4
5
  import type { RuntimeObjects } from '../runtime/runtimeObjects.js';
@@ -79,6 +80,11 @@ export interface HostExecuteGraphRunOptions {
79
80
  * Node `taskConfiguration.mainReadinessPolicy` overrides. Default `off`.
80
81
  */
81
82
  mainReadinessPolicy?: MainReadinessPolicy;
83
+ /**
84
+ * Logxer 4.5+ stack pass-through (`GRAPH_ENGINE` and optional downstream package prefixes).
85
+ * Merged: per-invocation input → `createExellixGraphRuntime` defaults.
86
+ */
87
+ logging?: StackLoggingOptions;
82
88
  }
83
89
  /**
84
90
  * Optional Activix-backed persistence for per-node execution rows.
@@ -2,6 +2,7 @@
2
2
  * Structured run log for execution consoles (playground, Activix, HTTP APIs).
3
3
  * @see `.docs/exellix-graph-format.md` — Layer 08 / run log contract.
4
4
  */
5
+ import type { DebugLogKind, DiagnosticEvidence, LogDiagnostics } from '@x12i/logxer';
5
6
  /**
6
7
  * NOTE: `@exellix/ai-tasks` 5.5+ no longer exports `RunLogCorrelationIds`.
7
8
  * We preserve the field for downstream consumers but keep it structurally typed.
@@ -28,6 +29,14 @@ export interface RunLogEntry {
28
29
  message: string;
29
30
  /** Optional structured payload; may be truncated (see buildRunLog / runtime options). */
30
31
  data?: unknown;
32
+ /** Diagnostic catalog code when merged from Logxer / ai-tasks metadata (@x12i/logxer 4.5.x). */
33
+ code?: string;
34
+ /** Structured diagnostic context (@x12i/logxer 4.5.x). */
35
+ diagnostics?: LogDiagnostics;
36
+ /** Semantic debug category (@x12i/logxer DebugLogAbstract). */
37
+ debugKind?: DebugLogKind;
38
+ /** Small diagnostic evidence samples (@x12i/logxer 4.5.x). */
39
+ evidence?: DiagnosticEvidence[];
31
40
  }
32
41
  /** How aggressively to populate `runLog` on {@link ExecuteGraphResult}. */
33
42
  export type RunLogMode = 'off' | 'summary' | 'full';
@@ -1,7 +1,3 @@
1
- /**
2
- * Structured run log for execution consoles (playground, Activix, HTTP APIs).
3
- * @see `.docs/exellix-graph-format.md` — Layer 08 / run log contract.
4
- */
5
1
  /**
6
2
  * Canonical key on `runTask` response metadata for buffered run-log lines.
7
3
  * 5.x: only this key is read; the legacy `exellixRunLog` alias is no longer accepted.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exellix/graph-engine",
3
- "version": "7.2.10",
3
+ "version": "7.2.14",
4
4
  "type": "module",
5
5
  "description": "Graph executor SDK",
6
6
  "main": "dist/src/index.js",
@@ -25,7 +25,7 @@
25
25
  "scripts": {
26
26
  "prebuild": "node scripts/clean-dist.mjs",
27
27
  "build": "tsc",
28
- "test": "npm run build && npm run check:no-legacy && tsx --test --test-force-exit tests/model-alias-contract.test.ts tests/reports-fixtures-pre-synthesis.test.ts tests/passthrough-parity.test.ts tests/step-retry-llm-call.test.ts",
28
+ "test": "npm run build && npm run check:no-legacy && tsx --test --test-force-exit tests/model-alias-contract.test.ts tests/reports-fixtures-pre-synthesis.test.ts tests/passthrough-parity.test.ts tests/step-retry-llm-call.test.ts tests/run-log-diagnostics.test.ts",
29
29
  "test:full": "npm run build && npm run check:no-legacy && tsx --test --test-force-exit tests/graph-engine.test.ts tests/passthrough-parity.test.ts tests/task-node-run-task-preflight.test.ts tests/reports-fixtures-pre-synthesis.test.ts tests/model-alias-contract.test.ts tests/step-retry-llm-call.test.ts",
30
30
  "test:live": "npm run run:pre-synthesis",
31
31
  "run:pre-synthesis": "npm run build && node --env-file=.env scripts/run-pre-synthesis-graph.mjs",
@@ -50,19 +50,19 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@exellix/ai-tasks": "^8.1.10",
53
+ "@exellix/ai-tasks": "^8.1.12",
54
54
  "@x12i/activix": "8.3.1",
55
55
  "@x12i/ai-profiles": "1.6.0",
56
56
  "@x12i/catalox": "5.1.1",
57
57
  "@x12i/env": "4.0.1",
58
- "@x12i/funcx": "4.2.0",
58
+ "@x12i/funcx": "4.2.2",
59
59
  "@x12i/graphenix": "2.5.0",
60
60
  "@x12i/graphenix-format": "2.0.0",
61
- "@x12i/logxer": "4.4.0",
61
+ "@x12i/logxer": "^4.5.0",
62
62
  "@x12i/memorix-descriptors": "1.6.0",
63
- "@x12i/memorix-retrieval": "1.10.0",
63
+ "@x12i/memorix-retrieval": "1.11.0",
64
64
  "@x12i/memorix-writer": "1.0.0",
65
- "@x12i/optimixer": "^2.4.1",
65
+ "@x12i/optimixer": "^2.4.2",
66
66
  "@x12i/rendrix": "4.3.0",
67
67
  "@x12i/runx": "1.3.0"
68
68
  },