@principles/core 1.84.0 → 1.85.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/internalization/__tests__/philosopher-runner-trust-boundary.test.d.ts +2 -0
- package/dist/runtime-v2/internalization/__tests__/philosopher-runner-trust-boundary.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/philosopher-runner-trust-boundary.test.js +398 -0
- package/dist/runtime-v2/internalization/__tests__/philosopher-runner-trust-boundary.test.js.map +1 -0
- package/dist/runtime-v2/internalization/philosopher-output.d.ts +8 -2
- package/dist/runtime-v2/internalization/philosopher-output.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/philosopher-output.js +16 -11
- package/dist/runtime-v2/internalization/philosopher-output.js.map +1 -1
- package/dist/runtime-v2/internalization/philosopher-runner.d.ts +36 -55
- package/dist/runtime-v2/internalization/philosopher-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/philosopher-runner.js +117 -401
- package/dist/runtime-v2/internalization/philosopher-runner.js.map +1 -1
- package/dist/runtime-v2/runner/__tests__/base-peer-runner-trust-boundary.test.js +22 -0
- 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.map +1 -1
- package/dist/runtime-v2/runner/base-peer-runner.js +5 -1
- package/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
- package/dist/telemetry-event.d.ts +2 -2
- package/dist/telemetry-event.d.ts.map +1 -1
- package/dist/telemetry-event.js +23 -0
- package/dist/telemetry-event.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PhilosopherRunner — Second peer runner for the Internalization Engine (PRI-90).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Migrated to extend BasePeerRunner (PRI-new). The shared lease → buildContext →
|
|
5
|
+
* invoke → poll → fetch → validate → succeed/fail pipeline is now in the base
|
|
6
|
+
* class. This file only contains Philosopher-specific logic.
|
|
6
7
|
*
|
|
7
8
|
* Key constraints (ADR-0003):
|
|
8
9
|
* - Uses PDRuntimeAdapter for all LLM execution (no direct SDK calls)
|
|
@@ -17,20 +18,25 @@
|
|
|
17
18
|
* 3. fetch Dreamer artifact via PIArtifactStore
|
|
18
19
|
* 4. startRun with outputSchemaRef: 'philosopher-output-v1'
|
|
19
20
|
* 5. pollUntilTerminal
|
|
20
|
-
* 6. fetchOutput →
|
|
21
|
-
* 7.
|
|
22
|
-
* 8.
|
|
23
|
-
* 9. write PIArtifact → markTaskSucceeded with philosopher:// resultRef
|
|
21
|
+
* 6. fetchOutput → validate as unknown → cast to PhilosopherOutputV1
|
|
22
|
+
* 7. updateRunOutput → persist serialized output
|
|
23
|
+
* 8. write PIArtifact → markTaskSucceeded with philosopher:// resultRef
|
|
24
24
|
*
|
|
25
25
|
* @see docs/adr/0003-peer-agent-state-machine-orchestration.md
|
|
26
|
+
* @see BasePeerRunner in runner/base-peer-runner.ts
|
|
26
27
|
*/
|
|
27
|
-
import type {
|
|
28
|
-
import type { PDRuntimeAdapter } from '../runtime-protocol.js';
|
|
29
|
-
import type { StoreEventEmitter } from '../store/event-emitter.js';
|
|
28
|
+
import type { RunHandle } from '../runtime-protocol.js';
|
|
30
29
|
import type { PhilosopherOutputV1, PhilosopherValidator } from './philosopher-output.js';
|
|
31
|
-
import type {
|
|
30
|
+
import type { TaskRecord } from '../task-status.js';
|
|
32
31
|
import { type PDErrorCategory } from '../error-categories.js';
|
|
33
|
-
import {
|
|
32
|
+
import { BasePeerRunner } from '../runner/base-peer-runner.js';
|
|
33
|
+
import type { PeerRunnerOptions, PeerRunnerDeps, PeerRunnerResult, PeerRunnerValidationResult } from '../runner/peer-runner-types.js';
|
|
34
|
+
/** Context built by PhilosopherRunner.buildContext() and consumed by invokeRuntime(). */
|
|
35
|
+
interface PhilosopherContext {
|
|
36
|
+
readonly contextHash: string;
|
|
37
|
+
readonly dreamerArtifact: string;
|
|
38
|
+
readonly sourceDreamerArtifactId: string;
|
|
39
|
+
}
|
|
34
40
|
export type PhilosopherRunnerResultStatus = 'succeeded' | 'failed' | 'retried';
|
|
35
41
|
export interface PhilosopherRunnerResult {
|
|
36
42
|
readonly status: PhilosopherRunnerResultStatus;
|
|
@@ -44,14 +50,7 @@ export interface PhilosopherRunnerResult {
|
|
|
44
50
|
readonly failureReason?: string;
|
|
45
51
|
readonly attemptCount: number;
|
|
46
52
|
}
|
|
47
|
-
export
|
|
48
|
-
readonly pollIntervalMs?: number;
|
|
49
|
-
readonly timeoutMs?: number;
|
|
50
|
-
readonly defaultMaxAttempts?: number;
|
|
51
|
-
readonly owner: string;
|
|
52
|
-
readonly runtimeKind: string;
|
|
53
|
-
readonly agentId?: string;
|
|
54
|
-
}
|
|
53
|
+
export type PhilosopherRunnerOptions = PeerRunnerOptions;
|
|
55
54
|
export interface ResolvedPhilosopherRunnerOptions {
|
|
56
55
|
readonly pollIntervalMs: number;
|
|
57
56
|
readonly timeoutMs: number;
|
|
@@ -60,44 +59,26 @@ export interface ResolvedPhilosopherRunnerOptions {
|
|
|
60
59
|
readonly runtimeKind: string;
|
|
61
60
|
readonly agentId: string;
|
|
62
61
|
}
|
|
63
|
-
declare const DEFAULT_PHILOSOPHER_RUNNER_OPTIONS: Readonly<Omit<ResolvedPhilosopherRunnerOptions, 'owner' | 'runtimeKind'>>;
|
|
64
|
-
declare function resolvePhilosopherRunnerOptions(options: PhilosopherRunnerOptions): ResolvedPhilosopherRunnerOptions;
|
|
65
|
-
export interface PhilosopherRunnerDeps {
|
|
66
|
-
readonly stateManager: RuntimeStateManager;
|
|
67
|
-
readonly runtimeAdapter: PDRuntimeAdapter;
|
|
68
|
-
readonly eventEmitter: StoreEventEmitter;
|
|
62
|
+
export declare const DEFAULT_PHILOSOPHER_RUNNER_OPTIONS: Readonly<Omit<ResolvedPhilosopherRunnerOptions, 'owner' | 'runtimeKind'>>;
|
|
63
|
+
export declare function resolvePhilosopherRunnerOptions(options: PhilosopherRunnerOptions): ResolvedPhilosopherRunnerOptions;
|
|
64
|
+
export interface PhilosopherRunnerDeps extends PeerRunnerDeps {
|
|
69
65
|
readonly validator: PhilosopherValidator;
|
|
70
|
-
readonly artifactStore: PIArtifactStore;
|
|
71
66
|
}
|
|
72
|
-
export declare class PhilosopherRunner {
|
|
73
|
-
private phase;
|
|
74
|
-
private readonly resolvedOptions;
|
|
75
|
-
private readonly stateManager;
|
|
76
|
-
private readonly runtimeAdapter;
|
|
77
|
-
private readonly eventEmitter;
|
|
67
|
+
export declare class PhilosopherRunner extends BasePeerRunner<PhilosopherContext, PhilosopherOutputV1> {
|
|
78
68
|
private readonly validator;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
private handleValidationError;
|
|
93
|
-
private handleLeaseOrPhaseError;
|
|
94
|
-
private handlePostLeaseError;
|
|
95
|
-
private retryOrFail;
|
|
96
|
-
private readonly PERMANENT_ERROR_CATEGORIES;
|
|
97
|
-
private isPermanentError;
|
|
98
|
-
private classifyError;
|
|
99
|
-
private mapRunStatusToErrorCategory;
|
|
100
|
-
private sleep;
|
|
69
|
+
constructor(deps: PhilosopherRunnerDeps, options: PeerRunnerOptions);
|
|
70
|
+
get permanentErrorCategories(): ReadonlySet<PDErrorCategory>;
|
|
71
|
+
buildContext(taskId: string): Promise<PhilosopherContext>;
|
|
72
|
+
invokeRuntime(taskId: string, context: PhilosopherContext): Promise<RunHandle>;
|
|
73
|
+
validateOutput(output: unknown, taskId: string): Promise<PeerRunnerValidationResult>;
|
|
74
|
+
succeedTask(taskId: string, runId: string, output: PhilosopherOutputV1, task: TaskRecord, contextHash: string, context: PhilosopherContext): Promise<PeerRunnerResult<PhilosopherOutputV1>>;
|
|
75
|
+
/**
|
|
76
|
+
* Re-inject taskId if stripped by stripLineageFields (PRI-272 / ERR-008).
|
|
77
|
+
* Only fill when absent via Object.hasOwn — present-but-falsy values
|
|
78
|
+
* must reach validation and fail loud (Runtime Contract Rule 3).
|
|
79
|
+
*/
|
|
80
|
+
protected postFetchTransform(taskId: string, untrustedOutput: unknown): void;
|
|
81
|
+
protected emitSuccessTelemetry(taskId: string, output: PhilosopherOutputV1): void;
|
|
101
82
|
}
|
|
102
|
-
export {
|
|
83
|
+
export {};
|
|
103
84
|
//# sourceMappingURL=philosopher-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"philosopher-runner.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/philosopher-runner.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"philosopher-runner.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/philosopher-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAkB,KAAK,eAAe,EAAqB,MAAM,wBAAwB,CAAC;AAIjG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,gCAAgC,CAAC;AAIxC,yFAAyF;AACzF,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;CAC1C;AAID,MAAM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