@principles/pd-cli 1.152.11 → 1.152.13

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 (303) hide show
  1. package/dist/commands/candidate.d.ts +3 -3
  2. package/dist/commands/candidate.d.ts.map +1 -1
  3. package/dist/commands/candidate.js +9 -21
  4. package/dist/commands/candidate.js.map +1 -1
  5. package/dist/index.js +0 -0
  6. package/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
  7. package/dist/services/rulehost-pipeline-runner.js +4 -17
  8. package/dist/services/rulehost-pipeline-runner.js.map +1 -1
  9. package/package.json +13 -7
  10. package/dist/commands/__tests__/intent-flag-wiring.test.d.ts +0 -9
  11. package/dist/commands/__tests__/intent-flag-wiring.test.d.ts.map +0 -1
  12. package/dist/commands/__tests__/intent-flag-wiring.test.js +0 -237
  13. package/dist/commands/__tests__/intent-flag-wiring.test.js.map +0 -1
  14. package/dist/commands/__tests__/legacy-cleanup.test.d.ts +0 -18
  15. package/dist/commands/__tests__/legacy-cleanup.test.d.ts.map +0 -1
  16. package/dist/commands/__tests__/legacy-cleanup.test.js +0 -467
  17. package/dist/commands/__tests__/legacy-cleanup.test.js.map +0 -1
  18. package/dist/commands/__tests__/mvp-smoke.test.d.ts +0 -15
  19. package/dist/commands/__tests__/mvp-smoke.test.d.ts.map +0 -1
  20. package/dist/commands/__tests__/mvp-smoke.test.js +0 -262
  21. package/dist/commands/__tests__/mvp-smoke.test.js.map +0 -1
  22. package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.d.ts +0 -2
  23. package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.d.ts.map +0 -1
  24. package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.js +0 -60
  25. package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.js.map +0 -1
  26. package/dist/commands/__tests__/rulecode-flag-wiring.test.d.ts +0 -21
  27. package/dist/commands/__tests__/rulecode-flag-wiring.test.d.ts.map +0 -1
  28. package/dist/commands/__tests__/rulecode-flag-wiring.test.js +0 -186
  29. package/dist/commands/__tests__/rulecode-flag-wiring.test.js.map +0 -1
  30. package/dist/commands/__tests__/rulecode-handler.test.d.ts +0 -16
  31. package/dist/commands/__tests__/rulecode-handler.test.d.ts.map +0 -1
  32. package/dist/commands/__tests__/rulecode-handler.test.js +0 -285
  33. package/dist/commands/__tests__/rulecode-handler.test.js.map +0 -1
  34. package/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts +0 -24
  35. package/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts.map +0 -1
  36. package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js +0 -232
  37. package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js.map +0 -1
  38. package/dist/commands/__tests__/runtime-activation-nextaction.test.d.ts +0 -15
  39. package/dist/commands/__tests__/runtime-activation-nextaction.test.d.ts.map +0 -1
  40. package/dist/commands/__tests__/runtime-activation-nextaction.test.js +0 -73
  41. package/dist/commands/__tests__/runtime-activation-nextaction.test.js.map +0 -1
  42. package/dist/commands/__tests__/runtime-probe-config.test.d.ts +0 -20
  43. package/dist/commands/__tests__/runtime-probe-config.test.d.ts.map +0 -1
  44. package/dist/commands/__tests__/runtime-probe-config.test.js +0 -389
  45. package/dist/commands/__tests__/runtime-probe-config.test.js.map +0 -1
  46. package/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts +0 -9
  47. package/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts.map +0 -1
  48. package/dist/commands/__tests__/telemetry-flag-wiring.test.js +0 -76
  49. package/dist/commands/__tests__/telemetry-flag-wiring.test.js.map +0 -1
  50. package/dist/commands/__tests__/version.test.d.ts +0 -2
  51. package/dist/commands/__tests__/version.test.d.ts.map +0 -1
  52. package/dist/commands/__tests__/version.test.js +0 -238
  53. package/dist/commands/__tests__/version.test.js.map +0 -1
  54. package/dist/commands/runtime-uat.guard.test.d.ts +0 -2
  55. package/dist/commands/runtime-uat.guard.test.d.ts.map +0 -1
  56. package/dist/commands/runtime-uat.guard.test.js +0 -153
  57. package/dist/commands/runtime-uat.guard.test.js.map +0 -1
  58. package/dist/services/__tests__/cli-output.test.d.ts +0 -18
  59. package/dist/services/__tests__/cli-output.test.d.ts.map +0 -1
  60. package/dist/services/__tests__/cli-output.test.js +0 -103
  61. package/dist/services/__tests__/cli-output.test.js.map +0 -1
  62. package/dist/services/__tests__/evaluator-runner-deps.test.d.ts +0 -2
  63. package/dist/services/__tests__/evaluator-runner-deps.test.d.ts.map +0 -1
  64. package/dist/services/__tests__/evaluator-runner-deps.test.js +0 -343
  65. package/dist/services/__tests__/evaluator-runner-deps.test.js.map +0 -1
  66. package/dist/services/__tests__/rulehost-readiness.test.d.ts +0 -2
  67. package/dist/services/__tests__/rulehost-readiness.test.d.ts.map +0 -1
  68. package/dist/services/__tests__/rulehost-readiness.test.js +0 -311
  69. package/dist/services/__tests__/rulehost-readiness.test.js.map +0 -1
  70. package/dist/services/__tests__/runtime-adapter-resolver.test.d.ts +0 -18
  71. package/dist/services/__tests__/runtime-adapter-resolver.test.d.ts.map +0 -1
  72. package/dist/services/__tests__/runtime-adapter-resolver.test.js +0 -673
  73. package/dist/services/__tests__/runtime-adapter-resolver.test.js.map +0 -1
  74. package/dist/utils/production-workspace-guard.test.d.ts +0 -2
  75. package/dist/utils/production-workspace-guard.test.d.ts.map +0 -1
  76. package/dist/utils/production-workspace-guard.test.js +0 -137
  77. package/dist/utils/production-workspace-guard.test.js.map +0 -1
  78. package/scripts/llm-dogfood.ts +0 -456
  79. package/scripts/migrate-illegal-expected-decision.ts +0 -252
  80. package/src/commands/__tests__/intent-flag-wiring.test.ts +0 -282
  81. package/src/commands/__tests__/legacy-cleanup.test.ts +0 -602
  82. package/src/commands/__tests__/mvp-smoke.test.ts +0 -300
  83. package/src/commands/__tests__/pain-retry-maxTokens-flag.test.ts +0 -73
  84. package/src/commands/__tests__/rulecode-flag-wiring.test.ts +0 -237
  85. package/src/commands/__tests__/rulecode-handler.test.ts +0 -369
  86. package/src/commands/__tests__/run-rulehost-flag-wiring.test.ts +0 -292
  87. package/src/commands/__tests__/runtime-activation-nextaction.test.ts +0 -81
  88. package/src/commands/__tests__/runtime-probe-config.test.ts +0 -432
  89. package/src/commands/__tests__/telemetry-flag-wiring.test.ts +0 -84
  90. package/src/commands/__tests__/version.test.ts +0 -251
  91. package/src/commands/admission-gate.ts +0 -30
  92. package/src/commands/artifact.ts +0 -82
  93. package/src/commands/build-trajectory-evidence.ts +0 -298
  94. package/src/commands/candidate.ts +0 -1260
  95. package/src/commands/codex-ingest-catchup.ts +0 -114
  96. package/src/commands/codex-ingest-quarantine.ts +0 -127
  97. package/src/commands/codex-reconcile.ts +0 -84
  98. package/src/commands/codex-setup.ts +0 -476
  99. package/src/commands/codex-worker.ts +0 -185
  100. package/src/commands/command-helpers.ts +0 -24
  101. package/src/commands/config-doctor.ts +0 -193
  102. package/src/commands/console.ts +0 -797
  103. package/src/commands/context.ts +0 -72
  104. package/src/commands/demo-story-a.ts +0 -241
  105. package/src/commands/diagnose.ts +0 -756
  106. package/src/commands/errors-list.ts +0 -441
  107. package/src/commands/evolution-tasks-list.ts +0 -48
  108. package/src/commands/evolution-tasks-show.ts +0 -62
  109. package/src/commands/flow.ts +0 -60
  110. package/src/commands/health-codex.ts +0 -576
  111. package/src/commands/health.ts +0 -315
  112. package/src/commands/history.ts +0 -63
  113. package/src/commands/intent.ts +0 -457
  114. package/src/commands/legacy-cleanup.ts +0 -531
  115. package/src/commands/legacy-import.ts +0 -104
  116. package/src/commands/mvp-smoke.ts +0 -160
  117. package/src/commands/pain-evidence.ts +0 -226
  118. package/src/commands/pain-list.ts +0 -239
  119. package/src/commands/pain-record.ts +0 -612
  120. package/src/commands/pain-retry.ts +0 -916
  121. package/src/commands/principles-stats.ts +0 -700
  122. package/src/commands/proven-channel-baseline.ts +0 -115
  123. package/src/commands/quality-scorecard.ts +0 -272
  124. package/src/commands/remediation-output.ts +0 -66
  125. package/src/commands/rulecode.ts +0 -465
  126. package/src/commands/run.ts +0 -89
  127. package/src/commands/runtime-activation.ts +0 -1629
  128. package/src/commands/runtime-artifact-repair.ts +0 -524
  129. package/src/commands/runtime-canary.ts +0 -395
  130. package/src/commands/runtime-compatibility-scan.ts +0 -105
  131. package/src/commands/runtime-diagnostics-export.ts +0 -229
  132. package/src/commands/runtime-features.ts +0 -153
  133. package/src/commands/runtime-gfi-snapshot.ts +0 -135
  134. package/src/commands/runtime-health-snapshot.ts +0 -108
  135. package/src/commands/runtime-init.ts +0 -429
  136. package/src/commands/runtime-internalization-enqueue-successors.ts +0 -530
  137. package/src/commands/runtime-internalization-integrity-repair.ts +0 -79
  138. package/src/commands/runtime-internalization-integrity.ts +0 -107
  139. package/src/commands/runtime-internalization-queue.ts +0 -135
  140. package/src/commands/runtime-internalization-retry.ts +0 -191
  141. package/src/commands/runtime-internalization-run-once.ts +0 -791
  142. package/src/commands/runtime-internalization-run-rulehost.ts +0 -749
  143. package/src/commands/runtime-internalization-wake-once.ts +0 -87
  144. package/src/commands/runtime-pain-flood-simulation.ts +0 -121
  145. package/src/commands/runtime-pruning.ts +0 -438
  146. package/src/commands/runtime-recovery-failed-tasks.ts +0 -258
  147. package/src/commands/runtime-recovery.ts +0 -109
  148. package/src/commands/runtime-synthetic-baseline.ts +0 -70
  149. package/src/commands/runtime-uat.guard.test.ts +0 -175
  150. package/src/commands/runtime-uat.ts +0 -380
  151. package/src/commands/runtime.ts +0 -473
  152. package/src/commands/samples-list.ts +0 -39
  153. package/src/commands/samples-review.ts +0 -36
  154. package/src/commands/task.ts +0 -271
  155. package/src/commands/telemetry.ts +0 -349
  156. package/src/commands/trace.ts +0 -174
  157. package/src/commands/trajectory-db-unavailable.ts +0 -19
  158. package/src/commands/trajectory.ts +0 -64
  159. package/src/commands/version.ts +0 -49
  160. package/src/config-reader.ts +0 -122
  161. package/src/index.ts +0 -1276
  162. package/src/legacy/legacy-import.ts +0 -179
  163. package/src/legacy/session-history-import.ts +0 -203
  164. package/src/resolve-workspace.ts +0 -106
  165. package/src/services/__tests__/cli-output.test.ts +0 -130
  166. package/src/services/__tests__/evaluator-runner-deps.test.ts +0 -382
  167. package/src/services/__tests__/rulehost-readiness.test.ts +0 -363
  168. package/src/services/__tests__/runtime-adapter-resolver.test.ts +0 -793
  169. package/src/services/cli-output.ts +0 -95
  170. package/src/services/config-doctor.ts +0 -697
  171. package/src/services/console-launcher.ts +0 -537
  172. package/src/services/demo-rule-compiler.ts +0 -40
  173. package/src/services/demo-story-a-runner.ts +0 -471
  174. package/src/services/mainline-snapshot-assembler.ts +0 -579
  175. package/src/services/pain-flood-simulation-runner.ts +0 -462
  176. package/src/services/pd-config-loader.ts +0 -433
  177. package/src/services/proven-channel-baseline-runner.ts +0 -157
  178. package/src/services/quality-scorecard/data-extractor.ts +0 -150
  179. package/src/services/quality-scorecard/local-evaluator.ts +0 -142
  180. package/src/services/quality-scorecard/strong-model-gate.ts +0 -202
  181. package/src/services/resolve-runtime-from-pd-config.ts +0 -230
  182. package/src/services/rulehost-pipeline-runner.ts +0 -1216
  183. package/src/services/rulehost-readiness.ts +0 -326
  184. package/src/services/runtime-adapter-resolver.ts +0 -364
  185. package/src/services/synthetic-baseline-runner.ts +0 -400
  186. package/src/services/version-report.ts +0 -253
  187. package/src/services/workspace-tool-semantics.ts +0 -26
  188. package/src/utils/path-security.ts +0 -96
  189. package/src/utils/production-workspace-guard.test.ts +0 -157
  190. package/src/utils/production-workspace-guard.ts +0 -210
  191. package/tests/bdd/cli-contract.steps.ts +0 -346
  192. package/tests/bdd/principles-stats.steps.ts +0 -211
  193. package/tests/bdd/support/gherkin-loader.ts +0 -147
  194. package/tests/bdd/support/repo-root.ts +0 -62
  195. package/tests/bdd/support/vitest-bdd.ts +0 -179
  196. package/tests/commands/admission-gate-coverage.test.ts +0 -79
  197. package/tests/commands/build-trajectory-evidence.test.ts +0 -508
  198. package/tests/commands/candidate-audit-repair.test.ts +0 -421
  199. package/tests/commands/candidate-intake.test.ts +0 -732
  200. package/tests/commands/candidate-internalization-backfill.test.ts +0 -548
  201. package/tests/commands/candidate-internalize-lineage.test.ts +0 -565
  202. package/tests/commands/candidate-internalize.test.ts +0 -299
  203. package/tests/commands/candidate-route.test.ts +0 -329
  204. package/tests/commands/candidate-show.test.ts +0 -95
  205. package/tests/commands/cli-command-tree.test.ts +0 -144
  206. package/tests/commands/cli-help-snapshot.test.ts +0 -155
  207. package/tests/commands/cli-skill-contract.test.ts +0 -121
  208. package/tests/commands/codex-consent-reversibility.steps.test.ts +0 -299
  209. package/tests/commands/codex-ingest-quarantine.test.ts +0 -136
  210. package/tests/commands/codex-setup.test.ts +0 -297
  211. package/tests/commands/codex-worker-daemon.test.ts +0 -95
  212. package/tests/commands/codex-worker-registration.test.ts +0 -207
  213. package/tests/commands/config-doctor.test.ts +0 -336
  214. package/tests/commands/console-launcher-edge-cases.test.ts +0 -388
  215. package/tests/commands/console-open.test.ts +0 -1381
  216. package/tests/commands/context.test.ts +0 -114
  217. package/tests/commands/demo-story-a.test.ts +0 -318
  218. package/tests/commands/diagnose.test.ts +0 -1803
  219. package/tests/commands/errors-list.test.ts +0 -679
  220. package/tests/commands/evolution-tasks-list.test.ts +0 -41
  221. package/tests/commands/evolution-tasks-show.test.ts +0 -46
  222. package/tests/commands/health-codex.test.ts +0 -349
  223. package/tests/commands/health-host-wiring.test.ts +0 -76
  224. package/tests/commands/health-reliability.test.ts +0 -99
  225. package/tests/commands/health.test.ts +0 -413
  226. package/tests/commands/intent.test.ts +0 -321
  227. package/tests/commands/legacy-cleanup.test.ts +0 -148
  228. package/tests/commands/pain-evidence.test.ts +0 -518
  229. package/tests/commands/pain-list.test.ts +0 -219
  230. package/tests/commands/pain-record-async.test.ts +0 -335
  231. package/tests/commands/pain-record-session-parser.test.ts +0 -228
  232. package/tests/commands/pain-record.test.ts +0 -851
  233. package/tests/commands/pain-retry.test.ts +0 -1121
  234. package/tests/commands/plugin-config-resolution-cutover.test.ts +0 -229
  235. package/tests/commands/pri-393-runtime-config-unification.test.ts +0 -443
  236. package/tests/commands/principles-stats-wiring.test.ts +0 -135
  237. package/tests/commands/principles-stats.test.ts +0 -274
  238. package/tests/commands/product-path-regression.test.ts +0 -86
  239. package/tests/commands/proven-channel-baseline.test.ts +0 -441
  240. package/tests/commands/rulecode.test.ts +0 -177
  241. package/tests/commands/run-rulehost-handler.test.ts +0 -908
  242. package/tests/commands/runtime-activation-approve-flag-wiring.test.ts +0 -227
  243. package/tests/commands/runtime-activation-deactivate-flag-wiring.test.ts +0 -167
  244. package/tests/commands/runtime-activation-dispatch-flag-wiring.test.ts +0 -262
  245. package/tests/commands/runtime-activation-governance-audit.test.ts +0 -95
  246. package/tests/commands/runtime-activation-list-flag-wiring.test.ts +0 -193
  247. package/tests/commands/runtime-activation-promote-flag-wiring.test.ts +0 -248
  248. package/tests/commands/runtime-activation-shadow-telemetry.test.ts +0 -130
  249. package/tests/commands/runtime-activation.test.ts +0 -2052
  250. package/tests/commands/runtime-artifact-repair-registration.test.ts +0 -74
  251. package/tests/commands/runtime-artifact-repair.test.ts +0 -404
  252. package/tests/commands/runtime-canary.test.ts +0 -430
  253. package/tests/commands/runtime-compatibility-scan.test.ts +0 -146
  254. package/tests/commands/runtime-diagnostics-export.test.ts +0 -175
  255. package/tests/commands/runtime-features.test.ts +0 -249
  256. package/tests/commands/runtime-health-snapshot.test.ts +0 -358
  257. package/tests/commands/runtime-init-empty-workspace.test.ts +0 -252
  258. package/tests/commands/runtime-init.test.ts +0 -420
  259. package/tests/commands/runtime-internalization-enqueue-successors.test.ts +0 -782
  260. package/tests/commands/runtime-internalization-integrity-repair.test.ts +0 -239
  261. package/tests/commands/runtime-internalization-integrity.test.ts +0 -140
  262. package/tests/commands/runtime-internalization-queue.test.ts +0 -380
  263. package/tests/commands/runtime-internalization-retry-owner-authority.test.ts +0 -431
  264. package/tests/commands/runtime-internalization-run-once-evaluator-parity.test.ts +0 -269
  265. package/tests/commands/runtime-internalization-run-once-language.test.ts +0 -303
  266. package/tests/commands/runtime-internalization-run-once-real-config.test.ts +0 -237
  267. package/tests/commands/runtime-internalization-run-once-rollout-parity.test.ts +0 -706
  268. package/tests/commands/runtime-internalization-run-once.test.ts +0 -1791
  269. package/tests/commands/runtime-internalization-wake-once.test.ts +0 -171
  270. package/tests/commands/runtime-internalization.test.ts +0 -53
  271. package/tests/commands/runtime-pain-flood-simulation.test.ts +0 -418
  272. package/tests/commands/runtime-pruning.test.ts +0 -694
  273. package/tests/commands/runtime-recovery-failed-tasks.test.ts +0 -328
  274. package/tests/commands/runtime-recovery.test.ts +0 -120
  275. package/tests/commands/runtime-synthetic-baseline.test.ts +0 -249
  276. package/tests/commands/runtime-uat.test.ts +0 -397
  277. package/tests/commands/runtime.test.ts +0 -392
  278. package/tests/commands/samples-list.test.ts +0 -43
  279. package/tests/commands/samples-review.test.ts +0 -41
  280. package/tests/commands/task.test.ts +0 -153
  281. package/tests/commands/telemetry.test.ts +0 -190
  282. package/tests/commands/trace.test.ts +0 -316
  283. package/tests/config-reader.test.ts +0 -143
  284. package/tests/e2e/candidate-intake-e2e.test.ts +0 -338
  285. package/tests/e2e/cli-full-flow.test.ts +0 -233
  286. package/tests/e2e/cross-package-acceptance.test.ts +0 -635
  287. package/tests/helpers/pd-cli-path.ts +0 -5
  288. package/tests/pd-cli-smoke.test.ts +0 -13
  289. package/tests/resolve-workspace.test.ts +0 -196
  290. package/tests/services/config-doctor-signal-health.test.ts +0 -109
  291. package/tests/services/console-launcher.test.ts +0 -114
  292. package/tests/services/demo-rule-compiler.test.ts +0 -242
  293. package/tests/services/mainline-snapshot-assembler.test.ts +0 -572
  294. package/tests/services/pd-config-loader.test.ts +0 -505
  295. package/tests/services/proven-channel-baseline-runner.test.ts +0 -30
  296. package/tests/services/quality-scorecard/strong-model-gate.test.ts +0 -133
  297. package/tests/services/resolve-runtime-from-pd-config.test.ts +0 -485
  298. package/tests/services/rulehost-pipeline-e2e.test.ts +0 -538
  299. package/tests/services/rulehost-pipeline-runner.test.ts +0 -1175
  300. package/tests/services/workspace-tool-semantics.test.ts +0 -76
  301. package/tests/utils/path-security.test.ts +0 -180
  302. package/tsconfig.json +0 -26
  303. package/vitest.config.ts +0 -9
