create-principles-disciple 1.156.2 → 1.157.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/codex-adapter/dist/worker/workspace-worker.d.ts +11 -3
  3. package/codex-adapter/dist/worker/workspace-worker.js +30 -16
  4. package/codex-adapter/package.json +1 -1
  5. package/console/dist/server/models/OwnerDecisionConsoleModel.js +33 -1
  6. package/console/dist/web/assets/app.js +3 -3
  7. package/core/dist/runtime/adversarial-loop.d.ts +8 -0
  8. package/core/dist/runtime/adversarial-loop.d.ts.map +1 -1
  9. package/core/dist/runtime/adversarial-loop.js +420 -45
  10. package/core/dist/runtime/adversarial-loop.js.map +1 -1
  11. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +3 -3
  12. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  13. package/core/dist/runtime/feature-flags/plugin-surface-registry.d.ts.map +1 -1
  14. package/core/dist/runtime/feature-flags/plugin-surface-registry.js +0 -16
  15. package/core/dist/runtime/feature-flags/plugin-surface-registry.js.map +1 -1
  16. package/core/dist/runtime/index.d.ts +4 -0
  17. package/core/dist/runtime/index.d.ts.map +1 -1
  18. package/core/dist/runtime/index.js +10 -0
  19. package/core/dist/runtime/index.js.map +1 -1
  20. package/core/dist/runtime/internalization/artificer-runner.d.ts +9 -0
  21. package/core/dist/runtime/internalization/artificer-runner.d.ts.map +1 -1
  22. package/core/dist/runtime/internalization/artificer-runner.js +52 -0
  23. package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
  24. package/core/dist/runtime/internalization/correlation-lineage.d.ts +16 -3
  25. package/core/dist/runtime/internalization/correlation-lineage.d.ts.map +1 -1
  26. package/core/dist/runtime/internalization/correlation-lineage.js +4 -4
  27. package/core/dist/runtime/internalization/correlation-lineage.js.map +1 -1
  28. package/core/dist/runtime/internalization/evaluator-runner.d.ts +35 -0
  29. package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
  30. package/core/dist/runtime/internalization/evaluator-runner.js +390 -91
  31. package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
  32. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +40 -13
  33. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
  34. package/core/dist/runtime/internalization/internalization-orchestrator.js +520 -199
  35. package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
  36. package/core/dist/runtime/internalization/internalization-transition-decision.js +1 -1
  37. package/core/dist/runtime/internalization/internalization-transition-decision.js.map +1 -1
  38. package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
  39. package/core/dist/runtime/internalization/owner-resolution-service.js +10 -8
  40. package/core/dist/runtime/internalization/owner-resolution-service.js.map +1 -1
  41. package/core/dist/runtime/internalization/owner-review.d.ts +2 -0
  42. package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
  43. package/core/dist/runtime/internalization/owner-review.js +17 -11
  44. package/core/dist/runtime/internalization/owner-review.js.map +1 -1
  45. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -0
  46. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
  47. package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
  48. package/core/dist/runtime/internalization/pitask-metadata.d.ts +36 -1
  49. package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
  50. package/core/dist/runtime/internalization/pitask-metadata.js +23 -2
  51. package/core/dist/runtime/internalization/pitask-metadata.js.map +1 -1
  52. package/core/dist/runtime/internalization/repair-create.d.ts +73 -0
  53. package/core/dist/runtime/internalization/repair-create.d.ts.map +1 -0
  54. package/core/dist/runtime/internalization/repair-create.js +200 -0
  55. package/core/dist/runtime/internalization/repair-create.js.map +1 -0
  56. package/core/dist/runtime/internalization/repair-lineage-backfill.d.ts +94 -0
  57. package/core/dist/runtime/internalization/repair-lineage-backfill.d.ts.map +1 -0
  58. package/core/dist/runtime/internalization/repair-lineage-backfill.js +123 -0
  59. package/core/dist/runtime/internalization/repair-lineage-backfill.js.map +1 -0
  60. package/core/dist/runtime/internalization/repair-task-identity.d.ts +99 -4
  61. package/core/dist/runtime/internalization/repair-task-identity.d.ts.map +1 -1
  62. package/core/dist/runtime/internalization/repair-task-identity.js +225 -7
  63. package/core/dist/runtime/internalization/repair-task-identity.js.map +1 -1
  64. package/core/dist/runtime/internalization/revision-reopen.d.ts +56 -1
  65. package/core/dist/runtime/internalization/revision-reopen.d.ts.map +1 -1
  66. package/core/dist/runtime/internalization/revision-reopen.js +82 -39
  67. package/core/dist/runtime/internalization/revision-reopen.js.map +1 -1
  68. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +0 -7
  69. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
  70. package/core/dist/runtime/internalization/rollout-reviewer-runner.js +13 -68
  71. package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
  72. package/core/dist/runtime/internalization/successor-create.d.ts +69 -0
  73. package/core/dist/runtime/internalization/successor-create.d.ts.map +1 -0
  74. package/core/dist/runtime/internalization/successor-create.js +173 -0
  75. package/core/dist/runtime/internalization/successor-create.js.map +1 -0
  76. package/core/dist/runtime/internalization/successor-lookup.d.ts +50 -0
  77. package/core/dist/runtime/internalization/successor-lookup.d.ts.map +1 -0
  78. package/core/dist/runtime/internalization/successor-lookup.js +213 -0
  79. package/core/dist/runtime/internalization/successor-lookup.js.map +1 -0
  80. package/core/dist/runtime/runner/succeeded-result-recovery.d.ts +58 -0
  81. package/core/dist/runtime/runner/succeeded-result-recovery.d.ts.map +1 -0
  82. package/core/dist/runtime/runner/succeeded-result-recovery.js +117 -0
  83. package/core/dist/runtime/runner/succeeded-result-recovery.js.map +1 -0
  84. package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -0
  85. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  86. package/core/dist/runtime/store/runtime-state-manager.js +4 -0
  87. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  88. package/core/dist/runtime/store/task/memory-task-store.d.ts +3 -3
  89. package/core/dist/runtime/store/task/memory-task-store.d.ts.map +1 -1
  90. package/core/dist/runtime/store/task/memory-task-store.js +52 -0
  91. package/core/dist/runtime/store/task/memory-task-store.js.map +1 -1
  92. package/core/dist/runtime/store/task/sqlite-task-store.d.ts +3 -0
  93. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  94. package/core/dist/runtime/store/task/sqlite-task-store.js +204 -135
  95. package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
  96. package/core/dist/runtime/store/task/task-store.d.ts +17 -0
  97. package/core/dist/runtime/store/task/task-store.d.ts.map +1 -1
  98. package/core/dist/telemetry-event.d.ts +2 -2
  99. package/core/dist/telemetry-event.d.ts.map +1 -1
  100. package/core/dist/telemetry-event.js +4 -0
  101. package/core/dist/telemetry-event.js.map +1 -1
  102. package/core/package.json +1 -1
  103. package/dist/index.js +1 -1
  104. package/dist/index.js.map +1 -1
  105. package/dist/installer.d.ts +69 -11
  106. package/dist/installer.d.ts.map +1 -1
  107. package/dist/installer.js +432 -120
  108. package/dist/installer.js.map +1 -1
  109. package/dist/service-host-bridge.d.ts +0 -5
  110. package/dist/service-host-bridge.d.ts.map +1 -1
  111. package/dist/service-host-bridge.js.map +1 -1
  112. package/dist/service-host-provisioning.d.ts +123 -18
  113. package/dist/service-host-provisioning.d.ts.map +1 -1
  114. package/dist/service-host-provisioning.js +645 -77
  115. package/dist/service-host-provisioning.js.map +1 -1
  116. package/dist/utils/env.d.ts +9 -0
  117. package/dist/utils/env.d.ts.map +1 -1
  118. package/dist/utils/env.js +269 -49
  119. package/dist/utils/env.js.map +1 -1
  120. package/host-runtime/dist/codex-worker-status.d.ts +6 -4
  121. package/host-runtime/dist/codex-worker-status.js +7 -5
  122. package/host-runtime/dist/diagnostician-auto-run.js +2 -2
  123. package/host-runtime/dist/governance-signal-admission.d.ts +2 -1
  124. package/host-runtime/dist/governance-signal-admission.js +2 -1
  125. package/host-runtime/dist/index.d.ts +4 -2
  126. package/host-runtime/dist/index.js +6 -2
  127. package/host-runtime/dist/internalization-consumer-cycle.d.ts +13 -106
  128. package/host-runtime/dist/internalization-consumer-cycle.js +21 -99
  129. package/host-runtime/dist/internalization-consumer-governance.d.ts +3 -3
  130. package/host-runtime/dist/internalization-consumer-governance.js +17 -96
  131. package/host-runtime/dist/internalization-task-executor.d.ts +127 -0
  132. package/host-runtime/dist/internalization-task-executor.js +121 -0
  133. package/host-runtime/dist/workbuddy-worker-status.d.ts +6 -3
  134. package/host-runtime/dist/workbuddy-worker-status.js +7 -4
  135. package/host-runtime/dist/workspace-telemetry-emitter.js +1 -1
  136. package/host-runtime/package.json +1 -1
  137. package/install-layout/dist/background-execution-transition.d.ts +25 -29
  138. package/install-layout/dist/background-execution-transition.js +90 -138
  139. package/install-layout/dist/index.d.ts +45 -33
  140. package/install-layout/dist/index.js +24 -18
  141. package/install-layout/package.json +1 -1
  142. package/package.json +5 -4
  143. package/pd-cli/dist/commands/codex-worker.d.ts +7 -3
  144. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  145. package/pd-cli/dist/commands/codex-worker.js +125 -101
  146. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  147. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
  148. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +148 -130
  149. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
  150. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  151. package/pd-cli/dist/commands/runtime-internalization-run-once.js +4 -0
  152. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  153. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +1 -1
  154. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  155. package/pd-cli/dist/commands/service-run-once.d.ts +12 -27
  156. package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
  157. package/pd-cli/dist/commands/service-run-once.js +15 -206
  158. package/pd-cli/dist/commands/service-run-once.js.map +1 -1
  159. package/pd-cli/dist/commands/workbuddy-worker.d.ts +7 -2
  160. package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
  161. package/pd-cli/dist/commands/workbuddy-worker.js +133 -99
  162. package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
  163. package/pd-cli/dist/commands/worker-service-host-gate.d.ts +38 -0
  164. package/pd-cli/dist/commands/worker-service-host-gate.d.ts.map +1 -0
  165. package/pd-cli/dist/commands/worker-service-host-gate.js +110 -0
  166. package/pd-cli/dist/commands/worker-service-host-gate.js.map +1 -0
  167. package/pd-cli/dist/program.d.ts.map +1 -1
  168. package/pd-cli/dist/program.js +20 -84
  169. package/pd-cli/dist/program.js.map +1 -1
  170. package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
  171. package/pd-cli/dist/services/rulehost-pipeline-runner.js +198 -142
  172. package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
  173. package/pd-cli/dist/services/service-host/coordinator-common.d.ts.map +1 -1
  174. package/pd-cli/dist/services/service-host/coordinator-common.js +4 -5
  175. package/pd-cli/dist/services/service-host/coordinator-common.js.map +1 -1
  176. package/pd-cli/dist/services/service-host/index.d.ts +7 -10
  177. package/pd-cli/dist/services/service-host/index.d.ts.map +1 -1
  178. package/pd-cli/dist/services/service-host/index.js +8 -11
  179. package/pd-cli/dist/services/service-host/index.js.map +1 -1
  180. package/pd-cli/dist/services/service-host/install-identity.d.ts +5 -5
  181. package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -1
  182. package/pd-cli/dist/services/service-host/managed-run.js +19 -22
  183. package/pd-cli/dist/services/service-host/managed-run.js.map +1 -1
  184. package/pd-cli/dist/services/service-host/scheduler/linux.d.ts.map +1 -1
  185. package/pd-cli/dist/services/service-host/scheduler/linux.js +21 -2
  186. package/pd-cli/dist/services/service-host/scheduler/linux.js.map +1 -1
  187. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +1 -1
  188. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -1
  189. package/pd-cli/dist/services/service-host/scheduler/service-status.js +0 -2
  190. package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -1
  191. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +7 -51
  192. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
  193. package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
  194. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js +3 -3
  195. package/pd-cli/dist/services/service-host/worker-adapter.d.ts +0 -10
  196. package/pd-cli/dist/services/service-host/worker-adapter.d.ts.map +1 -1
  197. package/pd-cli/dist/services/service-host/worker-adapter.js +4 -12
  198. package/pd-cli/dist/services/service-host/worker-adapter.js.map +1 -1
  199. package/pd-cli/dist/services/service-host/worker-env.d.ts +1 -1
  200. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts +5 -7
  201. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts.map +1 -1
  202. package/pd-cli/dist/services/service-host/workspace-dispatch.js +1 -3
  203. package/pd-cli/dist/services/service-host/workspace-dispatch.js.map +1 -1
  204. package/pd-cli/package.json +1 -1
  205. package/plugin/dist/bundle.js +616 -1319
  206. package/plugin/dist/core/openclaw-tool-declaration.d.ts +13 -0
  207. package/plugin/dist/index.d.ts +0 -9
  208. package/plugin/dist/openclaw-worker.d.ts +21 -8
  209. package/plugin/dist/openclaw-worker.js +267 -267
  210. package/plugin/dist/openclaw.plugin.json +1 -1
  211. package/plugin/openclaw.plugin.json +1 -1
  212. package/plugin/package.json +1 -1
  213. package/release-manager/dist/installer.js +432 -120
  214. package/release-manager/dist/service-host-provisioning.js +645 -77
  215. package/release-manager/dist/utils/env.js +269 -49
  216. package/release-manager/package.json +3 -2
  217. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +9 -1
  218. package/workbuddy-adapter/dist/worker/workspace-worker.js +21 -9
  219. package/workbuddy-adapter/package.json +1 -1
  220. package/pd-cli/dist/commands/service-handover.d.ts +0 -12
  221. package/pd-cli/dist/commands/service-handover.d.ts.map +0 -1
  222. package/pd-cli/dist/commands/service-handover.js +0 -117
  223. package/pd-cli/dist/commands/service-handover.js.map +0 -1
  224. package/pd-cli/dist/commands/worker-drain.d.ts +0 -7
  225. package/pd-cli/dist/commands/worker-drain.d.ts.map +0 -1
  226. package/pd-cli/dist/commands/worker-drain.js +0 -51
  227. package/pd-cli/dist/commands/worker-drain.js.map +0 -1
  228. package/pd-cli/dist/services/service-host/handover-claims.d.ts +0 -14
  229. package/pd-cli/dist/services/service-host/handover-claims.d.ts.map +0 -1
  230. package/pd-cli/dist/services/service-host/handover-claims.js +0 -50
  231. package/pd-cli/dist/services/service-host/handover-claims.js.map +0 -1
  232. package/pd-cli/dist/services/service-host/shadow-run.d.ts +0 -87
  233. package/pd-cli/dist/services/service-host/shadow-run.d.ts.map +0 -1
  234. package/pd-cli/dist/services/service-host/shadow-run.js +0 -549
  235. package/pd-cli/dist/services/service-host/shadow-run.js.map +0 -1
  236. package/pd-cli/dist/services/service-host/workspace-handover.d.ts +0 -190
  237. package/pd-cli/dist/services/service-host/workspace-handover.d.ts.map +0 -1
  238. package/pd-cli/dist/services/service-host/workspace-handover.js +0 -1393
  239. package/pd-cli/dist/services/service-host/workspace-handover.js.map +0 -1
  240. package/plugin/dist/service/gateway-consumer-lease.d.ts +0 -142
  241. package/plugin/dist/service/gateway-quiesce-ack.d.ts +0 -40
  242. package/plugin/dist/service/internalization-auto-consumer-service.d.ts +0 -100
