create-principles-disciple 1.145.1 → 1.145.4

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 (173) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/codex-adapter/dist/worker/workspace-worker.js +2 -1
  3. package/codex-adapter/package.json +1 -1
  4. package/console/dist/server/config/pd-config-store.js +3 -0
  5. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +4 -4
  6. package/console/dist/ui/i18n/en.json +17 -16
  7. package/console/dist/ui/i18n/zh-CN.json +17 -16
  8. package/console/dist/ui/pages/focus/FocusPage.js +9 -5
  9. package/console/dist/ui/pages/focus/OwnerDecisionCard.js +1 -1
  10. package/console/dist/ui/pages/principles/PrincipleDetailPage.js +10 -4
  11. package/console/dist/ui/pages/principles/PrinciplesPage.js +1 -1
  12. package/console/dist/ui/utils/reading-layout.d.ts +19 -0
  13. package/console/dist/ui/utils/reading-layout.js +46 -0
  14. package/console/dist/web/assets/app.js +30 -28
  15. package/core/dist/runtime-v2/index.d.ts +13 -3
  16. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  17. package/core/dist/runtime-v2/index.js +6 -1
  18. package/core/dist/runtime-v2/index.js.map +1 -1
  19. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +25 -6
  20. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
  21. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +21 -7
  22. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
  23. package/core/dist/runtime-v2/internalization/artificer-run-correlation.d.ts +82 -0
  24. package/core/dist/runtime-v2/internalization/artificer-run-correlation.d.ts.map +1 -0
  25. package/core/dist/runtime-v2/internalization/artificer-run-correlation.js +79 -0
  26. package/core/dist/runtime-v2/internalization/artificer-run-correlation.js.map +1 -0
  27. package/core/dist/runtime-v2/internalization/artificer-runner.d.ts +16 -2
  28. package/core/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  29. package/core/dist/runtime-v2/internalization/artificer-runner.js +89 -9
  30. package/core/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  31. package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.d.ts +141 -0
  32. package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.d.ts.map +1 -0
  33. package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.js +284 -0
  34. package/core/dist/runtime-v2/internalization/consumer-evidence-preflight.js.map +1 -0
  35. package/core/dist/runtime-v2/internalization/evidence-readiness.d.ts +170 -0
  36. package/core/dist/runtime-v2/internalization/evidence-readiness.d.ts.map +1 -0
  37. package/core/dist/runtime-v2/internalization/evidence-readiness.js +335 -0
  38. package/core/dist/runtime-v2/internalization/evidence-readiness.js.map +1 -0
  39. package/core/dist/runtime-v2/internalization/owner-evidence-recovery.d.ts +190 -0
  40. package/core/dist/runtime-v2/internalization/owner-evidence-recovery.d.ts.map +1 -0
  41. package/core/dist/runtime-v2/internalization/owner-evidence-recovery.js +488 -0
  42. package/core/dist/runtime-v2/internalization/owner-evidence-recovery.js.map +1 -0
  43. package/core/dist/runtime-v2/internalization/owner-retry.d.ts +23 -1
  44. package/core/dist/runtime-v2/internalization/owner-retry.d.ts.map +1 -1
  45. package/core/dist/runtime-v2/internalization/owner-retry.js +19 -3
  46. package/core/dist/runtime-v2/internalization/owner-retry.js.map +1 -1
  47. package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts +16 -1
  48. package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts.map +1 -1
  49. package/core/dist/runtime-v2/internalization/peer-runner-contracts.js.map +1 -1
  50. package/core/dist/runtime-v2/internalization/pitask-metadata.d.ts +44 -0
  51. package/core/dist/runtime-v2/internalization/pitask-metadata.d.ts.map +1 -1
  52. package/core/dist/runtime-v2/internalization/pitask-metadata.js +75 -0
  53. package/core/dist/runtime-v2/internalization/pitask-metadata.js.map +1 -1
  54. package/core/dist/runtime-v2/recovery-actions-log.d.ts +55 -0
  55. package/core/dist/runtime-v2/recovery-actions-log.d.ts.map +1 -1
  56. package/core/dist/runtime-v2/recovery-actions-log.js +84 -3
  57. package/core/dist/runtime-v2/recovery-actions-log.js.map +1 -1
  58. package/core/dist/runtime-v2/recovery-sweep-service.d.ts +116 -1
  59. package/core/dist/runtime-v2/recovery-sweep-service.d.ts.map +1 -1
  60. package/core/dist/runtime-v2/recovery-sweep-service.js +252 -13
  61. package/core/dist/runtime-v2/recovery-sweep-service.js.map +1 -1
  62. package/core/dist/runtime-v2/runtime-state-handle.d.ts +8 -0
  63. package/core/dist/runtime-v2/runtime-state-handle.d.ts.map +1 -1
  64. package/core/dist/runtime-v2/runtime-state-handle.js +1 -0
  65. package/core/dist/runtime-v2/runtime-state-handle.js.map +1 -1
  66. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts +16 -1
  67. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
  68. package/core/dist/runtime-v2/store/runtime-state-manager.js +7 -2
  69. package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
  70. package/core/dist/runtime-v2/store/task/memory-task-store.d.ts +7 -1
  71. package/core/dist/runtime-v2/store/task/memory-task-store.d.ts.map +1 -1
  72. package/core/dist/runtime-v2/store/task/memory-task-store.js +16 -1
  73. package/core/dist/runtime-v2/store/task/memory-task-store.js.map +1 -1
  74. package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts +7 -1
  75. package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts.map +1 -1
  76. package/core/dist/runtime-v2/store/task/sqlite-task-store.js +31 -2
  77. package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
  78. package/core/dist/runtime-v2/store/task/task-store.d.ts +19 -5
  79. package/core/dist/runtime-v2/store/task/task-store.d.ts.map +1 -1
  80. package/core/dist/telemetry-event.d.ts +2 -2
  81. package/core/dist/telemetry-event.d.ts.map +1 -1
  82. package/core/dist/telemetry-event.js +13 -0
  83. package/core/dist/telemetry-event.js.map +1 -1
  84. package/core/package.json +5 -1
  85. package/dist/installer.d.ts +1 -1
  86. package/dist/installer.d.ts.map +1 -1
  87. package/dist/installer.js +5 -1
  88. package/dist/installer.js.map +1 -1
  89. package/dist/installers/workbuddy-host-installer.d.ts +16 -3
  90. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  91. package/dist/installers/workbuddy-host-installer.js +62 -11
  92. package/dist/installers/workbuddy-host-installer.js.map +1 -1
  93. package/dist/manifest-host-union.d.ts +23 -0
  94. package/dist/manifest-host-union.d.ts.map +1 -0
  95. package/dist/manifest-host-union.js +22 -0
  96. package/dist/manifest-host-union.js.map +1 -0
  97. package/dist/uninstaller.d.ts +2 -1
  98. package/dist/uninstaller.d.ts.map +1 -1
  99. package/dist/uninstaller.js +7 -1
  100. package/dist/uninstaller.js.map +1 -1
  101. package/host-runtime/dist/behavior-example-pack-assembler.d.ts +41 -0
  102. package/host-runtime/dist/behavior-example-pack-assembler.js +243 -0
  103. package/host-runtime/dist/behavior-history.d.ts +6 -0
  104. package/host-runtime/dist/behavior-history.js +76 -0
  105. package/host-runtime/dist/index.d.ts +3 -0
  106. package/host-runtime/dist/index.js +3 -0
  107. package/host-runtime/dist/internalization-consumer-cycle.d.ts +12 -1
  108. package/host-runtime/dist/internalization-consumer-cycle.js +141 -16
  109. package/host-runtime/dist/workspace-behavior-evidence.d.ts +3 -0
  110. package/host-runtime/dist/workspace-behavior-evidence.js +74 -0
  111. package/host-runtime/dist/workspace-telemetry-emitter.js +13 -0
  112. package/host-runtime/package.json +10 -2
  113. package/install-layout/dist/index.d.ts +40 -1
  114. package/install-layout/dist/index.js +88 -6
  115. package/install-layout/package.json +1 -1
  116. package/package.json +3 -3
  117. package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.d.ts +44 -0
  118. package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.d.ts.map +1 -0
  119. package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.js +138 -0
  120. package/pd-cli/dist/commands/runtime-internalization-audit-artificer-evidence.js.map +1 -0
  121. package/pd-cli/dist/commands/runtime-internalization-evidence.d.ts +71 -0
  122. package/pd-cli/dist/commands/runtime-internalization-evidence.d.ts.map +1 -0
  123. package/pd-cli/dist/commands/runtime-internalization-evidence.js +405 -0
  124. package/pd-cli/dist/commands/runtime-internalization-evidence.js.map +1 -0
  125. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  126. package/pd-cli/dist/commands/runtime-internalization-run-once.js +22 -1
  127. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  128. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
  129. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +45 -4
  130. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  131. package/pd-cli/dist/commands/runtime-recovery-failed-task.d.ts +22 -0
  132. package/pd-cli/dist/commands/runtime-recovery-failed-task.d.ts.map +1 -0
  133. package/pd-cli/dist/commands/runtime-recovery-failed-task.js +470 -0
  134. package/pd-cli/dist/commands/runtime-recovery-failed-task.js.map +1 -0
  135. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts +24 -0
  136. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts.map +1 -1
  137. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js +4 -1
  138. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js.map +1 -1
  139. package/pd-cli/dist/index.js +13 -0
  140. package/pd-cli/dist/index.js.map +1 -1
  141. package/pd-cli/dist/services/artificer-evidence-audit.d.ts +156 -0
  142. package/pd-cli/dist/services/artificer-evidence-audit.d.ts.map +1 -0
  143. package/pd-cli/dist/services/artificer-evidence-audit.js +321 -0
  144. package/pd-cli/dist/services/artificer-evidence-audit.js.map +1 -0
  145. package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
  146. package/pd-cli/dist/services/rulehost-pipeline-runner.js +17 -3
  147. package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
  148. package/pd-cli/package.json +1 -1
  149. package/plugin/dist/bundle.js +545 -541
  150. package/plugin/dist/core/behavior-example-pack-assembler.d.ts +4 -32
  151. package/plugin/dist/core/rule-context-assembler.d.ts +0 -9
  152. package/plugin/dist/openclaw.plugin.json +1 -1
  153. package/plugin/dist/rulehost-evidence.js +27 -27
  154. package/plugin/openclaw.plugin.json +1 -1
  155. package/plugin/package.json +1 -1
  156. package/release-manager/dist/installer.d.ts +1 -1
  157. package/release-manager/dist/installer.d.ts.map +1 -1
  158. package/release-manager/dist/installer.js +5 -1
  159. package/release-manager/dist/installer.js.map +1 -1
  160. package/release-manager/dist/installers/workbuddy-host-installer.d.ts +16 -3
  161. package/release-manager/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  162. package/release-manager/dist/installers/workbuddy-host-installer.js +62 -11
  163. package/release-manager/dist/installers/workbuddy-host-installer.js.map +1 -1
  164. package/release-manager/dist/manifest-host-union.d.ts +23 -0
  165. package/release-manager/dist/manifest-host-union.d.ts.map +1 -0
  166. package/release-manager/dist/manifest-host-union.js +22 -0
  167. package/release-manager/dist/manifest-host-union.js.map +1 -0
  168. package/release-manager/dist/uninstaller.d.ts +2 -1
  169. package/release-manager/dist/uninstaller.d.ts.map +1 -1
  170. package/release-manager/dist/uninstaller.js +7 -1
  171. package/release-manager/dist/uninstaller.js.map +1 -1
  172. package/release-manager/package.json +2 -2
  173. package/workbuddy-adapter/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ /** Read-only adapter over the canonical trajectory store; never creates/migrates it. */
