@exellix/ai-tasks 9.0.6 → 9.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -4
- package/README.md +5 -5
- package/RUNTASK_REQUEST.md +17 -15
- package/dist/compile/compileTaskConfiguration.d.ts.map +1 -1
- package/dist/compile/compileTaskConfiguration.js +3 -0
- package/dist/compile/compileTaskConfiguration.js.map +1 -1
- package/dist/core/task-sdk.d.ts.map +1 -1
- package/dist/core/task-sdk.js +112 -166
- package/dist/core/task-sdk.js.map +1 -1
- package/dist/invocation/types.d.ts +1 -1
- package/dist/narrix/narrixUnitExecution.js +2 -2
- package/dist/narrix/narrixUnitExecution.js.map +1 -1
- package/dist/node-execution/buildRequestFromNodePlan.d.ts +4 -0
- package/dist/node-execution/buildRequestFromNodePlan.d.ts.map +1 -1
- package/dist/node-execution/buildRequestFromNodePlan.js +4 -13
- package/dist/node-execution/buildRequestFromNodePlan.js.map +1 -1
- package/dist/node-execution/compileProfessionalAnswerRequest.d.ts +2 -0
- package/dist/node-execution/compileProfessionalAnswerRequest.d.ts.map +1 -0
- package/dist/node-execution/compileProfessionalAnswerRequest.js +4 -0
- package/dist/node-execution/compileProfessionalAnswerRequest.js.map +1 -0
- package/dist/node-execution/rejectForbiddenWireFields.d.ts +2 -0
- package/dist/node-execution/rejectForbiddenWireFields.d.ts.map +1 -1
- package/dist/node-execution/rejectForbiddenWireFields.js +42 -7
- package/dist/node-execution/rejectForbiddenWireFields.js.map +1 -1
- package/dist/node-execution/resolveUnitModelSelection.d.ts.map +1 -1
- package/dist/node-execution/resolveUnitModelSelection.js +10 -1
- package/dist/node-execution/resolveUnitModelSelection.js.map +1 -1
- package/dist/observability/graphExecutionRunLogContract.d.ts +1 -1
- package/dist/observability/graphExecutionRunLogContract.js +1 -1
- package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts +19 -3
- package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts.map +1 -1
- package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js +7 -1
- package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js.map +1 -1
- package/dist/post-steps/audit/loadAuditTemplates.d.ts +2 -55
- package/dist/post-steps/audit/loadAuditTemplates.d.ts.map +1 -1
- package/dist/post-steps/audit/loadAuditTemplates.js +3 -38
- package/dist/post-steps/audit/loadAuditTemplates.js.map +1 -1
- package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts +8 -0
- package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts.map +1 -0
- package/dist/post-steps/audit/parseAuditFuncxOutput.js +62 -0
- package/dist/post-steps/audit/parseAuditFuncxOutput.js.map +1 -0
- package/dist/post-steps/audit/parseAuditOutput.d.ts +2 -0
- package/dist/post-steps/audit/parseAuditOutput.d.ts.map +1 -1
- package/dist/post-steps/audit/parseAuditOutput.js +56 -0
- package/dist/post-steps/audit/parseAuditOutput.js.map +1 -1
- package/dist/post-steps/audit/runAudit.d.ts.map +1 -1
- package/dist/post-steps/audit/runAudit.js +53 -113
- package/dist/post-steps/audit/runAudit.js.map +1 -1
- package/dist/post-steps/audit/runAuditFuncxCall.d.ts +18 -0
- package/dist/post-steps/audit/runAuditFuncxCall.d.ts.map +1 -0
- package/dist/post-steps/audit/runAuditFuncxCall.js +59 -0
- package/dist/post-steps/audit/runAuditFuncxCall.js.map +1 -0
- package/dist/synthesis/resolveSourceMaterial.d.ts.map +1 -1
- package/dist/synthesis/resolveSourceMaterial.js +14 -0
- package/dist/synthesis/resolveSourceMaterial.js.map +1 -1
- package/dist/types/task-types.d.ts +4 -3
- package/dist/types/task-types.d.ts.map +1 -1
- package/dist/utils/bridgeRunSkillGatewayMemory.d.ts.map +1 -1
- package/dist/utils/bridgeRunSkillGatewayMemory.js +1 -0
- package/dist/utils/bridgeRunSkillGatewayMemory.js.map +1 -1
- package/dist/utils/executionMemoryInputRecord.d.ts +12 -0
- package/dist/utils/executionMemoryInputRecord.d.ts.map +1 -0
- package/dist/utils/executionMemoryInputRecord.js +28 -0
- package/dist/utils/executionMemoryInputRecord.js.map +1 -0
- package/dist/utils/resolveAiProfileModel.d.ts +1 -1
- package/dist/utils/resolveAiProfileModel.d.ts.map +1 -1
- package/dist/utils/skillTemplateVariables.d.ts +3 -2
- package/dist/utils/skillTemplateVariables.d.ts.map +1 -1
- package/dist/utils/skillTemplateVariables.js +3 -2
- package/dist/utils/skillTemplateVariables.js.map +1 -1
- package/dist/validation/validateProfessionalAnswerContract.d.ts +8 -0
- package/dist/validation/validateProfessionalAnswerContract.d.ts.map +1 -0
- package/dist/validation/validateProfessionalAnswerContract.js +45 -0
- package/dist/validation/validateProfessionalAnswerContract.js.map +1 -0
- package/dist/validation/validateRunTaskConfig.d.ts.map +1 -1
- package/dist/validation/validateRunTaskConfig.js +2 -0
- package/dist/validation/validateRunTaskConfig.js.map +1 -1
- package/documenations/record-and-template-variables.md +21 -13
- package/documenations/run-task-execution-flow.md +1 -1
- package/documenations/schemas/v1/run-task-request.json +1 -1
- package/documenations/upstream-feature-requests/README.md +9 -5
- package/documenations/upstream-feature-requests/ai-skills-orchestrator-invoke-contract-5.9.md +1 -1
- package/documenations/upstream-feature-requests/funcx-4.9.13-open-items.md +62 -0
- package/documenations/upstream-feature-requests/funcx-gap-analysis-cr-fr.md +401 -0
- package/documenations/upstream-feature-requests/funcx-pre-post-sidekick-actions.md +1 -0
- package/documenations/upstream-feature-requests/graph-engine-runtask-contract-alignment-investigation.md +370 -0
- package/documenations/upstream-feature-requests/xynthesis-ai-profiles-2.1-import-break.md +2 -2
- package/documenations/upstream-feature-requests/xynthesis-openrouter-wire-model-double-prefix-bug.md +1 -1
- package/documenations/upstream-feature-requests/xynthesis-orchestrator-invoke-contract-4.2.md +1 -1
- package/package.json +14 -17
- package/.docs/DOWNSTREAM_ENV.md +0 -42
- package/.docs/FEEDBACK_TO_CLIENT_DOWNSTREAM_FIXES.md +0 -64
- package/.docs/INTERMEDIATE_STEPS.md +0 -82
- package/.docs/activity-structure.md +0 -31
- package/.docs/ai-task-ai-scoping-spec.md +0 -338
- package/.docs/ai-tasks-model-profile-aliases-7x.md +0 -96
- package/.docs/blockers-and-issues.md +0 -346
- package/.docs/building-runTask-sdk.md +0 -659
- package/.docs/building-skill-execution-orchestrator.md +0 -968
- package/.docs/code-used-before/run-task.txt +0 -39
- package/.docs/code-used-before/task-executor.ts.old +0 -57
- package/.docs/code-used-before/test-run-task.ts.old +0 -42
- package/.docs/code-used-before/types.txt +0 -23
- package/.docs/env-ready-policy.md +0 -40
- package/.docs/flow-io/flow-README.md +0 -76
- package/.docs/flow-io/narrix.md +0 -124
- package/.docs/flow-io/web-scoping.md +0 -135
- package/.docs/flow-io/xynthesis-post.md +0 -154
- package/.docs/flow-io/xynthesis-pre.md +0 -181
- package/.docs/gap-analysis.md +0 -201
- package/.docs/integration-facts-ai-tasks.md +0 -109
- package/.docs/investigation/ai-skills.md +0 -170
- package/.docs/investigation/external-packages-assignments.md +0 -66
- package/.docs/investigation/integration-summary.md +0 -20
- package/.docs/investigation/narrix-catalox.md +0 -29
- package/.docs/investigation/workplan-close-graph-engine-gaps.md +0 -101
- package/.docs/logging-stack.md +0 -30
- package/.docs/memory-narrix-adapter-developer-guide.md +0 -402
- package/.docs/memory-narrix-adapter-requirements.md +0 -112
- package/.docs/narrix-context-consumption-gap.md +0 -184
- package/.docs/narrix-context-downstream-report.md +0 -30
- package/.docs/narrix-ingest-and-packs-library-spec.md +0 -240
- package/.docs/narrix-record-input-current-design.md +0 -48
- package/.docs/pacakge.md +0 -48
- package/.docs/possible-components/README.md +0 -11
- package/.docs/possible-components/integration/README.md +0 -10
- package/.docs/possible-components/integration/gaps-when-merging.md +0 -16
- package/.docs/possible-components/integration/platform.md +0 -54
- package/.docs/possible-components/integration/reintegrate-into-ai-tasks.md +0 -26
- package/.docs/possible-components/integration/roadmap-and-checklists.md +0 -54
- package/.docs/possible-components/post-component/README.md +0 -18
- package/.docs/possible-components/post-component/builder-guide.md +0 -175
- package/.docs/possible-components/post-component/gaps-and-artifacts.md +0 -52
- package/.docs/possible-components/post-component/handler-audit.md +0 -47
- package/.docs/possible-components/post-component/handler-polish.md +0 -41
- package/.docs/possible-components/post-component/unified-protocol.md +0 -59
- package/.docs/possible-components/pre-component/README.md +0 -22
- package/.docs/possible-components/pre-component/builder-guide.md +0 -127
- package/.docs/possible-components/pre-component/gaps-and-artifacts.md +0 -35
- package/.docs/possible-components/pre-component/handler-ai-scoping.md +0 -45
- package/.docs/possible-components/pre-component/handler-narrix-preprocessor.md +0 -49
- package/.docs/possible-components/pre-component/handler-narrix-system2.md +0 -35
- package/.docs/possible-components/pre-component/handler-synthesized-context.md +0 -65
- package/.docs/possible-components/pre-component/handler-web-scope.md +0 -29
- package/.docs/possible-components/pre-component/unified-protocol.md +0 -89
- package/.docs/prefer-openrouter-routing-policy.md +0 -114
- package/.docs/questions-for-ai-skills.md +0 -123
- package/.docs/realtime-narrixing-gap-analysis.md +0 -40
- package/.docs/realtime-narrixing.md +0 -433
- package/.docs/run-context-object.md +0 -32
- package/.docs/session-id-usage.md +0 -26
- package/.docs/skill-library-spec.md +0 -249
- package/.docs/synthesized-context-strategy-spec.md +0 -906
- package/.docs/upstream-issue/2026-03-21_woroces-ai-tasks_ISSUE-006_web-scope-question-from-cni-entity.md +0 -46
- package/.docs/web-scopper-embed.md +0 -93
- package/.docs/xynthesis-wiring-and-io.md +0 -12
- package/documenations/activix-feature-request-identity.md +0 -123
- package/documenations/bug-report-xynthesis-and-synthesis-call.md +0 -217
- package/documenations/feature-request-ai-skills-raw-template-access.md +0 -82
- package/documenations/feature-request-athenix-core-directive.md +0 -145
- package/documenations/feature-request-athenix-token-extraction.md +0 -124
- package/documenations/funcx-upstream-github-issues-draft.md +0 -153
- package/documenations/identity-metadata-contract.md +0 -165
- package/documenations/run-task-single-run-checklist.md +0 -109
- package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-1-no-concrete-wire-in-graph-plans.md +0 -93
- package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-2-skillModel-profile-only-at-storage.md +0 -88
- package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-3-reject-concrete-models-in-catalog-rows.md +0 -76
- package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-1-suggested-profile-in-catalogs.md +0 -96
- package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-2-graph-engine-failure-phase-attribution.md +0 -92
- package/documenations/sessions/2026-06-08-subnets-model-resolution/INVESTIGATION-original-bug.md +0 -182
- package/documenations/sessions/2026-06-08-subnets-model-resolution/PROBLEM.md +0 -236
- package/documenations/sessions/2026-06-08-subnets-model-resolution/README.md +0 -11
- package/documenations/sessions/2026-06-08-subnets-model-resolution/funcx-test-resolveModel.cheapDefaultWireSlug.test.ts +0 -117
- package/documenations/upstream-feature-requests/ai-tasks-wrap-up-after-upstream.md +0 -129
- package/documenations/upstream-feedback-request-shape-clarification.md +0 -101
- package/documenations/web-context-precedence.md +0 -33
- package/documenations/xynthesis-activix-telemetry.md +0 -28
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
# Questions for @woroces/ai-skills Implementation
|
|
2
|
-
|
|
3
|
-
## Context
|
|
4
|
-
We are implementing `runTask` functionality in `@woroces/ai-tasks` package. The old code (from when `runTask` was in `@woroces/ai-skills`) had memory enrichment and context generation that we need to replicate.
|
|
5
|
-
|
|
6
|
-
## Old Implementation Reference
|
|
7
|
-
|
|
8
|
-
From `.docs/code-used-before/run-task.txt`:
|
|
9
|
-
```typescript
|
|
10
|
-
async runTask<TParsed = any>(input: RunTaskRequest): Promise<RunSkillResponse<TParsed>> {
|
|
11
|
-
// Extract taskId from skillKey (remove "tasks/" prefix if present, or use skillKey as-is)
|
|
12
|
-
const taskId = input.skillKey.replace(/^tasks\//, '');
|
|
13
|
-
|
|
14
|
-
// Build memory bundle
|
|
15
|
-
const memoryBundle = {
|
|
16
|
-
jobMemory: input.jobMemory,
|
|
17
|
-
taskMemory: input.taskMemory
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// Step 1: Enrich memories with scoping data
|
|
21
|
-
const enrichedBundle = await this.enrichMemoriesWithScoping(taskId, 'task', memoryBundle);
|
|
22
|
-
|
|
23
|
-
// Step 2: Generate context markdown
|
|
24
|
-
const contextMarkdown = await this.generateContextMarkdown(taskId, 'task', enrichedBundle);
|
|
25
|
-
|
|
26
|
-
// Create enriched input
|
|
27
|
-
const enrichedInput: RunTaskRequest = {
|
|
28
|
-
...input,
|
|
29
|
-
jobMemory: enrichedBundle.jobMemory,
|
|
30
|
-
taskMemory: enrichedBundle.taskMemory,
|
|
31
|
-
context: contextMarkdown
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return this.taskExecutor.execute<TParsed>(enrichedInput, async (key) => {
|
|
35
|
-
await this.registry.diagnose(key);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Questions
|
|
41
|
-
|
|
42
|
-
### 1. Memory Enrichment Methods
|
|
43
|
-
**Question:** The old code used `this.enrichMemoriesWithScoping()` and `this.generateContextMarkdown()`. These are now private methods in `WorecesSkillsClient`.
|
|
44
|
-
|
|
45
|
-
- **Q1.1:** Are these methods exposed through any public API in `WorecesSkillsClient`?
|
|
46
|
-
- **Q1.2:** If not, should we duplicate this logic in `@woroces/ai-tasks`, or is there a better approach?
|
|
47
|
-
- **Q1.3:** The methods use `this.contextManager` - is `contextManager` accessible from outside the client?
|
|
48
|
-
|
|
49
|
-
### 2. Context Manager Access
|
|
50
|
-
**Question:** The memory enrichment requires a `contextManager` instance.
|
|
51
|
-
|
|
52
|
-
- **Q2.1:** How do we access or initialize a `contextManager` in `@woroces/ai-tasks`?
|
|
53
|
-
- **Q2.2:** Is `contextManager` part of `WorecesSkillsClient` initialization, or do we need to set it up separately?
|
|
54
|
-
- **Q2.3:** What package provides `contextManager`? Is it `@athenices/execution-memory-manager`?
|
|
55
|
-
|
|
56
|
-
### 3. Task Executor vs Skill Executor
|
|
57
|
-
**Question:** The old code called `this.taskExecutor.execute()`, but we see that `WorecesSkillsClient` now has `this.executor.execute()` (for skills).
|
|
58
|
-
|
|
59
|
-
- **Q3.1:** Is there still a `taskExecutor` in `WorecesSkillsClient`, or was it removed?
|
|
60
|
-
- **Q3.2:** For `ExecutionType.DIRECT`, should we:
|
|
61
|
-
- Call `client.runSkill()` directly (which already does memory enrichment for skills)?
|
|
62
|
-
- Or do our own memory enrichment for tasks, then call `client.runSkill()`?
|
|
63
|
-
- **Q3.3:** The old `TaskExecutor.execute()` handled `executionType` switching - should we replicate this in our strategy pattern?
|
|
64
|
-
|
|
65
|
-
### 4. Memory Enrichment for Tasks vs Skills
|
|
66
|
-
**Question:** Looking at `WorecesSkillsClient.runSkill()`, it already does memory enrichment for skills (level: 'skill').
|
|
67
|
-
|
|
68
|
-
- **Q4.1:** For `runTask`, should we do the same enrichment but with level: 'task'?
|
|
69
|
-
- **Q4.2:** Is the difference between 'skill' and 'task' levels significant, or can we use 'skill' for both?
|
|
70
|
-
- **Q4.3:** The old code extracted `taskId` by removing "tasks/" prefix - should we still do this, or use the skillKey as-is?
|
|
71
|
-
|
|
72
|
-
### 5. Registry Diagnosis
|
|
73
|
-
**Question:** The old code had `await this.registry.diagnose(key)` as an error callback.
|
|
74
|
-
|
|
75
|
-
- **Q5.1:** How do we access the registry from `WorecesSkillsClient`?
|
|
76
|
-
- **Q5.2:** Is there a public method to call `diagnose()` on a skill key?
|
|
77
|
-
|
|
78
|
-
### 6. Implementation Approach
|
|
79
|
-
**Question:** What's the recommended approach for implementing `runTask` in `@woroces/ai-tasks`?
|
|
80
|
-
|
|
81
|
-
- **Q6.1:** Should we:
|
|
82
|
-
- Option A: Duplicate the memory enrichment logic from `WorecesSkillsClient`?
|
|
83
|
-
- Option B: Access internal methods/properties of `WorecesSkillsClient` (if exposed)?
|
|
84
|
-
- Option C: Call `client.runSkill()` and handle task-specific logic separately?
|
|
85
|
-
- Option D: Something else?
|
|
86
|
-
|
|
87
|
-
- **Q6.2:** The current implementation uses a strategy pattern - should memory enrichment happen:
|
|
88
|
-
- Before strategy selection?
|
|
89
|
-
- Inside each strategy?
|
|
90
|
-
- Not at all (if `runSkill` already handles it)?
|
|
91
|
-
|
|
92
|
-
### 7. Task ID Extraction
|
|
93
|
-
**Question:** The old code did `input.skillKey.replace(/^tasks\//, '')` to extract taskId.
|
|
94
|
-
|
|
95
|
-
- **Q7.1:** Should we still do this transformation?
|
|
96
|
-
- **Q7.2:** Or should we pass the skillKey as-is to the enrichment methods?
|
|
97
|
-
|
|
98
|
-
### 8. Error Handling
|
|
99
|
-
**Question:** The old code passed an `onNotFound` callback to `taskExecutor.execute()`.
|
|
100
|
-
|
|
101
|
-
- **Q8.1:** Does `client.runSkill()` support an `onNotFound` callback?
|
|
102
|
-
- **Q8.2:** How should we handle missing skills/tasks in the new implementation?
|
|
103
|
-
|
|
104
|
-
## Current Implementation Status
|
|
105
|
-
|
|
106
|
-
Our current `TaskSDK.runTask()` implementation:
|
|
107
|
-
- ✅ Extracts executionType from request
|
|
108
|
-
- ✅ Uses strategy pattern for execution
|
|
109
|
-
- ❌ Missing: Memory enrichment with scoping
|
|
110
|
-
- ❌ Missing: Context markdown generation
|
|
111
|
-
- ❌ Missing: Task ID extraction (removing "tasks/" prefix)
|
|
112
|
-
- ❌ Missing: Registry diagnosis callback
|
|
113
|
-
|
|
114
|
-
## What We Need
|
|
115
|
-
|
|
116
|
-
1. **Clarification** on how to access/use memory enrichment functionality
|
|
117
|
-
2. **Guidance** on whether to duplicate logic or access it from the client
|
|
118
|
-
3. **Confirmation** on the correct flow for task execution vs skill execution
|
|
119
|
-
4. **Documentation** on any public APIs we should be using instead of duplicating code
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
**Note:** We want to implement this correctly and avoid duplicating code if there's a better way. Please advise on the recommended approach.
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# Realtime System-2 Narrixing – Gap Analysis & Test Summary
|
|
2
|
-
|
|
3
|
-
## Gap analysis (spec vs implementation)
|
|
4
|
-
|
|
5
|
-
| Spec item | Status | Notes |
|
|
6
|
-
|-----------|--------|--------|
|
|
7
|
-
| **1. Types (types.ts)** | Done | `NarrixSystem2Mode`, `NarrixSmartScope`, `NarrixSystem2Options`, `NarrixRunInputWithOptions`; resolution order documented. |
|
|
8
|
-
| **2. Env config (system2/config.ts)** | Done | All env vars from spec; `system2Env` exported. |
|
|
9
|
-
| **3. Smart init (system2/smartInit.ts)** | Done | `ensureSmartModeInitialized`; dynamic import with cast (packs-library does not yet export smart APIs at compile time). |
|
|
10
|
-
| **4. detectGaps (system2/detectGaps.ts)** | Done | Pure; ok:false and meta.errors/diagnostics/passes; keyword scan; unit tested. |
|
|
11
|
-
| **5. resolveSmartScope (system2/resolveSmartScope.ts)** | Done | Order: smartScope → agentId → domainKey → null; unit tested. |
|
|
12
|
-
| **6. Patch plan + LLM** | Done | `patchPlan.ts` (types + validate), `buildSystem2Input.ts`, `llmPlan.ts` (ai-gateway dynamic import). |
|
|
13
|
-
| **7. applyPatchPlan (system2/applyPatchPlan.ts)** | Done | remember* via dynamic import; skippedWrite when !enableWrites or !scope. |
|
|
14
|
-
| **8. runWithSystem2 (system2/runWithSystem2.ts)** | Done | Options resolution, loop, artifacts write once at end. |
|
|
15
|
-
| **9. task.ts wiring** | Done | `resolveOptions` from raw input + ctx; `runWithSystem2(..., system1Runner)`; no system2 field when OFF. |
|
|
16
|
-
| **10. artifacts (system2/artifacts.ts)** | Done | `writeArtifacts` under `artifactDir/datasetId/timestamp/`; all listed files. |
|
|
17
|
-
| **11. Unit tests** | Done | detectGaps (5), resolveSmartScope (5), validatePatchPlan (6), OFF mode (2). |
|
|
18
|
-
|
|
19
|
-
## External dependencies (not in this repo)
|
|
20
|
-
|
|
21
|
-
- **@narrices/narrix-packs-library**: Smart mode APIs (`createXronoxFromEnv`, `configurePacksLibrarySmartMode`, `rememberDatasetPackRouting`, `rememberDatasetProcessorRouting`, `rememberRecordSchemaOverride`) are **not** in the current type definitions; code uses dynamic import and runtime checks. When the package adds these exports, no ai-tasks code change is needed.
|
|
22
|
-
- **@athenices/ai-gateway**: Used in `llmPlan.ts` (dynamic import). Request shape may need to match your gateway’s actual API (jobId, agentId, instructions, config.model, response content).
|
|
23
|
-
|
|
24
|
-
- **System-2 model**: Resolved from (1) `input.system2.model`, (2) env `NARRIX_SYSTEM2_MODEL`, (3) default **`gpt-5-mini`** (use gpt-5-nano or gpt-5-mini; override via env or input).
|
|
25
|
-
|
|
26
|
-
## Tests run (for real)
|
|
27
|
-
|
|
28
|
-
- **System-2 unit tests** (no narrix ingest, no LLM):
|
|
29
|
-
- `detectGaps.test.js`: 5/5 pass
|
|
30
|
-
- `resolveSmartScope.test.js`: 5/5 pass
|
|
31
|
-
- `patchPlan.test.js`: 6/6 pass
|
|
32
|
-
- `offMode.test.js`: 2/2 pass (handler returns no `system2` when mode OFF or omitted)
|
|
33
|
-
- **System-2 E2E (real token + ai-gateway)**:
|
|
34
|
-
- `e2e-system2-real.test.ts`: Run with `RUN_SYSTEM2_E2E=1 USE_NARRIX_INGEST=1 NARRIX_SYSTEM2_MODEL=<model>` (and real API token in `.env`). Triggers a gap (unknown dataset), calls real ai-gateway, asserts `system2` metadata and `system2.llm` (real call). **Test passed** with `workingMemory.input` request shape; LLM returned valid PatchPlan JSON (`actions: [], rerun: false`).
|
|
35
|
-
- **Full `npm test`**: Includes existing narrix and narrix-then-execute tests; some subtests are skipped when `USE_NARRIX_INGEST=1` is not set or when real LLM is not desired.
|
|
36
|
-
|
|
37
|
-
## Acceptance criteria (spec)
|
|
38
|
-
|
|
39
|
-
- **OFF mode**: Output unchanged, no `system2` field, no xronox init, no ai-gateway – verified by OFF mode tests.
|
|
40
|
-
- **AUTO / scope / writes / artifacts**: Implemented as specified; full E2E depends on packs-library smart APIs and ai-gateway being available at runtime.
|
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
Below is start→finish spec** for **`@woroces/ai-tasks`** to add **System-2 “real-time narrixing”** using:
|
|
2
|
-
|
|
3
|
-
* **Narrix System-1** (existing: ingest + runner)
|
|
4
|
-
* **System-2** (new: ai-gateway LLM that decides what to remember/do)
|
|
5
|
-
* **Persistence** via the **new smart mode in `@narrices/narrix-packs-library`** (Xronox overlay; domain/agent scoping)
|
|
6
|
-
|
|
7
|
-
This spec assumes your packs-library smart APIs exist exactly as described in your README summary.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# 0) Goal (what this adds)
|
|
12
|
-
|
|
13
|
-
When ai-tasks receives a Narrix input (record/text/docs/chat):
|
|
14
|
-
|
|
15
|
-
1. Run Narrix normally (System-1).
|
|
16
|
-
2. If it fails or attaches “missing mapping / processor not matched / schema missing” style errors, then:
|
|
17
|
-
|
|
18
|
-
* System-2 calls an LLM (via `@athenices/ai-gateway`) to produce a **Patch Plan** (JSON).
|
|
19
|
-
* Apply patch plan by calling packs-library smart “remember*” APIs (writes to Xronox overlay).
|
|
20
|
-
* Re-run Narrix (System-1) again (now with remembered routing/schema).
|
|
21
|
-
3. Return final result plus **system2 metadata** (only when system2 ran).
|
|
22
|
-
|
|
23
|
-
**Safety:** When System-2 mode is OFF, behavior is exactly as today.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
# 1) Add System-2 modes and input options
|
|
28
|
-
|
|
29
|
-
## 1.1 Extend Narrix input types to accept System-2 options
|
|
30
|
-
|
|
31
|
-
**Edit:** `src/narrix/types.ts`
|
|
32
|
-
|
|
33
|
-
Add:
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
export type NarrixSystem2Mode = "OFF" | "AUTO" | "AUTO_HIGH" | "ALWAYS";
|
|
37
|
-
|
|
38
|
-
export type NarrixSmartScope =
|
|
39
|
-
| { scopeType: "domain"; key: string }
|
|
40
|
-
| { scopeType: "agent"; key: string };
|
|
41
|
-
|
|
42
|
-
export type NarrixSystem2Options = {
|
|
43
|
-
mode?: NarrixSystem2Mode;
|
|
44
|
-
force?: boolean;
|
|
45
|
-
|
|
46
|
-
// Smart overlay
|
|
47
|
-
smartScope?: NarrixSmartScope;
|
|
48
|
-
enableWrites?: boolean; // default false; must be true to remember
|
|
49
|
-
|
|
50
|
-
// LLM behavior (ai-gateway)
|
|
51
|
-
model?: string; // required when mode != OFF
|
|
52
|
-
maxIterations?: number; // default 2 (patch + rerun; allow 2)
|
|
53
|
-
stakes?: "low" | "high";
|
|
54
|
-
|
|
55
|
-
// Artifacts (dev)
|
|
56
|
-
saveArtifacts?: boolean;
|
|
57
|
-
artifactDir?: string;
|
|
58
|
-
};
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Then add to your run input:
|
|
62
|
-
|
|
63
|
-
* allow `input.system2?: NarrixSystem2Options`
|
|
64
|
-
* and/or `input.options?.system2?: NarrixSystem2Options`
|
|
65
|
-
|
|
66
|
-
**Resolution precedence in handler:**
|
|
67
|
-
|
|
68
|
-
1. `input.system2`
|
|
69
|
-
2. `input.options.system2`
|
|
70
|
-
3. `ctx.variables.narrixSystem2`
|
|
71
|
-
4. env defaults
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
# 2) Add env defaults (consistent with current style)
|
|
76
|
-
|
|
77
|
-
**Create:** `src/narrix/system2/config.ts`
|
|
78
|
-
|
|
79
|
-
Env vars:
|
|
80
|
-
|
|
81
|
-
* `NARRIX_SYSTEM2_MODE` default `OFF`
|
|
82
|
-
* `NARRIX_SYSTEM2_ENABLE_WRITES` default `0`
|
|
83
|
-
* `NARRIX_SYSTEM2_MAX_ITERATIONS` default `2`
|
|
84
|
-
* `NARRIX_SYSTEM2_MODEL` (required if mode != OFF and not provided in input)
|
|
85
|
-
* `NARRIX_SYSTEM2_SAVE_ARTIFACTS` default `0`
|
|
86
|
-
* `NARRIX_SYSTEM2_ARTIFACT_DIR` default `.tests/test-output/narrix-system2`
|
|
87
|
-
|
|
88
|
-
Smart overlay (packs-library):
|
|
89
|
-
|
|
90
|
-
* `NARRIX_SMART_ROLE` default `"reader"` (or `"writer"` if you want; but safest default is reader)
|
|
91
|
-
* No fixed domain: must come from input/ctx (see below)
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
# 3) Configure packs-library smart mode in ai-tasks
|
|
96
|
-
|
|
97
|
-
You’ll initialize Xronox and configure packs-library smart mode once.
|
|
98
|
-
|
|
99
|
-
## 3.1 Add dependency imports
|
|
100
|
-
|
|
101
|
-
**Edit:** `src/narrix/narrixClient.ts` (or a new `src/narrix/system2/smartInit.ts`)
|
|
102
|
-
|
|
103
|
-
Add imports from `@narrices/narrix-packs-library`:
|
|
104
|
-
|
|
105
|
-
* `configurePacksLibrarySmartMode`
|
|
106
|
-
* `createXronoxFromEnv` (per your README update summary)
|
|
107
|
-
* plus smart APIs will be called later by ai-tasks, not here.
|
|
108
|
-
|
|
109
|
-
### Create a singleton init
|
|
110
|
-
|
|
111
|
-
**Create:** `src/narrix/system2/smartInit.ts`
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
let smartInitPromise: Promise<void> | null = null;
|
|
115
|
-
|
|
116
|
-
export function ensureSmartModeInitialized(opts: {
|
|
117
|
-
enableWrites: boolean;
|
|
118
|
-
role?: "reader" | "writer";
|
|
119
|
-
}) {
|
|
120
|
-
if (smartInitPromise) return smartInitPromise;
|
|
121
|
-
smartInitPromise = (async () => {
|
|
122
|
-
const xronox = createXronoxFromEnv(); // uses MONGO_URI, MONGO_KNOWLEDGE_DB
|
|
123
|
-
configurePacksLibrarySmartMode({
|
|
124
|
-
xronox,
|
|
125
|
-
enableWrites: opts.enableWrites,
|
|
126
|
-
role: opts.role ?? (opts.enableWrites ? "writer" : "reader")
|
|
127
|
-
// NOTE: do not set domain here; domain comes via smartScope per call
|
|
128
|
-
});
|
|
129
|
-
})();
|
|
130
|
-
return smartInitPromise;
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**Important:** Initialize only when System-2 mode is not OFF OR when smart reads are enabled.
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
# 4) Add error detection triggers (when System-2 should run)
|
|
139
|
-
|
|
140
|
-
You said runner runtime is configured to attach errors for:
|
|
141
|
-
|
|
142
|
-
* processor not matched
|
|
143
|
-
* missing mapping
|
|
144
|
-
|
|
145
|
-
We need a robust detector that doesn’t assume exact shape.
|
|
146
|
-
|
|
147
|
-
**Create:** `src/narrix/system2/detectGaps.ts`
|
|
148
|
-
|
|
149
|
-
Input: Narrix success output or failure output.
|
|
150
|
-
|
|
151
|
-
Output:
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
{
|
|
155
|
-
hasGap: boolean;
|
|
156
|
-
reasons: string[];
|
|
157
|
-
gapHints: {
|
|
158
|
-
processorNotMatched?: boolean;
|
|
159
|
-
missingMapping?: boolean;
|
|
160
|
-
missingSchema?: boolean;
|
|
161
|
-
unknownDataset?: boolean;
|
|
162
|
-
details?: any; // extracted snippets to feed LLM
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Detection strategy (v1, pragmatic):
|
|
168
|
-
|
|
169
|
-
* If `ok:false` → `hasGap=true`, reason includes `error`
|
|
170
|
-
* Else if `meta` contains `errors` array → scan strings/objects for keywords:
|
|
171
|
-
|
|
172
|
-
* `"ProcessorNotMatched"` / `"processor not matched"`
|
|
173
|
-
* `"MissingMapping"` / `"missing mapping"`
|
|
174
|
-
* `"schema"` / `"record schema"` / `"roleMap"`
|
|
175
|
-
* Also scan `passes` if present (many systems attach errors there).
|
|
176
|
-
* Keep extraction generic:
|
|
177
|
-
|
|
178
|
-
* collect up to N error objects/strings to include in LLM input.
|
|
179
|
-
|
|
180
|
-
This function should be pure and unit-tested.
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
# 5) Resolve smart scope per request (domain/agent)
|
|
185
|
-
|
|
186
|
-
System-2 memory must be scoped.
|
|
187
|
-
|
|
188
|
-
**Create:** `src/narrix/system2/resolveSmartScope.ts`
|
|
189
|
-
|
|
190
|
-
Resolution order:
|
|
191
|
-
|
|
192
|
-
1. `system2.smartScope` if provided
|
|
193
|
-
2. else if `ctx.agentId` exists → `{ scopeType:"agent", key: ctx.agentId }`
|
|
194
|
-
3. else if `ctx.variables.domainKey` exists → `{ scopeType:"domain", key: ctx.variables.domainKey }`
|
|
195
|
-
4. else → **no scope** (System-2 may still run, but cannot “remember”; it will return patch suggestions only)
|
|
196
|
-
|
|
197
|
-
**Write gating:**
|
|
198
|
-
|
|
199
|
-
* if no scope → do not call remember* even if enableWrites true (log reason)
|
|
200
|
-
* if scope exists and enableWrites false → do not remember, only rerun if possible without writes
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
# 6) System-2 Patch Plan: LLM via ai-gateway
|
|
205
|
-
|
|
206
|
-
We add a new module that produces a patch plan JSON.
|
|
207
|
-
This is the “thinking”.
|
|
208
|
-
|
|
209
|
-
## 6.1 Patch plan schema (JSON-only)
|
|
210
|
-
|
|
211
|
-
**Create:** `src/narrix/system2/patchPlan.ts`
|
|
212
|
-
|
|
213
|
-
```ts
|
|
214
|
-
export type PatchPlan = {
|
|
215
|
-
actions: Array<
|
|
216
|
-
| {
|
|
217
|
-
type: "rememberDatasetPackRouting";
|
|
218
|
-
datasetId: string;
|
|
219
|
-
packId: string;
|
|
220
|
-
}
|
|
221
|
-
| {
|
|
222
|
-
type: "rememberDatasetProcessorRouting";
|
|
223
|
-
datasetId: string;
|
|
224
|
-
packId: string;
|
|
225
|
-
processorId: string;
|
|
226
|
-
entityKind: string;
|
|
227
|
-
}
|
|
228
|
-
| {
|
|
229
|
-
type: "rememberRecordSchemaOverride";
|
|
230
|
-
packId: string;
|
|
231
|
-
entityKind: string;
|
|
232
|
-
mergeStrategy: "deepMerge";
|
|
233
|
-
schemaOverride: any; // json schema fragment
|
|
234
|
-
}
|
|
235
|
-
>;
|
|
236
|
-
rerun: boolean; // whether to rerun system-1 after actions
|
|
237
|
-
notes?: string[];
|
|
238
|
-
confidence?: number;
|
|
239
|
-
};
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## 6.2 Build the LLM prompt input (compact, deterministic)
|
|
243
|
-
|
|
244
|
-
**Create:** `src/narrix/system2/buildSystem2Input.ts`
|
|
245
|
-
|
|
246
|
-
Given:
|
|
247
|
-
|
|
248
|
-
* original request input
|
|
249
|
-
* narrix result
|
|
250
|
-
* detected gap hints
|
|
251
|
-
Return a string that includes:
|
|
252
|
-
* datasetId, medium
|
|
253
|
-
* current chosen packId/entityKind if any
|
|
254
|
-
* list of signals/stories (codes/ids)
|
|
255
|
-
* extracted errors snippets
|
|
256
|
-
* record signature: top-level keys + a few nested paths (no full dump)
|
|
257
|
-
* strict instruction: “Return JSON only matching PatchPlan schema”
|
|
258
|
-
|
|
259
|
-
Keep this under a size limit.
|
|
260
|
-
|
|
261
|
-
## 6.3 Call ai-gateway and parse JSON
|
|
262
|
-
|
|
263
|
-
**Create:** `src/narrix/system2/llmPlan.ts`
|
|
264
|
-
|
|
265
|
-
Use `@athenices/ai-gateway` (same style as your platform uses). Requirements you previously noted:
|
|
266
|
-
|
|
267
|
-
* need `jobId`, `agentId`, `instructions`, and `config.model` for request.
|
|
268
|
-
|
|
269
|
-
Implementation:
|
|
270
|
-
|
|
271
|
-
* `instructions`: a strict System-2 instruction:
|
|
272
|
-
|
|
273
|
-
* “You are System-2. Produce PatchPlan JSON only. No markdown.”
|
|
274
|
-
* include allowed actions list and schema
|
|
275
|
-
* `input`: output of `buildSystem2Input`
|
|
276
|
-
|
|
277
|
-
Return:
|
|
278
|
-
|
|
279
|
-
* parsed PatchPlan (validate with runtime checks)
|
|
280
|
-
* metadata (model, tokens, cost, latency, activityId if available)
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
# 7) Apply Patch Plan (write through packs-library smart APIs)
|
|
285
|
-
|
|
286
|
-
**Create:** `src/narrix/system2/applyPatchPlan.ts`
|
|
287
|
-
|
|
288
|
-
Inputs:
|
|
289
|
-
|
|
290
|
-
* `plan: PatchPlan`
|
|
291
|
-
* `smartScope`
|
|
292
|
-
* `enableWrites`
|
|
293
|
-
|
|
294
|
-
Behavior:
|
|
295
|
-
|
|
296
|
-
* For each action:
|
|
297
|
-
|
|
298
|
-
* call the corresponding packs-library function:
|
|
299
|
-
|
|
300
|
-
* `rememberDatasetPackRouting(scope, { datasetId, packId })`
|
|
301
|
-
* `rememberDatasetProcessorRouting(scope, { datasetId, packId, processorId, entityKind })`
|
|
302
|
-
* `rememberRecordSchemaOverride(scope, { packId, entityKind, schemaOverride, mergeStrategy })`
|
|
303
|
-
* If writes are disabled → don’t call them; collect “skippedWrite” notes.
|
|
304
|
-
* Return an `applied[]` list with status per action.
|
|
305
|
-
|
|
306
|
-
**Important:** these functions should throw clear errors when writes disabled; catch and record in system2 meta.
|
|
307
|
-
|
|
308
|
-
---
|
|
309
|
-
|
|
310
|
-
# 8) Rerun System-1 after patch (iteration control)
|
|
311
|
-
|
|
312
|
-
**Create:** `src/narrix/system2/runWithSystem2.ts`
|
|
313
|
-
|
|
314
|
-
Algorithm:
|
|
315
|
-
|
|
316
|
-
1. Run System-1 (existing).
|
|
317
|
-
2. If mode OFF → return.
|
|
318
|
-
3. Detect gaps.
|
|
319
|
-
4. If no gap and mode != ALWAYS → return.
|
|
320
|
-
5. Ensure smart mode initialized:
|
|
321
|
-
|
|
322
|
-
* `ensureSmartModeInitialized({ enableWrites, role: enableWrites ? "writer" : "reader" })`
|
|
323
|
-
6. Resolve smartScope.
|
|
324
|
-
7. For `iter=1..maxIterations`:
|
|
325
|
-
|
|
326
|
-
* Call `llmPlan(...)` → PatchPlan
|
|
327
|
-
* Apply patch plan
|
|
328
|
-
* If plan.rerun is false → stop (return original result + meta)
|
|
329
|
-
* Rerun System-1
|
|
330
|
-
* Detect gaps again; if resolved → stop
|
|
331
|
-
8. Return last result with `system2` metadata attached.
|
|
332
|
-
|
|
333
|
-
Default `maxIterations=2` is enough:
|
|
334
|
-
|
|
335
|
-
* Iter 1: propose and remember
|
|
336
|
-
* Rerun
|
|
337
|
-
* If still failing, iter 2 tries a smaller fix
|
|
338
|
-
|
|
339
|
-
---
|
|
340
|
-
|
|
341
|
-
# 9) Wire it into `narrixRunHandler`
|
|
342
|
-
|
|
343
|
-
**Edit:** `src/narrix/task.ts`
|
|
344
|
-
|
|
345
|
-
After you normalize input and before returning:
|
|
346
|
-
|
|
347
|
-
* Call `runWithSystem2({ input, ctx }, () => system1RunnerFn)`
|
|
348
|
-
|
|
349
|
-
Where `system1RunnerFn` is the existing switch:
|
|
350
|
-
|
|
351
|
-
* record/text/docs/chat
|
|
352
|
-
|
|
353
|
-
**Behavior preservation:**
|
|
354
|
-
|
|
355
|
-
* If mode OFF (default) → this wrapper returns exactly system1 output with no extra fields.
|
|
356
|
-
|
|
357
|
-
**When system2 ran:**
|
|
358
|
-
Add a top-level optional field (only then):
|
|
359
|
-
|
|
360
|
-
```ts
|
|
361
|
-
system2?: {
|
|
362
|
-
mode: NarrixSystem2Mode;
|
|
363
|
-
reasons: string[];
|
|
364
|
-
iterations: number;
|
|
365
|
-
appliedActions: Array<{ type: string; ok: boolean; error?: string }>;
|
|
366
|
-
llm?: { model?: string; tokens?: any; cost?: number; activityId?: string; latencyMs?: number };
|
|
367
|
-
scope?: { scopeType: "domain" | "agent"; key: string } | null;
|
|
368
|
-
}
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
---
|
|
372
|
-
|
|
373
|
-
# 10) Artifacts (playground inspection)
|
|
374
|
-
|
|
375
|
-
**Create:** `src/narrix/system2/artifacts.ts`
|
|
376
|
-
|
|
377
|
-
If `saveArtifacts=true`:
|
|
378
|
-
Write under:
|
|
379
|
-
|
|
380
|
-
* `${artifactDir}/${datasetId}/${timestampOrHash}/`
|
|
381
|
-
|
|
382
|
-
Files:
|
|
383
|
-
|
|
384
|
-
* `input.json` (sanitized if needed)
|
|
385
|
-
* `system1-result.json`
|
|
386
|
-
* `gap-detect.json`
|
|
387
|
-
* `system2-plan.json`
|
|
388
|
-
* `system2-applied.json`
|
|
389
|
-
* `system1-rerun-result.json`
|
|
390
|
-
* `_summary.json`
|
|
391
|
-
|
|
392
|
-
This is super useful for debugging System-2.
|
|
393
|
-
|
|
394
|
-
---
|
|
395
|
-
|
|
396
|
-
# 11) Tests
|
|
397
|
-
|
|
398
|
-
Add unit tests without private deps:
|
|
399
|
-
|
|
400
|
-
1. `detectGaps` correctly flags simulated attachError structures
|
|
401
|
-
2. `resolveSmartScope` chooses agent by default when present
|
|
402
|
-
3. PatchPlan validation rejects invalid output
|
|
403
|
-
4. OFF mode path does not initialize xronox and does not call ai-gateway
|
|
404
|
-
|
|
405
|
-
For integration tests:
|
|
406
|
-
|
|
407
|
-
* If `.env` provides `MONGO_URI` and `MONGO_KNOWLEDGE_DB` (as you described), you can run a real memory write+read test:
|
|
408
|
-
|
|
409
|
-
* apply patch plan
|
|
410
|
-
* verify record exists in Xronox knowledge DB
|
|
411
|
-
|
|
412
|
-
---
|
|
413
|
-
|
|
414
|
-
# Acceptance criteria checklist
|
|
415
|
-
|
|
416
|
-
✅ **OFF mode**: output unchanged, no new fields, no xronox init, no ai-gateway
|
|
417
|
-
✅ **AUTO mode**: on missing mapping / processor mismatch, generates patch plan, writes remembered overrides, reruns, improves outcome
|
|
418
|
-
✅ **Scope generic**: supports either `{scopeType:"agent"}` or `{scopeType:"domain"}`
|
|
419
|
-
✅ **Writes gated**: no “remember” without `enableWrites=true` AND a scope
|
|
420
|
-
✅ **Artifacts**: optional, in `.tests/test-output/narrix-system2/...`
|
|
421
|
-
|
|
422
|
-
---
|
|
423
|
-
|
|
424
|
-
# What you need to pass in ai-tasks requests (minimum)
|
|
425
|
-
|
|
426
|
-
For System-2 to actually “remember”:
|
|
427
|
-
|
|
428
|
-
* `system2.mode = "AUTO" | "AUTO_HIGH" | "ALWAYS"`
|
|
429
|
-
* `system2.smartScope = { scopeType:"agent"|"domain", key:"..." }`
|
|
430
|
-
(or rely on `ctx.agentId` auto-scope)
|
|
431
|
-
* `system2.enableWrites = true`
|
|
432
|
-
* `system2.model` (or `NARRIX_SYSTEM2_MODEL` env)
|
|
433
|
-
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Run Context Object (Activix)
|
|
2
|
-
|
|
3
|
-
`runContext` is the **runtime correlation envelope** written with each activity record. It is **not** constructor configuration and should be passed at write time (e.g. `startRecord`, `patchRecord`, `completeRecord`, `failRecord`).
|
|
4
|
-
|
|
5
|
-
## Goals
|
|
6
|
-
|
|
7
|
-
- Preserve upstream correlation identifiers end-to-end.
|
|
8
|
-
- Make multi-phase / multi-step activity streams queryable by stable IDs.
|
|
9
|
-
- Avoid re-inventing correlation fields ad-hoc in `outer.metadata`.
|
|
10
|
-
|
|
11
|
-
## Recommended fields
|
|
12
|
-
|
|
13
|
-
- `sessionId` (string, recommended): stable correlation id from the true upstream request/session when available.
|
|
14
|
-
- `jobId` (string, optional): job/workflow run identifier.
|
|
15
|
-
- `taskId` (string, optional): logical task identifier.
|
|
16
|
-
- Any additional domain identifiers that are stable and queryable for your org.
|
|
17
|
-
|
|
18
|
-
## Rules of thumb
|
|
19
|
-
|
|
20
|
-
- Always pass a real upstream `sessionId` when available.
|
|
21
|
-
- Forward `runContext` through layers; don’t overwrite inherited IDs.
|
|
22
|
-
- Don’t embed large payloads in `runContext` (use `outer` for I/O payload).
|
|
23
|
-
|
|
24
|
-
## Minimal example
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
await ax.startRecord({
|
|
28
|
-
runContext: { sessionId, jobId, taskId },
|
|
29
|
-
outer: { input, output: null, metadata: { type: 'task' } },
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Session ID Usage (Activix)
|
|
2
|
-
|
|
3
|
-
`runContext.sessionId` is the **primary correlation id** you should carry from upstream into Activix writes whenever possible.
|
|
4
|
-
|
|
5
|
-
## Why it matters
|
|
6
|
-
|
|
7
|
-
- Groups multiple activity records into one logical run across phases/services.
|
|
8
|
-
- Enables fast queries for “everything that happened for this run”.
|
|
9
|
-
- Improves observability without requiring log-scraping or brittle heuristics.
|
|
10
|
-
|
|
11
|
-
## Best practices
|
|
12
|
-
|
|
13
|
-
- Prefer a true upstream `sessionId` (API gateway request id, workflow run id, user session id, etc.).
|
|
14
|
-
- If you must generate one, generate it **once** at the edge of your workflow and propagate it.
|
|
15
|
-
- Never “replace” an inherited `sessionId` in a lower layer.
|
|
16
|
-
- If you use both `sessionId` and `jobId`, keep them consistent (session = correlation, job = orchestration).
|
|
17
|
-
|
|
18
|
-
## Minimal example
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
await ax.startRecord({
|
|
22
|
-
runContext: { sessionId: request.sessionId, jobId: request.jobId },
|
|
23
|
-
outer: { input: payload, output: null, metadata: { type: 'task' } },
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|