create-principles-disciple 1.145.1 → 1.145.3

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.
Files changed (116) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +4 -4
  3. package/console/dist/ui/i18n/en.json +17 -16
  4. package/console/dist/ui/i18n/zh-CN.json +17 -16
  5. package/console/dist/ui/pages/focus/FocusPage.js +9 -5
  6. package/console/dist/ui/pages/focus/OwnerDecisionCard.js +1 -1
  7. package/console/dist/ui/pages/principles/PrincipleDetailPage.js +10 -4
  8. package/console/dist/ui/pages/principles/PrinciplesPage.js +1 -1
  9. package/console/dist/ui/utils/reading-layout.d.ts +19 -0
  10. package/console/dist/ui/utils/reading-layout.js +46 -0
  11. package/console/dist/web/assets/app.js +30 -28
  12. package/core/dist/runtime-v2/index.d.ts +10 -0
  13. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  14. package/core/dist/runtime-v2/index.js +5 -0
  15. package/core/dist/runtime-v2/index.js.map +1 -1
  16. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +25 -6
  17. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
  18. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +21 -7
  19. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
  20. package/core/dist/runtime-v2/internalization/artificer-run-correlation.d.ts +82 -0
  21. package/core/dist/runtime-v2/internalization/artificer-run-correlation.d.ts.map +1 -0
  22. package/core/dist/runtime-v2/internalization/artificer-run-correlation.js +79 -0
  23. package/core/dist/runtime-v2/internalization/artificer-run-correlation.js.map +1 -0
  24. package/core/dist/runtime-v2/internalization/artificer-runner.d.ts +16 -2
  25. package/core/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  26. package/core/dist/runtime-v2/internalization/artificer-runner.js +89 -9
  27. package/core/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  28. package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.d.ts +141 -0
  29. package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.d.ts.map +1 -0
  30. package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.js +284 -0
  31. package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.js.map +1 -0
  32. package/core/dist/runtime-v2/internalization/evidence-readiness.d.ts +170 -0
  33. package/core/dist/runtime-v2/internalization/evidence-readiness.d.ts.map +1 -0
  34. package/core/dist/runtime-v2/internalization/evidence-readiness.js +335 -0
  35. package/core/dist/runtime-v2/internalization/evidence-readiness.js.map +1 -0
  36. package/core/dist/runtime-v2/internalization/owner-evidence-recovery.d.ts +190 -0
  37. package/core/dist/runtime-v2/internalization/owner-evidence-recovery.d.ts.map +1 -0
  38. package/core/dist/runtime-v2/internalization/owner-evidence-recovery.js +488 -0
  39. package/core/dist/runtime-v2/internalization/owner-evidence-recovery.js.map +1 -0
  40. package/core/dist/runtime-v2/internalization/owner-retry.d.ts +23 -1
  41. package/core/dist/runtime-v2/internalization/owner-retry.d.ts.map +1 -1
  42. package/core/dist/runtime-v2/internalization/owner-retry.js +19 -3
  43. package/core/dist/runtime-v2/internalization/owner-retry.js.map +1 -1
  44. package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts +8 -0
  45. package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts.map +1 -1
  46. package/core/dist/runtime-v2/internalization/peer-runner-contracts.js.map +1 -1
  47. package/core/dist/runtime-v2/internalization/pitask-metadata.d.ts +12 -0
  48. package/core/dist/runtime-v2/internalization/pitask-metadata.d.ts.map +1 -1
  49. package/core/dist/runtime-v2/internalization/pitask-metadata.js +24 -0
  50. package/core/dist/runtime-v2/internalization/pitask-metadata.js.map +1 -1
  51. package/core/dist/runtime-v2/recovery-actions-log.d.ts +40 -0
  52. package/core/dist/runtime-v2/recovery-actions-log.d.ts.map +1 -1
  53. package/core/dist/runtime-v2/recovery-actions-log.js +77 -2
  54. package/core/dist/runtime-v2/recovery-actions-log.js.map +1 -1
  55. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts +6 -1
  56. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
  57. package/core/dist/runtime-v2/store/runtime-state-manager.js +6 -2
  58. package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
  59. package/core/dist/runtime-v2/store/task/memory-task-store.d.ts +3 -1
  60. package/core/dist/runtime-v2/store/task/memory-task-store.d.ts.map +1 -1
  61. package/core/dist/runtime-v2/store/task/memory-task-store.js +6 -1
  62. package/core/dist/runtime-v2/store/task/memory-task-store.js.map +1 -1
  63. package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts +3 -1
  64. package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts.map +1 -1
  65. package/core/dist/runtime-v2/store/task/sqlite-task-store.js +10 -2
  66. package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
  67. package/core/dist/runtime-v2/store/task/task-store.d.ts +11 -5
  68. package/core/dist/runtime-v2/store/task/task-store.d.ts.map +1 -1
  69. package/core/dist/telemetry-event.d.ts +2 -2
  70. package/core/dist/telemetry-event.d.ts.map +1 -1
  71. package/core/dist/telemetry-event.js +13 -0
  72. package/core/dist/telemetry-event.js.map +1 -1
  73. package/core/package.json +5 -1
  74. package/dist/installers/workbuddy-host-installer.d.ts +16 -3
  75. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  76. package/dist/installers/workbuddy-host-installer.js +57 -10
  77. package/dist/installers/workbuddy-host-installer.js.map +1 -1
  78. package/host-runtime/dist/internalization-consumer-cycle.d.ts +12 -1
  79. package/host-runtime/dist/internalization-consumer-cycle.js +141 -16
  80. package/host-runtime/dist/workspace-telemetry-emitter.js +13 -0
  81. package/host-runtime/package.json +1 -1
  82. package/package.json +2 -2
  83. package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.d.ts +44 -0
  84. package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.d.ts.map +1 -0
  85. package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.js +138 -0
  86. package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.js.map +1 -0
  87. package/pd-cli/dist/commands/runtime-internalization-evidence.d.ts +72 -0
  88. package/pd-cli/dist/commands/runtime-internalization-evidence.d.ts.map +1 -0
  89. package/pd-cli/dist/commands/runtime-internalization-evidence.js +424 -0
  90. package/pd-cli/dist/commands/runtime-internalization-evidence.js.map +1 -0
  91. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  92. package/pd-cli/dist/commands/runtime-internalization-run-once.js +22 -1
  93. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  94. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
  95. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +45 -4
  96. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  97. package/pd-cli/dist/index.js +8 -0
  98. package/pd-cli/dist/index.js.map +1 -1
  99. package/pd-cli/dist/services/artificer-evidence-audit.d.ts +156 -0
  100. package/pd-cli/dist/services/artificer-evidence-audit.d.ts.map +1 -0
  101. package/pd-cli/dist/services/artificer-evidence-audit.js +321 -0
  102. package/pd-cli/dist/services/artificer-evidence-audit.js.map +1 -0
  103. package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
  104. package/pd-cli/dist/services/rulehost-pipeline-runner.js +17 -3
  105. package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
  106. package/pd-cli/package.json +1 -1
  107. package/plugin/dist/bundle.js +491 -491
  108. package/plugin/dist/openclaw.plugin.json +1 -1
  109. package/plugin/dist/rulehost-evidence.js +26 -26
  110. package/plugin/openclaw.plugin.json +1 -1
  111. package/plugin/package.json +1 -1
  112. package/release-manager/dist/installers/workbuddy-host-installer.d.ts +16 -3
  113. package/release-manager/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  114. package/release-manager/dist/installers/workbuddy-host-installer.js +57 -10
  115. package/release-manager/dist/installers/workbuddy-host-installer.js.map +1 -1
  116. package/release-manager/package.json +2 -2