2
+ import path from 'node:path';
3
+ import Database from 'better-sqlite3';
4
+ import { createOwnerEvidenceScopeError } from '@principles/core/runtime-v2/internalization/evidence-readiness';
5
+ import { BehaviorExamplePackAssembler } from './behavior-example-pack-assembler.js';
6
+ import { resolveWorkspaceHostToolSemantics } from './host-tool-semantic-resolver.js';
7
+ function record(value) {
8
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
9
+ }
10
+ function contextRow(value) {
11
+ if (!record(value) || typeof value.id !== 'number' || !Number.isSafeInteger(value.id)
12
+ || typeof value.tool_name !== 'string' || typeof value.outcome !== 'string' || typeof value.params_json !== 'string') {
13
+ throw new Error('Malformed trajectory context row');
14
+ }
15
+ const params = JSON.parse(value.params_json);
16
+ if (!record(params))
17
+ throw new Error('Malformed trajectory params object');
18
+ if (Object.keys(params).some((key) => key === '__proto__' || key === 'constructor' || key === 'prototype')) {
19
+ throw new Error('Unsafe keys in persisted trajectory params');
20
+ }
21
+ return { id: value.id, toolName: value.tool_name, outcome: value.outcome, paramsJson: value.params_json };
22
+ }
23
+ function source(db) {
24
+ return {
25
+ getPainEventByCanonicalId(id) {
26
+ const row = db.prepare('SELECT id, session_id FROM pain_events WHERE canonical_pain_id = ? LIMIT 1').get(id);
27
+ if (row === undefined)
28
+ return null;
29
+ if (!record(row) || typeof row.id !== 'number' || typeof row.session_id !== 'string')
30
+ throw new Error('Malformed pain lineage row');
31
+ return { id: row.id, sessionId: row.session_id };
32
+ },
33
+ getRuleHostEvidenceRow(id) {
34
+ const row = db.prepare('SELECT id, session_id, tool_name, outcome, params_json FROM tool_calls WHERE id = ? LIMIT 1').get(id);
35
+ if (row === undefined)
36
+ return null;
37
+ if (!record(row) || typeof row.session_id !== 'string')
38
+ throw new Error('Malformed trajectory evidence row');
39
+ return { ...contextRow(row), sessionId: row.session_id };
40
+ },
41
+ getRuleHostContextRowsBefore(sessionId, beforeId, limit) {
42
+ const rows = db.prepare('SELECT id, tool_name, outcome, params_json FROM tool_calls WHERE session_id = ? AND id < ? ORDER BY id DESC LIMIT ?').all(sessionId, beforeId, limit + 1);
43
+ return { rows: rows.slice(0, limit).reverse().map(contextRow), truncated: rows.length > limit };
44
+ },
45
+ };
46
+ }
47
+ /** Lazy storage access: missing labels need no DB, and a failed open remains observable. */
48
+ export function createWorkspaceBehaviorEvidencePort(workspaceDir, toolSemantics) {
49
+ return {
50
+ assemble(selection) {
51
+ const resolved = toolSemantics === undefined ? resolveWorkspaceHostToolSemantics(workspaceDir) : null;
52
+ if (resolved !== null && !resolved.ok)
53
+ throw createOwnerEvidenceScopeError('evidence_source_error', resolved.reason);
54
+ const semantics = toolSemantics ?? (resolved !== null && resolved.ok ? resolved.registry : undefined);
55
+ if (semantics === undefined)
56
+ throw createOwnerEvidenceScopeError('evidence_source_error', 'Host tool semantics unavailable');
57
+ let db;
58
+ try {
59
+ db = new Database(path.join(workspaceDir, '.state', 'trajectory.db'), { readonly: true, fileMustExist: true });
60
+ }
61
+ catch (error) {
62
+ throw createOwnerEvidenceScopeError('evidence_source_error', `Trajectory evidence unavailable: ${error instanceof Error ? error.message : String(error)}`);
63
+ }
64
+ try {
65
+ // One read snapshot prevents a pack combining different trajectory revisions.
66
+ return db.transaction(() => new BehaviorExamplePackAssembler({ source: source(db), toolSemantics: semantics })
67
+ .assemble({ ...selection, projectDir: workspaceDir }))();
68
+ }
69
+ finally {
70
+ db.close();
71
+ }
72
+ },
73
+ };
74
+ }
@@ -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.10.0",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,7 +10,15 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "default": "./dist/index.js"
12
12
  },
