@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.
Files changed (187) hide show
  1. package/dist/commands/candidate.d.ts.map +1 -1
  2. package/dist/commands/candidate.js +16 -5
  3. package/dist/commands/candidate.js.map +1 -1
  4. package/dist/commands/codex-setup.d.ts.map +1 -1
  5. package/dist/commands/codex-setup.js +17 -1
  6. package/dist/commands/codex-setup.js.map +1 -1
  7. package/dist/commands/codex-worker.d.ts.map +1 -1
  8. package/dist/commands/codex-worker.js +8 -4
  9. package/dist/commands/codex-worker.js.map +1 -1
  10. package/dist/commands/consent-sweep-revoked.d.ts +20 -0
  11. package/dist/commands/consent-sweep-revoked.d.ts.map +1 -0
  12. package/dist/commands/consent-sweep-revoked.js +85 -0
  13. package/dist/commands/consent-sweep-revoked.js.map +1 -0
  14. package/dist/commands/context.d.ts.map +1 -1
  15. package/dist/commands/context.js +9 -1
  16. package/dist/commands/context.js.map +1 -1
  17. package/dist/commands/diagnose.d.ts.map +1 -1
  18. package/dist/commands/diagnose.js +12 -6
  19. package/dist/commands/diagnose.js.map +1 -1
  20. package/dist/commands/openclaw-worker.d.ts +11 -0
  21. package/dist/commands/openclaw-worker.d.ts.map +1 -0
  22. package/dist/commands/openclaw-worker.js +199 -0
  23. package/dist/commands/openclaw-worker.js.map +1 -0
  24. package/dist/commands/pain-explicit.d.ts.map +1 -1
  25. package/dist/commands/pain-explicit.js +1 -0
  26. package/dist/commands/pain-explicit.js.map +1 -1
  27. package/dist/commands/pain-recall.d.ts +2 -2
  28. package/dist/commands/pain-recall.d.ts.map +1 -1
  29. package/dist/commands/pain-recall.js +7 -1
  30. package/dist/commands/pain-recall.js.map +1 -1
  31. package/dist/commands/pain-record.d.ts.map +1 -1
  32. package/dist/commands/pain-record.js +4 -1
  33. package/dist/commands/pain-record.js.map +1 -1
  34. package/dist/commands/pain-retry.d.ts.map +1 -1
  35. package/dist/commands/pain-retry.js +30 -6
  36. package/dist/commands/pain-retry.js.map +1 -1
  37. package/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
  38. package/dist/commands/runtime-internalization-enqueue-successors.js +2 -1
  39. package/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
  40. package/dist/commands/runtime-internalization-run-once.d.ts +1 -0
  41. package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  42. package/dist/commands/runtime-internalization-run-once.js +32 -8
  43. package/dist/commands/runtime-internalization-run-once.js.map +1 -1
  44. package/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -1
  45. package/dist/commands/runtime-internalization-wake-once.js +2 -1
  46. package/dist/commands/runtime-internalization-wake-once.js.map +1 -1
  47. package/dist/commands/service-handover.d.ts +12 -0
  48. package/dist/commands/service-handover.d.ts.map +1 -0
  49. package/dist/commands/service-handover.js +117 -0
  50. package/dist/commands/service-handover.js.map +1 -0
  51. package/dist/commands/service-lifecycle.d.ts +31 -0
  52. package/dist/commands/service-lifecycle.d.ts.map +1 -0
  53. package/dist/commands/service-lifecycle.js +207 -0
  54. package/dist/commands/service-lifecycle.js.map +1 -0
  55. package/dist/commands/service-run-once.d.ts +102 -0
  56. package/dist/commands/service-run-once.d.ts.map +1 -0
  57. package/dist/commands/service-run-once.js +558 -0
  58. package/dist/commands/service-run-once.js.map +1 -0
  59. package/dist/commands/workbuddy-setup.d.ts.map +1 -1
  60. package/dist/commands/workbuddy-setup.js +22 -2
  61. package/dist/commands/workbuddy-setup.js.map +1 -1
  62. package/dist/program.d.ts.map +1 -1
  63. package/dist/program.js +180 -1
  64. package/dist/program.js.map +1 -1
  65. package/dist/services/admission-write-gate.d.ts +3 -1
  66. package/dist/services/admission-write-gate.d.ts.map +1 -1
  67. package/dist/services/admission-write-gate.js +1 -0
  68. package/dist/services/admission-write-gate.js.map +1 -1
  69. package/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
  70. package/dist/services/pain-flood-simulation-runner.js +4 -0
  71. package/dist/services/pain-flood-simulation-runner.js.map +1 -1
  72. package/dist/services/service-host/coordinator-common.d.ts +49 -0
  73. package/dist/services/service-host/coordinator-common.d.ts.map +1 -0
  74. package/dist/services/service-host/coordinator-common.js +158 -0
  75. package/dist/services/service-host/coordinator-common.js.map +1 -0
  76. package/dist/services/service-host/handover-claims.d.ts +14 -0
  77. package/dist/services/service-host/handover-claims.d.ts.map +1 -0
  78. package/dist/services/service-host/handover-claims.js +50 -0
  79. package/dist/services/service-host/handover-claims.js.map +1 -0
  80. package/dist/services/service-host/index.d.ts +31 -0
  81. package/dist/services/service-host/index.d.ts.map +1 -0
  82. package/dist/services/service-host/index.js +33 -0
  83. package/dist/services/service-host/index.js.map +1 -0
  84. package/dist/services/service-host/install-identity.d.ts +99 -0
  85. package/dist/services/service-host/install-identity.d.ts.map +1 -0
  86. package/dist/services/service-host/install-identity.js +176 -0
  87. package/dist/services/service-host/install-identity.js.map +1 -0
  88. package/dist/services/service-host/locking/service-run-lock.d.ts +255 -0
  89. package/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -0
  90. package/dist/services/service-host/locking/service-run-lock.js +739 -0
  91. package/dist/services/service-host/locking/service-run-lock.js.map +1 -0
  92. package/dist/services/service-host/managed-run.d.ts +75 -0
  93. package/dist/services/service-host/managed-run.d.ts.map +1 -0
  94. package/dist/services/service-host/managed-run.js +550 -0
  95. package/dist/services/service-host/managed-run.js.map +1 -0
  96. package/dist/services/service-host/owner-projection.d.ts +47 -0
  97. package/dist/services/service-host/owner-projection.d.ts.map +1 -0
  98. package/dist/services/service-host/owner-projection.js +121 -0
  99. package/dist/services/service-host/owner-projection.js.map +1 -0
  100. package/dist/services/service-host/progress-evidence.d.ts +38 -0
  101. package/dist/services/service-host/progress-evidence.d.ts.map +1 -0
  102. package/dist/services/service-host/progress-evidence.js +155 -0
  103. package/dist/services/service-host/progress-evidence.js.map +1 -0
  104. package/dist/services/service-host/run-once.d.ts +96 -0
  105. package/dist/services/service-host/run-once.d.ts.map +1 -0
  106. package/dist/services/service-host/run-once.js +308 -0
  107. package/dist/services/service-host/run-once.js.map +1 -0
  108. package/dist/services/service-host/scheduler/contract.d.ts +184 -0
  109. package/dist/services/service-host/scheduler/contract.d.ts.map +1 -0
  110. package/dist/services/service-host/scheduler/contract.js +86 -0
  111. package/dist/services/service-host/scheduler/contract.js.map +1 -0
  112. package/dist/services/service-host/scheduler/index.d.ts +76 -0
  113. package/dist/services/service-host/scheduler/index.d.ts.map +1 -0
  114. package/dist/services/service-host/scheduler/index.js +128 -0
  115. package/dist/services/service-host/scheduler/index.js.map +1 -0
  116. package/dist/services/service-host/scheduler/linux.d.ts +27 -0
  117. package/dist/services/service-host/scheduler/linux.d.ts.map +1 -0
  118. package/dist/services/service-host/scheduler/linux.js +1010 -0
  119. package/dist/services/service-host/scheduler/linux.js.map +1 -0
  120. package/dist/services/service-host/scheduler/macos.d.ts +13 -0
  121. package/dist/services/service-host/scheduler/macos.d.ts.map +1 -0
  122. package/dist/services/service-host/scheduler/macos.js +819 -0
  123. package/dist/services/service-host/scheduler/macos.js.map +1 -0
  124. package/dist/services/service-host/scheduler/runtime-io.d.ts +13 -0
  125. package/dist/services/service-host/scheduler/runtime-io.d.ts.map +1 -0
  126. package/dist/services/service-host/scheduler/runtime-io.js +141 -0
  127. package/dist/services/service-host/scheduler/runtime-io.js.map +1 -0
  128. package/dist/services/service-host/scheduler/service-status.d.ts +99 -0
  129. package/dist/services/service-host/scheduler/service-status.d.ts.map +1 -0
  130. package/dist/services/service-host/scheduler/service-status.js +202 -0
  131. package/dist/services/service-host/scheduler/service-status.js.map +1 -0
  132. package/dist/services/service-host/scheduler/windows.d.ts +40 -0
  133. package/dist/services/service-host/scheduler/windows.d.ts.map +1 -0
  134. package/dist/services/service-host/scheduler/windows.js +688 -0
  135. package/dist/services/service-host/scheduler/windows.js.map +1 -0
  136. package/dist/services/service-host/shadow-progress-store.d.ts +43 -0
  137. package/dist/services/service-host/shadow-progress-store.d.ts.map +1 -0
  138. package/dist/services/service-host/shadow-progress-store.js +156 -0
  139. package/dist/services/service-host/shadow-progress-store.js.map +1 -0
  140. package/dist/services/service-host/shadow-run.d.ts +87 -0
  141. package/dist/services/service-host/shadow-run.d.ts.map +1 -0
  142. package/dist/services/service-host/shadow-run.js +549 -0
  143. package/dist/services/service-host/shadow-run.js.map +1 -0
  144. package/dist/services/service-host/status/service-run-status.d.ts +227 -0
  145. package/dist/services/service-host/status/service-run-status.d.ts.map +1 -0
  146. package/dist/services/service-host/status/service-run-status.js +187 -0
  147. package/dist/services/service-host/status/service-run-status.js.map +1 -0
  148. package/dist/services/service-host/worker-adapter-codex.d.ts +2 -0
  149. package/dist/services/service-host/worker-adapter-codex.d.ts.map +1 -0
  150. package/dist/services/service-host/worker-adapter-codex.js +76 -0
  151. package/dist/services/service-host/worker-adapter-codex.js.map +1 -0
  152. package/dist/services/service-host/worker-adapter-openclaw.d.ts +2 -0
  153. package/dist/services/service-host/worker-adapter-openclaw.d.ts.map +1 -0
  154. package/dist/services/service-host/worker-adapter-openclaw.js +49 -0
  155. package/dist/services/service-host/worker-adapter-openclaw.js.map +1 -0
  156. package/dist/services/service-host/worker-adapter-workbuddy.d.ts +2 -0
  157. package/dist/services/service-host/worker-adapter-workbuddy.d.ts.map +1 -0
  158. package/dist/services/service-host/worker-adapter-workbuddy.js +36 -0
  159. package/dist/services/service-host/worker-adapter-workbuddy.js.map +1 -0
  160. package/dist/services/service-host/worker-adapter.d.ts +187 -0
  161. package/dist/services/service-host/worker-adapter.d.ts.map +1 -0
  162. package/dist/services/service-host/worker-adapter.js +609 -0
  163. package/dist/services/service-host/worker-adapter.js.map +1 -0
  164. package/dist/services/service-host/worker-env.d.ts +84 -0
  165. package/dist/services/service-host/worker-env.d.ts.map +1 -0
  166. package/dist/services/service-host/worker-env.js +195 -0
  167. package/dist/services/service-host/worker-env.js.map +1 -0
  168. package/dist/services/service-host/worker-process.d.ts +75 -0
  169. package/dist/services/service-host/worker-process.d.ts.map +1 -0
  170. package/dist/services/service-host/worker-process.js +225 -0
  171. package/dist/services/service-host/worker-process.js.map +1 -0
  172. package/dist/services/service-host/workspace-discovery.d.ts +71 -0
  173. package/dist/services/service-host/workspace-discovery.d.ts.map +1 -0
  174. package/dist/services/service-host/workspace-discovery.js +288 -0
  175. package/dist/services/service-host/workspace-discovery.js.map +1 -0
  176. package/dist/services/service-host/workspace-dispatch.d.ts +61 -0
  177. package/dist/services/service-host/workspace-dispatch.d.ts.map +1 -0
  178. package/dist/services/service-host/workspace-dispatch.js +105 -0
  179. package/dist/services/service-host/workspace-dispatch.js.map +1 -0
  180. package/dist/services/service-host/workspace-handover.d.ts +190 -0
  181. package/dist/services/service-host/workspace-handover.d.ts.map +1 -0
  182. package/dist/services/service-host/workspace-handover.js +1393 -0
  183. package/dist/services/service-host/workspace-handover.js.map +1 -0
  184. package/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
  185. package/dist/services/synthetic-baseline-runner.js +4 -0
  186. package/dist/services/synthetic-baseline-runner.js.map +1 -1
  187. package/package.json +10 -9
