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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Internalization consumer governance wiring (host-neutral, PRI-624).
|
|
3
3
|
*
|
|
4
4
|
* Ported verbatim from openclaw-plugin `auto-consumer-governance-wiring.ts`
|
|
5
|
-
* (P0-D/E/F 生产接线) so the OpenClaw auto-consumer and the
|
|
6
|
-
* workspace
|
|
5
|
+
* (P0-D/E/F 生产接线) so the OpenClaw auto-consumer and the Service-Host-spawned
|
|
6
|
+
* workspace workers share ONE wiring implementation instead of copying it:
|
|
7
7
|
* - evaluator: isRepairLoopEnabled + seedArtificerRepairTask (bounded repair)
|
|
8
8
|
* - rollout_reviewer: dispatchActivation (approve_rollout → ActivationDispatcher;
|
|
9
9
|
* PRI-811 Phase B: 一律入 approvals.pending,Owner 批准后才激活) +
|
|
@@ -14,10 +14,7 @@
|
|
|
14
14
|
* dedupes by `${artifactId}::${channel}`; reopen idempotency is owned by
|
|
15
15
|
* orchestrator.reopenTaskForRevision.
|
|
16
16
|
*/
|
|
17
|
-
import { ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, SqliteConnection, SqliteActivationStateStore, SqliteApprovalQueueStore, SqlitePIArtifactStore, PrincipleTreeLedgerAdapter, createProductionGateDeps,
|
|
18
|
-
// PRI-1293 Phase 3: InternalizationOrchestrator.resolveAuthoritativeCorrelationId
|
|
19
|
-
// 静态只读包装 — 跨包访问唯一血缘权威的授权通道 (core 内部模块不进 barrel)。
|
|
20
|
-
import { InternalizationOrchestrator } from '@principles/core/runtime';
|
|
17
|
+
import { ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, SqliteConnection, SqliteActivationStateStore, SqliteApprovalQueueStore, SqlitePIArtifactStore, PrincipleTreeLedgerAdapter, createProductionGateDeps, createRepairTask, repairSeedErrorMessage, computeFeatureFlagsFromConfig, isFeatureEnabled, } from '@principles/core/runtime';
|
|
21
18
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
22
19
|
function normalizeDecision(decision) {
|
|
23
20
|
if (decision.decision === 'activated') {
|
|
@@ -145,98 +142,22 @@ export function createEvaluatorRepairDeps(workspaceDir, stateManager, logger) {
|
|
|
145
142
|
return isFeatureEnabled(flags, 'evaluator_artificer_repair_loop');
|
|
146
143
|
},
|
|
147
144
|
seedArtificerRepairTask: async (params) => {
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// corrective work, not a vehicle for new corrective work. Returning
|
|
156
|
-
// it here made the evaluator re-run against a superseded artifact
|
|
157
|
-
// forever (EP002-R2: same-artifact score oscillation, one LLM call
|
|
158
|
-
// per cycle, no new repair). New work requires a new revision epoch
|
|
159
|
-
// (Owner revise_once) — surface as a seed failure so the evaluator
|
|
160
|
-
// degrades to needs_human_review instead of looping.
|
|
161
|
-
if (existing.status === 'succeeded' || existing.status === 'failed' || existing.status === 'needs_human_review') {
|
|
162
|
-
throw new Error(`repair task ${repairTaskId} already reached terminal status ${existing.status}; refusing to reuse it as new corrective work (PRI-718 revise-ne-resume)`);
|
|
163
|
-
}
|
|
164
|
-
// PRI-1293 R7 (P1-1): 复用前完整身份验证 — 共享 core 唯一实现
|
|
165
|
-
// (verifyRepairTaskIdentity), 与 pd-cli seeder / orchestrator 完成
|
|
166
|
-
// 路径同一规则: payload 存在+来源/iteration 一致+taskId 互证+来源
|
|
167
|
-
// evaluator 真实+parent/correlation 一致+channel 一致。缺失亲缘字段
|
|
168
|
-
// 可 CAS 回填, payload 身份不符一律 fail-closed。
|
|
169
|
-
const identity = await verifyRepairTaskIdentity(existing, params.repairPayload.sourceEvaluatorTaskId, params.repairPayload.repairIteration, stateManager);
|
|
170
|
-
if (!identity.ok) {
|
|
171
|
-
throw new Error(`evaluator_repair_seed_lineage_refused:${identity.reason}:${identity.detail}`);
|
|
172
|
-
}
|
|
173
|
-
const existingPi = hydratePITaskRecord(existing);
|
|
174
|
-
if (!existingPi) {
|
|
175
|
-
throw new Error(`evaluator_repair_seed_lineage_refused:invalid_task_metadata:repair task ${repairTaskId} diagnosticJson unreadable`);
|
|
176
|
-
}
|
|
177
|
-
if (identity.needsLineageBackfill) {
|
|
178
|
-
// 旧任务缺亲缘字段 — 按权威来源补齐 ( merge 保持其余 28 字段 ),
|
|
179
|
-
// CAS 断言读取时的完整状态; 并发被触碰则放弃并结构化抛出, 下一轮
|
|
180
|
-
// seed 重试 (播种幂等, 重试安全)。
|
|
181
|
-
const merged = mergePITaskMetadata(existingPi, {
|
|
182
|
-
parentTaskId: params.repairPayload.sourceEvaluatorTaskId,
|
|
183
|
-
correlationId: identity.authoritativeCorrelationId,
|
|
184
|
-
});
|
|
185
|
-
const casResult = await stateManager.updateTaskIfDiagnosticJsonUnchanged(repairTaskId, existing.diagnosticJson ?? null, { diagnosticJson: createPITaskDiagnosticJson(merged) }, {
|
|
186
|
-
expectedStatus: existing.status,
|
|
187
|
-
expectedAttemptCount: existing.attemptCount,
|
|
188
|
-
expectedMaxAttempts: existing.maxAttempts,
|
|
189
|
-
expectedLeaseOwner: existing.leaseOwner ?? null,
|
|
190
|
-
expectedLeaseExpiresAt: existing.leaseExpiresAt ?? null,
|
|
191
|
-
expectedLeaseGeneration: existing.leaseGeneration ?? 0,
|
|
192
|
-
});
|
|
193
|
-
if (casResult === null) {
|
|
194
|
-
throw new Error(`evaluator_repair_seed_concurrent_modification: repair task ${repairTaskId} changed during lineage backfill — seed NOT applied, safe to retry`);
|
|
195
|
-
}
|
|
196
|
-
logger?.info?.(`[PD:Consumer] repair task ${repairTaskId} lineage backfilled (parentTaskId + correlationId ${identity.authoritativeCorrelationId}) before reuse`);
|
|
197
|
-
}
|
|
198
|
-
logger?.info?.(`[PD:Consumer] repair task ${repairTaskId} already exists (in-flight ${existing.status}); reusing (idempotent seed)`);
|
|
199
|
-
return repairTaskId;
|
|
145
|
+
// PRI-1299 Phase 1: 宿主层只做参数转发与既有错误语义映射; identity、
|
|
146
|
+
// reuse、payload/channel adjudication、lineage proof、insert 与 UNIQUE
|
|
147
|
+
// race re-arbitration 全部由 principles-core 的唯一 RepairCreationAuthority 执行。
|
|
148
|
+
const result = await createRepairTask(stateManager, params);
|
|
149
|
+
if (result.outcome === 'created') {
|
|
150
|
+
logger?.info?.(`[PD:Consumer] seeded artificer repair task ${result.task.taskId} (iteration ${params.repairPayload.repairIteration})`);
|
|
151
|
+
return result.task.taskId;
|
|
200
152
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
// runner 调用方传入的任何 candidateId (SeedArtificerRepairParams 本就
|
|
208
|
-
// 无此字段)。
|
|
209
|
-
const sourceEvaluatorTask = await stateManager.getTask(params.repairPayload.sourceEvaluatorTaskId);
|
|
210
|
-
if (!sourceEvaluatorTask) {
|
|
211
|
-
throw new Error(`evaluator_repair_seed_lineage_refused: source evaluator task ${params.repairPayload.sourceEvaluatorTaskId} not found`);
|
|
212
|
-
}
|
|
213
|
-
const lineage = await InternalizationOrchestrator.resolveAuthoritativeCorrelationId(sourceEvaluatorTask, (taskId) => stateManager.getTask(taskId));
|
|
214
|
-
if (!lineage.ok) {
|
|
215
|
-
throw new Error(`evaluator_repair_seed_lineage_refused:${lineage.reason}:${lineage.detail}`);
|
|
153
|
+
if (result.outcome === 'adopted_existing') {
|
|
154
|
+
if (result.backfilled) {
|
|
155
|
+
logger?.info?.(`[PD:Consumer] repair task ${result.task.taskId} lineage backfilled before reuse`);
|
|
156
|
+
}
|
|
157
|
+
logger?.info?.(`[PD:Consumer] repair task ${result.task.taskId} already exists (in-flight ${result.task.status}); reusing (idempotent seed)`);
|
|
158
|
+
return result.task.taskId;
|
|
216
159
|
}
|
|
217
|
-
|
|
218
|
-
taskId: repairTaskId,
|
|
219
|
-
taskKind: 'artificer',
|
|
220
|
-
status: 'pending',
|
|
221
|
-
attemptCount: 0,
|
|
222
|
-
maxAttempts: 3,
|
|
223
|
-
diagnosticJson: createPITaskDiagnosticJson({
|
|
224
|
-
dependencyTaskIds: [...params.inheritedDependencyTaskIds],
|
|
225
|
-
channel: params.inheritedChannel,
|
|
226
|
-
pipelineMode: params.inheritedPipelineMode,
|
|
227
|
-
timeoutMs: params.inheritedTimeoutMs,
|
|
228
|
-
inputArtifactRefs: [...params.inheritedInputArtifactRefs],
|
|
229
|
-
outputArtifactRefs: [],
|
|
230
|
-
parentTaskId: params.repairPayload.sourceEvaluatorTaskId,
|
|
231
|
-
correlationId: lineage.correlationId,
|
|
232
|
-
...(params.ownerEvidenceSelection !== undefined
|
|
233
|
-
? { ownerEvidenceSelection: params.ownerEvidenceSelection }
|
|
234
|
-
: {}),
|
|
235
|
-
repairPayload: params.repairPayload,
|
|
236
|
-
}),
|
|
237
|
-
});
|
|
238
|
-
logger?.info?.(`[PD:Consumer] seeded artificer repair task ${repairTaskId} (iteration ${params.repairPayload.repairIteration}, correlationId ${lineage.correlationId}${lineage.recoveredFromLegacyRoot ? ', recovered from legacy root' : ''})`);
|
|
239
|
-
return repairTaskId;
|
|
160
|
+
throw new Error(repairSeedErrorMessage(result));
|
|
240
161
|
},
|
|
241
162
|
};
|
|
242
163
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-1301 / PRI-1293 Phase 2B — 共享单步 Runner 执行器 (SPEC-PD-PIPELINE-SPINE-001 §3.5)
|
|
3
|
+
* (PRI-1301: 从 internalization-consumer-cycle.ts 独立成模块 — 纯移动,
|
|
4
|
+
* 执行器本体逐字等价; 周期调度/选择/lease/恢复/reconciliation 留在 cycle)。
|
|
5
|
+
*
|
|
6
|
+
* `executeSelectedInternalizationTask` 是六种 Peer Runner 构造+执行的唯一权威
|
|
7
|
+
* 实现。收编对象:consumer cycle 分支 + pd-cli
|
|
8
|
+
* `runtime-internalization-run-once` 的 6 分支手搓构造。`rulehost-pipeline-
|
|
9
|
+
* runner` 是显式同步对抗算子 (非租约编排),按 SPEC §3.5.2 白名单保留独立构造。
|
|
10
|
+
*
|
|
11
|
+
* 职责边界 (统一 Runner 执行,不统一所有宿主行为):
|
|
12
|
+
* 只负责 — kind→Runner 映射、按判别联合的类型化依赖装配、执行指定 taskId、
|
|
13
|
+
* 返回原始执行结果。
|
|
14
|
+
* 不进入 — 任务发现/选择/wake/lease (orchestrator)、Runtime Profile 解析、
|
|
15
|
+
* Adapter/L2 路由 (各入口自建 adapter 传入)、Owner Evidence Preflight
|
|
16
|
+
* (auto consumer)、repair 任务创建 (两个 governance deps 工厂)、后继提交、
|
|
17
|
+
* 周期调度、Workspace Telemetry 归属 (eventEmitter 由入口选择)。
|
|
18
|
+
*
|
|
19
|
+
* Scribe/Artificer/Evaluator 的 ledgerIdentity 从 (workspaceDir, stateManager)
|
|
20
|
+
* 以同一装配导出 — 此前 consumer 与 run-once 各自内联同一段闭包 (重复实现)。
|
|
21
|
+
* 两个入口的有意差异 (§2.5) 由输入类型表达:artificer 的 evidence pack /
|
|
22
|
+
* trustedFacts 仅由具备 preflight 能力的入口传入;evaluator 的 repair deps /
|
|
23
|
+
* gateDeps / hostToolCatalog / hostSemanticContext 必需显式提供,不存在缺省
|
|
24
|
+
* 掩盖 (类型层面不可缺失)。
|
|
25
|
+
*/
|
|
26
|
+
import { type PDRuntimeAdapter, type RuntimeStateManager, type TelemetryEvent, type PIArtifactStore, type EffectivePdConfig, type OutputLanguage, type RefinerRuleHostGateDeps, type RolloutAutoDispatchInput, type RolloutAutoDispatchOutcome, type RolloutRevisionRoutingInput, type SeedArtificerRepairParams, type BehaviorExamplePack, type ArtificerTrustedFactsPort, type ArtificerHostSemanticContext, type DreamerRunnerResult, type PhilosopherRunnerResult, type ScribeRunnerResult, type ArtificerRunnerResult, type EvaluatorRunnerResult, type EvaluatorRunnerOptions, type RolloutReviewerRunnerResult } from '@principles/core/runtime';
|
|
27
|
+
/**
|
|
28
|
+
* Runner 遥测窄端口 — 与 core `PeerRunnerTelemetryEmitter` 结构等价
|
|
29
|
+
* (该类型不在 core 冻结 barrel 上,此处按结构声明,零新增导出)。
|
|
30
|
+
* StoreEventEmitter 与 WorkspaceTelemetryEmitter 均满足。
|
|
31
|
+
*/
|
|
32
|
+
export interface SelectedTaskTelemetryEmitter {
|
|
33
|
+
readonly emitTelemetry: (event: TelemetryEvent) => unknown;
|
|
34
|
+
}
|
|
35
|
+
/** 全部 kind 共享的调用方依赖。 */
|
|
36
|
+
export interface SelectedInternalizationTaskBaseDeps {
|
|
37
|
+
/** 要执行的已**选中**任务 — 执行租约由 Runner 在 run() 内自行获取, 调用方不在本层租约。 */
|
|
38
|
+
readonly taskId: string;
|
|
39
|
+
readonly stateManager: RuntimeStateManager;
|
|
40
|
+
/** 入口自建的 runtime adapter (含 L2 / test-double 路由决策)。 */
|
|
41
|
+
readonly runtimeAdapter: PDRuntimeAdapter;
|
|
42
|
+
/** 入口选择的遥测口 (consumer evaluator 用 workspace-scoped emitter)。 */
|
|
43
|
+
readonly eventEmitter: SelectedTaskTelemetryEmitter;
|
|
44
|
+
readonly artifactStore: PIArtifactStore;
|
|
45
|
+
/** Workspace 根 — ledgerIdentity 装配的唯一事实来源。 */
|
|
46
|
+
readonly workspaceDir: string;
|
|
47
|
+
}
|
|
48
|
+
/** Runner 构造/执行选项 — 原样转发 (各入口既有语义保持)。 */
|
|
49
|
+
export interface SelectedInternalizationTaskRunnerOptions {
|
|
50
|
+
readonly owner: string;
|
|
51
|
+
readonly runtimeKind: string;
|
|
52
|
+
readonly timeoutMs: number;
|
|
53
|
+
readonly effectiveConfig?: EffectivePdConfig;
|
|
54
|
+
readonly outputLanguage?: OutputLanguage;
|
|
55
|
+
readonly pollIntervalMs?: number;
|
|
56
|
+
}
|
|
57
|
+
/** Evaluator repair 轮的宿主接线 (来自既有 governance deps 工厂,不造第三套)。 */
|
|
58
|
+
export interface SelectedEvaluatorRepairDeps {
|
|
59
|
+
readonly isRepairLoopEnabled: () => boolean;
|
|
60
|
+
readonly seedArtificerRepairTask: (params: SeedArtificerRepairParams) => Promise<string>;
|
|
61
|
+
}
|
|
62
|
+
/** rollout 治理接线 (来自 createRolloutGovernanceDeps)。 */
|
|
63
|
+
export interface SelectedRolloutGovernanceDeps {
|
|
64
|
+
readonly dispatchActivation: (input: RolloutAutoDispatchInput) => Promise<RolloutAutoDispatchOutcome>;
|
|
65
|
+
readonly reopenRevisionTarget: (input: RolloutRevisionRoutingInput) => Promise<{
|
|
66
|
+
ok: boolean;
|
|
67
|
+
reason: string;
|
|
68
|
+
reopenedTaskId?: string;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 按 taskKind 收窄的判别联合输入 — 必需依赖在类型层面不可缺失;
|
|
73
|
+
* optional 仅限两个入口现状真实可选的字段 (artificer 的 evidence pack /
|
|
74
|
+
* trustedFacts / hostSemanticContext、evaluator 的宿主目录与语义投影)。
|
|
75
|
+
*/
|
|
76
|
+
export type ExecuteSelectedInternalizationTaskInput = ({
|
|
77
|
+
readonly taskKind: 'dreamer';
|
|
78
|
+
} & SelectedInternalizationTaskBaseDeps & {
|
|
79
|
+
readonly runnerOptions: SelectedInternalizationTaskRunnerOptions;
|
|
80
|
+
}) | ({
|
|
81
|
+
readonly taskKind: 'philosopher';
|
|
82
|
+
} & SelectedInternalizationTaskBaseDeps & {
|
|
83
|
+
readonly runnerOptions: SelectedInternalizationTaskRunnerOptions;
|
|
84
|
+
}) | ({
|
|
85
|
+
readonly taskKind: 'scribe';
|
|
86
|
+
} & SelectedInternalizationTaskBaseDeps & {
|
|
87
|
+
readonly runnerOptions: SelectedInternalizationTaskRunnerOptions;
|
|
88
|
+
}) | ({
|
|
89
|
+
readonly taskKind: 'artificer';
|
|
90
|
+
/** 仅 preflight 通过的入口传入 (consumer evidence ready);run-once 无此能力则缺省。 */
|
|
91
|
+
readonly behaviorExamplePack?: BehaviorExamplePack;
|
|
92
|
+
/** 仅 consumer 传入 — 与 intent preflight 同源的 trusted-facts 端口。 */
|
|
93
|
+
readonly trustedFacts?: ArtificerTrustedFactsPort;
|
|
94
|
+
readonly hostSemanticContext?: ArtificerHostSemanticContext;
|
|
95
|
+
} & SelectedInternalizationTaskBaseDeps & {
|
|
96
|
+
readonly runnerOptions: SelectedInternalizationTaskRunnerOptions;
|
|
97
|
+
}) | ({
|
|
98
|
+
readonly taskKind: 'evaluator';
|
|
99
|
+
/** repair 轮宿主接线 — 缺失即是装配错误,不允许缺省掩盖。 */
|
|
100
|
+
readonly repairDeps: SelectedEvaluatorRepairDeps;
|
|
101
|
+
/** 对抗重放 gate — 两个入口都必须显式提供各自权威解析结果。 */
|
|
102
|
+
readonly gateDeps: RefinerRuleHostGateDeps;
|
|
103
|
+
readonly hostToolCatalog?: EvaluatorRunnerOptions['hostToolCatalog'];
|
|
104
|
+
readonly hostSemanticContext?: ArtificerHostSemanticContext;
|
|
105
|
+
} & SelectedInternalizationTaskBaseDeps & {
|
|
106
|
+
readonly runnerOptions: SelectedInternalizationTaskRunnerOptions;
|
|
107
|
+
}) | ({
|
|
108
|
+
readonly taskKind: 'rollout_reviewer';
|
|
109
|
+
readonly governanceDeps: SelectedRolloutGovernanceDeps;
|
|
110
|
+
} & SelectedInternalizationTaskBaseDeps & {
|
|
111
|
+
readonly runnerOptions: SelectedInternalizationTaskRunnerOptions;
|
|
112
|
+
});
|
|
113
|
+
export type SelectedInternalizationTaskRunResult = DreamerRunnerResult | PhilosopherRunnerResult | ScribeRunnerResult | ArtificerRunnerResult | EvaluatorRunnerResult | RolloutReviewerRunnerResult;
|
|
114
|
+
/**
|
|
115
|
+
* Execute ONE selected internalization task with the kind-selected runner.
|
|
116
|
+
* Constructs the runner from the typed input and returns the raw run result.
|
|
117
|
+
*
|
|
118
|
+
* Lease ownership contract (CodeRabbit review fix): the caller is responsible
|
|
119
|
+
* for SELECTING the task (e.g. a dry-run `wakeOnce` `would_lease` candidate);
|
|
120
|
+
* the runner itself acquires the execution lease inside `run()` — callers must
|
|
121
|
+
* NOT lease at this layer. The doc previously demanded an already-leased task,
|
|
122
|
+
* which would lead new callers to acquire the lease at the wrong layer.
|
|
123
|
+
*
|
|
124
|
+
* Runner crashes propagate to the caller (each entry keeps its own crash
|
|
125
|
+
* semantics: consumer rethrows without state writes; run-once logs + rethrows).
|
|
126
|
+
*/
|
|
127
|
+
export declare function executeSelectedInternalizationTask(input: ExecuteSelectedInternalizationTaskInput): Promise<SelectedInternalizationTaskRunResult>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-1301 / PRI-1293 Phase 2B — 共享单步 Runner 执行器 (SPEC-PD-PIPELINE-SPINE-001 §3.5)
|
|
3
|
+
* (PRI-1301: 从 internalization-consumer-cycle.ts 独立成模块 — 纯移动,
|
|
4
|
+
* 执行器本体逐字等价; 周期调度/选择/lease/恢复/reconciliation 留在 cycle)。
|
|
5
|
+
*
|
|
6
|
+
* `executeSelectedInternalizationTask` 是六种 Peer Runner 构造+执行的唯一权威
|
|
7
|
+
* 实现。收编对象:consumer cycle 分支 + pd-cli
|
|
8
|
+
* `runtime-internalization-run-once` 的 6 分支手搓构造。`rulehost-pipeline-
|
|
9
|
+
* runner` 是显式同步对抗算子 (非租约编排),按 SPEC §3.5.2 白名单保留独立构造。
|
|
10
|
+
*
|
|
11
|
+
* 职责边界 (统一 Runner 执行,不统一所有宿主行为):
|
|
12
|
+
* 只负责 — kind→Runner 映射、按判别联合的类型化依赖装配、执行指定 taskId、
|
|
13
|
+
* 返回原始执行结果。
|
|
14
|
+
* 不进入 — 任务发现/选择/wake/lease (orchestrator)、Runtime Profile 解析、
|
|
15
|
+
* Adapter/L2 路由 (各入口自建 adapter 传入)、Owner Evidence Preflight
|
|
16
|
+
* (auto consumer)、repair 任务创建 (两个 governance deps 工厂)、后继提交、
|
|
17
|
+
* 周期调度、Workspace Telemetry 归属 (eventEmitter 由入口选择)。
|
|
18
|
+
*
|
|
19
|
+
* Scribe/Artificer/Evaluator 的 ledgerIdentity 从 (workspaceDir, stateManager)
|
|
20
|
+
* 以同一装配导出 — 此前 consumer 与 run-once 各自内联同一段闭包 (重复实现)。
|
|
21
|
+
* 两个入口的有意差异 (§2.5) 由输入类型表达:artificer 的 evidence pack /
|
|
22
|
+
* trustedFacts 仅由具备 preflight 能力的入口传入;evaluator 的 repair deps /
|
|
23
|
+
* gateDeps / hostToolCatalog / hostSemanticContext 必需显式提供,不存在缺省
|
|
24
|
+
* 掩盖 (类型层面不可缺失)。
|
|
25
|
+
*/
|
|
26
|
+
import { DreamerRunner, PhilosopherRunner, ScribeRunner, ArtificerRunner, EvaluatorRunner, RolloutReviewerRunner, DefaultDreamerValidator, DefaultPhilosopherValidator, DefaultScribeValidator, DefaultArtificerValidator, DefaultEvaluatorValidator, DefaultRolloutReviewerValidator, PrincipleTreeLedgerAdapter, } from '@principles/core/runtime';
|
|
27
|
+
/**
|
|
28
|
+
* Scribe/Artificer/Evaluator 共用的 ledger 身份装配 — 与两个入口此前内联的
|
|
29
|
+
* 闭包逐字等价 (每次调用新开 PrincipleTreeLedgerAdapter 读盘,无跨周期缓存)。
|
|
30
|
+
*/
|
|
31
|
+
function buildWorkspaceLedgerIdentity(workspaceDir, stateManager) {
|
|
32
|
+
const ledger = () => new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` });
|
|
33
|
+
return {
|
|
34
|
+
resolveForCandidate: async (candidateId) => {
|
|
35
|
+
const candidate = await stateManager.getCandidate(candidateId);
|
|
36
|
+
return ledger().resolveCandidatePrincipleIdentity(candidateId, candidate?.rawRecommendationKind);
|
|
37
|
+
},
|
|
38
|
+
// PRI-915: availability first — an unreadable ledger must not read as an
|
|
39
|
+
// unresolved chain.
|
|
40
|
+
isAvailable: () => ledger().isAvailable(),
|
|
41
|
+
listForCandidate: (candidateId) => ledger().listForCandidate(candidateId),
|
|
42
|
+
hasPrinciple: (principleId) => ledger().hasPrinciple(principleId),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execute ONE selected internalization task with the kind-selected runner.
|
|
47
|
+
* Constructs the runner from the typed input and returns the raw run result.
|
|
48
|
+
*
|
|
49
|
+
* Lease ownership contract (CodeRabbit review fix): the caller is responsible
|
|
50
|
+
* for SELECTING the task (e.g. a dry-run `wakeOnce` `would_lease` candidate);
|
|
51
|
+
* the runner itself acquires the execution lease inside `run()` — callers must
|
|
52
|
+
* NOT lease at this layer. The doc previously demanded an already-leased task,
|
|
53
|
+
* which would lead new callers to acquire the lease at the wrong layer.
|
|
54
|
+
*
|
|
55
|
+
* Runner crashes propagate to the caller (each entry keeps its own crash
|
|
56
|
+
* semantics: consumer rethrows without state writes; run-once logs + rethrows).
|
|
57
|
+
*/
|
|
58
|
+
export async function executeSelectedInternalizationTask(input) {
|
|
59
|
+
const { taskId, stateManager, runtimeAdapter, eventEmitter, artifactStore, workspaceDir } = input;
|
|
60
|
+
const { runnerOptions } = input;
|
|
61
|
+
// Evaluator 的身份装配含 hasPrinciple (PRI-911A writer boundary);
|
|
62
|
+
// Scribe 另需 listForCandidate (chain stamping);Artificer 只读解析。
|
|
63
|
+
// 一次装配、按 kind 结构化满足各自 deps 形状。
|
|
64
|
+
const ledgerIdentity = buildWorkspaceLedgerIdentity(workspaceDir, stateManager);
|
|
65
|
+
switch (input.taskKind) {
|
|
66
|
+
case 'dreamer':
|
|
67
|
+
return new DreamerRunner({ stateManager, runtimeAdapter, eventEmitter, artifactStore, validator: new DefaultDreamerValidator() }, runnerOptions).run(taskId);
|
|
68
|
+
case 'philosopher':
|
|
69
|
+
return new PhilosopherRunner({ stateManager, runtimeAdapter, eventEmitter, artifactStore, validator: new DefaultPhilosopherValidator() }, runnerOptions).run(taskId);
|
|
70
|
+
case 'scribe':
|
|
71
|
+
return new ScribeRunner({
|
|
72
|
+
stateManager, runtimeAdapter, eventEmitter, artifactStore,
|
|
73
|
+
validator: new DefaultScribeValidator({ requireRuleCodeContracts: true }),
|
|
74
|
+
// I2 — CHAIN STAMPING (Owner review of PR #1856, P1): 完整三元身份
|
|
75
|
+
// (resolveForCandidate / isAvailable / listForCandidate)。
|
|
76
|
+
ledgerIdentity,
|
|
77
|
+
}, runnerOptions).run(taskId);
|
|
78
|
+
case 'artificer':
|
|
79
|
+
return new ArtificerRunner({
|
|
80
|
+
stateManager, runtimeAdapter, eventEmitter, artifactStore,
|
|
81
|
+
validator: new DefaultArtificerValidator(),
|
|
82
|
+
ledgerIdentity,
|
|
83
|
+
...(input.behaviorExamplePack !== undefined ? { behaviorExamplePack: input.behaviorExamplePack } : {}),
|
|
84
|
+
...(input.trustedFacts !== undefined ? { trustedFacts: input.trustedFacts } : {}),
|
|
85
|
+
}, {
|
|
86
|
+
...runnerOptions,
|
|
87
|
+
...(input.hostSemanticContext !== undefined ? { hostSemanticContext: input.hostSemanticContext } : {}),
|
|
88
|
+
}).run(taskId);
|
|
89
|
+
case 'evaluator': {
|
|
90
|
+
const evaluatorLedgerIdentity = {
|
|
91
|
+
resolveForCandidate: ledgerIdentity.resolveForCandidate,
|
|
92
|
+
isAvailable: ledgerIdentity.isAvailable,
|
|
93
|
+
hasPrinciple: ledgerIdentity.hasPrinciple,
|
|
94
|
+
};
|
|
95
|
+
return new EvaluatorRunner({
|
|
96
|
+
stateManager,
|
|
97
|
+
runtimeAdapter,
|
|
98
|
+
eventEmitter,
|
|
99
|
+
artifactStore,
|
|
100
|
+
validator: new DefaultEvaluatorValidator(),
|
|
101
|
+
ledgerIdentity: evaluatorLedgerIdentity,
|
|
102
|
+
isRepairLoopEnabled: input.repairDeps.isRepairLoopEnabled,
|
|
103
|
+
seedArtificerRepairTask: input.repairDeps.seedArtificerRepairTask,
|
|
104
|
+
}, {
|
|
105
|
+
...runnerOptions,
|
|
106
|
+
gateDeps: input.gateDeps,
|
|
107
|
+
...(input.hostToolCatalog !== undefined
|
|
108
|
+
? { hostToolCatalog: { readOnlyTools: [...input.hostToolCatalog.readOnlyTools], writeTools: [...input.hostToolCatalog.writeTools] } }
|
|
109
|
+
: {}),
|
|
110
|
+
...(input.hostSemanticContext !== undefined ? { hostSemanticContext: input.hostSemanticContext } : {}),
|
|
111
|
+
}).run(taskId);
|
|
112
|
+
}
|
|
113
|
+
case 'rollout_reviewer':
|
|
114
|
+
return new RolloutReviewerRunner({
|
|
115
|
+
stateManager, runtimeAdapter, eventEmitter, artifactStore,
|
|
116
|
+
validator: new DefaultRolloutReviewerValidator(),
|
|
117
|
+
dispatchActivation: input.governanceDeps.dispatchActivation,
|
|
118
|
+
reopenRevisionTarget: input.governanceDeps.reopenRevisionTarget,
|
|
119
|
+
}, runnerOptions).run(taskId);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
* (SPEC workbuddy-host-adapter §1 Excluded: no transcript reads).
|
|
9
9
|
*
|
|
10
10
|
* SPEC §15 worker mode, evaluated WITHOUT executing anything (no lease, no
|
|
11
|
-
* LLM). `manual_action_required` means
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* LLM). `manual_action_required` means this governance workspace is not
|
|
12
|
+
* registered in the canonical install manifest, so the PD Service Host —
|
|
13
|
+
* the only background runtime, triggered by the OS scheduler — never
|
|
14
|
+
* discovers it and no automatic worker cycles run for it. Manual
|
|
15
|
+
* `pd diagnose` / `pd runtime internalization run-once` is the recovery
|
|
16
|
+
* route.
|
|
14
17
|
*/
|
|
15
18
|
export type WorkbuddyWorkerMode = 'ready' | 'manual_action_required' | 'paused' | 'degraded';
|
|
16
19
|
export interface WorkbuddyWorkerStatusEvaluation {
|
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
* (SPEC workbuddy-host-adapter §1 Excluded: no transcript reads).
|
|
9
9
|
*
|
|
10
10
|
* SPEC §15 worker mode, evaluated WITHOUT executing anything (no lease, no
|
|
11
|
-
* LLM). `manual_action_required` means
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* LLM). `manual_action_required` means this governance workspace is not
|
|
12
|
+
* registered in the canonical install manifest, so the PD Service Host —
|
|
13
|
+
* the only background runtime, triggered by the OS scheduler — never
|
|
14
|
+
* discovers it and no automatic worker cycles run for it. Manual
|
|
15
|
+
* `pd diagnose` / `pd runtime internalization run-once` is the recovery
|
|
16
|
+
* route.
|
|
14
17
|
*/
|
|
15
18
|
import * as fs from 'node:fs';
|
|
16
19
|
import * as path from 'node:path';
|
|
@@ -48,7 +51,7 @@ export function computeWorkbuddyWorkerStatusMode(input) {
|
|
|
48
51
|
return {
|
|
49
52
|
mode: 'manual_action_required',
|
|
50
53
|
reason: 'workspace_not_in_install_manifest',
|
|
51
|
-
nextAction: `
|
|
54
|
+
nextAction: `This governance workspace is not registered in the canonical install manifest, so the PD Service Host does not manage automatic worker cycles for it. Repair the registration with the PD installer (npx create-principles-disciple). Manual path: pd diagnose --workspace "${workspaceDir}", then pd runtime internalization run-once.`,
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
return { mode: 'ready' };
|
|
@@ -52,7 +52,7 @@ import { StoreEventEmitter } from '@principles/core/runtime';
|
|
|
52
52
|
* 事件,含完整 TelemetryEvent)。同步 append:事件量小(allowlist 限流),
|
|
53
53
|
* 换取 crash 前落盘的 durable 语义。写失败绝不影响 runner —— 降级为
|
|
54
54
|
* `onPersistFailure` 回调(宿主注入的结构化告警口;OpenClaw 是
|
|
55
|
-
* SystemLogger,
|
|
55
|
+
* SystemLogger,Service-Host 派生的 workspace worker 是自己的事件口)。
|
|
56
56
|
*/
|
|
57
57
|
const CRITICAL_EVENT_ALLOWLIST = new Set([
|
|
58
58
|
'evaluator_adversarial_replay_skipped',
|
|
@@ -178,7 +178,7 @@ export declare function withInstallManifestWriteLock<T>(options: WithManifestWri
|
|
|
178
178
|
export type WorkspaceBackgroundOwnership = {
|
|
179
179
|
status: 'legacy_owned';
|
|
180
180
|
source: 'no_record' | 'record';
|
|
181
|
-
/** Implicit generation of the
|
|
181
|
+
/** Implicit generation of the absent-record/un-provisioned projection is 0; a record carries its own. */
|
|
182
182
|
generation: number;
|
|
183
183
|
record?: BackgroundExecutionRecord;
|
|
184
184
|
} | {
|
|
@@ -199,39 +199,35 @@ export interface ReadOwnershipOptions {
|
|
|
199
199
|
realpath?: RealpathProbe;
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
|
-
* The single read-side projection
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
202
|
+
* The single read-side ownership projection for ONE workspace in the
|
|
203
|
+
* Service-Host-only model. `service_host_owned` is the only state that may
|
|
204
|
+
* admit consumption; every other persisted state is historical residue, and
|
|
205
|
+
* an absent record means not-yet-provisioned. For projection compatibility
|
|
206
|
+
* the absent case is still represented as `legacy_owned`/`no_record`/
|
|
207
|
+
* generation 0 — readers must interpret that as un-provisioned, never as a
|
|
208
|
+
* living legacy consumer. Fail-closed: an unreadable or malformed manifest
|
|
209
|
+
* is `manifest_unreadable`; "cannot decide" is NEVER collapsed into an
|
|
210
|
+
* admission decision for a consumer that is about to act.
|
|
207
211
|
*/
|
|
208
212
|
export declare function readWorkspaceBackgroundOwnership(options: ReadOwnershipOptions): WorkspaceBackgroundOwnership;
|
|
209
|
-
export declare const BACKGROUND_EXECUTION_TRANSITIONS: readonly ['provision_fresh_install'
|
|
213
|
+
export declare const BACKGROUND_EXECUTION_TRANSITIONS: readonly ['provision_fresh_install'];
|
|
210
214
|
export type BackgroundExecutionTransitionKind = (typeof BACKGROUND_EXECUTION_TRANSITIONS)[number];
|
|
211
215
|
export interface TransitionBackgroundExecutionInput {
|
|
212
216
|
manifestPath: string;
|
|
213
217
|
workspaceDir: string;
|
|
214
218
|
kind: BackgroundExecutionTransitionKind;
|
|
215
219
|
/**
|
|
216
|
-
* Idempotency key of the operator's operation.
|
|
217
|
-
* `
|
|
218
|
-
*
|
|
220
|
+
* Idempotency key of the operator's provisioning operation. The converged
|
|
221
|
+
* `service_host_owned` record is steady-state and therefore persists
|
|
222
|
+
* `operationId: null` (the schema contract); replay safety is enforced by
|
|
223
|
+
* treating that converged state as a no-op rather than by writing a second
|
|
224
|
+
* generation.
|
|
219
225
|
*/
|
|
220
226
|
operationId: string;
|
|
221
227
|
/** Caller-observed generation fence; mismatch refuses (stale view loses). */
|
|
222
228
|
expectedGeneration?: number;
|
|
223
|
-
/**
|
|
229
|
+
/** Also merge the workspace into `workspaces[]` in the same atomic write. */
|
|
224
230
|
registerWorkspace?: boolean;
|
|
225
|
-
/**
|
|
226
|
-
* provision_fresh_install ONLY: the caller's proof that this Workspace has
|
|
227
|
-
* no historical background consumer (a brand-new PD install created it in
|
|
228
|
-
* this run). A legacy upgrade NEVER passes this — it must use
|
|
229
|
-
* begin_handover so the old consumer is stopped and verified first.
|
|
230
|
-
* The proof is enforced structurally below: the manifest must hold NO
|
|
231
|
-
* ownership record for the workspace (absence of history), not merely a
|
|
232
|
-
* `legacy_owned` record.
|
|
233
|
-
*/
|
|
234
|
-
freshInstall?: boolean;
|
|
235
231
|
platform?: string;
|
|
236
232
|
now?: () => Date;
|
|
237
233
|
staleMs?: number;
|
|
@@ -250,19 +246,19 @@ export interface TransitionBackgroundExecutionSuccess {
|
|
|
250
246
|
}
|
|
251
247
|
export interface TransitionBackgroundExecutionFailure {
|
|
252
248
|
ok: false;
|
|
253
|
-
reason: 'invalid_input' | 'manifest_unreadable' | 'workspace_not_registered' | 'unexpected_state' | 'stale_generation' | '
|
|
249
|
+
reason: 'invalid_input' | 'manifest_unreadable' | 'workspace_not_registered' | 'unexpected_state' | 'stale_generation' | 'lock_busy' | 'lock_invalid' | 'lock_io_error' | 'io_error';
|
|
254
250
|
message: string;
|
|
255
251
|
nextAction?: string;
|
|
256
252
|
current?: WorkspaceBackgroundOwnership;
|
|
257
253
|
}
|
|
258
254
|
export type TransitionBackgroundExecutionResult = TransitionBackgroundExecutionSuccess | TransitionBackgroundExecutionFailure;
|
|
259
255
|
/**
|
|
260
|
-
* Execute one
|
|
261
|
-
* critical section. The manifest is
|
|
262
|
-
* (unknown top-level fields survive
|
|
263
|
-
* `autoCheck` / `releaseMetadataUrl`),
|
|
264
|
-
* atomic rename. A legacy single-key
|
|
265
|
-
* migrated to the per-Workspace map in the
|
|
266
|
-
* the write would be a parse conflict).
|
|
256
|
+
* Execute the one live ownership transition — provision this Workspace into
|
|
257
|
+
* `service_host_owned` — under the CAS critical section. The manifest is
|
|
258
|
+
* read, validated, mutated as a RAW object (unknown top-level fields survive
|
|
259
|
+
* — the update side owns `channel` / `autoCheck` / `releaseMetadataUrl`),
|
|
260
|
+
* re-validated, and landed with an atomic rename. A legacy single-key
|
|
261
|
+
* `backgroundExecution` spelling is migrated to the per-Workspace map in the
|
|
262
|
+
* same write (both spellings after the write would be a parse conflict).
|
|
267
263
|
*/
|
|
268
264
|
export declare function transitionWorkspaceBackgroundExecution(input: TransitionBackgroundExecutionInput): TransitionBackgroundExecutionResult;
|