13
- "./package.json": "./package.json"
13
+ "./package.json": "./package.json",
14
+ "./behavior-example-pack-assembler": {
15
+ "types": "./dist/behavior-example-pack-assembler.d.ts",
16
+ "default": "./dist/behavior-example-pack-assembler.js"
17
+ },
18
+ "./behavior-history": {
19
+ "types": "./dist/behavior-history.d.ts",
20
+ "default": "./dist/behavior-history.js"
21
+ }
14
22
  },
15
23
  "files": [
16
24
  "dist",
@@ -6,7 +6,23 @@ export type InstallHost = (typeof INSTALL_HOSTS)[number];
6
6
  export interface InstallManifest {
7
7
  layoutVersion: typeof INSTALL_LAYOUT_VERSION;
8
8
  mode: InstallLayoutMode;
9
+ /**
10
+ * Hosts THIS reader version recognizes. Host strings the reader does not
11
+ * know are NOT here — they land in `unknownHosts` so an install registered
12
+ * with a newer host keeps resolving instead of being rejected as malformed.
13
+ */
9
14
  hosts: InstallHost[];
15
+ /**
16
+ * Host strings present in the persisted `hosts` array that this reader
17
+ * version does not know (forward compatibility, 2026-10-16). A NEWER
18
+ * installer may register a host an OLDER reader never heard of; that is a
19
+ * compatibility warning, never "manifest malformed" — treating it as one
20
+ * made every pre-WorkBuddy Companion report `console_runtime_not_installed`
21
+ * against a healthy 3-host install and mass-stop its workers. Fail-closed
22
+ * stays reserved for structural damage: wrong layoutVersion, non-array or
23
+ * non-string hosts, bad mode, illegal workspace paths.
24
+ */
25
+ unknownHosts?: readonly string[];
10
26
  /**
11
27
  * Canonical absolute paths of Workspaces the install serves (PRI-624 Slice C).
12
28
  * Optional so pre-PRI-624 manifests stay valid; always normalized to
@@ -16,6 +32,11 @@ export interface InstallManifest {
16
32
  */
17
33
  workspaces?: readonly string[];
18
34
  }
35
+ /** Structured forward-compatibility observation from manifest parsing (rc-9). */
36
+ export interface InstallManifestWarning {
37
+ code: 'install_manifest_unknown_host';
38
+ host: string;
39
+ }
19
40
  export interface InstallLayoutPaths {
20
41
  homeDir: string;
21
42
  pdDir: string;
@@ -58,6 +79,8 @@ export interface LayoutResolution {
58
79
  manifest?: InstallManifest;
59
80
  reason?: string;
60
81
  nextAction?: string;
82
+ /** Forward-compatibility warnings surfaced while parsing the manifest. */
83
+ warnings?: readonly InstallManifestWarning[];
61
84
  }
62
85
  export interface ResolveInstallLayoutOptions {
63
86
  homeDir: string;
@@ -65,10 +88,26 @@ export interface ResolveInstallLayoutOptions {
65
88
  canonicalRuntimeExists: boolean;
66
89
  legacyExtensionExists: boolean;
67
90
  }
68
- /** Merge one Workspace into a manifest's workspace list (installer write path). Idempotent by canonical path. */
91
+ /**
92
+ * Merge one Workspace into a manifest's workspace list (installer write path). Idempotent by canonical path. */
69
93
  export declare function mergeInstallManifestWorkspaces(current: InstallManifest | undefined, workspaceDir: string): string[];
94
+ /**
95
+ * The `hosts` array a manifest WRITER must persist: every registration the
96
+ * reader recognized plus every unknown one, deduped, known hosts first.
97
+ * Writers that rebuild `hosts` from `manifest.hosts` alone silently DELETE a
98
+ * newer host's registration — the write-side twin of the read-side
99
+ * unknown-host brick (2026-10-16). `undefined` yields `[]` so the installer's
100
+ * fresh-install path keeps working unchanged.
101
+ */
102
+ export declare function installManifestHostsForPersist(manifest: InstallManifest | undefined): string[];
103
+ /**
104
+ * Parse the install manifest. Structural damage fails closed with `error`;
105
+ * a host string this reader version does not know is a `warnings` entry and
106
+ * the manifest still parses (forward compatibility — see `InstallManifest.unknownHosts`).
107
+ */
70
108
  export declare function parseInstallManifest(value: unknown): {
71
109
  manifest?: InstallManifest;
110
+ warnings?: readonly InstallManifestWarning[];
72
111
  error?: string;
73
112
  };
74
113
  export declare function getInstallLayoutPaths(homeDir: string): InstallLayoutPaths;
@@ -8,6 +8,9 @@ function isRecord(value) {
8
8
  function isHost(value) {
9
9
  return typeof value === 'string' && INSTALL_HOSTS.includes(value);
10
10
  }
11
+ function isNonEmptyString(value) {
12
+ return typeof value === 'string' && value.length > 0;
13
+ }
11
14
  /** Workspace entries must be non-empty absolute paths — the Companion spawns per-Workspace workers keyed by canonical path. */
12
15
  function parseWorkspaceList(value) {
13
16
  if (value === undefined)
@@ -25,7 +28,8 @@ function parseWorkspaceList(value) {
25
28
  }
26
29
  return { workspaces: resolved };
27
30
  }
28
- /** Merge one Workspace into a manifest's workspace list (installer write path). Idempotent by canonical path. */
31
+ /**
32
+ * Merge one Workspace into a manifest's workspace list (installer write path). Idempotent by canonical path. */
29
33
  export function mergeInstallManifestWorkspaces(current, workspaceDir) {
30
34
  const canonical = path.resolve(workspaceDir);
31
35
  const resolved = [];
@@ -38,6 +42,22 @@ export function mergeInstallManifestWorkspaces(current, workspaceDir) {
38
42
  resolved.push(canonical);
39
43
  return resolved;
40
44
  }
45
+ /**
46
+ * The `hosts` array a manifest WRITER must persist: every registration the
47
+ * reader recognized plus every unknown one, deduped, known hosts first.
48
+ * Writers that rebuild `hosts` from `manifest.hosts` alone silently DELETE a
49
+ * newer host's registration — the write-side twin of the read-side
50
+ * unknown-host brick (2026-10-16). `undefined` yields `[]` so the installer's
51
+ * fresh-install path keeps working unchanged.
52
+ */
53
+ export function installManifestHostsForPersist(manifest) {
54
+ return [...new Set([...(manifest?.hosts ?? []), ...(manifest?.unknownHosts ?? [])])];
55
+ }
56
+ /**
57
+ * Parse the install manifest. Structural damage fails closed with `error`;
58
+ * a host string this reader version does not know is a `warnings` entry and
59
+ * the manifest still parses (forward compatibility — see `InstallManifest.unknownHosts`).
60
+ */
41
61
  export function parseInstallManifest(value) {
42
62
  if (!isRecord(value))
43
63
  return { error: 'install_manifest_malformed: expected an object' };
@@ -47,14 +67,55 @@ export function parseInstallManifest(value) {
47
67
  if (value.mode !== 'canonical' && value.mode !== 'legacy') {
48
68
  return { error: 'install_manifest_malformed: mode must be canonical or legacy' };
49
69
  }
50
- if (!Array.isArray(value.hosts) || value.hosts.length === 0 || !value.hosts.every(isHost)) {
51
- return { error: 'install_manifest_malformed: hosts must contain codex, openclaw and/or workbuddy' };
70
+ // Host entries must be non-empty strings; WHICH strings are valid hosts is
71
+ // version-relative knowledge, so unknown strings warn instead of failing.
72
+ if (!Array.isArray(value.hosts) || !value.hosts.every(isNonEmptyString)) {
73
+ return { error: 'install_manifest_malformed: hosts must be an array of host name strings' };
74
+ }
75
+ // Idempotency: the parser must re-read its own output. An all-unknown-hosts
76
+ // manifest parses to hosts: [] + unknownHosts, so the optional persisted
77
+ // `unknownHosts` field is accepted on input too (installManifestHostsForPersist
78
+ // reunifies them on write; writers persist the union into `hosts`).
79
+ let carriedUnknownHosts = [];
80
+ if (value.unknownHosts !== undefined) {
81
+ if (!Array.isArray(value.unknownHosts) || !value.unknownHosts.every(isNonEmptyString)) {
82
+ return { error: 'install_manifest_malformed: unknownHosts must be an array of host name strings' };
83
+ }
84
+ carriedUnknownHosts = value.unknownHosts.filter((host) => !isHost(host));
85
+ }
86
+ if (value.hosts.length === 0 && carriedUnknownHosts.length === 0) {
87
+ return { error: 'install_manifest_malformed: hosts must contain at least one host' };
88
+ }
89
+ const hosts = [];
90
+ const unknownHosts = [];
91
+ const warnings = [];
92
+ for (const host of [...new Set(value.hosts)]) {
93
+ if (isHost(host))
94
+ hosts.push(host);
95
+ else {
96
+ unknownHosts.push(host);
97
+ warnings.push({ code: 'install_manifest_unknown_host', host });
98
+ }
99
+ }
100
+ for (const host of carriedUnknownHosts) {
101
+ if (!unknownHosts.includes(host)) {
102
+ unknownHosts.push(host);
103
+ warnings.push({ code: 'install_manifest_unknown_host', host });
104
+ }
52
105
  }
53
- const hosts = [...new Set(value.hosts)];
54
106
  const workspaces = parseWorkspaceList(value.workspaces);
55
107
  if (workspaces.error)
56
108
  return { error: workspaces.error };
57
- return { manifest: { layoutVersion: INSTALL_LAYOUT_VERSION, mode: value.mode, hosts, workspaces: workspaces.workspaces } };
109
+ return {
110
+ manifest: {
111
+ layoutVersion: INSTALL_LAYOUT_VERSION,
112
+ mode: value.mode,
113
+ hosts,
114
+ ...(unknownHosts.length > 0 ? { unknownHosts } : {}),
115
+ workspaces: workspaces.workspaces,
116
+ },
117
+ ...(warnings.length > 0 ? { warnings } : {}),
118
+ };
58
119
  }
59
120
  export function getInstallLayoutPaths(homeDir) {
60
121
  const home = path.resolve(homeDir);
@@ -96,8 +157,28 @@ export function getWorkbuddyWorkspaceDir(homeDir) {
96
157
  export function resolveInstallLayout(options) {
97
158
  const paths = getInstallLayoutPaths(options.homeDir);
98
159
  const parsed = parseInstallManifest(options.manifest);
160
+ const { warnings } = parsed;
99
161
  if (parsed.manifest && parsed.manifest.mode === 'canonical' && options.canonicalRuntimeExists) {
100
- return { mode: 'canonical', paths, manifest: parsed.manifest };
162
+ return { mode: 'canonical', paths, manifest: parsed.manifest, ...(warnings !== undefined ? { warnings } : {}) };
163
+ }
164
+ // RF-01 (review 2026-10-16): when a canonical runtime EXISTS, the manifest
165
+ // is the install-state authority. A manifest that was READ but cannot be
166
+ // honored (newer layoutVersion, structural damage) must refuse the whole
167
+ // resolution — falling through to the legacy extension dir would launch a
168
+ // runtime that does not match the installed protocol. Legacy fallback stays
169
+ // legitimate only when the reader genuinely saw NO manifest (absent file →
170
+ // `options.manifest === undefined`), i.e. a real legacy-only install, or
171
+ // when there is no canonical runtime to bypass.
172
+ if (options.canonicalRuntimeExists && options.manifest !== undefined && parsed.manifest === undefined) {
173
+ return {
174
+ mode: 'missing',
175
+ paths,
176
+ reason: parsed.error ?? 'install_manifest_malformed',
177
+ nextAction: parsed.error?.startsWith('install_manifest_unsupported_version')
178
+ ? 'Update PD Companion from https://github.com/csuzngjh/principles/releases (companion-v* Windows installer); do not reinstall the healthy PD runtime.'
179
+ : 'Run the PD installer/updater to repair the structurally damaged installation manifest.',
180
+ ...(warnings !== undefined ? { warnings } : {}),
181
+ };
101
182
  }
102
183
  if (options.legacyExtensionExists) {
103
184
  return {
@@ -106,6 +187,7 @@ export function resolveInstallLayout(options) {
106
187
  ...(parsed.manifest ? { manifest: parsed.manifest } : {}),
107
188
  reason: parsed.error ?? 'install_layout_legacy_fallback',
108
189
  nextAction: 'Run the installer update to migrate the shared runtime to ~/.pd/runtime.',
190
+ ...(warnings !== undefined ? { warnings } : {}),
109
191
  };
110
192
  }
111
193
  return {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/install-layout",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
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.4",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,7 +58,7 @@
58
58
  "author": "csuzngjh",
59
59
  "license": "Apache-2.0",
60
60
  "dependencies": {
61
- "@principles/install-layout": "^0.3.1",
61
+ "@principles/install-layout": "^0.4.0",
62
62
  "@tufjs/models": "3.0.1",
63
63
  "@inquirer/prompts": "^8.7.2",
64
64
  "commander": "^14.0.3",
@@ -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.6"
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,G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CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,+EAA+E;QAC/E,MAAM,GAAG,GAAiC;YACxC,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,iBAAiB;YACvB,SAAS,EAAE,iBAAiB,IAAI,IAAI,CAAC,SAAS,IAAI,wBAAwB;YAC1E,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;YACxD,UAAU,EAAE,0JAA0J;SACvK,CAAC;QACF,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,IAAI,EAAE,KAAK,EAAE,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,yEAAyE;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,71 @@
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
+ * Host-neutral trajectory assembly is shared with the background worker.
37
+ * It uses persisted host tool declarations; unknown host semantics fail loud.
38
+ */
39
+ import type { Command } from 'commander';
40
+ export interface EvidenceListOptions {
41
+ workspace?: string;
42
+ json?: boolean;
43
+ }
44
+ export declare function handleRuntimeInternalizationEvidenceList(opts: EvidenceListOptions): Promise<void>;
45
+ export interface EvidenceAttachOptions {
46
+ workspace?: string;
47
+ task?: string;
48
+ pain?: string;
49
+ negative?: number;
50
+ positive?: string[];
51
+ outcome?: string;
52
+ decidedBy?: string;
53
+ json?: boolean;
54
+ confirm?: boolean;
55
+ }
56
+ export declare function handleRuntimeInternalizationEvidenceAttach(opts: EvidenceAttachOptions): Promise<void>;
57
+ export interface EvidenceResumeOptions {
58
+ workspace?: string;
59
+ task?: string;
60
+ decidedBy?: string;
61
+ json?: boolean;
62
+ confirm?: boolean;
63
+ }
64
+ export declare function handleRuntimeInternalizationEvidenceResume(opts: EvidenceResumeOptions): Promise<void>;
65
+ /** Register `pd runtime internalization evidence list|attach|resume`. */
66
+ export declare function registerRuntimeInternalizationEvidenceCommand(internalizationCmd: Command, handlers?: {
67
+ list?: typeof handleRuntimeInternalizationEvidenceList;
68
+ attach?: typeof handleRuntimeInternalizationEvidenceAttach;
69
+ resume?: typeof handleRuntimeInternalizationEvidenceResume;
70
+ }): Command;
71
+ //# sourceMappingURL=runtime-internalization-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-internalization-evidence.d.ts","sourceRoot":"","sources":["../../src/commands/runtime-internalization-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiDzC,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,wCAAwC,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDvG;AAID,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MA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