@principles/pd-cli 1.111.0 → 1.113.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/commands/__tests__/run-rulehost-flag-wiring.test.d.ts +24 -0
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts.map +1 -0
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js +223 -0
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js.map +1 -0
- package/dist/commands/runtime-internalization-run-rulehost.d.ts +23 -0
- package/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-run-rulehost.js +364 -0
- package/dist/commands/runtime-internalization-run-rulehost.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/services/demo-rule-compiler.d.ts +24 -0
- package/dist/services/demo-rule-compiler.d.ts.map +1 -0
- package/dist/services/demo-rule-compiler.js +53 -0
- package/dist/services/demo-rule-compiler.js.map +1 -0
- package/dist/services/rulehost-pipeline-runner.d.ts +124 -0
- package/dist/services/rulehost-pipeline-runner.d.ts.map +1 -0
- package/dist/services/rulehost-pipeline-runner.js +334 -0
- package/dist/services/rulehost-pipeline-runner.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/__tests__/run-rulehost-flag-wiring.test.ts +280 -0
- package/src/commands/runtime-internalization-run-rulehost.ts +417 -0
- package/src/index.ts +3 -0
- package/src/services/demo-rule-compiler.ts +71 -0
- package/src/services/rulehost-pipeline-runner.ts +585 -0
- package/tests/commands/diagnose.test.ts +178 -1
- package/tests/services/resolve-runtime-from-pd-config.test.ts +59 -0
- package/tests/services/rulehost-pipeline-e2e.test.ts +477 -0
- package/tests/services/rulehost-pipeline-runner.test.ts +519 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { AdversarialLoopResult, PDRuntimeAdapter, RefinerRuleHostGateDeps, PIArtifactStore } from '@principles/core/runtime-v2';
|
|
2
|
+
/**
|
|
3
|
+
* Code-rule capability (atomic: ArtificerL2 + Evaluator).
|
|
4
|
+
*
|
|
5
|
+
* Per the user correction (2026-06-18): ArtificerL2 and Evaluator are atomic —
|
|
6
|
+
* both must run or neither runs. When enabled, the adversarial loop runs with
|
|
7
|
+
* the artificerAdapter (L2 write-test-fix). When disabled or not provided, the
|
|
8
|
+
* pipeline degrades to text-principle-only.
|
|
9
|
+
*
|
|
10
|
+
* The caller (CLI handler) resolves per-agent config (enabled/runtimeProfile)
|
|
11
|
+
* and constructs the ArtificerL2Adapter when both artificer + evaluator are
|
|
12
|
+
* enabled. The pipeline runner branches on `enabled` — it does NOT do config
|
|
13
|
+
* resolution itself (separation of concerns: service vs I/O).
|
|
14
|
+
*/
|
|
15
|
+
export interface CodeRuleCapability {
|
|
16
|
+
/** Whether the capability is enabled (atomic: both artificer + evaluator enabled in config). */
|
|
17
|
+
readonly enabled: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The ArtificerL2Adapter (or test-double) for the artificer stage. Required
|
|
20
|
+
* when enabled. When enabled, this adapter replaces the base runtimeAdapter
|
|
21
|
+
* for the ArtificerRunner only; EvaluatorRunner still uses the base adapter.
|
|
22
|
+
* Ignored when disabled (may be omitted or set to the base adapter).
|
|
23
|
+
*/
|
|
24
|
+
readonly artificerAdapter?: PDRuntimeAdapter;
|
|
25
|
+
/** Structured reason when disabled (for degradation reporting). Required when disabled. */
|
|
26
|
+
readonly disabledReason?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface RuleHostAgentAdapters {
|
|
29
|
+
readonly dreamer: PDRuntimeAdapter;
|
|
30
|
+
readonly philosopher: PDRuntimeAdapter;
|
|
31
|
+
readonly scribe: PDRuntimeAdapter;
|
|
32
|
+
readonly evaluator: PDRuntimeAdapter;
|
|
33
|
+
}
|
|
34
|
+
export interface RuleHostPipelineOptions {
|
|
35
|
+
/** Workspace directory containing .state/ (SQLite stores). */
|
|
36
|
+
readonly workspaceDir: string;
|
|
37
|
+
/** Pain ID whose internalization chain to drive. */
|
|
38
|
+
readonly painId: string;
|
|
39
|
+
/**
|
|
40
|
+
* Runtime adapter (LLM). Caller constructs it (PiAi / test-double) so the
|
|
41
|
+
* service stays runtime-agnostic. Mirrors full-chain-real-llm.test.ts.
|
|
42
|
+
*
|
|
43
|
+
* Used for: dreamer, philosopher, scribe, and evaluator (when capability ON).
|
|
44
|
+
* The artificer stage uses codeRuleCapability.artificerAdapter when enabled.
|
|
45
|
+
*/
|
|
46
|
+
readonly runtimeAdapter: PDRuntimeAdapter;
|
|
47
|
+
/** Production per-agent adapters. Tests may omit this to use runtimeAdapter for every stage. */
|
|
48
|
+
readonly agentAdapters?: RuleHostAgentAdapters;
|
|
49
|
+
/**
|
|
50
|
+
* Code-rule capability (atomic: ArtificerL2 + Evaluator). When omitted, the
|
|
51
|
+
* capability is treated as OFF with reason 'code_rule_capability not provided'.
|
|
52
|
+
*/
|
|
53
|
+
readonly codeRuleCapability?: CodeRuleCapability;
|
|
54
|
+
/** Internalization channel for created tasks (default 'code_tool_hook'). */
|
|
55
|
+
readonly channel?: 'prompt' | 'code_tool_hook' | 'defer_archive';
|
|
56
|
+
/** Max adversarial rounds (PRD cap = 2). */
|
|
57
|
+
readonly maxRounds?: number;
|
|
58
|
+
/** Per-LLM-call timeout (default 300_000). */
|
|
59
|
+
readonly timeoutMs?: number;
|
|
60
|
+
/** Runner poll interval (default 100). */
|
|
61
|
+
readonly pollIntervalMs?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Max stage retry attempts for transient `retried` status (default 2).
|
|
64
|
+
* Each retry gets fresh state from the state manager (Runtime Contract Rule 7).
|
|
65
|
+
* When exhausted, the stage is marked 'degraded' with a structured reason.
|
|
66
|
+
*/
|
|
67
|
+
readonly maxStageRetries?: number;
|
|
68
|
+
/** Correlation prefix for task IDs. */
|
|
69
|
+
readonly correlationId?: string;
|
|
70
|
+
/** Progress callback (stage start/complete). Optional. */
|
|
71
|
+
readonly onProgress?: (stage: string, status: 'start' | 'succeeded' | 'failed' | 'degraded' | 'skipped', detail?: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Called once after the internal RuntimeStateManager + artifactStore are
|
|
74
|
+
* constructed, so the caller (e.g. a test-double adapter) can wire the store
|
|
75
|
+
* for artifactId resolution. Optional.
|
|
76
|
+
*/
|
|
77
|
+
readonly onStoreReady?: (store: PIArtifactStore) => void;
|
|
78
|
+
}
|
|
79
|
+
export type RuleHostPipelineStageStatus = 'succeeded' | 'failed' | 'skipped' | 'degraded';
|
|
80
|
+
export interface RuleHostPipelineStage {
|
|
81
|
+
readonly name: 'pain_lookup' | 'dreamer' | 'philosopher' | 'scribe' | 'adversarial_loop';
|
|
82
|
+
readonly status: RuleHostPipelineStageStatus;
|
|
83
|
+
readonly taskId?: string;
|
|
84
|
+
readonly reason?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Final pipeline decision.
|
|
88
|
+
*
|
|
89
|
+
* - `candidate_ready_for_owner_review`: adversarial loop approved. A validated
|
|
90
|
+
* rule artifact exists and is WAITING for owner review. This is NOT owner
|
|
91
|
+
* approval — it means the candidate is ready for the owner to review.
|
|
92
|
+
* - `text_principle_only`: code-rule capability OFF (artificer or evaluator
|
|
93
|
+
* disabled). No rule artifact; a text principle artifact is produced for
|
|
94
|
+
* prompt-channel fallback.
|
|
95
|
+
* - `generation_rejected`: pipeline failed (no dreamer task, stage failure, or
|
|
96
|
+
* evaluator rejected the candidate). No rule artifact.
|
|
97
|
+
*/
|
|
98
|
+
export interface RuleHostPipelineResult {
|
|
99
|
+
readonly decision: 'candidate_ready_for_owner_review' | 'text_principle_only' | 'generation_rejected';
|
|
100
|
+
readonly painId: string;
|
|
101
|
+
readonly stages: RuleHostPipelineStage[];
|
|
102
|
+
/** Scribe task that fed the adversarial loop (or text-principle path). */
|
|
103
|
+
readonly scribeTaskId: string | null;
|
|
104
|
+
/** From the adversarial loop result, when reached. */
|
|
105
|
+
readonly adversarialLoop?: AdversarialLoopResult;
|
|
106
|
+
/** Rule artifact ID when candidate_ready_for_owner_review; null otherwise. */
|
|
107
|
+
readonly ruleArtifactId: string | null;
|
|
108
|
+
/** Principle artifact ID (always present when scribe ran). */
|
|
109
|
+
readonly principleArtifactId: string | null;
|
|
110
|
+
/** Structured reason when decision is not candidate_ready_for_owner_review. */
|
|
111
|
+
readonly degradationReason?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Build the sandbox gate deps for adversarial replay.
|
|
115
|
+
*
|
|
116
|
+
* `compileDemoRule` is byte-equivalent to openclaw-plugin's
|
|
117
|
+
* `loadRuleImplementationModule` (same vm.createContext, same normalize, same
|
|
118
|
+
* evaluate-shape check). pd-cli cannot import openclaw-plugin (package
|
|
119
|
+
* boundary), so this duplicate is intentional and capability-identical, not a
|
|
120
|
+
* stripped demo. See demo-rule-compiler.ts header comment.
|
|
121
|
+
*/
|
|
122
|
+
export declare function createSandboxGateDeps(): RefinerRuleHostGateDeps;
|
|
123
|
+
export declare function runRuleHostPipeline(opts: RuleHostPipelineOptions): Promise<RuleHostPipelineResult>;
|
|
124
|
+
//# sourceMappingURL=rulehost-pipeline-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rulehost-pipeline-runner.d.ts","sourceRoot":"","sources":["../../src/services/rulehost-pipeline-runner.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAEhB,uBAAuB,EACvB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAMrC;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,kBAAkB;IACjC,gGAAgG;IAChG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAC7C,2FAA2F;IAC3F,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,qBAAqB;IACpC,QA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rule artifact in ONE call:
|
|
5
|
+
* pain → dreamer → philosopher → scribe → artificer↔evaluator adversarial loop
|
|
6
|
+
*
|
|
7
|
+
* This is the "last mile" wiring that makes `runAdversarialLoop` reachable
|
|
8
|
+
* from a real host entry point (the PRI-428 pr-review finding: the loop had no
|
|
9
|
+
* production caller). Operators invoke it via
|
|
10
|
+
* `pd runtime internalization run-rulehost --pain-id <id>`
|
|
11
|
+
*
|
|
12
|
+
* Design:
|
|
13
|
+
* - Does NOT reuse the lease-based InternalizationOrchestrator. Instead it
|
|
14
|
+
* chains runners directly (mirrors full-chain-real-llm.test.ts), because
|
|
15
|
+
* the lease model is single-step + successor-proposal and cannot host a
|
|
16
|
+
* synchronous multi-round loop.
|
|
17
|
+
* - The artificer↔evaluator stage delegates to `runAdversarialLoop` (PRI-428),
|
|
18
|
+
* which never throws and degrades to { decision: 'rejected' } with a reason.
|
|
19
|
+
* - gateDeps (the sandbox adapter) is built from `compileDemoRule` +
|
|
20
|
+
* `evaluateInRefinerSandbox`. Per the Explore finding, `compileDemoRule` is
|
|
21
|
+
* byte-equivalent to openclaw-plugin's `loadRuleImplementationModule`; the
|
|
22
|
+
* duplication is a package-boundary necessity (pd-cli cannot import
|
|
23
|
+
* openclaw-plugin), not a capability gap.
|
|
24
|
+
*
|
|
25
|
+
* @see docs/plans/rulehost-mvp-activation.md
|
|
26
|
+
* @see runAdversarialLoop in @principles/core/runtime-v2
|
|
27
|
+
*/
|
|
28
|
+
import { RuntimeStateManager, StoreEventEmitter, DreamerRunner, DefaultDreamerValidator, PhilosopherRunner, DefaultPhilosopherValidator, ScribeRunner, DefaultScribeValidator, ArtificerRunner, DefaultArtificerValidator, EvaluatorRunner, DefaultEvaluatorValidator, createPITaskDiagnosticJson, runAdversarialLoop, evaluateInRefinerSandbox, DEFAULT_MAX_ROUNDS, } from '@principles/core/runtime-v2';
|
|
29
|
+
/* eslint-disable @typescript-eslint/no-use-before-define -- helpers declared after main, matching codebase convention */
|
|
30
|
+
import { compileDemoRule } from './demo-rule-compiler.js';
|
|
31
|
+
// ── gateDeps builder ─────────────────────────────────────────────────────────
|
|
32
|
+
/**
|
|
33
|
+
* Build the sandbox gate deps for adversarial replay.
|
|
34
|
+
*
|
|
35
|
+
* `compileDemoRule` is byte-equivalent to openclaw-plugin's
|
|
36
|
+
* `loadRuleImplementationModule` (same vm.createContext, same normalize, same
|
|
37
|
+
* evaluate-shape check). pd-cli cannot import openclaw-plugin (package
|
|
38
|
+
* boundary), so this duplicate is intentional and capability-identical, not a
|
|
39
|
+
* stripped demo. See demo-rule-compiler.ts header comment.
|
|
40
|
+
*/
|
|
41
|
+
export function createSandboxGateDeps() {
|
|
42
|
+
return {
|
|
43
|
+
evaluateInSandbox: (code, goldenTrace, opts) => {
|
|
44
|
+
// compileDemoRule throws on bad code. The throw propagates out of
|
|
45
|
+
// evaluateInSandbox; EvaluatorRunner (and runAdversarialLoop's
|
|
46
|
+
// evaluator_run_threw catch) classifies it as a sandbox failure, so it
|
|
47
|
+
// surfaces as a rejected round rather than an uncaught exception.
|
|
48
|
+
// evaluateInRefinerSandbox separately catches its own runtime throws
|
|
49
|
+
// (from executing the evaluate function) and classifies them as
|
|
50
|
+
// validation_failed / runtime_error.
|
|
51
|
+
const evaluateCode = compileDemoRule(code, 'rulehost-pipeline');
|
|
52
|
+
return evaluateInRefinerSandbox(code, goldenTrace, { evaluateCode, ...opts });
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// ── Pipeline ─────────────────────────────────────────────────────────────────
|
|
57
|
+
const DEFAULT_TIMEOUT_MS = 300_000;
|
|
58
|
+
const DEFAULT_POLL_MS = 100;
|
|
59
|
+
const DEFAULT_MAX_STAGE_RETRIES = 2;
|
|
60
|
+
export async function runRuleHostPipeline(opts) {
|
|
61
|
+
const channel = opts.channel ?? 'code_tool_hook';
|
|
62
|
+
const maxRounds = opts.maxRounds ?? DEFAULT_MAX_ROUNDS;
|
|
63
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
64
|
+
const pollIntervalMs = opts.pollIntervalMs ?? DEFAULT_POLL_MS;
|
|
65
|
+
const maxStageRetries = opts.maxStageRetries ?? DEFAULT_MAX_STAGE_RETRIES;
|
|
66
|
+
const correlation = opts.correlationId ?? `rulehost-${opts.painId}`;
|
|
67
|
+
const onProgress = opts.onProgress ?? (() => { });
|
|
68
|
+
// ── Resolve code-rule capability (atomic: ArtificerL2 + Evaluator) ──
|
|
69
|
+
// Per user correction (2026-06-18): both must be enabled or neither runs.
|
|
70
|
+
// When OFF, degrade to text-principle-only after scribe. When ON, run the
|
|
71
|
+
// adversarial loop with the artificerAdapter (L2 write-test-fix).
|
|
72
|
+
const capability = opts.codeRuleCapability;
|
|
73
|
+
const capabilityEnabled = capability?.enabled === true;
|
|
74
|
+
const capabilityDisabledReason = capability?.enabled === false
|
|
75
|
+
? (capability.disabledReason ?? 'code_rule_capability is disabled')
|
|
76
|
+
: 'code_rule_capability not provided — default OFF (set codeRuleCapability.enabled=true when both artificer + evaluator agents are enabled)';
|
|
77
|
+
const stages = [];
|
|
78
|
+
const stateManager = new RuntimeStateManager({ workspaceDir: opts.workspaceDir });
|
|
79
|
+
await stateManager.initialize();
|
|
80
|
+
try {
|
|
81
|
+
const artifactStore = stateManager.piArtifactStore;
|
|
82
|
+
const eventEmitter = new StoreEventEmitter();
|
|
83
|
+
// Allow the caller's adapter to resolve real artifactIds (needed by
|
|
84
|
+
// test-double adapters whose scripted outputs must match store-assigned IDs).
|
|
85
|
+
opts.onStoreReady?.(artifactStore);
|
|
86
|
+
const owner = 'rulehost-pipeline';
|
|
87
|
+
const agentAdapters = opts.agentAdapters ?? {
|
|
88
|
+
dreamer: opts.runtimeAdapter,
|
|
89
|
+
philosopher: opts.runtimeAdapter,
|
|
90
|
+
scribe: opts.runtimeAdapter,
|
|
91
|
+
evaluator: opts.runtimeAdapter,
|
|
92
|
+
};
|
|
93
|
+
const runnerOptsFor = (adapter) => ({ owner, runtimeKind: adapter.kind(), pollIntervalMs, timeoutMs });
|
|
94
|
+
// ── Stage: pain lookup ──
|
|
95
|
+
// Find a dreamer task already seeded for this pain (the pain→dreamer bridge
|
|
96
|
+
// runs via `pd pain record` → PainSignalBridge.onPainDetected). We need the
|
|
97
|
+
// dreamer task to start the chain. If none exists, the operator must run
|
|
98
|
+
// `pd pain record` first — fail loud with guidance.
|
|
99
|
+
//
|
|
100
|
+
// D fix (PRI-429): exact sourcePainId match via Object.hasOwn on parsed
|
|
101
|
+
// diagnosticJson. No substring matching (pain-1 must NOT match pain-10).
|
|
102
|
+
onProgress('pain_lookup', 'start', `painId=${opts.painId}`);
|
|
103
|
+
const dreamerLookup = await findDreamerTaskForPain(stateManager, opts.painId);
|
|
104
|
+
if (dreamerLookup.status === 'ambiguous') {
|
|
105
|
+
const reason = `ambiguous_dreamer_tasks_for_pain: ${dreamerLookup.taskIds.join(',')}`;
|
|
106
|
+
stages.push({ name: 'pain_lookup', status: 'failed', reason });
|
|
107
|
+
onProgress('pain_lookup', 'failed', reason);
|
|
108
|
+
return rejectedResult(opts.painId, stages, reason);
|
|
109
|
+
}
|
|
110
|
+
if (dreamerLookup.status === 'not_found') {
|
|
111
|
+
stages.push({ name: 'pain_lookup', status: 'failed', reason: 'no_dreamer_task_seeded_for_pain' });
|
|
112
|
+
onProgress('pain_lookup', 'failed', 'no dreamer task seeded');
|
|
113
|
+
return rejectedResult(opts.painId, stages, 'no_dreamer_task_seeded_for_pain: run `pd pain record` first');
|
|
114
|
+
}
|
|
115
|
+
const dreamerSeedTaskId = dreamerLookup.taskId;
|
|
116
|
+
stages.push({ name: 'pain_lookup', status: 'succeeded', taskId: dreamerSeedTaskId });
|
|
117
|
+
onProgress('pain_lookup', 'succeeded', `dreamerTaskId=${dreamerSeedTaskId}`);
|
|
118
|
+
// ── Stage: dreamer ──
|
|
119
|
+
onProgress('dreamer', 'start');
|
|
120
|
+
const dreamerRunner = new DreamerRunner({ stateManager, runtimeAdapter: agentAdapters.dreamer, eventEmitter, validator: new DefaultDreamerValidator(), artifactStore }, runnerOptsFor(agentAdapters.dreamer));
|
|
121
|
+
const dreamerResult = await runStage(dreamerRunner, dreamerSeedTaskId, { maxStageRetries, pollIntervalMs });
|
|
122
|
+
stages.push(stageFromResult('dreamer', dreamerSeedTaskId, dreamerResult));
|
|
123
|
+
if (dreamerResult.status !== 'succeeded') {
|
|
124
|
+
onProgress('dreamer', 'failed', dreamerResult.failureReason);
|
|
125
|
+
return rejectedResult(opts.painId, stages, `dreamer_failed: ${dreamerResult.failureReason ?? dreamerResult.status}`);
|
|
126
|
+
}
|
|
127
|
+
onProgress('dreamer', 'succeeded');
|
|
128
|
+
// ── Stage: philosopher ──
|
|
129
|
+
onProgress('philosopher', 'start');
|
|
130
|
+
const philosopherTaskId = `${correlation}-philosopher-${Date.now().toString(36)}`;
|
|
131
|
+
await createInternalizationTask(stateManager, philosopherTaskId, 'philosopher', [dreamerSeedTaskId], channel, timeoutMs);
|
|
132
|
+
const philosopherRunner = new PhilosopherRunner({ stateManager, runtimeAdapter: agentAdapters.philosopher, eventEmitter, validator: new DefaultPhilosopherValidator(), artifactStore }, runnerOptsFor(agentAdapters.philosopher));
|
|
133
|
+
const philosopherResult = await runStage(philosopherRunner, philosopherTaskId, { maxStageRetries, pollIntervalMs });
|
|
134
|
+
stages.push(stageFromResult('philosopher', philosopherTaskId, philosopherResult));
|
|
135
|
+
if (philosopherResult.status !== 'succeeded') {
|
|
136
|
+
onProgress('philosopher', 'failed', philosopherResult.failureReason);
|
|
137
|
+
return rejectedResult(opts.painId, stages, `philosopher_failed: ${philosopherResult.failureReason ?? philosopherResult.status}`);
|
|
138
|
+
}
|
|
139
|
+
onProgress('philosopher', 'succeeded');
|
|
140
|
+
// ── Stage: scribe ──
|
|
141
|
+
onProgress('scribe', 'start');
|
|
142
|
+
const scribeTaskId = `${correlation}-scribe-${Date.now().toString(36)}`;
|
|
143
|
+
await createInternalizationTask(stateManager, scribeTaskId, 'scribe', [philosopherTaskId], channel, timeoutMs);
|
|
144
|
+
const scribeRunner = new ScribeRunner({ stateManager, runtimeAdapter: agentAdapters.scribe, eventEmitter, validator: new DefaultScribeValidator(), artifactStore }, runnerOptsFor(agentAdapters.scribe));
|
|
145
|
+
const scribeResult = await runStage(scribeRunner, scribeTaskId, { maxStageRetries, pollIntervalMs });
|
|
146
|
+
stages.push(stageFromResult('scribe', scribeTaskId, scribeResult));
|
|
147
|
+
if (scribeResult.status !== 'succeeded') {
|
|
148
|
+
onProgress('scribe', 'failed', scribeResult.failureReason);
|
|
149
|
+
return rejectedResult(opts.painId, stages, `scribe_failed: ${scribeResult.failureReason ?? scribeResult.status}`);
|
|
150
|
+
}
|
|
151
|
+
onProgress('scribe', 'succeeded');
|
|
152
|
+
// ── Atomic capability branching ──
|
|
153
|
+
// Per user correction (2026-06-18): ArtificerL2 + Evaluator are atomic.
|
|
154
|
+
// When OFF (or not provided), skip the adversarial loop entirely and
|
|
155
|
+
// degrade to text-principle-only. The scribe's principle artifact remains
|
|
156
|
+
// for prompt-channel fallback.
|
|
157
|
+
if (!capabilityEnabled) {
|
|
158
|
+
stages.push({ name: 'adversarial_loop', status: 'skipped', reason: capabilityDisabledReason });
|
|
159
|
+
onProgress('adversarial_loop', 'skipped', capabilityDisabledReason);
|
|
160
|
+
return await textPrincipleOnlyResult({ painId: opts.painId, stages, scribeTaskId, disabledReason: capabilityDisabledReason, artifactStore });
|
|
161
|
+
}
|
|
162
|
+
// ── Stage: adversarial loop (artificer↔evaluator) ──
|
|
163
|
+
// Capability ON: use the artificerAdapter (L2 write-test-fix) for the
|
|
164
|
+
// artificer stage, and the base runtimeAdapter for the evaluator stage.
|
|
165
|
+
if (!capability?.artificerAdapter) {
|
|
166
|
+
// Contract violation: enabled but no adapter provided. Fail loud.
|
|
167
|
+
stages.push({ name: 'adversarial_loop', status: 'failed', reason: 'artificerAdapter not provided' });
|
|
168
|
+
onProgress('adversarial_loop', 'failed', 'artificerAdapter not provided');
|
|
169
|
+
return rejectedResult(opts.painId, stages, 'code_rule_capability enabled but artificerAdapter not provided');
|
|
170
|
+
}
|
|
171
|
+
onProgress('adversarial_loop', 'start');
|
|
172
|
+
const artificerRunner = new ArtificerRunner({ stateManager, runtimeAdapter: capability.artificerAdapter, eventEmitter, validator: new DefaultArtificerValidator(), artifactStore }, runnerOptsFor(capability.artificerAdapter));
|
|
173
|
+
const evaluatorRunner = new EvaluatorRunner({ stateManager, runtimeAdapter: agentAdapters.evaluator, eventEmitter, validator: new DefaultEvaluatorValidator(), artifactStore }, { ...runnerOptsFor(agentAdapters.evaluator), gateDeps: createSandboxGateDeps() });
|
|
174
|
+
const loopResult = await runAdversarialLoop({
|
|
175
|
+
artificerRunner,
|
|
176
|
+
evaluatorRunner,
|
|
177
|
+
stateManager,
|
|
178
|
+
artifactStore,
|
|
179
|
+
scribeTaskId,
|
|
180
|
+
maxRounds,
|
|
181
|
+
correlationId: correlation,
|
|
182
|
+
channel,
|
|
183
|
+
});
|
|
184
|
+
const loopStatus = loopResult.decision === 'approved' ? 'succeeded' : 'degraded';
|
|
185
|
+
stages.push({ name: 'adversarial_loop', status: loopStatus, taskId: loopResult.finalEvaluatorTaskId, reason: loopResult.degradationReason });
|
|
186
|
+
onProgress('adversarial_loop', loopResult.decision === 'approved' ? 'succeeded' : 'degraded', loopResult.degradationReason);
|
|
187
|
+
// Map adversarial loop decision to pipeline decision:
|
|
188
|
+
// 'approved' → candidate_ready_for_owner_review (NOT owner approval)
|
|
189
|
+
// 'rejected' → generation_rejected
|
|
190
|
+
const pipelineDecision = loopResult.decision === 'approved'
|
|
191
|
+
? 'candidate_ready_for_owner_review'
|
|
192
|
+
: 'generation_rejected';
|
|
193
|
+
return {
|
|
194
|
+
decision: pipelineDecision,
|
|
195
|
+
painId: opts.painId,
|
|
196
|
+
stages,
|
|
197
|
+
scribeTaskId,
|
|
198
|
+
adversarialLoop: loopResult,
|
|
199
|
+
ruleArtifactId: loopResult.ruleArtifactId,
|
|
200
|
+
principleArtifactId: loopResult.principleArtifactId,
|
|
201
|
+
degradationReason: loopResult.degradationReason,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
await stateManager.close();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async function findDreamerTaskForPain(stateManager, painId) {
|
|
209
|
+
const tasks = await stateManager.listTasks();
|
|
210
|
+
const dreamerTasks = tasks.filter((t) => t.taskKind === 'dreamer' && (t.status === 'pending' || t.status === 'retry_wait'));
|
|
211
|
+
const matches = [];
|
|
212
|
+
for (const t of dreamerTasks) {
|
|
213
|
+
if (typeof t.diagnosticJson !== 'string')
|
|
214
|
+
continue;
|
|
215
|
+
let parsed;
|
|
216
|
+
try {
|
|
217
|
+
parsed = JSON.parse(t.diagnosticJson);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
// Malformed JSON — skip this task, don't crash (Runtime Contract Rule 9:
|
|
221
|
+
// graceful degradation with observable behavior — the task is simply not
|
|
222
|
+
// a match, and the caller will report no_dreamer_task_seeded_for_pain).
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
226
|
+
continue;
|
|
227
|
+
if (!Object.hasOwn(parsed, 'sourcePainId'))
|
|
228
|
+
continue;
|
|
229
|
+
const stored = Reflect.get(parsed, 'sourcePainId');
|
|
230
|
+
if (typeof stored === 'string' && stored === painId) {
|
|
231
|
+
matches.push(t.taskId);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
matches.sort();
|
|
235
|
+
if (matches.length === 0)
|
|
236
|
+
return { status: 'not_found' };
|
|
237
|
+
if (matches.length > 1)
|
|
238
|
+
return { status: 'ambiguous', taskIds: matches };
|
|
239
|
+
return { status: 'found', taskId: matches[0] };
|
|
240
|
+
}
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
242
|
+
async function createInternalizationTask(stateManager, taskId, taskKind, dependencyTaskIds, channel, timeoutMs) {
|
|
243
|
+
await stateManager.createTask({
|
|
244
|
+
taskId,
|
|
245
|
+
taskKind,
|
|
246
|
+
status: 'pending',
|
|
247
|
+
attemptCount: 0,
|
|
248
|
+
maxAttempts: 3,
|
|
249
|
+
diagnosticJson: createPITaskDiagnosticJson({
|
|
250
|
+
dependencyTaskIds,
|
|
251
|
+
channel,
|
|
252
|
+
timeoutMs,
|
|
253
|
+
inputArtifactRefs: [],
|
|
254
|
+
outputArtifactRefs: [],
|
|
255
|
+
}),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
async function runStage(runner, taskId, opts) {
|
|
259
|
+
let attempt = 0;
|
|
260
|
+
// First attempt is not a retry — it's the initial run.
|
|
261
|
+
let result = await runner.run(taskId);
|
|
262
|
+
while (result.status === 'retried' && attempt < opts.maxStageRetries) {
|
|
263
|
+
attempt++;
|
|
264
|
+
// Brief wait before retry to allow transient conditions to clear.
|
|
265
|
+
// The state manager has already marked the task as retry_wait; the runner
|
|
266
|
+
// will re-read it on the next .run() call (fresh state per iteration).
|
|
267
|
+
await new Promise((resolve) => setTimeout(resolve, opts.pollIntervalMs));
|
|
268
|
+
result = await runner.run(taskId);
|
|
269
|
+
}
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
function stageFromResult(name, taskId, result) {
|
|
273
|
+
// `retried` after exhausting retries is a transient-exhausted state, not a
|
|
274
|
+
// hard failure. Mark as 'degraded' so the caller can distinguish "stage
|
|
275
|
+
// failed permanently" from "stage exhausted transient retries".
|
|
276
|
+
if (result.status === 'succeeded') {
|
|
277
|
+
return { name, taskId, status: 'succeeded' };
|
|
278
|
+
}
|
|
279
|
+
if (result.status === 'retried') {
|
|
280
|
+
return {
|
|
281
|
+
name,
|
|
282
|
+
taskId,
|
|
283
|
+
status: 'degraded',
|
|
284
|
+
reason: `transient_retry_exhausted: ${result.failureReason ?? result.status}`,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
name,
|
|
289
|
+
taskId,
|
|
290
|
+
status: 'failed',
|
|
291
|
+
reason: result.failureReason ?? result.status,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function rejectedResult(painId, stages, degradationReason) {
|
|
295
|
+
return {
|
|
296
|
+
decision: 'generation_rejected',
|
|
297
|
+
painId,
|
|
298
|
+
stages,
|
|
299
|
+
scribeTaskId: null,
|
|
300
|
+
ruleArtifactId: null,
|
|
301
|
+
principleArtifactId: null,
|
|
302
|
+
degradationReason,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
async function textPrincipleOnlyResult(params) {
|
|
306
|
+
const { painId, stages, scribeTaskId, disabledReason, artifactStore } = params;
|
|
307
|
+
// Look up the principle artifact produced by the scribe stage.
|
|
308
|
+
try {
|
|
309
|
+
const arts = await artifactStore.listBySourceTaskId(scribeTaskId);
|
|
310
|
+
const principleArt = arts.find((a) => a.artifactKind === 'principle');
|
|
311
|
+
return {
|
|
312
|
+
decision: 'text_principle_only',
|
|
313
|
+
painId,
|
|
314
|
+
stages,
|
|
315
|
+
scribeTaskId,
|
|
316
|
+
ruleArtifactId: null,
|
|
317
|
+
principleArtifactId: principleArt?.artifactId ?? null,
|
|
318
|
+
degradationReason: `code_rule_capability_off: ${disabledReason}`,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
323
|
+
return {
|
|
324
|
+
decision: 'text_principle_only',
|
|
325
|
+
painId,
|
|
326
|
+
stages,
|
|
327
|
+
scribeTaskId,
|
|
328
|
+
ruleArtifactId: null,
|
|
329
|
+
principleArtifactId: null,
|
|
330
|
+
degradationReason: `code_rule_capability_off: ${disabledReason}; principle_artifact_lookup_failed: ${message}`,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=rulehost-pipeline-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rulehost-pipeline-runner.js","sourceRoot":"","sources":["../../src/services/rulehost-pipeline-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EACzB,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAQrC,yHAAyH;AACzH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAyH1D,gFAAgF;AAEhF;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,iBAAiB,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;YAC7C,kEAAkE;YAClE,+DAA+D;YAC/D,uEAAuE;YACvE,kEAAkE;YAClE,qEAAqE;YACrE,gEAAgE;YAChE,qCAAqC;YACrC,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;YAChE,OAAO,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;QAChF,CAAC;KACF,CAAC;AACJ,CAAC;AAED,gFAAgF;AAEhF,MAAM,kBAAkB,GAAG,OAAO,CAAC;AACnC,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAA6B;IACrE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,gBAAgB,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,kBAAkB,CAAC;IACvD,MAAM,SAAS,GAAG,IAAI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