create-principles-disciple 1.154.3 → 1.154.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/worker/workspace-worker.js +7 -1
- package/codex-adapter/package.json +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-contract.js +1 -0
- package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +8 -0
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.d.ts +13 -0
- package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.js +26 -0
- package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
- package/core/dist/runtime/pain-ingress.d.ts +1 -1
- package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress.js +15 -2
- package/core/dist/runtime/pain-ingress.js.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts +18 -0
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +49 -1
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts +7 -0
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js +2 -0
- package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.d.ts +8 -0
- package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.js +21 -1
- package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
- package/core/package.json +1 -1
- package/host-runtime/dist/auto-pain-authorization.d.ts +29 -0
- package/host-runtime/dist/auto-pain-authorization.js +32 -0
- package/host-runtime/dist/diagnostician-auto-run.d.ts +1 -1
- package/host-runtime/dist/diagnostician-auto-run.js +41 -0
- package/host-runtime/dist/governance-signal-admission.js +16 -0
- package/host-runtime/dist/index.d.ts +1 -0
- package/host-runtime/dist/index.js +1 -0
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/active-release.d.ts +41 -0
- package/install-layout/dist/active-release.js +131 -0
- package/install-layout/dist/index.d.ts +56 -5
- package/install-layout/dist/index.js +166 -1
- package/install-layout/dist/mcp-binding-contract.d.ts +76 -12
- package/install-layout/dist/mcp-binding-contract.js +183 -75
- package/install-layout/package.json +1 -1
- package/package.json +3 -3
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +4 -1
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +19 -1
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/dist/commands/service-run-once.d.ts +6 -0
- package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -0
- package/pd-cli/dist/commands/service-run-once.js +139 -0
- package/pd-cli/dist/commands/service-run-once.js.map +1 -0
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +21 -0
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/pain-flood-simulation-runner.js +4 -0
- package/pd-cli/dist/services/pain-flood-simulation-runner.js.map +1 -1
- package/pd-cli/dist/services/service-host/index.d.ts +15 -0
- package/pd-cli/dist/services/service-host/index.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/index.js +15 -0
- package/pd-cli/dist/services/service-host/index.js.map +1 -0
- package/pd-cli/dist/services/service-host/install-identity.d.ts +79 -0
- package/pd-cli/dist/services/service-host/install-identity.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/install-identity.js +166 -0
- package/pd-cli/dist/services/service-host/install-identity.js.map +1 -0
- package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts +134 -0
- package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/locking/service-run-lock.js +659 -0
- package/pd-cli/dist/services/service-host/locking/service-run-lock.js.map +1 -0
- package/pd-cli/dist/services/service-host/owner-projection.d.ts +47 -0
- package/pd-cli/dist/services/service-host/owner-projection.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/owner-projection.js +121 -0
- package/pd-cli/dist/services/service-host/owner-projection.js.map +1 -0
- package/pd-cli/dist/services/service-host/run-once.d.ts +96 -0
- package/pd-cli/dist/services/service-host/run-once.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/run-once.js +440 -0
- package/pd-cli/dist/services/service-host/run-once.js.map +1 -0
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +117 -0
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/status/service-run-status.js +150 -0
- package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -0
- package/pd-cli/dist/services/service-host/workspace-discovery.d.ts +71 -0
- package/pd-cli/dist/services/service-host/workspace-discovery.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/workspace-discovery.js +288 -0
- package/pd-cli/dist/services/service-host/workspace-discovery.js.map +1 -0
- package/pd-cli/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/synthetic-baseline-runner.js +4 -0
- package/pd-cli/dist/services/synthetic-baseline-runner.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +420 -420
- package/plugin/dist/core/signal-collector-host.d.ts +12 -0
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/templates/langs/en/skills/pd-pain-signal/SKILL.md +10 -2
- package/plugin/dist/templates/langs/zh/skills/pd-pain-signal/SKILL.md +10 -2
- package/plugin/mcp/launcher.cjs +40 -4
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/templates/langs/en/skills/pd-pain-signal/SKILL.md +10 -2
- package/plugin/templates/langs/zh/skills/pd-pain-signal/SKILL.md +10 -2
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/dist/worker/workspace-worker.js +4 -1
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/mcp/launcher.cjs +40 -4
- package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +10 -2
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run-once coordinator (SPEC-PD-SERVICE-HOST-001 §8.2, TD §5).
|
|
3
|
+
*
|
|
4
|
+
* One bounded execution: resolve install identity, acquire the install
|
|
5
|
+
* single-instance lock, verify the active release, read and parse the
|
|
6
|
+
* install manifest (a read failure is NEVER a zero-Workspace result),
|
|
7
|
+
* collect validated per-host claims, discover and validate Workspaces,
|
|
8
|
+
* project each Workspace's owner state (read-only), persist the versioned
|
|
9
|
+
* operational status, release the lock.
|
|
10
|
+
*
|
|
11
|
+
* Phase 1 admission boundary (SPEC §11): dry-run only, NO Worker is started,
|
|
12
|
+
* NO consumer ownership changes, NO manifest write, no OS scheduler. The
|
|
13
|
+
* only writes are the expected run metadata: the lock protocol's transient
|
|
14
|
+
* lock file and the operational status file, both under the PD-owned
|
|
15
|
+
* service directory of the resolved install root.
|
|
16
|
+
*/
|
|
17
|
+
import * as fs from 'node:fs';
|
|
18
|
+
import { randomUUID } from 'node:crypto';
|
|
19
|
+
import { collectHostWorkspaceClaims, parseInstallManifest, } from '@principles/install-layout';
|
|
20
|
+
import { resolveCoordinatorInstallIdentity, } from './install-identity.js';
|
|
21
|
+
import { discoverWorkspaces } from './workspace-discovery.js';
|
|
22
|
+
import { acquireServiceRunLock, holdsServiceRunLock, releaseServiceRunLock, serviceRunLockPath, } from './locking/service-run-lock.js';
|
|
23
|
+
import { readActiveReleaseFacts, writeServiceRunStatus, } from './status/service-run-status.js';
|
|
24
|
+
export { SERVICE_RUN_STATUS_SCHEMA_VERSION, serviceRunStatusPath } from './status/service-run-status.js';
|
|
25
|
+
/** Read + parse the manifest with the five task-required verdicts. */
|
|
26
|
+
function readManifest(identity) {
|
|
27
|
+
let raw;
|
|
28
|
+
try {
|
|
29
|
+
raw = fs.readFileSync(identity.manifestPath, 'utf8');
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const code = typeof error === 'object' && error !== null && Object.hasOwn(error, 'code')
|
|
33
|
+
? String(Reflect.get(error, 'code'))
|
|
34
|
+
: '';
|
|
35
|
+
if (code === 'ENOENT') {
|
|
36
|
+
return { manifest: undefined, verdict: 'missing', reason: 'install_manifest_missing' };
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
manifest: undefined,
|
|
40
|
+
verdict: 'read_failed',
|
|
41
|
+
reason: code !== '' ? `install_manifest_read_failed:${code}` : 'install_manifest_read_failed',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = JSON.parse(raw);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
50
|
+
return { manifest: undefined, verdict: 'unparsable', reason: `install_manifest_unparsable:${message.slice(0, 120)}` };
|
|
51
|
+
}
|
|
52
|
+
const result = parseInstallManifest(parsed);
|
|
53
|
+
if (result.manifest === undefined) {
|
|
54
|
+
const error = result.error ?? 'install_manifest_malformed';
|
|
55
|
+
return {
|
|
56
|
+
manifest: undefined,
|
|
57
|
+
verdict: error.startsWith('install_manifest_unsupported_version') ? 'version_mismatch' : 'invalid',
|
|
58
|
+
reason: error,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return { manifest: result.manifest, verdict: 'ok' };
|
|
62
|
+
}
|
|
63
|
+
/** Empty discovery counts for refusal statuses. */
|
|
64
|
+
function zeroCounts() {
|
|
65
|
+
return { authorized: 0, degraded: 0, unavailable: 0, conflicting: 0, invalid: 0, discovered: 0 };
|
|
66
|
+
}
|
|
67
|
+
/** Build the empty discovery result used by refusal statuses. */
|
|
68
|
+
function buildEmptyDiscovery() {
|
|
69
|
+
return { workspaces: [], discoveredTotal: 0, counts: zeroCounts() };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The default host-root listability probe (P2-1). `statSync` succeeding is
|
|
73
|
+
* not enough — a directory the OS reports but `readdir` refuses (EACCES /
|
|
74
|
+
* EPERM) or fails on (EIO, transient FS errors) is NOT listable, and the
|
|
75
|
+
* claims collector could not have seen the workspaces under it. The four
|
|
76
|
+
* verdicts are distinct and none is ever faked:
|
|
77
|
+
* - `missing` — ENOENT/ENOTDIR at stat, or the dir vanished before readdir;
|
|
78
|
+
* - `not_directory` — the path exists but is not a directory;
|
|
79
|
+
* - `unreadable` — exists, is a directory, readdir failed for any reason;
|
|
80
|
+
* - `readable` — readdir actually succeeded.
|
|
81
|
+
*/
|
|
82
|
+
function defaultListDir(dir) {
|
|
83
|
+
try {
|
|
84
|
+
if (!fs.statSync(dir).isDirectory())
|
|
85
|
+
return 'not_directory';
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const code = typeof error === 'object' && error !== null && Object.hasOwn(error, 'code')
|
|
89
|
+
? String(Reflect.get(error, 'code'))
|
|
90
|
+
: '';
|
|
91
|
+
return code === 'ENOENT' || code === 'ENOTDIR' ? 'missing' : 'unreadable';
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
fs.readdirSync(dir);
|
|
95
|
+
return 'readable';
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const code = typeof error === 'object' && error !== null && Object.hasOwn(error, 'code')
|
|
99
|
+
? String(Reflect.get(error, 'code'))
|
|
100
|
+
: '';
|
|
101
|
+
return code === 'ENOENT' || code === 'ENOTDIR' ? 'missing' : 'unreadable';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Per-host root report (P1-2/P2-1): for every host, which root the claims
|
|
106
|
+
* collector consulted, whether it came from an env override, and whether
|
|
107
|
+
* the directory was actually LISTABLE. An unreadable root — env-selected
|
|
108
|
+
* or default — is surfaced as incomplete discovery, never silently folded
|
|
109
|
+
* into "no workspaces".
|
|
110
|
+
*/
|
|
111
|
+
function hostRootReports(identity, env, listDir = defaultListDir) {
|
|
112
|
+
const hasEnv = (name) => {
|
|
113
|
+
const value = env[name];
|
|
114
|
+
return value !== undefined && value.trim().length > 0;
|
|
115
|
+
};
|
|
116
|
+
const roots = [
|
|
117
|
+
{
|
|
118
|
+
host: 'openclaw',
|
|
119
|
+
root: identity.hostRoots.openclawHome,
|
|
120
|
+
source: hasEnv('OPENCLAW_STATE_DIR') || hasEnv('OPENCLAW_HOME') ? 'env' : 'default',
|
|
121
|
+
},
|
|
122
|
+
{ host: 'codex', root: identity.hostRoots.codexHome, source: hasEnv('CODEX_HOME') ? 'env' : 'default' },
|
|
123
|
+
{
|
|
124
|
+
host: 'workbuddy',
|
|
125
|
+
root: identity.hostRoots.workbuddyConfigDir,
|
|
126
|
+
source: hasEnv('WORKBUDDY_CONFIG_DIR') ? 'env' : 'default',
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
return roots.map((entry) => ({ ...entry, status: listDir(entry.root) }));
|
|
130
|
+
}
|
|
131
|
+
/** True when at least one consulted host root exists but could not be listed. */
|
|
132
|
+
function discoveryIncompleteRoots(hostRoots) {
|
|
133
|
+
return hostRoots.filter((r) => r.status === 'unreadable' || r.status === 'not_directory');
|
|
134
|
+
}
|
|
135
|
+
/** The operator-facing next action for a completed dry-run. */
|
|
136
|
+
function completedNextAction(discovery, hostRoots, bindingDiagnostics) {
|
|
137
|
+
// A host root that exists but could not be listed is a finding of its
|
|
138
|
+
// own (P1-2/P2-1): workspaces under it were NOT silently absent — say
|
|
139
|
+
// so, for env-selected AND default roots alike.
|
|
140
|
+
const blocked = discoveryIncompleteRoots(hostRoots);
|
|
141
|
+
const rootNote = blocked.length > 0
|
|
142
|
+
? ` Host root(s) ${blocked.map((r) => `${r.host}=${r.root} (${r.status}, ${r.source})`).join(', ')} are not listable — workspaces under them were not discoverable; discovery is INCOMPLETE. Fix the permissions/path or unset the env override.`
|
|
143
|
+
: '';
|
|
144
|
+
// A binding/declaration file that exists but cannot be read or parsed is
|
|
145
|
+
// degraded evidence (§9.1.8), not "no claim": say which file degraded.
|
|
146
|
+
const bindingNote = bindingDiagnostics.length > 0
|
|
147
|
+
? ` Binding evidence file(s) ${bindingDiagnostics.map((d) => `${d.file} (${d.status})`).join(', ')} could not be read — host claims in them were not discoverable; discovery is INCOMPLETE. Repair the file or its permissions.`
|
|
148
|
+
: '';
|
|
149
|
+
if (discovery.counts.authorized === 0 && discovery.discoveredTotal > 0) {
|
|
150
|
+
const countsSummary = Object.entries(discovery.counts)
|
|
151
|
+
.map(([verdict, count]) => `${verdict}=${count}`)
|
|
152
|
+
.join(' ');
|
|
153
|
+
return `No workspace is currently authorized (counts: ${countsSummary}); check the per-workspace reasons below.${rootNote}${bindingNote}`;
|
|
154
|
+
}
|
|
155
|
+
if (discovery.counts.conflicting > 0 || discovery.counts.invalid > 0) {
|
|
156
|
+
return `Fix the conflicting/invalid workspaces listed below before any future worker phase.${rootNote}${bindingNote}`;
|
|
157
|
+
}
|
|
158
|
+
if (rootNote !== '' || bindingNote !== '') {
|
|
159
|
+
return `Discovery dry-run complete.${rootNote}${bindingNote} Phase 1 starts no worker.`;
|
|
160
|
+
}
|
|
161
|
+
return 'Discovery dry-run complete. Phase 1 starts no worker; the next phase (PRI-1280) introduces bounded real cycles behind handover gates.';
|
|
162
|
+
}
|
|
163
|
+
/** Assemble the versioned status document. */
|
|
164
|
+
function buildStatus(args) {
|
|
165
|
+
return {
|
|
166
|
+
schemaVersion: 'pd.service-run-status.v1',
|
|
167
|
+
runId: args.runId,
|
|
168
|
+
outcome: args.outcome,
|
|
169
|
+
dryRun: true,
|
|
170
|
+
triggerSource: 'manual',
|
|
171
|
+
startedAt: args.startedAt.toISOString(),
|
|
172
|
+
completedAt: args.completedAt.toISOString(),
|
|
173
|
+
durationMs: Math.max(0, args.completedAt.getTime() - args.startedAt.getTime()),
|
|
174
|
+
installation: {
|
|
175
|
+
pdHome: args.identity.pdHome,
|
|
176
|
+
homeDir: args.identity.homeDir,
|
|
177
|
+
homeSource: args.identity.homeSource,
|
|
178
|
+
mode: args.identity.mode,
|
|
179
|
+
activeRelease: args.activeRelease,
|
|
180
|
+
},
|
|
181
|
+
environmentIsolation: {
|
|
182
|
+
pdExperimentRootStripped: args.identity.environment.experimentRootStripped,
|
|
183
|
+
ignoredIdentityEnvVars: args.identity.environment.ignoredIdentityEnvVars,
|
|
184
|
+
inheritedHostRootEnvVars: args.identity.environment.inheritedHostRootEnvVars,
|
|
185
|
+
},
|
|
186
|
+
manifest: args.manifest,
|
|
187
|
+
discovery: {
|
|
188
|
+
discoveredTotal: args.discovery.discoveredTotal,
|
|
189
|
+
counts: args.discovery.counts,
|
|
190
|
+
hostRoots: args.hostRoots,
|
|
191
|
+
// A host root that exists but could not be listed, or binding
|
|
192
|
+
// evidence that exists but could not be read (§9.1.8), makes
|
|
193
|
+
// discovery INCOMPLETE — the workspace list below may be missing
|
|
194
|
+
// entries, so "0 workspaces" is never the same fact as "discovery
|
|
195
|
+
// finished".
|
|
196
|
+
incomplete: discoveryIncompleteRoots(args.hostRoots).length > 0 || args.bindingDiagnostics.length > 0,
|
|
197
|
+
},
|
|
198
|
+
workspaces: args.discovery.workspaces,
|
|
199
|
+
nextAction: args.nextAction,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function completeRun(identity, context) {
|
|
203
|
+
const hostRoots = hostRootReports(identity, context.env, context.listDir);
|
|
204
|
+
/**
|
|
205
|
+
* Mid-run ownership check (P1-4): before EVERY protected status write the
|
|
206
|
+
* run must still hold the lock it acquired. If it was taken over, the run
|
|
207
|
+
* stops — a holder that lost its lock may never write operational state
|
|
208
|
+
* on behalf of the install it no longer owns.
|
|
209
|
+
*/
|
|
210
|
+
const lockLost = () => ({
|
|
211
|
+
ok: false,
|
|
212
|
+
outcome: 'refused',
|
|
213
|
+
runId: context.runId,
|
|
214
|
+
reason: 'service_run_lock_lost',
|
|
215
|
+
nextAction: 'The install-level run lock was taken over mid-run, so the run stopped before writing status. ' +
|
|
216
|
+
'Inspect the current holder and re-run; do not treat this run\'s discovery as authoritative.',
|
|
217
|
+
});
|
|
218
|
+
const manifestSection = (read) => read.manifest === undefined
|
|
219
|
+
? {
|
|
220
|
+
verdict: read.verdict,
|
|
221
|
+
...(read.reason !== undefined ? { reason: read.reason } : {}),
|
|
222
|
+
hosts: [],
|
|
223
|
+
unknownHosts: [],
|
|
224
|
+
workspacesCount: 0,
|
|
225
|
+
}
|
|
226
|
+
: {
|
|
227
|
+
verdict: 'ok',
|
|
228
|
+
hosts: [...read.manifest.hosts, ...(read.manifest.unknownHosts ?? [])],
|
|
229
|
+
unknownHosts: [...(read.manifest.unknownHosts ?? [])],
|
|
230
|
+
workspacesCount: (read.manifest.workspaces ?? []).length,
|
|
231
|
+
};
|
|
232
|
+
const persistRefusal = (args) => {
|
|
233
|
+
if (!context.holdsLock(context.handle))
|
|
234
|
+
return lockLost();
|
|
235
|
+
const status = buildStatus({
|
|
236
|
+
identity,
|
|
237
|
+
runId: context.runId,
|
|
238
|
+
startedAt: context.startedAt,
|
|
239
|
+
completedAt: new Date(),
|
|
240
|
+
outcome: 'refused',
|
|
241
|
+
activeRelease: args.activeRelease,
|
|
242
|
+
manifest: args.manifest ?? { verdict: 'ok', hosts: [], unknownHosts: [], workspacesCount: 0 },
|
|
243
|
+
discovery: args.discovery ?? buildEmptyDiscovery(),
|
|
244
|
+
hostRoots,
|
|
245
|
+
bindingDiagnostics: [],
|
|
246
|
+
nextAction: args.nextAction,
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
ok: false,
|
|
250
|
+
outcome: 'refused',
|
|
251
|
+
runId: context.runId,
|
|
252
|
+
reason: args.reason,
|
|
253
|
+
nextAction: status.nextAction,
|
|
254
|
+
statusWrite: writeServiceRunStatus(identity.pdHome, status),
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
// ── 3. Active release — verified against the authoritative schema (P1-3).
|
|
258
|
+
// A record that parses but is not the installer's record is a REFUSAL,
|
|
259
|
+
// never a completed run over a fake install.
|
|
260
|
+
const activeRelease = readActiveReleaseFacts(identity.activeRecordPath);
|
|
261
|
+
// ── 4. Manifest: read failures are NEVER a zero-Workspace result ──
|
|
262
|
+
const manifestRead = readManifest(identity);
|
|
263
|
+
if (activeRelease.verdict !== 'ok') {
|
|
264
|
+
return persistRefusal({
|
|
265
|
+
reason: activeRelease.reason ?? 'active_release_invalid',
|
|
266
|
+
activeRelease,
|
|
267
|
+
manifest: manifestSection(manifestRead),
|
|
268
|
+
nextAction: activeRelease.verdict === 'missing'
|
|
269
|
+
? 'Install or repair PD with npx create-principles-disciple — no active release record exists for this install.'
|
|
270
|
+
: 'Repair the install with the PD installer/updater; the active release record could not be verified against the authoritative schema.',
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (manifestRead.manifest === undefined) {
|
|
274
|
+
// Fail-closed: refuse the run (and persist a truthful status) — an
|
|
275
|
+
// unreadable or malformed manifest must not be reported as an empty install.
|
|
276
|
+
return persistRefusal({
|
|
277
|
+
reason: manifestRead.reason ?? 'install_manifest_invalid',
|
|
278
|
+
activeRelease,
|
|
279
|
+
manifest: manifestSection(manifestRead),
|
|
280
|
+
nextAction: manifestRead.verdict === 'missing'
|
|
281
|
+
? 'Run npx create-principles-disciple to install PD (no manifest exists for this user-level install).'
|
|
282
|
+
: 'Repair the install manifest with the PD installer/updater before running the coordinator; the run refused instead of treating the install as empty.',
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
const manifest = manifestRead.manifest;
|
|
286
|
+
// ── 5. Validated per-host claims over ALL resolved host roots (P1-2).
|
|
287
|
+
// Custom roots (env overrides) reach the collector so workspaces under
|
|
288
|
+
// them are discoverable; they can never steer pdHome itself.
|
|
289
|
+
const readDiagnostics = [];
|
|
290
|
+
const claimOptions = {
|
|
291
|
+
homeDir: identity.homeDir,
|
|
292
|
+
codexHome: identity.hostRoots.codexHome,
|
|
293
|
+
openclawHome: identity.hostRoots.openclawHome,
|
|
294
|
+
workbuddyConfigDir: identity.hostRoots.workbuddyConfigDir,
|
|
295
|
+
platform: process.platform,
|
|
296
|
+
readDiagnostics,
|
|
297
|
+
...(context.claimReaders !== undefined ? { readers: context.claimReaders } : {}),
|
|
298
|
+
};
|
|
299
|
+
const claims = collectHostWorkspaceClaims(claimOptions);
|
|
300
|
+
// ── 6. Discovery + per-workspace owner projection ──
|
|
301
|
+
const discovery = discoverWorkspaces({ manifest, claims, claimOptions });
|
|
302
|
+
// ── 7. Persist status; lock release stays in the caller's finally ──
|
|
303
|
+
if (!context.holdsLock(context.handle))
|
|
304
|
+
return lockLost();
|
|
305
|
+
const status = buildStatus({
|
|
306
|
+
identity,
|
|
307
|
+
runId: context.runId,
|
|
308
|
+
startedAt: context.startedAt,
|
|
309
|
+
completedAt: new Date(),
|
|
310
|
+
outcome: 'completed',
|
|
311
|
+
activeRelease,
|
|
312
|
+
manifest: manifestSection(manifestRead),
|
|
313
|
+
discovery,
|
|
314
|
+
hostRoots,
|
|
315
|
+
bindingDiagnostics: readDiagnostics,
|
|
316
|
+
nextAction: completedNextAction(discovery, hostRoots, readDiagnostics),
|
|
317
|
+
});
|
|
318
|
+
const statusWrite = writeServiceRunStatus(identity.pdHome, status);
|
|
319
|
+
return {
|
|
320
|
+
ok: true,
|
|
321
|
+
outcome: 'completed',
|
|
322
|
+
runId: context.runId,
|
|
323
|
+
identity,
|
|
324
|
+
activeRelease,
|
|
325
|
+
manifest: status.manifest,
|
|
326
|
+
discovery,
|
|
327
|
+
statusWrite,
|
|
328
|
+
status,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Execute one bounded run-once (dry-run). Never throws for expected
|
|
333
|
+
* refusals — everything expected is a structured result; only a genuine bug
|
|
334
|
+
* escapes as an exception.
|
|
335
|
+
*/
|
|
336
|
+
export function runServiceRunOnce(options = {}) {
|
|
337
|
+
const runId = randomUUID();
|
|
338
|
+
const startedAt = new Date();
|
|
339
|
+
const env = options.env ?? process.env;
|
|
340
|
+
// ── 1. Install identity (production-forced; env-derived homes refused) ──
|
|
341
|
+
const identityResult = resolveCoordinatorInstallIdentity(env, {
|
|
342
|
+
...(options.trustedHomeDir !== undefined ? { trustedHomeDir: options.trustedHomeDir } : {}),
|
|
343
|
+
});
|
|
344
|
+
if (!identityResult.ok) {
|
|
345
|
+
return { ok: false, outcome: 'refused', runId, reason: identityResult.reason, nextAction: identityResult.nextAction };
|
|
346
|
+
}
|
|
347
|
+
const { identity } = identityResult;
|
|
348
|
+
// ── 2. Install-level single-instance lock ──
|
|
349
|
+
const lock = acquireServiceRunLock(identity.pdHome, {
|
|
350
|
+
probes: {
|
|
351
|
+
...(options.probes?.processAlive !== undefined ? { processAlive: options.probes.processAlive } : {}),
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
if (!lock.ok) {
|
|
355
|
+
if (lock.kind === 'held') {
|
|
356
|
+
return {
|
|
357
|
+
ok: true,
|
|
358
|
+
outcome: 'already_running',
|
|
359
|
+
runId,
|
|
360
|
+
identity,
|
|
361
|
+
holderBodyHash: lock.holderBodyHash,
|
|
362
|
+
reason: 'service_run_lock_held',
|
|
363
|
+
nextAction: 'Another run-once coordinator holds the install-level lock. Wait for it to finish; do not start a second instance.',
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
const lockPathForMessage = serviceRunLockPath(identity.pdHome);
|
|
367
|
+
return {
|
|
368
|
+
ok: false,
|
|
369
|
+
outcome: 'refused',
|
|
370
|
+
runId,
|
|
371
|
+
reason: lock.kind === 'corrupt'
|
|
372
|
+
? `service_run_lock_corrupt:${lock.detail}`
|
|
373
|
+
: `service_run_lock_unwritable:${lock.detail}`,
|
|
374
|
+
nextAction: lock.kind === 'corrupt'
|
|
375
|
+
? [
|
|
376
|
+
'Inspect the run lock by hand at',
|
|
377
|
+
lockPathForMessage,
|
|
378
|
+
'— a lock this old must stay verifiable before any coordinator may run.',
|
|
379
|
+
].join(' ')
|
|
380
|
+
: 'Check the permissions of the PD service directory and retry.',
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
const handle = lock.handle;
|
|
384
|
+
const releaseLock = options.probes?.releaseLock ?? releaseServiceRunLock;
|
|
385
|
+
let result;
|
|
386
|
+
let runError;
|
|
387
|
+
let runThrew = false;
|
|
388
|
+
try {
|
|
389
|
+
result = completeRun(identity, {
|
|
390
|
+
runId,
|
|
391
|
+
startedAt,
|
|
392
|
+
staleTakenOver: lock.staleTakenOver,
|
|
393
|
+
handle,
|
|
394
|
+
env,
|
|
395
|
+
holdsLock: options.probes?.holdsLock ?? holdsServiceRunLock,
|
|
396
|
+
listDir: options.probes?.listDir ?? defaultListDir,
|
|
397
|
+
...(options.probes?.claimReaders !== undefined ? { claimReaders: options.probes.claimReaders } : {}),
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
runThrew = true;
|
|
402
|
+
runError = error;
|
|
403
|
+
result = { ok: false, outcome: 'refused', runId, reason: 'internal_error', nextAction: '' };
|
|
404
|
+
}
|
|
405
|
+
const release = releaseLock(handle);
|
|
406
|
+
const releaseFailed = release === 'failed_busy' || release === 'failed_unwritable';
|
|
407
|
+
if (runThrew) {
|
|
408
|
+
// §三.8: the PRIMARY error stays the thrown one; a release failure is
|
|
409
|
+
// recorded on the diagnostics channel, never swapped in as the error.
|
|
410
|
+
if (releaseFailed) {
|
|
411
|
+
console.error(`pd service run-once: lock release also failed (${release}) after the run error`);
|
|
412
|
+
}
|
|
413
|
+
throw runError;
|
|
414
|
+
}
|
|
415
|
+
if (releaseFailed) {
|
|
416
|
+
// §三.7: a genuinely failed release is never reported as an unremarkable
|
|
417
|
+
// `completed` — the release failure surfaces (exit code 1 through the
|
|
418
|
+
// refused path) while the persisted status keeps its truthful record.
|
|
419
|
+
if (result.outcome === 'completed') {
|
|
420
|
+
return {
|
|
421
|
+
ok: false,
|
|
422
|
+
outcome: 'refused',
|
|
423
|
+
runId,
|
|
424
|
+
reason: `service_run_lock_release_failed:${release === 'failed_busy' ? 'busy' : 'unwritable'}`,
|
|
425
|
+
nextAction: 'The dry-run finished but its run lock could not be released through the arbitration gate. ' +
|
|
426
|
+
'The leftover lock carries a dead-holder PID once this process exits, so the next run recovers ' +
|
|
427
|
+
'on PID evidence — inspect the service directory and the gate database before re-running.',
|
|
428
|
+
statusWrite: result.statusWrite,
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
// The run already ended refused: keep the primary reason, record the
|
|
432
|
+
// secondary release failure in nextAction (§三.8).
|
|
433
|
+
return {
|
|
434
|
+
...result,
|
|
435
|
+
nextAction: `${result.nextAction} (Additionally, the run lock release failed: ${release}.)`,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
//# sourceMappingURL=run-once.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-once.js","sourceRoot":"","sources":["../../../src/services/service-host/run-once.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GAKrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iCAAiC,GAElC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAiC,MAAM,0BAA0B,CAAC;A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AO,KAAK,aAAa,IAAI,OAAO,KAAK,mBAAmB,CAAC;IACnF,IAAI,QAAQ,EAAE,CAAC;QACb,qEAAqE;QACrE,sEAAsE;QACtE,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,kDAAkD,OAAO,uBAAuB,CAAC,CAAC;QAClG,CAAC;QACD,MAAM,QAAQ,CAAC;IACjB,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,wEAAwE;QACxE,sEAAsE;QACtE,sEAAsE;QACtE,IAAI,MAAM,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;YACnC,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,SAAS;gBAClB,KAAK;gBACL,MAAM,EAAE,mCAAmC,OAAO,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,EAAE;gBAC9F,UAAU,EACR,4FAA4F;oBAC5F,gGAAgG;oBAChG,0FAA0F;gBAC5F,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAC;QACJ,CAAC;QACD,qEAAqE;QACrE,kDAAkD;QAClD,OAAO;YACL,GAAG,MAAM;YACT,UAAU,EAAE,GAAG,MAAM,CAAC,UAAU,gDAAgD,OAAO,IAAI;SAC5F,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { InstallIdentity } from '../install-identity.js';
|
|
2
|
+
import type { WorkspaceDiscoveryResult } from '../workspace-discovery.js';
|
|
3
|
+
export declare const SERVICE_RUN_STATUS_SCHEMA_VERSION = "pd.service-run-status.v1";
|
|
4
|
+
/** How this run was triggered. Phase 1 only ever has the manual CLI trigger. */
|
|
5
|
+
export type ServiceRunTriggerSource = 'manual';
|
|
6
|
+
/** Top-level run outcome (distinct from per-workspace verdicts). */
|
|
7
|
+
export type ServiceRunOutcome = 'completed' | 'already_running' | 'refused';
|
|
8
|
+
/**
|
|
9
|
+
* The five task-required read verdicts (missing / read_failed / unparsable /
|
|
10
|
+
* not_an_object / invalid) plus `ok`. Only `ok` marks a conforming record —
|
|
11
|
+
* `readable` alone NEVER does (P1-3).
|
|
12
|
+
*/
|
|
13
|
+
export type ActiveReleaseVerdict = 'ok' | 'missing' | 'read_failed' | 'unparsable' | 'not_an_object' | 'invalid';
|
|
14
|
+
export interface ActiveReleaseFacts {
|
|
15
|
+
/** The record file exists. */
|
|
16
|
+
readonly present: boolean;
|
|
17
|
+
/** The record parsed into a JSON object (diagnostic only). */
|
|
18
|
+
readonly readable: boolean;
|
|
19
|
+
/** The record conforms to the authoritative schema — the ONLY validity bit. */
|
|
20
|
+
readonly valid: boolean;
|
|
21
|
+
readonly verdict: ActiveReleaseVerdict;
|
|
22
|
+
/** Bounded release identity when valid (never a credential). */
|
|
23
|
+
readonly releaseId?: string;
|
|
24
|
+
readonly productVersion?: string;
|
|
25
|
+
readonly generation?: number;
|
|
26
|
+
/** Structured reason when not valid (rc-9). */
|
|
27
|
+
readonly reason?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Per-host root report (P1-2): where the coordinator looked for each host's
|
|
31
|
+
* claims, whether the root came from an env override, and whether it could
|
|
32
|
+
* actually be read. A root that cannot be read is NEVER silently folded
|
|
33
|
+
* into "no workspaces" — it is reported.
|
|
34
|
+
*/
|
|
35
|
+
export interface HostRootReport {
|
|
36
|
+
readonly host: 'openclaw' | 'codex' | 'workbuddy';
|
|
37
|
+
readonly root: string;
|
|
38
|
+
readonly source: 'default' | 'env';
|
|
39
|
+
readonly status: 'readable' | 'missing' | 'not_directory' | 'unreadable';
|
|
40
|
+
}
|
|
41
|
+
export interface ServiceRunStatus {
|
|
42
|
+
readonly schemaVersion: typeof SERVICE_RUN_STATUS_SCHEMA_VERSION;
|
|
43
|
+
readonly runId: string;
|
|
44
|
+
readonly outcome: ServiceRunOutcome;
|
|
45
|
+
readonly dryRun: boolean;
|
|
46
|
+
readonly triggerSource: ServiceRunTriggerSource;
|
|
47
|
+
readonly startedAt: string;
|
|
48
|
+
readonly completedAt: string;
|
|
49
|
+
readonly durationMs: number;
|
|
50
|
+
readonly installation: {
|
|
51
|
+
readonly pdHome: string;
|
|
52
|
+
readonly homeDir: string;
|
|
53
|
+
readonly homeSource: InstallIdentity['homeSource'];
|
|
54
|
+
readonly mode: InstallIdentity['mode'];
|
|
55
|
+
readonly activeRelease: ActiveReleaseFacts;
|
|
56
|
+
};
|
|
57
|
+
readonly environmentIsolation: {
|
|
58
|
+
/** PD_EXPERIMENT_ROOT was inherited and stripped before identity resolution. */
|
|
59
|
+
readonly pdExperimentRootStripped: boolean;
|
|
60
|
+
/** HOME/USERPROFILE present in the inherited env but ignored for identity. */
|
|
61
|
+
readonly ignoredIdentityEnvVars: readonly string[];
|
|
62
|
+
/** Host-root overrides that steered discovery (never pdHome). */
|
|
63
|
+
readonly inheritedHostRootEnvVars: readonly string[];
|
|
64
|
+
};
|
|
65
|
+
readonly manifest: {
|
|
66
|
+
/** ok | missing | read_failed | unparsable | invalid | version_mismatch */
|
|
67
|
+
readonly verdict: 'ok' | 'missing' | 'read_failed' | 'unparsable' | 'invalid' | 'version_mismatch';
|
|
68
|
+
readonly reason?: string;
|
|
69
|
+
readonly hosts: readonly string[];
|
|
70
|
+
readonly unknownHosts: readonly string[];
|
|
71
|
+
readonly workspacesCount: number;
|
|
72
|
+
};
|
|
73
|
+
readonly discovery: {
|
|
74
|
+
readonly discoveredTotal: number;
|
|
75
|
+
readonly counts: WorkspaceDiscoveryResult['counts'];
|
|
76
|
+
/** Every host root consulted this run (P1-2 evidence; never silent). */
|
|
77
|
+
readonly hostRoots: readonly HostRootReport[];
|
|
78
|
+
/**
|
|
79
|
+
* True when at least one consulted host root exists but could not be
|
|
80
|
+
* LISTED (status `unreadable` / `not_directory`, P2-1): the workspace
|
|
81
|
+
* list below may be missing entries, so a zero/low count is never the
|
|
82
|
+
* same fact as a finished discovery.
|
|
83
|
+
*/
|
|
84
|
+
readonly incomplete: boolean;
|
|
85
|
+
};
|
|
86
|
+
readonly workspaces: WorkspaceDiscoveryResult['workspaces'];
|
|
87
|
+
readonly nextAction: string;
|
|
88
|
+
}
|
|
89
|
+
export declare function serviceRunStatusPath(pdHome: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Read the active release record (`<pdHome>/active.json`) against the ONE
|
|
92
|
+
* authoritative schema in `@principles/install-layout` (P1-3): a record is
|
|
93
|
+
* `valid` only when it is the record the installer's commit point writes —
|
|
94
|
+
* schemaVersion 1, non-empty releaseId, positive-safe-integer generation,
|
|
95
|
+
* 64-hex digest, transactionId, productVersion (+ strict optional
|
|
96
|
+
* sourceCommit). Missing vs unreadable vs malformed JSON vs non-object vs
|
|
97
|
+
* schema-nonconforming stay distinct (rc-3/rc-9); a record that parses but
|
|
98
|
+
* fails schema is reported as `invalid`, NEVER as a healthy release.
|
|
99
|
+
*/
|
|
100
|
+
export declare function readActiveReleaseFacts(activeRecordPath: string): ActiveReleaseFacts;
|
|
101
|
+
/**
|
|
102
|
+
* Persist the status atomically (temp file in the same directory + rename).
|
|
103
|
+
* A failed write is LOUD (rc-9): the returned result distinguishes an
|
|
104
|
+
* unwritable directory from a rename failure instead of silently dropping
|
|
105
|
+
* the record. The rename overwrite semantics rely on Node's fs.renameSync
|
|
106
|
+
* POSIX behavior; on Windows a pre-existing destination is replaced (the
|
|
107
|
+
* established repo-wide atomic-write pattern, e.g. worker liveness files).
|
|
108
|
+
*/
|
|
109
|
+
export declare function writeServiceRunStatus(pdHome: string, status: ServiceRunStatus): {
|
|
110
|
+
ok: true;
|
|
111
|
+
path: string;
|
|
112
|
+
} | {
|
|
113
|
+
ok: false;
|
|
114
|
+
reason: string;
|
|
115
|
+
nextAction: string;
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=service-run-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-run-status.d.ts","sourceRoot":"","sources":["../../../../src/services/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