create-principles-disciple 1.156.1 → 1.156.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 +1 -1
- package/core/dist/runtime/adversarial-loop.d.ts.map +1 -1
- package/core/dist/runtime/adversarial-loop.js +12 -0
- package/core/dist/runtime/adversarial-loop.js.map +1 -1
- package/core/dist/runtime/index.d.ts +7 -1
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +8 -1
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/internalization/correlation-lineage.d.ts +113 -0
- package/core/dist/runtime/internalization/correlation-lineage.d.ts.map +1 -0
- package/core/dist/runtime/internalization/correlation-lineage.js +431 -0
- package/core/dist/runtime/internalization/correlation-lineage.js.map +1 -0
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +58 -5
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.js +370 -100
- package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-state-machine.d.ts +14 -0
- package/core/dist/runtime/internalization/internalization-state-machine.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-state-machine.js +22 -0
- package/core/dist/runtime/internalization/internalization-state-machine.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 +31 -0
- package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.js +54 -1
- package/core/dist/runtime/internalization/pitask-metadata.js.map +1 -1
- package/core/dist/runtime/internalization/repair-task-identity.d.ts +43 -0
- package/core/dist/runtime/internalization/repair-task-identity.d.ts.map +1 -0
- package/core/dist/runtime/internalization/repair-task-identity.js +102 -0
- package/core/dist/runtime/internalization/repair-task-identity.js.map +1 -0
- package/core/dist/runtime/internalization/revision-reopen.d.ts +37 -0
- package/core/dist/runtime/internalization/revision-reopen.d.ts.map +1 -1
- package/core/dist/runtime/internalization/revision-reopen.js +144 -7
- package/core/dist/runtime/internalization/revision-reopen.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +8 -2
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js +2 -2
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/rule-binding-revision.js +3 -3
- package/core/dist/runtime/internalization/rule-binding-revision.js.map +1 -1
- package/core/package.json +1 -1
- package/host-runtime/dist/index.d.ts +2 -1
- package/host-runtime/dist/index.js +11 -1
- package/host-runtime/dist/internalization-consumer-cycle.d.ts +102 -1
- package/host-runtime/dist/internalization-consumer-cycle.js +177 -95
- package/host-runtime/dist/internalization-consumer-governance.d.ts +2 -1
- package/host-runtime/dist/internalization-consumer-governance.js +57 -2
- package/host-runtime/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +184 -17
- 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 +209 -127
- package/pd-cli/dist/commands/runtime-internalization-run-once.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 +53 -4
- package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +480 -480
- package/plugin/dist/openclaw-worker.js +265 -265
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/package.json +1 -1
|
@@ -158,7 +158,16 @@ async function runReconciliationBudget(workspaceDir, orchestrator, ports) {
|
|
|
158
158
|
cursorStore.set(SUCCEEDED_TRANSITIONS_SCOPE, recon.nextCursor);
|
|
159
159
|
}
|
|
160
160
|
const errors = recon.outcomes.filter((o) => o.decision.startsWith('reconcile_error'));
|
|
161
|
-
|
|
161
|
+
// PRI-1293 R6: fail-closed 错误类别 (血缘拒绝/并发冲突/完整性冲突/
|
|
162
|
+
// repair reopen 失败/元数据损坏) 的完整排障信息必须进遥测 — 不得
|
|
163
|
+
// 只留下 blocked 计数而静默丢弃拒绝原因。
|
|
164
|
+
const REFUSAL_DECISIONS = new Set([
|
|
165
|
+
'lineage_refused', 'concurrent_modification', 'successor_integrity_conflict',
|
|
166
|
+
'successor_id_conflict', 'revision_reopen_failed', 'invalid_task_metadata',
|
|
167
|
+
'source_correction_reopen_failed',
|
|
168
|
+
]);
|
|
169
|
+
const refusals = recon.outcomes.filter((o) => REFUSAL_DECISIONS.has(o.decision));
|
|
170
|
+
if (recon.recovered > 0 || errors.length > 0 || refusals.length > 0) {
|
|
162
171
|
emitEvent('INTERNALIZATION_CONSUMER_RECONCILED', JSON.stringify({
|
|
163
172
|
scanned: recon.scanned,
|
|
164
173
|
recovered: recon.recovered,
|
|
@@ -168,6 +177,7 @@ async function runReconciliationBudget(workspaceDir, orchestrator, ports) {
|
|
|
168
177
|
recoveries: recon.outcomes.filter((o) => o.decision === 'successor_created' || o.decision.includes('reopened')),
|
|
169
178
|
// P1 (最终复核): per-task 错误显式可观测 — 即使 recovered=0
|
|
170
179
|
errors,
|
|
180
|
+
refusals,
|
|
171
181
|
}));
|
|
172
182
|
logger.info(`[PD:${logLabel}] Reconciliation: recovered=${recon.recovered} errors=${errors.length} wrapped=${recon.wrappedAround}`);
|
|
173
183
|
}
|
|
@@ -185,6 +195,101 @@ async function runReconciliationBudget(workspaceDir, orchestrator, ports) {
|
|
|
185
195
|
logger.warn(`[PD:${logLabel}] Succeeded-transition reconciliation failed: ${String(reconErr)}`);
|
|
186
196
|
}
|
|
187
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Scribe/Artificer/Evaluator 共用的 ledger 身份装配 — 与两个入口此前内联的
|
|
200
|
+
* 闭包逐字等价 (每次调用新开 PrincipleTreeLedgerAdapter 读盘,无跨周期缓存)。
|
|
201
|
+
*/
|
|
202
|
+
function buildWorkspaceLedgerIdentity(workspaceDir, stateManager) {
|
|
203
|
+
const ledger = () => new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` });
|
|
204
|
+
return {
|
|
205
|
+
resolveForCandidate: async (candidateId) => {
|
|
206
|
+
const candidate = await stateManager.getCandidate(candidateId);
|
|
207
|
+
return ledger().resolveCandidatePrincipleIdentity(candidateId, candidate?.rawRecommendationKind);
|
|
208
|
+
},
|
|
209
|
+
// PRI-915: availability first — an unreadable ledger must not read as an
|
|
210
|
+
// unresolved chain.
|
|
211
|
+
isAvailable: () => ledger().isAvailable(),
|
|
212
|
+
listForCandidate: (candidateId) => ledger().listForCandidate(candidateId),
|
|
213
|
+
hasPrinciple: (principleId) => ledger().hasPrinciple(principleId),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Execute ONE selected internalization task with the kind-selected runner.
|
|
218
|
+
* Constructs the runner from the typed input and returns the raw run result.
|
|
219
|
+
*
|
|
220
|
+
* Lease ownership contract (CodeRabbit review fix): the caller is responsible
|
|
221
|
+
* for SELECTING the task (e.g. a dry-run `wakeOnce` `would_lease` candidate);
|
|
222
|
+
* the runner itself acquires the execution lease inside `run()` — callers must
|
|
223
|
+
* NOT lease at this layer. The doc previously demanded an already-leased task,
|
|
224
|
+
* which would lead new callers to acquire the lease at the wrong layer.
|
|
225
|
+
*
|
|
226
|
+
* Runner crashes propagate to the caller (each entry keeps its own crash
|
|
227
|
+
* semantics: consumer rethrows without state writes; run-once logs + rethrows).
|
|
228
|
+
*/
|
|
229
|
+
export async function executeSelectedInternalizationTask(input) {
|
|
230
|
+
const { taskId, stateManager, runtimeAdapter, eventEmitter, artifactStore, workspaceDir } = input;
|
|
231
|
+
const { runnerOptions } = input;
|
|
232
|
+
// Evaluator 的身份装配含 hasPrinciple (PRI-911A writer boundary);
|
|
233
|
+
// Scribe 另需 listForCandidate (chain stamping);Artificer 只读解析。
|
|
234
|
+
// 一次装配、按 kind 结构化满足各自 deps 形状。
|
|
235
|
+
const ledgerIdentity = buildWorkspaceLedgerIdentity(workspaceDir, stateManager);
|
|
236
|
+
switch (input.taskKind) {
|
|
237
|
+
case 'dreamer':
|
|
238
|
+
return new DreamerRunner({ stateManager, runtimeAdapter, eventEmitter, artifactStore, validator: new DefaultDreamerValidator() }, runnerOptions).run(taskId);
|
|
239
|
+
case 'philosopher':
|
|
240
|
+
return new PhilosopherRunner({ stateManager, runtimeAdapter, eventEmitter, artifactStore, validator: new DefaultPhilosopherValidator() }, runnerOptions).run(taskId);
|
|
241
|
+
case 'scribe':
|
|
242
|
+
return new ScribeRunner({
|
|
243
|
+
stateManager, runtimeAdapter, eventEmitter, artifactStore,
|
|
244
|
+
validator: new DefaultScribeValidator({ requireRuleCodeContracts: true }),
|
|
245
|
+
// I2 — CHAIN STAMPING (Owner review of PR #1856, P1): 完整三元身份
|
|
246
|
+
// (resolveForCandidate / isAvailable / listForCandidate)。
|
|
247
|
+
ledgerIdentity,
|
|
248
|
+
}, runnerOptions).run(taskId);
|
|
249
|
+
case 'artificer':
|
|
250
|
+
return new ArtificerRunner({
|
|
251
|
+
stateManager, runtimeAdapter, eventEmitter, artifactStore,
|
|
252
|
+
validator: new DefaultArtificerValidator(),
|
|
253
|
+
ledgerIdentity,
|
|
254
|
+
...(input.behaviorExamplePack !== undefined ? { behaviorExamplePack: input.behaviorExamplePack } : {}),
|
|
255
|
+
...(input.trustedFacts !== undefined ? { trustedFacts: input.trustedFacts } : {}),
|
|
256
|
+
}, {
|
|
257
|
+
...runnerOptions,
|
|
258
|
+
...(input.hostSemanticContext !== undefined ? { hostSemanticContext: input.hostSemanticContext } : {}),
|
|
259
|
+
}).run(taskId);
|
|
260
|
+
case 'evaluator': {
|
|
261
|
+
const evaluatorLedgerIdentity = {
|
|
262
|
+
resolveForCandidate: ledgerIdentity.resolveForCandidate,
|
|
263
|
+
isAvailable: ledgerIdentity.isAvailable,
|
|
264
|
+
hasPrinciple: ledgerIdentity.hasPrinciple,
|
|
265
|
+
};
|
|
266
|
+
return new EvaluatorRunner({
|
|
267
|
+
stateManager,
|
|
268
|
+
runtimeAdapter,
|
|
269
|
+
eventEmitter,
|
|
270
|
+
artifactStore,
|
|
271
|
+
validator: new DefaultEvaluatorValidator(),
|
|
272
|
+
ledgerIdentity: evaluatorLedgerIdentity,
|
|
273
|
+
isRepairLoopEnabled: input.repairDeps.isRepairLoopEnabled,
|
|
274
|
+
seedArtificerRepairTask: input.repairDeps.seedArtificerRepairTask,
|
|
275
|
+
}, {
|
|
276
|
+
...runnerOptions,
|
|
277
|
+
gateDeps: input.gateDeps,
|
|
278
|
+
...(input.hostToolCatalog !== undefined
|
|
279
|
+
? { hostToolCatalog: { readOnlyTools: [...input.hostToolCatalog.readOnlyTools], writeTools: [...input.hostToolCatalog.writeTools] } }
|
|
280
|
+
: {}),
|
|
281
|
+
...(input.hostSemanticContext !== undefined ? { hostSemanticContext: input.hostSemanticContext } : {}),
|
|
282
|
+
}).run(taskId);
|
|
283
|
+
}
|
|
284
|
+
case 'rollout_reviewer':
|
|
285
|
+
return new RolloutReviewerRunner({
|
|
286
|
+
stateManager, runtimeAdapter, eventEmitter, artifactStore,
|
|
287
|
+
validator: new DefaultRolloutReviewerValidator(),
|
|
288
|
+
dispatchActivation: input.governanceDeps.dispatchActivation,
|
|
289
|
+
reopenRevisionTarget: input.governanceDeps.reopenRevisionTarget,
|
|
290
|
+
}, runnerOptions).run(taskId);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
188
293
|
/**
|
|
189
294
|
* Run ONE bounded consumer cycle for a workspace. At most one downstream task
|
|
190
295
|
* is leased and executed per cycle (DEFAULT_CONSUMER_MAX_TASKS_PER_CYCLE=1);
|
|
@@ -735,126 +840,80 @@ async function executeConsumerCycle(workspaceDir, ports, signals) {
|
|
|
735
840
|
// degrade through the host's structured event port, never break the runner.
|
|
736
841
|
// (PRI-795 review P1: the emitter itself is constructed above, before the
|
|
737
842
|
// adapter dispatch, so the ArtificerL2 adapter can share it.)
|
|
843
|
+
// PRI-1293 Phase 2B: 构造执行器输入并交由唯一权威实现执行。逐 kind 的
|
|
844
|
+
// 差异只剩「哪些类型化依赖由本入口提供」(eventEmitter 选择、evidence
|
|
845
|
+
// pack、repair/governance 接线、宿主目录/语义投影) — Runner 构造本体
|
|
846
|
+
// 收编进 executeSelectedInternalizationTask。
|
|
738
847
|
// Dispatch by leased task kind. Only kinds listed in
|
|
739
848
|
// FULL_CHAIN_CONSUMER_RUNNER_KINDS can be leased here; anything else
|
|
740
849
|
// (e.g. diagnostician) hits the default branch — fail loud if it does (EP-03).
|
|
741
|
-
let
|
|
850
|
+
let executionInput = null;
|
|
742
851
|
switch (taskKind) {
|
|
743
852
|
case 'dreamer':
|
|
744
|
-
|
|
853
|
+
executionInput = {
|
|
854
|
+
taskKind, taskId, workspaceDir, stateManager, runtimeAdapter: adapter,
|
|
855
|
+
eventEmitter: storeEmitter, artifactStore: stateManager.piArtifactStore, runnerOptions,
|
|
856
|
+
};
|
|
745
857
|
break;
|
|
746
858
|
case 'philosopher':
|
|
747
|
-
|
|
859
|
+
executionInput = {
|
|
860
|
+
taskKind, taskId, workspaceDir, stateManager, runtimeAdapter: adapter,
|
|
861
|
+
eventEmitter: storeEmitter, artifactStore: stateManager.piArtifactStore, runnerOptions,
|
|
862
|
+
};
|
|
748
863
|
break;
|
|
749
864
|
case 'scribe':
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
// dreamer task seed's candidateId) onto the artifact it writes, so
|
|
755
|
-
// the dispatcher's ledger identity gate sees a resolvable
|
|
756
|
-
// identity on the live production chain. listForCandidate reads
|
|
757
|
-
// the ledger from disk per call — no cross-cycle staleness.
|
|
758
|
-
ledgerIdentity: {
|
|
759
|
-
resolveForCandidate: async (candidateId) => {
|
|
760
|
-
const candidate = await stateManager.getCandidate(candidateId);
|
|
761
|
-
return new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` }).resolveCandidatePrincipleIdentity(candidateId, candidate?.rawRecommendationKind);
|
|
762
|
-
},
|
|
763
|
-
// PRI-915: availability first — an unreadable ledger must not
|
|
764
|
-
// read as an unresolved chain.
|
|
765
|
-
isAvailable: () => new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` }).isAvailable(),
|
|
766
|
-
listForCandidate: (candidateId) => new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` }).listForCandidate(candidateId),
|
|
767
|
-
},
|
|
768
|
-
}, runnerOptions);
|
|
865
|
+
executionInput = {
|
|
866
|
+
taskKind, taskId, workspaceDir, stateManager, runtimeAdapter: adapter,
|
|
867
|
+
eventEmitter: storeEmitter, artifactStore: stateManager.piArtifactStore, runnerOptions,
|
|
868
|
+
};
|
|
769
869
|
break;
|
|
770
870
|
case 'artificer':
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
const candidate = await stateManager.getCandidate(candidateId);
|
|
775
|
-
return new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` }).resolveCandidatePrincipleIdentity(candidateId, candidate?.rawRecommendationKind);
|
|
776
|
-
} },
|
|
871
|
+
executionInput = {
|
|
872
|
+
taskKind, taskId, workspaceDir, stateManager, runtimeAdapter: adapter,
|
|
873
|
+
eventEmitter: storeEmitter, artifactStore: stateManager.piArtifactStore, runnerOptions,
|
|
777
874
|
// PRI-982 (SPEC-PD-IAER-001 FR-02): the preflight-assembled Owner
|
|
778
875
|
// evidence pack — present only when the authoritative channel is
|
|
779
|
-
// code_tool_hook AND the readiness gate returned ready
|
|
780
|
-
// ArtificerRunnerDeps shape as the run-rulehost CLI pipeline).
|
|
876
|
+
// code_tool_hook AND the readiness gate returned ready.
|
|
781
877
|
...(artificerEvidence !== null && artificerEvidence.decision === 'ready'
|
|
782
878
|
? { behaviorExamplePack: artificerEvidence.pack }
|
|
783
879
|
: {}),
|
|
784
880
|
// SPEC-RULECODE-QUALITY-001 A1 (Owner review P2): the SAME
|
|
785
881
|
// trusted-facts port the intent preflight used must ride into the
|
|
786
|
-
// runner so the defensive mirror sees the same fact resolutions
|
|
787
|
-
// without this, a port-resolved task would pass the entry gate and
|
|
788
|
-
// then be refused by the runner's "provider absent" guard.
|
|
882
|
+
// runner so the defensive mirror sees the same fact resolutions.
|
|
789
883
|
...(ports.trustedFacts !== undefined ? { trustedFacts: ports.trustedFacts } : {}),
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
884
|
+
// PRI-741: thread the host semantic projection into generation.
|
|
885
|
+
...(artificerHostSemanticContext !== undefined ? { hostSemanticContext: artificerHostSemanticContext } : {}),
|
|
886
|
+
};
|
|
793
887
|
break;
|
|
794
888
|
case 'evaluator':
|
|
795
|
-
// P0-D
|
|
796
|
-
//
|
|
797
|
-
//
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
// 无论 OpenClaw 还是 Codex worker 执行, deterministic gate wiring
|
|
807
|
-
// 必须存在 (第二个 options 参数, 绝不放第一个 deps 参数)。
|
|
808
|
-
runner = new EvaluatorRunner({
|
|
809
|
-
stateManager, runtimeAdapter: adapter, eventEmitter: workspaceEmitter,
|
|
810
|
-
artifactStore: stateManager.piArtifactStore, validator: new DefaultEvaluatorValidator(),
|
|
811
|
-
// PRI-911A (I1 writer boundary): the rule artifact's identity is a
|
|
812
|
-
// ledger UUID or nothing. hasPrinciple turns "UUID-shaped" into
|
|
813
|
-
// "UUID the ledger actually mints", so a shaped-but-unknown id is
|
|
814
|
-
// refused as invalid_identity instead of being carried forward.
|
|
815
|
-
// Same per-call disk read as the scribe wiring above.
|
|
816
|
-
// PRI-915: availability first — an unreadable ledger must surface
|
|
817
|
-
// as identity_source_unavailable, not as invalid_identity drift.
|
|
818
|
-
ledgerIdentity: {
|
|
819
|
-
resolveForCandidate: async (candidateId) => {
|
|
820
|
-
const candidate = await stateManager.getCandidate(candidateId);
|
|
821
|
-
return new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` }).resolveCandidatePrincipleIdentity(candidateId, candidate?.rawRecommendationKind);
|
|
822
|
-
},
|
|
823
|
-
isAvailable: () => new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` }).isAvailable(),
|
|
824
|
-
hasPrinciple: (principleId) => new PrincipleTreeLedgerAdapter({ stateDir: `${workspaceDir}/.state` }).hasPrinciple(principleId),
|
|
825
|
-
},
|
|
826
|
-
...createEvaluatorRepairDeps(workspaceDir, stateManager, logger),
|
|
827
|
-
}, {
|
|
828
|
-
...runnerOptions,
|
|
829
|
-
// PRI-634-F: host registry + workspace root (when declared) make
|
|
830
|
-
// the evaluator's adversarial replay resolve tool semantics and
|
|
831
|
-
// normalizedPath identically to the host production gate.
|
|
889
|
+
// P0-D 生产接线 / PRI-630 / PRI-634 A1+A3 注释语义保持: repair deps
|
|
890
|
+
// 来自既有 governance 工厂; gateDeps 是 evaluator production
|
|
891
|
+
// semantics (options 第二参由执行器装配), 宿主目录/语义投影可选透传。
|
|
892
|
+
executionInput = {
|
|
893
|
+
taskKind, taskId, workspaceDir, stateManager, runtimeAdapter: adapter,
|
|
894
|
+
// PRI-634 A3: workspace-scoped telemetry — evaluator 事件归属本
|
|
895
|
+
// workspace (multi-workspace 隔离), 其余 kind 走全局 storeEmitter。
|
|
896
|
+
eventEmitter: workspaceEmitter,
|
|
897
|
+
artifactStore: stateManager.piArtifactStore,
|
|
898
|
+
runnerOptions,
|
|
899
|
+
repairDeps: createEvaluatorRepairDeps(workspaceDir, stateManager, logger),
|
|
832
900
|
gateDeps: createProductionGateDeps({
|
|
833
901
|
...(toolSemantics ? { toolSemantics } : {}),
|
|
834
902
|
projectDir: workspaceDir,
|
|
835
903
|
}),
|
|
836
|
-
...(hostToolCatalog
|
|
837
|
-
? { hostToolCatalog: { readOnlyTools: [...hostToolCatalog.readOnlyTools], writeTools: [...hostToolCatalog.writeTools] } }
|
|
838
|
-
: {}),
|
|
839
|
-
// PRI-741: host-name parity replay case from the SAME registry
|
|
840
|
-
// provenance as the gateDeps above.
|
|
904
|
+
...(hostToolCatalog ? { hostToolCatalog } : {}),
|
|
841
905
|
...(artificerHostSemanticContext !== undefined ? { hostSemanticContext: artificerHostSemanticContext } : {}),
|
|
842
|
-
}
|
|
906
|
+
};
|
|
843
907
|
break;
|
|
844
908
|
case 'rollout_reviewer':
|
|
845
|
-
// Lineage echo reconciliation is built into the runner
|
|
846
|
-
//
|
|
847
|
-
//
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
runner = new RolloutReviewerRunner({
|
|
854
|
-
stateManager, runtimeAdapter: adapter, eventEmitter: storeEmitter,
|
|
855
|
-
artifactStore: stateManager.piArtifactStore, validator: new DefaultRolloutReviewerValidator(),
|
|
856
|
-
...createRolloutGovernanceDeps(workspaceDir, orchestrator, { logger, ...(toolSemantics ? { toolSemantics } : {}) }),
|
|
857
|
-
}, runnerOptions);
|
|
909
|
+
// Lineage echo reconciliation is built into the runner; P0-E/F 治理接线
|
|
910
|
+
// (approve_rollout → approvals.pending; needs_revision → reopen, INV-04)
|
|
911
|
+
// 来自既有 governance 工厂 — Owner 审批绝不被绕过。
|
|
912
|
+
executionInput = {
|
|
913
|
+
taskKind, taskId, workspaceDir, stateManager, runtimeAdapter: adapter,
|
|
914
|
+
eventEmitter: storeEmitter, artifactStore: stateManager.piArtifactStore, runnerOptions,
|
|
915
|
+
governanceDeps: createRolloutGovernanceDeps(workspaceDir, orchestrator, { logger, ...(toolSemantics ? { toolSemantics } : {}) }),
|
|
916
|
+
};
|
|
858
917
|
break;
|
|
859
918
|
default:
|
|
860
919
|
emitEvent('INTERNALIZATION_CONSUMER_SKIP', JSON.stringify({ decision: 'no_runner_for_kind', taskKind }));
|
|
@@ -876,7 +935,7 @@ async function executeConsumerCycle(workspaceDir, ports, signals) {
|
|
|
876
935
|
}));
|
|
877
936
|
let runResult;
|
|
878
937
|
try {
|
|
879
|
-
runResult = await
|
|
938
|
+
runResult = await executeSelectedInternalizationTask(executionInput);
|
|
880
939
|
}
|
|
881
940
|
catch (runErr) {
|
|
882
941
|
logger.error(`[PD:${logLabel}] Runner crashed for task ${taskId}: ${String(runErr)}`);
|
|
@@ -899,10 +958,33 @@ async function executeConsumerCycle(workspaceDir, ports, signals) {
|
|
|
899
958
|
emitEvent('INTERNALIZATION_CONSUMER_COMMIT_FAILED', JSON.stringify({ taskId, error: String(commitErr).slice(0, 300) }));
|
|
900
959
|
logger.warn(`[PD:${logLabel}] Task ${taskId} succeeded but successor proposal failed: ${String(commitErr).slice(0, 200)}`);
|
|
901
960
|
}
|
|
961
|
+
// PRI-1293 R6: 结构化 successor 事件 — decision 之外的排障字段
|
|
962
|
+
// (reason/detail/冲突 id 集合/reopened 目标) 必须透出, repair reopen
|
|
963
|
+
// 失败不得只留下一个模糊 decision 名。
|
|
964
|
+
const successorTelemetry = {};
|
|
965
|
+
if (commitResult) {
|
|
966
|
+
successorTelemetry.successorDecision = commitResult.decision;
|
|
967
|
+
if ('reason' in commitResult && typeof commitResult.reason === 'string') {
|
|
968
|
+
successorTelemetry.successorReason = commitResult.reason;
|
|
969
|
+
}
|
|
970
|
+
if ('detail' in commitResult && typeof commitResult.detail === 'string') {
|
|
971
|
+
successorTelemetry.successorDetail = commitResult.detail;
|
|
972
|
+
}
|
|
973
|
+
if ('conflictingSuccessorTaskIds' in commitResult && Array.isArray(commitResult.conflictingSuccessorTaskIds)) {
|
|
974
|
+
successorTelemetry.successorConflictingTaskIds = [...commitResult.conflictingSuccessorTaskIds];
|
|
975
|
+
}
|
|
976
|
+
successorTelemetry.sourceTaskId = 'sourceTaskId' in commitResult ? commitResult.sourceTaskId : taskId;
|
|
977
|
+
if ('reopenedTaskId' in commitResult && typeof commitResult.reopenedTaskId === 'string') {
|
|
978
|
+
successorTelemetry.reopenedTaskId = commitResult.reopenedTaskId;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
successorTelemetry.successorDecision = 'commit_failed';
|
|
983
|
+
}
|
|
902
984
|
emitEvent('INTERNALIZATION_CONSUMER_SUCCESS', JSON.stringify({
|
|
903
985
|
taskId,
|
|
904
986
|
status: runResult.status,
|
|
905
|
-
...
|
|
987
|
+
...successorTelemetry,
|
|
906
988
|
}));
|
|
907
989
|
logger.info(`[PD:${logLabel}] Task ${taskId} succeeded. Successor: ${commitResult ? commitResult.decision : 'commit_failed'}`);
|
|
908
990
|
return { ran: true, taskId, taskKind, runStatus: 'succeeded' };
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* dedupes by `${artifactId}::${channel}`; reopen idempotency is owned by
|
|
15
15
|
* orchestrator.reopenTaskForRevision.
|
|
16
16
|
*/
|
|
17
|
-
import { type RolloutAutoDispatchInput, type RolloutAutoDispatchOutcome, type RolloutRevisionRoutingInput, type SeedArtificerRepairParams, type RuntimeStateManager, type
|
|
17
|
+
import { type RolloutAutoDispatchInput, type RolloutAutoDispatchOutcome, type RolloutRevisionRoutingInput, type SeedArtificerRepairParams, type RuntimeStateManager, type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
18
|
+
import { InternalizationOrchestrator } from '@principles/core/runtime';
|
|
18
19
|
/** Structural logger port — PluginLogger satisfies this without adaptation. */
|
|
19
20
|
export interface ConsumerGovernanceLogger {
|
|
20
21
|
info?: (msg: string) => void;
|
|
@@ -14,7 +14,10 @@
|
|
|
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, createPITaskDiagnosticJson, artificerRepairTaskId, computeFeatureFlagsFromConfig, isFeatureEnabled, } from '@principles/core/runtime';
|
|
17
|
+
import { ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, SqliteConnection, SqliteActivationStateStore, SqliteApprovalQueueStore, SqlitePIArtifactStore, PrincipleTreeLedgerAdapter, createProductionGateDeps, createPITaskDiagnosticJson, mergePITaskMetadata, hydratePITaskRecord, artificerRepairTaskId, verifyRepairTaskIdentity, computeFeatureFlagsFromConfig, isFeatureEnabled, } from '@principles/core/runtime';
|
|
18
|
+
// PRI-1293 Phase 3: InternalizationOrchestrator.resolveAuthoritativeCorrelationId
|
|
19
|
+
// 静态只读包装 — 跨包访问唯一血缘权威的授权通道 (core 内部模块不进 barrel)。
|
|
20
|
+
import { InternalizationOrchestrator } from '@principles/core/runtime';
|
|
18
21
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
19
22
|
function normalizeDecision(decision) {
|
|
20
23
|
if (decision.decision === 'activated') {
|
|
@@ -158,9 +161,59 @@ export function createEvaluatorRepairDeps(workspaceDir, stateManager, logger) {
|
|
|
158
161
|
if (existing.status === 'succeeded' || existing.status === 'failed' || existing.status === 'needs_human_review') {
|
|
159
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)`);
|
|
160
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
|
+
}
|
|
161
198
|
logger?.info?.(`[PD:Consumer] repair task ${repairTaskId} already exists (in-flight ${existing.status}); reusing (idempotent seed)`);
|
|
162
199
|
return repairTaskId;
|
|
163
200
|
}
|
|
201
|
+
// PRI-1293 Phase 3 (§5.2): repair 任务创建前从来源 evaluator 恢复权威
|
|
202
|
+
// 血缘 — 校验失败结构化抛出 (流入 evaluator 的 repair_task_seed_failed →
|
|
203
|
+
// seed_failed 路径), 绝不创建无血缘后继; 成功则把验证过的 correlationId
|
|
204
|
+
// 与 parentTaskId=sourceEvaluatorTaskId 写入 repair metadata (既有
|
|
205
|
+
// createPITaskDiagnosticJson 机制), 使 repair 链可回溯根 dreamer、
|
|
206
|
+
// 下一轮 evaluator 经 mergePITaskMetadata 天然继承同一 id。不信任
|
|
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}`);
|
|
216
|
+
}
|
|
164
217
|
await stateManager.createTask({
|
|
165
218
|
taskId: repairTaskId,
|
|
166
219
|
taskKind: 'artificer',
|
|
@@ -174,13 +227,15 @@ export function createEvaluatorRepairDeps(workspaceDir, stateManager, logger) {
|
|
|
174
227
|
timeoutMs: params.inheritedTimeoutMs,
|
|
175
228
|
inputArtifactRefs: [...params.inheritedInputArtifactRefs],
|
|
176
229
|
outputArtifactRefs: [],
|
|
230
|
+
parentTaskId: params.repairPayload.sourceEvaluatorTaskId,
|
|
231
|
+
correlationId: lineage.correlationId,
|
|
177
232
|
...(params.ownerEvidenceSelection !== undefined
|
|
178
233
|
? { ownerEvidenceSelection: params.ownerEvidenceSelection }
|
|
179
234
|
: {}),
|
|
180
235
|
repairPayload: params.repairPayload,
|
|
181
236
|
}),
|
|
182
237
|
});
|
|
183
|
-
logger?.info?.(`[PD:Consumer] seeded artificer repair task ${repairTaskId} (iteration ${params.repairPayload.repairIteration})`);
|
|
238
|
+
logger?.info?.(`[PD:Consumer] seeded artificer repair task ${repairTaskId} (iteration ${params.repairPayload.repairIteration}, correlationId ${lineage.correlationId}${lineage.recoveredFromLegacyRoot ? ', recovered from legacy root' : ''})`);
|
|
184
239
|
return repairTaskId;
|
|
185
240
|
},
|
|
186
241
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-principles-disciple",
|
|
3
|
-
"version": "1.156.
|
|
3
|
+
"version": "1.156.2",
|
|
4
4
|
"description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"pd": {
|
|
104
104
|
"bundledPluginVersion": "4.2.1"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "3f068988cf04b22501a5c190f52f88630d1cb12f"
|
|
107
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-internalization-enqueue-successors.d.ts","sourceRoot":"","sources":["../../src/commands/runtime-internalization-enqueue-successors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-internalization-enqueue-successors.d.ts","sourceRoot":"","sources":["../../src/commands/runtime-internalization-enqueue-successors.ts"],"names":[],"mappings":"AAcA,UAAU,wBAAwB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAwWD,wBAAsB,6CAA6C,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkWjH"}
|