@@ -1,17 +1,30 @@
1
1
  /**
2
- * Workspace background-execution ownership transitions — the CAS write path
3
- * for SPEC-PD-SERVICE-HOST-001 §8.4 (PRI-1282 Phase 4).
2
+ * Workspace background-execution provisioning — the CAS write path for the
3
+ * Service-Host-only runtime model (PRI-1278 consolidation).
4
4
  *
5
5
  * The manifest schema (`backgroundExecutions`, `BackgroundExecutionRecord`)
6
- * lives in `index.ts`; this module owns the STATE MACHINE half that the
7
- * schema doc string deferred: starting, completing, aborting and rolling back
8
- * a per-Workspace ownership transition under a cross-process critical section
9
- * with monotonic-generation fencing and operationId idempotency.
6
+ * lives in `index.ts`; this module owns the single live write transition,
7
+ * `provision_fresh_install`, together with the cross-process critical
8
+ * section, monotonic-generation fencing and idempotent terminal replay.
10
9
  *
11
- * Phase attribution (Owner execution directive 2026-11-22, closing the
12
- * SPEC §8.4-10 / TD §9 conflict): Phase 4 implements this minimal, reusable
13
- * primitive and uses it for the OpenClaw per-Workspace handover; Phase 5
14
- * REUSES it for Codex / WorkBuddy — there is no second state machine.
10
+ * Current ownership model:
11
+ * - `service_host_owned` is the ONLY live ownership state. Consumption
12
+ * admission is binary: a consumer is admitted when the projection is
13
+ * `service_host_owned`, and is paused/fail-closed otherwise.
14
+ * - `legacy_owned`, `handover_preparing` and `rollback_pending` remain in
15
+ * the persisted schema only so pre-consolidation manifests stay parseable.
16
+ * They are historical residue; no code path may WRITE them anymore.
17
+ * - An absent record means "not yet provisioned". It is not proof that any
18
+ * legacy runtime owns the workspace.
19
+ *
20
+ * Why provisioning may flip every persisted state directly: the legacy
21
+ * consumer implementation is deleted repo-wide, so a pre-existing record —
22
+ * including interrupted handover/rollback residue — cannot prove a live
23
+ * consumer that this CAS must quiesce. Migration safety is owned by the
24
+ * installer's one-time stop-old-entries sequencing BEFORE provisioning is
25
+ * invoked, not by this state machine; lease fencing remains the task-level
26
+ * backstop. This primitive's narrower job is to serialize the write, fence
27
+ * stale generations, and converge each workspace exactly once.
15
28
  *
16
29
  * Concurrency model:
17
30
  * - physical exclusion: one lock directory next to the manifest
@@ -27,17 +40,16 @@
27
40
  * reclaim's check and its recreate, and a release deletes only the
28
41
  * lock whose owner token it verified inside the same transaction;
29
42
  * - logical fencing: inside the critical section the writer re-reads the
30
- * current record; a stale observed `generation` or an unexpected state
31
- * loses and nothing is written;
43
+ * current record; a stale observed `generation` loses and nothing is
44
+ * written;
32
45
  * - durability: the manifest lands via temp file + atomic rename, so a crash
33
46
  * mid-write leaves either the previous or the complete new document —
34
47
  * never a partial one.
35
48
  *
36
- * Ownership of process liveness is NEVER consulted: PID, startup order and
37
- * delays are not proof (SPEC §8.4). The persisted record is the only
38
- * authority; `readWorkspaceBackgroundOwnership` is its read-side projection
39
- * shared by the OpenClaw Gateway gate, the `pd openclaw worker` gate and the
40
- * handover/rollback commands.
49
+ * Process liveness is NEVER ownership proof: PID, startup order and delays
50
+ * are not proof. The persisted record is the only authority;
51
+ * `readWorkspaceBackgroundOwnership` is its read-side projection for
52
+ * provisioning and consumer-admission readers.
41
53
  */
