create-principles-disciple 1.144.27 → 1.145.1

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 (347) hide show
  1. package/LICENSE +73 -21
  2. package/NOTICE +2 -0
  3. package/README.md +1 -1
  4. package/_release/product-identity.json +2 -2
  5. package/codex-adapter/dist/index.d.ts +2 -2
  6. package/codex-adapter/dist/index.js +1 -1
  7. package/codex-adapter/dist/ingestion/admission.js +16 -0
  8. package/codex-adapter/dist/ingestion/codex-version.d.ts +10 -4
  9. package/codex-adapter/dist/ingestion/codex-version.js +10 -4
  10. package/codex-adapter/dist/ingestion/explicit-owner-statement.d.ts +48 -0
  11. package/codex-adapter/dist/ingestion/explicit-owner-statement.js +123 -0
  12. package/codex-adapter/dist/ingestion/ingestion.js +50 -1
  13. package/codex-adapter/dist/pd-hook.js +66 -3
  14. package/codex-adapter/dist/worker/workspace-worker.d.ts +14 -0
  15. package/codex-adapter/dist/worker/workspace-worker.js +194 -11
  16. package/codex-adapter/package.json +6 -4
  17. package/console/dist/server/models/ApprovalsConsoleModel.d.ts +2 -2
  18. package/console/dist/server/models/ApprovalsConsoleModel.js +1 -1
  19. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +1 -1
  20. package/console/dist/server/models/PrinciplesConsoleModel.d.ts +26 -1
  21. package/console/dist/server/models/PrinciplesConsoleModel.js +18 -1
  22. package/console/dist/server/routes/activations.js +4 -4
  23. package/console/dist/server/routes/approvals.js +2 -2
  24. package/console/dist/server/routes/failed-tasks.d.ts +9 -0
  25. package/console/dist/server/routes/failed-tasks.js +116 -7
  26. package/console/dist/server/routes/principles.js +73 -1
  27. package/console/dist/shared/prompt-injection-contract.d.ts +1 -1
  28. package/console/dist/ui/api.d.ts +5 -5
  29. package/console/dist/ui/i18n/en.json +13 -2
  30. package/console/dist/ui/i18n/zh-CN.json +13 -2
  31. package/console/dist/ui/pages/activation/ActivationPage.js +2 -1
  32. package/console/dist/ui/pages/failed-tasks/FailedTasksPage.js +42 -4
  33. package/console/dist/ui/pages/focus/FocusPage.js +3 -3
  34. package/console/dist/ui/pages/principles/PrinciplesPage.js +7 -2
  35. package/console/dist/ui/utils/validators.d.ts +6 -2
  36. package/console/dist/ui/utils/validators.js +19 -4
  37. package/console/dist/web/assets/app.css +26 -0
  38. package/console/dist/web/assets/app.js +24 -24
  39. package/console/package.json +6 -5
  40. package/core/dist/host/host-installer.d.ts +3 -1
  41. package/core/dist/host/host-installer.d.ts.map +1 -1
  42. package/core/dist/host/host-installer.js.map +1 -1
  43. package/core/dist/runtime-v2/admission-gate.d.ts +8 -0
  44. package/core/dist/runtime-v2/admission-gate.d.ts.map +1 -1
  45. package/core/dist/runtime-v2/admission-gate.js +3 -2
  46. package/core/dist/runtime-v2/admission-gate.js.map +1 -1
  47. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  48. package/core/dist/runtime-v2/config/pd-config-defaults.js +16 -1
  49. package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  50. package/core/dist/runtime-v2/context-payload.d.ts +43 -3
  51. package/core/dist/runtime-v2/context-payload.d.ts.map +1 -1
  52. package/core/dist/runtime-v2/context-payload.js +15 -1
  53. package/core/dist/runtime-v2/context-payload.js.map +1 -1
  54. package/core/dist/runtime-v2/evidence-guards.d.ts +6 -0
  55. package/core/dist/runtime-v2/evidence-guards.d.ts.map +1 -1
  56. package/core/dist/runtime-v2/evidence-guards.js +11 -0
  57. package/core/dist/runtime-v2/evidence-guards.js.map +1 -1
  58. package/core/dist/runtime-v2/evolution/evolution-types.d.ts +4 -4
  59. package/core/dist/runtime-v2/evolution/evolution-types.d.ts.map +1 -1
  60. package/core/dist/runtime-v2/evolution/evolution-types.js +1 -1
  61. package/core/dist/runtime-v2/evolution/evolution-types.js.map +1 -1
  62. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  63. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +6 -0
  64. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  65. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  66. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js +8 -0
  67. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js.map +1 -1
  68. package/core/dist/runtime-v2/index.d.ts +5 -2
  69. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  70. package/core/dist/runtime-v2/index.js +3 -1
  71. package/core/dist/runtime-v2/index.js.map +1 -1
  72. package/core/dist/runtime-v2/internalization/evaluator-output.d.ts +11 -0
  73. package/core/dist/runtime-v2/internalization/evaluator-output.d.ts.map +1 -1
  74. package/core/dist/runtime-v2/internalization/evaluator-output.js +10 -0
  75. package/core/dist/runtime-v2/internalization/evaluator-output.js.map +1 -1
  76. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +3 -3
  77. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  78. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js +49 -5
  79. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
  80. package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  81. package/core/dist/runtime-v2/internalization/evaluator-runner.js +13 -16
  82. package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  83. package/core/dist/runtime-v2/internalization/owner-decision-review.d.ts.map +1 -1
  84. package/core/dist/runtime-v2/internalization/owner-decision-review.js +5 -1
  85. package/core/dist/runtime-v2/internalization/owner-decision-review.js.map +1 -1
  86. package/core/dist/runtime-v2/internalization/owner-review.d.ts +2 -2
  87. package/core/dist/runtime-v2/internalization/owner-review.js +2 -2
  88. package/core/dist/runtime-v2/internalization/scribe-output.d.ts +12 -0
  89. package/core/dist/runtime-v2/internalization/scribe-output.d.ts.map +1 -1
  90. package/core/dist/runtime-v2/internalization/scribe-output.js +20 -0
  91. package/core/dist/runtime-v2/internalization/scribe-output.js.map +1 -1
  92. package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts +32 -1
  93. package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
  94. package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js +38 -1
  95. package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
  96. package/core/dist/runtime-v2/internalization-queue-read-model.d.ts +6 -0
  97. package/core/dist/runtime-v2/internalization-queue-read-model.d.ts.map +1 -1
  98. package/core/dist/runtime-v2/internalization-queue-read-model.js +8 -1
  99. package/core/dist/runtime-v2/internalization-queue-read-model.js.map +1 -1
  100. package/core/dist/runtime-v2/intervention-evidence-normalizer.d.ts.map +1 -1
  101. package/core/dist/runtime-v2/intervention-evidence-normalizer.js +10 -3
  102. package/core/dist/runtime-v2/intervention-evidence-normalizer.js.map +1 -1
  103. package/core/dist/runtime-v2/pain-ingress.d.ts +1 -1
  104. package/core/dist/runtime-v2/pain-ingress.d.ts.map +1 -1
  105. package/core/dist/runtime-v2/pain-signal-bridge.d.ts +68 -2
  106. package/core/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
  107. package/core/dist/runtime-v2/pain-signal-bridge.js +541 -18
  108. package/core/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
  109. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  110. package/core/dist/runtime-v2/pain-signal-runtime-factory.js +4 -0
  111. package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  112. package/core/dist/runtime-v2/product-telemetry/snapshot-contract.d.ts +2 -2
  113. package/core/dist/runtime-v2/product-telemetry/snapshot-contract.d.ts.map +1 -1
  114. package/core/dist/runtime-v2/product-telemetry/snapshot-contract.js +2 -2
  115. package/core/dist/runtime-v2/product-telemetry/snapshot-contract.js.map +1 -1
  116. package/core/dist/runtime-v2/store/candidate/admission-document.d.ts +90 -0
  117. package/core/dist/runtime-v2/store/candidate/admission-document.d.ts.map +1 -0
  118. package/core/dist/runtime-v2/store/candidate/admission-document.js +142 -0
  119. package/core/dist/runtime-v2/store/candidate/admission-document.js.map +1 -0
  120. package/core/dist/runtime-v2/store/candidate/candidate-store.d.ts +53 -0
  121. package/core/dist/runtime-v2/store/candidate/candidate-store.d.ts.map +1 -1
  122. package/core/dist/runtime-v2/store/candidate/memory-candidate-store.d.ts +35 -0
  123. package/core/dist/runtime-v2/store/candidate/memory-candidate-store.d.ts.map +1 -1
  124. package/core/dist/runtime-v2/store/candidate/memory-candidate-store.js +48 -0
  125. package/core/dist/runtime-v2/store/candidate/memory-candidate-store.js.map +1 -1
  126. package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.d.ts +44 -0
  127. package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.d.ts.map +1 -1
  128. package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.js +136 -0
  129. package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.js.map +1 -1
  130. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.js.map +1 -1
  131. package/core/dist/runtime-v2/store/intervention-evidence-schema.js +1 -1
  132. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts +65 -0
  133. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
  134. package/core/dist/runtime-v2/store/runtime-state-manager.js +46 -0
  135. package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
  136. package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
  137. package/core/dist/runtime-v2/store/sqlite-connection.js +42 -0
  138. package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
  139. package/core/dist/runtime-v2/store/sqlite-intervention-evidence-store.d.ts +1 -1
  140. package/core/dist/runtime-v2/store/sqlite-intervention-evidence-store.d.ts.map +1 -1
  141. package/core/dist/runtime-v2/store/sqlite-intervention-evidence-store.js.map +1 -1
  142. package/core/dist/runtime-v2/store/task/sqlite-family-reopen.d.ts +19 -0
  143. package/core/dist/runtime-v2/store/task/sqlite-family-reopen.d.ts.map +1 -0
  144. package/core/dist/runtime-v2/store/task/sqlite-family-reopen.js +36 -0
  145. package/core/dist/runtime-v2/store/task/sqlite-family-reopen.js.map +1 -0
  146. package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts +23 -0
  147. package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts.map +1 -1
  148. package/core/dist/runtime-v2/store/task/sqlite-task-store.js +50 -0
  149. package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
  150. package/core/dist/runtime-v2/task-status.d.ts +3 -1
  151. package/core/dist/runtime-v2/task-status.d.ts.map +1 -1
  152. package/core/dist/runtime-v2/task-status.js +1 -1
  153. package/core/dist/runtime-v2/task-status.js.map +1 -1
  154. package/core/dist/runtime-v2/trajectory-schema.d.ts.map +1 -1
  155. package/core/dist/runtime-v2/trajectory-schema.js +11 -0
  156. package/core/dist/runtime-v2/trajectory-schema.js.map +1 -1
  157. package/core/dist/runtime-v2/types/event-types.d.ts +2 -2
  158. package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  159. package/core/dist/runtime-v2/types/event-types.js +1 -1
  160. package/core/dist/runtime-v2/types/event-types.js.map +1 -1
  161. package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts +1 -1
  162. package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts.map +1 -1
  163. package/core/dist/runtime-v2/types/evidence-chain-contract.js +2 -2
  164. package/core/dist/runtime-v2/types/evidence-chain-contract.js.map +1 -1
  165. package/core/dist/runtime-v2/types/intervention-evidence-contract.d.ts +3 -3
  166. package/core/dist/runtime-v2/types/intervention-evidence-contract.d.ts.map +1 -1
  167. package/core/dist/runtime-v2/types/intervention-evidence-contract.js +1 -0
  168. package/core/dist/runtime-v2/types/intervention-evidence-contract.js.map +1 -1
  169. package/core/dist/telemetry-event.d.ts +2 -2
  170. package/core/dist/telemetry-event.d.ts.map +1 -1
  171. package/core/dist/telemetry-event.js +4 -0
  172. package/core/dist/telemetry-event.js.map +1 -1
  173. package/core/dist/trajectory-types.d.ts +2 -2
  174. package/core/dist/trajectory-types.d.ts.map +1 -1
  175. package/core/package.json +7 -5
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +84 -8
  178. package/dist/index.js.map +1 -1
  179. package/dist/installer.d.ts +42 -11
  180. package/dist/installer.d.ts.map +1 -1
  181. package/dist/installer.js +140 -36
  182. package/dist/installer.js.map +1 -1
  183. package/dist/installers/index.d.ts +18 -7
  184. package/dist/installers/index.d.ts.map +1 -1
  185. package/dist/installers/index.js +13 -4
  186. package/dist/installers/index.js.map +1 -1
  187. package/dist/installers/workbuddy-host-installer.d.ts +246 -0
  188. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -0
  189. package/dist/installers/workbuddy-host-installer.js +1419 -0
  190. package/dist/installers/workbuddy-host-installer.js.map +1 -0
  191. package/dist/mvp-config.d.ts +24 -0
  192. package/dist/mvp-config.d.ts.map +1 -1
  193. package/dist/mvp-config.js +36 -0
  194. package/dist/mvp-config.js.map +1 -1
  195. package/dist/prompts.d.ts +13 -0
  196. package/dist/prompts.d.ts.map +1 -1
  197. package/dist/prompts.js +45 -8
  198. package/dist/prompts.js.map +1 -1
  199. package/dist/uninstaller.d.ts +1 -1
  200. package/dist/uninstaller.d.ts.map +1 -1
  201. package/dist/uninstaller.js +29 -4
  202. package/dist/uninstaller.js.map +1 -1
  203. package/host-runtime/dist/governance-signal-admission.d.ts +63 -0
  204. package/host-runtime/dist/governance-signal-admission.js +322 -53
  205. package/host-runtime/dist/host-liveness-contract.js +7 -1
  206. package/host-runtime/dist/index.d.ts +1 -0
  207. package/host-runtime/dist/index.js +5 -1
  208. package/host-runtime/dist/internalization-consumer-cycle.d.ts +12 -0
  209. package/host-runtime/dist/internalization-consumer-cycle.js +43 -1
  210. package/host-runtime/dist/intervention-evidence-ingress.d.ts +1 -1
  211. package/host-runtime/dist/product-telemetry/service.js +1 -1
  212. package/host-runtime/dist/production-pain-evidence.d.ts +59 -1
  213. package/host-runtime/dist/production-pain-evidence.js +200 -17
  214. package/host-runtime/dist/prompt-activation-deliverability.js +5 -4
  215. package/host-runtime/dist/prompt-injection-event-evidence.d.ts +1 -1
  216. package/host-runtime/dist/prompt-injection-event-evidence.js +5 -1
  217. package/host-runtime/dist/prompt-injection-projection.d.ts +14 -5
  218. package/host-runtime/dist/prompt-injection-projection.js +30 -16
  219. package/host-runtime/dist/workbuddy-worker-status.d.ts +24 -0
  220. package/host-runtime/dist/workbuddy-worker-status.js +52 -0
  221. package/host-runtime/package.json +7 -5
  222. package/install-layout/dist/index.d.ts +18 -1
  223. package/install-layout/dist/index.js +15 -2
  224. package/install-layout/package.json +5 -3
  225. package/package.json +9 -7
  226. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  227. package/pd-cli/dist/commands/candidate.js +44 -4
  228. package/pd-cli/dist/commands/candidate.js.map +1 -1
  229. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  230. package/pd-cli/dist/commands/codex-worker.js +30 -1
  231. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  232. package/pd-cli/dist/commands/config-doctor.d.ts.map +1 -1
  233. package/pd-cli/dist/commands/config-doctor.js +19 -4
  234. package/pd-cli/dist/commands/config-doctor.js.map +1 -1
  235. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  236. package/pd-cli/dist/commands/diagnose.js +4 -1
  237. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  238. package/pd-cli/dist/commands/health-codex-install.d.ts +85 -0
  239. package/pd-cli/dist/commands/health-codex-install.d.ts.map +1 -0
  240. package/pd-cli/dist/commands/health-codex-install.js +207 -0
  241. package/pd-cli/dist/commands/health-codex-install.js.map +1 -0
  242. package/pd-cli/dist/commands/health-codex.d.ts.map +1 -1
  243. package/pd-cli/dist/commands/health-codex.js +78 -0
  244. package/pd-cli/dist/commands/health-codex.js.map +1 -1
  245. package/pd-cli/dist/commands/pain-list.d.ts +3 -2
  246. package/pd-cli/dist/commands/pain-list.d.ts.map +1 -1
  247. package/pd-cli/dist/commands/pain-list.js +10 -10
  248. package/pd-cli/dist/commands/pain-list.js.map +1 -1
  249. package/pd-cli/dist/commands/pain-record.d.ts +2 -0
  250. package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
  251. package/pd-cli/dist/commands/pain-record.js +36 -0
  252. package/pd-cli/dist/commands/pain-record.js.map +1 -1
  253. package/pd-cli/dist/commands/pain-retry.d.ts +6 -0
  254. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  255. package/pd-cli/dist/commands/pain-retry.js +152 -5
  256. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  257. package/pd-cli/dist/commands/runtime-activation.d.ts +1 -1
  258. package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
  259. package/pd-cli/dist/commands/runtime-activation.js +3 -3
  260. package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
  261. package/pd-cli/dist/commands/workbuddy-worker.d.ts +19 -0
  262. package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -0
  263. package/pd-cli/dist/commands/workbuddy-worker.js +168 -0
  264. package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -0
  265. package/pd-cli/dist/index.js +29 -1
  266. package/pd-cli/dist/index.js.map +1 -1
  267. package/pd-cli/dist/resolve-workspace.d.ts +14 -2
  268. package/pd-cli/dist/resolve-workspace.d.ts.map +1 -1
  269. package/pd-cli/dist/resolve-workspace.js +88 -21
  270. package/pd-cli/dist/resolve-workspace.js.map +1 -1
  271. package/pd-cli/dist/services/admission-write-gate.d.ts +24 -0
  272. package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -0
  273. package/pd-cli/dist/services/admission-write-gate.js +41 -0
  274. package/pd-cli/dist/services/admission-write-gate.js.map +1 -0
  275. package/pd-cli/dist/services/pd-config-loader.d.ts +39 -7
  276. package/pd-cli/dist/services/pd-config-loader.d.ts.map +1 -1
  277. package/pd-cli/dist/services/pd-config-loader.js +111 -18
  278. package/pd-cli/dist/services/pd-config-loader.js.map +1 -1
  279. package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts +10 -0
  280. package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
  281. package/pd-cli/dist/services/rulehost-pipeline-runner.js +59 -4
  282. package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
  283. package/pd-cli/package.json +8 -5
  284. package/plugin/dist/bundle.js +564 -509
  285. package/plugin/dist/governance-audit.js +1 -1
  286. package/plugin/dist/openclaw.plugin.json +1 -1
  287. package/plugin/dist/rulehost-evidence.js +1 -1
  288. package/plugin/openclaw.plugin.json +1 -1
  289. package/plugin/package.json +7 -5
  290. package/release-manager/dist/index.d.ts.map +1 -1
  291. package/release-manager/dist/index.js +84 -8
  292. package/release-manager/dist/index.js.map +1 -1
  293. package/release-manager/dist/installer.d.ts +42 -11
  294. package/release-manager/dist/installer.d.ts.map +1 -1
  295. package/release-manager/dist/installer.js +140 -36
  296. package/release-manager/dist/installer.js.map +1 -1
  297. package/release-manager/dist/installers/index.d.ts +18 -7
  298. package/release-manager/dist/installers/index.d.ts.map +1 -1
  299. package/release-manager/dist/installers/index.js +13 -4
  300. package/release-manager/dist/installers/index.js.map +1 -1
  301. package/release-manager/dist/installers/workbuddy-host-installer.d.ts +246 -0
  302. package/release-manager/dist/installers/workbuddy-host-installer.d.ts.map +1 -0
  303. package/release-manager/dist/installers/workbuddy-host-installer.js +1419 -0
  304. package/release-manager/dist/installers/workbuddy-host-installer.js.map +1 -0
  305. package/release-manager/dist/mvp-config.d.ts +24 -0
  306. package/release-manager/dist/mvp-config.d.ts.map +1 -1
  307. package/release-manager/dist/mvp-config.js +36 -0
  308. package/release-manager/dist/mvp-config.js.map +1 -1
  309. package/release-manager/dist/prompts.d.ts +13 -0
  310. package/release-manager/dist/prompts.d.ts.map +1 -1
  311. package/release-manager/dist/prompts.js +45 -8
  312. package/release-manager/dist/prompts.js.map +1 -1
  313. package/release-manager/dist/uninstaller.d.ts +1 -1
  314. package/release-manager/dist/uninstaller.d.ts.map +1 -1
  315. package/release-manager/dist/uninstaller.js +29 -4
  316. package/release-manager/dist/uninstaller.js.map +1 -1
  317. package/release-manager/package.json +8 -6
  318. package/workbuddy-adapter/dist/codec/index.d.ts +2 -0
  319. package/workbuddy-adapter/dist/codec/index.js +2 -0
  320. package/workbuddy-adapter/dist/codec/input-decoder.d.ts +30 -0
  321. package/workbuddy-adapter/dist/codec/input-decoder.js +232 -0
  322. package/workbuddy-adapter/dist/codec/output-encoder.d.ts +62 -0
  323. package/workbuddy-adapter/dist/codec/output-encoder.js +75 -0
  324. package/workbuddy-adapter/dist/host-adapter.d.ts +33 -0
  325. package/workbuddy-adapter/dist/host-adapter.js +23 -0
  326. package/workbuddy-adapter/dist/index.d.ts +16 -0
  327. package/workbuddy-adapter/dist/index.js +16 -0
  328. package/workbuddy-adapter/dist/pd-hook.d.ts +17 -0
  329. package/workbuddy-adapter/dist/pd-hook.js +505 -0
  330. package/workbuddy-adapter/dist/tool-semantics.d.ts +22 -0
  331. package/workbuddy-adapter/dist/tool-semantics.js +33 -0
  332. package/workbuddy-adapter/dist/workbuddy-evidence-recorder.d.ts +50 -0
  333. package/workbuddy-adapter/dist/workbuddy-evidence-recorder.js +238 -0
  334. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +41 -0
  335. package/workbuddy-adapter/dist/worker/workspace-worker.js +219 -0
  336. package/workbuddy-adapter/dist/workspace-resolution.d.ts +15 -0
  337. package/workbuddy-adapter/dist/workspace-resolution.js +53 -0
  338. package/workbuddy-adapter/package.json +64 -0
  339. package/workbuddy-adapter/plugin/.codebuddy-plugin/plugin.json +6 -0
  340. package/workbuddy-adapter/plugin/hooks/hooks.json +62 -0
  341. package/workbuddy-adapter/plugin/scripts/wrapper.cjs +79 -0
  342. package/console/dist/ui/utils/navigation.d.ts +0 -9
  343. package/console/dist/ui/utils/navigation.js +0 -7
  344. package/core/dist/runtime-v2/internalization/dimension-coverage-policy.d.ts +0 -54
  345. package/core/dist/runtime-v2/internalization/dimension-coverage-policy.d.ts.map +0 -1
  346. package/core/dist/runtime-v2/internalization/dimension-coverage-policy.js +0 -70
  347. package/core/dist/runtime-v2/internalization/dimension-coverage-policy.js.map +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,73 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Principles Disciple Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