@@ -0,0 +1,308 @@
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 { randomUUID } from 'node:crypto';
18
+ import { collectHostWorkspaceClaims, } from '@principles/install-layout';
19
+ import { resolveCoordinatorInstallIdentity, } from './install-identity.js';
20
+ import { discoverWorkspaces } from './workspace-discovery.js';
21
+ import { buildEmptyDiscovery, claimOptionsFor, defaultListDir, discoveryIncompleteRoots, hostRootReports, manifestSection, readManifest, } from './coordinator-common.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
+ /** The operator-facing next action for a completed dry-run. */
26
+ function completedNextAction(discovery, hostRoots, bindingDiagnostics) {
27
+ // A host root that exists but could not be listed is a finding of its
28
+ // own (P1-2/P2-1): workspaces under it were NOT silently absent — say
29
+ // so, for env-selected AND default roots alike.
30
+ const blocked = discoveryIncompleteRoots(hostRoots);
31
+ const rootNote = blocked.length > 0
32
+ ? ` 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.`
33
+ : '';
34
+ // A binding/declaration file that exists but cannot be read or parsed is
35
+ // degraded evidence (§9.1.8), not "no claim": say which file degraded.
36
+ const bindingNote = bindingDiagnostics.length > 0
37
+ ? ` 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.`
38
+ : '';
39
+ if (discovery.counts.authorized === 0 && discovery.discoveredTotal > 0) {
40
+ const countsSummary = Object.entries(discovery.counts)
41
+ .map(([verdict, count]) => `${verdict}=${count}`)
42
+ .join(' ');
43
+ return `No workspace is currently authorized (counts: ${countsSummary}); check the per-workspace reasons below.${rootNote}${bindingNote}`;
44
+ }
45
+ if (discovery.counts.conflicting > 0 || discovery.counts.invalid > 0) {
46
+ return `Fix the conflicting/invalid workspaces listed below before any future worker phase.${rootNote}${bindingNote}`;
47
+ }
48
+ if (rootNote !== '' || bindingNote !== '') {
49
+ return `Discovery dry-run complete.${rootNote}${bindingNote} Phase 1 starts no worker.`;
50
+ }
51
+ return 'Discovery dry-run complete. Phase 1 starts no worker; the next phase (PRI-1280) introduces bounded real cycles behind handover gates.';
52
+ }
53
+ /** Assemble the versioned status document. */
54
+ function buildStatus(args) {
55
+ return {
56
+ schemaVersion: 'pd.service-run-status.v1',
57
+ runId: args.runId,
58
+ outcome: args.outcome,
59
+ dryRun: true,
60
+ triggerSource: 'manual',
61
+ startedAt: args.startedAt.toISOString(),
62
+ completedAt: args.completedAt.toISOString(),
63
+ durationMs: Math.max(0, args.completedAt.getTime() - args.startedAt.getTime()),
64
+ installation: {
65
+ pdHome: args.identity.pdHome,
66
+ homeDir: args.identity.homeDir,
67
+ homeSource: args.identity.homeSource,
68
+ mode: args.identity.mode,
69
+ activeRelease: args.activeRelease,
70
+ },
71
+ environmentIsolation: {
72
+ pdExperimentRootStripped: args.identity.environment.experimentRootStripped,
73
+ ignoredIdentityEnvVars: args.identity.environment.ignoredIdentityEnvVars,
74
+ inheritedHostRootEnvVars: args.identity.environment.inheritedHostRootEnvVars,
75
+ },
76
+ manifest: args.manifest,
77
+ discovery: {
78
+ discoveredTotal: args.discovery.discoveredTotal,
79
+ counts: args.discovery.counts,
80
+ hostRoots: args.hostRoots,
81
+ // A host root that exists but could not be listed, or binding
82
+ // evidence that exists but could not be read (§9.1.8), makes
83
+ // discovery INCOMPLETE — the workspace list below may be missing
84
+ // entries, so "0 workspaces" is never the same fact as "discovery
85
+ // finished".
86
+ incomplete: discoveryIncompleteRoots(args.hostRoots).length > 0 || args.bindingDiagnostics.length > 0,
87
+ },
88
+ workspaces: args.discovery.workspaces,
89
+ nextAction: args.nextAction,
90
+ };
91
+ }
92
+ function completeRun(identity, context) {
93
+ const hostRoots = hostRootReports(identity, context.listDir);
94
+ /**
95
+ * Mid-run ownership check (P1-4): before EVERY protected status write the
96
+ * run must still hold the lock it acquired. If it was taken over, the run
97
+ * stops — a holder that lost its lock may never write operational state
98
+ * on behalf of the install it no longer owns.
99
+ */
100
+ const lockLost = () => ({
101
+ ok: false,
102
+ outcome: 'refused',
103
+ runId: context.runId,
104
+ reason: 'service_run_lock_lost',
105
+ nextAction: 'The install-level run lock was taken over mid-run, so the run stopped before writing status. ' +
106
+ 'Inspect the current holder and re-run; do not treat this run\'s discovery as authoritative.',
107
+ });
108
+ const persistRefusal = (args) => {
109
+ if (!context.holdsLock(context.handle))
110
+ return lockLost();
111
+ const status = buildStatus({
112
+ identity,
113
+ runId: context.runId,
114
+ startedAt: context.startedAt,
115
+ completedAt: new Date(),
116
+ outcome: 'refused',
117
+ activeRelease: args.activeRelease,
118
+ manifest: args.manifest ?? { verdict: 'ok', hosts: [], unknownHosts: [], workspacesCount: 0 },
119
+ discovery: args.discovery ?? buildEmptyDiscovery(),
120
+ hostRoots,
121
+ bindingDiagnostics: [],
122
+ nextAction: args.nextAction,
123
+ });
124
+ return {
125
+ ok: false,
126
+ outcome: 'refused',
127
+ runId: context.runId,
128
+ reason: args.reason,
129
+ nextAction: status.nextAction,
130
+ statusWrite: writeServiceRunStatus(identity.pdHome, status),
131
+ };
132
+ };
133
+ // ── 3. Active release — verified against the authoritative schema (P1-3).
134
+ // A record that parses but is not the installer's record is a REFUSAL,
135
+ // never a completed run over a fake install.
136
+ const activeRelease = readActiveReleaseFacts(identity.activeRecordPath);
137
+ // ── 4. Manifest: read failures are NEVER a zero-Workspace result ──
138
+ const manifestRead = readManifest(identity);
139
+ if (activeRelease.verdict !== 'ok') {
140
+ return persistRefusal({
141
+ reason: activeRelease.reason ?? 'active_release_invalid',
142
+ activeRelease,
143
+ manifest: manifestSection(manifestRead),
144
+ nextAction: activeRelease.verdict === 'missing'
145
+ ? 'Install or repair PD with npx create-principles-disciple — no active release record exists for this install.'
146
+ : 'Repair the install with the PD installer/updater; the active release record could not be verified against the authoritative schema.',
147
+ });
148
+ }
149
+ if (manifestRead.manifest === undefined) {
150
+ // Fail-closed: refuse the run (and persist a truthful status) — an
151
+ // unreadable or malformed manifest must not be reported as an empty install.
152
+ return persistRefusal({
153
+ reason: manifestRead.reason ?? 'install_manifest_invalid',
154
+ activeRelease,
155
+ manifest: manifestSection(manifestRead),
156
+ nextAction: manifestRead.verdict === 'missing'
157
+ ? 'Run npx create-principles-disciple to install PD (no manifest exists for this user-level install).'
158
+ : 'Repair the install manifest with the PD installer/updater before running the coordinator; the run refused instead of treating the install as empty.',
159
+ });
160
+ }
161
+ const manifest = manifestRead.manifest;
162
+ // ── 5. Validated per-host claims over ALL resolved host roots (P1-2).
163
+ // Custom roots (env overrides) reach the collector so workspaces under
164
+ // them are discoverable; they can never steer pdHome itself.
165
+ const readDiagnostics = [];
166
+ const claimOptions = claimOptionsFor(identity, readDiagnostics, context.claimReaders);
167
+ const claims = collectHostWorkspaceClaims(claimOptions);
168
+ // ── 6. Discovery + per-workspace owner projection ──
169
+ const discovery = discoverWorkspaces({ manifest, claims, claimOptions });
170
+ // ── 7. Persist status; lock release stays in the caller's finally ──
171
+ if (!context.holdsLock(context.handle))
172
+ return lockLost();
173
+ const status = buildStatus({
174
+ identity,
175
+ runId: context.runId,
176
+ startedAt: context.startedAt,
177
+ completedAt: new Date(),
178
+ outcome: 'completed',
179
+ activeRelease,
180
+ manifest: manifestSection(manifestRead),
181
+ discovery,
182
+ hostRoots,
183
+ bindingDiagnostics: readDiagnostics,
184
+ nextAction: completedNextAction(discovery, hostRoots, readDiagnostics),
185
+ });
186
+ const statusWrite = writeServiceRunStatus(identity.pdHome, status);
187
+ return {
188
+ ok: true,
189
+ outcome: 'completed',
190
+ runId: context.runId,
191
+ identity,
192
+ activeRelease,
193
+ manifest: status.manifest,
194
+ discovery,
195
+ statusWrite,
196
+ status,
197
+ };
198
+ }
199
+ /**
200
+ * Execute one bounded run-once (dry-run). Never throws for expected
201
+ * refusals — everything expected is a structured result; only a genuine bug
202
+ * escapes as an exception.
203
+ */
204
+ export function runServiceRunOnce(options = {}) {
205
+ const runId = randomUUID();
206
+ const startedAt = new Date();
207
+ const env = options.env ?? process.env;
208
+ // ── 1. Install identity (production-forced; env-derived homes refused) ──
209
+ const identityResult = resolveCoordinatorInstallIdentity(env, {
210
+ ...(options.trustedHomeDir !== undefined ? { trustedHomeDir: options.trustedHomeDir } : {}),
211
+ });
212
+ if (!identityResult.ok) {
213
+ return { ok: false, outcome: 'refused', runId, reason: identityResult.reason, nextAction: identityResult.nextAction };
214
+ }
215
+ const { identity } = identityResult;
216
+ // ── 2. Install-level single-instance lock ──
217
+ const lock = acquireServiceRunLock(identity.pdHome, {
218
+ probes: {
219
+ ...(options.probes?.processAlive !== undefined ? { processAlive: options.probes.processAlive } : {}),
220
+ },
221
+ });
222
+ if (!lock.ok) {
223
+ if (lock.kind === 'held') {
224
+ return {
225
+ ok: true,
226
+ outcome: 'already_running',
227
+ runId,
228
+ identity,
229
+ holderBodyHash: lock.holderBodyHash,
230
+ reason: 'service_run_lock_held',
231
+ nextAction: 'Another run-once coordinator holds the install-level lock. Wait for it to finish; do not start a second instance.',
232
+ };
233
+ }
234
+ const lockPathForMessage = serviceRunLockPath(identity.pdHome);
235
+ return {
236
+ ok: false,
237
+ outcome: 'refused',
238
+ runId,
239
+ reason: lock.kind === 'corrupt'
240
+ ? `service_run_lock_corrupt:${lock.detail}`
241
+ : `service_run_lock_unwritable:${lock.detail}`,
242
+ nextAction: lock.kind === 'corrupt'
243
+ ? [
244
+ 'Inspect the run lock by hand at',
245
+ lockPathForMessage,
246
+ '— a lock this old must stay verifiable before any coordinator may run.',
247
+ ].join(' ')
248
+ : 'Check the permissions of the PD service directory and retry.',
249
+ };
250
+ }
251
+ const handle = lock.handle;
252
+ const releaseLock = options.probes?.releaseLock ?? releaseServiceRunLock;
253
+ let result;
254
+ let runError;
255
+ let runThrew = false;
256
+ try {
257
+ result = completeRun(identity, {
258
+ runId,
259
+ startedAt,
260
+ staleTakenOver: lock.staleTakenOver,
261
+ handle,
262
+ env,
263
+ holdsLock: options.probes?.holdsLock ?? holdsServiceRunLock,
264
+ listDir: options.probes?.listDir ?? defaultListDir,
265
+ ...(options.probes?.claimReaders !== undefined ? { claimReaders: options.probes.claimReaders } : {}),
266
+ });
267
+ }
268
+ catch (error) {
269
+ runThrew = true;
270
+ runError = error;
271
+ result = { ok: false, outcome: 'refused', runId, reason: 'internal_error', nextAction: '' };
272
+ }
273
+ const release = releaseLock(handle);
274
+ const releaseFailed = release === 'failed_busy' || release === 'failed_unwritable';
275
+ if (runThrew) {
276
+ // §三.8: the PRIMARY error stays the thrown one; a release failure is
277
+ // recorded on the diagnostics channel, never swapped in as the error.
278
+ if (releaseFailed) {
279
+ console.error(`pd service run-once: lock release also failed (${release}) after the run error`);
280
+ }
281
+ throw runError;
282
+ }
283
+ if (releaseFailed) {
284
+ // §三.7: a genuinely failed release is never reported as an unremarkable
285
+ // `completed` — the release failure surfaces (exit code 1 through the
286
+ // refused path) while the persisted status keeps its truthful record.
287
+ if (result.outcome === 'completed') {
288
+ return {
289
+ ok: false,
290
+ outcome: 'refused',
291
+ runId,
292
+ reason: `service_run_lock_release_failed:${release === 'failed_busy' ? 'busy' : 'unwritable'}`,
293
+ nextAction: 'The dry-run finished but its run lock could not be released through the arbitration gate. ' +
294
+ 'The leftover lock carries a dead-holder PID once this process exits, so the next run recovers ' +
295
+ 'on PID evidence — inspect the service directory and the gate database before re-running.',
296
+ statusWrite: result.statusWrite,
297
+ };
298
+ }
299
+ // The run already ended refused: keep the primary reason, record the
300
+ // secondary release failure in nextAction (§三.8).
301
+ return {
302
+ ...result,
303
+ nextAction: `${result.nextAction} (Additionally, the run lock release failed: ${release}.)`,
304
+ };
305
+ }
306
+ return result;
307
+ }
308
+ //# 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,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,0BAA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,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,184 @@
1
+ /** Platforms with a real Phase 3 scheduler adapter. */
2
+ export type SchedulerPlatform = 'win32' | 'darwin' | 'linux';
3
+ /**
4
+ * Default trigger interval — aligned with the existing Codex / WorkBuddy CLI
5
+ * worker default cadence (120,000 ms). This is a DEFAULT, not a performance
6
+ * SLA; every trigger runs one bounded run-once (task §3.5).
7
+ */
8
+ export declare const DEFAULT_SCHEDULER_INTERVAL_MS = 120000;
9
+ /**
10
+ * Floor against meaningless high-frequency triggering (task §3.5). 60s: the
11
+ * Windows Task Scheduler repetition interval rejects anything below one
12
+ * minute (HRESULT 0x80041318, verified on a real host) — the contract keeps
13
+ * ONE cross-platform floor at the strictest platform minimum.
14
+ */
15
+ export declare const MIN_SCHEDULER_INTERVAL_MS = 60000;
16
+ export declare const MAX_SCHEDULER_INTERVAL_MS: number;
17
+ export type IntervalValidation = {
18
+ readonly ok: true;
19
+ readonly intervalMs: number;
20
+ } | {
21
+ readonly ok: false;
22
+ readonly reason: string;
23
+ readonly nextAction: string;
24
+ };
25
+ export declare function validateSchedulerIntervalMs(raw: number | undefined): IntervalValidation;
26
+ /** The full install-bound registration definition an adapter registers. */
27
+ export interface SchedulerRegistration {
28
+ /** Canonical, trusted PD home this registration belongs to (`<home>/.pd`). */
29
+ readonly pdHome: string;
30
+ /**
31
+ * The trusted HOME root (`dirname(pdHome)`): the value the registered
32
+ * command passes as `--pd-home` — the CLI treats that flag as the trusted
33
+ * home DIRECTORY and derives `<home>/.pd` itself, so passing pdHome here
34
+ * would resolve to `<home>/.pd/.pd`.
35
+ */
36
+ readonly homeDir: string;
37
+ /** Absolute installed CLI entry (active release), resolved by the coordinator. */
38
+ readonly cliEntry: string;
39
+ /** Absolute node executable that runs the entry. */
40
+ readonly nodePath: string;
41
+ readonly intervalMs: number;
42
+ /**
43
+ * True when the caller explicitly passed `--interval-ms` on install. An
44
+ * explicit interval wins over the OS-preserved one on refresh; an omitted
45
+ * interval keeps the registered cadence (task §15 refresh semantics).
46
+ */
47
+ readonly intervalExplicit?: boolean;
48
+ /** Derived platform names — see {@link schedulerIdentityFor}. */
49
+ readonly identity: SchedulerIdentity;
50
+ }
51
+ /** Platform-specific names derived 1:1 from the canonical pdHome. */
52
+ export interface SchedulerIdentity {
53
+ /** 10-hex stable key of the canonical pdHome (sha256 prefix). */
54
+ readonly installKey: string;
55
+ /** Windows Task Scheduler task name (root folder). */
56
+ readonly windowsTaskName: string;
57
+ /** macOS LaunchAgent label and plist base name. */
58
+ readonly macosLabel: string;
59
+ /** Linux systemd --user unit base name (without .service/.timer). */
60
+ readonly linuxUnitBase: string;
61
+ }
62
+ /**
63
+ * Derive the install-unique scheduler identity from a canonical pdHome.
64
+ * Windows path comparisons fold case so `D:\PD` and `d:\pd` cannot produce
65
+ * two registrations for one install (or collide two installs).
66
+ */
67
+ export declare function schedulerIdentityFor(pdHome: string): SchedulerIdentity;
68
+ /**
69
+ * The exact managed-run invocation arguments registered with the OS. Kept in
70
+ * ONE place so every platform registers the identical command line. NOTE:
71
+ * `--pd-home` carries the trusted HOME root (registration.homeDir), matching
72
+ * the CLI flag's semantics (the CLI derives `<home>/.pd` itself).
73
+ */
74
+ export declare function schedulerInvocationArgs(registration: SchedulerRegistration): readonly string[];
75
+ /** What the OS truthfully reports about the registration. */
76
+ export interface SchedulerFacts {
77
+ readonly platform: SchedulerPlatform;
78
+ readonly taskName: string;
79
+ /** A registration exists in the OS (any enabled state). null = unreadable. */
80
+ readonly registered: boolean | null;
81
+ /**
82
+ * Future automatic triggers will fire (the persistent arm bit: Task
83
+ * enabled / launchd not-disabled / timer is-enabled). null = unreadable —
84
+ * a failed query is NEVER reported as disabled or enabled (task §9).
85
+ */
86
+ readonly enabled: boolean | null;
87
+ /**
88
+ * The job is loaded/active in the OS right now (Task Running / launchd
89
+ * loaded / timer is-active). Independent of `enabled` — the two are
90
+ * separate witnesses and never inferred from each other (task §14).
91
+ * null = unreadable. Absent on platforms reporting no load state.
92
+ */
93
+ readonly active?: boolean | null;
94
+ /** Configured trigger interval in ms, read from the OS artifact when parseable. */
95
+ readonly triggerIntervalMs?: number | null;
96
+ /** OS-level last trigger time (ISO) when the platform reports one. */
97
+ readonly lastRunAt: string | null;
98
+ /** OS-level last run result (platform vocabulary, raw). */
99
+ readonly lastResult: string | null;
100
+ /**
101
+ * Every degraded/unreadable OS witness behind the verdicts above, each
102
+ * with its own bounded reason (query failures, unparsable output, bus
103
+ * unavailable). The status composer folds these into degradedReasons so
104
+ * an unreadable witness is never folded into a healthy-looking document
105
+ * (task §9/§13).
106
+ */
107
+ readonly degradedReasons?: readonly string[];
108
+ }
109
+ /** Structured operation result — success/failed/unavailable with reason + nextAction (rc-9). */
110
+ export type SchedulerOperationResult = {
111
+ readonly ok: true;
112
+ readonly changed: boolean;
113
+ readonly facts: SchedulerFacts;
114
+ } | {
115
+ readonly ok: false;
116
+ readonly kind: 'unavailable' | 'external_conflict' | 'command_failed' | 'unsafe_state';
117
+ readonly reason: string;
118
+ readonly nextAction: string;
119
+ /** Best-effort facts at failure time (never fabricated). */
120
+ readonly facts?: SchedulerFacts;
121
+ };
122
+ /** Injectable command boundary (tests fake it; production spawns real tools). */
123
+ export interface SchedulerCommandRunner {
124
+ /**
125
+ * Run one platform command. Never resolves with a thrown error — spawn
126
+ * failures surface as `{ code: null, spawnError }`. `extraEnv` merges into
127
+ * the child environment (used to pass file paths to PowerShell scripts
128
+ * without shell interpolation).
129
+ */
130
+ run(command: string, args: readonly string[], extraEnv?: Readonly<Record<string, string>>): Promise<SchedulerCommandResult>;
131
+ }
132
+ export interface SchedulerCommandResult {
133
+ readonly code: number | null;
134
+ readonly stdout: string;
135
+ readonly stderr: string;
136
+ readonly spawnError?: string;
137
+ readonly timedOut?: boolean;
138
+ readonly durationMs?: number;
139
+ }
140
+ /** Injectable file boundary for plist/unit read/write (tests fake it). */
141
+ export interface SchedulerFileIo {
142
+ readIfExists(file: string): {
143
+ ok: true;
144
+ content: string;
145
+ } | {
146
+ ok: false;
147
+ reason: 'missing' | 'unreadable';
148
+ detail?: string;
149
+ };
150
+ writeAtomic(file: string, content: string): {
151
+ ok: true;
152
+ } | {
153
+ ok: false;
154
+ reason: string;
155
+ };
156
+ remove(file: string): {
157
+ ok: true;
158
+ } | {
159
+ ok: false;
160
+ reason: string;
161
+ };
162
+ exists(file: string): boolean;
163
+ mkdirs(dir: string): {
164
+ ok: true;
165
+ } | {
166
+ ok: false;
167
+ reason: string;
168
+ };
169
+ }
170
+ /** The five lifecycle operations every platform adapter must provide. */
171
+ export interface SchedulerAdapter {
172
+ readonly platform: SchedulerPlatform;
173
+ /** Create the user-level registration (default disabled). Idempotent for our own registration. */
174
+ install(registration: SchedulerRegistration): Promise<SchedulerOperationResult>;
175
+ /** Enable future automatic triggers. Idempotent. */
176
+ enable(registration: SchedulerRegistration): Promise<SchedulerOperationResult>;
177
+ /** Stop future automatic triggers; keep the registration. Idempotent. */
178
+ disable(registration: SchedulerRegistration): Promise<SchedulerOperationResult>;
179
+ /** Read the OS-reported registration state. Read-only. */
180
+ status(registration: SchedulerRegistration): Promise<SchedulerOperationResult>;
181
+ /** Remove our registration. Never touches foreign registrations. Idempotent. */
182
+ uninstall(registration: SchedulerRegistration): Promise<SchedulerOperationResult>;
183
+ }
184
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/services/service-host/scheduler/contract.ts"],"names":[],"mappings":"AA6BA,uDAAuD;AACvD,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,SAAU,CAAC;AACrD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAChD,eAAO,MAAM,yBAAyB,QAAwB,CAAC;AAE/D,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,CAUvF;AAED,2EAA2E;AAC3E,MAAM,WAAW,qBAAqB;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,iEAAiE;IACj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* (PRI-1281).
4
+ *
5
+ * The Service Host's OS-level trigger is an INSTALL-LEVEL object: exactly one
6
+ * user-level scheduler registration per PD installation (NOT per workspace),
7
+ * bound to the trusted install identity resolved by the coordinator. The
8
+ * registration invokes the managed execution entry:
9
+ *
10
+ * <nodePath> <cliEntry> service run-once --json --trigger scheduler
11
+ * --pd-home <canonical pdHome>
12
+ *
13
+ * Platform implementations (Windows Task Scheduler / macOS LaunchAgent /
14
+ * Linux systemd --user) all expose the SAME five operations through this
15
+ * contract — the CLI never keeps three parallel lifecycle logic sets.
16
+ *
17
+ * Security invariants (SPEC §10, task §8):
18
+ * - runs as the current OS user only; no elevation, no system-level service;
19
+ * - no credential ever lands in the registration (arguments carry paths and
20
+ * flags only);
21
+ * - absolute install entry, no PATH / cwd dependence;
22
+ * - a registration whose definition does not reference THIS install's cli
23
+ * entry is FOREIGN — never overwritten or deleted (fail-closed);
24
+ * - the scheduler registration identity is derived from the canonical pdHome
25
+ * so two PD installations of the same user can never collide.
26
+ */
27
+ import * as crypto from 'node:crypto';
28
+ import * as path from 'node:path';
29
+ /**
30
+ * Default trigger interval — aligned with the existing Codex / WorkBuddy CLI
31
+ * worker default cadence (120,000 ms). This is a DEFAULT, not a performance
32
+ * SLA; every trigger runs one bounded run-once (task §3.5).
33
+ */
34
+ export const DEFAULT_SCHEDULER_INTERVAL_MS = 120_000;
35
+ /**
36
+ * Floor against meaningless high-frequency triggering (task §3.5). 60s: the
37
+ * Windows Task Scheduler repetition interval rejects anything below one
38
+ * minute (HRESULT 0x80041318, verified on a real host) — the contract keeps
39
+ * ONE cross-platform floor at the strictest platform minimum.
40
+ */
41
+ export const MIN_SCHEDULER_INTERVAL_MS = 60_000;
42
+ export const MAX_SCHEDULER_INTERVAL_MS = 30 * 24 * 60 * 60_000;
43
+ export function validateSchedulerIntervalMs(raw) {
44
+ if (raw === undefined)
45
+ return { ok: true, intervalMs: DEFAULT_SCHEDULER_INTERVAL_MS };
46
+ if (!Number.isSafeInteger(raw) || raw < MIN_SCHEDULER_INTERVAL_MS || raw > MAX_SCHEDULER_INTERVAL_MS) {
47
+ return {
48
+ ok: false,
49
+ reason: `scheduler_interval_out_of_range:${String(raw).slice(0, 40)}`,
50
+ nextAction: `--interval-ms must be an integer between ${MIN_SCHEDULER_INTERVAL_MS} (60s — the Windows Task Scheduler repetition floor) and ${MAX_SCHEDULER_INTERVAL_MS} (30 days). The default is ${DEFAULT_SCHEDULER_INTERVAL_MS} (120s, matching the existing CLI worker cadence).`,
51
+ };
52
+ }
53
+ return { ok: true, intervalMs: raw };
54
+ }
55
+ /**
56
+ * Derive the install-unique scheduler identity from a canonical pdHome.
57
+ * Windows path comparisons fold case so `D:\PD` and `d:\pd` cannot produce
58
+ * two registrations for one install (or collide two installs).
59
+ */
60
+ export function schedulerIdentityFor(pdHome) {
61
+ const normalized = process.platform === 'win32' ? path.resolve(pdHome).toLowerCase() : path.resolve(pdHome);
62
+ const installKey = crypto.createHash('sha256').update(normalized).digest('hex').slice(0, 10);
63
+ return {
64
+ installKey,
65
+ windowsTaskName: `PrinciplesDisciple-ServiceHost-${installKey}`,
66
+ macosLabel: `com.principles-disciple.service-host.${installKey}`,
67
+ linuxUnitBase: `pd-service-host-${installKey}`,
68
+ };
69
+ }
70
+ /**
71
+ * The exact managed-run invocation arguments registered with the OS. Kept in
72
+ * ONE place so every platform registers the identical command line. NOTE:
73
+ * `--pd-home` carries the trusted HOME root (registration.homeDir), matching
74
+ * the CLI flag's semantics (the CLI derives `<home>/.pd` itself).
75
+ */
76
+ export function schedulerInvocationArgs(registration) {
77
+ return [
78
+ registration.cliEntry,
79
+ 'service',
80
+ 'run-once',
81
+ '--json',
82
+ '--trigger', 'scheduler',
83
+ '--pd-home', registration.homeDir,
84
+ ];
85
+ }
86
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/services/service-host/scheduler/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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