create-principles-disciple 1.156.2 → 1.157.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_release/product-identity.json +2 -2
- package/codex-adapter/dist/worker/workspace-worker.d.ts +11 -3
- package/codex-adapter/dist/worker/workspace-worker.js +30 -16
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/models/OwnerDecisionConsoleModel.js +33 -1
- package/console/dist/web/assets/app.js +3 -3
- package/core/dist/runtime/adversarial-loop.d.ts +8 -0
- package/core/dist/runtime/adversarial-loop.d.ts.map +1 -1
- package/core/dist/runtime/adversarial-loop.js +420 -45
- package/core/dist/runtime/adversarial-loop.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +3 -3
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/feature-flags/plugin-surface-registry.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/plugin-surface-registry.js +0 -16
- package/core/dist/runtime/feature-flags/plugin-surface-registry.js.map +1 -1
- package/core/dist/runtime/index.d.ts +4 -0
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +10 -0
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-runner.d.ts +9 -0
- package/core/dist/runtime/internalization/artificer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-runner.js +52 -0
- package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/correlation-lineage.d.ts +16 -3
- package/core/dist/runtime/internalization/correlation-lineage.d.ts.map +1 -1
- package/core/dist/runtime/internalization/correlation-lineage.js +4 -4
- package/core/dist/runtime/internalization/correlation-lineage.js.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.d.ts +35 -0
- package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.js +390 -91
- package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +40 -13
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.js +520 -199
- package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-transition-decision.js +1 -1
- package/core/dist/runtime/internalization/internalization-transition-decision.js.map +1 -1
- package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-resolution-service.js +10 -8
- package/core/dist/runtime/internalization/owner-resolution-service.js.map +1 -1
- package/core/dist/runtime/internalization/owner-review.d.ts +2 -0
- package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-review.js +17 -11
- package/core/dist/runtime/internalization/owner-review.js.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -0
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts +36 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.js +23 -2
- package/core/dist/runtime/internalization/pitask-metadata.js.map +1 -1
- package/core/dist/runtime/internalization/repair-create.d.ts +73 -0
- package/core/dist/runtime/internalization/repair-create.d.ts.map +1 -0
- package/core/dist/runtime/internalization/repair-create.js +200 -0
- package/core/dist/runtime/internalization/repair-create.js.map +1 -0
- package/core/dist/runtime/internalization/repair-lineage-backfill.d.ts +94 -0
- package/core/dist/runtime/internalization/repair-lineage-backfill.d.ts.map +1 -0
- package/core/dist/runtime/internalization/repair-lineage-backfill.js +123 -0
- package/core/dist/runtime/internalization/repair-lineage-backfill.js.map +1 -0
- package/core/dist/runtime/internalization/repair-task-identity.d.ts +99 -4
- package/core/dist/runtime/internalization/repair-task-identity.d.ts.map +1 -1
- package/core/dist/runtime/internalization/repair-task-identity.js +225 -7
- package/core/dist/runtime/internalization/repair-task-identity.js.map +1 -1
- package/core/dist/runtime/internalization/revision-reopen.d.ts +56 -1
- package/core/dist/runtime/internalization/revision-reopen.d.ts.map +1 -1
- package/core/dist/runtime/internalization/revision-reopen.js +82 -39
- package/core/dist/runtime/internalization/revision-reopen.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +0 -7
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js +13 -68
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/successor-create.d.ts +69 -0
- package/core/dist/runtime/internalization/successor-create.d.ts.map +1 -0
- package/core/dist/runtime/internalization/successor-create.js +173 -0
- package/core/dist/runtime/internalization/successor-create.js.map +1 -0
- package/core/dist/runtime/internalization/successor-lookup.d.ts +50 -0
- package/core/dist/runtime/internalization/successor-lookup.d.ts.map +1 -0
- package/core/dist/runtime/internalization/successor-lookup.js +213 -0
- package/core/dist/runtime/internalization/successor-lookup.js.map +1 -0
- package/core/dist/runtime/runner/succeeded-result-recovery.d.ts +58 -0
- package/core/dist/runtime/runner/succeeded-result-recovery.d.ts.map +1 -0
- package/core/dist/runtime/runner/succeeded-result-recovery.js +117 -0
- package/core/dist/runtime/runner/succeeded-result-recovery.js.map +1 -0
- package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -0
- package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.js +4 -0
- package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime/store/task/memory-task-store.d.ts +3 -3
- package/core/dist/runtime/store/task/memory-task-store.d.ts.map +1 -1
- package/core/dist/runtime/store/task/memory-task-store.js +52 -0
- package/core/dist/runtime/store/task/memory-task-store.js.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts +3 -0
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.js +204 -135
- package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime/store/task/task-store.d.ts +17 -0
- package/core/dist/runtime/store/task/task-store.d.ts.map +1 -1
- package/core/dist/telemetry-event.d.ts +2 -2
- package/core/dist/telemetry-event.d.ts.map +1 -1
- package/core/dist/telemetry-event.js +4 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +69 -11
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +432 -120
- package/dist/installer.js.map +1 -1
- package/dist/service-host-bridge.d.ts +0 -5
- package/dist/service-host-bridge.d.ts.map +1 -1
- package/dist/service-host-bridge.js.map +1 -1
- package/dist/service-host-provisioning.d.ts +123 -18
- package/dist/service-host-provisioning.d.ts.map +1 -1
- package/dist/service-host-provisioning.js +645 -77
- package/dist/service-host-provisioning.js.map +1 -1
- package/dist/utils/env.d.ts +9 -0
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +269 -49
- package/dist/utils/env.js.map +1 -1
- package/host-runtime/dist/codex-worker-status.d.ts +6 -4
- package/host-runtime/dist/codex-worker-status.js +7 -5
- package/host-runtime/dist/diagnostician-auto-run.js +2 -2
- package/host-runtime/dist/governance-signal-admission.d.ts +2 -1
- package/host-runtime/dist/governance-signal-admission.js +2 -1
- package/host-runtime/dist/index.d.ts +4 -2
- package/host-runtime/dist/index.js +6 -2
- package/host-runtime/dist/internalization-consumer-cycle.d.ts +13 -106
- package/host-runtime/dist/internalization-consumer-cycle.js +21 -99
- package/host-runtime/dist/internalization-consumer-governance.d.ts +3 -3
- package/host-runtime/dist/internalization-consumer-governance.js +17 -96
- package/host-runtime/dist/internalization-task-executor.d.ts +127 -0
- package/host-runtime/dist/internalization-task-executor.js +121 -0
- package/host-runtime/dist/workbuddy-worker-status.d.ts +6 -3
- package/host-runtime/dist/workbuddy-worker-status.js +7 -4
- package/host-runtime/dist/workspace-telemetry-emitter.js +1 -1
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/background-execution-transition.d.ts +25 -29
- package/install-layout/dist/background-execution-transition.js +90 -138
- package/install-layout/dist/index.d.ts +45 -33
- package/install-layout/dist/index.js +24 -18
- package/install-layout/package.json +1 -1
- package/package.json +5 -4
- package/pd-cli/dist/commands/codex-worker.d.ts +7 -3
- package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/codex-worker.js +125 -101
- package/pd-cli/dist/commands/codex-worker.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +148 -130
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +4 -0
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
- package/pd-cli/dist/commands/service-run-once.d.ts +12 -27
- package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/service-run-once.js +15 -206
- package/pd-cli/dist/commands/service-run-once.js.map +1 -1
- package/pd-cli/dist/commands/workbuddy-worker.d.ts +7 -2
- package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/workbuddy-worker.js +133 -99
- package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
- package/pd-cli/dist/commands/worker-service-host-gate.d.ts +38 -0
- package/pd-cli/dist/commands/worker-service-host-gate.d.ts.map +1 -0
- package/pd-cli/dist/commands/worker-service-host-gate.js +110 -0
- package/pd-cli/dist/commands/worker-service-host-gate.js.map +1 -0
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +20 -84
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/rulehost-pipeline-runner.js +198 -142
- package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
- package/pd-cli/dist/services/service-host/coordinator-common.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/coordinator-common.js +4 -5
- package/pd-cli/dist/services/service-host/coordinator-common.js.map +1 -1
- package/pd-cli/dist/services/service-host/index.d.ts +7 -10
- package/pd-cli/dist/services/service-host/index.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/index.js +8 -11
- package/pd-cli/dist/services/service-host/index.js.map +1 -1
- package/pd-cli/dist/services/service-host/install-identity.d.ts +5 -5
- package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/managed-run.js +19 -22
- package/pd-cli/dist/services/service-host/managed-run.js.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/linux.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/linux.js +21 -2
- package/pd-cli/dist/services/service-host/scheduler/linux.js.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +1 -1
- package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/service-status.js +0 -2
- package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -1
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +7 -51
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
- package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js +3 -3
- package/pd-cli/dist/services/service-host/worker-adapter.d.ts +0 -10
- package/pd-cli/dist/services/service-host/worker-adapter.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/worker-adapter.js +4 -12
- package/pd-cli/dist/services/service-host/worker-adapter.js.map +1 -1
- package/pd-cli/dist/services/service-host/worker-env.d.ts +1 -1
- package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts +5 -7
- package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/workspace-dispatch.js +1 -3
- package/pd-cli/dist/services/service-host/workspace-dispatch.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +616 -1319
- package/plugin/dist/core/openclaw-tool-declaration.d.ts +13 -0
- package/plugin/dist/index.d.ts +0 -9
- package/plugin/dist/openclaw-worker.d.ts +21 -8
- package/plugin/dist/openclaw-worker.js +267 -267
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +432 -120
- package/release-manager/dist/service-host-provisioning.js +645 -77
- package/release-manager/dist/utils/env.js +269 -49
- package/release-manager/package.json +3 -2
- package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +9 -1
- package/workbuddy-adapter/dist/worker/workspace-worker.js +21 -9
- package/workbuddy-adapter/package.json +1 -1
- package/pd-cli/dist/commands/service-handover.d.ts +0 -12
- package/pd-cli/dist/commands/service-handover.d.ts.map +0 -1
- package/pd-cli/dist/commands/service-handover.js +0 -117
- package/pd-cli/dist/commands/service-handover.js.map +0 -1
- package/pd-cli/dist/commands/worker-drain.d.ts +0 -7
- package/pd-cli/dist/commands/worker-drain.d.ts.map +0 -1
- package/pd-cli/dist/commands/worker-drain.js +0 -51
- package/pd-cli/dist/commands/worker-drain.js.map +0 -1
- package/pd-cli/dist/services/service-host/handover-claims.d.ts +0 -14
- package/pd-cli/dist/services/service-host/handover-claims.d.ts.map +0 -1
- package/pd-cli/dist/services/service-host/handover-claims.js +0 -50
- package/pd-cli/dist/services/service-host/handover-claims.js.map +0 -1
- package/pd-cli/dist/services/service-host/shadow-run.d.ts +0 -87
- package/pd-cli/dist/services/service-host/shadow-run.d.ts.map +0 -1
- package/pd-cli/dist/services/service-host/shadow-run.js +0 -549
- package/pd-cli/dist/services/service-host/shadow-run.js.map +0 -1
- package/pd-cli/dist/services/service-host/workspace-handover.d.ts +0 -190
- package/pd-cli/dist/services/service-host/workspace-handover.d.ts.map +0 -1
- package/pd-cli/dist/services/service-host/workspace-handover.js +0 -1393
- package/pd-cli/dist/services/service-host/workspace-handover.js.map +0 -1
- package/plugin/dist/service/gateway-consumer-lease.d.ts +0 -142
- package/plugin/dist/service/gateway-quiesce-ack.d.ts +0 -40
- package/plugin/dist/service/internalization-auto-consumer-service.d.ts +0 -100
|
@@ -17,14 +17,14 @@ import { atomicReplaceTextFile, errnoCode } from './utils/config-file-io.js';
|
|
|
17
17
|
import { readCanonicalRuntimeCohort, readInstalledRuntimeCohort, resolvePluginDataRoot } from './installers/codex-host-installer.js';
|
|
18
18
|
import { runWorkbuddyEarlyPreflight } from './installers/workbuddy-host-installer.js';
|
|
19
19
|
import { findForeignWorkspaceOwner } from './utils/host-workspace-ownership.js';
|
|
20
|
-
import { INSTALL_LAYOUT_VERSION, getInstallLayoutPaths, getWorkbuddyWorkspaceDir, installManifestHostsForPersist, mergeInstallManifestWorkspaces, parseInstallManifest, resolvePdHome } from '@principles/install-layout';
|
|
20
|
+
import { INSTALL_LAYOUT_VERSION, getInstallLayoutPaths, getWorkbuddyWorkspaceDir, installManifestHostsForPersist, mergeInstallManifestWorkspaces, parseInstallManifest, readWorkspaceBackgroundOwnership, resolvePdHome, validateMcpBinding, getHostDefaultWorkspaceDirs } from '@principles/install-layout';
|
|
21
21
|
// Namespace import keeps the shared lock capability check explicit at the
|
|
22
22
|
// write boundary; an incompatible older dependency cohort fails closed.
|
|
23
23
|
import * as installLayoutModule from '@principles/install-layout';
|
|
24
24
|
import { resolveMcpServerDir } from './mcp-server-layout-compat.js';
|
|
25
25
|
import { detectOpenClawMainWorkspaceDivergence } from './utils/workspace-divergence.js';
|
|
26
26
|
import { reconcileServiceHostScheduler } from './service-host-bridge.js';
|
|
27
|
-
import { provisionFreshInstallWorkspace, readAllPendingProvisioning,
|
|
27
|
+
import { provisionFreshInstallWorkspace, readAllPendingProvisioning, scanRunningLegacyWorkerProcesses } from './service-host-provisioning.js';
|
|
28
28
|
import { applySkillLanguageSelection } from './skill-language.js';
|
|
29
29
|
import { parseReleaseAssetIdentity, parseReleaseAssetManifest, ReleaseAssetManifestError, verifyReleaseAssetManifestAsync, verifyReleaseAssetTarget, } from './update/release-asset-manifest.js';
|
|
30
30
|
import { parseEmbeddedProductIdentity, ProductIdentityError } from './update/product-identity.js';
|
|
@@ -154,9 +154,11 @@ function installsWorkbuddy(host) {
|
|
|
154
154
|
* PRI-1278 Phase 5 review: when may THIS run (re)initialize ownership?
|
|
155
155
|
*
|
|
156
156
|
* - a fresh install always records the attempt (a pending marker on failure);
|
|
157
|
-
* - an existing install resumes ONLY with explicit enable consent
|
|
158
|
-
*
|
|
159
|
-
*
|
|
157
|
+
* - an existing install resumes ONLY with explicit enable consent for a
|
|
158
|
+
* workspace registered in the authoritative install manifest. A pending
|
|
159
|
+
* marker is resume evidence, not migration eligibility: historical
|
|
160
|
+
* workspaces never wrote that marker and must still migrate when the Owner
|
|
161
|
+
* explicitly authorizes it.
|
|
160
162
|
*/
|
|
161
163
|
export function shouldProvisionOnInstall(input) {
|
|
162
164
|
if (input.freshInstall)
|
|
@@ -164,7 +166,8 @@ export function shouldProvisionOnInstall(input) {
|
|
|
164
166
|
return input.consentIntent === 'enable'
|
|
165
167
|
&& input.consentSource === 'explicit_flag'
|
|
166
168
|
&& input.schedulerState === 'enabled'
|
|
167
|
-
&& input.
|
|
169
|
+
&& input.workspaceRegistered
|
|
170
|
+
&& !input.alreadyOwned;
|
|
168
171
|
}
|
|
169
172
|
/** Stable identity for a workspace directory (real path, case-insensitive on Windows). */
|
|
170
173
|
function workspaceKey(workspaceDir) {
|
|
@@ -209,22 +212,36 @@ export function resolveProvisioningTargets(options) {
|
|
|
209
212
|
});
|
|
210
213
|
}
|
|
211
214
|
/**
|
|
212
|
-
* Merge
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
+
* Merge the authoritative install-manifest workspaces into an explicitly
|
|
216
|
+
* authorized existing-install migration. Manifest entries carry no host bias:
|
|
217
|
+
* the per-target binding resolver below proves which host (if any) owns the
|
|
218
|
+
* workspace NOW. This deliberately does not infer targets from cwd or HOME.
|
|
215
219
|
*/
|
|
216
|
-
export function
|
|
220
|
+
export function mergeManifestProvisioningTargets(targets, manifestWorkspaces) {
|
|
217
221
|
const merged = [...targets];
|
|
218
222
|
const seen = new Set(targets.map((target) => workspaceKey(target.workspaceDir)));
|
|
219
|
-
for (const
|
|
220
|
-
const key = workspaceKey(
|
|
223
|
+
for (const workspaceDir of manifestWorkspaces) {
|
|
224
|
+
const key = workspaceKey(workspaceDir);
|
|
221
225
|
if (seen.has(key))
|
|
222
226
|
continue;
|
|
223
227
|
seen.add(key);
|
|
224
|
-
merged.push({ host:
|
|
228
|
+
merged.push({ host: 'none', workspaceDir });
|
|
225
229
|
}
|
|
226
230
|
return merged;
|
|
227
231
|
}
|
|
232
|
+
/** Read authoritative workspace registrations for explicit migration; malformed means none are eligible. */
|
|
233
|
+
function readManifestWorkspacesForProvisioning() {
|
|
234
|
+
const manifestPath = getInstallManifestPath();
|
|
235
|
+
try {
|
|
236
|
+
const parsed = parseInstallManifest(readInstallJsonRecord(manifestPath));
|
|
237
|
+
if (!parsed.manifest)
|
|
238
|
+
return { workspaces: [], warning: `install manifest could not be validated (${parsed.error ?? 'unknown'}); historical workspace migration is fail-closed.` };
|
|
239
|
+
return { workspaces: parsed.manifest.workspaces ?? [] };
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
return { workspaces: [], warning: `install manifest could not be read (${error instanceof Error ? error.message : String(error)}); historical workspace migration is fail-closed.` };
|
|
243
|
+
}
|
|
244
|
+
}
|
|
228
245
|
/**
|
|
229
246
|
* Whether this run actually serves Codex — as the requested install target or
|
|
230
247
|
* as a persisted sibling host being refreshed. The Codex workspace is
|
|
@@ -331,7 +348,8 @@ export function planUpgradeHosts(requested, persistedHosts, detected) {
|
|
|
331
348
|
}
|
|
332
349
|
/**
|
|
333
350
|
* PRI-624 Slice C: the install manifest records every Workspace this install
|
|
334
|
-
* serves so the
|
|
351
|
+
* serves so the PD Service Host — the only background runtime — can discover
|
|
352
|
+
* the workspaces it owns and dispatches bounded worker cycles for (SPEC §13
|
|
335
353
|
* "canonical install manifest"). Idempotent by canonical path.
|
|
336
354
|
*
|
|
337
355
|
* WorkBuddy (SPEC workbuddy-host-adapter §6): when the run targets workbuddy,
|
|
@@ -346,12 +364,12 @@ export function planUpgradeHosts(requested, persistedHosts, detected) {
|
|
|
346
364
|
* between the read and the locked write lost the workspaces[] entry, making
|
|
347
365
|
* the manifest fail validation (ownership key not in the declared list).
|
|
348
366
|
*/
|
|
349
|
-
function mergeInstallManifestWorkspacesFor(current,
|
|
350
|
-
let workspaces =
|
|
351
|
-
|
|
367
|
+
function mergeInstallManifestWorkspacesFor(current, workspaceDirs) {
|
|
368
|
+
let workspaces = [...(current?.workspaces ?? [])];
|
|
369
|
+
for (const workspaceDir of workspaceDirs) {
|
|
352
370
|
// Set-union via the same authority helper — order of existing entries is
|
|
353
|
-
// preserved,
|
|
354
|
-
workspaces = mergeInstallManifestWorkspaces({ layoutVersion: current?.layoutVersion ?? INSTALL_LAYOUT_VERSION, mode: current?.mode ?? 'canonical', hosts: current?.hosts ?? [], workspaces },
|
|
371
|
+
// preserved, each real workspace is appended when absent (idempotent).
|
|
372
|
+
workspaces = mergeInstallManifestWorkspaces({ layoutVersion: current?.layoutVersion ?? INSTALL_LAYOUT_VERSION, mode: current?.mode ?? 'canonical', hosts: current?.hosts ?? [], workspaces }, path.resolve(workspaceDir));
|
|
355
373
|
}
|
|
356
374
|
return workspaces;
|
|
357
375
|
}
|
|
@@ -1837,6 +1855,7 @@ async function resolveGatewayAction(status, opts) {
|
|
|
1837
1855
|
return 'stop';
|
|
1838
1856
|
if (!opts.interactive)
|
|
1839
1857
|
return 'abort';
|
|
1858
|
+
const allowProceed = opts.allowProceed !== false;
|
|
1840
1859
|
const portInfo = status.port ? ` (port ${status.port})` : '';
|
|
1841
1860
|
const pidInfo = status.pid ? `, PID ${status.pid}` : '';
|
|
1842
1861
|
logger.warn(`${t('gateway_running')}${portInfo}${pidInfo}.`);
|
|
@@ -1845,11 +1864,13 @@ async function resolveGatewayAction(status, opts) {
|
|
|
1845
1864
|
message: t('gateway_prompt_title'),
|
|
1846
1865
|
choices: [
|
|
1847
1866
|
{ value: 'stop', name: t('gateway_choice_stop') },
|
|
1848
|
-
{ value: 'proceed', name: t('gateway_choice_proceed') },
|
|
1867
|
+
...(allowProceed ? [{ value: 'proceed', name: t('gateway_choice_proceed') }] : []),
|
|
1849
1868
|
{ value: 'abort', name: t('gateway_choice_abort') },
|
|
1850
1869
|
],
|
|
1851
1870
|
});
|
|
1852
|
-
|
|
1871
|
+
// Accepting EPERM risk is not evidence that a legacy consumer is quiescent.
|
|
1872
|
+
// Ownership migration removes that choice; treat any unexpected proceed as abort.
|
|
1873
|
+
return choice === 'proceed' && !allowProceed ? 'abort' : choice;
|
|
1853
1874
|
}
|
|
1854
1875
|
/**
|
|
1855
1876
|
* Structured failure result for a gateway pre-flight refusal — either the run
|
|
@@ -4483,42 +4504,115 @@ function readCodexBindingFromPayloadCache() {
|
|
|
4483
4504
|
? { state: 'invalid', reason: firstInvalid ?? 'no readable Codex mcp-binding.json under the plugin cache' }
|
|
4484
4505
|
: { state: 'absent' };
|
|
4485
4506
|
}
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
if (!existsSync(configPath)) {
|
|
4498
|
-
return { state: 'unbound', reason: `openclaw declaration absent at ${configPath}` };
|
|
4499
|
-
}
|
|
4500
|
-
let raw;
|
|
4501
|
-
try {
|
|
4502
|
-
raw = readFileSync(configPath, 'utf-8');
|
|
4503
|
-
}
|
|
4504
|
-
catch (error) {
|
|
4505
|
-
return { state: 'unverifiable', reason: `openclaw declaration unreadable at ${configPath} (${describeError(error)})` };
|
|
4506
|
-
}
|
|
4507
|
+
function readOpenClawDeclarationEvidence() {
|
|
4508
|
+
// Mirror the host resolver's persistent declaration precedence: the primary
|
|
4509
|
+
// declaration wins when usable; the legacy secondary file is consulted only
|
|
4510
|
+
// when the primary is absent. PD_WORKSPACE_DIR / OPENCLAW_WORKSPACE are
|
|
4511
|
+
// process-environment inputs inside OpenClaw-launched processes, not proof
|
|
4512
|
+
// that the installer process's own inherited environment is an OpenClaw
|
|
4513
|
+
// binding. A stale lower-priority record must not block migration, but
|
|
4514
|
+
// malformed effective evidence is unverifiable.
|
|
4515
|
+
const readOne = (configPath) => {
|
|
4516
|
+
if (!existsSync(configPath))
|
|
4517
|
+
return { state: 'absent' };
|
|
4507
4518
|
let parsed;
|
|
4508
4519
|
try {
|
|
4509
|
-
parsed = JSON.parse(
|
|
4520
|
+
parsed = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
4510
4521
|
}
|
|
4511
4522
|
catch (error) {
|
|
4512
|
-
return { state: 'unverifiable', reason: `openclaw declaration
|
|
4523
|
+
return { state: 'unverifiable', reason: `openclaw declaration unreadable/invalid at ${configPath} (${describeError(error)})` };
|
|
4513
4524
|
}
|
|
4514
4525
|
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
4515
4526
|
return { state: 'unverifiable', reason: `openclaw declaration at ${configPath} has no JSON-object root` };
|
|
4516
4527
|
}
|
|
4517
4528
|
const declared = Object.hasOwn(parsed, 'workspace') ? Reflect.get(parsed, 'workspace') : undefined;
|
|
4518
4529
|
if (typeof declared !== 'string' || !isUsableWorkspacePointer(declared.trim())) {
|
|
4519
|
-
return { state: '
|
|
4530
|
+
return { state: 'unverifiable', reason: `openclaw declaration at ${configPath} has no usable absolute "workspace"` };
|
|
4520
4531
|
}
|
|
4521
4532
|
return { state: 'bound', workspaceDir: path.resolve(declared.trim()), source: 'openclaw_declaration' };
|
|
4533
|
+
};
|
|
4534
|
+
const primary = readOne(path.join(getOpenClawDir(), OPENCLAW_PD_CONFIG_FILENAME));
|
|
4535
|
+
if (primary.state !== 'absent')
|
|
4536
|
+
return primary;
|
|
4537
|
+
return readOne(path.join(getHomeDir(), '.principles', OPENCLAW_PD_CONFIG_FILENAME));
|
|
4538
|
+
}
|
|
4539
|
+
function readOpenClawPayloadBindingEvidence() {
|
|
4540
|
+
const bindingPath = path.join(getPluginExtDir(), 'mcp-binding.json');
|
|
4541
|
+
if (!existsSync(bindingPath))
|
|
4542
|
+
return { state: 'absent' };
|
|
4543
|
+
let parsed;
|
|
4544
|
+
try {
|
|
4545
|
+
parsed = JSON.parse(readFileSync(bindingPath, 'utf-8'));
|
|
4546
|
+
}
|
|
4547
|
+
catch (error) {
|
|
4548
|
+
return { state: 'unverifiable', reason: `openclaw mcp-binding unreadable/invalid at ${bindingPath} (${describeError(error)})` };
|
|
4549
|
+
}
|
|
4550
|
+
const verdict = validateMcpBinding(parsed, 'openclaw', process.platform);
|
|
4551
|
+
if (!verdict.ok) {
|
|
4552
|
+
return { state: 'unverifiable', reason: `openclaw mcp-binding at ${bindingPath} is invalid (${verdict.reason})` };
|
|
4553
|
+
}
|
|
4554
|
+
const workspaceDir = path.resolve(verdict.binding.workspaceDir.trim());
|
|
4555
|
+
if (!existsSync(workspaceDir)) {
|
|
4556
|
+
return { state: 'unverifiable', reason: `openclaw mcp-binding at ${bindingPath} names a workspace that does not exist (${workspaceDir})` };
|
|
4557
|
+
}
|
|
4558
|
+
return { state: 'bound', workspaceDir, source: 'openclaw_mcp_binding' };
|
|
4559
|
+
}
|
|
4560
|
+
function readOpenClawWorkspaceBindingEvidence() {
|
|
4561
|
+
const declaration = readOpenClawDeclarationEvidence();
|
|
4562
|
+
const payload = readOpenClawPayloadBindingEvidence();
|
|
4563
|
+
if (declaration.state === 'unverifiable' || payload.state === 'unverifiable') {
|
|
4564
|
+
return {
|
|
4565
|
+
state: 'unverifiable',
|
|
4566
|
+
reason: [declaration, payload]
|
|
4567
|
+
.filter((entry) => entry.state === 'unverifiable')
|
|
4568
|
+
.map((entry) => entry.reason).join('; '),
|
|
4569
|
+
};
|
|
4570
|
+
}
|
|
4571
|
+
if (declaration.state === 'bound') {
|
|
4572
|
+
if (payload.state === 'bound' && !sameWorkspaceTarget(payload.workspaceDir, declaration.workspaceDir)) {
|
|
4573
|
+
return { state: 'unverifiable', reason: `conflicting OpenClaw workspace evidence: openclaw_declaration=${declaration.workspaceDir}; openclaw_mcp_binding=${payload.workspaceDir}` };
|
|
4574
|
+
}
|
|
4575
|
+
return { state: 'bound', workspaceDir: declaration.workspaceDir, source: 'openclaw_declaration' };
|
|
4576
|
+
}
|
|
4577
|
+
if (payload.state === 'bound') {
|
|
4578
|
+
// OpenClaw also supports an ENVIRONMENT-only workspace declaration: the
|
|
4579
|
+
// Gateway child inherits PD_WORKSPACE_DIR / OPENCLAW_WORKSPACE and its
|
|
4580
|
+
// health path then writes this OpenClaw-specific payload binding. The
|
|
4581
|
+
// installer's inherited environment is not independently sufficient (it
|
|
4582
|
+
// may belong to a Codex-only shell), but an exact env declaration ↔
|
|
4583
|
+
// OpenClaw-written binding match is verifiable host evidence. A payload
|
|
4584
|
+
// binding with no matching persistent or environment declaration remains
|
|
4585
|
+
// orphaned residue and fail-closed.
|
|
4586
|
+
const environmentDeclarations = [process.env.OPENCLAW_WORKSPACE, process.env.PD_WORKSPACE_DIR]
|
|
4587
|
+
.filter((value) => typeof value === 'string' && isUsableWorkspacePointer(value.trim()))
|
|
4588
|
+
.map((value) => path.resolve(value.trim()));
|
|
4589
|
+
if (environmentDeclarations.some((workspaceDir) => sameWorkspaceTarget(workspaceDir, payload.workspaceDir))) {
|
|
4590
|
+
return { state: 'bound', workspaceDir: payload.workspaceDir, source: 'openclaw_mcp_binding' };
|
|
4591
|
+
}
|
|
4592
|
+
return { state: 'unverifiable', reason: `openclaw mcp-binding records ${payload.workspaceDir}, but no effective OpenClaw declaration anchors it` };
|
|
4593
|
+
}
|
|
4594
|
+
return { state: 'unbound', reason: 'OpenClaw declaration and mcp-binding are absent; no workspace is recorded' };
|
|
4595
|
+
}
|
|
4596
|
+
function hostDefaultClaimOptions() {
|
|
4597
|
+
return {
|
|
4598
|
+
homeDir: getHomeDir(),
|
|
4599
|
+
codexHome: getCodexHomeDir(),
|
|
4600
|
+
openclawHome: getOpenClawDir(),
|
|
4601
|
+
workbuddyConfigDir: process.env.WORKBUDDY_CONFIG_DIR ?? path.join(getHomeDir(), '.workbuddy'),
|
|
4602
|
+
platform: process.platform,
|
|
4603
|
+
};
|
|
4604
|
+
}
|
|
4605
|
+
/** The workspace a host is ACTUALLY bound to, read from that host's own record. */
|
|
4606
|
+
export function readHostWorkspaceBinding(host) {
|
|
4607
|
+
if (host === 'workbuddy') {
|
|
4608
|
+
return {
|
|
4609
|
+
state: 'bound',
|
|
4610
|
+
workspaceDir: getWorkbuddyWorkspaceDir(getHomeDir(), process.env.WORKBUDDY_CONFIG_DIR),
|
|
4611
|
+
source: 'workbuddy_governance_dir',
|
|
4612
|
+
};
|
|
4613
|
+
}
|
|
4614
|
+
if (host === 'openclaw') {
|
|
4615
|
+
return readOpenClawWorkspaceBindingEvidence();
|
|
4522
4616
|
}
|
|
4523
4617
|
// Codex: durable binding first, payload-local legacy second — the same
|
|
4524
4618
|
// authority order the launcher and `pd health` use.
|
|
@@ -4537,6 +4631,25 @@ export function readHostWorkspaceBinding(host) {
|
|
|
4537
4631
|
return { state: 'unverifiable', reason: payload.reason };
|
|
4538
4632
|
return { state: 'unbound', reason: 'no Codex mcp-binding.json records an existing workspace' };
|
|
4539
4633
|
}
|
|
4634
|
+
/** Target-specific OpenClaw claim judgment: explicit evidence plus the host default workspaces. */
|
|
4635
|
+
function openClawWorkspaceClaimState(workspaceDir) {
|
|
4636
|
+
let binding;
|
|
4637
|
+
try {
|
|
4638
|
+
binding = readHostWorkspaceBinding('openclaw');
|
|
4639
|
+
}
|
|
4640
|
+
catch {
|
|
4641
|
+
return 'unverifiable';
|
|
4642
|
+
}
|
|
4643
|
+
if (binding.state === 'unverifiable')
|
|
4644
|
+
return 'unverifiable';
|
|
4645
|
+
if (binding.state === 'bound' && sameWorkspaceTarget(binding.workspaceDir, workspaceDir))
|
|
4646
|
+
return 'bound';
|
|
4647
|
+
for (const candidate of getHostDefaultWorkspaceDirs('openclaw', hostDefaultClaimOptions())) {
|
|
4648
|
+
if (sameWorkspaceTarget(candidate, workspaceDir))
|
|
4649
|
+
return 'bound';
|
|
4650
|
+
}
|
|
4651
|
+
return 'unbound';
|
|
4652
|
+
}
|
|
4540
4653
|
/**
|
|
4541
4654
|
* PRI-1278 Phase 5 review: a host that is REFRESHED (not explicitly selected)
|
|
4542
4655
|
* must keep the workspace it is already bound to. Passing this run's target
|
|
@@ -4572,6 +4685,16 @@ export function resolveResumeProvisioningHost(markerHost, workspaceDir) {
|
|
|
4572
4685
|
const bound = [];
|
|
4573
4686
|
const unverifiable = [];
|
|
4574
4687
|
for (const host of candidates) {
|
|
4688
|
+
if (host === 'openclaw') {
|
|
4689
|
+
const claim = openClawWorkspaceClaimState(workspaceDir);
|
|
4690
|
+
if (claim === 'unverifiable') {
|
|
4691
|
+
unverifiable.push('openclaw: workspace claim evidence could not be verified');
|
|
4692
|
+
}
|
|
4693
|
+
else if (claim === 'bound') {
|
|
4694
|
+
bound.push(host);
|
|
4695
|
+
}
|
|
4696
|
+
continue;
|
|
4697
|
+
}
|
|
4575
4698
|
let binding;
|
|
4576
4699
|
try {
|
|
4577
4700
|
binding = readHostWorkspaceBinding(host);
|
|
@@ -4588,15 +4711,25 @@ export function resolveResumeProvisioningHost(markerHost, workspaceDir) {
|
|
|
4588
4711
|
bound.push(host);
|
|
4589
4712
|
}
|
|
4590
4713
|
}
|
|
4591
|
-
|
|
4714
|
+
// Positive evidence for one host is not evidence that another host is
|
|
4715
|
+
// absent. Any unverifiable binding evidence keeps the migration fail-closed.
|
|
4716
|
+
if (unverifiable.length > 0) {
|
|
4592
4717
|
return {
|
|
4593
4718
|
ok: false,
|
|
4594
4719
|
reason: unverifiable.join('; '),
|
|
4595
4720
|
nextAction: 'Repair the host binding file(s) so the workspace ownership can be verified, then re-run this install.',
|
|
4596
4721
|
};
|
|
4597
4722
|
}
|
|
4598
|
-
if (bound.length === 0)
|
|
4723
|
+
if (bound.length === 0) {
|
|
4724
|
+
if (markerHost !== 'none') {
|
|
4725
|
+
return {
|
|
4726
|
+
ok: false,
|
|
4727
|
+
reason: `pending provisioning evidence names host "${markerHost}", but no current binding for that workspace could be verified`,
|
|
4728
|
+
nextAction: 'Repair or re-create the recorded host binding, or explicitly retire the legacy consumer before re-running this install. Absence of a binding is not proof that the recorded consumer is absent.',
|
|
4729
|
+
};
|
|
4730
|
+
}
|
|
4599
4731
|
return { ok: true, host: 'none' };
|
|
4732
|
+
}
|
|
4600
4733
|
if (bound.includes('openclaw') && bound.includes('codex'))
|
|
4601
4734
|
return { ok: true, host: 'all' };
|
|
4602
4735
|
if (markerHost !== 'none' && markerHost !== 'all' && bound.includes(markerHost)) {
|
|
@@ -4604,6 +4737,143 @@ export function resolveResumeProvisioningHost(markerHost, workspaceDir) {
|
|
|
4604
4737
|
}
|
|
4605
4738
|
return { ok: true, host: bound[0] ?? 'none' };
|
|
4606
4739
|
}
|
|
4740
|
+
/**
|
|
4741
|
+
* Production orchestration used by install() after the runtime transaction
|
|
4742
|
+
* commits. Existing-install migration candidates come ONLY from authoritative
|
|
4743
|
+
* install.json workspaces; pending entries supply per-workspace metadata but
|
|
4744
|
+
* never create targets. The heavy safety work remains inside the existing
|
|
4745
|
+
* provisioning pipeline (binding gate, scan gate, readiness, CAS, evidence,
|
|
4746
|
+
* first run-once).
|
|
4747
|
+
*/
|
|
4748
|
+
export async function provisionServiceHostInstallTargets(input) {
|
|
4749
|
+
const targets = input.freshInstall
|
|
4750
|
+
? input.runTargets
|
|
4751
|
+
: mergeManifestProvisioningTargets([], input.manifestWorkspaces);
|
|
4752
|
+
const registeredKeys = new Set(input.manifestWorkspaces.map((workspaceDir) => workspaceKey(workspaceDir)));
|
|
4753
|
+
const perTarget = [];
|
|
4754
|
+
const scanFn = input.scanFn ?? scanRunningLegacyWorkerProcesses;
|
|
4755
|
+
let legacyWorkerScan;
|
|
4756
|
+
for (const target of targets) {
|
|
4757
|
+
if (!existsSync(target.workspaceDir)) {
|
|
4758
|
+
input.warn(`Service Host provisioning skipped for ${target.workspaceDir}: the directory does not exist.`);
|
|
4759
|
+
continue;
|
|
4760
|
+
}
|
|
4761
|
+
const targetKey = workspaceKey(target.workspaceDir);
|
|
4762
|
+
const marker = input.freshInstall
|
|
4763
|
+
? null
|
|
4764
|
+
: input.pendingEntries.find((entry) => workspaceKey(entry.workspaceDir) === targetKey) ?? null;
|
|
4765
|
+
const ownershipBefore = readWorkspaceBackgroundOwnership({
|
|
4766
|
+
manifestPath: getInstallManifestPath(),
|
|
4767
|
+
workspaceDir: target.workspaceDir,
|
|
4768
|
+
});
|
|
4769
|
+
const resume = shouldProvisionOnInstall({
|
|
4770
|
+
freshInstall: input.freshInstall,
|
|
4771
|
+
consentIntent: input.consentIntent,
|
|
4772
|
+
consentSource: input.consentSource,
|
|
4773
|
+
schedulerState: input.scheduler.state,
|
|
4774
|
+
workspaceRegistered: registeredKeys.has(targetKey),
|
|
4775
|
+
alreadyOwned: ownershipBefore.status === 'service_host_owned',
|
|
4776
|
+
});
|
|
4777
|
+
if (!resume)
|
|
4778
|
+
continue;
|
|
4779
|
+
if (!input.freshInstall && legacyWorkerScan === undefined) {
|
|
4780
|
+
legacyWorkerScan = scanFn();
|
|
4781
|
+
if (!legacyWorkerScan.ok) {
|
|
4782
|
+
input.warn(`The legacy worker process scan could not verify quiesce (${legacyWorkerScan.detail ?? 'scan failed'}); ownership hand-over stays pending for this run.`);
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
let host = target.host;
|
|
4786
|
+
let bindingVerification;
|
|
4787
|
+
if (!input.freshInstall) {
|
|
4788
|
+
const resolution = resolveResumeProvisioningHost(marker?.host ?? target.host, target.workspaceDir);
|
|
4789
|
+
if (resolution.ok) {
|
|
4790
|
+
({ host } = resolution);
|
|
4791
|
+
}
|
|
4792
|
+
else {
|
|
4793
|
+
// A refusal must not erase the very historical evidence that caused it.
|
|
4794
|
+
// Manifest targets are host-neutral; writing that neutral default back
|
|
4795
|
+
// into pending would let the next retry fall through as `none`.
|
|
4796
|
+
host = marker?.host ?? target.host;
|
|
4797
|
+
bindingVerification = { ok: false, reason: resolution.reason, nextAction: resolution.nextAction };
|
|
4798
|
+
}
|
|
4799
|
+
}
|
|
4800
|
+
const outcome = await provisionFreshInstallWorkspace({
|
|
4801
|
+
pdHome: input.pdHome,
|
|
4802
|
+
workspaceDir: target.workspaceDir,
|
|
4803
|
+
host,
|
|
4804
|
+
scheduler: input.scheduler,
|
|
4805
|
+
...(bindingVerification !== undefined ? { bindingVerification } : {}),
|
|
4806
|
+
...(legacyWorkerScan !== undefined ? { legacyWorkerScan } : {}),
|
|
4807
|
+
...(!input.freshInstall ? { legacyWorkerScanFn: scanFn } : {}),
|
|
4808
|
+
...(!input.freshInstall ? { hostBindingReverification: () => resolveResumeProvisioningHost(marker?.host ?? target.host, target.workspaceDir) } : {}),
|
|
4809
|
+
...(input.probes !== undefined ? { probes: input.probes } : {}),
|
|
4810
|
+
requireOpenClawGatewayQuiesce: !input.freshInstall,
|
|
4811
|
+
...(input.openClawGatewayQuiesce !== undefined ? { openClawGatewayQuiesce: input.openClawGatewayQuiesce } : {}),
|
|
4812
|
+
...(input.openClawGatewayQuiesceFn !== undefined ? { openClawGatewayQuiesceFn: input.openClawGatewayQuiesceFn } : {}),
|
|
4813
|
+
warn: input.warn,
|
|
4814
|
+
...(input.info !== undefined ? { info: input.info } : {}),
|
|
4815
|
+
});
|
|
4816
|
+
perTarget.push({ host, workspaceDir: target.workspaceDir, outcome });
|
|
4817
|
+
}
|
|
4818
|
+
return perTarget.length > 0
|
|
4819
|
+
? {
|
|
4820
|
+
targets: perTarget,
|
|
4821
|
+
pending: perTarget.some((entry) => entry.outcome.pendingProvisioning === true),
|
|
4822
|
+
nextAction: perTarget.map((entry) => entry.outcome.nextAction).join(' | '),
|
|
4823
|
+
}
|
|
4824
|
+
: null;
|
|
4825
|
+
}
|
|
4826
|
+
/**
|
|
4827
|
+
* Whether this run's explicit Service Host migration can affect the workspace
|
|
4828
|
+
* the OpenClaw declaration binds NOW. `--host` is not evidence on a deferred
|
|
4829
|
+
* resume: it may be omitted while install.json still authoritatively names
|
|
4830
|
+
* that bound workspace. This predicate is intentionally conservative and only
|
|
4831
|
+
* widens the existing gateway pre-flight; it never creates a migration target.
|
|
4832
|
+
*/
|
|
4833
|
+
/**
|
|
4834
|
+
* Translate a measured negative Gateway state into migration evidence. Only a
|
|
4835
|
+
* readable configured port with no listener is positive not-running evidence;
|
|
4836
|
+
* missing/unreadable configuration is unknown, never proof of quiescence.
|
|
4837
|
+
*/
|
|
4838
|
+
export function openClawGatewayQuiesceFromObservedStatus(status, explicitOwnershipMigration) {
|
|
4839
|
+
return !explicitOwnershipMigration || status.observation === 'port_not_listening'
|
|
4840
|
+
? { ok: true, evidence: 'not_running' }
|
|
4841
|
+
: {
|
|
4842
|
+
ok: false,
|
|
4843
|
+
reason: `OpenClaw Gateway state is unverifiable (${status.observation ?? 'observation unavailable'}); absence of a listener is not quiesce evidence`,
|
|
4844
|
+
};
|
|
4845
|
+
}
|
|
4846
|
+
export function openClawMigrationRequiresGatewayCheck(options) {
|
|
4847
|
+
if (installsOpenClaw(options.host) || options.refreshTargets?.includes('openclaw') === true)
|
|
4848
|
+
return true;
|
|
4849
|
+
const explicitEnable = options.serviceHost !== undefined
|
|
4850
|
+
? options.serviceHost.intent === 'enable' && options.serviceHost.source === 'explicit_flag'
|
|
4851
|
+
: options.enableServiceHost === true;
|
|
4852
|
+
if (!explicitEnable)
|
|
4853
|
+
return false;
|
|
4854
|
+
const manifest = readManifestWorkspacesForProvisioning();
|
|
4855
|
+
const candidatePaths = [options.workspaceDir, ...manifest.workspaces];
|
|
4856
|
+
try {
|
|
4857
|
+
const binding = readHostWorkspaceBinding('openclaw');
|
|
4858
|
+
if (binding.state === 'unverifiable')
|
|
4859
|
+
return true;
|
|
4860
|
+
if (binding.state === 'bound')
|
|
4861
|
+
candidatePaths.push(binding.workspaceDir);
|
|
4862
|
+
}
|
|
4863
|
+
catch {
|
|
4864
|
+
// Unverifiable evidence must never become proof that no OpenClaw workspace is in scope.
|
|
4865
|
+
return true;
|
|
4866
|
+
}
|
|
4867
|
+
return candidatePaths.some((workspaceDir) => openClawWorkspaceClaimState(workspaceDir) !== 'unbound');
|
|
4868
|
+
}
|
|
4869
|
+
async function probeOpenClawGatewayQuiesceForMigration() {
|
|
4870
|
+
try {
|
|
4871
|
+
return openClawGatewayQuiesceFromObservedStatus(await checkOpenClawGateway(), true);
|
|
4872
|
+
}
|
|
4873
|
+
catch (error) {
|
|
4874
|
+
return { ok: false, reason: `OpenClaw Gateway state could not be re-verified (${error instanceof Error ? error.message : String(error)})` };
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4607
4877
|
export function resolveUpdateWorkspaceDir(workspaceDir, host, options = {}) {
|
|
4608
4878
|
if (!installsOpenClaw(host))
|
|
4609
4879
|
return { kind: 'resolved', workspaceDir, source: 'caller' };
|
|
@@ -5174,13 +5444,37 @@ transaction) {
|
|
|
5174
5444
|
// that make the backup rename fail with EPERM. Decide stop/abort/proceed
|
|
5175
5445
|
// BEFORE mutating anything (cli-5: abort/stop-failed paths must not mutate).
|
|
5176
5446
|
let restartedGateway = false;
|
|
5177
|
-
const
|
|
5447
|
+
const explicitOwnershipMigration = options.serviceHost !== undefined
|
|
5448
|
+
? options.serviceHost.intent === 'enable' && options.serviceHost.source === 'explicit_flag'
|
|
5449
|
+
: options.enableServiceHost === true;
|
|
5450
|
+
let openClawGatewayQuiesce = {
|
|
5451
|
+
ok: false,
|
|
5452
|
+
reason: 'OpenClaw Gateway quiescence was not evaluated before install',
|
|
5453
|
+
};
|
|
5454
|
+
// Host coverage must be known BEFORE the Gateway gate: on an upgrade the
|
|
5455
|
+
// run may refresh an already-installed OpenClaw sibling even when this
|
|
5456
|
+
// invocation names only Codex/none. This is a read-only plan; the identical
|
|
5457
|
+
// persisted/detected state is planned again inside the transaction below.
|
|
5458
|
+
const preflightHostPlan = planUpgradeHosts(options.host, freshInstallRun ? [] : readPersistedInstallHosts(), freshInstallRun ? [] : detectInstalledHosts());
|
|
5459
|
+
const requiresGatewayCheck = openClawMigrationRequiresGatewayCheck({
|
|
5460
|
+
...options,
|
|
5461
|
+
refreshTargets: preflightHostPlan.refreshTargets,
|
|
5462
|
+
});
|
|
5463
|
+
const gatewayStatus = requiresGatewayCheck
|
|
5178
5464
|
? await checkOpenClawGateway()
|
|
5179
|
-
:
|
|
5180
|
-
if (gatewayStatus.isRunning) {
|
|
5465
|
+
: null;
|
|
5466
|
+
if (requiresGatewayCheck && gatewayStatus !== null && !gatewayStatus.isRunning) {
|
|
5467
|
+
// A negative port probe is evidence only when the gateway configuration
|
|
5468
|
+
// itself was readable enough to name the port. Missing/malformed config is
|
|
5469
|
+
// unverifiable for ownership migration, while ordinary upgrades keep the
|
|
5470
|
+
// historical non-blocking absence behavior.
|
|
5471
|
+
openClawGatewayQuiesce = openClawGatewayQuiesceFromObservedStatus(gatewayStatus, explicitOwnershipMigration);
|
|
5472
|
+
}
|
|
5473
|
+
if (gatewayStatus?.isRunning === true) {
|
|
5181
5474
|
const action = await resolveGatewayAction(gatewayStatus, {
|
|
5182
5475
|
stopGateway: options.stopGateway,
|
|
5183
5476
|
interactive: !nonInteractive,
|
|
5477
|
+
allowProceed: !explicitOwnershipMigration,
|
|
5184
5478
|
});
|
|
5185
5479
|
if (action === 'abort') {
|
|
5186
5480
|
logger.warn(t('gateway_aborted_reason'));
|
|
@@ -5192,7 +5486,9 @@ transaction) {
|
|
|
5192
5486
|
if (action === 'stop') {
|
|
5193
5487
|
if (!quiet)
|
|
5194
5488
|
logger.info(t('gateway_stopping'));
|
|
5195
|
-
const stopRes = await stopOpenClawGateway(gatewayStatus
|
|
5489
|
+
const stopRes = await stopOpenClawGateway(gatewayStatus, {
|
|
5490
|
+
requireProcessExit: explicitOwnershipMigration,
|
|
5491
|
+
});
|
|
5196
5492
|
if (!stopRes.ok) {
|
|
5197
5493
|
logger.error(`${t('gateway_stop_failed')} ${stopRes.error ?? ''}`);
|
|
5198
5494
|
return buildGatewayRefusalResult(options, {
|
|
@@ -5210,6 +5506,11 @@ transaction) {
|
|
|
5210
5506
|
}
|
|
5211
5507
|
if (!quiet)
|
|
5212
5508
|
logger.success(t('gateway_stopped'));
|
|
5509
|
+
openClawGatewayQuiesce = {
|
|
5510
|
+
ok: true,
|
|
5511
|
+
evidence: 'process_exited',
|
|
5512
|
+
...(gatewayStatus.pid !== undefined ? { pid: gatewayStatus.pid } : {}),
|
|
5513
|
+
};
|
|
5213
5514
|
restartedGateway = true; // restart after install, even on failure
|
|
5214
5515
|
}
|
|
5215
5516
|
else {
|
|
@@ -5692,6 +5993,7 @@ transaction) {
|
|
|
5692
5993
|
// install/refresh result below, keeping the other hosts' error
|
|
5693
5994
|
// isolation intact.
|
|
5694
5995
|
let codexWorkspaceDir;
|
|
5996
|
+
let codexWorkspaceRedirected = false;
|
|
5695
5997
|
let codexWorkspaceError;
|
|
5696
5998
|
// PRI-1278 Phase 5 review: materialize a Codex workspace ONLY when Codex
|
|
5697
5999
|
// is the REQUESTED target. A refresh-only Codex (a plain `--yes` upgrade
|
|
@@ -5706,13 +6008,33 @@ transaction) {
|
|
|
5706
6008
|
ensureDir: (dir) => fse.ensureDir(dir),
|
|
5707
6009
|
warn: (message) => logger.warn(message),
|
|
5708
6010
|
});
|
|
5709
|
-
({ codexWorkspaceDir } = materialized);
|
|
6011
|
+
({ codexWorkspaceDir, redirected: codexWorkspaceRedirected } = materialized);
|
|
5710
6012
|
}
|
|
5711
6013
|
catch (error) {
|
|
5712
6014
|
codexWorkspaceError = error instanceof Error ? error.message : String(error);
|
|
5713
6015
|
logger.warn(`Host "codex" workspace materialization failed: ${codexWorkspaceError}`);
|
|
5714
6016
|
}
|
|
5715
6017
|
}
|
|
6018
|
+
// A redirected Codex workspace is itself a Service-Host candidate. The
|
|
6019
|
+
// main runtime-init above targets options.workspaceDir (often OpenClaw),
|
|
6020
|
+
// while Codex setup deliberately uses --skip-init; initialize the real
|
|
6021
|
+
// redirected workspace through the same installed pd-cli mechanism so
|
|
6022
|
+
// ownership cannot outrun discovery authorization.
|
|
6023
|
+
if (codexWorkspaceDir !== undefined && codexWorkspaceRedirected && codexWorkspaceError === undefined) {
|
|
6024
|
+
try {
|
|
6025
|
+
const pdCliEntry = path.join(getInstalledPdCliDir(), 'dist', 'index.js');
|
|
6026
|
+
execFileSync(process.execPath, [pdCliEntry, 'runtime', 'init', '--confirm', '--workspace', codexWorkspaceDir], {
|
|
6027
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
6028
|
+
windowsHide: true,
|
|
6029
|
+
timeout: 30000,
|
|
6030
|
+
env: { ...process.env, PD_INVOCATION_SOURCE: 'installer' },
|
|
6031
|
+
});
|
|
6032
|
+
}
|
|
6033
|
+
catch (err) {
|
|
6034
|
+
codexWorkspaceError = `pd runtime init failed for redirected Codex workspace ${codexWorkspaceDir}: ${err instanceof Error ? err.message : String(err)}`;
|
|
6035
|
+
logger.warn(`Host "codex" workspace initialization failed: ${codexWorkspaceError}`);
|
|
6036
|
+
}
|
|
6037
|
+
}
|
|
5716
6038
|
const hostResults = await runHostInstallers(options.host, hostInstallCtx, { codexWorkspaceDir, codexWorkspaceError });
|
|
5717
6039
|
// Report host install results (rc-9: surface failures, don't silently swallow).
|
|
5718
6040
|
// rc-9 propagation: if ANY host installer FAILED, the aggregate install
|
|
@@ -5757,6 +6079,7 @@ transaction) {
|
|
|
5757
6079
|
// and a sibling refresh failure must not roll back the working runtime.
|
|
5758
6080
|
const { refreshTargets } = hostPlan;
|
|
5759
6081
|
const refreshedResults = [];
|
|
6082
|
+
const refreshedWorkspaceDirs = [];
|
|
5760
6083
|
for (const refreshTarget of refreshTargets) {
|
|
5761
6084
|
if (spinner)
|
|
5762
6085
|
updateProgress(spinner, stepIndex, `Refreshing ${refreshTarget} host binding...`);
|
|
@@ -5776,6 +6099,7 @@ transaction) {
|
|
|
5776
6099
|
});
|
|
5777
6100
|
continue;
|
|
5778
6101
|
}
|
|
6102
|
+
refreshedWorkspaceDirs.push(existing.workspaceDir);
|
|
5779
6103
|
const refreshCtx = { ...hostInstallCtx, workspaceDir: existing.workspaceDir };
|
|
5780
6104
|
const refreshResults = await runHostInstallers(refreshTarget, refreshCtx, { codexWorkspaceDir: existing.workspaceDir, codexWorkspaceError });
|
|
5781
6105
|
refreshedResults.push(...refreshResults);
|
|
@@ -5829,9 +6153,31 @@ transaction) {
|
|
|
5829
6153
|
// host's registration still points at it — the exact A3 hazard class
|
|
5830
6154
|
// this fix exists to close. Real install state remains file-based truth
|
|
5831
6155
|
// (checkInstallStatus / host detect()).
|
|
6156
|
+
// The workspaces[] list is the migration authority, so it must name the
|
|
6157
|
+
// ACTUAL host-bound directories this run serves — including a redirected
|
|
6158
|
+
// Codex workspace, WorkBuddy governance, `--host all`, and every verified
|
|
6159
|
+
// sibling-host refresh — not merely the caller's cwd-shaped workspace.
|
|
6160
|
+
const runTargets = resolveProvisioningTargets({
|
|
6161
|
+
host: options.host,
|
|
6162
|
+
workspaceDir: options.workspaceDir,
|
|
6163
|
+
...(codexWorkspaceDir !== undefined ? { codexWorkspaceDir } : {}),
|
|
6164
|
+
});
|
|
6165
|
+
// Existing-install hostless runs are often upgrade/migration invocations
|
|
6166
|
+
// whose workspace came from detection (~/pd-workspace or PD_WORKSPACE_DIR),
|
|
6167
|
+
// not Owner intent. Registering that guess before reading the migration
|
|
6168
|
+
// authority would let the same run self-authorize it. Only an explicit
|
|
6169
|
+
// hostless --workspace is a registration target; verified sibling refresh
|
|
6170
|
+
// bindings below remain authoritative.
|
|
6171
|
+
const registrationRunTargets = freshInstallRun
|
|
6172
|
+
? runTargets
|
|
6173
|
+
: runTargets.filter((target) => target.host !== 'none' || options.workspaceExplicit === true);
|
|
6174
|
+
const servedWorkspaceDirs = [
|
|
6175
|
+
...registrationRunTargets.map((target) => target.workspaceDir),
|
|
6176
|
+
...refreshedWorkspaceDirs,
|
|
6177
|
+
];
|
|
5832
6178
|
writeInstallManifest({
|
|
5833
6179
|
hosts: installManifestHosts,
|
|
5834
|
-
workspaces: (current) => mergeInstallManifestWorkspacesFor(current,
|
|
6180
|
+
workspaces: (current) => mergeInstallManifestWorkspacesFor(current, servedWorkspaceDirs),
|
|
5835
6181
|
});
|
|
5836
6182
|
// PRI-709 P0-1: persist the metadata source after the manifest write, so
|
|
5837
6183
|
// the durable tier cannot be clobbered by the same install.
|
|
@@ -5930,15 +6276,17 @@ transaction) {
|
|
|
5930
6276
|
logger.warn(`Could not record recovery resolution for ${pendingId} (alarm stays): ${resolutionError instanceof Error ? resolutionError.message : String(resolutionError)}`);
|
|
5931
6277
|
}
|
|
5932
6278
|
}
|
|
5933
|
-
// PRI-1281 Phase 3 / PRI-1278
|
|
5934
|
-
// reconciliation +
|
|
5935
|
-
//
|
|
5936
|
-
//
|
|
5937
|
-
//
|
|
5938
|
-
// enforces the two hard rules itself:
|
|
6279
|
+
// PRI-1281 Phase 3 / PRI-1278 consolidation: user-level OS scheduler
|
|
6280
|
+
// reconciliation + ownership provisioning. POST-COMMIT by design — the
|
|
6281
|
+
// runtime transaction is already confirmed, so every bridge failure is a
|
|
6282
|
+
// WARNING, never a reported install failure (ERR-197). The consent intent
|
|
6283
|
+
// is resolved by the caller; the installer enforces the hard rules itself:
|
|
5939
6284
|
// 1. an upgrade NEVER enables implicitly (only an explicit flag may);
|
|
5940
|
-
// 2. ownership is handed over ONLY
|
|
5941
|
-
//
|
|
6285
|
+
// 2. ownership is handed over ONLY when the scheduler is verified
|
|
6286
|
+
// enabled — there is no companion fallback;
|
|
6287
|
+
// 3. an upgrade flips ownership ONLY after the one-time switch evidence
|
|
6288
|
+
// gate: no legacy continuous worker process may still consume the
|
|
6289
|
+
// workspace (process scan below, BEFORE the first provision write).
|
|
5942
6290
|
let serviceHostOutcome;
|
|
5943
6291
|
try {
|
|
5944
6292
|
const freshInstall = freshInstallRun;
|
|
@@ -5978,70 +6326,34 @@ transaction) {
|
|
|
5978
6326
|
// (`--host all` → OpenClaw + Codex), instead of the last one overwriting
|
|
5979
6327
|
// the others.
|
|
5980
6328
|
//
|
|
5981
|
-
// An existing installation
|
|
5982
|
-
//
|
|
5983
|
-
//
|
|
5984
|
-
//
|
|
5985
|
-
const runTargets = resolveProvisioningTargets({
|
|
5986
|
-
host: options.host,
|
|
5987
|
-
workspaceDir: options.workspaceDir,
|
|
5988
|
-
...(codexWorkspaceDir !== undefined ? { codexWorkspaceDir } : {}),
|
|
5989
|
-
});
|
|
6329
|
+
// An existing installation migrates ONLY with explicit consent for a
|
|
6330
|
+
// workspace registered in the authoritative install manifest. Pending
|
|
6331
|
+
// entries remain per-workspace metadata/host hints; they never create a
|
|
6332
|
+
// migration target by themselves.
|
|
5990
6333
|
const pending = freshInstall
|
|
5991
6334
|
? { entries: [] }
|
|
5992
6335
|
: readAllPendingProvisioning(getPdDir());
|
|
5993
6336
|
if (pending.warning !== undefined)
|
|
5994
6337
|
logger.warn(pending.warning);
|
|
5995
|
-
const
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
// named the host the first install intended.
|
|
6015
|
-
let host = target.host;
|
|
6016
|
-
let bindingVerification;
|
|
6017
|
-
if (marker !== null) {
|
|
6018
|
-
const resolution = resolveResumeProvisioningHost(marker.host, target.workspaceDir);
|
|
6019
|
-
if (resolution.ok) {
|
|
6020
|
-
({ host } = resolution);
|
|
6021
|
-
}
|
|
6022
|
-
else {
|
|
6023
|
-
bindingVerification = { ok: false, reason: resolution.reason, nextAction: resolution.nextAction };
|
|
6024
|
-
}
|
|
6025
|
-
}
|
|
6026
|
-
const outcome = await provisionFreshInstallWorkspace({
|
|
6027
|
-
pdHome: getPdDir(),
|
|
6028
|
-
workspaceDir: target.workspaceDir,
|
|
6029
|
-
host,
|
|
6030
|
-
scheduler,
|
|
6031
|
-
resume: marker !== null,
|
|
6032
|
-
...(bindingVerification !== undefined ? { bindingVerification } : {}),
|
|
6033
|
-
warn: (message) => logger.warn(message),
|
|
6034
|
-
info: (message) => logger.info(message),
|
|
6035
|
-
});
|
|
6036
|
-
perTarget.push({ host, workspaceDir: target.workspaceDir, outcome });
|
|
6037
|
-
}
|
|
6038
|
-
const provisioning = perTarget.length > 0
|
|
6039
|
-
? {
|
|
6040
|
-
targets: perTarget,
|
|
6041
|
-
pending: perTarget.some((entry) => entry.outcome.pendingProvisioning === true),
|
|
6042
|
-
nextAction: perTarget.map((entry) => entry.outcome.nextAction).join(' | '),
|
|
6043
|
-
}
|
|
6044
|
-
: null;
|
|
6338
|
+
const manifest = freshInstall
|
|
6339
|
+
? { workspaces: [] }
|
|
6340
|
+
: readManifestWorkspacesForProvisioning();
|
|
6341
|
+
if (!freshInstall && manifest.warning !== undefined)
|
|
6342
|
+
logger.warn(manifest.warning);
|
|
6343
|
+
const provisioning = await provisionServiceHostInstallTargets({
|
|
6344
|
+
pdHome: getPdDir(),
|
|
6345
|
+
freshInstall,
|
|
6346
|
+
consentIntent: consent.intent,
|
|
6347
|
+
consentSource: consent.source,
|
|
6348
|
+
scheduler,
|
|
6349
|
+
runTargets,
|
|
6350
|
+
pendingEntries: pending.entries,
|
|
6351
|
+
manifestWorkspaces: manifest.workspaces,
|
|
6352
|
+
warn: (message) => logger.warn(message),
|
|
6353
|
+
info: (message) => logger.info(message),
|
|
6354
|
+
openClawGatewayQuiesce,
|
|
6355
|
+
openClawGatewayQuiesceFn: probeOpenClawGatewayQuiesceForMigration,
|
|
6356
|
+
});
|
|
6045
6357
|
serviceHostOutcome = {
|
|
6046
6358
|
freshInstall,
|
|
6047
6359
|
scheduler,
|