@principles/core 1.122.0 → 1.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime-v2/__tests__/architecture-regression.test.js +37 -73
- package/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +4 -0
- package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +37 -0
- package/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-defaults.js +2 -0
- package/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-types.d.ts +2 -0
- package/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-types.js.map +1 -1
- package/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.d.ts +2 -0
- package/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.js +45 -0
- package/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.js.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.d.ts +2 -0
- package/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js +57 -0
- package/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.d.ts +2 -0
- package/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.js +39 -0
- package/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.js.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.d.ts +2 -0
- package/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js +34 -0
- package/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.d.ts +2 -0
- package/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.js +57 -0
- package/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.js.map +1 -0
- package/dist/runtime-v2/diagnostician/diag-distiller-output.d.ts +80 -0
- package/dist/runtime-v2/diagnostician/diag-distiller-output.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/diag-distiller-output.js +103 -0
- package/dist/runtime-v2/diagnostician/diag-distiller-output.js.map +1 -0
- package/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts +115 -0
- package/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/diag-rootcause-output.js +166 -0
- package/dist/runtime-v2/diagnostician/diag-rootcause-output.js.map +1 -0
- package/dist/runtime-v2/diagnostician/distiller-prompt-builder.d.ts +134 -0
- package/dist/runtime-v2/diagnostician/distiller-prompt-builder.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/distiller-prompt-builder.js +156 -0
- package/dist/runtime-v2/diagnostician/distiller-prompt-builder.js.map +1 -0
- package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts +96 -0
- package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js +216 -0
- package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js.map +1 -0
- package/dist/runtime-v2/diagnostician/router-prompt-builder.d.ts +127 -0
- package/dist/runtime-v2/diagnostician/router-prompt-builder.d.ts.map +1 -0
- package/dist/runtime-v2/diagnostician/router-prompt-builder.js +131 -0
- package/dist/runtime-v2/diagnostician/router-prompt-builder.js.map +1 -0
- package/dist/runtime-v2/index.d.ts +6 -3
- package/dist/runtime-v2/index.d.ts.map +1 -1
- package/dist/runtime-v2/index.js +1 -1
- package/dist/runtime-v2/index.js.map +1 -1
- package/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.d.ts +25 -0
- package/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.js +123 -0
- package/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.js.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.d.ts +2 -0
- package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js +731 -0
- package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.d.ts +2 -0
- package/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.js +437 -0
- package/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.js.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.d.ts +2 -0
- package/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js +336 -0
- package/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.d.ts +2 -0
- package/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.js +437 -0
- package/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.js.map +1 -0
- package/dist/runtime-v2/internalization/diag-distiller-runner.d.ts +83 -0
- package/dist/runtime-v2/internalization/diag-distiller-runner.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/diag-distiller-runner.js +274 -0
- package/dist/runtime-v2/internalization/diag-distiller-runner.js.map +1 -0
- package/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts +73 -0
- package/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/diag-rootcause-runner.js +229 -0
- package/dist/runtime-v2/internalization/diag-rootcause-runner.js.map +1 -0
- package/dist/runtime-v2/internalization/diag-router-runner.d.ts +85 -0
- package/dist/runtime-v2/internalization/diag-router-runner.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/diag-router-runner.js +353 -0
- package/dist/runtime-v2/internalization/diag-router-runner.js.map +1 -0
- package/dist/runtime-v2/internalization/evaluator-runner.d.ts +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.js +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/split-diagnostician-runner.d.ts +66 -0
- package/dist/runtime-v2/internalization/split-diagnostician-runner.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/split-diagnostician-runner.js +172 -0
- package/dist/runtime-v2/internalization/split-diagnostician-runner.js.map +1 -0
- package/dist/runtime-v2/pain-signal-bridge.d.ts +22 -3
- package/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
- package/dist/runtime-v2/pain-signal-bridge.js +16 -7
- package/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
- package/dist/runtime-v2/pain-signal-runtime-factory.d.ts +3 -0
- package/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
- package/dist/runtime-v2/pain-signal-runtime-factory.js +52 -24
- package/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
- package/dist/runtime-v2/runner/__tests__/base-peer-runner-trust-boundary.test.js +2 -2
- package/dist/runtime-v2/runner/__tests__/base-peer-runner-trust-boundary.test.js.map +1 -1
- package/dist/runtime-v2/runner/base-peer-runner.d.ts +3 -3
- package/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
- package/dist/runtime-v2/runner/base-peer-runner.js +6 -6
- package/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
- package/dist/runtime-v2/runner/peer-runner-types.d.ts +3 -3
- package/dist/runtime-v2/runner/peer-runner-types.d.ts.map +1 -1
- package/dist/runtime-v2/store/candidate/sqlite-candidate-store.js +2 -2
- package/dist/runtime-v2/store/candidate/sqlite-candidate-store.js.map +1 -1
- package/dist/runtime-v2/types/principle-enums.d.ts +2 -2
- package/dist/runtime-v2/types/principle-enums.d.ts.map +1 -1
- package/dist/runtime-v2/types/principle-enums.js +1 -0
- package/dist/runtime-v2/types/principle-enums.js.map +1 -1
- package/dist/runtime-v2/types/principle-schema.d.ts +1 -1
- package/dist/runtime-v2/types/principle-tree-store.d.ts +1 -1
- package/dist/telemetry-event.d.ts +2 -2
- package/dist/telemetry-event.d.ts.map +1 -1
- package/dist/telemetry-event.js +1 -0
- package/dist/telemetry-event.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiagDistillerRunner — Stage B runner for the split diagnostician pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Takes the root-cause artifact from Stage A and produces an abstracted,
|
|
5
|
+
* cross-scenario principle grounded on the T-01..T-10 core axiom registry.
|
|
6
|
+
*
|
|
7
|
+
* Extends BasePeerRunner following the DreamerRunner pattern (PRI-302).
|
|
8
|
+
* The shared lease → buildContext → invoke → poll → fetch → validate →
|
|
9
|
+
* succeed/fail pipeline is in the base class. This file only contains
|
|
10
|
+
* Stage B–specific logic.
|
|
11
|
+
*
|
|
12
|
+
* Key constraints:
|
|
13
|
+
* - Uses PDRuntimeAdapter for all LLM execution (no direct SDK calls)
|
|
14
|
+
* - No plugin-layer imports (core is infrastructure-agnostic)
|
|
15
|
+
* - Uses RuntimeStateManager for all state operations
|
|
16
|
+
* - NO candidate commit — only writes PIArtifact (like DreamerRunner)
|
|
17
|
+
* - Reads diagnostician_core_grounding flag from effectiveConfig (PRI-371)
|
|
18
|
+
* - Validates groundedOnCorePrincipleIds against registry (fabricated IDs fail)
|
|
19
|
+
* - Lineage integrity: output.sourceRootCauseArtifactId must match context
|
|
20
|
+
*
|
|
21
|
+
* @see PRI-372
|
|
22
|
+
* @see BasePeerRunner in runner/base-peer-runner.ts
|
|
23
|
+
*/
|
|
24
|
+
import { Value } from '@sinclair/typebox/value';
|
|
25
|
+
import { DiagRootCauseOutputV1Schema } from '../diagnostician/diag-rootcause-output.js';
|
|
26
|
+
import { PDRuntimeError } from '../error-categories.js';
|
|
27
|
+
import { hydratePITaskRecord } from './pitask-metadata.js';
|
|
28
|
+
import { DistillerPromptBuilder } from '../diagnostician/distiller-prompt-builder.js';
|
|
29
|
+
import { injectRunnerLineageIfAbsent } from './peer-runner-contracts.js';
|
|
30
|
+
import { computeFeatureFlagsFromConfig, isFeatureEnabled } from '../config/pd-config-feature-flags.js';
|
|
31
|
+
import { BasePeerRunner } from '../runner/base-peer-runner.js';
|
|
32
|
+
// ── DiagDistillerRunner ──────────────────────────────────────────────────────
|
|
33
|
+
/**
|
|
34
|
+
* Stage B runner for the split diagnostician pipeline.
|
|
35
|
+
*
|
|
36
|
+
* Produces a DiagDistillerOutputV1 containing the abstracted principle,
|
|
37
|
+
* core axiom grounding, scope, and confidence. Does NOT commit candidates —
|
|
38
|
+
* that is the responsibility of Stage C (DiagRouterRunner).
|
|
39
|
+
*
|
|
40
|
+
* @see PRI-372
|
|
41
|
+
*/
|
|
42
|
+
export class DiagDistillerRunner extends BasePeerRunner {
|
|
43
|
+
validator;
|
|
44
|
+
effectiveConfig;
|
|
45
|
+
constructor(deps, options) {
|
|
46
|
+
super(deps, options, {
|
|
47
|
+
runnerName: 'diag_distiller',
|
|
48
|
+
expectedTaskKind: 'diag_distiller',
|
|
49
|
+
defaultAgentId: 'diag_distiller',
|
|
50
|
+
resultRefPrefix: 'diag-distiller',
|
|
51
|
+
});
|
|
52
|
+
this.validator = deps.validator;
|
|
53
|
+
this.effectiveConfig = options.effectiveConfig;
|
|
54
|
+
}
|
|
55
|
+
// ── Abstract implementations ───────────────────────────────────────────────
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
57
|
+
get permanentErrorCategories() {
|
|
58
|
+
return new Set(['storage_unavailable', 'workspace_invalid', 'capability_missing', 'cancelled', 'input_invalid']);
|
|
59
|
+
}
|
|
60
|
+
async buildContext(taskId) {
|
|
61
|
+
const task = await this.stateManager.getTask(taskId);
|
|
62
|
+
if (!task) {
|
|
63
|
+
throw new PDRuntimeError('input_invalid', `Task ${taskId} not found`);
|
|
64
|
+
}
|
|
65
|
+
const piTask = hydratePITaskRecord(task);
|
|
66
|
+
const deps = piTask?.dependencyTaskIds ?? [];
|
|
67
|
+
if (deps.length === 0) {
|
|
68
|
+
throw new PDRuntimeError('input_invalid', `DiagDistiller task ${taskId} has no predecessor dependency`);
|
|
69
|
+
}
|
|
70
|
+
// Resolve predecessor artifact (Stage A root cause)
|
|
71
|
+
const [depId] = deps;
|
|
72
|
+
if (!depId) {
|
|
73
|
+
throw new PDRuntimeError('input_invalid', `DiagDistiller task ${taskId} has no predecessor dependency`);
|
|
74
|
+
}
|
|
75
|
+
const artifacts = await this.artifactStore.listBySourceTaskId(depId);
|
|
76
|
+
if (artifacts.length === 0) {
|
|
77
|
+
throw new PDRuntimeError('input_invalid', `No root cause artifact found for predecessor task ${depId}`);
|
|
78
|
+
}
|
|
79
|
+
const [rootCauseArtifact] = artifacts;
|
|
80
|
+
if (!rootCauseArtifact) {
|
|
81
|
+
throw new PDRuntimeError('input_invalid', `No root cause artifact found for predecessor task ${depId}`);
|
|
82
|
+
}
|
|
83
|
+
const rootCauseArtifactId = rootCauseArtifact.artifactId;
|
|
84
|
+
// Parse predecessor output — ERR-001: treat parsed artifact content as unknown
|
|
85
|
+
// before runtime validation (Runtime Contract Rule 1).
|
|
86
|
+
let rootCauseOutput;
|
|
87
|
+
let parsedRootCause;
|
|
88
|
+
try {
|
|
89
|
+
parsedRootCause = JSON.parse(rootCauseArtifact.contentJson);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
throw new PDRuntimeError('input_invalid', `Failed to parse root cause artifact content for predecessor task ${depId}`);
|
|
93
|
+
}
|
|
94
|
+
// EP-01: Runtime validation of parsed DB content before typed assignment
|
|
95
|
+
if (!Value.Check(DiagRootCauseOutputV1Schema, parsedRootCause)) {
|
|
96
|
+
const errors = [...Value.Errors(DiagRootCauseOutputV1Schema, parsedRootCause)]
|
|
97
|
+
.slice(0, 3)
|
|
98
|
+
.map((e) => `${e.path}: ${e.message}`);
|
|
99
|
+
throw new PDRuntimeError('input_invalid', `Root cause artifact content failed schema validation for predecessor task ${depId}: ${errors.join('; ')}`);
|
|
100
|
+
}
|
|
101
|
+
rootCauseOutput = parsedRootCause;
|
|
102
|
+
// Read coreGrounding flag from effectiveConfig
|
|
103
|
+
let coreGrounding = false;
|
|
104
|
+
if (this.effectiveConfig) {
|
|
105
|
+
const featureFlags = computeFeatureFlagsFromConfig(this.effectiveConfig);
|
|
106
|
+
coreGrounding = isFeatureEnabled(featureFlags, 'diagnostician_core_grounding');
|
|
107
|
+
}
|
|
108
|
+
// Compute contextHash
|
|
109
|
+
const contextRefs = [rootCauseArtifactId];
|
|
110
|
+
if (rootCauseArtifact.lineageArtifactIds) {
|
|
111
|
+
contextRefs.push(...rootCauseArtifact.lineageArtifactIds);
|
|
112
|
+
}
|
|
113
|
+
const contextHash = BasePeerRunner.hashContextRefs(contextRefs);
|
|
114
|
+
const context = { contextHash, contextRefs, rootCauseArtifactId, rootCauseOutput, coreGrounding };
|
|
115
|
+
return context;
|
|
116
|
+
}
|
|
117
|
+
async invokeRuntime(taskId, context) {
|
|
118
|
+
const builder = new DistillerPromptBuilder();
|
|
119
|
+
const { message } = builder.buildPrompt({
|
|
120
|
+
rootCauseArtifactId: context.rootCauseArtifactId,
|
|
121
|
+
rootCauseOutput: context.rootCauseOutput,
|
|
122
|
+
coreGrounding: context.coreGrounding,
|
|
123
|
+
}, {
|
|
124
|
+
outputLanguage: this.resolvedOptions.outputLanguage,
|
|
125
|
+
coreGrounding: context.coreGrounding,
|
|
126
|
+
});
|
|
127
|
+
return this.runtimeAdapter.startRun({
|
|
128
|
+
agentSpec: { agentId: this.resolvedOptions.agentId, schemaVersion: 'v1' },
|
|
129
|
+
taskRef: { taskId },
|
|
130
|
+
inputPayload: message,
|
|
131
|
+
contextItems: [],
|
|
132
|
+
outputSchemaRef: 'diag-distiller-output-v1',
|
|
133
|
+
timeoutMs: this.resolvedOptions.timeoutMs,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async validateOutput(output, taskId, _context) {
|
|
137
|
+
const result = await this.validator.validate(output, taskId);
|
|
138
|
+
return {
|
|
139
|
+
valid: result.valid,
|
|
140
|
+
errors: result.errors,
|
|
141
|
+
errorCategory: result.errorCategory,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
145
|
+
async succeedTask(taskId, runId, output, task, contextHash, _context) {
|
|
146
|
+
// 1. Store output before marking succeeded
|
|
147
|
+
try {
|
|
148
|
+
await this.stateManager.updateRunOutput(runId, JSON.stringify(output));
|
|
149
|
+
}
|
|
150
|
+
catch (updateErr) {
|
|
151
|
+
this.emitEvent('update_output_failed', taskId, {
|
|
152
|
+
runId,
|
|
153
|
+
errorMessage: updateErr instanceof Error ? updateErr.message : String(updateErr),
|
|
154
|
+
});
|
|
155
|
+
throw updateErr;
|
|
156
|
+
}
|
|
157
|
+
// 2. Write PIArtifact via artifactStore (idempotent upsert) — NO candidate commit
|
|
158
|
+
let lineageArtifactIds = [];
|
|
159
|
+
let lineageHasRejected = false;
|
|
160
|
+
try {
|
|
161
|
+
const lineageResult = await this.resolveLineageArtifactIds(taskId);
|
|
162
|
+
lineageArtifactIds = lineageResult.ids;
|
|
163
|
+
lineageHasRejected = lineageResult.hasRejected;
|
|
164
|
+
}
|
|
165
|
+
catch (lineageErr) {
|
|
166
|
+
this.emitEvent('lineage_resolve_failed', taskId, {
|
|
167
|
+
runId,
|
|
168
|
+
errorMessage: lineageErr instanceof Error ? lineageErr.message : String(lineageErr),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (lineageHasRejected) {
|
|
172
|
+
this.emitEvent('lineage_partial', taskId, {
|
|
173
|
+
runId,
|
|
174
|
+
resolvedCount: lineageArtifactIds.length,
|
|
175
|
+
warning: 'Some dependency artifact queries were rejected; lineage may be incomplete',
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
const artifactId = `pi-art-${taskId}-${runId}`;
|
|
179
|
+
const now = new Date().toISOString();
|
|
180
|
+
try {
|
|
181
|
+
await this.artifactStore.upsertArtifact({
|
|
182
|
+
artifactId,
|
|
183
|
+
artifactKind: 'principle',
|
|
184
|
+
sourceTaskId: taskId,
|
|
185
|
+
lineageArtifactIds,
|
|
186
|
+
validationStatus: 'pending',
|
|
187
|
+
contentJson: JSON.stringify(output),
|
|
188
|
+
createdAt: now,
|
|
189
|
+
updatedAt: now,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (artifactErr) {
|
|
193
|
+
this.emitEvent('artifact_write_failed', taskId, {
|
|
194
|
+
runId,
|
|
195
|
+
errorMessage: artifactErr instanceof Error ? artifactErr.message : String(artifactErr),
|
|
196
|
+
});
|
|
197
|
+
return this.retryOrFail({
|
|
198
|
+
taskId,
|
|
199
|
+
task,
|
|
200
|
+
errorCategory: 'artifact_commit_failed',
|
|
201
|
+
failureReason: `PIArtifact write failed: ${artifactErr instanceof Error ? artifactErr.message : String(artifactErr)}`,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// 3. Mark task succeeded
|
|
205
|
+
const resultRef = `${this.config.resultRefPrefix}://${runId}`;
|
|
206
|
+
try {
|
|
207
|
+
await this.stateManager.markTaskSucceeded(taskId, resultRef);
|
|
208
|
+
}
|
|
209
|
+
catch (stateErr) {
|
|
210
|
+
this.emitEvent('mark_succeeded_failed', taskId, {
|
|
211
|
+
taskId,
|
|
212
|
+
runId,
|
|
213
|
+
errorMessage: stateErr instanceof Error ? stateErr.message : String(stateErr),
|
|
214
|
+
});
|
|
215
|
+
throw stateErr;
|
|
216
|
+
}
|
|
217
|
+
// 4. Emit diag_distiller_task_succeeded telemetry
|
|
218
|
+
this.emitEvent('task_succeeded', taskId, {
|
|
219
|
+
attemptCount: task.attemptCount,
|
|
220
|
+
resultRef,
|
|
221
|
+
groundedOnCorePrincipleIds: output.groundedOnCorePrincipleIds,
|
|
222
|
+
scope: output.scope,
|
|
223
|
+
});
|
|
224
|
+
return {
|
|
225
|
+
status: 'succeeded',
|
|
226
|
+
taskId,
|
|
227
|
+
runId,
|
|
228
|
+
artifactId,
|
|
229
|
+
resultRef,
|
|
230
|
+
contextHash,
|
|
231
|
+
output,
|
|
232
|
+
attemptCount: task.attemptCount,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
// ── Optional hooks ─────────────────────────────────────────────────────────
|
|
236
|
+
/**
|
|
237
|
+
* Re-inject taskId and sourceRootCauseArtifactId if stripped by
|
|
238
|
+
* stripLineageFields (PRI-272 / ERR-008).
|
|
239
|
+
* Only fill when absent via Object.hasOwn — present-but-falsy values
|
|
240
|
+
* must reach validation and fail loud (Runtime Contract Rule 3).
|
|
241
|
+
*/
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
243
|
+
postFetchTransform(taskId, untrustedOutput) {
|
|
244
|
+
injectRunnerLineageIfAbsent(untrustedOutput, 'taskId', taskId);
|
|
245
|
+
// sourceRootCauseArtifactId is NOT re-injected here because it comes
|
|
246
|
+
// from the predecessor artifact, not from the runner's own context.
|
|
247
|
+
// The validator checks its value against the expected artifact ID.
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Check lineage strip contract invariant (EP-07).
|
|
251
|
+
*
|
|
252
|
+
* After validation passes, verify that the output's sourceRootCauseArtifactId
|
|
253
|
+
* matches the context's rootCauseArtifactId. If they mismatch, the LLM
|
|
254
|
+
* fabricated or altered the lineage field — emit telemetry and throw.
|
|
255
|
+
*/
|
|
256
|
+
checkLineageIntegrity(taskId, output, context) {
|
|
257
|
+
if (context.rootCauseArtifactId && output.sourceRootCauseArtifactId !== context.rootCauseArtifactId) {
|
|
258
|
+
this.emitEvent('lineage_integrity_violation', taskId, {
|
|
259
|
+
expectedArtifactId: context.rootCauseArtifactId,
|
|
260
|
+
actualArtifactId: output.sourceRootCauseArtifactId,
|
|
261
|
+
field: 'sourceRootCauseArtifactId',
|
|
262
|
+
});
|
|
263
|
+
throw new PDRuntimeError('output_invalid', `sourceRootCauseArtifactId mismatch: expected ${context.rootCauseArtifactId}, got ${output.sourceRootCauseArtifactId}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
emitSuccessTelemetry(taskId, output, _context) {
|
|
267
|
+
this.emitEvent('distiller_completed', taskId, {
|
|
268
|
+
groundedOnCorePrincipleIds: output.groundedOnCorePrincipleIds,
|
|
269
|
+
scope: output.scope,
|
|
270
|
+
confidence: output.confidence,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=diag-distiller-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diag-distiller-runner.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/diag-distiller-run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EAAE,MAAM,CAAC,KAAK;YACnB,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiagRootCauseRunner — Stage A runner for the split diagnostician pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Identifies the underlying cause of a pain signal using a 5-Whys causal
|
|
5
|
+
* chain and categorises it into one of four root-cause categories.
|
|
6
|
+
*
|
|
7
|
+
* Extends BasePeerRunner following the DreamerRunner pattern (PRI-302).
|
|
8
|
+
* The shared lease → buildContext → invoke → poll → fetch → validate →
|
|
9
|
+
* succeed/fail pipeline is in the base class. This file only contains
|
|
10
|
+
* Stage A–specific logic.
|
|
11
|
+
*
|
|
12
|
+
* Key constraints:
|
|
13
|
+
* - Uses PDRuntimeAdapter for all LLM execution (no direct SDK calls)
|
|
14
|
+
* - No plugin-layer imports (core is infrastructure-agnostic)
|
|
15
|
+
* - Uses RuntimeStateManager for all state operations
|
|
16
|
+
* - NO candidate commit — only writes PIArtifact (like DreamerRunner)
|
|
17
|
+
* - Reads diagnostician_core_grounding flag from effectiveConfig (PRI-371)
|
|
18
|
+
*
|
|
19
|
+
* @see PRI-372
|
|
20
|
+
* @see BasePeerRunner in runner/base-peer-runner.ts
|
|
21
|
+
*/
|
|
22
|
+
import type { RunHandle } from '../runtime-protocol.js';
|
|
23
|
+
import type { DiagRootCauseOutputV1, DiagRootCauseValidator } from '../diagnostician/diag-rootcause-output.js';
|
|
24
|
+
import type { DiagnosticianContextPayload } from '../context-payload.js';
|
|
25
|
+
import type { ContextAssembler } from '../store/context/context-assembler.js';
|
|
26
|
+
import type { TaskRecord } from '../task-status.js';
|
|
27
|
+
import type { EffectivePdConfig } from '../config/pd-config-types.js';
|
|
28
|
+
import { type PDErrorCategory } from '../error-categories.js';
|
|
29
|
+
import { BasePeerRunner } from '../runner/base-peer-runner.js';
|
|
30
|
+
import type { PeerRunnerOptions, PeerRunnerDeps, PeerRunnerResult, PeerRunnerValidationResult } from '../runner/peer-runner-types.js';
|
|
31
|
+
/** Context built by DiagRootCauseRunner.buildContext() and consumed by invokeRuntime(). */
|
|
32
|
+
interface DiagRootCauseContext {
|
|
33
|
+
readonly contextHash: string;
|
|
34
|
+
readonly contextRefs: string[];
|
|
35
|
+
readonly painPayload: DiagnosticianContextPayload;
|
|
36
|
+
}
|
|
37
|
+
export interface DiagRootCauseRunnerDeps extends PeerRunnerDeps {
|
|
38
|
+
readonly validator: DiagRootCauseValidator;
|
|
39
|
+
readonly contextAssembler: ContextAssembler;
|
|
40
|
+
}
|
|
41
|
+
export interface DiagRootCauseRunnerOptions extends PeerRunnerOptions {
|
|
42
|
+
/** Effective PD config for feature flag resolution (PRI-371). */
|
|
43
|
+
readonly effectiveConfig?: EffectivePdConfig;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Stage A runner for the split diagnostician pipeline.
|
|
47
|
+
*
|
|
48
|
+
* Produces a DiagRootCauseOutputV1 containing the 5-Whys causal chain,
|
|
49
|
+
* root cause classification, and evidence. Does NOT commit candidates —
|
|
50
|
+
* that is the responsibility of Stage C (DiagRouterRunner).
|
|
51
|
+
*
|
|
52
|
+
* @see PRI-372
|
|
53
|
+
*/
|
|
54
|
+
export declare class DiagRootCauseRunner extends BasePeerRunner<DiagRootCauseContext, DiagRootCauseOutputV1> {
|
|
55
|
+
private readonly validator;
|
|
56
|
+
private readonly contextAssembler;
|
|
57
|
+
private readonly effectiveConfig?;
|
|
58
|
+
constructor(deps: DiagRootCauseRunnerDeps, options: DiagRootCauseRunnerOptions);
|
|
59
|
+
get permanentErrorCategories(): ReadonlySet<PDErrorCategory>;
|
|
60
|
+
buildContext(taskId: string): Promise<DiagRootCauseContext>;
|
|
61
|
+
invokeRuntime(taskId: string, context: DiagRootCauseContext): Promise<RunHandle>;
|
|
62
|
+
validateOutput(output: unknown, taskId: string, _context: DiagRootCauseContext): Promise<PeerRunnerValidationResult>;
|
|
63
|
+
succeedTask(taskId: string, runId: string, output: DiagRootCauseOutputV1, task: TaskRecord, contextHash: string, _context: DiagRootCauseContext): Promise<PeerRunnerResult<DiagRootCauseOutputV1>>;
|
|
64
|
+
/**
|
|
65
|
+
* Re-inject taskId if stripped by stripLineageFields (PRI-272 / ERR-008).
|
|
66
|
+
* Only fill when absent via Object.hasOwn — present-but-falsy values
|
|
67
|
+
* must reach validation and fail loud (Runtime Contract Rule 3).
|
|
68
|
+
*/
|
|
69
|
+
protected postFetchTransform(taskId: string, untrustedOutput: unknown): void;
|
|
70
|
+
protected emitSuccessTelemetry(taskId: string, output: DiagRootCauseOutputV1, _context: DiagRootCauseContext): void;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=diag-rootcause-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diag-rootcause-runner.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/diag-rootcause-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAC/G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAK9E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,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,EAAE,oBAAoB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IA+FnD;;;;OAIG;cAEgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;cAIlE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,oBAAoB,GAAG,IAAI;CAM7H"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiagRootCauseRunner — Stage A runner for the split diagnostician pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Identifies the underlying cause of a pain signal using a 5-Whys causal
|
|
5
|
+
* chain and categorises it into one of four root-cause categories.
|
|
6
|
+
*
|
|
7
|
+
* Extends BasePeerRunner following the DreamerRunner pattern (PRI-302).
|
|
8
|
+
* The shared lease → buildContext → invoke → poll → fetch → validate →
|
|
9
|
+
* succeed/fail pipeline is in the base class. This file only contains
|
|
10
|
+
* Stage A–specific logic.
|
|
11
|
+
*
|
|
12
|
+
* Key constraints:
|
|
13
|
+
* - Uses PDRuntimeAdapter for all LLM execution (no direct SDK calls)
|
|
14
|
+
* - No plugin-layer imports (core is infrastructure-agnostic)
|
|
15
|
+
* - Uses RuntimeStateManager for all state operations
|
|
16
|
+
* - NO candidate commit — only writes PIArtifact (like DreamerRunner)
|
|
17
|
+
* - Reads diagnostician_core_grounding flag from effectiveConfig (PRI-371)
|
|
18
|
+
*
|
|
19
|
+
* @see PRI-372
|
|
20
|
+
* @see BasePeerRunner in runner/base-peer-runner.ts
|
|
21
|
+
*/
|
|
22
|
+
import { PDRuntimeError } from '../error-categories.js';
|
|
23
|
+
import { hydratePITaskRecord } from './pitask-metadata.js';
|
|
24
|
+
import { RootCausePromptBuilder } from '../diagnostician/rootcause-prompt-builder.js';
|
|
25
|
+
import { injectRunnerLineageIfAbsent } from './peer-runner-contracts.js';
|
|
26
|
+
import { computeFeatureFlagsFromConfig, isFeatureEnabled } from '../config/pd-config-feature-flags.js';
|
|
27
|
+
import { BasePeerRunner } from '../runner/base-peer-runner.js';
|
|
28
|
+
// ── DiagRootCauseRunner ──────────────────────────────────────────────────────
|
|
29
|
+
/**
|
|
30
|
+
* Stage A runner for the split diagnostician pipeline.
|
|
31
|
+
*
|
|
32
|
+
* Produces a DiagRootCauseOutputV1 containing the 5-Whys causal chain,
|
|
33
|
+
* root cause classification, and evidence. Does NOT commit candidates —
|
|
34
|
+
* that is the responsibility of Stage C (DiagRouterRunner).
|
|
35
|
+
*
|
|
36
|
+
* @see PRI-372
|
|
37
|
+
*/
|
|
38
|
+
export class DiagRootCauseRunner extends BasePeerRunner {
|
|
39
|
+
validator;
|
|
40
|
+
contextAssembler;
|
|
41
|
+
effectiveConfig;
|
|
42
|
+
constructor(deps, options) {
|
|
43
|
+
super(deps, options, {
|
|
44
|
+
runnerName: 'diag_rootcause',
|
|
45
|
+
expectedTaskKind: 'diag_rootcause',
|
|
46
|
+
defaultAgentId: 'diag_rootcause',
|
|
47
|
+
resultRefPrefix: 'diag-rootcause',
|
|
48
|
+
});
|
|
49
|
+
this.validator = deps.validator;
|
|
50
|
+
this.contextAssembler = deps.contextAssembler;
|
|
51
|
+
this.effectiveConfig = options.effectiveConfig;
|
|
52
|
+
}
|
|
53
|
+
// ── Abstract implementations ───────────────────────────────────────────────
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
55
|
+
get permanentErrorCategories() {
|
|
56
|
+
return new Set(['storage_unavailable', 'workspace_invalid', 'capability_missing', 'cancelled', 'input_invalid']);
|
|
57
|
+
}
|
|
58
|
+
async buildContext(taskId) {
|
|
59
|
+
const task = await this.stateManager.getTask(taskId);
|
|
60
|
+
if (!task) {
|
|
61
|
+
throw new PDRuntimeError('input_invalid', `Task ${taskId} not found`);
|
|
62
|
+
}
|
|
63
|
+
const parentTaskId = task.inputRef || taskId;
|
|
64
|
+
// Assemble pain signal context via ContextAssembler
|
|
65
|
+
const painPayload = await this.contextAssembler.assemble(parentTaskId);
|
|
66
|
+
// Compute contextHash from sourceRefs
|
|
67
|
+
const piTask = hydratePITaskRecord(task);
|
|
68
|
+
const deps = piTask?.dependencyTaskIds ?? [];
|
|
69
|
+
const contextRefs = [...painPayload.sourceRefs];
|
|
70
|
+
// Include predecessor result refs
|
|
71
|
+
if (deps.length > 0) {
|
|
72
|
+
const results = await Promise.allSettled(deps.map((depId) => this.stateManager.getTask(depId)));
|
|
73
|
+
for (let i = 0; i < results.length; i++) {
|
|
74
|
+
const result = results[i];
|
|
75
|
+
const depId = deps[i];
|
|
76
|
+
if (!result || depId === undefined)
|
|
77
|
+
continue;
|
|
78
|
+
if (result.status === 'fulfilled' && result.value) {
|
|
79
|
+
if (result.value.resultRef) {
|
|
80
|
+
contextRefs.push(result.value.resultRef);
|
|
81
|
+
}
|
|
82
|
+
const depPiTask = result.value ? hydratePITaskRecord(result.value) : null;
|
|
83
|
+
if (depPiTask?.outputArtifactRefs) {
|
|
84
|
+
contextRefs.push(...depPiTask.outputArtifactRefs.map((a) => a.ref));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const contextHash = BasePeerRunner.hashContextRefs(contextRefs);
|
|
90
|
+
return { contextHash, contextRefs, painPayload };
|
|
91
|
+
}
|
|
92
|
+
async invokeRuntime(taskId, context) {
|
|
93
|
+
// T-E (PRI-371): Read diagnostician_core_grounding flag from effective config.
|
|
94
|
+
let coreGrounding = false;
|
|
95
|
+
if (this.effectiveConfig) {
|
|
96
|
+
const featureFlags = computeFeatureFlagsFromConfig(this.effectiveConfig);
|
|
97
|
+
coreGrounding = isFeatureEnabled(featureFlags, 'diagnostician_core_grounding');
|
|
98
|
+
}
|
|
99
|
+
const builder = new RootCausePromptBuilder();
|
|
100
|
+
const { message } = builder.buildPrompt(context.painPayload, {
|
|
101
|
+
outputLanguage: this.resolvedOptions.outputLanguage,
|
|
102
|
+
coreGrounding,
|
|
103
|
+
});
|
|
104
|
+
return this.runtimeAdapter.startRun({
|
|
105
|
+
agentSpec: { agentId: this.resolvedOptions.agentId, schemaVersion: 'v1' },
|
|
106
|
+
taskRef: { taskId },
|
|
107
|
+
inputPayload: message,
|
|
108
|
+
contextItems: [],
|
|
109
|
+
outputSchemaRef: 'diag-rootcause-output-v1',
|
|
110
|
+
timeoutMs: this.resolvedOptions.timeoutMs,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async validateOutput(output, taskId, _context) {
|
|
114
|
+
const result = await this.validator.validate(output, taskId);
|
|
115
|
+
return {
|
|
116
|
+
valid: result.valid,
|
|
117
|
+
errors: result.errors,
|
|
118
|
+
errorCategory: result.errorCategory,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
122
|
+
async succeedTask(taskId, runId, output, task, contextHash, _context) {
|
|
123
|
+
// 1. Store output before marking succeeded
|
|
124
|
+
try {
|
|
125
|
+
await this.stateManager.updateRunOutput(runId, JSON.stringify(output));
|
|
126
|
+
}
|
|
127
|
+
catch (updateErr) {
|
|
128
|
+
this.emitEvent('update_output_failed', taskId, {
|
|
129
|
+
runId,
|
|
130
|
+
errorMessage: updateErr instanceof Error ? updateErr.message : String(updateErr),
|
|
131
|
+
});
|
|
132
|
+
throw updateErr;
|
|
133
|
+
}
|
|
134
|
+
// 2. Write PIArtifact via artifactStore (idempotent upsert) — NO candidate commit
|
|
135
|
+
let lineageArtifactIds = [];
|
|
136
|
+
let lineageHasRejected = false;
|
|
137
|
+
try {
|
|
138
|
+
const lineageResult = await this.resolveLineageArtifactIds(taskId);
|
|
139
|
+
lineageArtifactIds = lineageResult.ids;
|
|
140
|
+
lineageHasRejected = lineageResult.hasRejected;
|
|
141
|
+
}
|
|
142
|
+
catch (lineageErr) {
|
|
143
|
+
this.emitEvent('lineage_resolve_failed', taskId, {
|
|
144
|
+
runId,
|
|
145
|
+
errorMessage: lineageErr instanceof Error ? lineageErr.message : String(lineageErr),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (lineageHasRejected) {
|
|
149
|
+
this.emitEvent('lineage_partial', taskId, {
|
|
150
|
+
runId,
|
|
151
|
+
resolvedCount: lineageArtifactIds.length,
|
|
152
|
+
warning: 'Some dependency artifact queries were rejected; lineage may be incomplete',
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const artifactId = `pi-art-${taskId}-${runId}`;
|
|
156
|
+
const now = new Date().toISOString();
|
|
157
|
+
try {
|
|
158
|
+
await this.artifactStore.upsertArtifact({
|
|
159
|
+
artifactId,
|
|
160
|
+
artifactKind: 'principle',
|
|
161
|
+
sourceTaskId: taskId,
|
|
162
|
+
lineageArtifactIds,
|
|
163
|
+
validationStatus: 'pending',
|
|
164
|
+
contentJson: JSON.stringify(output),
|
|
165
|
+
createdAt: now,
|
|
166
|
+
updatedAt: now,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (artifactErr) {
|
|
170
|
+
this.emitEvent('artifact_write_failed', taskId, {
|
|
171
|
+
runId,
|
|
172
|
+
errorMessage: artifactErr instanceof Error ? artifactErr.message : String(artifactErr),
|
|
173
|
+
});
|
|
174
|
+
return this.retryOrFail({
|
|
175
|
+
taskId,
|
|
176
|
+
task,
|
|
177
|
+
errorCategory: 'artifact_commit_failed',
|
|
178
|
+
failureReason: `PIArtifact write failed: ${artifactErr instanceof Error ? artifactErr.message : String(artifactErr)}`,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
// 3. Mark task succeeded
|
|
182
|
+
const resultRef = `${this.config.resultRefPrefix}://${runId}`;
|
|
183
|
+
try {
|
|
184
|
+
await this.stateManager.markTaskSucceeded(taskId, resultRef);
|
|
185
|
+
}
|
|
186
|
+
catch (stateErr) {
|
|
187
|
+
this.emitEvent('mark_succeeded_failed', taskId, {
|
|
188
|
+
taskId,
|
|
189
|
+
runId,
|
|
190
|
+
errorMessage: stateErr instanceof Error ? stateErr.message : String(stateErr),
|
|
191
|
+
});
|
|
192
|
+
throw stateErr;
|
|
193
|
+
}
|
|
194
|
+
// 4. Emit diag_rootcause_task_succeeded telemetry
|
|
195
|
+
this.emitEvent('task_succeeded', taskId, {
|
|
196
|
+
attemptCount: task.attemptCount,
|
|
197
|
+
resultRef,
|
|
198
|
+
rootCauseCategory: output.rootCauseCategory,
|
|
199
|
+
causalChainDepth: output.causalChain.length,
|
|
200
|
+
});
|
|
201
|
+
return {
|
|
202
|
+
status: 'succeeded',
|
|
203
|
+
taskId,
|
|
204
|
+
runId,
|
|
205
|
+
artifactId,
|
|
206
|
+
resultRef,
|
|
207
|
+
contextHash,
|
|
208
|
+
output,
|
|
209
|
+
attemptCount: task.attemptCount,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
// ── Optional hooks ─────────────────────────────────────────────────────────
|
|
213
|
+
/**
|
|
214
|
+
* Re-inject taskId if stripped by stripLineageFields (PRI-272 / ERR-008).
|
|
215
|
+
* Only fill when absent via Object.hasOwn — present-but-falsy values
|
|
216
|
+
* must reach validation and fail loud (Runtime Contract Rule 3).
|
|
217
|
+
*/
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
219
|
+
postFetchTransform(taskId, untrustedOutput) {
|
|
220
|
+
injectRunnerLineageIfAbsent(untrustedOutput, 'taskId', taskId);
|
|
221
|
+
}
|
|
222
|
+
emitSuccessTelemetry(taskId, output, _context) {
|
|
223
|
+
this.emitEvent('rootcause_completed', taskId, {
|
|
224
|
+
rootCauseCategory: output.rootCauseCategory,
|
|
225
|
+
causalChainDepth: output.causalChain.length,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=diag-rootcause-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diag-rootcause-runner.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/diag-rootcause-runner.ts"],"names":[],"mappings":"AAAA;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