create-principles-disciple 1.156.2 → 1.157.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_release/product-identity.json +2 -2
- package/codex-adapter/dist/worker/workspace-worker.d.ts +11 -3
- package/codex-adapter/dist/worker/workspace-worker.js +30 -16
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/models/OwnerDecisionConsoleModel.js +33 -1
- package/console/dist/web/assets/app.js +3 -3
- package/core/dist/runtime/adversarial-loop.d.ts +8 -0
- package/core/dist/runtime/adversarial-loop.d.ts.map +1 -1
- package/core/dist/runtime/adversarial-loop.js +420 -45
- package/core/dist/runtime/adversarial-loop.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +3 -3
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/feature-flags/plugin-surface-registry.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/plugin-surface-registry.js +0 -16
- package/core/dist/runtime/feature-flags/plugin-surface-registry.js.map +1 -1
- package/core/dist/runtime/index.d.ts +4 -0
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +10 -0
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-runner.d.ts +9 -0
- package/core/dist/runtime/internalization/artificer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-runner.js +52 -0
- package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/correlation-lineage.d.ts +16 -3
- package/core/dist/runtime/internalization/correlation-lineage.d.ts.map +1 -1
- package/core/dist/runtime/internalization/correlation-lineage.js +4 -4
- package/core/dist/runtime/internalization/correlation-lineage.js.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.d.ts +35 -0
- package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.js +390 -91
- package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +40 -13
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.js +520 -199
- package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-transition-decision.js +1 -1
- package/core/dist/runtime/internalization/internalization-transition-decision.js.map +1 -1
- package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-resolution-service.js +10 -8
- package/core/dist/runtime/internalization/owner-resolution-service.js.map +1 -1
- package/core/dist/runtime/internalization/owner-review.d.ts +2 -0
- package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-review.js +17 -11
- package/core/dist/runtime/internalization/owner-review.js.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -0
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts +36 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.js +23 -2
- package/core/dist/runtime/internalization/pitask-metadata.js.map +1 -1
- package/core/dist/runtime/internalization/repair-create.d.ts +73 -0
- package/core/dist/runtime/internalization/repair-create.d.ts.map +1 -0
- package/core/dist/runtime/internalization/repair-create.js +200 -0
- package/core/dist/runtime/internalization/repair-create.js.map +1 -0
- package/core/dist/runtime/internalization/repair-lineage-backfill.d.ts +94 -0
- package/core/dist/runtime/internalization/repair-lineage-backfill.d.ts.map +1 -0
- package/core/dist/runtime/internalization/repair-lineage-backfill.js +123 -0
- package/core/dist/runtime/internalization/repair-lineage-backfill.js.map +1 -0
- package/core/dist/runtime/internalization/repair-task-identity.d.ts +99 -4
- package/core/dist/runtime/internalization/repair-task-identity.d.ts.map +1 -1
- package/core/dist/runtime/internalization/repair-task-identity.js +225 -7
- package/core/dist/runtime/internalization/repair-task-identity.js.map +1 -1
- package/core/dist/runtime/internalization/revision-reopen.d.ts +56 -1
- package/core/dist/runtime/internalization/revision-reopen.d.ts.map +1 -1
- package/core/dist/runtime/internalization/revision-reopen.js +82 -39
- package/core/dist/runtime/internalization/revision-reopen.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +0 -7
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js +13 -68
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/successor-create.d.ts +69 -0
- package/core/dist/runtime/internalization/successor-create.d.ts.map +1 -0
- package/core/dist/runtime/internalization/successor-create.js +173 -0
- package/core/dist/runtime/internalization/successor-create.js.map +1 -0
- package/core/dist/runtime/internalization/successor-lookup.d.ts +50 -0
- package/core/dist/runtime/internalization/successor-lookup.d.ts.map +1 -0
- package/core/dist/runtime/internalization/successor-lookup.js +213 -0
- package/core/dist/runtime/internalization/successor-lookup.js.map +1 -0
- package/core/dist/runtime/runner/succeeded-result-recovery.d.ts +58 -0
- package/core/dist/runtime/runner/succeeded-result-recovery.d.ts.map +1 -0
- package/core/dist/runtime/runner/succeeded-result-recovery.js +117 -0
- package/core/dist/runtime/runner/succeeded-result-recovery.js.map +1 -0
- package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -0
- package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.js +4 -0
- package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime/store/task/memory-task-store.d.ts +3 -3
- package/core/dist/runtime/store/task/memory-task-store.d.ts.map +1 -1
- package/core/dist/runtime/store/task/memory-task-store.js +52 -0
- package/core/dist/runtime/store/task/memory-task-store.js.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts +3 -0
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.js +204 -135
- package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime/store/task/task-store.d.ts +17 -0
- package/core/dist/runtime/store/task/task-store.d.ts.map +1 -1
- package/core/dist/telemetry-event.d.ts +2 -2
- package/core/dist/telemetry-event.d.ts.map +1 -1
- package/core/dist/telemetry-event.js +4 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +69 -11
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +432 -120
- package/dist/installer.js.map +1 -1
- package/dist/service-host-bridge.d.ts +0 -5
- package/dist/service-host-bridge.d.ts.map +1 -1
- package/dist/service-host-bridge.js.map +1 -1
- package/dist/service-host-provisioning.d.ts +123 -18
- package/dist/service-host-provisioning.d.ts.map +1 -1
- package/dist/service-host-provisioning.js +645 -77
- package/dist/service-host-provisioning.js.map +1 -1
- package/dist/utils/env.d.ts +9 -0
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +269 -49
- package/dist/utils/env.js.map +1 -1
- package/host-runtime/dist/codex-worker-status.d.ts +6 -4
- package/host-runtime/dist/codex-worker-status.js +7 -5
- package/host-runtime/dist/diagnostician-auto-run.js +2 -2
- package/host-runtime/dist/governance-signal-admission.d.ts +2 -1
- package/host-runtime/dist/governance-signal-admission.js +2 -1
- package/host-runtime/dist/index.d.ts +4 -2
- package/host-runtime/dist/index.js +6 -2
- package/host-runtime/dist/internalization-consumer-cycle.d.ts +13 -106
- package/host-runtime/dist/internalization-consumer-cycle.js +21 -99
- package/host-runtime/dist/internalization-consumer-governance.d.ts +3 -3
- package/host-runtime/dist/internalization-consumer-governance.js +17 -96
- package/host-runtime/dist/internalization-task-executor.d.ts +127 -0
- package/host-runtime/dist/internalization-task-executor.js +121 -0
- package/host-runtime/dist/workbuddy-worker-status.d.ts +6 -3
- package/host-runtime/dist/workbuddy-worker-status.js +7 -4
- package/host-runtime/dist/workspace-telemetry-emitter.js +1 -1
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/background-execution-transition.d.ts +25 -29
- package/install-layout/dist/background-execution-transition.js +90 -138
- package/install-layout/dist/index.d.ts +45 -33
- package/install-layout/dist/index.js +24 -18
- package/install-layout/package.json +1 -1
- package/package.json +5 -4
- package/pd-cli/dist/commands/codex-worker.d.ts +7 -3
- package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/codex-worker.js +125 -101
- package/pd-cli/dist/commands/codex-worker.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +148 -130
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +4 -0
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
- package/pd-cli/dist/commands/service-run-once.d.ts +12 -27
- package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/service-run-once.js +15 -206
- package/pd-cli/dist/commands/service-run-once.js.map +1 -1
- package/pd-cli/dist/commands/workbuddy-worker.d.ts +7 -2
- package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/workbuddy-worker.js +133 -99
- package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
- package/pd-cli/dist/commands/worker-service-host-gate.d.ts +38 -0
- package/pd-cli/dist/commands/worker-service-host-gate.d.ts.map +1 -0
- package/pd-cli/dist/commands/worker-service-host-gate.js +110 -0
- package/pd-cli/dist/commands/worker-service-host-gate.js.map +1 -0
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +20 -84
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/rulehost-pipeline-runner.js +198 -142
- package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
- package/pd-cli/dist/services/service-host/coordinator-common.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/coordinator-common.js +4 -5
- package/pd-cli/dist/services/service-host/coordinator-common.js.map +1 -1
- package/pd-cli/dist/services/service-host/index.d.ts +7 -10
- package/pd-cli/dist/services/service-host/index.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/index.js +8 -11
- package/pd-cli/dist/services/service-host/index.js.map +1 -1
- package/pd-cli/dist/services/service-host/install-identity.d.ts +5 -5
- package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/managed-run.js +19 -22
- package/pd-cli/dist/services/service-host/managed-run.js.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/linux.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/linux.js +21 -2
- package/pd-cli/dist/services/service-host/scheduler/linux.js.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +1 -1
- package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/service-status.js +0 -2
- package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -1
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +7 -51
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
- package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js +3 -3
- package/pd-cli/dist/services/service-host/worker-adapter.d.ts +0 -10
- package/pd-cli/dist/services/service-host/worker-adapter.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/worker-adapter.js +4 -12
- package/pd-cli/dist/services/service-host/worker-adapter.js.map +1 -1
- package/pd-cli/dist/services/service-host/worker-env.d.ts +1 -1
- package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts +5 -7
- package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/workspace-dispatch.js +1 -3
- package/pd-cli/dist/services/service-host/workspace-dispatch.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +616 -1319
- package/plugin/dist/core/openclaw-tool-declaration.d.ts +13 -0
- package/plugin/dist/index.d.ts +0 -9
- package/plugin/dist/openclaw-worker.d.ts +21 -8
- package/plugin/dist/openclaw-worker.js +267 -267
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +432 -120
- package/release-manager/dist/service-host-provisioning.js +645 -77
- package/release-manager/dist/utils/env.js +269 -49
- package/release-manager/package.json +3 -2
- package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +9 -1
- package/workbuddy-adapter/dist/worker/workspace-worker.js +21 -9
- package/workbuddy-adapter/package.json +1 -1
- package/pd-cli/dist/commands/service-handover.d.ts +0 -12
- package/pd-cli/dist/commands/service-handover.d.ts.map +0 -1
- package/pd-cli/dist/commands/service-handover.js +0 -117
- package/pd-cli/dist/commands/service-handover.js.map +0 -1
- package/pd-cli/dist/commands/worker-drain.d.ts +0 -7
- package/pd-cli/dist/commands/worker-drain.d.ts.map +0 -1
- package/pd-cli/dist/commands/worker-drain.js +0 -51
- package/pd-cli/dist/commands/worker-drain.js.map +0 -1
- package/pd-cli/dist/services/service-host/handover-claims.d.ts +0 -14
- package/pd-cli/dist/services/service-host/handover-claims.d.ts.map +0 -1
- package/pd-cli/dist/services/service-host/handover-claims.js +0 -50
- package/pd-cli/dist/services/service-host/handover-claims.js.map +0 -1
- package/pd-cli/dist/services/service-host/shadow-run.d.ts +0 -87
- package/pd-cli/dist/services/service-host/shadow-run.d.ts.map +0 -1
- package/pd-cli/dist/services/service-host/shadow-run.js +0 -549
- package/pd-cli/dist/services/service-host/shadow-run.js.map +0 -1
- package/pd-cli/dist/services/service-host/workspace-handover.d.ts +0 -190
- package/pd-cli/dist/services/service-host/workspace-handover.d.ts.map +0 -1
- package/pd-cli/dist/services/service-host/workspace-handover.js +0 -1393
- package/pd-cli/dist/services/service-host/workspace-handover.js.map +0 -1
- package/plugin/dist/service/gateway-consumer-lease.d.ts +0 -142
- package/plugin/dist/service/gateway-quiesce-ack.d.ts +0 -40
- package/plugin/dist/service/internalization-auto-consumer-service.d.ts +0 -100
|
@@ -10,11 +10,13 @@ import { canonicalLedgerPrincipleId } from '../activation/low-risk-writers.js';
|
|
|
10
10
|
import { assessArtificerCodeBearing } from './artificer-code-bearing.js';
|
|
11
11
|
import { PDRuntimeError, isPDErrorCategory } from '../error-categories.js';
|
|
12
12
|
import { hydratePITaskRecord, createPITaskDiagnosticJson, mergePITaskMetadata, artificerRepairTaskId, parseLastValidatorErrors, isFreshForNextAttempt } from './pitask-metadata.js';
|
|
13
|
+
import { resolveEvaluatorArtificerDependencyIdentity, verifyRepairTaskIdentity } from './repair-task-identity.js';
|
|
13
14
|
import { HUMAN_REVIEW_REASON, planOwnerVerdictOverrideResume, markOwnerResolutionApplied, computeArtifactContentHash, } from './owner-review.js';
|
|
14
15
|
import { EvaluatorPromptBuilder, deriveRequirementLedger } from './evaluator-prompt-builder.js';
|
|
15
16
|
import { resolveFormationContext } from './formation-context.js';
|
|
16
17
|
import { reconcileLineageEcho } from './peer-runner-contracts.js';
|
|
17
18
|
import { BasePeerRunner } from '../runner/base-peer-runner.js';
|
|
19
|
+
import { recoverSucceededPeerRunnerResult } from '../runner/succeeded-result-recovery.js';
|
|
18
20
|
import { extractExecutionConditions, extractIntentContract } from './intent-contract.js';
|
|
19
21
|
// PRI-426: single-round adversarial sandbox replay in succeedTask.
|
|
20
22
|
import { evaluateRefinerRuleHostGate } from './refiner-rulehost-gate.js';
|
|
@@ -290,6 +292,17 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
290
292
|
this.emitEvent('no_dependencies', taskId, {});
|
|
291
293
|
throw new PDRuntimeError('input_invalid', 'Artificer dependency artifact ID not resolved');
|
|
292
294
|
}
|
|
295
|
+
const dependencyIdentity = await resolveEvaluatorArtificerDependencyIdentity({
|
|
296
|
+
evaluatorTask: task,
|
|
297
|
+
store: this.stateManager,
|
|
298
|
+
});
|
|
299
|
+
if (dependencyIdentity.kind === 'invalid') {
|
|
300
|
+
this.emitEvent('repair_dependency_identity_refused', taskId, {
|
|
301
|
+
reason: dependencyIdentity.reason,
|
|
302
|
+
detail: dependencyIdentity.detail,
|
|
303
|
+
});
|
|
304
|
+
throw new PDRuntimeError('input_invalid', `artificer dependency identity invalid: ${dependencyIdentity.reason}`);
|
|
305
|
+
}
|
|
293
306
|
for (const depId of deps) {
|
|
294
307
|
const depTask = await this.stateManager.getTask(depId);
|
|
295
308
|
if (!depTask)
|
|
@@ -655,6 +668,231 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
655
668
|
errorCategory,
|
|
656
669
|
};
|
|
657
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* Resolve the current input artifact an evaluator would read if it were
|
|
673
|
+
* built now. Recovery and completion-intent resume must use the same input
|
|
674
|
+
* authority as fresh execution; internally consistent stale output is not
|
|
675
|
+
* evidence for the current artifact epoch.
|
|
676
|
+
*/
|
|
677
|
+
async resolveCurrentArtificerInput(task) {
|
|
678
|
+
const piTask = hydratePITaskRecord(task);
|
|
679
|
+
if (!piTask) {
|
|
680
|
+
throw new PDRuntimeError('input_invalid', `evaluator task ${task.taskId} metadata is malformed`);
|
|
681
|
+
}
|
|
682
|
+
const dependencyIdentity = await resolveEvaluatorArtificerDependencyIdentity({
|
|
683
|
+
evaluatorTask: task,
|
|
684
|
+
store: this.stateManager,
|
|
685
|
+
});
|
|
686
|
+
if (dependencyIdentity.kind === 'invalid') {
|
|
687
|
+
throw new PDRuntimeError('input_invalid', `artificer dependency identity invalid: ${dependencyIdentity.reason}`);
|
|
688
|
+
}
|
|
689
|
+
let selected = null;
|
|
690
|
+
let artificerDependencyCount = 0;
|
|
691
|
+
for (const dependencyTaskId of piTask.dependencyTaskIds) {
|
|
692
|
+
const dependency = await this.stateManager.getTask(dependencyTaskId);
|
|
693
|
+
if (!dependency || dependency.taskKind !== 'artificer')
|
|
694
|
+
continue;
|
|
695
|
+
artificerDependencyCount += 1;
|
|
696
|
+
const dependencyPi = hydratePITaskRecord(dependency);
|
|
697
|
+
if (!dependencyPi) {
|
|
698
|
+
throw new PDRuntimeError('input_invalid', `artificer dependency ${dependencyTaskId} metadata is malformed`);
|
|
699
|
+
}
|
|
700
|
+
if (dependency.status !== 'succeeded') {
|
|
701
|
+
throw new PDRuntimeError('input_invalid', `artificer dependency ${dependencyTaskId} is not succeeded (status: ${dependency.status})`);
|
|
702
|
+
}
|
|
703
|
+
const artifacts = await this.artifactStore.listBySourceTaskId(dependencyTaskId);
|
|
704
|
+
let artifact;
|
|
705
|
+
try {
|
|
706
|
+
artifact = selectTaskRevisionArtifact(dependency, artifacts, dependencyPi.revisionCount ?? 0);
|
|
707
|
+
}
|
|
708
|
+
catch (err) {
|
|
709
|
+
throw new PDRuntimeError('input_invalid', `current artificer revision artifact unavailable for ${dependencyTaskId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
710
|
+
}
|
|
711
|
+
if (!artifact) {
|
|
712
|
+
throw new PDRuntimeError('input_invalid', `current artificer artifact missing for ${dependencyTaskId}`);
|
|
713
|
+
}
|
|
714
|
+
selected = {
|
|
715
|
+
artifactId: artifact.artifactId,
|
|
716
|
+
contentJson: artifact.contentJson,
|
|
717
|
+
...(dependencyPi.repairPayload !== undefined ? { repairPayload: dependencyPi.repairPayload } : {}),
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
if (artificerDependencyCount !== 1 || !selected) {
|
|
721
|
+
throw new PDRuntimeError('input_invalid', `evaluator task ${task.taskId} must have exactly one artificer dependency (found ${artificerDependencyCount})`);
|
|
722
|
+
}
|
|
723
|
+
return selected;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* A completion intent is recovery authority only for the input artifact it
|
|
727
|
+
* actually evaluated. If an upstream revision advanced before the terminal
|
|
728
|
+
* write completed, the incomplete evaluation must not be finalized as a
|
|
729
|
+
* verdict for the new artifact; returning false lets the normal execution
|
|
730
|
+
* path build fresh context and overwrite the nonterminal intent.
|
|
731
|
+
*/
|
|
732
|
+
async completionIntentMatchesCurrentInput(taskId, intent) {
|
|
733
|
+
const task = await this.stateManager.getTask(taskId);
|
|
734
|
+
if (!task)
|
|
735
|
+
throw new PDRuntimeError('storage_unavailable', `task ${taskId} missing during completion-intent input validation`);
|
|
736
|
+
const currentInput = await this.resolveCurrentArtificerInput(task);
|
|
737
|
+
const output = await this.recoverIntentOutput(taskId, intent.sourceRunId, intent.decision);
|
|
738
|
+
return output.sourceArtificerArtifactId === currentInput.artifactId;
|
|
739
|
+
}
|
|
740
|
+
async ownerResolutionMatchesCurrentInput(taskId, resolution, leasedTask) {
|
|
741
|
+
const currentInput = await this.resolveCurrentArtificerInput(leasedTask);
|
|
742
|
+
const output = await this.recoverIntentOutput(taskId, resolution.sourceRunId, resolution.machineDecision);
|
|
743
|
+
return output.sourceArtificerArtifactId === currentInput.artifactId;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Retire a pending Owner resolution whose evidence input was superseded
|
|
747
|
+
* before application. The authority log row remains durable; the lease-
|
|
748
|
+
* fenced conditional metadata write only changes its lifecycle status.
|
|
749
|
+
*/
|
|
750
|
+
async supersedeStaleOwnerResolution(taskId, leasedTask, resolutionId) {
|
|
751
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
752
|
+
const raw = await this.stateManager.getTask(taskId);
|
|
753
|
+
const piTask = raw ? hydratePITaskRecord(raw) : null;
|
|
754
|
+
if (!raw || !piTask?.ownerResolutions) {
|
|
755
|
+
throw new PDRuntimeError('execution_failed', `owner resolution ${resolutionId} metadata unavailable`);
|
|
756
|
+
}
|
|
757
|
+
const target = piTask.ownerResolutions.find((resolution) => resolution.resolutionId === resolutionId);
|
|
758
|
+
if (!target || target.status === 'superseded')
|
|
759
|
+
return;
|
|
760
|
+
if (target.status !== 'pending') {
|
|
761
|
+
throw new PDRuntimeError('execution_failed', `owner resolution ${resolutionId} is no longer pending`);
|
|
762
|
+
}
|
|
763
|
+
const updatedResolutions = piTask.ownerResolutions.map((resolution) => (resolution.resolutionId === resolutionId
|
|
764
|
+
? {
|
|
765
|
+
...resolution,
|
|
766
|
+
status: 'superseded',
|
|
767
|
+
supersededAt: new Date().toISOString(),
|
|
768
|
+
supersededReason: 'input_artifact_stale',
|
|
769
|
+
}
|
|
770
|
+
: resolution));
|
|
771
|
+
const updated = await this.stateManager.updateTaskIfDiagnosticJsonUnchanged(taskId, raw.diagnosticJson ?? null, { diagnosticJson: createPITaskDiagnosticJson(mergePITaskMetadata(piTask, { ownerResolutions: updatedResolutions })) }, {
|
|
772
|
+
expectedLeaseOwner: this.resolvedOptions.owner,
|
|
773
|
+
...(leasedTask.leaseGeneration !== undefined ? { expectedLeaseGeneration: leasedTask.leaseGeneration } : {}),
|
|
774
|
+
});
|
|
775
|
+
if (updated)
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
throw new PDRuntimeError('execution_failed', `failed to supersede stale owner resolution ${resolutionId}`);
|
|
779
|
+
}
|
|
780
|
+
/** Prove that durable nonterminal review evidence already belongs to the current input artifact. */
|
|
781
|
+
async hasCurrentInputEvidence(task) {
|
|
782
|
+
try {
|
|
783
|
+
const piTask = hydratePITaskRecord(task);
|
|
784
|
+
const sourceRunId = piTask?.completionIntent?.sourceRunId;
|
|
785
|
+
if (!piTask || !sourceRunId)
|
|
786
|
+
return false;
|
|
787
|
+
const currentInput = await this.resolveCurrentArtificerInput(task);
|
|
788
|
+
const run = (await this.stateManager.getRunsByTask(task.taskId)).find((candidate) => candidate.runId === sourceRunId);
|
|
789
|
+
if (!run?.outputPayload)
|
|
790
|
+
return false;
|
|
791
|
+
const parsed = JSON.parse(run.outputPayload);
|
|
792
|
+
const validation = await this.validator.validate(parsed, task.taskId, currentInput.artifactId);
|
|
793
|
+
return validation.valid;
|
|
794
|
+
}
|
|
795
|
+
catch {
|
|
796
|
+
return false;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Recover an already-succeeded evaluator execution from durable evidence.
|
|
801
|
+
* The run output is authoritative for execution-time replay evidence; the
|
|
802
|
+
* principle artifact may legitimately lack a late best-effort replay update,
|
|
803
|
+
* so consistency is checked on stable verdict/lineage fields rather than by
|
|
804
|
+
* requiring byte equality.
|
|
805
|
+
*/
|
|
806
|
+
async recoverSucceededResult(task) {
|
|
807
|
+
let currentInput;
|
|
808
|
+
try {
|
|
809
|
+
currentInput = await this.resolveCurrentArtificerInput(task);
|
|
810
|
+
}
|
|
811
|
+
catch (err) {
|
|
812
|
+
return { outcome: 'invalid', reason: `current_input_unavailable:${err instanceof Error ? err.message : String(err)}` };
|
|
813
|
+
}
|
|
814
|
+
let convergence;
|
|
815
|
+
if (currentInput.repairPayload) {
|
|
816
|
+
const previousEvaluation = await this.resolvePreviousEvaluation(task.taskId, currentInput.repairPayload, currentInput.contentJson);
|
|
817
|
+
if (!previousEvaluation) {
|
|
818
|
+
return { outcome: 'invalid', reason: 'repair_convergence_context_unavailable' };
|
|
819
|
+
}
|
|
820
|
+
convergence = { expectedRequirements: previousEvaluation.requirements.map((requirement) => ({ id: requirement.id, statement: requirement.statement })) };
|
|
821
|
+
}
|
|
822
|
+
return recoverSucceededPeerRunnerResult({
|
|
823
|
+
task,
|
|
824
|
+
expectedTaskKind: 'evaluator',
|
|
825
|
+
resultRefPrefix: this.config.resultRefPrefix,
|
|
826
|
+
stateManager: this.stateManager,
|
|
827
|
+
artifactStore: this.artifactStore,
|
|
828
|
+
validateOutput: (output, taskId) => this.validator.validate(output, taskId, currentInput.artifactId, convergence),
|
|
829
|
+
validateIncompleteAuthoritativeRun: ({ task: terminalTask, authoritativeRun, runs }) => {
|
|
830
|
+
const piTask = hydratePITaskRecord(terminalTask);
|
|
831
|
+
const intent = piTask?.completionIntent;
|
|
832
|
+
if (!piTask || !intent)
|
|
833
|
+
return 'authoritative_run_incomplete_without_completion_intent';
|
|
834
|
+
if (intent.sourceRunId !== authoritativeRun.runId)
|
|
835
|
+
return 'completion_intent_run_mismatch';
|
|
836
|
+
if (intent.status !== 'applied')
|
|
837
|
+
return `completion_intent_not_applied:${intent.status}`;
|
|
838
|
+
if (intent.revisionEpoch !== (piTask.revisionCount ?? 0)) {
|
|
839
|
+
return `completion_intent_epoch_mismatch:${intent.revisionEpoch}!=${piTask.revisionCount ?? 0}`;
|
|
840
|
+
}
|
|
841
|
+
const completionRuns = runs.filter((candidate) => (candidate.taskId === terminalTask.taskId
|
|
842
|
+
&& candidate.attemptNumber > authoritativeRun.attemptNumber
|
|
843
|
+
&& candidate.executionStatus === 'succeeded'
|
|
844
|
+
&& candidate.reason === 'task_completed'
|
|
845
|
+
&& candidate.errorCategory === undefined));
|
|
846
|
+
if (completionRuns.length !== 1)
|
|
847
|
+
return `completion_run_not_unique:${completionRuns.length}`;
|
|
848
|
+
if (typeof completionRuns[0]?.outputPayload === 'string' && completionRuns[0].outputPayload.length > 0) {
|
|
849
|
+
return 'completion_run_carries_independent_output';
|
|
850
|
+
}
|
|
851
|
+
return null;
|
|
852
|
+
},
|
|
853
|
+
verifyRecoveredEvidence: ({ task: terminalTask, output, artifactOutput, runId }) => {
|
|
854
|
+
if (output.taskId !== terminalTask.taskId)
|
|
855
|
+
return 'output_task_id_mismatch';
|
|
856
|
+
if (output.evaluation.decision !== artifactOutput.evaluation.decision) {
|
|
857
|
+
return 'artifact_evaluation_decision_mismatch';
|
|
858
|
+
}
|
|
859
|
+
if ((output.sourceArtificerArtifactId ?? null) !== (artifactOutput.sourceArtificerArtifactId ?? null)) {
|
|
860
|
+
return 'artifact_source_artificer_mismatch';
|
|
861
|
+
}
|
|
862
|
+
if (isEvaluatorOutputV2(output) && isEvaluatorOutputV2(artifactOutput)) {
|
|
863
|
+
const runHasReplay = output.adversarialResult !== undefined;
|
|
864
|
+
const artifactHasReplay = artifactOutput.adversarialResult !== undefined;
|
|
865
|
+
if (runHasReplay !== artifactHasReplay)
|
|
866
|
+
return 'artifact_adversarial_result_presence_mismatch';
|
|
867
|
+
if (runHasReplay && artifactHasReplay
|
|
868
|
+
&& JSON.stringify(output.adversarialResult) !== JSON.stringify(artifactOutput.adversarialResult)) {
|
|
869
|
+
return 'artifact_adversarial_result_conflicts_run_output';
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
const piTask = hydratePITaskRecord(terminalTask);
|
|
873
|
+
if (piTask) {
|
|
874
|
+
const rawDecision = output.evaluation.decision;
|
|
875
|
+
if (piTask.runnerDecision !== undefined && piTask.runnerDecision !== rawDecision) {
|
|
876
|
+
return `runner_decision_mismatch:${piTask.runnerDecision}!=${rawDecision}`;
|
|
877
|
+
}
|
|
878
|
+
if (piTask.completionIntent !== undefined) {
|
|
879
|
+
if (piTask.completionIntent.sourceRunId !== runId)
|
|
880
|
+
return 'completion_intent_run_mismatch';
|
|
881
|
+
if (piTask.completionIntent.status !== 'applied') {
|
|
882
|
+
return `completion_intent_not_applied:${piTask.completionIntent.status}`;
|
|
883
|
+
}
|
|
884
|
+
if (piTask.completionIntent.revisionEpoch !== (piTask.revisionCount ?? 0)) {
|
|
885
|
+
return `completion_intent_epoch_mismatch:${piTask.completionIntent.revisionEpoch}!=${piTask.revisionCount ?? 0}`;
|
|
886
|
+
}
|
|
887
|
+
if (piTask.completionIntent.decision !== rawDecision) {
|
|
888
|
+
return `completion_intent_decision_mismatch:${piTask.completionIntent.decision}!=${rawDecision}`;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
return null;
|
|
893
|
+
},
|
|
894
|
+
});
|
|
895
|
+
}
|
|
658
896
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
659
897
|
async succeedTask(taskId, runId, output, task, contextHash, context) {
|
|
660
898
|
// Lineage consistency: sourceArtificerArtifactId must match buildContext result (ERR-004).
|
|
@@ -1395,34 +1633,38 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
1395
1633
|
* (probe is bounded: the budget gate stops at 2; the cap only guards against
|
|
1396
1634
|
* pathological id growth).
|
|
1397
1635
|
*/
|
|
1398
|
-
async
|
|
1636
|
+
async resolveEvaluatorArtificerDependency(taskId) {
|
|
1399
1637
|
const task = await this.stateManager.getTask(taskId);
|
|
1400
1638
|
if (!task)
|
|
1401
|
-
return
|
|
1402
|
-
const
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
continue;
|
|
1409
|
-
if (depTask.taskKind !== 'artificer')
|
|
1410
|
-
continue;
|
|
1411
|
-
const piDepTask = hydratePITaskRecord(depTask);
|
|
1412
|
-
// rc-5: use Object.hasOwn to check repairPayload presence.
|
|
1413
|
-
if (piDepTask?.repairPayload && typeof piDepTask.repairPayload.repairIteration === 'number') {
|
|
1414
|
-
depPrior = piDepTask.repairPayload.repairIteration;
|
|
1415
|
-
}
|
|
1416
|
-
// First artificer (no repairPayload) → prior iteration = 0.
|
|
1417
|
-
break;
|
|
1639
|
+
return { kind: 'none' };
|
|
1640
|
+
const resolution = await resolveEvaluatorArtificerDependencyIdentity({
|
|
1641
|
+
evaluatorTask: task,
|
|
1642
|
+
store: this.stateManager,
|
|
1643
|
+
});
|
|
1644
|
+
if (resolution.kind === 'invalid') {
|
|
1645
|
+
return { kind: 'invalid', reason: resolution.reason };
|
|
1418
1646
|
}
|
|
1647
|
+
if (resolution.kind === 'none')
|
|
1648
|
+
return { kind: 'none' };
|
|
1649
|
+
return { kind: 'resolved', task: resolution.task, piTask: resolution.piTask };
|
|
1650
|
+
}
|
|
1651
|
+
async resolvePriorRepairIteration(taskId, piArtificerTask) {
|
|
1652
|
+
const repairPayload = piArtificerTask?.repairPayload;
|
|
1653
|
+
const depPrior = repairPayload && typeof repairPayload.repairIteration === 'number'
|
|
1654
|
+
? repairPayload.repairIteration
|
|
1655
|
+
: 0;
|
|
1419
1656
|
let durableMax = 0;
|
|
1420
1657
|
for (let iteration = 1; iteration <= 5; iteration++) {
|
|
1421
1658
|
const existing = await this.stateManager.getTask(artificerRepairTaskId(taskId, iteration));
|
|
1422
|
-
if (existing)
|
|
1423
|
-
|
|
1659
|
+
if (!existing)
|
|
1660
|
+
continue;
|
|
1661
|
+
const identity = await verifyRepairTaskIdentity(existing, taskId, iteration, this.stateManager);
|
|
1662
|
+
if (!identity.ok) {
|
|
1663
|
+
return { kind: 'invalid', reason: identity.reason };
|
|
1664
|
+
}
|
|
1665
|
+
durableMax = iteration;
|
|
1424
1666
|
}
|
|
1425
|
-
return Math.max(depPrior, durableMax);
|
|
1667
|
+
return { kind: 'ok', iteration: Math.max(depPrior, durableMax) };
|
|
1426
1668
|
}
|
|
1427
1669
|
/**
|
|
1428
1670
|
* 把 runner verdict 持久化进任务 diagnosticJson(commit 门控的输入)。
|
|
@@ -1566,6 +1808,15 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
1566
1808
|
// terminal 的 crash 窗口同样由此收敛 (SPEC §30)。
|
|
1567
1809
|
const ownerOverride = piTask ? planOwnerVerdictOverrideResume(piTask) : null;
|
|
1568
1810
|
if (ownerOverride) {
|
|
1811
|
+
if (!await this.ownerResolutionMatchesCurrentInput(taskId, ownerOverride.resolution, leasedTask)) {
|
|
1812
|
+
this.emitEvent('owner_resolution_stale_input', taskId, {
|
|
1813
|
+
resolutionId: ownerOverride.resolution.resolutionId,
|
|
1814
|
+
sourceRunId: ownerOverride.resolution.sourceRunId,
|
|
1815
|
+
nextAction: 'supersede_stale_resolution_and_evaluate_current_input',
|
|
1816
|
+
});
|
|
1817
|
+
await this.supersedeStaleOwnerResolution(taskId, leasedTask, ownerOverride.resolution.resolutionId);
|
|
1818
|
+
return null;
|
|
1819
|
+
}
|
|
1569
1820
|
return await this.applyOwnerVerdictOverrideAndFinalize(taskId, leasedTask, ownerOverride);
|
|
1570
1821
|
}
|
|
1571
1822
|
const intent = piTask?.completionIntent;
|
|
@@ -1576,6 +1827,13 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
1576
1827
|
if (piTask && intent && intent.status === 'applied'
|
|
1577
1828
|
&& intent.revisionEpoch === (piTask.revisionCount ?? 0)
|
|
1578
1829
|
&& leasedTask.status !== 'needs_human_review') {
|
|
1830
|
+
if (!await this.completionIntentMatchesCurrentInput(taskId, intent)) {
|
|
1831
|
+
this.emitEvent('completion_intent_stale_input', taskId, {
|
|
1832
|
+
sourceRunId: intent.sourceRunId,
|
|
1833
|
+
nextAction: 'discard_incomplete_intent_and_evaluate_current_input',
|
|
1834
|
+
});
|
|
1835
|
+
return null;
|
|
1836
|
+
}
|
|
1579
1837
|
return await this.finalizeAppliedIntentTerminal({ taskId, decision: intent.decision, sourceRunId: intent.sourceRunId, leasedTask });
|
|
1580
1838
|
}
|
|
1581
1839
|
return null;
|
|
@@ -1588,6 +1846,13 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
1588
1846
|
});
|
|
1589
1847
|
return null;
|
|
1590
1848
|
}
|
|
1849
|
+
if (!await this.completionIntentMatchesCurrentInput(taskId, intent)) {
|
|
1850
|
+
this.emitEvent('completion_intent_stale_input', taskId, {
|
|
1851
|
+
sourceRunId: intent.sourceRunId,
|
|
1852
|
+
nextAction: 'discard_incomplete_intent_and_evaluate_current_input',
|
|
1853
|
+
});
|
|
1854
|
+
return null;
|
|
1855
|
+
}
|
|
1591
1856
|
this.emitEvent('completion_intent_resumed', taskId, {
|
|
1592
1857
|
decision: intent.decision,
|
|
1593
1858
|
sourceRunId: intent.sourceRunId,
|
|
@@ -1761,6 +2026,17 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
1761
2026
|
});
|
|
1762
2027
|
// 恢复裁决时的 durable output — decision 必须与 resolution 记录的机器判定一致
|
|
1763
2028
|
const output = await this.recoverIntentOutput(taskId, resolution.sourceRunId, resolution.machineDecision);
|
|
2029
|
+
const currentInput = await this.resolveCurrentArtificerInput(leasedTask);
|
|
2030
|
+
if (output.sourceArtificerArtifactId !== currentInput.artifactId) {
|
|
2031
|
+
this.emitEvent('owner_resolution_stale_input', taskId, {
|
|
2032
|
+
resolutionId: resolution.resolutionId,
|
|
2033
|
+
sourceRunId: resolution.sourceRunId,
|
|
2034
|
+
resolutionArtifactId: output.sourceArtificerArtifactId,
|
|
2035
|
+
currentArtifactId: currentInput.artifactId,
|
|
2036
|
+
nextAction: 'formal_upstream_revision_required_before_owner_resolution',
|
|
2037
|
+
});
|
|
2038
|
+
throw new PDRuntimeError('execution_failed', 'owner_resolution_input_stale');
|
|
2039
|
+
}
|
|
1764
2040
|
// SPEC §20 纵深防御: 确定性对抗门失败不允许 approved override (capability
|
|
1765
2041
|
// 层已挡一道;此处防事实漂移窗口)。
|
|
1766
2042
|
if (overrideDecision === 'approved'
|
|
@@ -2000,9 +2276,56 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2000
2276
|
}
|
|
2001
2277
|
return undefined;
|
|
2002
2278
|
}
|
|
2279
|
+
async invokeRepairTaskSeeder(evaluatorTaskId, evaluatorRunId, params) {
|
|
2280
|
+
if (!this.repairTaskSeeder) {
|
|
2281
|
+
// Seeder not injected despite flag enabled — configuration error.
|
|
2282
|
+
// Surface via telemetry (rc-9: no silent fallback).
|
|
2283
|
+
this.emitEvent('repair_loop_seeder_missing', evaluatorTaskId, {
|
|
2284
|
+
runId: evaluatorRunId,
|
|
2285
|
+
reason: 'seed_artificer_repair_task_not_injected',
|
|
2286
|
+
});
|
|
2287
|
+
return null;
|
|
2288
|
+
}
|
|
2289
|
+
try {
|
|
2290
|
+
return await this.repairTaskSeeder(params);
|
|
2291
|
+
}
|
|
2292
|
+
catch (seedErr) {
|
|
2293
|
+
// Surface failure — do not silently swallow (rc-9).
|
|
2294
|
+
this.emitEvent('repair_task_seed_failed', evaluatorTaskId, {
|
|
2295
|
+
runId: evaluatorRunId,
|
|
2296
|
+
errorMessage: seedErr instanceof Error ? seedErr.message : String(seedErr),
|
|
2297
|
+
});
|
|
2298
|
+
return null;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2003
2301
|
async maybeSeedArtificerRepair(evaluatorTaskId, ctx) {
|
|
2004
2302
|
const { runId: evaluatorRunId, output } = ctx;
|
|
2005
|
-
const
|
|
2303
|
+
const artificerDependency = await this.resolveEvaluatorArtificerDependency(evaluatorTaskId);
|
|
2304
|
+
if (artificerDependency.kind === 'invalid') {
|
|
2305
|
+
this.emitEvent('repair_loop_seeding_refused', evaluatorTaskId, {
|
|
2306
|
+
runId: evaluatorRunId,
|
|
2307
|
+
reason: artificerDependency.reason,
|
|
2308
|
+
nextAction: 'inspect_evaluator_artificer_dependency_metadata',
|
|
2309
|
+
});
|
|
2310
|
+
return { kind: 'max_iterations_reached', detail: 'seed_failed' };
|
|
2311
|
+
}
|
|
2312
|
+
const inheritedArtificerPi = artificerDependency.kind === 'resolved' ? artificerDependency.piTask : undefined;
|
|
2313
|
+
const priorRepairResolution = await this.resolvePriorRepairIteration(evaluatorTaskId, inheritedArtificerPi);
|
|
2314
|
+
if (priorRepairResolution.kind === 'invalid') {
|
|
2315
|
+
this.emitEvent('repair_loop_seeding_refused', evaluatorTaskId, {
|
|
2316
|
+
runId: evaluatorRunId,
|
|
2317
|
+
reason: priorRepairResolution.reason,
|
|
2318
|
+
nextAction: 'inspect_deterministic_repair_task_identity',
|
|
2319
|
+
});
|
|
2320
|
+
return { kind: 'max_iterations_reached', detail: 'seed_failed' };
|
|
2321
|
+
}
|
|
2322
|
+
const priorRepairIteration = priorRepairResolution.iteration;
|
|
2323
|
+
const inheritedDeps = inheritedArtificerPi ? [...inheritedArtificerPi.dependencyTaskIds] : [];
|
|
2324
|
+
const inheritedChannel = inheritedArtificerPi?.channel ?? 'prompt';
|
|
2325
|
+
const inheritedPipelineMode = inheritedArtificerPi?.pipelineMode;
|
|
2326
|
+
const inheritedTimeoutMs = inheritedArtificerPi?.timeoutMs ?? 300_000;
|
|
2327
|
+
const inheritedInputArtifactRefs = inheritedArtificerPi ? [...inheritedArtificerPi.inputArtifactRefs] : [];
|
|
2328
|
+
const ownerEvidenceSelection = inheritedArtificerPi?.ownerEvidenceSelection;
|
|
2006
2329
|
// ── PRI-703 Phase 2 (Owner decision 2026-09-07): deterministic failure
|
|
2007
2330
|
// attribution BEFORE seeding a repair round. "测试失败 → 继续改 Rule" is
|
|
2008
2331
|
// the wrong default; a needs_revision whose replay failures are ALL
|
|
@@ -2091,12 +2414,39 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2091
2414
|
continue;
|
|
2092
2415
|
const existingPayload = piExisting.repairPayload;
|
|
2093
2416
|
if (existingPayload && existingPayload.sourceEvaluatorRunId === evaluatorRunId) {
|
|
2417
|
+
const payloadIdentityMatches = existingPayload.sourceEvaluatorTaskId === evaluatorTaskId
|
|
2418
|
+
&& existingPayload.repairIteration === iteration
|
|
2419
|
+
&& artificerRepairTaskId(existingPayload.sourceEvaluatorTaskId, existingPayload.repairIteration) === existing.taskId;
|
|
2420
|
+
if (!payloadIdentityMatches) {
|
|
2421
|
+
this.emitEvent('repair_loop_seeding_refused', evaluatorTaskId, {
|
|
2422
|
+
runId: evaluatorRunId,
|
|
2423
|
+
reason: 'repair_payload_identity_mismatch',
|
|
2424
|
+
nextAction: 'inspect_deterministic_repair_task_payload',
|
|
2425
|
+
});
|
|
2426
|
+
return { kind: 'max_iterations_reached', detail: 'seed_failed' };
|
|
2427
|
+
}
|
|
2428
|
+
// Same-run reuse is still an adoption decision: route it through the
|
|
2429
|
+
// same injected Repair Creation Authority instead of trusting the row
|
|
2430
|
+
// from runId alone. Terminal/malformed/channel-conflicting rows fail
|
|
2431
|
+
// closed here exactly as a seeder replay would.
|
|
2432
|
+
const repairTaskId = await this.invokeRepairTaskSeeder(evaluatorTaskId, evaluatorRunId, {
|
|
2433
|
+
repairPayload: existingPayload,
|
|
2434
|
+
inheritedDependencyTaskIds: inheritedDeps,
|
|
2435
|
+
inheritedChannel,
|
|
2436
|
+
inheritedPipelineMode,
|
|
2437
|
+
inheritedTimeoutMs,
|
|
2438
|
+
inheritedInputArtifactRefs,
|
|
2439
|
+
ownerEvidenceSelection,
|
|
2440
|
+
});
|
|
2441
|
+
if (repairTaskId === null) {
|
|
2442
|
+
return { kind: 'max_iterations_reached', detail: 'seed_failed' };
|
|
2443
|
+
}
|
|
2094
2444
|
this.emitEvent('repair_loop_idempotent_reuse', evaluatorTaskId, {
|
|
2095
2445
|
runId: evaluatorRunId,
|
|
2096
|
-
repairTaskId
|
|
2446
|
+
repairTaskId,
|
|
2097
2447
|
repairIteration: iteration,
|
|
2098
2448
|
});
|
|
2099
|
-
return { kind: 'repair_seeded', taskId:
|
|
2449
|
+
return { kind: 'repair_seeded', taskId: repairTaskId };
|
|
2100
2450
|
}
|
|
2101
2451
|
}
|
|
2102
2452
|
// ── Slice 5: max iterations (2) reached → fail loud ──
|
|
@@ -2154,78 +2504,27 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2154
2504
|
...(ctx.diagnosticReplayEvidence ? { diagnosticReplay: ctx.diagnosticReplayEvidence } : {}),
|
|
2155
2505
|
...(repairAttribution !== undefined ? { failureAttribution: repairAttribution } : {}),
|
|
2156
2506
|
};
|
|
2157
|
-
// Resolve the dependency artificer task to inherit dependencyTaskIds
|
|
2158
|
-
// (so the repair task points to the same scribe task, preserving lineage).
|
|
2159
|
-
const evaluatorTask = await this.stateManager.getTask(evaluatorTaskId);
|
|
2160
|
-
const evaluatorPiTask = evaluatorTask ? hydratePITaskRecord(evaluatorTask) : null;
|
|
2161
|
-
const evaluatorDeps = evaluatorPiTask?.dependencyTaskIds ?? [];
|
|
2162
|
-
// Inherit scribe-level dependency from the artificer task (the artificer's
|
|
2163
|
-
// own dependencyTaskIds), NOT the evaluator's dependencyTaskIds (which
|
|
2164
|
-
// point to the artificer, not the scribe).
|
|
2165
|
-
let inheritedDeps = [];
|
|
2166
|
-
let inheritedChannel = 'prompt';
|
|
2167
|
-
let inheritedPipelineMode;
|
|
2168
|
-
let inheritedTimeoutMs = 300_000;
|
|
2169
|
-
let inheritedInputArtifactRefs = [];
|
|
2170
|
-
let ownerEvidenceSelection;
|
|
2171
|
-
for (const depId of evaluatorDeps) {
|
|
2172
|
-
const depTask = await this.stateManager.getTask(depId);
|
|
2173
|
-
if (!depTask)
|
|
2174
|
-
continue;
|
|
2175
|
-
if (depTask.taskKind !== 'artificer')
|
|
2176
|
-
continue;
|
|
2177
|
-
const piArtificer = hydratePITaskRecord(depTask);
|
|
2178
|
-
if (!piArtificer)
|
|
2179
|
-
continue;
|
|
2180
|
-
inheritedDeps = piArtificer.dependencyTaskIds;
|
|
2181
|
-
inheritedChannel = piArtificer.channel;
|
|
2182
|
-
inheritedPipelineMode = piArtificer.pipelineMode;
|
|
2183
|
-
inheritedTimeoutMs = piArtificer.timeoutMs;
|
|
2184
|
-
inheritedInputArtifactRefs = piArtificer.inputArtifactRefs;
|
|
2185
|
-
({ ownerEvidenceSelection } = piArtificer);
|
|
2186
|
-
break;
|
|
2187
|
-
}
|
|
2188
2507
|
// Delegate to the injected seeder — core peer runners do NOT call
|
|
2189
2508
|
// task-creation directly (architecture-regression.test.ts enforces
|
|
2190
2509
|
// this boundary; the plugin layer wires the actual store mutation).
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
try {
|
|
2202
|
-
const repairTaskId = await this.repairTaskSeeder({
|
|
2203
|
-
repairPayload,
|
|
2204
|
-
inheritedDependencyTaskIds: inheritedDeps,
|
|
2205
|
-
inheritedChannel,
|
|
2206
|
-
inheritedPipelineMode,
|
|
2207
|
-
inheritedTimeoutMs,
|
|
2208
|
-
inheritedInputArtifactRefs,
|
|
2209
|
-
ownerEvidenceSelection,
|
|
2210
|
-
});
|
|
2211
|
-
this.emitEvent('repair_task_seeded', evaluatorTaskId, {
|
|
2212
|
-
repairTaskId,
|
|
2213
|
-
repairIteration: repairPayload.repairIteration,
|
|
2214
|
-
sourceArtificerArtifactId,
|
|
2215
|
-
});
|
|
2216
|
-
return { kind: 'repair_seeded', taskId: repairTaskId };
|
|
2217
|
-
}
|
|
2218
|
-
catch (seedErr) {
|
|
2219
|
-
// Surface failure — do not silently swallow (rc-9).
|
|
2220
|
-
this.emitEvent('repair_task_seed_failed', evaluatorTaskId, {
|
|
2221
|
-
runId: evaluatorRunId,
|
|
2222
|
-
errorMessage: seedErr instanceof Error ? seedErr.message : String(seedErr),
|
|
2223
|
-
});
|
|
2224
|
-
// Treat as max iterations reached so the caller skips markTaskSucceeded
|
|
2225
|
-
// and returns succeeded — the evaluator verdict stands; only the repair
|
|
2226
|
-
// seeding failed, which is logged.
|
|
2510
|
+
const repairTaskId = await this.invokeRepairTaskSeeder(evaluatorTaskId, evaluatorRunId, {
|
|
2511
|
+
repairPayload,
|
|
2512
|
+
inheritedDependencyTaskIds: inheritedDeps,
|
|
2513
|
+
inheritedChannel,
|
|
2514
|
+
inheritedPipelineMode,
|
|
2515
|
+
inheritedTimeoutMs,
|
|
2516
|
+
inheritedInputArtifactRefs,
|
|
2517
|
+
ownerEvidenceSelection,
|
|
2518
|
+
});
|
|
2519
|
+
if (repairTaskId === null) {
|
|
2227
2520
|
return { kind: 'max_iterations_reached', detail: 'seed_failed' };
|
|
2228
2521
|
}
|
|
2522
|
+
this.emitEvent('repair_task_seeded', evaluatorTaskId, {
|
|
2523
|
+
repairTaskId,
|
|
2524
|
+
repairIteration: repairPayload.repairIteration,
|
|
2525
|
+
sourceArtificerArtifactId,
|
|
2526
|
+
});
|
|
2527
|
+
return { kind: 'repair_seeded', taskId: repairTaskId };
|
|
2229
2528
|
}
|
|
2230
2529
|
// ── Optional hooks ──────────────────────────────────────────────────────────
|
|
2231
2530
|
/**
|