42
+
43
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ APPENDIX: How to apply the Apache License to your work.
58
+
59
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
+
61
+ Copyright [yyyy] [name of copyright owner]
62
+
63
+ Licensed under the Apache License, Version 2.0 (the "License");
64
+ you may not use this file except in compliance with the License.
65
+ You may obtain a copy of the License at
66
+
67
+ http://www.apache.org/licenses/LICENSE-2.0
68
+
69
+ Unless required by applicable law or agreed to in writing, software
70
+ distributed under the License is distributed on an "AS IS" BASIS,
71
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72
+ See the License for the specific language governing permissions and
73
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ Principles Disciple
2
+ Copyright 2026 Principles Disciple Contributors
package/README.md CHANGED
@@ -142,4 +142,4 @@ PR feedback uses the single-target `.github/workflows/release-reproducibility.ym
142
142
 
143
143
  ## License
144
144
 
145
- MIT
145
+ Apache-2.0
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "productVersion": "2.3.2",
4
- "sourceCommit": "fc8836357dee5d465202e91dd062f330b0b61e53"
3
+ "productVersion": "2.3.4",
4
+ "sourceCommit": "ae30cf7b3b0db20c2dc409fd0f45b6a351267221"
5
5
  }
@@ -21,5 +21,5 @@ export { catchUpCodexIngestion, CODEX_CATCH_UP_NEXT_ACTION } from './ingestion/c
21
21
  export type { CodexCatchUpOptions, CodexCatchUpResult, CodexCatchUpRolloutResult } from './ingestion/catch-up.js';
22
22
  export { locateCodexTranscriptByRolloutIdentity } from './ingestion/transcript-locate.js';
23
23
  export type { CodexTranscriptLookup } from './ingestion/transcript-locate.js';
24
- export { runCodexWorkspaceWorkerCycle, computeCodexWorkerStatusMode } from './worker/workspace-worker.js';
25
- export type { CodexWorkerMode, CodexWorkerCycleResult, CodexWorkerCycleStepReport, CodexWorkerCycleOptions, CodexWorkerStatusEvaluation } from './worker/workspace-worker.js';
24
+ export { runCodexWorkspaceWorkerCycle, computeCodexWorkerStatusMode, readCodexWorkerLiveness } from './worker/workspace-worker.js';
25
+ export type { CodexWorkerMode, CodexWorkerCycleResult, CodexWorkerCycleStepReport, CodexWorkerCycleOptions, CodexWorkerStatusEvaluation, CodexWorkerPostProcessingReport } from './worker/workspace-worker.js';
@@ -16,4 +16,4 @@ export { decodeTranscriptWindow, createNodeTranscriptPort, TranscriptReplacedErr
16
16
  // PRI-624 Slice C: bounded catch-up + per-workspace worker cycle.
17
17
  export { catchUpCodexIngestion, CODEX_CATCH_UP_NEXT_ACTION } from './ingestion/catch-up.js';
18
18
  export { locateCodexTranscriptByRolloutIdentity } from './ingestion/transcript-locate.js';
19
- export { runCodexWorkspaceWorkerCycle, computeCodexWorkerStatusMode } from './worker/workspace-worker.js';
19
+ export { runCodexWorkspaceWorkerCycle, computeCodexWorkerStatusMode, readCodexWorkerLiveness } from './worker/workspace-worker.js';
@@ -47,6 +47,15 @@ export function buildLiveToolCandidate(args) {
47
47
  hostTurnId: fields.turnId,
48
48
  toolName: fields.toolName ?? '',
49
49
  source: CODEX_POST_TOOL_USE_SOURCE,
50
+ // Merge semantics (WorkBuddy × SPEC-CODEX-PAIN-CLOSURE-001): the same host
51
+ // `tool_use_id` feeds TWO consumers, so the candidate carries both views.
52
+ // I1 identity parity — the live handler derives the canonical pain from the
53
+ // same tool_use_id, so `toolCallId` must be present (one real call → one
54
+ // canonical pain across the admission + dispatch deliveries).
55
+ toolCallId: fields.toolUseId,
56
+ // CR-01 — `toolUseId` is recorded into tool_calls.tool_use_id and used for
57
+ // the admission dedup join against the live PostToolUse row.
58
+ toolUseId: fields.toolUseId,
50
59
  ...(fields.toolInput !== undefined ? { toolInput: fields.toolInput } : {}),
51
60
  ...(fields.toolResponse !== undefined ? { toolOutput: fields.toolResponse } : {}),
52
61
  observedAt: new Date().toISOString(),
@@ -90,6 +99,13 @@ export function buildTranscriptCandidates(observations) {
90
99
  hostTurnId: observation.hostTurnId,
91
100
  toolName: typeof toolName === 'string' ? toolName : '',
92
101
  source: CODEX_POST_TOOL_USE_SOURCE,
102
+ // Merge semantics: both merged views of the same host tool_use_id.
103
+ // I1 identity parity — the decoded observation carries the same
104
+ // tool_use_id the live delivery derived its canonical pain from, so a
105
+ // transcript replay converges on that pain instead of a second one.
106
+ ...(typeof observation.toolUseId === 'string' && observation.toolUseId.length > 0 ? { toolCallId: observation.toolUseId } : {}),
107
+ // CR-01 — recorded into tool_calls.tool_use_id for the dedup join.
108
+ ...(observation.toolUseId !== undefined ? { toolUseId: observation.toolUseId } : {}),
93
109
  toolInput: own(facts, 'command') ?? null,
94
110
  ...(exitCode !== undefined ? { toolOutput: { exitCode, stdout: own(facts, 'stdout') ?? null, stderr: own(facts, 'stderr') ?? null } } : {}),
95
111
  observedAt: observation.observedAt,
@@ -3,9 +3,15 @@
3
3
  * Slice A; ADR-0020 §11.2 + G1 probe report §9).
4
4
  *
5
5
  * The G1 contract baseline is: minimum supported Codex 0.148.0, verified
6
- * on-device at 0.150.1. The transcript itself carries `session_meta.
7
- * payload.cli_version`, which is the version signal available inside a hook
8
- * subprocess (hook payloads carry no version field — G1 fixture contract).
6
+ * on-device at 0.150.1 and re-verified at 0.162.1 (PRI-953, 2026-10-13:
7
+ * on-device probe against real codex-cli 0.162.1 — 125/125 captured hook
8
+ * payloads decode, 8/8 real rollout transcripts ingest with only designed
9
+ * unknown-record-type skips; sanitized fixtures:
10
+ * tests/fixtures/g1-contract/hook-payloads/v0.162.1/ and
11
+ * transcripts/v0.162.1-tool-final-turn.jsonl). The transcript itself carries
12
+ * `session_meta.payload.cli_version`, which is the version signal available
13
+ * inside a hook subprocess (hook payloads carry no version field — G1
14
+ * fixture contract).
9
15
  *
10
16
  * Older-than-minimum and newer-than-verified versions both degrade
11
17
  * explicitly; an unknown version must never silently guess record fields.
@@ -13,7 +19,7 @@
13
19
  * refreshing the fixtures (G1 report §9 drift-detection boundary).
14
20
  */
15
21
  export declare const CODEX_INGESTION_MIN_VERSION = "0.148.0";
16
- export declare const CODEX_INGESTION_VERIFIED_VERSION = "0.150.1";
22
+ export declare const CODEX_INGESTION_VERIFIED_VERSION = "0.162.1";
17
23
  export type CodexVersionClassification = {
18
24
  status: 'supported';
19
25
  } | {
@@ -3,9 +3,15 @@
3
3
  * Slice A; ADR-0020 §11.2 + G1 probe report §9).
4
4
  *
5
5
  * The G1 contract baseline is: minimum supported Codex 0.148.0, verified
6
- * on-device at 0.150.1. The transcript itself carries `session_meta.
7
- * payload.cli_version`, which is the version signal available inside a hook
8
- * subprocess (hook payloads carry no version field — G1 fixture contract).
6
+ * on-device at 0.150.1 and re-verified at 0.162.1 (PRI-953, 2026-10-13:
7
+ * on-device probe against real codex-cli 0.162.1 — 125/125 captured hook
8
+ * payloads decode, 8/8 real rollout transcripts ingest with only designed
9
+ * unknown-record-type skips; sanitized fixtures:
10
+ * tests/fixtures/g1-contract/hook-payloads/v0.162.1/ and
11
+ * transcripts/v0.162.1-tool-final-turn.jsonl). The transcript itself carries
12
+ * `session_meta.payload.cli_version`, which is the version signal available
13
+ * inside a hook subprocess (hook payloads carry no version field — G1
14
+ * fixture contract).
9
15
  *
10
16
  * Older-than-minimum and newer-than-verified versions both degrade
11
17
  * explicitly; an unknown version must never silently guess record fields.
@@ -13,7 +19,7 @@
13
19
  * refreshing the fixtures (G1 report §9 drift-detection boundary).
14
20
  */
15
21
  export const CODEX_INGESTION_MIN_VERSION = '0.148.0';
16
- export const CODEX_INGESTION_VERIFIED_VERSION = '0.150.1';
22
+ export const CODEX_INGESTION_VERIFIED_VERSION = '0.162.1';
17
23
  export const CODEX_VERSION_NEXT_ACTION = 'rerun the Codex contract probe / update supported fixtures (docs/architecture/CODEX_G1_CONTRACT_PROBE_REPORT.md §9)';
18
24
  function isDigits(value) {
19
25
  return value.length > 0 && /^[0-9]+$/.test(value);
@@ -0,0 +1,48 @@
1
+ /** The exact prefix (fullwidth colon) defined by SPEC §6.4. */
2
+ export declare const CODEX_OWNER_STATEMENT_PREFIX = "PD\u8BB0\u5F55\u75DB\u82E6\uFF1A";
3
+ /** SPEC §6.1: reject instead of truncating the Owner's intent. */
4
+ export declare const MAX_OWNER_STATEMENT_CHARS = 500;
5
+ export type OwnerStatementPrefixParse = {
6
+ matched: false;
7
+ } | {
8
+ matched: true;
9
+ text: string | null;
10
+ reason?: 'statement_empty' | 'statement_too_long';
11
+ };
12
+ /**
13
+ * Deterministic prefix parse of the CURRENT user prompt. `text === null` means
14
+ * the prefix matched but the remainder was empty/blank — an explicit request
15
+ * with no content is a bounded rejection, never a fabricated statement.
16
+ */
17
+ export declare function parseOwnerStatementPrefix(prompt: unknown): OwnerStatementPrefixParse;
18
+ export type RecordOwnerStatementResult = {
19
+ status: 'received';
20
+ painId: string;
21
+ taskId: string;
22
+ disposition: 'admitted' | 'already_admitted';
23
+ logicalObservationKey: string;
24
+ /**
25
+ * SPEC §6.4.5: the durable task is what the receipt guarantees; evidence
26
+ * promotion may degrade (e.g. conversation ingestion off — no ingested
27
+ * rollout to promote from). The receipt discloses it instead of failing.
28
+ */
29
+ promotionDegraded?: string;
30
+ } | {
31
+ status: 'rejected';
32
+ reason: 'statement_empty' | 'statement_too_long' | 'transcript_unavailable' | 'lineage_invalid' | 'rate_limited' | 'continuation_failed';
33
+ nextAction: string;
34
+ };
35
+ /**
36
+ * Persist one explicit Owner statement. The consent-gated conversation
37
+ * ingestion flag does NOT gate this path (no conversation tables or transcript
38
+ * CONTENT are read — only the path is validated for the rollout identity),
39
+ * mirroring SPEC §6.4 rule 3.
40
+ */
41
+ export declare function recordExplicitOwnerStatement(args: {
42
+ rawPayload: unknown;
43
+ workspaceDir: string;
44
+ statementText: string;
45
+ env?: {
46
+ CODEX_HOME?: string | undefined;
47
+ };
48
+ }): Promise<RecordOwnerStatementResult>;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * SPEC-CODEX-PAIN-CLOSURE-001 CR-07 — the explicit Owner pain-report entry
3
+ * for Codex: the user types `PD记录痛苦:<反馈原文>` as the CURRENT message
4
+ * and this deterministic prefix parse turns exactly that text into one
5
+ * canonical pain signal through the existing governance admission +
6
+ * diagnostician-task continuation seams.
7
+ *
8
+ * Contract (SPEC §6.4):
9
+ * - ONLY an exact prefix match at the start of the CURRENT user prompt
10
+ * counts. Quoted text, tool output, model prose and ordinary corrections
11
+ * never trigger it (A17).
12
+ * - The statement is bounded at 500 chars (rejection, not truncation).
13
+ * - Identity comes from THIS hook payload's verified session/turn ids plus
14
+ * the transcript-path-derived rollout identity — the model never guesses
15
+ * ids and no other file is scanned.
16
+ * - The same logical observation key as the generic correction path
17
+ * (`codex|<rollout>|<turn>|user`) means explicit and generic detection of
18
+ * one turn converge on ONE canonical pain (unique marker dedup).
19
+ * - No LLM runs here: admission + durable enqueue only, well inside the
20
+ * 5s hook budget; the receipt carries painId/taskId.
21
+ */
22
+ import { admitGovernanceSignals, ensureGovernanceDiagnosticianTask, promoteAdmittedGovernanceEvidence, } from '@principles/host-runtime';
23
+ import { resolveCodexHome } from './codex-home.js';
24
+ import { validateCodexTranscriptPath } from './transcript-path.js';
25
+ import { extractFields } from './ingestion-fields.js';
26
+ /** The exact prefix (fullwidth colon) defined by SPEC §6.4. */
27
+ export const CODEX_OWNER_STATEMENT_PREFIX = 'PD记录痛苦:';
28
+ /** SPEC §6.1: reject instead of truncating the Owner's intent. */
29
+ export const MAX_OWNER_STATEMENT_CHARS = 500;
30
+ /**
31
+ * Deterministic prefix parse of the CURRENT user prompt. `text === null` means
32
+ * the prefix matched but the remainder was empty/blank — an explicit request
33
+ * with no content is a bounded rejection, never a fabricated statement.
34
+ */
35
+ export function parseOwnerStatementPrefix(prompt) {
36
+ if (typeof prompt !== 'string')
37
+ return { matched: false };
38
+ if (!prompt.startsWith(CODEX_OWNER_STATEMENT_PREFIX))
39
+ return { matched: false };
40
+ const remainder = prompt.slice(CODEX_OWNER_STATEMENT_PREFIX.length).trim();
41
+ if (remainder.length === 0)
42
+ return { matched: true, text: null, reason: 'statement_empty' };
43
+ if (remainder.length > MAX_OWNER_STATEMENT_CHARS)
44
+ return { matched: true, text: null, reason: 'statement_too_long' };
45
+ return { matched: true, text: remainder };
46
+ }
47
+ /**
48
+ * Persist one explicit Owner statement. The consent-gated conversation
49
+ * ingestion flag does NOT gate this path (no conversation tables or transcript
50
+ * CONTENT are read — only the path is validated for the rollout identity),
51
+ * mirroring SPEC §6.4 rule 3.
52
+ */
53
+ export async function recordExplicitOwnerStatement(args) {
54
+ const fields = extractFields(args.rawPayload);
55
+ if (fields === null || fields.sessionId.length === 0 || fields.turnId === null) {
56
+ return { status: 'rejected', reason: 'lineage_invalid', nextAction: 'The hook payload lacks the session/turn identity this explicit submission requires; nothing was recorded.' };
57
+ }
58
+ if (fields.transcriptPath === null) {
59
+ return { status: 'rejected', reason: 'transcript_unavailable', nextAction: 'Codex supplied no transcript path for this event; the explicit statement was NOT recorded — resubmit it in a new message.' };
60
+ }
61
+ const home = resolveCodexHome(args.env);
62
+ if (!home.ok) {
63
+ return { status: 'rejected', reason: 'transcript_unavailable', nextAction: `${home.reason}: ${home.nextAction}`.slice(0, 400) };
64
+ }
65
+ const validated = validateCodexTranscriptPath(fields.transcriptPath, home.home);
66
+ if (!validated.ok) {
67
+ return { status: 'rejected', reason: 'lineage_invalid', nextAction: `${validated.reason}: ${validated.nextAction}`.slice(0, 400) };
68
+ }
69
+ const candidate = {
70
+ kind: 'user_correction',
71
+ hostKind: 'codex',
72
+ logicalObservationKey: `codex|${validated.rolloutIdentity}|${fields.turnId}|user`,
73
+ rolloutIdentity: validated.rolloutIdentity,
74
+ rootSessionId: fields.sessionId,
75
+ hostTurnId: fields.turnId,
76
+ text: args.statementText,
77
+ observedAt: new Date().toISOString(),
78
+ explicitOwnerStatement: true,
79
+ };
80
+ const admitted = admitGovernanceSignals({ workspaceDir: args.workspaceDir, candidates: [candidate] });
81
+ if (!admitted.ok) {
82
+ return { status: 'rejected', reason: 'continuation_failed', nextAction: `${admitted.reason}: ${admitted.nextAction}`.slice(0, 400) };
83
+ }
84
+ const [outcome] = admitted.outcomes;
85
+ if (outcome === undefined || !('disposition' in outcome)) {
86
+ return { status: 'rejected', reason: 'continuation_failed', nextAction: 'The governance admission returned no disposition; nothing was recorded.' };
87
+ }
88
+ if (outcome.disposition === 'not_a_signal' || outcome.disposition === 'not_admitted') {
89
+ return { status: 'rejected', reason: 'continuation_failed', nextAction: 'reason' in outcome ? String(outcome.reason) : 'the signal was not admitted' };
90
+ }
91
+ if (outcome.disposition === 'rate_limited') {
92
+ return { status: 'rejected', reason: 'rate_limited', nextAction: 'The per-root-session correction quota (5/hour) is exhausted; resubmit later — the statement was NOT recorded.' };
93
+ }
94
+ // Task ensure is the receipt's hard guarantee; evidence promotion is
95
+ // best-effort (SPEC §6.4.5 — a degraded promotion is disclosed, never a
96
+ // failed receipt: the pain + task are durably recorded).
97
+ const ensured = await ensureGovernanceDiagnosticianTask({
98
+ workspaceDir: args.workspaceDir,
99
+ logicalObservationKey: candidate.logicalObservationKey,
100
+ canonicalPainId: outcome.canonicalPainId,
101
+ });
102
+ if (!ensured.ok) {
103
+ return { status: 'rejected', reason: 'continuation_failed', nextAction: `${ensured.reason}: ${ensured.nextAction}`.slice(0, 400) };
104
+ }
105
+ let promotionDegraded;
106
+ const promoted = promoteAdmittedGovernanceEvidence({
107
+ workspaceDir: args.workspaceDir,
108
+ rolloutIdentity: validated.rolloutIdentity,
109
+ triggerLogicalKey: candidate.logicalObservationKey,
110
+ canonicalPainId: outcome.canonicalPainId,
111
+ });
112
+ if (!promoted.ok) {
113
+ promotionDegraded = `${promoted.reason}`.slice(0, 160);
114
+ }
115
+ return {
116
+ status: 'received',
117
+ painId: outcome.canonicalPainId,
118
+ taskId: ensured.taskId,
119
+ disposition: outcome.disposition === 'already_admitted' ? 'already_admitted' : 'admitted',
120
+ logicalObservationKey: candidate.logicalObservationKey,
121
+ ...(promotionDegraded !== undefined ? { promotionDegraded } : {}),
122
+ };
123
+ }
@@ -1,4 +1,4 @@
1
- import { ingestGovernanceObservations, readGovernanceCheckpoint, } from '@principles/host-runtime';
1
+ import { ingestGovernanceObservations, readGovernanceCheckpoint, recordVerifiedToolOutcomes, } from '@principles/host-runtime';
2
2
  import { resolveCodexHome } from './codex-home.js';
3
3
  import { validateCodexTranscriptPath } from './transcript-path.js';
4
4
  import { classifyCodexVersion, CODEX_VERSION_NEXT_ACTION } from './codex-version.js';
@@ -70,6 +70,43 @@ function ingestLiveObservation({ fields, rolloutIdentity, workspaceDir, now }) {
70
70
  rolloutIdentity,
71
71
  };
72
72
  }
73
+ /**
74
+ * SPEC-CODEX-PAIN-CLOSURE-001 CR-01: project decoded CommandExecution facts
75
+ * onto the shared verified-outcome upgrade. The transcript's model-level call
76
+ * name for the shell tool is `exec` while the PostToolUse hook names it
77
+ * `Bash` (g1 fixture 04-post-tool-use.json ↔ normal-tool-final-turn.jsonl,
78
+ * same tool_use_id) — the host-specific mapping stays here in the adapter.
79
+ */
80
+ function collectVerifiedToolOutcomes(observations) {
81
+ const outcomes = [];
82
+ for (const observation of observations) {
83
+ if (observation.kind !== 'tool_call' || observation.toolUseId === undefined)
84
+ continue;
85
+ const facts = observation.toolFacts;
86
+ if (typeof facts !== 'object' || facts === null || Array.isArray(facts))
87
+ continue;
88
+ const { exitCode } = facts;
89
+ if (typeof exitCode !== 'number' || !Number.isInteger(exitCode))
90
+ continue;
91
+ const rawName = facts.toolName;
92
+ const toolName = rawName === 'exec' || typeof rawName !== 'string' || rawName.length === 0 ? 'Bash' : rawName;
93
+ const { stdout } = facts;
94
+ const { stderr } = facts;
95
+ const previewParts = [];
96
+ if (typeof stderr === 'string' && stderr.length > 0)
97
+ previewParts.push(stderr);
98
+ if (typeof stdout === 'string' && stdout.length > 0)
99
+ previewParts.push(stdout);
100
+ outcomes.push({
101
+ toolUseId: observation.toolUseId,
102
+ toolName,
103
+ params: facts.command ?? undefined,
104
+ exitCode,
105
+ ...(previewParts.length > 0 ? { outputPreview: previewParts.join('\n') } : {}),
106
+ });
107
+ }
108
+ return outcomes;
109
+ }
73
110
  function ingestTranscriptDelta({ fallbackRootSessionId, canonicalPath, identity, rolloutIdentity, workspaceDir, now, port }) {
74
111
  const checkpoint = readGovernanceCheckpoint({ workspaceDir, hostKind: 'codex', rolloutIdentity });
75
112
  if (checkpoint !== null && !('byteOffset' in checkpoint) && 'ok' in checkpoint && checkpoint.ok === false) {
@@ -126,6 +163,18 @@ function ingestTranscriptDelta({ fallbackRootSessionId, canonicalPath, identity,
126
163
  degradations.push({ reason: 'transcript_record_too_large', nextAction: 'a single transcript record exceeds the bounded-read window; inspect the rollout file.' });
127
164
  }
128
165
  const rootSessionId = decoded.rolloutMeta.rootSessionId ?? existing?.rootSessionId ?? fallbackRootSessionId;
166
+ // CR-01: upgrade text-only live observations with the host-verified exit
167
+ // codes BEFORE the checkpoint advances, so a write failure holds the delta
168
+ // and the next Stop retries instead of silently losing the verified facts.
169
+ const verifiedOutcomes = collectVerifiedToolOutcomes(decoded.observations);
170
+ if (verifiedOutcomes.length > 0) {
171
+ const verified = recordVerifiedToolOutcomes({ workspaceDir, sessionId: rootSessionId, outcomes: verifiedOutcomes });
172
+ const failed = verified.find((result) => result.status === 'unavailable');
173
+ if (failed !== undefined) {
174
+ const reason = failed.reason === 'trajectory_db_not_found' ? 'verified_outcome_db_unavailable' : `verified_outcome_write_failed:${failed.reason.split(':', 2)[1] ?? ''}`;
175
+ return { status: 'degraded', reason, nextAction: 'inspect the workspace trajectory database; the transcript checkpoint was NOT advanced, the next Stop retries this delta.', warnings: decoded.warnings };
176
+ }
177
+ }
129
178
  const result = ingestGovernanceObservations({
130
179
  workspaceDir,
131
180
  rollout: {
@@ -12,6 +12,7 @@ import { CodexHooksHostAdapter } from './host-adapter.js';
12
12
  import { CodexDecoderError, CodexEncoderError } from './codec/index.js';
13
13
  import { ingestCodexConversation } from './ingestion/ingestion.js';
14
14
  import { runGovernanceAdmission } from './ingestion/admission.js';
15
+ import { parseOwnerStatementPrefix, recordExplicitOwnerStatement } from './ingestion/explicit-owner-statement.js';
15
16
  import { recordCodexPromptDeliveryEvidence, recordCodexDenyEvidence } from './codex-evidence-recorder.js';
16
17
  const MAX_DIAGNOSTIC = 500;
17
18
  function diagnostic(reason, nextAction) {
@@ -190,9 +191,15 @@ async function runConversationIngestion(args) {
190
191
  // Slice B admission: hook awaits only admission + durable enqueue —
191
192
  // never an LLM (SPEC §12/§13). Ordinary conversation returns no
192
193
  // candidates/no admissions and stays completely silent.
194
+ // CR-07: when the explicit Owner-statement entry already handled this
195
+ // turn's prompt, its generic correction candidate is suppressed so the
196
+ // observation passes through exactly one pain writer.
197
+ const candidates = args.suppressCorrectionCandidate === true
198
+ ? outcome.admissionCandidates.filter((candidate) => candidate.kind !== 'user_correction')
199
+ : outcome.admissionCandidates;
193
200
  const admission = await runGovernanceAdmission({
194
201
  workspaceDir,
195
- candidates: outcome.admissionCandidates,
202
+ candidates,
196
203
  });
197
204
  for (const degradation of admission.degradations.slice(0, 2)) {
198
205
  diagnostics.push(diagnostic(degradation.reason, degradation.nextAction));
@@ -276,8 +283,53 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
276
283
  return { stdout: {}, exitCode: 0, stderr: [diagnostic(health.reason ?? 'runtime_unhealthy', health.nextAction ?? 'Inspect the Workspace runtime.')] };
277
284
  return { stdout: adapter.encodeOutput({ decision: 'allow', source: event.source }, 'session_start'), exitCode: 0, stderr: [] };
278
285
  }
286
+ // SPEC-CODEX-PAIN-CLOSURE-001 CR-07: the explicit Owner statement entry
287
+ // runs FIRST for the current user prompt — before the generic correction
288
+ // detection, so the same turn can never pass through two pain writers
289
+ // (the shared unique observation key dedups any replay). Works regardless
290
+ // of the codex_conversation_ingestion flag: only the transcript PATH is
291
+ // validated (rollout identity), never conversation content.
292
+ let explicitReceiptContext;
293
+ let explicitSuppressedGeneric = false;
294
+ const explicitDiagnostics = [];
295
+ if (event.kind === 'before_prompt_build') {
296
+ const rawRecord = parsed;
297
+ const prefixParse = parseOwnerStatementPrefix(typeof rawRecord?.prompt === 'string' ? rawRecord.prompt : undefined);
298
+ if (prefixParse.matched) {
299
+ explicitSuppressedGeneric = true;
300
+ if (prefixParse.text === null) {
301
+ explicitDiagnostics.push(diagnostic(`owner_statement_${prefixParse.reason ?? 'rejected'}`, prefixParse.reason === 'statement_too_long'
302
+ ? `The statement exceeds 500 characters; nothing was recorded. Resubmit within the limit.`
303
+ : 'The prefix carried no statement text; nothing was recorded. Resubmit as PD记录痛苦:<反馈原文>.'));
304
+ }
305
+ else {
306
+ const receipt = await recordExplicitOwnerStatement({
307
+ rawPayload: parsed,
308
+ workspaceDir: resolution.workspaceDir,
309
+ statementText: prefixParse.text,
310
+ env: _env,
311
+ });
312
+ if (receipt.status === 'received') {
313
+ explicitReceiptContext = `[PD] 已收到痛苦反馈(painId=${receipt.painId}, taskId=${receipt.taskId}${receipt.disposition === 'already_admitted' ? ', 重复提交已合并为同一信号' : ''})。后台将自动诊断;请在回复中如实转述本回执,不要声称仍在等待用户输入,也不要虚构诊断结论。${receipt.promotionDegraded !== undefined ? `(注意:会话证据提升暂不可用:${receipt.promotionDegraded};诊断仍会基于你提交的陈述进行。)` : ''}`;
314
+ explicitDiagnostics.push(diagnostic(`owner_statement_received:${receipt.painId}:${receipt.taskId}${receipt.promotionDegraded !== undefined ? `:promotion_degraded:${receipt.promotionDegraded}` : ''}`, 'Durable enqueue complete; the workspace worker continues diagnosis in the background.'));
315
+ }
316
+ else {
317
+ explicitDiagnostics.push(diagnostic(`owner_statement_${receipt.reason}`, receipt.nextAction));
318
+ }
319
+ }
320
+ }
321
+ }
279
322
  const ingestionDiagnostics = ingestionEnabled
280
- ? await runConversationIngestion({ rawPayload: parsed, kind: event.kind, workspaceDir: resolution.workspaceDir, env: _env })
323
+ ? await runConversationIngestion({
324
+ rawPayload: parsed,
325
+ kind: event.kind,
326
+ workspaceDir: resolution.workspaceDir,
327
+ env: _env,
328
+ // CR-07: the explicit path already handled this turn's user prompt —
329
+ // suppress the generic correction candidate so exactly one writer
330
+ // processed the observation (A17).
331
+ ...(explicitSuppressedGeneric && event.kind === 'before_prompt_build' ? { suppressCorrectionCandidate: true } : {}),
332
+ })
281
333
  : [];
282
334
  // PD v2 Phase 1: evidence context for this subprocess invocation. The
283
335
  // ledger flag follows the OpenClaw convention (principle_receipt_ledger
@@ -314,6 +366,17 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
314
366
  // v2 enforcement is suspended (PRI-780); wired honestly for the day it
315
367
  // is not.
316
368
  const encoded = adapter.encodeOutput(result, event.kind);
369
+ // CR-07 (A16): the explicit-statement receipt rides as additional context
370
+ // so the model can answer truthfully about what happened (received +
371
+ // queued), instead of guessing or claiming it is still waiting for input.
372
+ if (explicitReceiptContext !== undefined && event.kind === 'before_prompt_build') {
373
+ const output = encoded;
374
+ if (output.hookSpecificOutput !== undefined) {
375
+ output.hookSpecificOutput.additionalContext = output.hookSpecificOutput.additionalContext !== undefined
376
+ ? `${output.hookSpecificOutput.additionalContext}\n${explicitReceiptContext}`
377
+ : explicitReceiptContext;
378
+ }
379
+ }
317
380
  if (result.decision === 'deny') {
318
381
  try {
319
382
  let liveActivationId;
@@ -356,7 +419,7 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
356
419
  evidenceDiagnostics.push(diagnostic(`codex_evidence_deny_failed:${errorMessage(error)}`, 'The deny decision was already encoded; evidence replay from the durable source is safe.'));
357
420
  }
358
421
  }
359
- const stderr = [...annotateContextWarnings(result.warnings ?? []).slice(0, 16).map((warning) => diagnostic(warning, 'Inspect PD Workspace state and retry; the hook failed open.')), ...evaluationDiagnostics, ...evidenceDiagnostics, ...ingestionDiagnostics];
422
+ const stderr = [...annotateContextWarnings(result.warnings ?? []).slice(0, 16).map((warning) => diagnostic(warning, 'Inspect PD Workspace state and retry; the hook failed open.')), ...evaluationDiagnostics, ...evidenceDiagnostics, ...explicitDiagnostics, ...ingestionDiagnostics];
360
423
  return { stdout: encoded, exitCode: 0, stderr };
361
424
  }
362
425
  catch (error) {
@@ -2,9 +2,22 @@ import { type InternalizationConsumerCycleOutcome, type ConsumerCycleLogger, typ
2
2
  import { type CodexCatchUpResult } from '../ingestion/catch-up.js';
3
3
  import type { TranscriptPort } from '../ingestion/transcript-decoder.js';
4
4
  export type CodexWorkerMode = 'ready' | 'manual_action_required' | 'paused' | 'degraded';
5
+ export interface CodexWorkerPostProcessingReport {
6
+ readonly resumedTaskIds: readonly string[];
7
+ readonly processedCount: number;
8
+ /** Eligible-after-this-cycle backlog size (oldest-first scan is bounded). */
9
+ readonly remainingCount: number;
10
+ readonly oldestAgeMs: number | null;
11
+ readonly blocked: readonly {
12
+ candidateId: string;
13
+ reason: string;
14
+ }[];
15
+ }
5
16
  export interface CodexWorkerCycleStepReport {
6
17
  readonly catchUp: CodexCatchUpResult;
7
18
  readonly reconcile: ReconcileGovernanceContinuationResult;
19
+ /** CR-05: succeeded-diagnosis post-processing continuation (no LLM). */
20
+ readonly postProcessing: CodexWorkerPostProcessingReport | null;
8
21
  /** At most ONE diagnostician execution per cycle (bounded work). */
9
22
  readonly diagnostician: {
10
23
  readonly taskId: string;
@@ -41,6 +54,7 @@ export interface CodexWorkerCycleOptions {
41
54
  /** Cap on diagnostician candidates inspected per cycle (default 5). */
42
55
  readonly diagnosticianCandidateLimit?: number;
43
56
  }
57
+ export declare function readCodexWorkerLiveness(workspaceDir: string): Record<string, unknown> | null;
44
58
  /**
45
59
  * Run ONE bounded worker cycle for a canonical workspace. Never throws:
46
60
  * every failure becomes a structured degraded result with a nextAction.