@@ -1,400 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { RuntimeStateManager } from '@principles/core/runtime-v2';
4
- import { SqliteContextAssembler } from '@principles/core/runtime-v2';
5
- import { SqliteHistoryQuery } from '@principles/core/runtime-v2';
6
- import { StoreEventEmitter } from '@principles/core/runtime-v2';
7
- import {
8
- SplitDiagnosticianRunner,
9
- DiagRootCauseRunner,
10
- DiagDistillerRunner,
11
- DiagRouterRunner,
12
- DefaultDiagRootCauseValidator,
13
- DefaultDiagDistillerValidator,
14
- } from '@principles/core/runtime-v2';
15
- import { SqliteDiagnosticianCommitter } from '@principles/core/runtime-v2';
16
- import { TestDoubleRuntimeAdapter } from '@principles/core/runtime-v2';
17
- import { PainSignalBridge } from '@principles/core/runtime-v2';
18
- import { CandidateIntakeService } from '@principles/core/runtime-v2';
19
- import { PrincipleTreeLedgerAdapter } from '@principles/core/runtime-v2';
20
- import { auditCandidateLedgerConsistency } from '@principles/core/runtime-v2';
21
- import { OperatorHealthReadModel } from '@principles/core/runtime-v2';
22
- import { createInternalizationQueueReadModel } from '@principles/core/runtime-v2';
23
- import { createPITaskDiagnosticJson } from '@principles/core/runtime-v2';
24
- import {
25
- computeOverallStatus,
26
- boundedEvidence,
27
- truncateReason,
28
- recommendNextIssue,
29
- makeDeterministicDiagnosticianOutput,
30
- } from '@principles/core/runtime-v2';
31
- import type {
32
- SyntheticBaselineSummary,
33
- SyntheticBaselineStage,
34
- SyntheticBaselineStageName,
35
- SyntheticBaselineFailStage,
36
- } from '@principles/core/runtime-v2';
37
-
38
- export interface SyntheticBaselineRunnerOptions {
39
- workspaceDir: string;
40
- workspaceMode: 'temp' | 'explicit_workspace';
41
- failAfterStage?: SyntheticBaselineFailStage;
42
- }
43
-
44
- export async function runSyntheticBaseline(opts: SyntheticBaselineRunnerOptions): Promise<SyntheticBaselineSummary> {
45
- const { workspaceDir, workspaceMode, failAfterStage } = opts;
46
- const stages: SyntheticBaselineStage[] = [];
47
- const generatedAt = new Date().toISOString();
48
-
49
- const painId = `synth-pain-${Date.now()}`;
50
- const diagnosticianOutput = makeDeterministicDiagnosticianOutput(painId);
51
-
52
- let stateManager: RuntimeStateManager | null = null;
53
-
54
- try {
55
- const pdDir = path.join(workspaceDir, '.pd');
56
- const stateDir = path.join(workspaceDir, '.state');
57
- await fs.promises.mkdir(pdDir, { recursive: true });
58
- await fs.promises.mkdir(stateDir, { recursive: true });
59
-
60
- stateManager = new RuntimeStateManager({ workspaceDir });
61
- await stateManager.initialize();
62
-
63
- if (failAfterStage === 'before_pain_intake') {
64
- stages.push({
65
- name: 'pain_intake',
66
- status: 'failed',
67
- reason: truncateReason('Injected failure: pain intake stage forced to fail for testing'),
68
- });
69
- for (const name of ['diagnostician_task_created', 'candidate_created', 'ledger_consistent', 'internalization_queue_ready', 'canary_health'] as SyntheticBaselineStageName[]) {
70
- stages.push({ name, status: 'failed', reason: 'Prerequisite stage pain_intake failed' });
71
- }
72
- const status = computeOverallStatus(stages);
73
- return { status, workspaceMode, generatedAt, stages, recommendedNextIssue: recommendNextIssue(stages) };
74
- }
75
-
76
- const { connection: sqliteConn, taskStore, runStore } = stateManager;
77
- const historyQuery = new SqliteHistoryQuery(sqliteConn);
78
- const contextAssembler = new SqliteContextAssembler(taskStore, historyQuery, runStore);
79
- const eventEmitter = new StoreEventEmitter();
80
- const committer = new SqliteDiagnosticianCommitter(sqliteConn);
81
- const runIdToTaskId = new Map<string, string>();
82
- let runCounter = 0;
83
-
84
- // Single test-double adapter handles all pains with stage-aware output
85
- const runtimeAdapter = new TestDoubleRuntimeAdapter({
86
- onStartRun: (input) => {
87
- runCounter += 1;
88
- const runId = `td-${runCounter}`;
89
- const taskId = input.taskRef?.taskId ?? '';
90
- runIdToTaskId.set(runId, taskId);
91
- return {
92
- runId,
93
- runtimeKind: 'test-double',
94
- startedAt: new Date().toISOString(),
95
- };
96
- },
97
- onFetchOutput: async (runId: string) => {
98
- const taskId = runIdToTaskId.get(runId) ?? '';
99
- if (taskId.includes('diag_rootcause')) {
100
- return {
101
- runId,
102
- payload: {
103
- valid: true,
104
- diagnosisId: `diag-${runId}`,
105
- taskId,
106
- summary: 'Mock rootcause summary for synthetic-baseline',
107
- causalChain: [{ why: 1, statement: 'why', evidenceRefs: ['ref-1'] }],
108
- rootCause: 'Design: Mock rootcause',
109
- rootCauseCategory: 'Design',
110
- evidence: [{ sourceRef: 'ref-1', note: 'note' }],
111
- confidence: 0.9,
112
- },
113
- };
114
- } else if (taskId.includes('diag_distiller')) {
115
- const parentTaskId = taskId.replace('diag_distiller-', '');
116
- const stageATaskId = `diag_rootcause-${parentTaskId}`;
117
- const artifacts = stateManager
118
- ? await stateManager.piArtifactStore.listBySourceTaskId(stageATaskId)
119
- : [];
120
- const sourceRootCauseArtifactId = artifacts[0]?.artifactId ?? 'art-rc';
121
- return {
122
- runId,
123
- payload: {
124
- valid: true,
125
- taskId,
126
- sourceRootCauseArtifactId,
127
- abstractedPrinciple: 'Mock abstracted principle',
128
- rationale: 'Mock rationale',
129
- groundedOnCorePrincipleIds: ['T-01'],
130
- scope: 'domain',
131
- confidence: 0.9,
132
- },
133
- };
134
- } else {
135
- return {
136
- runId,
137
- payload: diagnosticianOutput,
138
- };
139
- }
140
- },
141
- });
142
-
143
- const rootCauseRunner = new DiagRootCauseRunner(
144
- {
145
- stateManager,
146
- runtimeAdapter,
147
- eventEmitter,
148
- artifactStore: stateManager.piArtifactStore,
149
- validator: new DefaultDiagRootCauseValidator(),
150
- contextAssembler,
151
- },
152
- {
153
- owner: 'synthetic-baseline',
154
- runtimeKind: 'test-double',
155
- pollIntervalMs: 50,
156
- timeoutMs: 10000,
157
- },
158
- );
159
-
160
- const distillerRunner = new DiagDistillerRunner(
161
- {
162
- stateManager,
163
- runtimeAdapter,
164
- eventEmitter,
165
- artifactStore: stateManager.piArtifactStore,
166
- validator: new DefaultDiagDistillerValidator(),
167
- },
168
- {
169
- owner: 'synthetic-baseline',
170
- runtimeKind: 'test-double',
171
- pollIntervalMs: 50,
172
- timeoutMs: 10000,
173
- },
174
- );
175
-
176
- const routerRunner = new DiagRouterRunner(
177
- {
178
- stateManager,
179
- runtimeAdapter,
180
- eventEmitter,
181
- artifactStore: stateManager.piArtifactStore,
182
- committer,
183
- },
184
- {
185
- owner: 'synthetic-baseline',
186
- runtimeKind: 'test-double',
187
- pollIntervalMs: 50,
188
- timeoutMs: 10000,
189
- },
190
- );
191
-
192
- const runner = new SplitDiagnosticianRunner({
193
- rootCauseRunner,
194
- distillerRunner,
195
- routerRunner,
196
- stateManager,
197
- committer,
198
- perStageTimeoutMs: 10000,
199
- });
200
-
201
- const ledgerAdapter = new PrincipleTreeLedgerAdapter({ stateDir });
202
- const intakeService = new CandidateIntakeService({ stateManager, ledgerAdapter });
203
-
204
- const bridge = new PainSignalBridge({
205
- stateManager,
206
- runner,
207
- intakeService,
208
- ledgerAdapter,
209
- autoIntakeEnabled: true,
210
- });
211
-
212
- const bridgeResult = await bridge.onPainDetected({
213
- painId,
214
- painType: 'tool_failure',
215
- source: 'synthetic-baseline',
216
- reason: 'Synthetic baseline deterministic pain signal',
217
- // Synthetic baseline is a deterministic smoke tool — it has no real host
218
- // session to harvest evidence from. Provide a synthetic evidence entry so
219
- // Gate B admission (TriggerController) does not short-circuit the pain
220
- // before diagnosis. Without this, the baseline reports
221
- // `short_circuited: input evidence empty` and every downstream stage
222
- // fails, even though the pipeline itself is healthy.
223
- evidence: [{ sourceRef: `synthetic:${painId}`, note: 'Synthetic baseline deterministic evidence anchor' }],
224
- });
225
-
226
- const painPassed = bridgeResult.status === 'succeeded';
227
- stages.push({
228
- name: 'pain_intake',
229
- status: painPassed ? 'passed' : 'failed',
230
- ...(painPassed ? {} : { reason: truncateReason(bridgeResult.message ?? `PainSignalBridge returned status=${bridgeResult.status}`) }),
231
- evidence: boundedEvidence({
232
- painId: bridgeResult.painId,
233
- bridgeStatus: bridgeResult.status,
234
- }),
235
- });
236
-
237
- if (failAfterStage === 'after_pain_intake') {
238
- stages.push({ name: 'diagnostician_task_created', status: 'failed', reason: 'Injected failure: forced fail after pain_intake' });
239
- stages.push({ name: 'candidate_created', status: 'failed', reason: 'Prerequisite stage diagnostician_task_created failed' });
240
- stages.push({ name: 'ledger_consistent', status: 'failed', reason: 'Prerequisite stage candidate_created failed' });
241
- stages.push({ name: 'internalization_queue_ready', status: 'failed', reason: 'Prerequisite stage ledger_consistent failed' });
242
- stages.push({ name: 'canary_health', status: 'failed', reason: 'Prerequisite stage internalization_queue_ready failed' });
243
- const status = computeOverallStatus(stages);
244
- return { status, workspaceMode, generatedAt, stages, recommendedNextIssue: recommendNextIssue(stages) };
245
- }
246
-
247
- const { taskId } = bridgeResult;
248
- const task = await stateManager.getTask(taskId);
249
- const taskPassed = task !== null && task.status === 'succeeded';
250
- stages.push({
251
- name: 'diagnostician_task_created',
252
- status: taskPassed ? 'passed' : 'failed',
253
- ...(taskPassed ? {} : { reason: truncateReason(`Task ${taskId} not found or not succeeded. task=${task ? task.status : 'null'}`) }),
254
- evidence: boundedEvidence({
255
- taskId,
256
- taskStatus: task?.status ?? 'not_found',
257
- }),
258
- });
259
-
260
- const candidates = await stateManager.getCandidatesByTaskId(taskId);
261
- const candidatePassed = candidates.length > 0;
262
- stages.push({
263
- name: 'candidate_created',
264
- status: candidatePassed ? 'passed' : 'failed',
265
- ...(candidatePassed ? {} : { reason: truncateReason(`No candidates found for task ${taskId}`) }),
266
- evidence: boundedEvidence({
267
- candidateCount: candidates.length,
268
- candidateIds: candidates.map(c => c.candidateId).slice(0, 5),
269
- }),
270
- });
271
-
272
- if (failAfterStage === 'after_candidate_created') {
273
- stages.push({ name: 'ledger_consistent', status: 'failed', reason: 'Injected failure: forced fail after candidate_created' });
274
- stages.push({ name: 'internalization_queue_ready', status: 'failed', reason: 'Prerequisite stage ledger_consistent failed' });
275
- stages.push({ name: 'canary_health', status: 'failed', reason: 'Prerequisite stage internalization_queue_ready failed' });
276
- const status = computeOverallStatus(stages);
277
- return { status, workspaceMode, generatedAt, stages, recommendedNextIssue: recommendNextIssue(stages) };
278
- }
279
-
280
- const auditResult = await auditCandidateLedgerConsistency(workspaceDir);
281
- const ledgerPassed = auditResult.status === 'ok';
282
- stages.push({
283
- name: 'ledger_consistent',
284
- status: ledgerPassed ? 'passed' : 'failed',
285
- ...(ledgerPassed ? {} : { reason: truncateReason(`Ledger audit status=${auditResult.status}. orphanCandidates=${auditResult.orphanCandidateCount} missingLedger=${auditResult.missingLedgerCount}`) }),
286
- evidence: boundedEvidence({
287
- auditStatus: auditResult.status,
288
- consumedCount: auditResult.consumedCount,
289
- orphanCandidateCount: auditResult.orphanCandidateCount,
290
- missingLedgerCount: auditResult.missingLedgerCount,
291
- }),
292
- });
293
-
294
- if (failAfterStage === 'after_ledger_consistent') {
295
- stages.push({ name: 'internalization_queue_ready', status: 'failed', reason: 'Injected failure: forced fail after ledger_consistent' });
296
- stages.push({ name: 'canary_health', status: 'failed', reason: 'Prerequisite stage internalization_queue_ready failed' });
297
- const status = computeOverallStatus(stages);
298
- return { status, workspaceMode, generatedAt, stages, recommendedNextIssue: recommendNextIssue(stages) };
299
- }
300
-
301
- const piTaskId = `synth-dreamer-${Date.now()}`;
302
- await stateManager.createTask({
303
- taskId: piTaskId,
304
- taskKind: 'dreamer',
305
- status: 'pending',
306
- attemptCount: 0,
307
- maxAttempts: 3,
308
- diagnosticJson: createPITaskDiagnosticJson({
309
- dependencyTaskIds: [],
310
- channel: 'prompt',
311
- timeoutMs: 300_000,
312
- inputArtifactRefs: [],
313
- outputArtifactRefs: [],
314
- }),
315
- });
316
-
317
- const { readModel: queueReadModel, close: queueClose } = await createInternalizationQueueReadModel({
318
- workspaceDir,
319
- readonly: true,
320
- });
321
- try {
322
- const queueSnapshot = await queueReadModel.getSnapshot();
323
- const queueReady = queueSnapshot.readyTasks.length > 0;
324
- stages.push({
325
- name: 'internalization_queue_ready',
326
- status: queueReady ? 'passed' : 'failed',
327
- ...(queueReady ? {} : { reason: truncateReason(`Queue has no ready tasks. pendingCount=${queueSnapshot.pendingCount} noReadyTasks=${queueSnapshot.noReadyTasks?.reason ?? 'n/a'}`) }),
328
- evidence: boundedEvidence({
329
- readyCount: queueSnapshot.readyTasks.length,
330
- pendingCount: queueSnapshot.pendingCount,
331
- noReadyReason: queueSnapshot.noReadyTasks?.reason ?? null,
332
- }),
333
- });
334
- } catch (err) {
335
- stages.push({
336
- name: 'internalization_queue_ready',
337
- status: 'failed',
338
- reason: truncateReason(`Queue read model failed: ${err instanceof Error ? err.message : String(err)}`),
339
- });
340
- } finally {
341
- await queueClose();
342
- }
343
-
344
- const healthModel = new OperatorHealthReadModel({ workspaceDir });
345
- try {
346
- const healthSnapshot = await healthModel.getSnapshot();
347
- const healthPassed = healthSnapshot.overallStatus === 'healthy' || healthSnapshot.overallStatus === 'degraded';
348
- stages.push({
349
- name: 'canary_health',
350
- status: healthPassed ? 'passed' : 'failed',
351
- ...(healthPassed ? {} : { reason: truncateReason(`Operator health: ${healthSnapshot.overallStatus}. Actions: ${healthSnapshot.recommendedActions.join('; ')}`) }),
352
- evidence: boundedEvidence({
353
- overallStatus: healthSnapshot.overallStatus,
354
- recommendedActions: healthSnapshot.recommendedActions.slice(0, 3),
355
- }),
356
- });
357
- } catch (err) {
358
- stages.push({
359
- name: 'canary_health',
360
- status: 'failed',
361
- reason: truncateReason(`Health read model failed: ${err instanceof Error ? err.message : String(err)}`),
362
- });
363
- } finally {
364
- await healthModel.close();
365
- }
366
- } catch (err) {
367
- const errorMessage = err instanceof Error ? err.message : String(err);
368
- const stageNames: SyntheticBaselineStageName[] = [
369
- 'pain_intake',
370
- 'diagnostician_task_created',
371
- 'candidate_created',
372
- 'ledger_consistent',
373
- 'internalization_queue_ready',
374
- 'canary_health',
375
- ];
376
- const existingNames = new Set(stages.map(s => s.name));
377
- for (const name of stageNames) {
378
- if (!existingNames.has(name)) {
379
- stages.push({
380
- name,
381
- status: 'failed',
382
- reason: truncateReason(`Unexpected error: ${errorMessage}`),
383
- });
384
- }
385
- }
386
- } finally {
387
- if (stateManager) {
388
- await stateManager.close();
389
- }
390
- }
391
-
392
- const status = computeOverallStatus(stages);
393
- return {
394
- status,
395
- workspaceMode,
396
- generatedAt,
397
- stages,
398
- recommendedNextIssue: recommendNextIssue(stages),
399
- };
400
- }
@@ -1,253 +0,0 @@
1
- /**
2
- * Canonical version report builder (SPEC §12).
3
- *
4
- * `pd --version` prints one stable short text line; `pd version --json`
5
- * exposes the full canonical report: productVersion, releaseId, components,
6
- * bootstrapVersion, channel, source, generation, health, and the last
7
- * transaction. The canonical product identity comes from the installation
8
- * state under ~/.pd — never from a checkout's package.json.
9
- *
10
- * The record shapes here mirror the canonical contracts owned by
11
- * create-principles-disciple/src/update/ (the deep ReleaseManager module);
12
- * this reader is deliberately thin: it READS installation state and never
13
- * performs update logic.
14
- */
15
-
16
- import * as fs from 'node:fs';
17
- import * as os from 'node:os';
18
- import * as path from 'node:path';
19
-
20
- export type VersionReportSource = 'official-installer' | 'official-legacy-overlay' | 'unknown';
21
-
22
- /**
23
- * Where the component versions in a report were read from (SPEC §12, additive
24
- * field). The installed canonical runtime is the live truth
25
- * (`~/.pd/runtime/<component>/package.json`); the release cache under
26
- * `~/.pd/releases/<id>/` remains the fallback for layouts without a runtime
27
- * directory, and the legacy overlay reports its own bundle.
28
- */
29
- export type VersionComponentsSource = 'runtime' | 'release-cached' | 'legacy-overlay';
30
-
31
- export interface VersionReport {
32
- readonly productVersion: string;
33
- readonly releaseId: string;
34
- readonly components: Readonly<Record<string, string>>;
35
- /**
36
- * Which layout the component versions were read from. Additive diagnostic
37
- * ahead of the canonical SPEC §12 contract update (the authoritative copy
38
- * lives in create-principles-disciple/src/update/product-identity.ts):
39
- * optional so older consumers of this mirror stay compatible; the builder
40
- * always emits it.
41
- */
42
- readonly componentsSource?: VersionComponentsSource;
43
- readonly bootstrapVersion: string;
44
- readonly channel: 'stable' | 'candidate';
45
- readonly source: VersionReportSource;
46
- readonly generation: number;
47
- readonly health: 'healthy' | 'degraded' | 'corrupt';
48
- readonly lastTransaction: Readonly<{ id: string; kind: string; outcome: string }> | null;
49
- }
50
-
51
- export class VersionReportError extends Error {
52
- readonly reason: string;
53
- readonly nextAction: string;
54
-
55
- constructor(reason: string, message: string, nextAction: string) {
56
- super(message);
57
- this.name = 'VersionReportError';
58
- this.reason = reason;
59
- this.nextAction = nextAction;
60
- }
61
- }
62
-
63
- function isPlainObject(value: unknown): value is Record<string, unknown> {
64
- return typeof value === 'object' && value !== null && !Array.isArray(value);
65
- }
66
-
67
- function readJsonIfPresent(filePath: string): Record<string, unknown> | null {
68
- if (!fs.existsSync(filePath)) return null;
69
- let value: unknown;
70
- try {
71
- value = JSON.parse(fs.readFileSync(filePath, 'utf8')) as unknown;
72
- } catch (error) {
73
- throw new VersionReportError(
74
- 'state_corrupt',
75
- `Installation state file is not valid JSON: ${filePath} (${error instanceof Error ? error.message : String(error)})`,
76
- 'Run the official installer recovery, or re-run the official installer to repair the installation record.',
77
- );
78
- }
79
- if (!isPlainObject(value)) {
80
- throw new VersionReportError(
81
- 'state_corrupt',
82
- `Installation state file is not a JSON object: ${filePath}`,
83
- 'Run the official installer recovery, or re-run the official installer to repair the installation record.',
84
- );
85
- }
86
- return value;
87
- }
88
-
89
- /** `pd --version` short stable text contract. */
90
- export function formatShortVersion(report: Pick<VersionReport, 'productVersion' | 'releaseId'>): string {
91
- return `Principles Disciple ${report.productVersion} (${report.releaseId.slice(0, 12)})`;
92
- }
93
-
94
- function buildLegacyOverlayReport(overlayDir: string, bootstrap: Record<string, unknown> | null): VersionReport {
95
- // The current official installer copies the plugin package directly into
96
- // the OpenClaw extension root. Older overlay bundles kept it under plugin/;
97
- // accept that layout only when the canonical root manifest is absent.
98
- const rootManifest = readJsonIfPresent(path.join(overlayDir, 'package.json'));
99
- const pluginManifest = rootManifest ?? readJsonIfPresent(path.join(overlayDir, 'plugin', 'package.json'));
100
- const version = pluginManifest?.version;
101
- if (typeof version !== 'string' || version.length === 0) {
102
- throw new VersionReportError(
103
- 'legacy_overlay_manifest_invalid',
104
- `The legacy overlay at ${overlayDir} has no readable plugin version.`,
105
- 'Re-install PD with the official installer to migrate this installation into the supported layout.',
106
- );
107
- }
108
- const bootstrapVersion = bootstrap?.bootstrapVersion;
109
- return {
110
- productVersion: version,
111
- releaseId: '0'.repeat(64),
112
- components: { plugin: version },
113
- componentsSource: 'legacy-overlay',
114
- bootstrapVersion: typeof bootstrapVersion === 'string' ? bootstrapVersion : 'unknown',
115
- channel: 'stable',
116
- source: 'official-legacy-overlay',
117
- generation: 0,
118
- health: 'degraded',
119
- lastTransaction: null,
120
- };
121
- }
122
-
123
- function readLastTransaction(historyPath: string): VersionReport['lastTransaction'] {
124
- if (!fs.existsSync(historyPath)) return null;
125
- const lines = fs.readFileSync(historyPath, 'utf8').split('\n').filter((line) => line.trim().length > 0);
126
- const lastLine = lines[lines.length - 1];
127
- if (lastLine === undefined) return null;
128
- let value: unknown;
129
- try {
130
- value = JSON.parse(lastLine) as unknown;
131
- } catch (error) {
132
- throw new VersionReportError(
133
- 'state_corrupt',
134
- `The last transaction record is not valid JSON: ${historyPath} (${error instanceof Error ? error.message : String(error)})`,
135
- 'Run the official installer recovery to reconcile the transaction journal before trusting the installed version.',
136
- );
137
- }
138
- if (!isPlainObject(value)) return null;
139
- const { transactionId, kind, outcome } = value;
140
- if (typeof transactionId !== 'string' || typeof kind !== 'string' || typeof outcome !== 'string') {
141
- return null;
142
- }
143
- return { id: transactionId, kind, outcome };
144
- }
145
-
146
- /**
147
- * Builds the canonical version report from the installation state. Throws
148
- * VersionReportError with an installer next-action when no installation
149
- * exists at all.
150
- */
151
- export function buildVersionReport(homeDir: string = os.homedir()): VersionReport {
152
- const pdHome = path.join(homeDir, '.pd');
153
- const active = readJsonIfPresent(path.join(pdHome, 'active.json'));
154
- const bootstrap = readJsonIfPresent(path.join(pdHome, 'bootstrap', 'bootstrap.json'));
155
- const installConfig = readJsonIfPresent(path.join(pdHome, 'install.json'));
156
-
157
- const overlayDir = path.join(homeDir, '.openclaw', 'extensions', 'principles-disciple');
158
-
159
- if (active === null && fs.existsSync(overlayDir)) {
160
- return buildLegacyOverlayReport(overlayDir, bootstrap);
161
- }
162
- if (active === null && !fs.existsSync(pdHome)) {
163
- throw new VersionReportError(
164
- 'not_installed',
165
- 'No PD installation was found under ~/.pd or the legacy overlay location.',
166
- 'Install PD with the official installer (npx create-principles-disciple), then run pd version again.',
167
- );
168
- }
169
- if (active === null) {
170
- throw new VersionReportError(
171
- 'active_record_missing',
172
- 'The ~/.pd installation exists but has no active release record.',
173
- 'Run the official installer to complete the installation, or re-run it to repair the record.',
174
- );
175
- }
176
-
177
- const { generation, releaseId, productVersion } = active;
178
- if (typeof generation !== 'number' || !Number.isSafeInteger(generation) || generation < 1
179
- || typeof releaseId !== 'string' || releaseId.length === 0
180
- || typeof productVersion !== 'string' || productVersion.length === 0) {
181
- throw new VersionReportError(
182
- 'active_record_corrupt',
183
- 'The active release record under ~/.pd is malformed.',
184
- 'Run the official installer recovery, or re-run the official installer to repair the installation record.',
185
- );
186
- }
187
-
188
- const releaseDir = path.join(pdHome, 'releases', releaseId);
189
- const releaseManifest = readJsonIfPresent(path.join(releaseDir, 'metadata.json'));
190
- const releaseMetadataMatchesActive = releaseManifest !== null
191
- && releaseManifest.productVersion === productVersion
192
- && releaseManifest.releaseId === releaseId
193
- && releaseManifest.metadataDigest === active.releaseMetadataDigest;
194
- const health: VersionReport['health'] = releaseManifest === null
195
- ? 'degraded'
196
- : releaseMetadataMatchesActive ? 'healthy' : 'corrupt';
197
-
198
- // The live canonical runtime is the primary component-version source; the
199
- // release cache stays as the fallback for layouts without a runtime
200
- // directory (and per component when the runtime copy is absent). Component
201
- // versions are read, never judged: independently versioned components are
202
- // not corruption, and health remains bound to the active-identity
203
- // verification above (a runtime full of readable package versions alone
204
- // never makes the report healthy). A malformed component manifest degrades
205
- // to an omitted component — this command exists to diagnose broken
206
- // installs, so one corrupt manifest must not kill the whole report.
207
- const runtimeDir = path.join(pdHome, 'runtime');
208
- const componentsBaseDir = fs.existsSync(runtimeDir) ? runtimeDir : releaseDir;
209
- const componentsSource: VersionReport['componentsSource'] = componentsBaseDir === runtimeDir
210
- ? 'runtime'
211
- : 'release-cached';
212
- const readComponentManifest = (component: string): Record<string, unknown> | null => {
213
- try {
214
- return readJsonIfPresent(path.join(componentsBaseDir, component, 'package.json'));
215
- } catch {
216
- return null; // malformed live manifest: omit the component, keep the report
217
- }
218
- };
219
- const components: Record<string, string> = {};
220
- for (const component of ['plugin', 'console', 'core', 'pd-cli', 'host-runtime', 'install-layout', 'codex-adapter', 'release-manager']) {
221
- let manifest = readComponentManifest(component);
222
- if (manifest === null && componentsBaseDir === runtimeDir) {
223
- // Per-component fallback: a partially populated runtime dir (partial
224
- // sync) must not silently drop components that the release cache can
225
- // still report.
226
- try {
227
- manifest = readJsonIfPresent(path.join(releaseDir, component, 'package.json'));
228
- } catch {
229
- manifest = null;
230
- }
231
- }
232
- const version = manifest?.version;
233
- if (typeof version === 'string') {
234
- components[component] = version;
235
- }
236
- }
237
-
238
- const bootstrapVersion = bootstrap?.bootstrapVersion;
239
- const channelValue = installConfig?.channel;
240
-
241
- return {
242
- productVersion,
243
- releaseId,
244
- components,
245
- componentsSource,
246
- bootstrapVersion: typeof bootstrapVersion === 'string' ? bootstrapVersion : 'unknown',
247
- channel: channelValue === 'candidate' ? 'candidate' : 'stable',
248
- source: 'official-installer',
249
- generation,
250
- health,
251
- lastTransaction: readLastTransaction(path.join(pdHome, 'logs', 'history.jsonl')),
252
- };
253
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * Workspace Tool Semantics Resolution — PRI-634-F R2 (review P1-2), R3
3
- * (SPEC §五 P1-1): thin delegation to the ONE host-runtime resolver so CLI,
4
- * Console, and any future entry point share the same multi-host
5
- * load/merge/validate/resolve path. The CLI refusal policy (code_tool_hook
6
- * refuses when unresolvable — no host guessing, no silent skip) stays here.
7
- */
8
-
9
- import type { ToolSemanticRegistry } from '@principles/core/runtime-v2';
10
- import { resolveWorkspaceHostToolSemantics } from '@principles/host-runtime';
11
-
12
- export type WorkspaceToolSemanticsResolution =
13
- | { readonly ok: true; readonly registry: ToolSemanticRegistry; readonly hostKind: string }
14
- | { readonly ok: false; readonly reason: string; readonly nextAction: string };
15
-
16
- export function resolveWorkspaceToolSemantics(workspaceDir: string): WorkspaceToolSemanticsResolution {
17
- const resolved = resolveWorkspaceHostToolSemantics(workspaceDir);
18
- if (!resolved.ok) {
19
- return { ok: false, reason: resolved.reason, nextAction: resolved.nextAction };
20
- }
21
- return {
22
- ok: true,
23
- registry: resolved.registry,
24
- hostKind: resolved.hostKinds.join('+'),
25
- };
26
- }