@exellix/exellix-runtime 3.5.1 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +6 -5
  2. package/dist/execution-matrix/activity-record-adapters.d.ts +74 -0
  3. package/dist/execution-matrix/activity-record-adapters.d.ts.map +1 -0
  4. package/dist/execution-matrix/activity-record-adapters.js +248 -0
  5. package/dist/execution-matrix/activity-record-adapters.js.map +1 -0
  6. package/dist/execution-matrix/activity-record-adapters.spec.d.ts +2 -0
  7. package/dist/execution-matrix/activity-record-adapters.spec.d.ts.map +1 -0
  8. package/dist/execution-matrix/activity-record-adapters.spec.js +114 -0
  9. package/dist/execution-matrix/activity-record-adapters.spec.js.map +1 -0
  10. package/dist/execution-matrix/execution-matrix.spec.js +13 -12
  11. package/dist/execution-matrix/execution-matrix.spec.js.map +1 -1
  12. package/dist/execution-matrix/graph-engine-preflight-reexport.spec.d.ts +2 -0
  13. package/dist/execution-matrix/graph-engine-preflight-reexport.spec.d.ts.map +1 -0
  14. package/dist/execution-matrix/graph-engine-preflight-reexport.spec.js +14 -0
  15. package/dist/execution-matrix/graph-engine-preflight-reexport.spec.js.map +1 -0
  16. package/dist/execution-matrix/index.d.ts +9 -1
  17. package/dist/execution-matrix/index.d.ts.map +1 -1
  18. package/dist/execution-matrix/index.js +8 -1
  19. package/dist/execution-matrix/index.js.map +1 -1
  20. package/dist/execution-matrix/job-activity-rollup.d.ts +56 -0
  21. package/dist/execution-matrix/job-activity-rollup.d.ts.map +1 -0
  22. package/dist/execution-matrix/job-activity-rollup.js +185 -0
  23. package/dist/execution-matrix/job-activity-rollup.js.map +1 -0
  24. package/dist/execution-matrix/materializer.d.ts +1 -1
  25. package/dist/execution-matrix/materializer.js +1 -1
  26. package/dist/execution-matrix/orchestrator.d.ts.map +1 -1
  27. package/dist/execution-matrix/orchestrator.js +39 -1
  28. package/dist/execution-matrix/orchestrator.js.map +1 -1
  29. package/package.json +4 -2
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **Integrating a BFF or worker?** → **[docs/client-integration.md](docs/client-integration.md)** (install, Mongo, reads, jobs HTTP, checklist) · **[docs/graph-execution-record-placement.md](docs/graph-execution-record-placement.md)** (record → `runtime.input` only) · **[docs/README.md](docs/README.md)** (full index)
4
4
 
5
- TypeScript runtime for **orchestrating Exellix graph execution at scale**: an **execution matrix** ties many inputs (from xmemory) to one or more graphs, tracks per-graph lifecycle (`not-started` → `in-progress` → `completed` | `failed` | `skipped`), stores successful **inferences** on the row document, and records **failures** in a separate collection. Design-time matrix definitions live in **Catalox**; durable execution state lives in **MongoDB** (matrix rows, failures, snapshots, and config collections — opened via **`createExellixMatrixDataTier`** from this package; **`@exellix/exellix-jobs`** composes **this** package for worker semantics). Individual graph runs go through **@exellix/graph-engine** (this package depends on **`^5.14.0`**; `createExellixGraphRuntime().executeGraph` receives `{ model: GraphModelObject, runtime: GraphRuntimeObject }`, and `MatrixGraphExecuteOverrides` is the optional runtime layer after the matrix supplies `jobId`, `job`, `input`, and `executionMemory`).
5
+ TypeScript runtime for **orchestrating Exellix graph execution at scale**: an **execution matrix** ties many inputs (from xmemory) to one or more graphs, tracks per-graph lifecycle (`not-started` → `in-progress` → `completed` | `failed` | `skipped`), stores successful **inferences** on the row document, and records **failures** in a separate collection. Design-time matrix definitions live in **Catalox**; durable execution state lives in **MongoDB** (matrix rows, failures, snapshots, and config collections — opened via **`createExellixMatrixDataTier`** from this package; **`@exellix/exellix-jobs`** composes **this** package for worker semantics). Individual graph runs go through **@exellix/graph-engine** (this package depends on **`^6.0.1`**; `createExellixGraphRuntime().executeGraph` receives `{ model: GraphModelObject, runtime: GraphRuntimeObject }`, and `MatrixGraphExecuteOverrides` is the optional runtime layer after the matrix supplies `jobId`, `job`, `input`, and `executionMemory`).
6
6
 
7
7
  **Why keep this package:** **`@exellix/exellix-jobs`** (worker deployable) wraps claims and operator HTTP. **Read dashboards** and **Mongo wiring** live here too (**`openMatrixReadTier`**, **`createExellixMatrixDataTier`**). The **domain** — contracts, materialization, orchestration, Memorix bridge, eligibility — is centralized in **`@exellix/exellix-runtime`**.
8
8
 
@@ -35,7 +35,7 @@ flowchart LR
35
35
  1. **Catalox** — **Matrix** template (`metadata.catalogType: "execution-matrix"`): `data.input`, `data.graphs[]` (references to graph ids). **Graph** definitions (e.g. catalog `exellix-graphs`, `metadata.catalogType: "graphs"`): `data.graphId`, `data.mappedInput[]`, `data.execution` (`priority`, optional `conditions` / `conditionRelations`). See [docs/execution-matrix-runtime.md](docs/execution-matrix-runtime.md). Repo-local seed example: `npm run use-case:create-exellix-graphs-catalog`.
36
36
  2. **xmemory** — Your host resolves selectors into concrete `input` rows (`XmemoryInputResolver` in code).
37
37
  3. **Mongo matrix collections** — `exellix_execution_matrix_rows` and `exellix_execution_matrix_failures` (and related config collections) hold runtime rows, statuses, inferences, and failure payloads. Open them with **`createExellixMatrixDataTier`** from **`@exellix/exellix-runtime`** — hosts should not wire **`@x12i/xronox-store`** directly.