@@ -23,7 +23,7 @@
23
23
  import { createRuntimeStateHandle, InternalizationOrchestrator, DreamerRunner, PhilosopherRunner, ScribeRunner, ArtificerRunner, buildArtificerHostSemanticContext, EvaluatorRunner, RolloutReviewerRunner, DefaultDreamerValidator, DefaultPhilosopherValidator, DefaultScribeValidator, DefaultArtificerValidator, DefaultEvaluatorValidator, DefaultRolloutReviewerValidator, PiAiRuntimeAdapter, L2AgentLoopAdapter, ArtificerL2Adapter, buildL2PrincipleReaderFromLedger, OpenClawCliRuntimeAdapter, storeEmitter, createProductionGateDeps, resolveRuntimeConfigFromPdConfig, resolveRuntimeConfigForAgent, AGENT_NAME_FOR_TASK_KIND, isRuntimeConfigError, computeConsumerDecision, FULL_CHAIN_CONSUMER_RUNNER_KINDS, DEFAULT_CONSUMER_RUNNER_KINDS, InternalizationQueueReadModel, MVP_CORE_TASK_KINDS, SqliteConnection, SqliteReconciliationCursorStore, SUCCEEDED_TRANSITIONS_SCOPE, PrincipleTreeLedgerAdapter,
24
24
  // PRI-714: resolve outputLanguage from the same effective config the
25
25
  // runners already receive (EP-07: canonical resolved value, not raw input).
26
- resolveOutputLanguage, } from '@principles/core/runtime-v2';
26
+ resolveOutputLanguage, hydratePITaskRecord, preflightArtificerOwnerEvidence, } from '@principles/core/runtime-v2';
27
27
  import { loadLedger } from '@principles/core/principle-tree-ledger';
28
28
  import { loadPdConfigForPlugin, loadFeatureFlagFromConfig } from './pd-config.js';
29
29
  import { createEvaluatorRepairDeps, createRolloutGovernanceDeps } from './internalization-consumer-governance.js';
@@ -296,6 +296,22 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
296
296
  // without touching leases, idempotency, dependency order, or the
297
297
  // single-task-per-cycle semantics. Ties keep the original priority order.
298
298
  const orderedRunnerKinds = orderKindsByOldestReadyStage(decision.runnerKinds, snapshot.readyTasks);
