@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,121 @@
1
+ /**
2
+ * Read-only owner projection (SPEC-PD-SERVICE-HOST-001 §8.4).
3
+ *
4
+ * Phase 1 NEVER writes: no owner marker, no generation increment, no CAS
5
+ * transition, no handover, no rollback, no consumer switch. The ONLY facts
6
+ * reported here come from the parsed install manifest's per-Workspace
7
+ * `backgroundExecutions` map, whose fail-closed parser (illegal state /
8
+ * owner / generation combinations are refused at parse time) already ran.
9
+ * A Workspace with no record is the legacy default (§8.4 contract 1);
10
+ * `effectiveOwner=legacy` is reported WITHOUT any claim that a legacy Worker
11
+ * could or should start — Phase 1 starts no Worker (§11 Phase 1 admission
12
+ * boundary).
13
+ */
14
+ import * as path from 'node:path';
15
+ const OWNER_RECORD_FIELDS = [
16
+ 'state',
17
+ 'effectiveOwner',
18
+ 'generation',
19
+ 'operationId',
20
+ 'previousOwner',
21
+ 'targetOwner',
22
+ 'updatedAt',
23
+ ];
24
+ function defaultLegacyProjection() {
25
+ return {
26
+ source: 'default_legacy',
27
+ state: 'legacy_owned',
28
+ effectiveOwner: 'legacy',
29
+ generation: 0,
30
+ operationId: null,
31
+ previousOwner: null,
32
+ targetOwner: null,
33
+ updatedAt: null,
34
+ };
35
+ }
36
+ function recordProjection(record) {
37
+ return {
38
+ source: 'record',
39
+ state: record.state,
40
+ effectiveOwner: record.effectiveOwner,
41
+ generation: record.generation,
42
+ operationId: record.operationId,
43
+ previousOwner: record.previousOwner,
44
+ targetOwner: record.targetOwner,
45
+ updatedAt: record.updatedAt,
46
+ };
47
+ }
48
+ /**
49
+ * Project ownership for ONE real Workspace that the manifest lists under
50
+ * possibly several path aliases (P1-6). `parseWorkspaceList` dedupes only
51
+ * lexically, so two `workspaces[]` entries (a symlink and its target, or two
52
+ * spellings that differ only in Windows case) can name the same real
53
+ * directory, and a `backgroundExecutions` record may be keyed under EITHER
54
+ * alias. Rules:
55
+ *
56
+ * - no record under any alias → `default_legacy` (the ONLY legacy path);
57
+ * - one record → that record;
58
+ * - several aliases all carrying semantically identical records → merged
59
+ * (they describe one fact);
60
+ * - two or more DISTINCT records (any of generation / effectiveOwner /
61
+ * state / operationId / previousOwner / targetOwner / updatedAt differs)
62
+ * → `conflicting` — an explicit invalid state, NEVER a silent pick of
63
+ * the first alias. `install.json` itself is never modified.
64
+ */
65
+ export function projectWorkspaceOwnerAliases(manifest, aliasDirs, platform = process.platform) {
66
+ const api = platform === 'win32' ? path.win32 : path.posix;
67
+ const seen = new Set();
68
+ const found = [];
69
+ for (const dir of aliasDirs) {
70
+ const key = api.resolve(dir);
71
+ if (seen.has(key))
72
+ continue;
73
+ seen.add(key);
74
+ const record = manifest.backgroundExecutions?.[key];
75
+ if (record !== undefined)
76
+ found.push({ alias: key, record });
77
+ }
78
+ if (found.length === 0)
79
+ return defaultLegacyProjection();
80
+ const [first, ...rest] = found;
81
+ const firstRecord = first?.record;
82
+ if (firstRecord === undefined)
83
+ return defaultLegacyProjection();
84
+ const differing = new Set();
85
+ for (const other of rest) {
86
+ for (const field of OWNER_RECORD_FIELDS) {
87
+ if (other.record[field] !== firstRecord[field])
88
+ differing.add(field);
89
+ }
90
+ }
91
+ if (differing.size === 0)
92
+ return recordProjection(firstRecord);
93
+ // A Workspace with two disagreeing owner records must surface as
94
+ // conflicting — picking either silently could hide a real service_host
95
+ // assignment behind a legacy alias.
96
+ const fields = [...differing].sort();
97
+ const aliases = found.map((entry) => entry.alias).join('|');
98
+ return {
99
+ source: 'conflicting',
100
+ state: 'owner_alias_conflict',
101
+ effectiveOwner: 'conflict',
102
+ generation: 0,
103
+ operationId: null,
104
+ previousOwner: null,
105
+ targetOwner: null,
106
+ updatedAt: null,
107
+ conflictDetail: `fields[${fields.join(',')}] aliases[${aliases.slice(0, 240)}]`,
108
+ };
109
+ }
110
+ /**
111
+ * Project the ownership facts for one Workspace by the SAME canonical rule
112
+ * the manifest parser uses (`api.resolve` with the manifest's platform
113
+ * rules). A Workspace absent from the map is the legacy default; a record
114
+ * present in the map is already semantically validated (illegal combinations
115
+ * never parse), so this projection is a plain field copy — no inference, no
116
+ * reinterpretation.
117
+ */
118
+ export function projectWorkspaceOwner(manifest, workspaceDir, platform = process.platform) {
119
+ return projectWorkspaceOwnerAliases(manifest, [workspaceDir], platform);
120
+ }
121
+ //# sourceMappingURL=owner-projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-projection.js","sourceRoot":"","sources":["../../../src/services/service-host/owner-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAsBlC,MAAM,mBAAmB,GAAG;IAC1B,OAAO;IACP,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,eAAe;IACf,aAAa;IACb,WAAW;CACoD,CAAC;AAElE,SAAS,uBAAuB;IAC9B,OAAO;QACL,MAAM,EAAE,gBAAgB;QACxB,KAAK,EAAE,cAAc;QACrB,cAAc,EAAE,QAAQ;QACxB,UAAU,EA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AAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAyB,EACzB,YAAoB,EACpB,QAAQ,GAAW,OAAO,CAAC,QAAQ;IAEnC,OAAO,4BAA4B,CAAC,QAAQ,EAAE,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,38 @@
1
+ export interface TaskProgressSnapshot {
2
+ /** taskId → status (the durable state machine position). */
3
+ readonly tasks: ReadonlyMap<string, string>;
4
+ /** taskId → updatedAt at snapshot time (per-task write timestamp). */
5
+ readonly taskUpdatedAt: ReadonlyMap<string, string>;
6
+ readonly maxUpdatedAt: string | null;
7
+ /** False when no state.db exists yet (empty task set, not an error). */
8
+ readonly storePresent: boolean;
9
+ }
10
+ export interface TaskProgressEvidence {
11
+ /** At least one new task or status transition between the two snapshots. */
12
+ readonly taskStateChanged: boolean;
13
+ readonly changedCount: number;
14
+ /** Max updatedAt among changed/new tasks — the progress timestamp, or null. */
15
+ readonly changedAt: string | null;
16
+ }
17
+ export type TaskProgressRead = {
18
+ readonly ok: true;
19
+ readonly snapshot: TaskProgressSnapshot;
20
+ } | {
21
+ readonly ok: false;
22
+ readonly reason: string;
23
+ };
24
+ export declare function readTaskProgressSnapshot(workspaceDir: string, options?: {
25
+ busyTimeoutMs?: number;
26
+ }): TaskProgressRead;
27
+ /**
28
+ * Diff two snapshots into progress evidence. A change is a NEW taskId or a
29
+ * STATUS transition; updatedAt-only movement (lease renewal) does not count.
30
+ *
31
+ * `changedAt` is the max `updatedAt` over the tasks that ACTUALLY changed —
32
+ * never the snapshot's global max: an unchanged task's lease renewal can hold
33
+ * a later updatedAt than the real transition, and the renewal is deliberately
34
+ * not progress (CodeRabbit review fix). When nothing changed it is null (a
35
+ * completed-but-empty cycle keeps the prior value at the status layer, §6).
36
+ */
37
+ export declare function diffTaskProgress(before: TaskProgressSnapshot, after: TaskProgressSnapshot): TaskProgressEvidence;
38
+ //# sourceMappingURL=progress-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-evidence.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/progress-evidence.ts"],"names":[],"mappings":"AAkCA,MAAM,WAAW,oBAAoB;IACnC,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,sEAAsE;IACtE,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,wEAAwE;IACxE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAA;CAAE,GAC9D;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAyCpD,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,gBAAgB,CAmDrH;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,CAmBhH"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * lastProgressAt evidence (task §6, FR-10 / AC-12, TD §7.2).
3
+ *
4
+ * `lastProgressAt` must reflect ACTUAL persisted business progress — never
5
+ * process start, PID liveness, worker "ready", or a bare cycle completion
6
+ * over an empty backlog. The primary evidence source is the Workspace's own
7
+ * task table in `.pd/state.db` (the single task authority, SPEC §9): the
8
+ * adapter snapshots (taskId → status) read-only BEFORE and AFTER the cycle,
9
+ * and progress is a NEW task or a STATUS transition. A pure `updatedAt`
10
+ * bump (lease renewal without a state change) is deliberately NOT progress.
11
+ *
12
+ * Read semantics (rc-9 + PRI-991 discipline):
13
+ * - a workspace with NO state.db yet is an EMPTY task set (`storePresent:
14
+ * false`), never an error — nothing is persisted, so nothing progressed;
15
+ * the file is never created by this reader;
16
+ * - an existing store is opened read-only (pure readonly first; a
17
+ * query_only recovery open as fallback for WAL/shm corner states);
18
+ * - a store that exists but cannot be read (corrupt, locked) is a
19
+ * STRUCTURED failure — the adapter degrades rather than guessing.
20
+ *
21
+ * Secondary (corroborating) evidence comes from the Worker cycle's own
22
+ * structured report (diagnostician succeeded, downstream ran, post-
23
+ * processing resumed, catch-up ingested) — extracted separately by each
24
+ * adapter because the two report shapes differ.
25
+ */
26
+ import * as fs from 'node:fs';
27
+ import * as path from 'node:path';
28
+ import Database from 'better-sqlite3';
29
+ /** Bounded snapshot: the most recently updated tasks are the diff surface. */
30
+ const SNAPSHOT_LIMIT = 500;
31
+ const TASK_SNAPSHOT_SQL = 'SELECT task_id AS taskId, status, updated_at AS updatedAt FROM tasks ORDER BY updated_at DESC LIMIT ?';
32
+ function isTaskRow(value) {
33
+ if (typeof value !== 'object' || value === null)
34
+ return false;
35
+ const row = value;
36
+ return typeof row.taskId === 'string'
37
+ && typeof row.status === 'string'
38
+ && typeof row.updatedAt === 'string';
39
+ }
40
+ /** Open the existing store for reading without creating or logically writing it. */
41
+ function openReadonly(dbPath, busyTimeoutMs) {
42
+ try {
43
+ return new Database(dbPath, { readonly: true, fileMustExist: true, timeout: busyTimeoutMs });
44
+ }
45
+ catch {
46
+ // WAL corner states (checkpointed clean, no -shm) can defeat a pure
47
+ // readonly open; a write-CAPABLE open performs the WAL/shm recovery with
48
+ // `query_only` pinning the logical database against any write.
49
+ const db = new Database(dbPath, { fileMustExist: true, timeout: busyTimeoutMs });
50
+ db.pragma('query_only = ON');
51
+ return db;
52
+ }
53
+ }
54
+ /**
55
+ * Read the (taskId → status) task snapshot. Side-effect free: a missing
56
+ * state.db is an empty snapshot; the reader never creates the store.
57
+ */
58
+ function emptySnapshot() {
59
+ return {
60
+ ok: true,
61
+ snapshot: { tasks: new Map(), taskUpdatedAt: new Map(), maxUpdatedAt: null, storePresent: false },
62
+ };
63
+ }
64
+ export function readTaskProgressSnapshot(workspaceDir, options) {
65
+ // P1-02 (final closure): the SQLite busy timeout is the CALLER's bounded
66
+ // budget — for the shadow adapter that is the remaining workspace
67
+ // deadline, never an independent fixed wait. A locked store then fails
68
+ // inside the deadline instead of the read silently overrunning it.
69
+ const busyTimeoutMs = Math.max(0, Math.floor(options?.busyTimeoutMs ?? 5_000));
70
+ const dbPath = path.join(path.resolve(workspaceDir), '.pd', 'state.db');
71
+ // P2-03 (final-remediation review): stat errors are CLASSIFIED — only a
72
+ // genuine ENOENT is the empty-task-set case; every other failure
73
+ // (EACCES/EPERM/EIO, a non-regular path, an unreadable parent) is
74
+ // evidence-unavailable, never a fabricated "empty store".
75
+ let stat;
76
+ try {
77
+ stat = fs.statSync(dbPath);
78
+ }
79
+ catch (error) {
80
+ const code = error.code ?? 'unknown';
81
+ if (code === 'ENOENT')
82
+ return emptySnapshot();
83
+ return { ok: false, reason: `progress_snapshot_stat_failed:${code}` };
84
+ }
85
+ if (!stat.isFile()) {
86
+ return { ok: false, reason: 'progress_snapshot_not_a_file' };
87
+ }
88
+ let db;
89
+ try {
90
+ db = openReadonly(dbPath, busyTimeoutMs);
91
+ }
92
+ catch (error) {
93
+ const message = error instanceof Error ? error.message : String(error);
94
+ return { ok: false, reason: `progress_snapshot_open_failed:${message.slice(0, 160)}` };
95
+ }
96
+ try {
97
+ const rows = db.prepare(TASK_SNAPSHOT_SQL).all(SNAPSHOT_LIMIT);
98
+ const tasks = new Map();
99
+ const taskUpdatedAt = new Map();
100
+ let maxUpdatedAt = null;
101
+ for (const row of rows) {
102
+ if (!isTaskRow(row))
103
+ continue;
104
+ tasks.set(row.taskId, row.status);
105
+ taskUpdatedAt.set(row.taskId, row.updatedAt);
106
+ if (maxUpdatedAt === null || row.updatedAt > maxUpdatedAt)
107
+ maxUpdatedAt = row.updatedAt;
108
+ }
109
+ return { ok: true, snapshot: { tasks, taskUpdatedAt, maxUpdatedAt, storePresent: true } };
110
+ }
111
+ catch (error) {
112
+ const message = error instanceof Error ? error.message : String(error);
113
+ return { ok: false, reason: `progress_snapshot_read_failed:${message.slice(0, 160)}` };
114
+ }
115
+ finally {
116
+ try {
117
+ db.close();
118
+ }
119
+ catch {
120
+ // best-effort close of our own reader
121
+ }
122
+ }
123
+ }
124
+ /**
125
+ * Diff two snapshots into progress evidence. A change is a NEW taskId or a
126
+ * STATUS transition; updatedAt-only movement (lease renewal) does not count.
127
+ *
128
+ * `changedAt` is the max `updatedAt` over the tasks that ACTUALLY changed —
129
+ * never the snapshot's global max: an unchanged task's lease renewal can hold
130
+ * a later updatedAt than the real transition, and the renewal is deliberately
131
+ * not progress (CodeRabbit review fix). When nothing changed it is null (a
132
+ * completed-but-empty cycle keeps the prior value at the status layer, §6).
133
+ */
134
+ export function diffTaskProgress(before, after) {
135
+ let changedCount = 0;
136
+ let changedAt = null;
137
+ for (const [taskId, status] of after.tasks) {
138
+ const previous = before.tasks.get(taskId);
139
+ if (previous === undefined || previous !== status) {
140
+ changedCount += 1;
141
+ const stamp = after.taskUpdatedAt.get(taskId);
142
+ if (stamp !== undefined && (changedAt === null || stamp > changedAt))
143
+ changedAt = stamp;
144
+ }
145
+ }
146
+ // A task REMOVED between snapshots (e.g. cleanup) is not business progress
147
+ // for this contract — only new/transitioned tasks count.
148
+ const taskStateChanged = changedCount > 0;
149
+ return {
150
+ taskStateChanged,
151
+ changedCount,
152
+ changedAt: taskStateChanged ? changedAt : null,
153
+ };
154
+ }
155
+ //# sourceMappingURL=progress-evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-evidence.js","sourceRoot":"","sources":["../../../src/services/service-host/progress-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,8EAA8E;AAC9E,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,iBAAiB,GACrB,uGAAuG,CAAC;AA8B1G,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,OAAO,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;WAChC,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;WAC9B,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ,CAAC;AACzC,CAAC;AAED,oFAAoF;AACpF,SAAS,YAAY,CAAC,MAAc,EAAE,aAAqB;IACzD,IAAI,CAAC;QACH,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;IAC/F,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;QACpE,yEAAyE;QACzE,+DAA+D;QAC/D,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;QACjF,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC7B,OAAO,EAAE,CA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+1,96 @@
1
+ import { type HostClaimReaders } from '@principles/install-layout';
2
+ import { type InstallIdentity } from './install-identity.js';
3
+ import { type WorkspaceDiscoveryResult } from './workspace-discovery.js';
4
+ import { type HolderLiveness, type ReleaseServiceRunLockResult, type ServiceRunLockHandle } from './locking/service-run-lock.js';
5
+ import { type ActiveReleaseFacts, type ServiceRunStatus } from './status/service-run-status.js';
6
+ export { SERVICE_RUN_STATUS_SCHEMA_VERSION, serviceRunStatusPath } from './status/service-run-status.js';
7
+ export interface RunOnceOptions {
8
+ /** Environment for identity resolution; defaults to process.env. Injected by tests. */
9
+ readonly env?: Readonly<Record<string, string | undefined>>;
10
+ /**
11
+ * A caller-pinned trusted home (absolute path) for identity resolution —
12
+ * same authority contract as `resolveCoordinatorInstallIdentity`. Never
13
+ * derived from env.
14
+ */
15
+ readonly trustedHomeDir?: string;
16
+ /** Injectable boundaries for tests; production uses the defaults. */
17
+ readonly probes?: {
18
+ /** Lock-holder liveness probe (default: `process.kill(pid, 0)`). */
19
+ readonly processAlive?: (pid: number) => HolderLiveness;
20
+ /**
21
+ * Mid-run lock ownership re-check (default: `holdsServiceRunLock`).
22
+ * Called before every protected status write.
23
+ */
24
+ readonly holdsLock?: (handle: ServiceRunLockHandle) => boolean;
25
+ /**
26
+ * Host-root listability probe (default: real `stat`+`readdir`, below).
27
+ * A path being a directory does NOT prove it is listable — EACCES,
28
+ * EPERM and EIO make a real directory unreadable, and an unreadable
29
+ * root must never be folded into "no workspaces found" (P2-1).
30
+ */
31
+ readonly listDir?: (dir: string) => 'readable' | 'missing' | 'not_directory' | 'unreadable';
32
+ /**
33
+ * Lock release (default: `releaseServiceRunLock`). The release outcome
34
+ * is part of the run's result: a genuinely failed release is NEVER
35
+ * reported as an unremarkable `completed` (§三).
36
+ */
37
+ readonly releaseLock?: (handle: ServiceRunLockHandle) => ReleaseServiceRunLockResult;
38
+ /**
39
+ * Claim readers for `collectHostWorkspaceClaims` (default: the real
40
+ * filesystem readers). Injected in tests so errno-specific binding
41
+ * evidence — including unreadable Codex plugins/data directories —
42
+ * reproduces deterministically on every platform (§五).
43
+ */
44
+ readonly claimReaders?: HostClaimReaders;
45
+ };
46
+ }
47
+ /** The three possible run results; every field is structured (rc-9). */
48
+ export type RunOnceResult = {
49
+ readonly ok: true;
50
+ readonly outcome: 'completed';
51
+ readonly runId: string;
52
+ readonly identity: InstallIdentity;
53
+ readonly activeRelease: ActiveReleaseFacts;
54
+ readonly manifest: ServiceRunStatus['manifest'];
55
+ readonly discovery: WorkspaceDiscoveryResult;
56
+ /** Persisted status file path, or the structured write failure (rc-9). */
57
+ readonly statusWrite: {
58
+ readonly ok: true;
59
+ readonly path: string;
60
+ } | {
61
+ readonly ok: false;
62
+ readonly reason: string;
63
+ readonly nextAction: string;
64
+ };
65
+ readonly status: ServiceRunStatus;
66
+ } | {
67
+ readonly ok: true;
68
+ readonly outcome: 'already_running';
69
+ readonly runId: string;
70
+ readonly identity: InstallIdentity;
71
+ readonly holderBodyHash: string;
72
+ readonly reason: string;
73
+ readonly nextAction: string;
74
+ } | {
75
+ readonly ok: false;
76
+ readonly outcome: 'refused';
77
+ readonly runId: string;
78
+ readonly reason: string;
79
+ readonly nextAction: string;
80
+ /** Present when the truthful refusal status could NOT be persisted (rc-9). */
81
+ readonly statusWrite?: {
82
+ readonly ok: true;
83
+ readonly path: string;
84
+ } | {
85
+ readonly ok: false;
86
+ readonly reason: string;
87
+ readonly nextAction: string;
88
+ };
89
+ };
90
+ /**
91
+ * Execute one bounded run-once (dry-run). Never throws for expected
92
+ * refusals — everything expected is a structured result; only a genuine bug
93
+ * escapes as an exception.
94
+ */
95
+ export declare function runServiceRunOnce(options?: RunOnceOptions): RunOnceResult;
96
+ //# sourceMappingURL=run-once.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-once.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/run-once.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,4BA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