38
- 4. **Executable graphs** — DAG JSON must satisfy graph-engine **5.14.x** canonical rules (see **`assertCanonicalGraphDocument`**). **Model root:** **`id`**, optional **`version`**, **`modelConfig`** (`{ cases: [{ modelConfig, when? }] }`), **`jobKnowledge`**, **`nodes`**, optional **`edges`**, **`variables`**, required root **`response`**, optional **`metadata`** (design-time fields such as **`graphEntry`** live under **`metadata`** only). **`nodes`** must be a **`GraphNode[]` array** (record-keyed maps are rejected). **Task nodes:** **`skillKey`** / **`variables`** on the node root; payload bindings in **`inputsConfig`**; prompts and variable hooks in **`taskVariable`** (deprecated: **`node.inputs`**). **Execution wiring** (`narrix`, **`aiTaskProfile`** / **`webScoping`**, **`executionStrategies`**, **`aiTasksOutputValidation`**, **`modelConfig`**, **`llmCall`**, local-skill paths, …) belongs under **`taskConfiguration`**, not **`metadata`**. **Runtime:** `runtime.input` → `executionMemory.input`; optional **`runtime.inputs`** is a separate caller bag on **`RunTaskRequest.inputs`**. **Variables:** job/graph bucket **`jobVariables.*`** (alias `variables.*`); task bucket **`taskVariables.*`** (see [docs/format/](docs/format/)). Author web retrieval under **`taskConfiguration.aiTaskProfile.webScoping`** only. Layer-01 seeding: **`buildExecutionSeedFromGraphEntry`** (delegates to graph-engine). Memorix Layer-01: **`loadGraphEntryMemorixPayload`** + **`buildExecutionSeedWithMemorixLayer`**. Structured gates: **`evaluateStructuredDataFilters`**. Run-log metadata on task responses: **`runLog`**, **`logxerRunId`** only. Narrative: [docs/exellix-graph-format.md](docs/exellix-graph-format.md) · typed contracts: [docs/format/graph-model-object-format.md](docs/format/graph-model-object-format.md).
38
+ 4. **Executable graphs** — DAG JSON must satisfy graph-engine **6.x** canonical rules (see **`assertCanonicalGraphDocument`**). **Model root:** **`id`**, optional **`version`**, **`modelConfig`** (`{ cases: [{ modelConfig, when? }] }`), **`jobKnowledge`**, **`nodes`**, optional **`edges`**, **`variables`**, required root **`response`**, optional **`metadata`** (design-time fields such as **`graphEntry`** live under **`metadata`** only). **`nodes`** must be a **`GraphNode[]` array** (record-keyed maps are rejected). **Task nodes:** **`skillKey`** / **`variables`** on the node root; payload bindings in **`inputsConfig`**; prompts and variable hooks in **`taskVariable`** (deprecated: **`node.inputs`**). **Execution wiring** (`narrix`, **`aiTaskProfile`** / **`webScoping`**, **`executionStrategies`**, **`aiTasksOutputValidation`**, **`modelConfig`**, **`llmCall`**, local-skill paths, …) belongs under **`taskConfiguration`**, not **`metadata`**. **Runtime:** flat fields on **`runtime.input`** only (graph-engine ≥ 5.16 does not promote `job.raw` → `input.raw`); see [docs/graph-execution-record-placement.md](docs/graph-execution-record-placement.md). `runtime.input` → `executionMemory.input`; optional **`runtime.inputs`** is a separate caller bag on **`RunTaskRequest.inputs`**. **Variables:** job/graph bucket **`jobVariables.*`** (alias `variables.*`); task bucket **`taskVariables.*`** (see [docs/format/](docs/format/)). Author web retrieval under **`taskConfiguration.aiTaskProfile.webScoping`** only. Layer-01 seeding: **`buildExecutionSeedFromGraphEntry`** (delegates to graph-engine). Memorix Layer-01: **`loadGraphEntryMemorixPayload`** + **`buildExecutionSeedWithMemorixLayer`**. Structured gates: **`evaluateStructuredDataFilters`**. Run-log metadata on task responses: **`runLog`**, **`logxerRunId`** only. Narrative: [docs/exellix-graph-format.md](docs/exellix-graph-format.md) · typed contracts: [docs/format/graph-model-object-format.md](docs/format/graph-model-object-format.md).
39
39
 
40
40
  ## Related packages
41
41
 
