@principles/pd-cli 2.9.1 → 2.11.0
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/dist/commands/candidate.d.ts.map +1 -1
- package/dist/commands/candidate.js +16 -5
- package/dist/commands/candidate.js.map +1 -1
- package/dist/commands/codex-setup.d.ts.map +1 -1
- package/dist/commands/codex-setup.js +17 -1
- package/dist/commands/codex-setup.js.map +1 -1
- package/dist/commands/codex-worker.d.ts.map +1 -1
- package/dist/commands/codex-worker.js +8 -4
- package/dist/commands/codex-worker.js.map +1 -1
- package/dist/commands/consent-sweep-revoked.d.ts +20 -0
- package/dist/commands/consent-sweep-revoked.d.ts.map +1 -0
- package/dist/commands/consent-sweep-revoked.js +85 -0
- package/dist/commands/consent-sweep-revoked.js.map +1 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +9 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/diagnose.d.ts.map +1 -1
- package/dist/commands/diagnose.js +12 -6
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/openclaw-worker.d.ts +11 -0
- package/dist/commands/openclaw-worker.d.ts.map +1 -0
- package/dist/commands/openclaw-worker.js +199 -0
- package/dist/commands/openclaw-worker.js.map +1 -0
- package/dist/commands/pain-explicit.d.ts.map +1 -1
- package/dist/commands/pain-explicit.js +1 -0
- package/dist/commands/pain-explicit.js.map +1 -1
- package/dist/commands/pain-recall.d.ts +2 -2
- package/dist/commands/pain-recall.d.ts.map +1 -1
- package/dist/commands/pain-recall.js +7 -1
- package/dist/commands/pain-recall.js.map +1 -1
- package/dist/commands/pain-record.d.ts.map +1 -1
- package/dist/commands/pain-record.js +4 -1
- package/dist/commands/pain-record.js.map +1 -1
- package/dist/commands/pain-retry.d.ts.map +1 -1
- package/dist/commands/pain-retry.js +30 -6
- package/dist/commands/pain-retry.js.map +1 -1
- package/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-enqueue-successors.js +2 -1
- package/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
- package/dist/commands/runtime-internalization-run-once.d.ts +1 -0
- package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-run-once.js +32 -8
- package/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-wake-once.js +2 -1
- package/dist/commands/runtime-internalization-wake-once.js.map +1 -1
- package/dist/commands/service-handover.d.ts +12 -0
- package/dist/commands/service-handover.d.ts.map +1 -0
- package/dist/commands/service-handover.js +117 -0
- package/dist/commands/service-handover.js.map +1 -0
- package/dist/commands/service-lifecycle.d.ts +31 -0
- package/dist/commands/service-lifecycle.d.ts.map +1 -0
- package/dist/commands/service-lifecycle.js +207 -0
- package/dist/commands/service-lifecycle.js.map +1 -0
- package/dist/commands/service-run-once.d.ts +102 -0
- package/dist/commands/service-run-once.d.ts.map +1 -0
- package/dist/commands/service-run-once.js +558 -0
- package/dist/commands/service-run-once.js.map +1 -0
- package/dist/commands/workbuddy-setup.d.ts.map +1 -1
- package/dist/commands/workbuddy-setup.js +22 -2
- package/dist/commands/workbuddy-setup.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +180 -1
- package/dist/program.js.map +1 -1
- package/dist/services/admission-write-gate.d.ts +3 -1
- package/dist/services/admission-write-gate.d.ts.map +1 -1
- package/dist/services/admission-write-gate.js +1 -0
- package/dist/services/admission-write-gate.js.map +1 -1
- package/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
- package/dist/services/pain-flood-simulation-runner.js +4 -0
- package/dist/services/pain-flood-simulation-runner.js.map +1 -1
- package/dist/services/service-host/coordinator-common.d.ts +49 -0
- package/dist/services/service-host/coordinator-common.d.ts.map +1 -0
- package/dist/services/service-host/coordinator-common.js +158 -0
- package/dist/services/service-host/coordinator-common.js.map +1 -0
- package/dist/services/service-host/handover-claims.d.ts +14 -0
- package/dist/services/service-host/handover-claims.d.ts.map +1 -0
- package/dist/services/service-host/handover-claims.js +50 -0
- package/dist/services/service-host/handover-claims.js.map +1 -0
- package/dist/services/service-host/index.d.ts +31 -0
- package/dist/services/service-host/index.d.ts.map +1 -0
- package/dist/services/service-host/index.js +33 -0
- package/dist/services/service-host/index.js.map +1 -0
- package/dist/services/service-host/install-identity.d.ts +99 -0
- package/dist/services/service-host/install-identity.d.ts.map +1 -0
- package/dist/services/service-host/install-identity.js +176 -0
- package/dist/services/service-host/install-identity.js.map +1 -0
- package/dist/services/service-host/locking/service-run-lock.d.ts +255 -0
- package/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -0
- package/dist/services/service-host/locking/service-run-lock.js +739 -0
- package/dist/services/service-host/locking/service-run-lock.js.map +1 -0
- package/dist/services/service-host/managed-run.d.ts +75 -0
- package/dist/services/service-host/managed-run.d.ts.map +1 -0
- package/dist/services/service-host/managed-run.js +550 -0
- package/dist/services/service-host/managed-run.js.map +1 -0
- package/dist/services/service-host/owner-projection.d.ts +47 -0
- package/dist/services/service-host/owner-projection.d.ts.map +1 -0
- package/dist/services/service-host/owner-projection.js +121 -0
- package/dist/services/service-host/owner-projection.js.map +1 -0
- package/dist/services/service-host/progress-evidence.d.ts +38 -0
- package/dist/services/service-host/progress-evidence.d.ts.map +1 -0
- package/dist/services/service-host/progress-evidence.js +155 -0
- package/dist/services/service-host/progress-evidence.js.map +1 -0
- package/dist/services/service-host/run-once.d.ts +96 -0
- package/dist/services/service-host/run-once.d.ts.map +1 -0
- package/dist/services/service-host/run-once.js +308 -0
- package/dist/services/service-host/run-once.js.map +1 -0
- package/dist/services/service-host/scheduler/contract.d.ts +184 -0
- package/dist/services/service-host/scheduler/contract.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/contract.js +86 -0
- package/dist/services/service-host/scheduler/contract.js.map +1 -0
- package/dist/services/service-host/scheduler/index.d.ts +76 -0
- package/dist/services/service-host/scheduler/index.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/index.js +128 -0
- package/dist/services/service-host/scheduler/index.js.map +1 -0
- package/dist/services/service-host/scheduler/linux.d.ts +27 -0
- package/dist/services/service-host/scheduler/linux.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/linux.js +1010 -0
- package/dist/services/service-host/scheduler/linux.js.map +1 -0
- package/dist/services/service-host/scheduler/macos.d.ts +13 -0
- package/dist/services/service-host/scheduler/macos.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/macos.js +819 -0
- package/dist/services/service-host/scheduler/macos.js.map +1 -0
- package/dist/services/service-host/scheduler/runtime-io.d.ts +13 -0
- package/dist/services/service-host/scheduler/runtime-io.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/runtime-io.js +141 -0
- package/dist/services/service-host/scheduler/runtime-io.js.map +1 -0
- package/dist/services/service-host/scheduler/service-status.d.ts +99 -0
- package/dist/services/service-host/scheduler/service-status.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/service-status.js +202 -0
- package/dist/services/service-host/scheduler/service-status.js.map +1 -0
- package/dist/services/service-host/scheduler/windows.d.ts +40 -0
- package/dist/services/service-host/scheduler/windows.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/windows.js +688 -0
- package/dist/services/service-host/scheduler/windows.js.map +1 -0
- package/dist/services/service-host/shadow-progress-store.d.ts +43 -0
- package/dist/services/service-host/shadow-progress-store.d.ts.map +1 -0
- package/dist/services/service-host/shadow-progress-store.js +156 -0
- package/dist/services/service-host/shadow-progress-store.js.map +1 -0
- package/dist/services/service-host/shadow-run.d.ts +87 -0
- package/dist/services/service-host/shadow-run.d.ts.map +1 -0
- package/dist/services/service-host/shadow-run.js +549 -0
- package/dist/services/service-host/shadow-run.js.map +1 -0
- package/dist/services/service-host/status/service-run-status.d.ts +227 -0
- package/dist/services/service-host/status/service-run-status.d.ts.map +1 -0
- package/dist/services/service-host/status/service-run-status.js +187 -0
- package/dist/services/service-host/status/service-run-status.js.map +1 -0
- package/dist/services/service-host/worker-adapter-codex.d.ts +2 -0
- package/dist/services/service-host/worker-adapter-codex.d.ts.map +1 -0
- package/dist/services/service-host/worker-adapter-codex.js +76 -0
- package/dist/services/service-host/worker-adapter-codex.js.map +1 -0
- package/dist/services/service-host/worker-adapter-openclaw.d.ts +2 -0
- package/dist/services/service-host/worker-adapter-openclaw.d.ts.map +1 -0
- package/dist/services/service-host/worker-adapter-openclaw.js +49 -0
- package/dist/services/service-host/worker-adapter-openclaw.js.map +1 -0
- package/dist/services/service-host/worker-adapter-workbuddy.d.ts +2 -0
- package/dist/services/service-host/worker-adapter-workbuddy.d.ts.map +1 -0
- package/dist/services/service-host/worker-adapter-workbuddy.js +36 -0
- package/dist/services/service-host/worker-adapter-workbuddy.js.map +1 -0
- package/dist/services/service-host/worker-adapter.d.ts +187 -0
- package/dist/services/service-host/worker-adapter.d.ts.map +1 -0
- package/dist/services/service-host/worker-adapter.js +609 -0
- package/dist/services/service-host/worker-adapter.js.map +1 -0
- package/dist/services/service-host/worker-env.d.ts +84 -0
- package/dist/services/service-host/worker-env.d.ts.map +1 -0
- package/dist/services/service-host/worker-env.js +195 -0
- package/dist/services/service-host/worker-env.js.map +1 -0
- package/dist/services/service-host/worker-process.d.ts +75 -0
- package/dist/services/service-host/worker-process.d.ts.map +1 -0
- package/dist/services/service-host/worker-process.js +225 -0
- package/dist/services/service-host/worker-process.js.map +1 -0
- package/dist/services/service-host/workspace-discovery.d.ts +71 -0
- package/dist/services/service-host/workspace-discovery.d.ts.map +1 -0
- package/dist/services/service-host/workspace-discovery.js +288 -0
- package/dist/services/service-host/workspace-discovery.js.map +1 -0
- package/dist/services/service-host/workspace-dispatch.d.ts +61 -0
- package/dist/services/service-host/workspace-dispatch.d.ts.map +1 -0
- package/dist/services/service-host/workspace-dispatch.js +105 -0
- package/dist/services/service-host/workspace-dispatch.js.map +1 -0
- package/dist/services/service-host/workspace-handover.d.ts +190 -0
- package/dist/services/service-host/workspace-handover.d.ts.map +1 -0
- package/dist/services/service-host/workspace-handover.js +1393 -0
- package/dist/services/service-host/workspace-handover.js.map +1 -0
- package/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
- package/dist/services/synthetic-baseline-runner.js +4 -0
- package/dist/services/synthetic-baseline-runner.js.map +1 -1
- package/package.json +10 -9
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coordinator install identity (SPEC-PD-SERVICE-HOST-001 §8.2 step 1, TD §5.2).
|
|
3
|
+
*
|
|
4
|
+
* The run-once coordinator must act on ONE explicit production install
|
|
5
|
+
* identity, and TD §5.2 names every env variable that must NOT be able to
|
|
6
|
+
* relocate it: `PD_EXPERIMENT_ROOT`, `HOME`/`USERPROFILE`,
|
|
7
|
+
* `OPENCLAW_STATE_DIR`/`OPENCLAW_HOME`, `WORKBUDDY_CONFIG_DIR`,
|
|
8
|
+
* `CODEX_HOME`.
|
|
9
|
+
*
|
|
10
|
+
* Two different questions get two different authorities:
|
|
11
|
+
*
|
|
12
|
+
* - WHO this install is (pdHome identity): derived ONLY from the OS account
|
|
13
|
+
* record — `os.userInfo().homedir`, which reads getpwuid /
|
|
14
|
+
* GetUserProfileDirectoryW and cannot be overridden by inherited env vars.
|
|
15
|
+
* `PD_EXPERIMENT_ROOT` is stripped before resolution and `HOME` /
|
|
16
|
+
* `USERPROFILE` are ignored for identity entirely; each fact is RECORDED
|
|
17
|
+
* in the returned environment view (rc-9), never silently dropped. When no
|
|
18
|
+
* trusted home can be determined (no OS record, non-absolute result) the
|
|
19
|
+
* coordinator REFUSES — it never falls back to an env-derived guess.
|
|
20
|
+
* - WHICH host roots the same install serves (discovery context): the host
|
|
21
|
+
* overrides ARE honored, exactly like every other PD component resolves
|
|
22
|
+
* them. They decide where workspace claims are collected; they can never
|
|
23
|
+
* move `pdHome` itself (P1-2 contract).
|
|
24
|
+
*
|
|
25
|
+
* The registration-pinned identity (TD §5.2 "由注册时解析出的绝对路径决定")
|
|
26
|
+
* arrives with `pd service install` in Phase 3; until then the OS record is
|
|
27
|
+
* the single identity authority. `trustedHomeDir` exists so callers with an
|
|
28
|
+
* already-verified home (tests, the future registration handoff) can pin the
|
|
29
|
+
* same authority without going through the OS lookup again.
|
|
30
|
+
*/
|
|
31
|
+
import * as os from 'node:os';
|
|
32
|
+
import * as path from 'node:path';
|
|
33
|
+
import { resolvePdHome } from '@principles/install-layout';
|
|
34
|
+
/** The one identity-switching experiment variable (pd-home.ts). */
|
|
35
|
+
const PD_EXPERIMENT_ROOT = 'PD_EXPERIMENT_ROOT';
|
|
36
|
+
/**
|
|
37
|
+
* Env variables that may steer host discovery but must never steer the
|
|
38
|
+
* coordinator's own identity. Recorded so the status output shows exactly
|
|
39
|
+
* which inherited inputs were consulted vs. ignored (rc-9).
|
|
40
|
+
*/
|
|
41
|
+
const IDENTITY_IGNORED_ENV_VARS = ['HOME', 'USERPROFILE'];
|
|
42
|
+
const HOST_ROOT_ENV_VARS = [
|
|
43
|
+
'OPENCLAW_STATE_DIR',
|
|
44
|
+
'OPENCLAW_HOME',
|
|
45
|
+
'CODEX_HOME',
|
|
46
|
+
'WORKBUDDY_CONFIG_DIR',
|
|
47
|
+
];
|
|
48
|
+
/** Strip the experiment-root switch, keeping every other variable intact. */
|
|
49
|
+
export function stripExperimentRoot(env) {
|
|
50
|
+
const isSet = (name) => {
|
|
51
|
+
const value = env[name];
|
|
52
|
+
return value !== undefined && value.trim().length > 0;
|
|
53
|
+
};
|
|
54
|
+
const ignoredIdentityEnvVars = IDENTITY_IGNORED_ENV_VARS.filter(isSet);
|
|
55
|
+
const inheritedHostRootEnvVars = HOST_ROOT_ENV_VARS.filter(isSet);
|
|
56
|
+
const base = {
|
|
57
|
+
ignoredIdentityEnvVars,
|
|
58
|
+
inheritedHostRootEnvVars,
|
|
59
|
+
// Overridden by resolveCoordinatorInstallIdentity when host-root
|
|
60
|
+
// resolution ignores the inherited overrides (canonicalHostRootsOnly).
|
|
61
|
+
ignoredHostRootEnvVars: [],
|
|
62
|
+
};
|
|
63
|
+
const raw = env[PD_EXPERIMENT_ROOT];
|
|
64
|
+
if (raw === undefined) {
|
|
65
|
+
return {
|
|
66
|
+
env: { ...env },
|
|
67
|
+
view: { inheritedExperimentRoot: false, experimentRootStripped: false, ...base },
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const next = {};
|
|
71
|
+
for (const [key, value] of Object.entries(env)) {
|
|
72
|
+
if (key !== PD_EXPERIMENT_ROOT)
|
|
73
|
+
next[key] = value;
|
|
74
|
+
}
|
|
75
|
+
const bounded = raw.length > 120 ? `${raw.slice(0, 120)}…` : raw;
|
|
76
|
+
return {
|
|
77
|
+
env: next,
|
|
78
|
+
view: {
|
|
79
|
+
inheritedExperimentRoot: true,
|
|
80
|
+
experimentRootStripped: true,
|
|
81
|
+
...(bounded.length > 0 ? { inheritedExperimentRootValue: bounded } : {}),
|
|
82
|
+
...base,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The OS account record's home. `os.userInfo()` resolves via getpwuid /
|
|
88
|
+
* GetUserProfileDirectoryW — it never consults `HOME` or `USERPROFILE`,
|
|
89
|
+
* which is exactly why it is the only env-independent authority available
|
|
90
|
+
* in-process.
|
|
91
|
+
*/
|
|
92
|
+
function resolveOsAccountHome() {
|
|
93
|
+
try {
|
|
94
|
+
const homeDir = os.userInfo().homedir;
|
|
95
|
+
if (typeof homeDir !== 'string' || homeDir.length === 0) {
|
|
96
|
+
return { ok: false, detail: 'os_user_home_unavailable' };
|
|
97
|
+
}
|
|
98
|
+
return { ok: true, homeDir };
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return { ok: false, detail: 'os_user_home_unavailable' };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resolve the coordinator's install identity. The home comes ONLY from the
|
|
106
|
+
* OS account record (or an explicitly pinned trusted home) — never from
|
|
107
|
+
* `HOME`/`USERPROFILE` — and `PD_EXPERIMENT_ROOT` is stripped before
|
|
108
|
+
* resolution. Every honored/ignored inherited input is recorded in the
|
|
109
|
+
* environment view. Any inability to determine a trusted identity is a
|
|
110
|
+
* structured refusal, never a downgrade to an env-derived or experimental
|
|
111
|
+
* directory.
|
|
112
|
+
*/
|
|
113
|
+
export function resolveCoordinatorInstallIdentity(env = process.env, options = {}) {
|
|
114
|
+
const { env: stripped, view } = stripExperimentRoot(env);
|
|
115
|
+
const homeSource = options.trustedHomeDir !== undefined ? 'injected' : 'os.userInfo()';
|
|
116
|
+
let homeDir;
|
|
117
|
+
if (options.trustedHomeDir !== undefined) {
|
|
118
|
+
homeDir = options.trustedHomeDir;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const osHome = resolveOsAccountHome();
|
|
122
|
+
if (!osHome.ok) {
|
|
123
|
+
return {
|
|
124
|
+
ok: false,
|
|
125
|
+
reason: `install_identity_refused:${osHome.detail}`,
|
|
126
|
+
nextAction: 'Cannot determine the production install identity: the OS account record has no home directory. ' +
|
|
127
|
+
'Run the coordinator as a real OS user with a valid home, or reinstall PD with `npx create-principles-disciple`.',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
({ homeDir } = osHome);
|
|
131
|
+
}
|
|
132
|
+
if (!path.isAbsolute(homeDir)) {
|
|
133
|
+
return {
|
|
134
|
+
ok: false,
|
|
135
|
+
reason: 'install_identity_refused:home_not_absolute',
|
|
136
|
+
nextAction: 'Cannot determine the production install identity: the trusted home is not an absolute path. ' +
|
|
137
|
+
'Fix the OS account home directory, or reinstall PD with `npx create-principles-disciple`.',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// canonicalHostRootsOnly: host-root resolution sees an EMPTY env — the
|
|
141
|
+
// overrides resolve to the trusted-home defaults — while the inherited
|
|
142
|
+
// presence is recorded as ignored (rc-9). HOME/USERPROFILE stay in
|
|
143
|
+
// `stripped` (they are never consulted for host roots anyway).
|
|
144
|
+
const ignoredHostRootEnvVars = options.canonicalHostRootsOnly === true
|
|
145
|
+
? view.inheritedHostRootEnvVars
|
|
146
|
+
: [];
|
|
147
|
+
const resolution = resolvePdHome({
|
|
148
|
+
env: options.canonicalHostRootsOnly === true ? {} : stripped,
|
|
149
|
+
homeDir,
|
|
150
|
+
});
|
|
151
|
+
if (!resolution.ok) {
|
|
152
|
+
return {
|
|
153
|
+
ok: false,
|
|
154
|
+
reason: `install_identity_refused:${resolution.reason}`,
|
|
155
|
+
nextAction: resolution.nextAction,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
ok: true,
|
|
160
|
+
identity: {
|
|
161
|
+
pdHome: resolution.pdHome,
|
|
162
|
+
homeDir: resolution.homeDir,
|
|
163
|
+
homeSource,
|
|
164
|
+
manifestPath: path.join(resolution.pdHome, 'install.json'),
|
|
165
|
+
activeRecordPath: path.join(resolution.pdHome, 'active.json'),
|
|
166
|
+
hostRoots: {
|
|
167
|
+
openclawHome: resolution.openclawHome,
|
|
168
|
+
codexHome: resolution.codexHome,
|
|
169
|
+
workbuddyConfigDir: resolution.workbuddyConfigDir,
|
|
170
|
+
},
|
|
171
|
+
mode: 'production',
|
|
172
|
+
environment: { ...view, ignoredHostRootEnvVars },
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=install-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-identity.js","sourceRoot":"","sources":["../../../src/services/service-host/install-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,mEAAmE;AACnE,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,CAA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AO;YAC3B,UAAU;YACV,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC;YAC1D,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC;YAC7D,SAAS,EAAE;gBACT,YAAY,EAAE,UAAU,CAAC,YAAY;gBACrC,SAAS,EAAE,UAAU,CAAC,SAAS;gBAC/B,kBAAkB,EAAE,UAAU,CAAC,kBAAkB;aAClD;YACD,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,EAAE,GAAG,IAAI,EAAE,sBAAsB,EAAE;SACjD;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install-level single-instance run lock (SPEC-PD-SERVICE-HOST-001 §8.2 step
|
|
3
|
+
* 2, FR-08; TD §2.1 `locking/service-run-lock.ts`).
|
|
4
|
+
*
|
|
5
|
+
* The protocol is the one proven by PRI-1151's cross-process control-state
|
|
6
|
+
* lock (`host-runtime/product-telemetry/control-state-lock.ts`): atomic
|
|
7
|
+
* `'wx'` create with an owner body `<pid> <token> <createdAtISO>`; ownership-
|
|
8
|
+
* checked release; stale takeover gated on holder-liveness proof. It is
|
|
9
|
+
* re-declared here rather than exported because the semantic contract
|
|
10
|
+
* genuinely differs (P7: a real variation axis, not a speculative seam):
|
|
11
|
+
*
|
|
12
|
+
* - The control-state lock guards millisecond-scale read-modify-write
|
|
13
|
+
* transactions (5s stale window). A run-once coordinator legitimately
|
|
14
|
+
* runs for minutes, so a second coordinator must NEVER take over a lock
|
|
15
|
+
* that may still be a live run — the stale window is 30 minutes by
|
|
16
|
+
* default.
|
|
17
|
+
* - Contention is an IMMEDIATE verdict, not a bounded wait: SPEC §8.2
|
|
18
|
+
* requires the second instance to report `already_running`, not to queue
|
|
19
|
+
* behind the first.
|
|
20
|
+
* - A stale mtime whose body cannot be read is `corrupt` (fail-closed,
|
|
21
|
+
* human decision), never silently takeover-able and never reported as a
|
|
22
|
+
* live run.
|
|
23
|
+
*
|
|
24
|
+
* ── Concurrency protocol (P1-4 round 4: SQLite arbitration) ────────────────
|
|
25
|
+
*
|
|
26
|
+
* Every acquisition, takeover and release decision is serialized through a
|
|
27
|
+
* dedicated arbitration gate: the stable, short-lived SQLite database
|
|
28
|
+
* `<pdHome>/service/service-run-gate.db`, guarded by `BEGIN IMMEDIATE`.
|
|
29
|
+
* While one process holds the transaction, a contender's `BEGIN IMMEDIATE`
|
|
30
|
+
* fails with SQLITE_BUSY — ACQUIRE waits zero milliseconds (SPEC §8.2
|
|
31
|
+
* immediate `already_running`, never a queue), RELEASE retries briefly and
|
|
32
|
+
* bounded. A gate that cannot be opened or transacted at all maps to
|
|
33
|
+
* `unwritable` (fail-closed).
|
|
34
|
+
*
|
|
35
|
+
* The state machine inside the transaction is:
|
|
36
|
+
*
|
|
37
|
+
* evaluateLock ─ 'absent' → 'wx' create → acquired
|
|
38
|
+
* ├ 'fresh' → held
|
|
39
|
+
* ├ 'dead' → re-evaluate → unlink → 'wx' create
|
|
40
|
+
* │ → acquired(staleTakenOver)
|
|
41
|
+
* ├ 'stale-alive' → held (live or inconclusive owner)
|
|
42
|
+
* ├ 'stale-unreadable' → corrupt (identity unverifiable)
|
|
43
|
+
* └ 'stale-anonymous' → corrupt (no holder identity)
|
|
44
|
+
*
|
|
45
|
+
* 'dead' means the recorded holder PID is PROVABLY dead — age does not
|
|
46
|
+
* matter: a verifiably-exited holder is recovered immediately rather than
|
|
47
|
+
* waiting out the stale window (§P0.8).
|
|
48
|
+
*
|
|
49
|
+
* Why this closes the file-mutex races:
|
|
50
|
+
*
|
|
51
|
+
* - No mutex file exists. The arbiter is a real cross-process lock held by
|
|
52
|
+
* the OS/SQLite, not a file whose mtime pretends to prove liveness — so
|
|
53
|
+
* "stale mutex" reclaim is impossible by construction, and a live
|
|
54
|
+
* coordinator's arbitration can never be reclaimed by file-age
|
|
55
|
+
* heuristics (P1-4A moot). File age only feeds `evaluateLock`, and only
|
|
56
|
+
* inside the serialized section where PID liveness remains the sole
|
|
57
|
+
* takeover authority.
|
|
58
|
+
* - verify→delete→create is one transaction: two stale breakers cannot
|
|
59
|
+
* interleave (P1-4B). The first commits before the second's BEGIN
|
|
60
|
+
* completes; the second re-evaluates AFTER the first's lock is already
|
|
61
|
+
* in place and reports `held`.
|
|
62
|
+
* - A crashed coordinator releases its transaction through the OS
|
|
63
|
+
* automatically — recovery is immediate and deterministic (P1-4B).
|
|
64
|
+
* - Release is verify-body + unlink inside the SAME transaction: a true
|
|
65
|
+
* compare-and-delete under the arbiter, never a read→compare→unlink
|
|
66
|
+
* window (P1-4C). A foreign body is never unlinked.
|
|
67
|
+
* - No generic sweep touches arbitration state: `sweepOrphanSidecars`
|
|
68
|
+
* only removes age-proven legacy sidecars (`.mtx`, `.take-*`, `.rel-*`),
|
|
69
|
+
* none of which the new protocol creates or reads (P1-4D). The gate
|
|
70
|
+
* database and its `-journal`/`-wal`/`-shm` sidecars are never swept.
|
|
71
|
+
*
|
|
72
|
+
* No heartbeat exists and none is needed for Phase 1: a run is bounded far
|
|
73
|
+
* below the stale window, and mid-run ownership is re-verified by
|
|
74
|
+
* `holdsServiceRunLock` (the body compare IS the heartbeat-identity check —
|
|
75
|
+
* a file no longer carrying our body means we lost the run). PID liveness
|
|
76
|
+
* remains the sole takeover authority — file age alone is never the sole
|
|
77
|
+
* eviction signal (same rule as `principles-core/ledger-file-lock.ts`).
|
|
78
|
+
*
|
|
79
|
+
* Cross-platform note: `BEGIN IMMEDIATE` is the same advisory-file-lock
|
|
80
|
+
* arbitration on POSIX and Windows (SQLite's POSIX fcntl locks and Windows
|
|
81
|
+
* LockFileEx regions are both released by the OS on process death), and the
|
|
82
|
+
* lock file itself still changes hands only via 'wx' create + unlink —
|
|
83
|
+
* never rename, whose overwrite semantics differ between the platforms. A
|
|
84
|
+
* file still open by its dead holder is not unlinkable on Windows — unlink
|
|
85
|
+
* failure aborts the takeover fail-closed inside the transaction.
|
|
86
|
+
*/
|
|
87
|
+
import * as fs from 'node:fs';
|
|
88
|
+
/**
|
|
89
|
+
* A lock older than this is treated as a crashed holder. A legitimate
|
|
90
|
+
* run-once (bounded cycles, Phase 2 per-workspace timeouts) must stay well
|
|
91
|
+
* below this window; the dry-run of Phase 1 finishes in seconds.
|
|
92
|
+
*/
|
|
93
|
+
export declare const SERVICE_RUN_LOCK_STALE_MS: number;
|
|
94
|
+
/** The one lock file per install: `<pdHome>/service/service-run.lock`. */
|
|
95
|
+
export declare function serviceRunLockPath(pdHome: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* The per-workspace consumer mutex: `<pdHome>/service/workspace-runs/<hash>.lock`.
|
|
98
|
+
*
|
|
99
|
+
* A consuming Worker child holds this for the whole cycle, so an
|
|
100
|
+
* orchestrator (handover resume / rollback) can prove "an old worker is
|
|
101
|
+
* still running on THIS workspace" by holder-PID liveness instead of
|
|
102
|
+
* guessing from the coordinator's own lock. The workspace is addressed by
|
|
103
|
+
* its canonical real directory — the same spelling-or-alias identity rule
|
|
104
|
+
* the §8.4 ownership projection uses — so either path spelling reaches the
|
|
105
|
+
* same mutex (PRI-1282 review).
|
|
106
|
+
*/
|
|
107
|
+
export declare function workspaceServiceRunLockPath(pdHome: string, workspaceDir: string): string;
|
|
108
|
+
export interface ServiceRunLockHandle {
|
|
109
|
+
readonly lockPath: string;
|
|
110
|
+
/** Random per-acquisition token; identifies THIS holder inside the body. */
|
|
111
|
+
readonly token: string;
|
|
112
|
+
/** The exact body we wrote; release and re-verification check it. */
|
|
113
|
+
readonly body: string;
|
|
114
|
+
}
|
|
115
|
+
export type AcquireServiceRunLockResult = {
|
|
116
|
+
ok: true;
|
|
117
|
+
handle: ServiceRunLockHandle;
|
|
118
|
+
staleTakenOver: boolean;
|
|
119
|
+
} | {
|
|
120
|
+
ok: false;
|
|
121
|
+
kind: 'held';
|
|
122
|
+
holderBodyHash: string;
|
|
123
|
+
} | {
|
|
124
|
+
ok: false;
|
|
125
|
+
kind: 'corrupt';
|
|
126
|
+
detail: string;
|
|
127
|
+
} | {
|
|
128
|
+
ok: false;
|
|
129
|
+
kind: 'unwritable';
|
|
130
|
+
detail: string;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Holder-liveness verdict. 'alive' includes EPERM-observable processes
|
|
134
|
+
* (exists, we just can't signal it). 'unknown' means the platform could not
|
|
135
|
+
* produce a reliable verdict — takeover must fail CLOSED on it.
|
|
136
|
+
*/
|
|
137
|
+
export type HolderLiveness = 'alive' | 'dead' | 'unknown';
|
|
138
|
+
/**
|
|
139
|
+
* Deterministic injection points inside the arbitrated takeover section so
|
|
140
|
+
* multi-process tests can interleave contenders without random sleeps.
|
|
141
|
+
* Called synchronously INSIDE the arbitration transaction — a contender
|
|
142
|
+
* parked here still holds the gate, which is exactly what the tests need to
|
|
143
|
+
* prove: nobody else can even evaluate the lock meanwhile.
|
|
144
|
+
* A thrown error aborts the takeover fail-closed (transaction rolled back).
|
|
145
|
+
*/
|
|
146
|
+
export type ServiceRunLockTakeoverPhase = 'mutex-acquired' | 'stale-verified' | 'lock-removed';
|
|
147
|
+
export interface ServiceRunLockProbes {
|
|
148
|
+
/**
|
|
149
|
+
* Liveness probe for the PID recorded in a stale lock body. Default:
|
|
150
|
+
* `process.kill(pid, 0)` semantics (alive / ESRCH→dead / EPERM→alive /
|
|
151
|
+
* anything else→unknown). Tests inject fakes; the contract is that an
|
|
152
|
+
* inconclusive answer MUST yield 'unknown' (fail-closed), never 'dead'.
|
|
153
|
+
*/
|
|
154
|
+
readonly processAlive?: (pid: number) => HolderLiveness;
|
|
155
|
+
/**
|
|
156
|
+
* Synchronization hook for deterministic takeover-interleaving tests.
|
|
157
|
+
* Invoked once per phase inside the arbitration transaction; production
|
|
158
|
+
* passes nothing.
|
|
159
|
+
*/
|
|
160
|
+
readonly takeoverSync?: (phase: ServiceRunLockTakeoverPhase) => void;
|
|
161
|
+
/**
|
|
162
|
+
* Deterministic test seam: force the gate transaction's END to fail after
|
|
163
|
+
* the acquire body ran — exercises the orphan-lock compensation path
|
|
164
|
+
* (§P0). Production never sets it.
|
|
165
|
+
*/
|
|
166
|
+
readonly gateEndFailure?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Deterministic test seam: replace the lock-file stat (default
|
|
169
|
+
* `fs.statSync`). Lets tests reproduce EACCES/EIO/ENOTDIR stat failures on
|
|
170
|
+
* every platform without depending on OS permission behavior —
|
|
171
|
+
* production never sets it.
|
|
172
|
+
*/
|
|
173
|
+
readonly statLock?: (lockPath: string) => fs.Stats;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Structured lock-file read outcome (P0 round 6): a missing file and an
|
|
177
|
+
* existing-but-unreadable file are different facts and the release path
|
|
178
|
+
* MUST distinguish them — EACCES/EPERM/EIO/EISDIR are degraded evidence,
|
|
179
|
+
* never `not_owned`.
|
|
180
|
+
*/
|
|
181
|
+
export type LockBodyRead = {
|
|
182
|
+
readonly kind: 'readable';
|
|
183
|
+
readonly body: string;
|
|
184
|
+
} | {
|
|
185
|
+
readonly kind: 'absent';
|
|
186
|
+
} | {
|
|
187
|
+
readonly kind: 'unreadable';
|
|
188
|
+
readonly detail: string;
|
|
189
|
+
};
|
|
190
|
+
export declare function readLockBodyStatus(lockPath: string): LockBodyRead;
|
|
191
|
+
/** True when the lock file still carries OUR body (mid-run ownership re-check). */
|
|
192
|
+
export declare function holdsServiceRunLock(handle: ServiceRunLockHandle): boolean;
|
|
193
|
+
/** Acquire the install-level single-instance run lock (see {@link acquireLockAt}). */
|
|
194
|
+
export declare function acquireServiceRunLock(pdHome: string, options?: {
|
|
195
|
+
staleMs?: number;
|
|
196
|
+
probes?: ServiceRunLockProbes;
|
|
197
|
+
}): AcquireServiceRunLockResult;
|
|
198
|
+
/**
|
|
199
|
+
* Acquire the per-workspace consumer mutex (see
|
|
200
|
+
* {@link workspaceServiceRunLockPath}). Same protocol as the install-level
|
|
201
|
+
* lock; the Worker child holds it for its whole consuming cycle so a
|
|
202
|
+
* handover resume / rollback can prove the old worker is still running
|
|
203
|
+
* (PRI-1282 review).
|
|
204
|
+
*/
|
|
205
|
+
export declare function acquireWorkspaceServiceRunLock(pdHome: string, workspaceDir: string, options?: {
|
|
206
|
+
staleMs?: number;
|
|
207
|
+
probes?: ServiceRunLockProbes;
|
|
208
|
+
}): AcquireServiceRunLockResult;
|
|
209
|
+
/**
|
|
210
|
+
* Non-mutating liveness probe: is a CONSUMING worker holding this lock
|
|
211
|
+
* right now? 'free' means no holder or a provably-dead one (recoverable);
|
|
212
|
+
* 'held' means a live or inconclusive holder — an orchestrator must refuse
|
|
213
|
+
* to overlap it; 'corrupt' means the body cannot be verified (fail-closed).
|
|
214
|
+
*/
|
|
215
|
+
export declare function probeServiceRunLockState(lockPath: string, options?: {
|
|
216
|
+
staleMs?: number;
|
|
217
|
+
probes?: ServiceRunLockProbes;
|
|
218
|
+
}): {
|
|
219
|
+
state: 'free' | 'held' | 'corrupt';
|
|
220
|
+
detail?: string;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Structured release outcome (§三): a release can never be silent.
|
|
224
|
+
* - `released` — our lock was verified and unlinked under the gate;
|
|
225
|
+
* - `not_owned` — the lock is gone or already another holder's;
|
|
226
|
+
* never an error, and never deletes a foreign body;
|
|
227
|
+
* - `failed_busy` — the arbiter stayed busy through the bounded retry;
|
|
228
|
+
* - `failed_unwritable` — the gate/transaction itself failed.
|
|
229
|
+
*/
|
|
230
|
+
export type ReleaseServiceRunLockResult = 'released' | 'not_owned' | 'failed_busy' | 'failed_unwritable';
|
|
231
|
+
export interface ReleaseServiceRunLockOptions {
|
|
232
|
+
/** Deterministic test seam: force the release transaction's end to fail. */
|
|
233
|
+
readonly injectEndFailure?: boolean;
|
|
234
|
+
/** Hook invoked once inside the release transaction (deterministic tests). */
|
|
235
|
+
readonly insideTxn?: () => void;
|
|
236
|
+
/**
|
|
237
|
+
* Deterministic test seam: replace the lock-file read inside the
|
|
238
|
+
* release transaction (default: the real classified read). Lets tests
|
|
239
|
+
* reproduce EACCES/EPERM/EIO on every platform without depending on OS
|
|
240
|
+
* permission behavior — production never sets it.
|
|
241
|
+
*/
|
|
242
|
+
readonly readBody?: (lockPath: string) => LockBodyRead;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Ownership-checked release under the SAME arbitration gate: verify the
|
|
246
|
+
* lock body is OURS and unlink it inside one transaction — a true
|
|
247
|
+
* compare-and-delete, so the file a foreign holder just created can never
|
|
248
|
+
* be removed by our late release (P1-4). The release gets its own bounded
|
|
249
|
+
* retry (`RELEASE_BUSY_TIMEOUT_MS` × `RELEASE_MAX_ATTEMPTS`) independent of
|
|
250
|
+
* acquire's zero-wait policy, but NEVER bypasses the gate to unlink: a gate
|
|
251
|
+
* failure leaves the lock in place and reports it — the leftover carries
|
|
252
|
+
* our own PID, which the next contender recovers on death evidence.
|
|
253
|
+
*/
|
|
254
|
+
export declare function releaseServiceRunLock(handle: ServiceRunLockHandle, options?: ReleaseServiceRunLockOptions): ReleaseServiceRunLockResult;
|
|
255
|
+
//# sourceMappingURL=service-run-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-run-lock.d.ts","sourceRoot":"","sources":["../../../../src/services/service-host/locking/service-run-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqFG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAK9B;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,QAAiB,CAAC;AAcxD,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,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