42
54
  import * as crypto from 'node:crypto';
43
55
  import * as fs from 'node:fs';
@@ -523,11 +535,15 @@ function resolveOwnershipIdentity(args) {
523
535
  }
524
536
  const OWNER_ALIAS_CONFLICT_NEXT_ACTION = 'Two registered path spellings of the same directory carry DIFFERENT ownership records; a writer must reconcile ~/.pd/install.json (remove the duplicate workspace entry / record) before background execution decisions.';
525
537
  /**
526
- * The single read-side projection of §8.4 ownership for ONE workspace.
527
- * Consumers: the OpenClaw Gateway start/tick gate, the `pd openclaw worker`
528
- * gate, and the handover/rollback commands. Fail-closed: an unreadable or
529
- * malformed manifest is `manifest_unreadable` — "cannot decide" is NEVER
530
- * collapsed into "legacy by default" for a consumer that is about to act.
538
+ * The single read-side ownership projection for ONE workspace in the
539
+ * Service-Host-only model. `service_host_owned` is the only state that may
540
+ * admit consumption; every other persisted state is historical residue, and
541
+ * an absent record means not-yet-provisioned. For projection compatibility
542
+ * the absent case is still represented as `legacy_owned`/`no_record`/
543
+ * generation 0 — readers must interpret that as un-provisioned, never as a
544
+ * living legacy consumer. Fail-closed: an unreadable or malformed manifest
545
+ * is `manifest_unreadable`; "cannot decide" is NEVER collapsed into an
546
+ * admission decision for a consumer that is about to act.
531
547
  */