299
+ // PRI-634 A3: workspace-scoped telemetry sink. Constructed here (per-wake,
300
+ // workspaceDir in scope) so events from THIS workspace's runners are
301
+ // attributable to THIS workspace — a global subscriber on the storeEmitter
302
+ // singleton cannot (multi-workspace isolation, see
303
+ // workspace-telemetry-emitter.ts). Persist failures degrade through the
304
+ // host's structured event port, never break the runner.
305
+ // PRI-795 review P1: shared by the EvaluatorRunner AND the ArtificerL2
306
+ // adapter so `artificer_l2_complete` evidence (abortOwner/budget/elapsed/
307
+ // stopReason/tokenUsage) persists durably instead of vanishing with the
308
+ // process (the EP002-R3 "nothing recoverable after a failure" class).
309
+ const workspaceEmitter = new WorkspaceTelemetryEmitter(storeEmitter, workspaceDir, (detail) => {
310
+ emitEvent('WORKSPACE_TELEMETRY_PERSIST_FAILED', detail);
311
+ });
312
+ let artificerEvidence = null;
313
+ let authoritativeChannel = null;
314
+ let preflightSkipReason;
299
315
  for (const kind of orderedRunnerKinds) {
300
316
  const agentName = AGENT_NAME_FOR_TASK_KIND[kind];
301
317
  if (agentName === undefined) {
@@ -327,6 +343,109 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
327
343
  }
328
344
  const candidate = await orchestrator.wakeOnce(kind);
329
345
  if (candidate.decision === 'would_lease') {
346
+ // PRI-982 (SPEC-PD-IAER-001 §4.2 / FR-02): authoritative channel routing
347
+ // for artificer tasks. The channel is written deterministically by the
348
+ // intake bridge at seed time (pi_metadata.channel — the SINGLE authority,
349
+ // inherited along the chain) and is read from the leased task's hydrated
350
+ // metadata here; the cycle NEVER guesses it from task names or model text.
351
+ // - code_tool_hook → RuleCode sub-chain: evidence preflight FIRST, then
352
+ // L2 (flag permitting) with the assembled pack injected;
353
+ // - prompt → the legal non-L2 pipeline (PiAi), evidence-exempt
354
+ // (production: 40 successes on that pipeline);
355
+ // - unresolvable → refuse to guess: observable skip, no run (T08).
356
+ const leasedTaskForChannel = await stateManager.getTask(candidate.taskId);
357
+ const leasedPiTask = leasedTaskForChannel ? hydratePITaskRecord(leasedTaskForChannel) : null;
358
+ authoritativeChannel = leasedPiTask?.channel ?? null;
359
+ if (candidate.taskKind === 'artificer') {
360
+ if (authoritativeChannel === null || leasedPiTask === null) {
361
+ // Defensive: wakeOnce never leases non-hydratable tasks, so reaching
362
+ // here means the metadata corrupted between wake and read. Fail closed
363
+ // — never route an artificer task without an authoritative channel.
364
+ const channelInfo = JSON.stringify({
365
+ reason: 'artificer_channel_unresolvable',
366
+ taskId: candidate.taskId,
367
+ nextAction: 'Inspect and repair the task metadata (pi_metadata.channel); the consumer refuses to route an artificer task without an authoritative channel (SPEC-PD-IAER-001 §4.2, T08).',
368
+ });
369
+ emitEvent('INTERNALIZATION_CONSUMER_SKIP', channelInfo);
370
+ logger.warn(`[PD:${logLabel}] Artificer task ${candidate.taskId} skipped: authoritative channel unresolvable.`);
371
+ preflightSkipReason = 'artificer_channel_unresolvable';
372
+ continue;
373
+ }
374
+ if (authoritativeChannel === 'code_tool_hook') {
375
+ // Capability OFF must block generation, not merely select L1.
376
+ if (!loadFeatureFlagFromConfig(workspaceDir, 'code_rule_capability').enabled) {
377
+ emitEvent('INTERNALIZATION_CONSUMER_SKIP', JSON.stringify({
378
+ reason: 'code_rule_capability_disabled',
379
+ taskId: candidate.taskId,
380
+ taskKind: candidate.taskKind,
381
+ nextAction: 'Owner must enable code_rule_capability before Code Rule generation.',
382
+ }));
383
+ logger.warn('[PD:' + logLabel + '] Code Rule task ' + candidate.taskId + ' paused: capability disabled.');
384
+ preflightSkipReason = 'code_rule_capability_disabled';
385
+ continue;
386
+ }
387
+ artificerEvidence = await preflightArtificerOwnerEvidence({
388
+ taskId: candidate.taskId,
389
+ piTask: leasedPiTask,
390
+ owner,
391
+ workspaceDir, // FR-08 run-correlation telemetry (PRI-984)
392
+ stateManager,
393
+ eventEmitter: workspaceEmitter,
394
+ behaviorEvidence: ports.behaviorEvidence,
395
+ });
396
+ if (artificerEvidence.decision === 'evidence_source_unavailable') {
397
+ // SPEC §6.2: a host assembly gap is NOT "Owner has not labeled".
398
+ // The task stays pending (re-observable next cycle, zero model
399
+ // cost); the runner is never constructed evidence-less.
400
+ const gapInfo = JSON.stringify({
401
+ reason: 'evidence_source_unavailable',
402
+ taskId: candidate.taskId,
403
+ taskKind: candidate.taskKind,
404
+ nextAction: 'Host must wire the behaviorEvidence port (BehaviorExamplePackAssembler) into the consumer cycle ports; the task stays pending until then.',
405
+ });
406
+ emitEvent('INTERNALIZATION_CONSUMER_SKIP', gapInfo);
407
+ logger.warn(`[PD:${logLabel}] Artificer task ${candidate.taskId} skipped: evidence source unavailable (host must wire the behaviorEvidence port).`);
408
+ preflightSkipReason = 'evidence_source_unavailable';
409
+ continue;
410
+ }
411
+ if (artificerEvidence.decision === 'evidence_source_error') {
412
+ // PRI-980 review P2-1 — SPEC §6.2 case 3: a trajectory-store I/O
413
+ // fault is preserved AS a storage fault. Same family as the absent
414
+ // port: the task stays wake-eligible (the next cycle retries the
415
+ // assembly at zero model cost), the runner is never constructed,
416
+ // and the preflight already emitted the structured degradation
417
+ // telemetry (reason=evidence_source_error, reviewPersisted=false).
418
+ const storageInfo = JSON.stringify({
419
+ reason: 'evidence_source_error',
420
+ taskId: candidate.taskId,
421
+ taskKind: candidate.taskKind,
422
+ nextAction: artificerEvidence.nextAction,
423
+ ...(artificerEvidence.detail !== undefined ? { detail: artificerEvidence.detail } : {}),
424
+ });
425
+ emitEvent('INTERNALIZATION_CONSUMER_SKIP', storageInfo);
426
+ logger.warn(`[PD:${logLabel}] Artificer task ${candidate.taskId} skipped: evidence source error (storage fault preserved; task stays wake-eligible).`);
427
+ preflightSkipReason = 'evidence_source_error';
428
+ continue;
429
+ }
430
+ if (artificerEvidence.decision === 'blocked') {
431
+ // FR-04: the preflight already moved the task atomically into
432
+ // needs_human_review — outside the wake scan (pending/retry_wait
433
+ // only), so it is never auto-rewoken (FR-05/T02). reviewPersisted
434
+ // = false means a concurrent writer won the CAS; still no run.
435
+ emitEvent('INTERNALIZATION_CONSUMER_EVIDENCE_BLOCKED', JSON.stringify({
436
+ taskId: candidate.taskId,
437
+ reasonCode: artificerEvidence.reasonCode,
438
+ nextAction: artificerEvidence.nextAction,
439
+ ...(artificerEvidence.missingFields !== undefined ? { missingFields: [...artificerEvidence.missingFields] } : {}),
440
+ ...(artificerEvidence.detail !== undefined ? { detail: artificerEvidence.detail } : {}),
441
+ reviewPersisted: artificerEvidence.reviewPersisted,
442
+ }));
443
+ logger.warn(`[PD:${logLabel}] Artificer task ${candidate.taskId} blocked on Owner evidence (${artificerEvidence.reasonCode}, reviewPersisted=${artificerEvidence.reviewPersisted}).`);
444
+ preflightSkipReason = 'artificer_blocked_on_owner_evidence';
445
+ continue;
446
+ }
447
+ }
448
+ }
330
449
  wakeResult = candidate;
331
450
  taskRuntimeConfig = kindRuntime;
332
451
  break;
@@ -337,6 +456,10 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
337
456
  lastSkipReason = candidate.decision === 'no_ready_tasks' ? candidate.reason : undefined;
338
457
  }
339
458
  if (!wakeResult || taskRuntimeConfig === null) {
459
+ if (preflightSkipReason !== undefined) {
460
+ lastSkipDecision = preflightSkipReason;
461
+ lastSkipReason = undefined;
462
+ }
340
463
  // A: 预算由周期 finally 统一执行 (每周期恰一次,含 backlog 场景)
341
464
  const skipPayload = { decision: lastSkipDecision };
342
465
  if (lastSkipReason) {
@@ -349,19 +472,6 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
349
472
  // PRI-719: everything downstream reads the LEASED TASK's resolved config —
350
473
  // the kind-specific profile, not the shared gate resolution.
351
474
  const taskRuntimeKind = taskRuntimeConfig.runtimeKind;
352
- // PRI-634 A3: workspace-scoped telemetry sink. Constructed here (per-wake,
353
- // workspaceDir in scope) so events from THIS workspace's runners are
354
- // attributable to THIS workspace — a global subscriber on the storeEmitter
355
- // singleton cannot (multi-workspace isolation, see
356
- // workspace-telemetry-emitter.ts). Persist failures degrade through the
357
- // host's structured event port, never break the runner.
358
- // PRI-795 review P1: shared by the EvaluatorRunner AND the ArtificerL2
359
- // adapter so `artificer_l2_complete` evidence (abortOwner/budget/elapsed/
360
- // stopReason/tokenUsage) persists durably instead of vanishing with the
361
- // process (the EP002-R3 "nothing recoverable after a failure" class).
362
- const workspaceEmitter = new WorkspaceTelemetryEmitter(storeEmitter, workspaceDir, (detail) => {
363
- emitEvent('WORKSPACE_TELEMETRY_PERSIST_FAILED', detail);
364
- });
365
475
  let adapter;
366
476
  if (taskRuntimeKind === 'pi-ai') {
367
477
  // PRI-419: when l2_dreamer flag is on AND this is a dreamer task, route
@@ -372,9 +482,15 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
372
482
  // so the model can self-iterate before submitting. Honors the
373
483
  // code_rule_capability emergency-disable flag (PR #1661 CodeRabbit P1).
374
484
  const codeRuleFlag = loadFeatureFlagFromConfig(workspaceDir, 'code_rule_capability');
485
+ // PRI-982 (SPEC-PD-IAER-001 §4.2): the authoritative TARGET CHANNEL is
486
+ // part of the L2 selection — `pi_metadata.channel === 'code_tool_hook'`
487
+ // (the seed-time bridge authority). prompt-channel artificer tasks are
488
+ // misroutes on L2 (production: 54 failures) and keep the legal non-L2
489
+ // PiAi pipeline below; unresolvable channels never enter L2.
375
490
  if (wakeResult.taskKind === 'artificer'
376
491
  && taskRuntimeKind === 'pi-ai'
377
- && codeRuleFlag.enabled) {
492
+ && codeRuleFlag.enabled
493
+ && authoritativeChannel === 'code_tool_hook') {
378
494
  adapter = new ArtificerL2Adapter({
379
495
  // Profile readiness check guarantees these are non-undefined for
380
496
  // pi-ai runtime kind (validatePdLocalProfile enforces provider/model/apiKeyEnv).
@@ -518,7 +634,16 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
518
634
  }, runnerOptions);
519
635
  break;
520
636
  case 'artificer':
521
- runner = new ArtificerRunner({ stateManager, runtimeAdapter: adapter, eventEmitter: storeEmitter, artifactStore: stateManager.piArtifactStore, validator: new DefaultArtificerValidator() },
637
+ runner = new ArtificerRunner({
638
+ stateManager, runtimeAdapter: adapter, eventEmitter: storeEmitter, artifactStore: stateManager.piArtifactStore, validator: new DefaultArtificerValidator(),
639
+ // PRI-982 (SPEC-PD-IAER-001 FR-02): the preflight-assembled Owner
640
+ // evidence pack — present only when the authoritative channel is
641
+ // code_tool_hook AND the readiness gate returned ready (same
642
+ // ArtificerRunnerDeps shape as the run-rulehost CLI pipeline).
643
+ ...(artificerEvidence !== null && artificerEvidence.decision === 'ready'
644
+ ? { behaviorExamplePack: artificerEvidence.pack }
645
+ : {}),
646
+ },
522
647
  // PRI-741: thread the host semantic projection into generation.
523
648
  { ...runnerOptions, ...(artificerHostSemanticContext !== undefined ? { hostSemanticContext: artificerHostSemanticContext } : {}) });
524
649
  break;
@@ -25,6 +25,14 @@ import { StoreEventEmitter } from '@principles/core/runtime-v2';
25
25
  * - artificer_l2_complete(PRI-795 review P1:Artificer L2 的 completion
26
26
  * 证据 — abortOwner/budgetMs/elapsedMs/stopReason/tokenUsage — 必须
27
27
  * crash 前落盘,否则 EP002-R3 的「失败后什么都查不到」重演)
28
+ * - artificer_blocked_on_owner_evidence(PRI-982 / SPEC-PD-IAER-001
29
+ * FR-04:consumer evidence preflight 把任务原子转入 needs_human_review
30
+ * 时的 Owner 恢复证据 — 稳定 reasonCode + nextAction + reviewPersisted。
31
+ * 与 artificer_l2_complete 同理必须 crash 前落盘:进程内 storeEmitter
32
+ * 生产装配零订阅者,事件丢失会让 NHR 任务变成「为什么被挡」的无头案
33
+ * (EP002-R3 类)。注意 readiness_checked 刻意不入列:它对每个 gate
34
+ * verdict 都发(含 ready),落盘会形成高频第二日志;blocked 才是
35
+ * Owner 必须能事后取证的判定点)
28
36
  * - reuse_gate_triggered(PRI-939 Option A:Reuse Review Gate 挂起观察,
29
37
  * Owner 复用闭环的入口证据)
30
38
  * - reuse_evaluation_unavailable(PRI-939 Option A:语义评估降级信号 —
@@ -44,6 +52,11 @@ const CRITICAL_EVENT_ALLOWLIST = new Set([
44
52
  'evaluator_rule_assembled',
45
53
  'evaluator_rule_assembly_failed',
46
54
  'artificer_l2_complete',
55
+ // PRI-982 (SPEC-PD-IAER-001 FR-04): Owner-recovery evidence for a task the
56
+ // consumer evidence preflight just blocked into needs_human_review — stable
57
+ // reasonCode + nextAction must survive a crash (same EP002-R3 class as
58
+ // artificer_l2_complete above; justification in the header comment).
59
+ 'artificer_blocked_on_owner_evidence',
47
60
  'reuse_gate_triggered',
48
61
  'reuse_evaluation_unavailable',
49
62
  ]);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.145.1",
3
+ "version": "1.145.3",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -89,6 +89,6 @@
89
89
  "directory": "packages/create-principles-disciple"
90
90
  },
91
91
  "pd": {
92
- "bundledPluginVersion": "2.1.4"
92
+ "bundledPluginVersion": "2.1.5"
93
93
  }
94
94
  }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * pd runtime internalization audit-artificer-evidence — read-only history audit
3
+ * (SPEC-PD-IAER-001 FR-09, T11, AC-10; PRI-985).
4
+ *
5
+ * Scans the workspace runtime state DB for runs that failed with the
6
+ * `behavior_example_pack_missing` signature (runtime kinds `pi-ai-l2` AND
7
+ * `pi-ai`), aggregates them BY TASK ID (production evidence: ~385 runs across
8
+ * ~82 tasks — runs are not tasks), and reports four anomaly markers per task
9
+ * plus a summary. This command is read-only BY CONSTRUCTION:
10
+ *
11
+ * - the DB is opened with `readonly: true, bootstrapIfMissing: false`
12
+ * (ERR-023 precedent from runtime-artifact-repair.ts) — a missing state.db
13
+ * is a structured refusal, never a fresh workspace;
14
+ * - no --confirm exists and no write path exists in this file (cli-4 moot:
15
+ * there is nothing to confirm; cli-5: failure paths mutate nothing);
16
+ * - no recovery/reschedule is performed here (that is the FR-09 B-side,
17
+ * handled by the existing retry / failed-tasks recovery entries).
18
+ *
19
+ * CLI contract (EP-04): `--json` prints exactly one parseable JSON object on
20
+ * stdout (cli-1); no matching data is a structured EMPTY result with a
21
+ * nextAction, not an error; a missing/unreadable DB or missing tables is a
22
+ * structured refusal with exit code 1 (cli-2/cli-6).
23
+ */
24
+ import type { Command } from 'commander';
25
+ import { type ArtificerEvidenceAuditReport } from '../services/artificer-evidence-audit.js';
26
+ export interface AuditArtificerEvidenceOptions {
27
+ workspace?: string;
28
+ json?: boolean;
29
+ }
30
+ export interface AuditArtificerEvidenceOutput {
31
+ ok: boolean;
32
+ mode: 'read_only_audit';
33
+ workspace: string;
34
+ status: 'complete' | 'empty' | 'failed';
35
+ summary?: ArtificerEvidenceAuditReport['summary'];
36
+ tasks?: ArtificerEvidenceAuditReport['tasks'];
37
+ governanceDetection?: string;
38
+ reason?: string;
39
+ nextAction?: string;
40
+ }
41
+ export declare function handleRuntimeInternalizationAuditArtificerEvidence(opts: AuditArtificerEvidenceOptions): Promise<void>;
42
+ /** Register the production `pd runtime internalization audit-artificer-evidence` command. */
43
+ export declare function registerRuntimeInternalizationAuditArtificerEvidenceCommand(internalizationCmd: Command, handler?: (opts: AuditArtificerEvidenceOptions) => Promise<void>): Command;
44
+ //# sourceMappingURL=runtime-internalization-audit-artificer-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-internalization-audit-artificer-evidence.d.ts","sourceRoot":"","sources":["../../src/commands/runtime-internalization-audit-artificer-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAGL,KAAK,4BAA4B,EAClC,MAAM,yCAAyC,CAAC;AAEjD,MAAM,WAAW,6BAA6B;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,iBAAiB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IACxC,OAAO,CAAC,EAAE,4BAA4B,CAAC,SAAS,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAC9C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA6CD,wBAAsB,kDAAkD,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAwD3H;AAED,6FAA6F;AAC7F,wBAAgB,2DAA2D,CACzE,kBAAkB,EAAE,OAAO,EAC3B,OAAO,GAAE,CAAC,IAAI,EAAE,6BAA6B,KAAK,OAAO,CAAC,IAAI,CAAsD,GACnH,OAAO,CAST"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * pd runtime internalization audit-artificer-evidence — read-only history audit
3
+ * (SPEC-PD-IAER-001 FR-09, T11, AC-10; PRI-985).
4
+ *
5
+ * Scans the workspace runtime state DB for runs that failed with the
6
+ * `behavior_example_pack_missing` signature (runtime kinds `pi-ai-l2` AND
7
+ * `pi-ai`), aggregates them BY TASK ID (production evidence: ~385 runs across
8
+ * ~82 tasks — runs are not tasks), and reports four anomaly markers per task
9
+ * plus a summary. This command is read-only BY CONSTRUCTION:
10
+ *
11
+ * - the DB is opened with `readonly: true, bootstrapIfMissing: false`
12
+ * (ERR-023 precedent from runtime-artifact-repair.ts) — a missing state.db
13
+ * is a structured refusal, never a fresh workspace;
14
+ * - no --confirm exists and no write path exists in this file (cli-4 moot:
15
+ * there is nothing to confirm; cli-5: failure paths mutate nothing);
16
+ * - no recovery/reschedule is performed here (that is the FR-09 B-side,
17
+ * handled by the existing retry / failed-tasks recovery entries).
18
+ *
19
+ * CLI contract (EP-04): `--json` prints exactly one parseable JSON object on
20
+ * stdout (cli-1); no matching data is a structured EMPTY result with a
21
+ * nextAction, not an error; a missing/unreadable DB or missing tables is a
22
+ * structured refusal with exit code 1 (cli-2/cli-6).
23
+ */
24
+ import * as path from 'path';
25
+ import { SqliteConnection } from '@principles/core/runtime-v2';
26
+ import { resolveWorkspaceDir } from '../resolve-workspace.js';
27
+ import { aggregateArtificerEvidenceRuns, loadArtificerEvidenceAuditInputs, } from '../services/artificer-evidence-audit.js';
28
+ function emit(out, json) {
29
+ if (json) {
30
+ // cli-1-strict-json: exactly one parseable JSON object on stdout.
31
+ console.log(JSON.stringify(out, null, 2));
32
+ return;
33
+ }
34
+ console.log(`Artificer Evidence Audit (${out.mode}) — ${out.workspace}`);
35
+ if (out.status === 'failed') {
36
+ console.log(` status: failed`);
37
+ console.log(` reason: ${out.reason ?? 'unknown'}`);
38
+ console.log(` nextAction: ${out.nextAction ?? ''}`);
39
+ return;
40
+ }
41
+ const s = out.summary;
42
+ console.log(` status: ${out.status}`);
43
+ console.log(` pack-missing runs: ${s?.totalRuns ?? 0}`);
44
+ console.log(` distinct tasks: ${s?.distinctTasks ?? 0}`);
45
+ console.log(` by runtime kind: ${Object.entries(s?.byRuntimeKind ?? {}).map(([k, v]) => `${k}=${v}`).join(', ') || '-'}`);
46
+ console.log(` by final status: ${Object.entries(s?.byFinalTaskStatus ?? {}).map(([k, v]) => `${k}=${v}`).join(', ') || '-'}`);
47
+ console.log(` anomalies: repeatedRetry=${s?.anomalyCounts.repeatedRetryConsumption ?? 0}, succeededArtifactThenFailed=${s?.anomalyCounts.succeededArtifactThenFailed ?? 0}, governanceSideEffects=${s?.anomalyCounts.hasGovernanceSideEffects ?? 0} (detection: ${out.governanceDetection ?? 'unknown'})`);
48
+ console.log(` nextAction: ${out.nextAction ?? ''}`);
49
+ const tasks = out.tasks ?? [];
50
+ if (tasks.length > 0) {
51
+ console.log('');
52
+ console.log('Tasks (oldest first):');
53
+ for (const t of tasks) {
54
+ console.log(` - ${t.taskId}`);
55
+ console.log(` taskKind: ${t.taskKind ?? '-'}`);
56
+ console.log(` status: ${t.taskStatus ?? 'unknown (no task row)'}${t.attemptCount !== null ? ` (${t.attemptCount}/${t.maxAttempts} attempts)` : ''}`);
57
+ console.log(` runs: ${t.runCount}${Object.keys(t.failureCategories).length > 0 ? ` [${Object.entries(t.failureCategories).map(([k, v]) => `${k}=${v}`).join(', ')}]` : ''}`);
58
+ console.log(` window: ${t.firstFailureAt} .. ${t.lastFailureAt}`);
59
+ const flags = [
60
+ t.anomalies.repeatedRetryConsumption ? 'repeated_retry_consumption' : null,
61
+ t.anomalies.succeededArtifactThenFailed ? 'succeeded_artifact_then_failed' : null,
62
+ t.anomalies.hasGovernanceSideEffects ? 'has_governance_side_effects' : null,
63
+ t.anomalies.packMissingFailure ? 'pack_missing_failure' : null,
64
+ ].filter((f) => f !== null);
65
+ console.log(` anomalies: ${flags.length > 0 ? flags.join(', ') : '(none)'}`);
66
+ console.log(` nextAction: ${t.nextAction}`);
67
+ }
68
+ }
69
+ }
70
+ export async function handleRuntimeInternalizationAuditArtificerEvidence(opts) {
71
+ // Resolution runs inside the try so an unresolvable default workspace is
72
+ // also a structured refusal (cli-6); if resolution itself fails, the
73
+ // refusal reports the raw --workspace value, when one was given.
74
+ let resolvedWorkspace = null;
75
+ let conn = null;
76
+ try {
77
+ const workspaceDir = path.resolve(resolveWorkspaceDir(opts.workspace));
78
+ resolvedWorkspace = workspaceDir;
79
+ // ERR-023 precedent: read-only audit opens the DB readonly and must not
80
+ // bootstrap an empty state.db — a missing state.db is a refusal.
81
+ conn = new SqliteConnection({ workspaceDir, readonly: true, bootstrapIfMissing: false });
82
+ const db = conn.getDb();
83
+ const inputs = loadArtificerEvidenceAuditInputs(db);
84
+ const report = aggregateArtificerEvidenceRuns(inputs);
85
+ const empty = report.summary.distinctTasks === 0;
86
+ const out = {
87
+ ok: true,
88
+ mode: 'read_only_audit',
89
+ workspace: workspaceDir,
90
+ status: empty ? 'empty' : 'complete',
91
+ summary: report.summary,
92
+ tasks: report.tasks,
93
+ governanceDetection: report.governanceDetection,
94
+ reason: empty
95
+ ? 'No runs match the behavior_example_pack_missing signature for runtime kinds pi-ai-l2/pi-ai'
96
+ : undefined,
97
+ nextAction: empty
98
+ ? 'Nothing to audit. If a failure is expected, verify the workspace path: this audit scans <workspace>/.pd/state.db'
99
+ : report.summary.anomalyCounts.packMissingFailure > 0
100
+ ? 'Read-only result — nothing was modified. Recovery is per-task and Owner-driven: attach evidence via the recovery entry (PRI-983), then use the per-task nextAction (pd runtime internalization retry --confirm for needs_human_review, pd runtime recovery failed-tasks --confirm for failed).'
101
+ : 'Read-only result — nothing was modified.',
102
+ };
103
+ emit(out, opts.json);
104
+ }
105
+ catch (err) {
106
+ // Structured refusal (cli-6): reason + nextAction, exit 1, no repair attempts.
107
+ const out = {
108
+ ok: false,
109
+ mode: 'read_only_audit',
110
+ workspace: resolvedWorkspace ?? opts.workspace ?? '(workspace unresolved)',
111
+ status: 'failed',
112
+ reason: err instanceof Error ? err.message : String(err),
113
+ nextAction: 'Verify --workspace points at a workspace with an initialized .pd/state.db (pd runtime init), then retry. This audit does not create or repair databases.',
114
+ };
115
+ emit(out, opts.json);
116
+ process.exitCode = 1;
117
+ }
118
+ finally {
119
+ try {
120
+ conn?.close();
121
+ }
122
+ catch {
123
+ // best-effort close of a read-only handle; the report is already emitted
124
+ }
125
+ }
126
+ }
127
+ /** Register the production `pd runtime internalization audit-artificer-evidence` command. */
128
+ export function registerRuntimeInternalizationAuditArtificerEvidenceCommand(internalizationCmd, handler = handleRuntimeInternalizationAuditArtificerEvidence) {
129
+ return internalizationCmd
130
+ .command('audit-artificer-evidence')
131
+ .description('Read-only history audit: aggregate behavior_example_pack_missing failures by task (FR-09)')
132
+ .option('-w, --workspace <path>', 'Workspace directory')
133
+ .option('--json', 'Output as JSON')
134
+ .action(async (opts) => {
135
+ await handler(opts);
136
+ });
137
+ }
138
+ //# sourceMappingURL=runtime-internalization-audit-artificer-evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-internalization-audit-artificer-evidence.js","sourceRoot":"","sources":["../../src/commands/runtime-internalization-audit-artificer-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,GAEjC,MAAM,yCAAyC,CAAC;AAmBjD,SAAS,IAAI,CAAC,GAAiC,EAAE,IAAc;IAC7D,IAAI,IAAI,EAAE,CAAC;QACT,kEAAkE;QAClE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,6BAA6B,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;IACzE,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC,CAAC;QACrD,OAAO;IACT,CAAC;IACD,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;IACt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AyE;QAC3E,CAAC;IACH,CAAC;AACH,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,2DAA2D,CACzE,kBAA2B,EAC3B,OAAO,GAA2D,kDAAkD;IAEpH,OAAO,kBAAkB;SACtB,OAAO,CAAC,0BAA0B,CAAC;SACnC,WAAW,CAAC,2FAA2F,CAAC;SACxG,MAAM,CAAC,wBAAwB,EAAE,qBAAqB,CAAC;SACvD,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,KAAK,EAAE,IAAmC,EAAE,EAAE;QACpD,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * pd runtime internalization evidence — Owner evidence attach/resume (B1).
3
+ *
4
+ * SPEC-PD-IAER-001 FR-03/FR-06 (PRI-983): the Owner recovery entry for
5
+ * Artificer tasks blocked on evidence (needs_human_review + a stable FR-04
6
+ * evidence reasonCode). Three subcommands, ALL default dry-run; `--confirm`
7
+ * performs the mutation (cli-4):
8
+ *
9
+ * evidence list --workspace <dir> [--json]
10
+ * Read-only: tasks waiting for Owner evidence with pain linkage,
11
+ * missing fields and the concrete next action (FR-06 1/2).
12
+ *
13
+ * evidence attach --task <id> --pain <painId> --negative <id>
14
+ * --positive <id>... --outcome <text>
15
+ * [--decidedBy <label>] [--json] [--confirm]
16
+ * Assembles the labelled examples through the production assembler
17
+ * (same chain as run-rulehost), and on --confirm persists the
18
+ * digest-verified selection into pi_metadata via CAS. The task STAYS
19
+ * needs_human_review — attach never unblocks (FR-06 6).
20
+ *
21
+ * evidence resume --task <id> [--decidedBy <label>] [--json] [--confirm]
22
+ * Re-assembles, verifies the stored contentDigest, and on --confirm
23
+ * performs the ATOMIC authority reset through the single recovery
24
+ * authority (ownerRetryNeedsHumanReviewTask, CAS precondition) — at
25
+ * most one concurrent resume wins (FR-06 7, §6.3, T06).
26
+ *
27
+ * Authorization expression (repo reality — no owner authentication exists):
28
+ * explicit --confirm + decidedBy label + append-only audit
29
+ * (.state/recovery_actions.jsonl) + revision/contentDigest provenance.
30
+ *
31
+ * CLI contract: --json prints exactly ONE parseable JSON object (cli-1);
32
+ * refusal paths set exit 1 with stable reason + nextAction and mutate
33
+ * nothing (cli-2/cli-5/cli-6). No V1 fallback exists on any path (PRI-780).
34
+ * No new feature flag: rollback = git revert (mvp-q-3).
35
+ *
36
+ * Lazy plugin import: `principles-disciple/rulehost-evidence` is loaded only
37
+ * when an attach/resume actually needs assembly — same rationale as
38
+ * run-rulehost (pd --version must not pull the plugin bundle).
39
+ */
40
+ import type { Command } from 'commander';
41
+ export interface EvidenceListOptions {
42
+ workspace?: string;
43
+ json?: boolean;
44
+ }
45
+ export declare function handleRuntimeInternalizationEvidenceList(opts: EvidenceListOptions): Promise<void>;
46
+ export interface EvidenceAttachOptions {
47
+ workspace?: string;
48
+ task?: string;
49
+ pain?: string;
50
+ negative?: number;
51
+ positive?: string[];
52
+ outcome?: string;
53
+ decidedBy?: string;
54
+ json?: boolean;
55
+ confirm?: boolean;
56
+ }
57
+ export declare function handleRuntimeInternalizationEvidenceAttach(opts: EvidenceAttachOptions): Promise<void>;
58
+ export interface EvidenceResumeOptions {
59
+ workspace?: string;
60
+ task?: string;
61
+ decidedBy?: string;
62
+ json?: boolean;
63
+ confirm?: boolean;
64
+ }
65
+ export declare function handleRuntimeInternalizationEvidenceResume(opts: EvidenceResumeOptions): Promise<void>;
66
+ /** Register `pd runtime internalization evidence list|attach|resume`. */
67
+ export declare function registerRuntimeInternalizationEvidenceCommand(internalizationCmd: Command, handlers?: {
68
+ list?: typeof handleRuntimeInternalizationEvidenceList;
69
+ attach?: typeof handleRuntimeInternalizationEvidenceAttach;
70
+ resume?: typeof handleRuntimeInternalizationEvidenceResume;
71
+ }): Command;
72
+ //# sourceMappingURL=runtime-internalization-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-internalization-evidence.d.ts","source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