@@ -291,9 +291,10 @@ Loads repo **`.env`** then **`.env.test`** (test-only smoke ids — never produc
291
291
  | Collections | `executionMatrixStoreCollectionDefs`, collection name constants | Used by **`createExellixMatrixDataTier`** / internal wiring |
292
292
  | Persistence | `ExecutionMatrixRuntime`, `createExecutionMatrixRuntime` | CRUD, claims, completion, **`listFailureRecords`** / **`getFailureRecord`** / **`getLatestFailureRecordForRowGraph`**, **`batchLookupSourceExecutionStatuses`** |
293
293
  | Catalox | `parseExecutionMatrixCatalogPayload`, `executionMatrixPayloadFromCatalogItem`, `parseGraphCatalogPayload`, `graphCatalogPayloadFromCatalogItem` | Validate / parse matrix + graph catalog `data` |
294
- | Materialization | `materializeExecutionMatrixRuntimeRows`, `sortGraphRecordsForMatrix`, `mergeMappedInputEntries`, `buildExecutionSeedFromGraphEntry`, `resolveInputRowsWithResolver`; re-exported `resolveGraphEntryFromGraph`, `createResolveGraphEntryFromLoader`, `validateExecutionSeedPaths`, types `BuildExecutionSeedSources` / `BuildExecutionSeedResult` | Rows from matrix + graph records; **`buildExecutionSeedFromGraphEntry`** delegates to **`@exellix/graph-engine`** (same Layer-01 path rules; matrix row `input``execution.input.*`); optional **`runtimeScope`** on materialize + resolver for tenant/xmemory alignment |
294
+ | Materialization | `materializeExecutionMatrixRuntimeRows`, `sortGraphRecordsForMatrix`, `mergeMappedInputEntries`, `buildExecutionSeedFromGraphEntry`, `resolveInputRowsWithResolver`; re-exported `resolveGraphEntryFromGraph`, `createResolveGraphEntryFromLoader`, `validateExecutionSeedPaths`, types `BuildExecutionSeedSources` / `BuildExecutionSeedResult` | Rows from matrix + graph records; **`buildExecutionSeedFromGraphEntry`** delegates to **`@exellix/graph-engine`** (Layer-01 paths such as **`input`** for the flat MAIN bucket — not legacy **`input.raw`**); matrix row fields**`runtime.input`**; optional **`runtimeScope`** on materialize + resolver for tenant/xmemory alignment |
295
+ | **RunTask preflight** | **`buildTaskNodeRunTaskRequest`**, **`validateTaskNodeRunTaskConfig`**, **`validateTaskNodeRunTaskInvoke`**, **`analyzeTaskNodeRunTaskRequest`**, **`validateRunTaskConfig`**, **`analyzeRunTaskRequest`**, … | Re-exported from **`@exellix/graph-engine`** 6.x — BFF/CI validation without a second import; unit tests: [`graph-engine-preflight-reexport.spec.ts`](src/execution-matrix/graph-engine-preflight-reexport.spec.ts) |
295
296
  | **Graph entry + Memorix (scoper)** | **`loadGraphEntryMemorixPayload`**, **`buildExecutionSeedWithMemorixLayer`**, **`GraphEntryXmemoryLoadCodes`**, request union types (`mode`: **`scoped-data-row`**, **`scoped-data-by-source-key`**, **`narrative`**, **`snapshot-scoped-data`**) | Loads Layer-01 artifacts via **`@x12i/xmemory-scoper`** only (no raw **`xmemory-store`** reads for entity bodies in this helper). Modes: entity+question (`getXScopedDataByEntityAndQuestionId`), entity type + source/document id (`getXScopedDataDocumentBySourceKey`), narrative (`getScopedAnswer` / `getScopedAnswerWithContext`), snapshot (`getScopedDataFromSnapshot`). Merge with matrix **`input`** using **`buildExecutionSeedWithMemorixLayer`**. Unit tests: [`graph-entry-xmemory-load.spec.ts`](src/execution-matrix/graph-entry-xmemory-load.spec.ts) |
296
- | **Structured `dataFilters`** | **`evaluateStructuredDataFilters`**, **`evaluateDataFilterPredicate`**, **`getStructuredDataFilterPathViolations`**, **`isStructuredDataFiltersV1`**, **`EXELLIX_STRUCTURED_DATA_FILTERS_V1`**, types **`EvaluateStructuredDataFiltersResult`**, **`EvaluateStructuredDataFiltersOptions`**, **`StructuredDataFiltersV1`**, **`ConditionsDataFilters`** | Re-exported from **`@exellix/graph-engine`** (≥ **5.3.8**, aligned with **5.14.x**) — same semantics as the executor for graph-entry / task **`conditions.dataFilters`**. Pass the **scoped `data` payload** as **`record`** (the object whose properties back `data.*` paths). Unit tests: [`graph-engine-datafilters-reexport.spec.ts`](src/execution-matrix/graph-engine-datafilters-reexport.spec.ts) |
297
+ | **Structured `dataFilters`** | **`evaluateStructuredDataFilters`**, **`evaluateDataFilterPredicate`**, **`getStructuredDataFilterPathViolations`**, **`isStructuredDataFiltersV1`**, **`EXELLIX_STRUCTURED_DATA_FILTERS_V1`**, types **`EvaluateStructuredDataFiltersResult`**, **`EvaluateStructuredDataFiltersOptions`**, **`StructuredDataFiltersV1`**, **`ConditionsDataFilters`** | Re-exported from **`@exellix/graph-engine`** (≥ **5.3.8**, aligned with **6.x**) — same semantics as the executor for graph-entry / task **`conditions.dataFilters`**. Pass the **scoped `data` payload** as **`record`** (the object whose properties back `data.*` paths). Unit tests: [`graph-engine-datafilters-reexport.spec.ts`](src/execution-matrix/graph-engine-datafilters-reexport.spec.ts) |
297
298
  | Orchestration | `processNextMatrixClaim`, `processMatrixClaimForRow`, `claimNextAcrossGraphs`, `processMatrixGraphBatch`, `processNextMatrixGraphExecution`, `processAllMatrixGraphExecutions`, `executeMatrixGraphForClaim`, `mergeClaimExtraFilter`, `mergeMatrixGraphExecuteOverrides`, **`createMatrixExecuteGraphAdapter`**, **`OrchestratorExecuteGraphInput`** | Claim → choose **mode** (runtime: external `jobId`, optional `debugMode: true`; autonomous: generated stable `jobId`) → resolve `GraphModelObject` → build `GraphRuntimeObject` → single **`executeGraph({ model, runtime })`** call → persist; optional **`runtimeScope`** on deps merges into `extraFilter`; optional **`executeOverrides`** merge into `runtime` only |
298
299
  | Source resolver | **`createMatrixSourceResolverFromRecordLikeDataSource`**, **`createMatrixSourceResolverFromEffectiveConfig`**, **`diffSourceIdsAgainstMatrix`**, **`DEFAULT_MATRIX_SOURCE_LIST_CAP`** | Wire `record` / `query-snapshot` sources for `fetchSourceJoinView` / run loop; `event` / `storage` need custom resolvers |
299
300
  | UI / BFF (read dashboards) | **`openMatrixReadTier`** → `graphDashboard`, `multiGraphOverview`, `sourceJoinView`, `navigatorPage`, `entityFacet`, **`listFailureRecords`**, **`getFailureRecord`** ([client-integration.md](docs/client-integration.md)). **Lower-level:** `fetchExecutionMatrixNavigatorPage`, `fetchSourceJoinView`, `runtime.listFailureRecords`, … when you already hold **`ExecutionMatrixRuntime`** |
@@ -395,7 +396,7 @@ dist/ # build output (gitignored in typical setups)
395
396
 
396
397
  ## Dependencies (summary)
397
398
 
398
- - **`@exellix/graph-engine` ^5.14.0** — Injected **`createExellixGraphRuntime().executeGraph`** receives **`ExecuteGraphInput = { model: GraphModelObject, runtime: GraphRuntimeObject }`**. **Graph JSON:** array **`nodes`**; required root **`response`**; **`modelConfig`** / task overrides as **`{ cases: [...] }`**; task **`inputsConfig`** + **`taskVariable`** (not legacy **`node.inputs`**); execution config under **`taskConfiguration`**; planning-only **`metadata`**. **Runtime:** `input` vs `inputs` are distinct; variable buckets **`jobVariables.*`** / **`taskVariables.*`**. **`evaluateStructuredDataFilters`** matches executor semantics for structured gates. `MatrixGraphExecuteOverrides` merges into `runtime` (`modelConfig` as `ModelConfigSelection` or flat `{ xynthesisModel, skillModel }`, `aliasConfig`, `nodes`, memory bags, run-log options, …). This repo wraps **`buildExecutionSeedFromGraphEntry`**, re-exports model/runtime types and matrix host helpers, and documents contracts under **[docs/format/](docs/format/)**. Run-log metadata on mocked **`runTask`** responses: **`runLog`**, **`logxerRunId`** only.
399
+ - **`@exellix/graph-engine` ^6.0.1** — Injected **`createExellixGraphRuntime().executeGraph`** receives **`ExecuteGraphInput = { model: GraphModelObject, runtime: GraphRuntimeObject }`**. **Graph JSON:** array **`nodes`**; required root **`response`**; **`modelConfig`** / task overrides as **`{ cases: [...] }`**; task **`inputsConfig`** + **`taskVariable`** (not legacy **`node.inputs`**); execution config under **`taskConfiguration`**; planning-only **`metadata`**. **Runtime:** `input` vs `inputs` are distinct; variable buckets **`jobVariables.*`** / **`taskVariables.*`**. **`evaluateStructuredDataFilters`** matches executor semantics for structured gates. `MatrixGraphExecuteOverrides` merges into `runtime` (`modelConfig` as `ModelConfigSelection` or flat `{ xynthesisModel, skillModel }`, `aliasConfig`, `nodes`, memory bags, run-log options, …). This repo wraps **`buildExecutionSeedFromGraphEntry`**, re-exports model/runtime types and matrix host helpers, and documents contracts under **[docs/format/](docs/format/)**. Run-log metadata on mocked **`runTask`** responses: **`runLog`**, **`logxerRunId`** only.
399
400
  - **`openMatrixReadTier`** (this package, **3.1+**) — read dashboards; used by **`npm run matrix-read:smoke`**. Replaces **`@exellix/exellix-matrix-read`**.
400
401
  - **`createExellixMatrixDataTier`** (this package, **3.1+**) — Mongo matrix + config collections; replaces **`@exellix/exellix-matrix-persister`**.
401
402
  - **`@x12i/xmemory-store` ^2.9.8** — Declared dependency (tier factories, statistics, scoped-data reads); re-exported from [`src/execution-matrix/index.ts`](src/execution-matrix/index.ts) for one import surface. Required for the matrix-read smoke script when enabling Memorix (`MATRIX_READ_MEMORIX_ENABLED=true`).
@@ -0,0 +1,74 @@
1
+ import type { ActivixCostShape } from '@x12i/activix';
2
+ /** Normalized token usage for one gateway / skill activity row. */
3
+ export type ActivityUsageView = {
4
+ promptTokens?: number;
5
+ completionTokens?: number;
6
+ totalTokens?: number;
7
+ cachedPromptTokens?: number;
8
+ reasoningTokens?: number;
9
+ costUsd?: number;
10
+ costStatus?: 'priced' | 'unpriced';
11
+ maxTokensRequested?: number;
12
+ isByok?: boolean;
13
+ };
14
+ /** Configured vs routed model fields on an activity row. */
15
+ export type ActivityModelView = {
16
+ configuredModel?: string;
17
+ modelUsed?: string;
18
+ /** `modelUsed` when set, otherwise `model` from metadata / response / config. */
19
+ effectiveModel?: string;
20
+ provider?: string;
21
+ };
22
+ export type ActivityTimingView = {
23
+ startTime?: number;
24
+ endTime?: number;
25
+ durationMs?: number;
26
+ status?: string;
27
+ };
28
+ /** Convenience bundle for dashboards and matrix rollups. */
29
+ export type ActivityRecordView = {
30
+ activityId?: string;
31
+ jobId?: string;
32
+ graphId?: string;
33
+ nodeId?: string;
34
+ activityType?: string;
35
+ status?: string;
36
+ hasResponse: boolean;
37
+ model: ActivityModelView;
38
+ usage: ActivityUsageView;
39
+ timing: ActivityTimingView;
40
+ };
41
+ export type ActivixActivityRecord = Record<string, unknown>;
42
+ /**
43
+ * Gateway completion payloads may be stored as `outer.output` (ai-gateway) or
44
+ * `outer.output.response` (nested envelope from some graph runtimes).
45
+ */
46
+ export declare function resolveActivityGatewayResponse(doc: ActivixActivityRecord): Record<string, unknown> | undefined;
47
+ /**
48
+ * Token + cost usage for one activity (prefers Activix `outer.cost`, then gateway `usage`).
49
+ */
50
+ export declare function resolveActivityUsage(doc: ActivixActivityRecord): ActivityUsageView;
51
+ /**
52
+ * Resolved model for an activity: prefers authoritative `modelUsed`, then `model`.
53
+ */
54
+ export declare function resolveActivityModel(doc: ActivixActivityRecord): ActivityModelView;
55
+ /** Lifecycle timing from Activix-owned top-level fields. */
56
+ export declare function resolveActivityTiming(doc: ActivixActivityRecord): ActivityTimingView;
57
+ export declare function resolveActivityHasResponse(doc: ActivixActivityRecord): boolean;
58
+ /**
59
+ * Full normalized read model for one persisted Activix / gateway activity document.
60
+ */
61
+ export declare function resolveActivityRecordView(doc: ActivixActivityRecord): ActivityRecordView;
62
+ /** Maps a rollup or single activity usage view to Activix `outer.cost`. */
63
+ export declare function toActivixCostShape(input: {
64
+ costUsd?: number;
65
+ promptTokens?: number;
66
+ completionTokens?: number;
67
+ totalTokens?: number;
68
+ reasoningTokens?: number;
69
+ provider?: string;
70
+ model?: string;
71
+ costStatus?: 'priced' | 'unpriced';
72
+ details?: Record<string, unknown>;
73
+ }): ActivixCostShape | undefined;
74
+ //# sourceMappingURL=activity-record-adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-record-adapters.d.ts","sourceRoot":"","sources":["../../src/execution-matrix/activity-record-adapters.ts"],"names":[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5
+ if (typeof v !== 'string')
6
+ return undefined;
7
+ const t = v.trim();
8
+ return t.length > 0 ? t : undefined;
9
+ }
10
+ function finiteNumber(v) {
11
+ return typeof v === 'number' && Number.isFinite(v) ? v : undefined;
12
+ }
13
+ function firstFiniteNumber(...values) {
14
+ for (const v of values) {
15
+ const n = finiteNumber(v);
16
+ if (n !== undefined)
17
+ return n;
18
+ }
19
+ return undefined;
20
+ }
21
+ function resolveOuter(doc) {
22
+ if (isPlainObject(doc.outer))
23
+ return doc.outer;
24
+ const legacy = doc.structure;
25
+ if (isPlainObject(legacy) && isPlainObject(legacy.outer))
26
+ return legacy.outer;
27
+ return undefined;
28
+ }
29
+ /**
30
+ * Gateway completion payloads may be stored as `outer.output` (ai-gateway) or
31
+ * `outer.output.response` (nested envelope from some graph runtimes).
32
+ */
33
+ export function resolveActivityGatewayResponse(doc) {
34
+ const outer = resolveOuter(doc);
35
+ const output = outer?.output;
36
+ if (!isPlainObject(output))
37
+ return undefined;
38
+ if (isPlainObject(output.response))
39
+ return output.response;
40
+ return output;
41
+ }
42
+ function readUsageObject(raw) {
43
+ if (!isPlainObject(raw))
44
+ return undefined;
45
+ if (isPlainObject(raw.usage))
46
+ return raw.usage;
47
+ if (isPlainObject(raw.tokens))
48
+ return raw.tokens;
49
+ return raw;
50
+ }
51
+ function normalizeUsageFields(raw) {
52
+ if (!raw)
53
+ return {};
54
+ const promptTokens = firstFiniteNumber(raw.prompt_tokens, raw.tokensPrompt, raw.prompt, raw.input, raw.tokensInput);
55
+ const completionTokens = firstFiniteNumber(raw.completion_tokens, raw.tokensCompletion, raw.completion, raw.output, raw.tokensOutput);
56
+ const totalTokens = firstFiniteNumber(raw.total_tokens, raw.tokensTotal, raw.total);
57
+ const promptDetails = isPlainObject(raw.prompt_tokens_details) ? raw.prompt_tokens_details : undefined;
58
+ const completionDetails = isPlainObject(raw.completion_tokens_details)
59
+ ? raw.completion_tokens_details
60
+ : undefined;
61
+ const cachedPromptTokens = firstFiniteNumber(raw.cachedTokensPrompt, raw.cached_prompt_tokens, promptDetails?.cached_tokens);
62
+ const reasoningTokens = firstFiniteNumber(raw.reasoning_tokens, completionDetails?.reasoning_tokens);
63
+ const costUsd = firstFiniteNumber(raw.cost, raw.costUsd, raw.usd);
64
+ const costStatus = raw.costStatus === 'priced' || raw.costStatus === 'unpriced' ? raw.costStatus : undefined;
65
+ const maxTokensRequested = firstFiniteNumber(raw.maxTokensRequested, raw.max_tokens);
66
+ const isByok = typeof raw.is_byok === 'boolean' ? raw.is_byok : undefined;
67
+ return {
68
+ ...(promptTokens !== undefined ? { promptTokens } : {}),
69
+ ...(completionTokens !== undefined ? { completionTokens } : {}),
70
+ ...(totalTokens !== undefined ? { totalTokens } : {}),
71
+ ...(cachedPromptTokens !== undefined ? { cachedPromptTokens } : {}),
72
+ ...(reasoningTokens !== undefined ? { reasoningTokens } : {}),
73
+ ...(costUsd !== undefined ? { costUsd } : {}),
74
+ ...(costStatus ? { costStatus } : {}),
75
+ ...(maxTokensRequested !== undefined ? { maxTokensRequested } : {}),
76
+ ...(isByok !== undefined ? { isByok } : {}),
77
+ };
78
+ }
79
+ function readOuterCostTokens(outer) {
80
+ const cost = outer?.cost;
81
+ if (!isPlainObject(cost))
82
+ return {};
83
+ const usd = finiteNumber(cost.usd);
84
+ const tokens = isPlainObject(cost.tokens) ? cost.tokens : undefined;
85
+ return {
86
+ ...(usd !== undefined ? { costUsd: usd } : {}),
87
+ ...(tokens
88
+ ? normalizeUsageFields({
89
+ input: tokens.input,
90
+ output: tokens.output,
91
+ total: tokens.total,
92
+ reasoning: tokens.reasoning,
93
+ })
94
+ : {}),
95
+ ...(isPlainObject(cost.details) && (cost.details.costStatus === 'priced' || cost.details.costStatus === 'unpriced')
96
+ ? { costStatus: cost.details.costStatus }
97
+ : {}),
98
+ };
99
+ }
100
+ /**
101
+ * Token + cost usage for one activity (prefers Activix `outer.cost`, then gateway `usage`).
102
+ */
103
+ export function resolveActivityUsage(doc) {
104
+ const outer = resolveOuter(doc);
105
+ const fromOuterCost = readOuterCostTokens(outer);
106
+ const response = resolveActivityGatewayResponse(doc);
107
+ const responseUsage = normalizeUsageFields(readUsageObject(response));
108
+ const metadataUsage = normalizeUsageFields(readUsageObject(isPlainObject(response?.metadata) ? response.metadata.tokens : undefined));
109
+ const topCost = firstFiniteNumber(doc.cost, doc.costUsd);
110
+ const topCostStatus = doc.costStatus === 'priced' || doc.costStatus === 'unpriced' ? doc.costStatus : undefined;
111
+ const promptTokens = fromOuterCost.promptTokens ?? responseUsage.promptTokens ?? metadataUsage.promptTokens;
112
+ const completionTokens = fromOuterCost.completionTokens ?? responseUsage.completionTokens ?? metadataUsage.completionTokens;
113
+ const totalTokens = fromOuterCost.totalTokens ??
114
+ responseUsage.totalTokens ??
115
+ metadataUsage.totalTokens ??
116
+ (promptTokens !== undefined && completionTokens !== undefined
117
+ ? promptTokens + completionTokens
118
+ : undefined);
119
+ const costUsd = fromOuterCost.costUsd ??
120
+ responseUsage.costUsd ??
121
+ metadataUsage.costUsd ??
122
+ firstFiniteNumber(isPlainObject(outer?.metadata) ? outer.metadata.cost : undefined, isPlainObject(outer?.metadata) ? outer.metadata.costUsd : undefined, topCost);
123
+ const costStatus = fromOuterCost.costStatus ?? responseUsage.costStatus ?? metadataUsage.costStatus ?? topCostStatus;
124
+ return {
125
+ ...(promptTokens !== undefined ? { promptTokens } : {}),
126
+ ...(completionTokens !== undefined ? { completionTokens } : {}),
127
+ ...(totalTokens !== undefined ? { totalTokens } : {}),
128
+ ...(fromOuterCost.cachedPromptTokens ?? responseUsage.cachedPromptTokens
129
+ ? { cachedPromptTokens: fromOuterCost.cachedPromptTokens ?? responseUsage.cachedPromptTokens }
130
+ : {}),
131
+ ...(fromOuterCost.reasoningTokens ?? responseUsage.reasoningTokens
132
+ ? { reasoningTokens: fromOuterCost.reasoningTokens ?? responseUsage.reasoningTokens }
133
+ : {}),
134
+ ...(costUsd !== undefined ? { costUsd } : {}),
135
+ ...(costStatus ? { costStatus } : {}),
136
+ ...(responseUsage.maxTokensRequested ?? fromOuterCost.maxTokensRequested
137
+ ? {
138
+ maxTokensRequested: responseUsage.maxTokensRequested ?? fromOuterCost.maxTokensRequested,
139
+ }
140
+ : {}),
141
+ ...(responseUsage.isByok !== undefined ? { isByok: responseUsage.isByok } : {}),
142
+ };
143
+ }
144
+ /**
145
+ * Resolved model for an activity: prefers authoritative `modelUsed`, then `model`.
146
+ */
147
+ export function resolveActivityModel(doc) {
148
+ const outer = resolveOuter(doc);
149
+ const outerMeta = isPlainObject(outer?.metadata) ? outer.metadata : undefined;
150
+ const topMeta = isPlainObject(doc.metadata) ? doc.metadata : undefined;
151
+ const config = isPlainObject(doc.config) ? doc.config : undefined;
152
+ const response = resolveActivityGatewayResponse(doc);
153
+ const responseMeta = isPlainObject(response?.metadata) ? response.metadata : undefined;
154
+ const modelUsed = trimString(topMeta?.modelUsed) ??
155
+ trimString(outerMeta?.modelUsed) ??
156
+ trimString(responseMeta?.modelUsed);
157
+ const model = trimString(topMeta?.model) ??
158
+ trimString(outerMeta?.model) ??
159
+ trimString(responseMeta?.model) ??
160
+ trimString(response?.model) ??
161
+ trimString(config?.model);
162
+ const configuredModel = trimString(config?.model);
163
+ const effectiveModel = modelUsed ?? model;
164
+ const provider = trimString(topMeta?.provider) ??
165
+ trimString(outerMeta?.provider) ??
166
+ trimString(responseMeta?.provider) ??
167
+ trimString(config?.provider) ??
168
+ (isPlainObject(outer?.cost) ? trimString(outer.cost.provider) : undefined);
169
+ return {
170
+ ...(configuredModel ? { configuredModel } : {}),
171
+ ...(modelUsed ? { modelUsed } : {}),
172
+ ...(effectiveModel ? { effectiveModel } : {}),
173
+ ...(provider ? { provider } : {}),
174
+ };
175
+ }
176
+ /** Lifecycle timing from Activix-owned top-level fields. */
177
+ export function resolveActivityTiming(doc) {
178
+ const startTime = finiteNumber(doc.startTime);
179
+ const endTime = finiteNumber(doc.endTime);
180
+ const durationMs = finiteNumber(doc.duration) ??
181
+ (startTime !== undefined && endTime !== undefined ? endTime - startTime : undefined);
182
+ const status = trimString(doc.status);
183
+ return {
184
+ ...(startTime !== undefined ? { startTime } : {}),
185
+ ...(endTime !== undefined ? { endTime } : {}),
186
+ ...(durationMs !== undefined ? { durationMs } : {}),
187
+ ...(status ? { status } : {}),
188
+ };
189
+ }
190
+ export function resolveActivityHasResponse(doc) {
191
+ const outer = resolveOuter(doc);
192
+ return outer?.output !== null && outer?.output !== undefined;
193
+ }
194
+ function resolveRunContextJobId(doc) {
195
+ const rc = doc.runContext;
196
+ if (!isPlainObject(rc))
197
+ return undefined;
198
+ return trimString(rc.jobId);
199
+ }
200
+ /**
201
+ * Full normalized read model for one persisted Activix / gateway activity document.
202
+ */
203
+ export function resolveActivityRecordView(doc) {
204
+ const rc = isPlainObject(doc.runContext) ? doc.runContext : undefined;
205
+ const activityId = trimString(doc.activityId) ?? trimString(doc._id);
206
+ return {
207
+ ...(activityId ? { activityId } : {}),
208
+ ...(resolveRunContextJobId(doc) ? { jobId: resolveRunContextJobId(doc) } : {}),
209
+ ...(rc && trimString(rc.graphId) ? { graphId: trimString(rc.graphId) } : {}),
210
+ ...(rc && trimString(rc.nodeId) ? { nodeId: trimString(rc.nodeId) } : {}),
211
+ ...(trimString(doc.activityType) ? { activityType: trimString(doc.activityType) } : {}),
212
+ ...(trimString(doc.status) ? { status: trimString(doc.status) } : {}),
213
+ hasResponse: resolveActivityHasResponse(doc),
214
+ model: resolveActivityModel(doc),
215
+ usage: resolveActivityUsage(doc),
216
+ timing: resolveActivityTiming(doc),
217
+ };
218
+ }
219
+ /** Maps a rollup or single activity usage view to Activix `outer.cost`. */
220
+ export function toActivixCostShape(input) {
221
+ const usd = finiteNumber(input.costUsd);
222
+ const tokens = input.promptTokens !== undefined ||
223
+ input.completionTokens !== undefined ||
224
+ input.totalTokens !== undefined ||
225
+ input.reasoningTokens !== undefined
226
+ ? {
227
+ ...(input.promptTokens !== undefined ? { input: input.promptTokens } : {}),
228
+ ...(input.completionTokens !== undefined ? { output: input.completionTokens } : {}),
229
+ ...(input.reasoningTokens !== undefined ? { reasoning: input.reasoningTokens } : {}),
230
+ ...(input.totalTokens !== undefined ? { total: input.totalTokens } : {}),
231
+ }
232
+ : undefined;
233
+ const details = { ...(input.details ?? {}) };
234
+ if (input.costStatus)
235
+ details.costStatus = input.costStatus;
236
+ const hasDetails = Object.keys(details).length > 0;
237
+ if (usd === undefined && !tokens && !input.provider && !input.model && !hasDetails) {
238
+ return undefined;
239
+ }
240
+ return {
241
+ ...(usd !== undefined ? { usd, unit: 'USD' } : {}),
242
+ ...(tokens ? { tokens } : {}),
243
+ ...(input.provider ? { provider: input.provider } : {}),
244
+ ...(input.model ? { model: input.model } : {}),
245
+ ...(hasDetails ? { details } : {}),
246
+ };
247
+ }
248
+ //# sourceMappingURL=activity-record-adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-record-adapters.js","sourceRoot":"","sources":["../../src/execution-matrix/activity-record-adapters.ts"],"names":[],"mappings":"AA+CA,SAAS,aAAa,CAAC,CAAU;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,UAAU,CAAC,CAAU;IAC5B,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACnB,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,SAAS,YAAY,CAAC,CAAU;IAC9B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC;AAED,SAAS,iBAAiB,CAAC,GA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AE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7B,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9C,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=activity-record-adapters.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-record-adapters.spec.d.ts","sourceRoot":"","sources":["../../src/execution-matrix/activity-record-adapters.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,114 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { resolveActivityModel, resolveActivityRecordView, resolveActivityUsage, } from './activity-record-adapters.js';
3
+ import { rollupJobActivitiesFromRecords } from './job-activity-rollup.js';
4
+ /** Completed gateway row shape (outer.output.response envelope). */
5
+ function completedGatewayActivity(overrides) {
6
+ return {
7
+ activityId: 'act-1',
8
+ status: 'completed',
9
+ startTime: 1779206026578,
10
+ endTime: 1779206026590,
11
+ duration: 12,
12
+ runContext: { jobId: 'job-abc', graphId: 'graph-1', nodeId: 'step-1' },
13
+ config: { model: 'gpt-5-nano' },
14
+ outer: {
15
+ input: { activityType: 'gateway-invocation' },
16
+ output: {
17
+ response: {
18
+ model: 'openai/gpt-5.2',
19
+ usage: {
20
+ prompt_tokens: 693,
21
+ completion_tokens: 1078,
22
+ total_tokens: 1771,
23
+ cost: 0.01630475,
24
+ tokensPrompt: 693,
25
+ tokensCompletion: 1078,
26
+ tokensTotal: 1771,
27
+ },
28
+ metadata: {
29
+ modelUsed: 'openai/gpt-5.2',
30
+ costStatus: 'priced',
31
+ },
32
+ },
33
+ },
34
+ metadata: { modelUsed: 'openai/gpt-5.2' },
35
+ cost: {
36
+ usd: 0.01630475,
37
+ unit: 'USD',
38
+ tokens: { input: 693, output: 1078, total: 1771 },
39
+ model: 'openai/gpt-5.2',
40
+ details: { costStatus: 'priced' },
41
+ },
42
+ },
43
+ ...overrides,
44
+ };
45
+ }
46
+ describe('resolveActivityModel', () => {
47
+ it('prefers modelUsed over configured model', () => {
48
+ const model = resolveActivityModel(completedGatewayActivity());
49
+ expect(model.configuredModel).toBe('gpt-5-nano');
50
+ expect(model.modelUsed).toBe('openai/gpt-5.2');
51
+ expect(model.effectiveModel).toBe('openai/gpt-5.2');
52
+ });
53
+ it('falls back to model when modelUsed is absent', () => {
54
+ const doc = completedGatewayActivity();
55
+ const outer = doc.outer;
56
+ const output = outer.output;
57
+ const response = output.response;
58
+ delete response.metadata.modelUsed;
59
+ delete outer.metadata.modelUsed;
60
+ const model = resolveActivityModel(doc);
61
+ expect(model.effectiveModel).toBe('openai/gpt-5.2');
62
+ });
63
+ });
64
+ describe('resolveActivityUsage', () => {
65
+ it('reads tokens and cost from gateway usage and outer.cost', () => {
66
+ const usage = resolveActivityUsage(completedGatewayActivity());
67
+ expect(usage.promptTokens).toBe(693);
68
+ expect(usage.completionTokens).toBe(1078);
69
+ expect(usage.totalTokens).toBe(1771);
70
+ expect(usage.costUsd).toBeCloseTo(0.01630475);
71
+ expect(usage.costStatus).toBe('priced');
72
+ });
73
+ });
74
+ describe('rollupJobActivitiesFromRecords', () => {
75
+ it('sums duration, tokens, and cost for a job', () => {
76
+ const second = completedGatewayActivity({
77
+ activityId: 'act-2',
78
+ duration: 8,
79
+ outer: {
80
+ input: {},
81
+ output: {
82
+ response: {
83
+ model: 'openai/gpt-5.2',
84
+ usage: { prompt_tokens: 100, completion_tokens: 50, total_tokens: 150, cost: 0.01 },
85
+ },
86
+ },
87
+ metadata: {},
88
+ cost: { usd: 0.01, tokens: { input: 100, output: 50, total: 150 } },
89
+ },
90
+ });
91
+ const rollup = rollupJobActivitiesFromRecords([completedGatewayActivity(), second], 'job-abc');
92
+ expect(rollup.activityCount).toBe(2);
93
+ expect(rollup.completedCount).toBe(2);
94
+ expect(rollup.totalDurationMs).toBe(20);
95
+ expect(rollup.totalCostUsd).toBeCloseTo(0.02630475);
96
+ expect(rollup.tokens.prompt).toBe(793);
97
+ expect(rollup.tokens.completion).toBe(1128);
98
+ });
99
+ });
100
+ describe('resolveActivityRecordView', () => {
101
+ it('marks started rows without output as hasResponse false', () => {
102
+ const view = resolveActivityRecordView({
103
+ activityId: 'act-started',
104
+ status: 'started',
105
+ runContext: { jobId: 'job-x' },
106
+ config: { model: 'gpt-5-nano' },
107
+ outer: { input: {}, output: null, metadata: {} },
108
+ });
109
+ expect(view.hasResponse).toBe(false);
110
+ expect(view.model.configuredModel).toBe('gpt-5-nano');
111
+ expect(view.model.effectiveModel).toBe('gpt-5-nano');
112
+ });
113
+ });
114
+ //# sourceMappingURL=activity-record-adapters.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-record-adapters.spec.js","sourceRoot":"","sources":["../../src/execution-matrix/activity-record-adapters.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,oEAAoE;AACpE,SAAS,wBAAwB,CAAC,SAAmC;IACnE,OAAO;QACL,UAAU,EAAE,OAAO;QACnB,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,aAAa;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AAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,IAAI,GAAG,yBAAyB,CAAC;YACrC,UAAU,EAAE,aAAa;YACzB,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;YAC9B,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;YAC/B,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;SACjD,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -164,10 +164,10 @@ describe('materializer helpers', () => {
164
164
  describe('materializer', () => {
165
165
  it('builds execution seed from graphEntry paths', () => {
166
166
  const graphEntry = {
167
- inputs: [{ kind: 'record', path: 'input.raw', required: true }],
167
+ inputs: [{ kind: 'record', path: 'input', required: true }],
168
168
  };
169
- const seed = buildExecutionSeedFromGraphEntry(graphEntry, { raw: { a: 1 } });
170
- expect(seed).toEqual({ input: { raw: { a: 1 } } });
169
+ const seed = buildExecutionSeedFromGraphEntry(graphEntry, { a: 1, b: 2 });
170
+ expect(seed).toEqual({ input: { a: 1, b: 2 } });
171
171
  });
172
172
  it('maps nested Layer-01 paths using graph-engine path rules', () => {
173
173
  const graphEntry = {
@@ -1046,7 +1046,7 @@ describe('matrix boundaries (integration-style)', () => {
1046
1046
  expect(after?.inferences[0].knowledge).toEqual({ verdict: 'ok' });
1047
1047
  expect(after?.inferences[0].graphId).toBe('G');
1048
1048
  });
1049
- it('passes matrix row input into executeGraph execution seed via graphEntry paths', async () => {
1049
+ it('passes matrix row input into executeGraph via runtime.input and graphEntry path input', async () => {
1050
1050
  const rows = new MemoryMatrixCollection(MATRIX_ROW_PK);
1051
1051
  const fails = new MemoryMatrixCollection(MATRIX_FAILURE_PK);
1052
1052
  const rt = createExecutionMatrixRuntime(rows.asCollection(), fails.asCollection(), { serializeClaims: true });
@@ -1056,7 +1056,7 @@ describe('matrix boundaries (integration-style)', () => {
1056
1056
  matrixRunId: 'r1',
1057
1057
  payload: { input: {}, graphs: ['G'] },
1058
1058
  graphRecords: [{ graphId: 'G', mappedInput: [], execution: { priority: 1 } }],
1059
- inputRows: [{ raw: { blob: 9 } }],
1059
+ inputRows: [{ blob: 9 }],
1060
1060
  });
1061
1061
  await rt.insertRuntimeRow(row);
1062
1062
  const executeGraph = vi.fn().mockResolvedValue(mockExecuteGraphSuccess());
@@ -1065,11 +1065,12 @@ describe('matrix boundaries (integration-style)', () => {
1065
1065
  executeGraph,
1066
1066
  resolveGraphModel: resolveGraphModelForTest,
1067
1067
  resolveGraphEntry: () => ({
1068
- inputs: [{ kind: 'record', path: 'input.raw', required: true }],
1068
+ inputs: [{ kind: 'record', path: 'input', required: true }],
1069
1069
  }),
1070
1070
  }, { matrixCatalogId: 'cat', matrixRunId: 'r1', graphIds: ['G'], limit: 1 });
1071
1071
  const call = executeGraph.mock.calls[0][0];
1072
- expect(call.runtime.executionMemory.input.raw).toEqual({ blob: 9 });
1072
+ expect(call.runtime.input).toMatchObject({ blob: 9 });
1073
+ expect(call.runtime.executionMemory.input).toMatchObject({ blob: 9 });
1073
1074
  });
1074
1075
  });
1075
1076
  /* ============================================================================
@@ -1755,7 +1756,7 @@ describe('graph-engine graph document round-trip', () => {
1755
1756
  id: 't1',
1756
1757
  type: 'task',
1757
1758
  skillKey: 'sk.test',
1758
- smartInput: { roots: ['input.raw'] },
1759
+ smartInput: { paths: ['input.blob'] },
1759
1760
  taskConfiguration: {
1760
1761
  aiTaskProfile: {
1761
1762
  inputSynthesis: { enabled: true, outputKey: 'synthesized', catalogId: 'x' },
@@ -1763,8 +1764,8 @@ describe('graph-engine graph document round-trip', () => {
1763
1764
  executionStrategies: [{ strategyKey: 'planner', phase: 'before', priority: 0 }],
1764
1765
  },
1765
1766
  executionPipeline: [{ phase: 'main', type: 'direct' }],
1766
- inputs: {
1767
- body: { type: 'executionMemoryPath', path: 'input.raw' },
1767
+ inputsConfig: {
1768
+ body: { type: 'executionMemoryPath', path: 'input' },
1768
1769
  },
1769
1770
  },
1770
1771
  ],
@@ -1777,9 +1778,9 @@ describe('graph-engine graph document round-trip', () => {
1777
1778
  expect(n[0].taskConfiguration
1778
1779
  ?.aiTaskProfile?.inputSynthesis).toBeDefined();
1779
1780
  expect(n[0].executionPipeline).toHaveLength(1);
1780
- expect(n[0].inputs?.body).toMatchObject({
1781
+ expect(n[0].inputsConfig?.body).toMatchObject({
1781
1782
  type: 'executionMemoryPath',
1782
- path: 'input.raw',
1783
+ path: 'input',
1783
1784
  });
1784
1785
  });
1785
1786
  });