532
548
  export function readWorkspaceBackgroundOwnership(options) {
533
549
  const fsOps = options.fsOps ?? realFsOps;
@@ -588,46 +604,26 @@ export function readWorkspaceBackgroundOwnership(options) {
588
604
  // ─── Transitions ────────────────────────────────────────────────────────────
589
605
  export const BACKGROUND_EXECUTION_TRANSITIONS = [
590
606
  'provision_fresh_install',
591
- 'begin_handover',
592
- 'abort_handover',
593
- 'complete_handover',
594
- 'begin_rollback',
595
- 'complete_rollback',
596
- 'abort_rollback',
597
607
  ];
598
608
  const TRANSITION_SPECS = {
599
- // Fresh-install provisioning: a brand-new Workspace is born Service-Host
600
- // owned in ONE atomic write (generation 0 → 1). There is no old consumer
601
- // to quiesce, so the handover_preparing staging is not used; the caller
602
- // still has to prove absence of history through the manifest itself.
603
- provision_fresh_install: { from: ['legacy_owned'], to: 'service_host_owned', needsOperationId: false },
604
- // legacy_owned -> handover_preparing; effectiveOwner stays legacy (SPEC §8.4-3:
605
- // PREPARING grants no new rights — the old consumer remains the only one).
606
- begin_handover: { from: ['legacy_owned', 'handover_preparing'], to: 'handover_preparing', needsOperationId: true },
607
- abort_handover: { from: ['handover_preparing'], to: 'legacy_owned', needsOperationId: false },
608
- complete_handover: { from: ['handover_preparing'], to: 'service_host_owned', needsOperationId: false },
609
- begin_rollback: { from: ['service_host_owned', 'rollback_pending'], to: 'rollback_pending', needsOperationId: true },
610
- complete_rollback: { from: ['rollback_pending'], to: 'legacy_owned', needsOperationId: false },
611
- abort_rollback: { from: ['rollback_pending'], to: 'service_host_owned', needsOperationId: false },
609
+ // Service-Host-only provisioning is a direct convergence write from ANY
610
+ // persisted state. All three non-service states are parse-only residue in
611
+ // the new model: the legacy consumer implementation has been deleted
612
+ // repo-wide, so there is no consumer left for a handover/rollback machine
613
+ // to quiesce. The installer's stop-old-entries sequencing owns migration
614
+ // safety before it calls this primitive; the CAS only guarantees that the
615
+ // convergence write itself is serialized, generation-fenced and atomic.
616
+ provision_fresh_install: {
617
+ from: ['legacy_owned', 'handover_preparing', 'rollback_pending', 'service_host_owned'],
618
+ to: 'service_host_owned',
619
+ },
612
620
  };
613
621
  function buildTargetRecord(context) {
614
622
  const generation = context.currentGeneration + 1;
615
- const { operationId, nowIso } = context;
623
+ const { nowIso } = context;
616
624
  switch (context.kind) {
617
625
  case 'provision_fresh_install':
618
626
  return { state: 'service_host_owned', effectiveOwner: 'service_host', generation, operationId: null, previousOwner: null, targetOwner: null, updatedAt: nowIso };
619
- case 'begin_handover':
620
- return { state: 'handover_preparing', effectiveOwner: 'legacy', generation, operationId, previousOwner: 'legacy', targetOwner: 'service_host', updatedAt: nowIso };
621
- case 'abort_handover':
622
- return { state: 'legacy_owned', effectiveOwner: 'legacy', generation, operationId: null, previousOwner: null, targetOwner: null, updatedAt: nowIso };
623
- case 'complete_handover':
624
- return { state: 'service_host_owned', effectiveOwner: 'service_host', generation, operationId: null, previousOwner: null, targetOwner: null, updatedAt: nowIso };
625
- case 'begin_rollback':
626
- return { state: 'rollback_pending', effectiveOwner: 'service_host', generation, operationId, previousOwner: 'service_host', targetOwner: 'legacy', updatedAt: nowIso };
627
- case 'complete_rollback':
628
- return { state: 'legacy_owned', effectiveOwner: 'legacy', generation, operationId: null, previousOwner: null, targetOwner: null, updatedAt: nowIso };
629
- case 'abort_rollback':
630
- return { state: 'service_host_owned', effectiveOwner: 'service_host', generation, operationId: null, previousOwner: null, targetOwner: null, updatedAt: nowIso };
631
627
  }
632
628
  }
633
629
  function projectOwnership(state, generation, record) {
@@ -635,19 +631,19 @@ function projectOwnership(state, generation, record) {
635
631
  return { status: 'legacy_owned', source: record !== undefined ? 'record' : 'no_record', generation, record };
636
632
  }
637
633
  if (record === undefined) {
638
- // Unreachable for transition states (a record must exist), kept total.
634
+ // Unreachable for persisted non-legacy states (a record must exist), kept total.
639
635
  return { status: 'legacy_owned', source: 'no_record', generation };
640
636
  }
641
637
  return { status: state, generation, record };
642
638
  }
643
639
  /**
644
- * Execute one §8.4 state-machine transition for one Workspace under the CAS
645
- * critical section. The manifest is read, validated, mutated as a RAW object
646
- * (unknown top-level fields survive — the update side owns `channel` /
647
- * `autoCheck` / `releaseMetadataUrl`), re-validated, and landed with an
648
- * atomic rename. A legacy single-key `backgroundExecution` spelling is
649
- * migrated to the per-Workspace map in the same write (both spellings after
650
- * the write would be a parse conflict).
640
+ * Execute the one live ownership transition — provision this Workspace into
641
+ * `service_host_owned` — under the CAS critical section. The manifest is
642
+ * read, validated, mutated as a RAW object (unknown top-level fields survive
643
+ * — the update side owns `channel` / `autoCheck` / `releaseMetadataUrl`),
644
+ * re-validated, and landed with an atomic rename. A legacy single-key
645
+ * `backgroundExecution` spelling is migrated to the per-Workspace map in the
646
+ * same write (both spellings after the write would be a parse conflict).
651
647
  */
652
648
  export function transitionWorkspaceBackgroundExecution(input) {
653
649
  if (input.operationId.length === 0) {
@@ -712,19 +708,19 @@ export function transitionWorkspaceBackgroundExecution(input) {
712
708
  nextAction: OWNER_ALIAS_CONFLICT_NEXT_ACTION,
713
709
  };
714
710
  }
715
- // Workspace registration: begin_handover may register (single atomic write
716
- // together with the record); every other kind requires existing membership
717
- // because a marker key outside `workspaces[]` cannot parse back. An alias
718
- // registration for the same real directory counts as registered.
711
+ // Workspace registration: provisioning may register the workspace in the
712
+ // same atomic write when the caller explicitly asks for it. Otherwise the
713
+ // workspace must already be a member because a record key outside
714
+ // `workspaces[]` cannot parse back. An alias registration for the same
715
+ // real directory counts as registered.
719
716
  const registered = identity.registeredAliases.length > 0;
720
- const mayRegister = (input.kind === 'begin_handover' || input.kind === 'provision_fresh_install')
721
- && input.registerWorkspace === true;
717
+ const mayRegister = input.registerWorkspace === true;
722
718
  if (!registered && !mayRegister) {
723
719
  return {
724
720
  ok: false,
725
721
  reason: 'workspace_not_registered',
726
722
  message: `workspace ${canonical} is not in the manifest workspaces list`,
727
- nextAction: 'Register the workspace through a begin_handover with registration, or the installer bind path.',
723
+ nextAction: 'Register the workspace through installer provisioning or the installer bind path.',
728
724
  };
729
725
  }
730
726
  const spec = TRANSITION_SPECS[input.kind];
@@ -733,39 +729,25 @@ export function transitionWorkspaceBackgroundExecution(input) {
733
729
  const currentRecord = identity.records[0]?.record;
734
730
  const currentState = currentRecord?.state ?? 'legacy_owned';
735
731
  const currentGeneration = currentRecord?.generation ?? 0;
736
- // Fresh-install provisioning is the ONE transition that skips the legacy
737
- // handover staging, so its authorization must be proven here rather than
738
- // trusted from the caller:
739
- // - `freshInstall` must be explicitly asserted (a legacy upgrade that
740
- // forgot it can never flip ownership silently);
741
- // - the manifest must hold NO ownership record at all for this
742
- // workspace (a `legacy_owned` RECORD is history — that workspace has
743
- // been managed before and must go through begin_handover);
744
- // - an already-provisioned workspace is an idempotent replay.
745
- if (input.kind === 'provision_fresh_install') {
746
- if (input.freshInstall !== true) {
747
- return {
748
- ok: false,
749
- reason: 'invalid_input',
750
- message: 'provision_fresh_install requires freshInstall=true; upgrades must use begin_handover so the legacy consumer is stopped and verified first',
751
- nextAction: 'Use pd service handover for an existing workspace; fresh-install provisioning is install-time only.',
752
- };
753
- }
754
- const alreadyOwned = currentRecord !== undefined
755
- && currentState === 'service_host_owned'
756
- && currentRecord.effectiveOwner === 'service_host';
757
- if (alreadyOwned) {
758
- return { ok: true, changed: false, record: currentRecord, previous: currentRecord };
759
- }
760
- if (currentRecord !== undefined) {
761
- return {
762
- ok: false,
763
- reason: 'unexpected_state',
764
- message: `workspace already carries a background-execution record (${currentState}, generation ${currentGeneration}); fresh-install provisioning refuses to overwrite history`,
765
- nextAction: 'Use pd service handover (with legacy consumer quiesce) to move this workspace to the Service Host.',
766
- current: projectOwnership(currentState, currentGeneration, currentRecord),
767
- };
768
- }
732
+ // `service_host_owned` is the converged terminal state. Replaying a
733
+ // provision onto a canonical terminal record is a no-op and must never
734
+ // mint another generation: concurrent installers/retries are allowed to
735
+ // converge exactly once. The persisted steady-state record carries
736
+ // `operationId: null` by schema, so terminal idempotency is state-based
737
+ // rather than a second write keyed by the caller's operation id. A no-op
738
+ // does not consult the generation fence because no write is attempted.
739
+ //
740
+ // Exception: an alias-keyed terminal record still needs the realpath
741
+ // pinning repair below. With no later transition kinds left, provisioning
742
+ // is the only remaining write opportunity that can move that historical
743
+ // record onto the real directory. That repair rewrites the SAME record
744
+ // (same generation); it is not a new ownership transition.
745
+ const terminalRecord = currentRecord !== undefined && currentState === spec.to ? currentRecord : undefined;
746
+ const terminalNeedsRealpathPinning = terminalRecord !== undefined
747
+ && priorKey !== undefined
748
+ && priorKey !== recordKey;
749
+ if (terminalRecord !== undefined && !terminalNeedsRealpathPinning) {
750
+ return { ok: true, changed: false, record: terminalRecord, previous: terminalRecord };
769
751
  }
770
752
  if (input.expectedGeneration !== undefined && input.expectedGeneration !== currentGeneration) {
771
753
  return {
@@ -776,21 +758,6 @@ export function transitionWorkspaceBackgroundExecution(input) {
776
758
  current: projectOwnership(currentState, currentGeneration, currentRecord),
777
759
  };
778
760
  }
779
- if (currentRecord !== undefined && currentState === spec.to && spec.needsOperationId) {
780
- // Idempotent begin replay: same operationId onto the same transition
781
- // state is a no-op; a different id means another operation owns it.
782
- const holderOp = currentRecord.operationId ?? '';
783
- if (holderOp === input.operationId) {
784
- return { ok: true, changed: false, record: currentRecord, previous: currentRecord };
785
- }
786
- return {
787
- ok: false,
788
- reason: 'operation_in_progress',
789
- message: `workspace is ${currentState} under operationId ${holderOp || '(none)'}; refusing to start ${input.operationId}`,
790
- nextAction: 'Wait for the in-flight operation to finish or abort it explicitly; one transition operation per workspace.',
791
- current: projectOwnership(currentState, currentGeneration, currentRecord),
792
- };
793
- }
794
761
  if (!spec.from.includes(currentState)) {
795
762
  return {
796
763
  ok: false,
@@ -800,23 +767,12 @@ export function transitionWorkspaceBackgroundExecution(input) {
800
767
  current: projectOwnership(currentState, currentGeneration, currentRecord),
801
768
  };
802
769
  }
803
- // complete/abort must address the operation that opened the transition.
804
- if (currentState === 'handover_preparing' || currentState === 'rollback_pending') {
805
- const holderOp = currentRecord?.operationId ?? '';
806
- if (holderOp !== input.operationId) {
807
- return {
808
- ok: false,
809
- reason: 'operation_mismatch',
810
- message: `${input.kind} addresses operationId ${input.operationId} but the transition record holds ${holderOp || '(none)'}`,
811
- nextAction: 'Use the persisted operationId, or abort the in-flight operation first.',
812
- current: projectOwnership(currentState, currentGeneration, currentRecord),
813
- };
814
- }
815
- }
770
+ // Historical handover/rollback operationIds are deliberately NOT matched
771
+ // here. Those records are residue from a deleted migration machine, not
772
+ // live operations; provisioning supersedes them directly.
816
773
  const target = buildTargetRecord({
817
774
  kind: input.kind,
818
775
  currentGeneration,
819
- operationId: input.operationId,
820
776
  nowIso: now().toISOString(),
821
777
  });
822
778
  // Mutate the RAW object (unknown top-level fields survive) using the same
@@ -837,19 +793,15 @@ export function transitionWorkspaceBackgroundExecution(input) {
837
793
  // Migrate the legacy single-key spelling away in the same write.
838
794
  delete raw.backgroundExecution;
839
795
  // The record key MUST be a workspaces[] member or it cannot parse back:
840
- // the real directory registers in the same CAS — on begin_handover for
841
- // a new workspace, on any later transition that migrated an alias-keyed
842
- // record (PRI-1282 review).
796
+ // once provisioning has been admitted, the real directory registers in
797
+ // the same CAS. This covers both first-time registration and migration of
798
+ // an alias-keyed record onto the real directory (PRI-1282 review).
843
799
  const registeredKeys = manifest.workspaces ?? [];
844
800
  const recordKeyRegistered = registeredKeys.some((entry) => pathApi.resolve(entry) === recordKey);
845
801
  if (!recordKeyRegistered) {
846
802
  raw.workspaces = mergeInstallManifestWorkspaces(manifest, recordKey, platform);
847
803
  raw.hosts = installManifestHostsForPersist(manifest);
848
804
  }
849
- else if (input.kind === 'begin_handover' && input.registerWorkspace === true && !registered) {
850
- raw.workspaces = mergeInstallManifestWorkspaces(manifest, recordKey, platform);
851
- raw.hosts = installManifestHostsForPersist(manifest);
852
- }
853
805
  // Re-validate the exact bytes we are about to land.
854
806
  const revalidated = parseInstallManifest(raw, input.platform);
855
807
  if (!revalidated.manifest || revalidated.manifest.backgroundExecutions?.[recordKey] === undefined) {
@@ -28,45 +28,55 @@ export interface InstallManifest {
28
28
  * Canonical absolute paths of Workspaces the install serves (PRI-624 Slice C).
29
29
  * Optional so pre-PRI-624 manifests stay valid; always normalized to
30
30
  * resolved absolute paths and deduped. The installer merges the install
31
- * Workspace in; the Companion worker discovers its per-Workspace workers
32
- * from this list (SPEC §13 "canonical install manifest").
31
+ * Workspace in; the Service Host discovers the Workspaces it serves from
32
+ * this list.
33
33
  */
34
34
  workspaces?: readonly string[];
35
35
  /**
36
- * Per-Workspace background-execution OWNERSHIP records (ADR-0020 §11.6
37
- * narrow scope / SPEC-PD-SERVICE-HOST-001 §8.4), keyed by canonical
36
+ * Per-Workspace background-execution OWNERSHIP records keyed by canonical
38
37
  * absolute workspace path — the same identity `workspaces` carries.
39
- * Optional so pre-record manifests stay valid; a Workspace with no entry
40
- * means "legacy Companion owns background execution" for THAT Workspace
41
- * only. Each Workspace migrates independently: one entry's transition
42
- * never touches another key, so Workspace A can be `service_host_owned`
43
- * while Workspace B is still `legacy_owned` or mid-`handover_preparing`.
38
+ * Optional so pre-record manifests stay valid; a Workspace with no entry is
39
+ * simply not-yet-provisioned. It does NOT mean a legacy consumer owns that
40
+ * Workspace: the legacy consumer implementation has been deleted repo-wide.
44
41
  *
45
- * This is the CAS contract between the legacy consumer and the Service
46
- * Host: only the state machine defined in the SPEC may advance an entry,
47
- * every transition is a monotonic-generation compare-and-set, and PID /
48
- * delays / startup order are NEVER ownership proof — this record is.
49
- * The CAS write path and the state machine live in
50
- * `background-execution-transition.ts` (Phase 4/5).
42
+ * `service_host_owned` is the only live ownership state. `legacy_owned`,
43
+ * `handover_preparing` and `rollback_pending` remain parseable solely as
44
+ * historical residue in pre-consolidation manifests; no writer may create
45
+ * them anymore. Consumption admission is binary — service-host-owned or
46
+ * not — and each Workspace converges independently: one entry's provision
47
+ * never touches another key.
48
+ *
49
+ * This is the Service Host provisioning contract: only
50
+ * `provision_fresh_install` may advance an entry, every write is a
51
+ * monotonic-generation compare-and-set, and PID / delays / startup order
52
+ * are NEVER ownership proof — this record is. Migration safety belongs to
53
+ * the installer's one-time stop-old-entries sequencing before provisioning;
54
+ * the CAS write path and read projection live in
55
+ * `background-execution-transition.ts`.
51
56
  */
52
57
  backgroundExecutions?: Readonly<Record<string, BackgroundExecutionRecord>>;
53
58
  }
59
+ /** `legacy` remains only so historical records remain parseable; new records are always `service_host`. */
54
60
  export declare const BACKGROUND_EXECUTION_OWNERS: readonly ['legacy', 'service_host'];
55
61
  export type BackgroundExecutionOwner = (typeof BACKGROUND_EXECUTION_OWNERS)[number];
62
+ /** All four states remain parseable historical schema; only `service_host_owned` is writable/live. */
56
63
  export declare const BACKGROUND_EXECUTION_STATES: readonly ['legacy_owned', 'handover_preparing', 'service_host_owned', 'rollback_pending'];
57
64
  export type BackgroundExecutionState = (typeof BACKGROUND_EXECUTION_STATES)[number];
58
65
  /**
59
- * The persisted ownership fact for background execution (SPEC §8.4).
60
- * - `state`/`effectiveOwner`: where the state machine currently stands and
61
- * which consumer is allowed to execute work RIGHT NOW;
62
- * - `generation`: strictly monotonic per accepted transition — the CAS key
66
+ * The persisted ownership fact for background execution.
67
+ * - `state`/`effectiveOwner`: the persisted ownership projection. In the
68
+ * Service-Host-only model only `service_host_owned`/`service_host` is a
69
+ * live admission fact; other combinations are parse-only historical
70
+ * residue and never admission proof;
71
+ * - `generation`: strictly monotonic per accepted write — the CAS key
63
72
  * (a writer must observe `generation` then write `generation+1` under the
64
73
  * manifest write lock; a stale observed generation loses);
65
- * - `operationId`: idempotency key of the handover/rollback operation —
66
- * replaying the same operationId must be a no-op;
67
- * - `previousOwner`/`targetOwner`: the two parties of an in-flight
68
- * transition (both null in a steady state);
69
- * - `updatedAt`: ISO-8601 timestamp of the last accepted transition.
74
+ * - `operationId`: operation attribution on historical in-flight records.
75
+ * Steady states persist null; terminal provisioning replay is a no-op
76
+ * rather than another generation;
77
+ * - `previousOwner`/`targetOwner`: the two parties of a historical
78
+ * migration record (both null in a steady state);
79
+ * - `updatedAt`: ISO-8601 timestamp of the last accepted write.
70
80
  */
71
81
  export interface BackgroundExecutionRecord {
72
82
  state: BackgroundExecutionState;
@@ -158,10 +168,12 @@ export declare function mergeInstallManifestWorkspaces(current: InstallManifest
158
168
  export declare function installManifestHostsForPersist(manifest: InstallManifest | undefined): string[];
159
169
  /**
160
170
  * Set or clear ONE Workspace's ownership record, preserving every other
161
- * Workspace's entry — the write-side half of "one migration never overwrites
162
- * another Workspace's state". `record` must already satisfy the semantic
163
- * contract (build it through the SPEC §8.4 state machine; absent record
164
- * removes the entry and restores the legacy default for that Workspace).
171
+ * Workspace's entry — the write-side half of "one workspace's provisioning
172
+ * never overwrites another Workspace's state". `record` must already satisfy
173
+ * the semantic contract; production writers build it through
174
+ * `transitionWorkspaceBackgroundExecution`, whose only live target is
175
+ * `service_host_owned`. Passing undefined removes the entry, returning that
176
+ * Workspace to the not-yet-provisioned absent-record shape.
165
177
  */
166
178
  export declare function setInstallManifestBackgroundExecution(manifest: InstallManifest | undefined, target: {
167
179
  workspaceDir: string;
@@ -293,10 +305,10 @@ export declare function selectCodexMcpBindingPath(codexHome: string, pluginRoot:
293
305
  */
294
306
  export { MCP_BINDING_SCHEMA_VERSION, MCP_BINDING_HOSTS, MCP_BINDING_SERVER_ENTRY_SEGMENTS, MCP_BINDING_SHAPE_CODES, MCP_BINDING_LAUNCHER_ONLY_REASONS, MCP_BINDING_FIXTURES, getCanonicalMcpServerEntry, getHostDefaultWorkspaceDirs, findForeignWorkspaceHost, collectHostWorkspaceClaims, findForeignWorkspaceOwner, isSameMcpBindingPath, validateMcpBinding, buildMcpBindingFixture, isMcpBindingHost, isSupportedBindingSchemaVersion, isSemverVersion, type McpBindingHost, type McpHostWorkspaceOptions, type McpBindingRecord, type McpBindingVerdict, type McpBindingShapeCode, type McpBindingFixture, type McpBindingFixtureId, type McpBindingFixtureContext, type HostWorkspaceClaim, type HostWorkspaceClaimVia, type HostClaimReaders, type HostClaimOptions, type JsonFileReadStatus, type BindingReadDiagnostic, type DirReadStatus, type ForeignWorkspaceOwnerVerdict, } from './mcp-binding-contract.js';
295
307
  /**
296
- * Workspace background-execution ownership transitions (SPEC §8.4 CAS write
297
- * path, PRI-1282 Phase 4): cross-process lock + generation-fenced state
298
- * machine + the single read-side ownership projection shared by the OpenClaw
299
- * Gateway gate, the `pd openclaw worker` gate and the handover/rollback
300
- * commands. Phase 5 reuses the same primitive for Codex / WorkBuddy.
308
+ * Workspace background-execution provisioning in the Service-Host-only model:
309
+ * a cross-process lock, a generation-fenced single live transition
310
+ * (`provision_fresh_install` → `service_host_owned`), and the read-side
311
+ * ownership projection. Historical legacy/handover/rollback states remain
312
+ * parseable residue only; consumption admission is binary.
301
313
  */
302
314
  export { DEFAULT_CAS_LOCK_STALE_MS, BACKGROUND_EXECUTION_TRANSITIONS, acquireBackgroundExecutionCasLock, defaultCasFsOps, readWorkspaceBackgroundOwnership, transitionWorkspaceBackgroundExecution, withInstallManifestWriteLock, type BackgroundExecutionTransitionKind, type TransitionBackgroundExecutionFailure, type TransitionBackgroundExecutionSuccess, type CasFsOps, type CasLockAcquireOptions, type CasLockAcquireResult, type CasLockHandle, type CasLockOwner, type ReadOwnershipOptions, type TransitionBackgroundExecutionInput, type WithManifestWriteLockOptions, type WithManifestWriteLockResult, type WorkspaceBackgroundOwnership, } from './background-execution-transition.js';
@@ -4,7 +4,9 @@ import { resolvePdHome } from './pd-home.js';
4
4
  export const INSTALL_LAYOUT_VERSION = 1;
5
5
  export const INSTALL_LAYOUT_MODES = ['canonical', 'legacy'];
6
6
  export const INSTALL_HOSTS = ['codex', 'openclaw', 'workbuddy'];
7
+ /** `legacy` remains only so historical records remain parseable; new records are always `service_host`. */
7
8
  export const BACKGROUND_EXECUTION_OWNERS = ['legacy', 'service_host'];
9
+ /** All four states remain parseable historical schema; only `service_host_owned` is writable/live. */
8
10
  export const BACKGROUND_EXECUTION_STATES = [
9
11
  'legacy_owned',
10
12
  'handover_preparing',
@@ -90,21 +92,23 @@ function isNullableOwner(value) {
90
92
  }
91
93
  /**
92
94
  * Fail-closed semantic check for one ownership record. Absent is fine
93
- * (legacy default); present-but-malformed is structural damage — an
95
+ * (not-yet-provisioned); present-but-malformed is structural damage — an
94
96
  * ownership fact that cannot be trusted must not be honored.
95
97
  *
96
98
  * Field types alone are NOT enough: the legal combination of
97
99
  * state/effectiveOwner/previousOwner/targetOwner/operationId/generation is
98
- * part of the contract (SPEC §8.4). Illegal combinations are refused at
99
- * parse time so a corrupt marker can never be honored as ownership proof:
100
+ * part of the persisted schema. Illegal combinations are refused at parse
101
+ * time so a corrupt marker can never be honored as ownership proof:
100
102
  * - legacy_owned: effectiveOwner=legacy, prev/target/operationId=null, generation>=0;
101
103
  * - service_host_owned: effectiveOwner=service_host, prev/target/operationId=null, generation>=1;
102
- * - handover_preparing: effectiveOwner=legacy (old consumer still owns until the CAS flips),
103
- * prev=legacy, target=service_host, operationId set, generation>=1;
104
- * - rollback_pending: effectiveOwner=service_host (still owned until the CAS restores),
105
- * prev=service_host, target=legacy, operationId set, generation>=1.
106
- * A transition state implies at least one accepted transition already
107
- * happened, so generation 0 there is unreachable and rejected.
104
+ * - handover_preparing: effectiveOwner=legacy, prev=legacy, target=service_host,
105
+ * operationId set, generation>=1 (historical residue only);
106
+ * - rollback_pending: effectiveOwner=service_host, prev=service_host, target=legacy,
107
+ * operationId set, generation>=1 (historical residue only).
108
+ * A historical transition state implies at least one accepted migration write
109
+ * already happened, so generation 0 there is unreachable and rejected. Only
110
+ * `service_host_owned` is writable or consumption-admitting in the current
111
+ * model; the other combinations remain readable for old manifests.
108
112
  */
109
113
  function parseBackgroundExecutionRecord(value) {
110
114
  if (value === undefined)
@@ -214,10 +218,12 @@ function parseBackgroundExecutions(value, workspaces, platform) {
214
218
  }
215
219
  /**
216
220
  * Set or clear ONE Workspace's ownership record, preserving every other
217
- * Workspace's entry — the write-side half of "one migration never overwrites
218
- * another Workspace's state". `record` must already satisfy the semantic
219
- * contract (build it through the SPEC §8.4 state machine; absent record
220
- * removes the entry and restores the legacy default for that Workspace).
221
+ * Workspace's entry — the write-side half of "one workspace's provisioning
222
+ * never overwrites another Workspace's state". `record` must already satisfy
223
+ * the semantic contract; production writers build it through
224
+ * `transitionWorkspaceBackgroundExecution`, whose only live target is
225
+ * `service_host_owned`. Passing undefined removes the entry, returning that
226
+ * Workspace to the not-yet-provisioned absent-record shape.
221
227
  */
222
228
  export function setInstallManifestBackgroundExecution(manifest, target, record) {
223
229
  const api = workspacePathApi(target.platform ?? process.platform);
@@ -557,10 +563,10 @@ export function selectCodexMcpBindingPath(codexHome, pluginRoot) {
557
563
  */
558
564
  export { MCP_BINDING_SCHEMA_VERSION, MCP_BINDING_HOSTS, MCP_BINDING_SERVER_ENTRY_SEGMENTS, MCP_BINDING_SHAPE_CODES, MCP_BINDING_LAUNCHER_ONLY_REASONS, MCP_BINDING_FIXTURES, getCanonicalMcpServerEntry, getHostDefaultWorkspaceDirs, findForeignWorkspaceHost, collectHostWorkspaceClaims, findForeignWorkspaceOwner, isSameMcpBindingPath, validateMcpBinding, buildMcpBindingFixture, isMcpBindingHost, isSupportedBindingSchemaVersion, isSemverVersion, } from './mcp-binding-contract.js';
559
565
  /**
560
- * Workspace background-execution ownership transitions (SPEC §8.4 CAS write
561
- * path, PRI-1282 Phase 4): cross-process lock + generation-fenced state
562
- * machine + the single read-side ownership projection shared by the OpenClaw
563
- * Gateway gate, the `pd openclaw worker` gate and the handover/rollback
564
- * commands. Phase 5 reuses the same primitive for Codex / WorkBuddy.
566
+ * Workspace background-execution provisioning in the Service-Host-only model:
567
+ * a cross-process lock, a generation-fenced single live transition
568
+ * (`provision_fresh_install` → `service_host_owned`), and the read-side
569
+ * ownership projection. Historical legacy/handover/rollback states remain
570
+ * parseable residue only; consumption admission is binary.
565
571
  */
566
572
  export { DEFAULT_CAS_LOCK_STALE_MS, BACKGROUND_EXECUTION_TRANSITIONS, acquireBackgroundExecutionCasLock, defaultCasFsOps, readWorkspaceBackgroundOwnership, transitionWorkspaceBackgroundExecution, withInstallManifestWriteLock, } from './background-execution-transition.js';
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/install-layout",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.156.2",
3
+ "version": "1.157.2",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -65,7 +65,7 @@
65
65
  "dependencies": {
66
66
  "@earendil-works/pi-agent-core": "1.6.0",
67
67
  "@earendil-works/pi-ai": "1.6.0",
68
- "@principles/install-layout": "^0.11.1",
68
+ "@principles/install-layout": "^0.12.0",
69
69
  "@sinclair/typebox": "^0.34.52",
70
70
  "@tufjs/models": "3.0.1",
71
71
  "@inquirer/prompts": "^8.8.0",
@@ -73,6 +73,7 @@
73
73
  "commander": "^15.1.0",
74
74
  "fs-extra": "^11.4.1",
75
75
  "js-yaml": "^5.4.3",
76
+ "json5": "2.2.3",
76
77
  "micromatch": "^4.0.8",
77
78
  "ora": "^10.0.0",
78
79
  "picocolors": "^1.0.0",
@@ -101,7 +102,7 @@
101
102
  "directory": "packages/create-principles-disciple"
102
103
  },
103
104
  "pd": {
104
- "bundledPluginVersion": "4.2.1"
105
+ "bundledPluginVersion": "4.4.1"
105
106
  },
106
- "gitHead": "3f068988cf04b22501a5c190f52f88630d1cb12f"
107
+ "gitHead": "ff62137821c993773cc7df104a01625310776c51"
107
108
  }
@@ -2,19 +2,23 @@ interface CodexWorkerOptions {
2
2
  workspace?: string;
3
3
  json?: boolean;
4
4
  once?: boolean;
5
- intervalMs?: number;
6
5
  status?: boolean;
7
6
  }
8
7
  export interface CodexWorkerStatusReport {
9
8
  generatedAt: string;
10
9
  host: 'codex';
11
10
  workspace: string;
12
- mode: 'ready' | 'manual_action_required' | 'paused' | 'degraded';
11
+ mode: 'ready' | 'paused' | 'degraded';
13
12
  registeredInInstallManifest: boolean;
13
+ serviceHostManaged: boolean;
14
+ ownership: {
15
+ state: string;
16
+ generation?: number;
17
+ source?: string;
18
+ };
14
19
  reason?: string;
15
20
  nextAction?: string;
16
21
  }
17
22
  export declare function handleCodexWorker(options: CodexWorkerOptions): Promise<void>;
18
23
  export {};
19
- /** SPEC §15 worker mode, evaluated without executing anything. */
20
24
  //# sourceMappingURL=codex-worker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex-worker.d.ts","sourceRoot":"","sources":["../../src/commands/codex-worker.ts"],"names":[],"mappings":"AA8DA,UAAU,kBAAkB;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,wBAAwB,GAAG,QAAQ,GAAG,UAAU,CAAC;IACjE,2BAA2B,EAAE,OAAO,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA2ID,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwDlF;;AAED,kEAAkE"}
1
+ {"version":3,"file":"codex-worker.d.ts","sourceRoot":"","sources":["../../src/commands/codex-worker.ts"],"names":[],"mappings":"AAoDA,UAAU,kBAAkB;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IACtC,2BAA2B,EAAE,OAAO,CAAC;IACrC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkMD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BlF"}