wicked-crew 0.7.27 → 0.7.29

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 (135) hide show
  1. package/README.md +9 -1
  2. package/dist/api/chat-scope.d.ts +210 -0
  3. package/dist/api/chat-scope.d.ts.map +1 -0
  4. package/dist/api/chat-scope.js +724 -0
  5. package/dist/api/chat-scope.js.map +1 -0
  6. package/dist/api/diagnostics.d.ts +30 -2
  7. package/dist/api/diagnostics.d.ts.map +1 -1
  8. package/dist/api/diagnostics.js +73 -5
  9. package/dist/api/diagnostics.js.map +1 -1
  10. package/dist/api/governance-health.d.ts +163 -0
  11. package/dist/api/governance-health.d.ts.map +1 -0
  12. package/dist/api/governance-health.js +348 -0
  13. package/dist/api/governance-health.js.map +1 -0
  14. package/dist/api/open-path.d.ts.map +1 -1
  15. package/dist/api/open-path.js +2 -1
  16. package/dist/api/open-path.js.map +1 -1
  17. package/dist/api/post-hoc-deliver.d.ts +9 -5
  18. package/dist/api/post-hoc-deliver.d.ts.map +1 -1
  19. package/dist/api/post-hoc-deliver.js +21 -7
  20. package/dist/api/post-hoc-deliver.js.map +1 -1
  21. package/dist/api/routes.d.ts +56 -12
  22. package/dist/api/routes.d.ts.map +1 -1
  23. package/dist/api/routes.js +318 -50
  24. package/dist/api/routes.js.map +1 -1
  25. package/dist/api/seat-health.d.ts.map +1 -1
  26. package/dist/api/seat-health.js +25 -5
  27. package/dist/api/seat-health.js.map +1 -1
  28. package/dist/api/seat-signin.d.ts.map +1 -1
  29. package/dist/api/seat-signin.js +49 -23
  30. package/dist/api/seat-signin.js.map +1 -1
  31. package/dist/api/server.d.ts +13 -0
  32. package/dist/api/server.d.ts.map +1 -1
  33. package/dist/api/server.js +34 -0
  34. package/dist/api/server.js.map +1 -1
  35. package/dist/campaigns/routes.d.ts +4 -4
  36. package/dist/cli/governance.d.ts +131 -0
  37. package/dist/cli/governance.d.ts.map +1 -0
  38. package/dist/cli/governance.js +354 -0
  39. package/dist/cli/governance.js.map +1 -0
  40. package/dist/cli/index.js +114 -19
  41. package/dist/cli/index.js.map +1 -1
  42. package/dist/core/adapter.d.ts +89 -1
  43. package/dist/core/adapter.d.ts.map +1 -1
  44. package/dist/core/adapter.js +145 -25
  45. package/dist/core/adapter.js.map +1 -1
  46. package/dist/core/bridge-reaper.d.ts.map +1 -1
  47. package/dist/core/bridge-reaper.js +4 -1
  48. package/dist/core/bridge-reaper.js.map +1 -1
  49. package/dist/core/deliver-text.d.ts +184 -0
  50. package/dist/core/deliver-text.d.ts.map +1 -0
  51. package/dist/core/deliver-text.js +434 -0
  52. package/dist/core/deliver-text.js.map +1 -0
  53. package/dist/core/deliver-triage.d.ts +90 -0
  54. package/dist/core/deliver-triage.d.ts.map +1 -0
  55. package/dist/core/deliver-triage.js +106 -0
  56. package/dist/core/deliver-triage.js.map +1 -0
  57. package/dist/core/deliver.d.ts +129 -19
  58. package/dist/core/deliver.d.ts.map +1 -1
  59. package/dist/core/deliver.js +271 -57
  60. package/dist/core/deliver.js.map +1 -1
  61. package/dist/core/deliverable-floor.d.ts.map +1 -1
  62. package/dist/core/deliverable-floor.js +5 -4
  63. package/dist/core/deliverable-floor.js.map +1 -1
  64. package/dist/core/estate-mcp-client.d.ts.map +1 -1
  65. package/dist/core/estate-mcp-client.js +7 -2
  66. package/dist/core/estate-mcp-client.js.map +1 -1
  67. package/dist/core/exec.d.ts.map +1 -1
  68. package/dist/core/exec.js +11 -1
  69. package/dist/core/exec.js.map +1 -1
  70. package/dist/core/governance-store.d.ts +197 -0
  71. package/dist/core/governance-store.d.ts.map +1 -0
  72. package/dist/core/governance-store.js +283 -0
  73. package/dist/core/governance-store.js.map +1 -0
  74. package/dist/core/repoPaths.d.ts +36 -5
  75. package/dist/core/repoPaths.d.ts.map +1 -1
  76. package/dist/core/repoPaths.js +46 -4
  77. package/dist/core/repoPaths.js.map +1 -1
  78. package/dist/interactive/bridge-pool.d.ts +130 -2
  79. package/dist/interactive/bridge-pool.d.ts.map +1 -1
  80. package/dist/interactive/bridge-pool.js +286 -8
  81. package/dist/interactive/bridge-pool.js.map +1 -1
  82. package/dist/interactive/bus-location.d.ts +65 -0
  83. package/dist/interactive/bus-location.d.ts.map +1 -0
  84. package/dist/interactive/bus-location.js +75 -0
  85. package/dist/interactive/bus-location.js.map +1 -0
  86. package/dist/interactive/chat-events.d.ts.map +1 -1
  87. package/dist/interactive/chat-events.js +29 -23
  88. package/dist/interactive/chat-events.js.map +1 -1
  89. package/dist/interactive/demo-events.d.ts +16 -1
  90. package/dist/interactive/demo-events.d.ts.map +1 -1
  91. package/dist/interactive/demo-events.js +262 -43
  92. package/dist/interactive/demo-events.js.map +1 -1
  93. package/dist/interactive/doc-grounding.d.ts +202 -0
  94. package/dist/interactive/doc-grounding.d.ts.map +1 -0
  95. package/dist/interactive/doc-grounding.js +647 -0
  96. package/dist/interactive/doc-grounding.js.map +1 -0
  97. package/dist/interactive/draft-events.d.ts +54 -1
  98. package/dist/interactive/draft-events.d.ts.map +1 -1
  99. package/dist/interactive/draft-events.js +234 -117
  100. package/dist/interactive/draft-events.js.map +1 -1
  101. package/dist/interactive/edit-events.d.ts.map +1 -1
  102. package/dist/interactive/edit-events.js +27 -21
  103. package/dist/interactive/edit-events.js.map +1 -1
  104. package/dist/interactive/proxy-routes.d.ts +78 -0
  105. package/dist/interactive/proxy-routes.d.ts.map +1 -1
  106. package/dist/interactive/proxy-routes.js +355 -14
  107. package/dist/interactive/proxy-routes.js.map +1 -1
  108. package/dist/interactive/repo-snapshot.d.ts +31 -0
  109. package/dist/interactive/repo-snapshot.d.ts.map +1 -1
  110. package/dist/interactive/repo-snapshot.js +56 -1
  111. package/dist/interactive/repo-snapshot.js.map +1 -1
  112. package/dist/projects/graph-paths.d.ts +4 -2
  113. package/dist/projects/graph-paths.d.ts.map +1 -1
  114. package/dist/projects/graph-paths.js +4 -2
  115. package/dist/projects/graph-paths.js.map +1 -1
  116. package/dist/projects/graph.d.ts +5 -4
  117. package/dist/projects/graph.d.ts.map +1 -1
  118. package/dist/projects/graph.js +22 -5
  119. package/dist/projects/graph.js.map +1 -1
  120. package/dist/projects/routes.d.ts.map +1 -1
  121. package/dist/projects/routes.js +18 -9
  122. package/dist/projects/routes.js.map +1 -1
  123. package/dist/qe/conformance.d.ts +10 -1
  124. package/dist/qe/conformance.d.ts.map +1 -1
  125. package/dist/qe/conformance.js +57 -4
  126. package/dist/qe/conformance.js.map +1 -1
  127. package/dist/skills/plugin-source.d.ts.map +1 -1
  128. package/dist/skills/plugin-source.js +3 -0
  129. package/dist/skills/plugin-source.js.map +1 -1
  130. package/dist/studio/assets/index-CeJTutxP.js +540 -0
  131. package/dist/studio/index.html +1 -1
  132. package/dist/studio/testid-inventory.json +333 -7
  133. package/endpoint-manifest.json +75 -12
  134. package/package.json +3 -3
  135. package/dist/studio/assets/index-FcZg3WDR.js +0 -539
@@ -0,0 +1,348 @@
1
+ /**
2
+ * `GET /diagnostics` → `governance`: is the engine's governance evidence actually LANDING?
3
+ * (crew#495, acceptance finding F-022.)
4
+ *
5
+ * The engine's emit seam either writes an event onto the shared store (`WICKED_ESTATE_DB`) or
6
+ * spools it to the dead-letter outbox (`WICKED_APPS_EMIT_DEADLETTER`) with a loud stderr line
7
+ * nobody reads. Until this module existed, neither outcome reached `/diagnostics`, so a daemon
8
+ * that had dead-lettered every governance event for a week reported `recentErrors: []` while the
9
+ * home board said "Governed 100%". This is the daemon's read-only answer, assembled from records
10
+ * it already owns, under the surface's honesty rule: a number it cannot derive is `null`, never 0.
11
+ *
12
+ * - `store` — the resolved store and which rule chose it (`core/governance-store.ts`);
13
+ * `null` when this process never resolved one (a library boot) — then every emit
14
+ * dead-letters, and a `governance.store` finding says so.
15
+ * - `records` — EVENT nodes on the store now, and how many landed since this daemon booted.
16
+ * Counted through the engine binding (`Core.eventStoreCount`, wicked-core-ts ≥ the
17
+ * release carrying crew#495's companion); on an older addon both are `null`.
18
+ * - `deadletters` — a streamed fold of the outbox: count, per-type and per-reason buckets, the
19
+ * timestamp range where entries carry the engine's `ts` (older engines wrote none —
20
+ * those are counted as `untimestamped`, never given an invented time), plus the
21
+ * legacy HOME outbox a pre-fix engine wrote, if one exists.
22
+ * - `findings` — `governance.deadletter` (error) whenever the outbox holds an entry;
23
+ * `governance.store` (error) when no store is resolved; `governance.legacy-outbox`
24
+ * (warning) when the pre-fix HOME outbox exists. Each names the replay command.
25
+ */
26
+ import { createReadStream } from 'node:fs';
27
+ import { promises as fsp } from 'node:fs';
28
+ import { createInterface } from 'node:readline';
29
+ import { governanceSidecarDb } from '../core/governance-store.js';
30
+ // ── The dead-letter fold ─────────────────────────────────────────────────────
31
+ /** Bounds on the fold's work: it runs inside a request handler, and a runaway outbox (227 MB of
32
+ * test junk was once observed under HOME) must not turn a diagnostics GET into a file crawl. Past
33
+ * the byte cap the fold stops and says so (`truncated`) — the count is then a floor, honestly
34
+ * labelled, never a guess at the rest. */
35
+ export const DEADLETTER_FOLD_MAX_BYTES = 256 * 1024 * 1024;
36
+ const DEADLETTER_FOLD_MAX_LINE_BYTES = 1024 * 1024;
37
+ /** Distinct event types are few (a dozen `wicked.*` names); anything past this many keys folds into `other`. */
38
+ const MAX_TYPE_KEYS = 64;
39
+ export function emptyDeadletterFold(path) {
40
+ return {
41
+ path,
42
+ count: 0,
43
+ byType: {},
44
+ byReason: {},
45
+ timestamped: 0,
46
+ untimestamped: 0,
47
+ oldestTs: null,
48
+ newestTs: null,
49
+ truncated: false,
50
+ };
51
+ }
52
+ /** The bucket a reason folds into: its text before the first `:` — the engine's three shapes are
53
+ * `no shared store (…)`, `open shared store failed: <path + error>` and `store write failed:
54
+ * <error>`, and only the prefix is stable across entries. */
55
+ export function reasonBucket(reason) {
56
+ const idx = reason.indexOf(':');
57
+ return (idx >= 0 ? reason.slice(0, idx) : reason).trim();
58
+ }
59
+ /** ECMAScript `Date`'s valid range: ±8.64e15 ms around the epoch (`toISOString` THROWS outside it). */
60
+ const MAX_EPOCH_MS = 8.64e15;
61
+ /** A usable `ts`: a finite, non-negative epoch-millisecond number inside `Date`'s range. Anything
62
+ * else on a spool line (a torn `1e20`, a negative, a string) is counted as untimestamped — never
63
+ * a `RangeError` that turns `/diagnostics` into a 500. */
64
+ export function isEpochMs(value) {
65
+ return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= MAX_EPOCH_MS;
66
+ }
67
+ /** Buckets are `Map`s while folding — the keys come from file content, and a plain object keyed by
68
+ * `constructor`, `toString` or `__proto__` (a torn or hostile line) would either inherit a value or
69
+ * drop the bucket. Serialized to a plain object once, at the end. */
70
+ function bump(counts, key, cap) {
71
+ const k = counts.has(key) || counts.size < cap ? key : 'other';
72
+ counts.set(k, (counts.get(k) ?? 0) + 1);
73
+ }
74
+ /**
75
+ * Stream-fold one outbox file. A missing file is an EMPTY fold (no dead letters — the good case),
76
+ * an unreadable one folds what it could; a malformed line still COUNTS (it is an entry the engine
77
+ * appended; a torn tail from a crashed daemon is exactly what a replay must not lose sight of) but
78
+ * contributes no type or timestamp.
79
+ */
80
+ export async function foldDeadletters(path) {
81
+ const fold = emptyDeadletterFold(path);
82
+ let size;
83
+ try {
84
+ size = (await fsp.stat(path)).size;
85
+ }
86
+ catch {
87
+ return fold; // no outbox — nothing dead-lettered, honestly empty
88
+ }
89
+ if (size === 0)
90
+ return fold;
91
+ const end = Math.min(size, DEADLETTER_FOLD_MAX_BYTES) - 1;
92
+ fold.truncated = size > DEADLETTER_FOLD_MAX_BYTES;
93
+ let stream;
94
+ let rl;
95
+ try {
96
+ stream = createReadStream(path, { encoding: 'utf8', end });
97
+ rl = createInterface({ input: stream, crlfDelay: Infinity });
98
+ }
99
+ catch {
100
+ return fold;
101
+ }
102
+ const byType = new Map();
103
+ const byReason = new Map();
104
+ try {
105
+ for await (const line of rl) {
106
+ if (line.trim() === '')
107
+ continue;
108
+ fold.count += 1;
109
+ if (line.length > DEADLETTER_FOLD_MAX_LINE_BYTES) {
110
+ fold.untimestamped += 1;
111
+ continue;
112
+ }
113
+ let record;
114
+ try {
115
+ record = JSON.parse(line);
116
+ }
117
+ catch {
118
+ fold.untimestamped += 1;
119
+ continue;
120
+ }
121
+ bump(byType, typeof record.type === 'string' ? record.type : 'unknown', MAX_TYPE_KEYS);
122
+ bump(byReason, typeof record.deadletter_reason === 'string' ? reasonBucket(record.deadletter_reason) : 'unknown', MAX_TYPE_KEYS);
123
+ if (isEpochMs(record.ts)) {
124
+ fold.timestamped += 1;
125
+ if (fold.oldestTs === null || record.ts < fold.oldestTs)
126
+ fold.oldestTs = record.ts;
127
+ if (fold.newestTs === null || record.ts > fold.newestTs)
128
+ fold.newestTs = record.ts;
129
+ }
130
+ else {
131
+ fold.untimestamped += 1;
132
+ }
133
+ }
134
+ }
135
+ catch {
136
+ /* a read error mid-stream: keep what folded so far */
137
+ }
138
+ finally {
139
+ rl.close();
140
+ stream.destroy();
141
+ }
142
+ fold.byType = Object.fromEntries(byType);
143
+ fold.byReason = Object.fromEntries(byReason);
144
+ return fold;
145
+ }
146
+ /**
147
+ * The fold, re-run only when the outbox CHANGES (size or mtime) — one `stat` per request, never a
148
+ * re-read for a dashboard that polls, and never a stale answer once the engine appends.
149
+ */
150
+ export class DeadletterFoldCache {
151
+ value = null;
152
+ inFlight = null;
153
+ async get(path) {
154
+ let key;
155
+ try {
156
+ const st = await fsp.stat(path);
157
+ key = `${st.size}:${st.mtimeMs}`;
158
+ }
159
+ catch {
160
+ key = 'absent';
161
+ }
162
+ if (this.value !== null && this.value.key === key)
163
+ return this.value.fold;
164
+ if (this.inFlight !== null)
165
+ return this.inFlight;
166
+ this.inFlight = foldDeadletters(path)
167
+ .then((fold) => {
168
+ this.value = { key, fold };
169
+ return fold;
170
+ })
171
+ .finally(() => {
172
+ this.inFlight = null;
173
+ });
174
+ return this.inFlight;
175
+ }
176
+ }
177
+ /**
178
+ * Baseline-at-boot plus a short-TTL live count. `sinceBoot` is `total − baseline`; either side
179
+ * unknown (no binding, or a read that failed) folds to `null` rather than a fabricated delta.
180
+ */
181
+ export class GovernanceRecordCounter {
182
+ dbPath;
183
+ counter;
184
+ ttlMs;
185
+ baseline = null;
186
+ live = null;
187
+ inFlight = null;
188
+ baselinePromise;
189
+ constructor(dbPath, counter, ttlMs = 15_000) {
190
+ this.dbPath = dbPath;
191
+ this.counter = counter;
192
+ this.ttlMs = ttlMs;
193
+ this.baselinePromise = this.read().then((n) => {
194
+ this.baseline = n;
195
+ });
196
+ }
197
+ /** Test seam: the boot baseline has been taken. */
198
+ ready() {
199
+ return this.baselinePromise;
200
+ }
201
+ async read() {
202
+ if (this.dbPath === null || this.counter === null)
203
+ return null;
204
+ try {
205
+ return await this.counter(this.dbPath);
206
+ }
207
+ catch {
208
+ return null;
209
+ }
210
+ }
211
+ async total() {
212
+ const now = Date.now();
213
+ if (this.live !== null && now - this.live.at < this.ttlMs)
214
+ return this.live.total;
215
+ if (this.inFlight !== null)
216
+ return this.inFlight;
217
+ this.inFlight = this.read()
218
+ .then((total) => {
219
+ this.live = { at: Date.now(), total };
220
+ return total;
221
+ })
222
+ .finally(() => {
223
+ this.inFlight = null;
224
+ });
225
+ return this.inFlight;
226
+ }
227
+ async records() {
228
+ await this.baselinePromise;
229
+ const total = await this.total();
230
+ const sinceBoot = total !== null && this.baseline !== null ? Math.max(0, total - this.baseline) : null;
231
+ return { total, sinceBoot };
232
+ }
233
+ }
234
+ // ── Assembly ─────────────────────────────────────────────────────────────────
235
+ /** Quote one argument for the operator's shell: bare when it needs no quoting, otherwise
236
+ * single-quoted on POSIX and double-quoted on Windows (JSON quoting is not shell quoting there). */
237
+ export function shellQuote(arg) {
238
+ if (/^[A-Za-z0-9_./:@%+=,-]+$/.test(arg))
239
+ return arg; // `<` `>` are redirections — never bare
240
+ return process.platform === 'win32' ? `"${arg.replace(/"/g, '\\"')}"` : `'${arg.replace(/'/g, `'\\''`)}'`;
241
+ }
242
+ /**
243
+ * The replay recipe every finding points at — one spelling, so the console and the log agree — and
244
+ * TARGET-SPECIFIC: a bare recipe followed on a daemon booted with a custom `--db` or
245
+ * `--governance-db` would replay into a different store than the one that dead-lettered. The target
246
+ * is ALWAYS an explicit, DURABLE `--governance-db`: the flag outranks the env rungs of
247
+ * `replayTarget()`'s ladder (a `WICKED_CREW_GOVERNANCE_DB` / `WICKED_ESTATE_DB` exported in the
248
+ * operator's shell would otherwise win over `--db`), and a `:memory:` daemon's dead letters are
249
+ * pointed at its durable sidecar store rather than at a target a real replay refuses. `null` target
250
+ * = no daemon store known: the bare recipe, for a `--dry-run` inspection.
251
+ */
252
+ export function replayCommand(outboxPath, target) {
253
+ const base = `wicked-crew governance replay ${shellQuote(outboxPath)}`;
254
+ if (target === null)
255
+ return base;
256
+ const durable = target.dbPath === ':memory:' ? governanceSidecarDb(target.coreDbPath) : target.displayPath;
257
+ return `${base} --governance-db ${shellQuote(durable)}`;
258
+ }
259
+ export function governanceHealth(input) {
260
+ const findings = [];
261
+ // `displayPath`, never `dbPath`: a URL spec's credentials are for the engine, not the wire.
262
+ const store = input.location !== null ? { path: input.location.displayPath, source: input.location.source } : null;
263
+ if (store === null) {
264
+ findings.push({
265
+ kind: 'governance.store',
266
+ severity: 'error',
267
+ message: 'this daemon resolved no governance store — WICKED_ESTATE_DB is not exported to the engine, so every ' +
268
+ 'governance event (conformance claims, phase transitions, rule lifecycle) dead-letters instead of landing; ' +
269
+ 'boot through `wicked-crew serve` (which resolves <core db>.governance/governance.db) or pass --governance-db; ' +
270
+ `inspect any outbox meanwhile with ${replayCommand('<outbox.ndjson>', null)} --dry-run`,
271
+ });
272
+ }
273
+ if (input.fold.count > 0) {
274
+ const path = input.fold.path ?? '(unknown outbox)';
275
+ const newest = input.fold.newestTs !== null ? `, newest ${new Date(input.fold.newestTs).toISOString()}` : '';
276
+ const floor = input.fold.truncated ? ' (at least — the fold stopped at its size cap)' : '';
277
+ findings.push({
278
+ kind: 'governance.deadletter',
279
+ severity: 'error',
280
+ message: `${input.fold.count} governance event(s) dead-lettered to ${path}${floor}${newest} — the store refused or was ` +
281
+ `unset when they were emitted (${Object.keys(input.fold.byReason).join('; ') || 'reason unknown'}); ` +
282
+ `replay them with ${replayCommand(path, input.location)}`,
283
+ });
284
+ }
285
+ if (input.legacyOutbox !== null) {
286
+ const recipe = replayCommand(input.legacyOutbox.path, input.location);
287
+ findings.push({
288
+ kind: 'governance.legacy-outbox',
289
+ severity: 'warning',
290
+ message: `a pre-fix dead-letter outbox exists under HOME at ${input.legacyOutbox.path} (${input.legacyOutbox.bytes} bytes) — ` +
291
+ `events every earlier daemon on this host spooled there instead of storing; inspect it with ` +
292
+ `${recipe} --dry-run, then ` +
293
+ (input.location !== null
294
+ ? `replay it into this daemon's store with ${recipe}`
295
+ : 'replay it once this daemon resolves a store') +
296
+ ' (a replay appends the lines that fail to land back onto that same file, so this warning persists until they are repaired)',
297
+ });
298
+ }
299
+ return {
300
+ store,
301
+ records: input.records,
302
+ deadletters: { ...input.fold, legacyOutbox: input.legacyOutbox },
303
+ findings,
304
+ };
305
+ }
306
+ /** `{ path, bytes }` when the legacy HOME outbox exists and is non-empty (a `stat`, never a read), else `null`. */
307
+ export async function probeLegacyOutbox(path) {
308
+ if (path === null)
309
+ return null;
310
+ try {
311
+ const st = await fsp.stat(path);
312
+ return st.isFile() && st.size > 0 ? { path, bytes: st.size } : null;
313
+ }
314
+ catch {
315
+ return null;
316
+ }
317
+ }
318
+ /**
319
+ * The per-daemon diagnostics assembly the route calls: one fold cache, one record counter, one
320
+ * legacy probe. `legacyOutboxPath` is injectable so a test never has to `stat` the developer's real
321
+ * HOME to reason about the block.
322
+ */
323
+ export class GovernanceDiagnostics {
324
+ location;
325
+ legacyOutboxPath;
326
+ folds = new DeadletterFoldCache();
327
+ counter;
328
+ constructor(location, eventCounter, legacyOutboxPath) {
329
+ this.location = location;
330
+ this.legacyOutboxPath = legacyOutboxPath;
331
+ this.counter = new GovernanceRecordCounter(location?.dbPath ?? null, eventCounter);
332
+ }
333
+ /** Test seam: the boot baseline has been taken. */
334
+ ready() {
335
+ return this.counter.ready();
336
+ }
337
+ async health() {
338
+ const outbox = this.location?.outboxPath ?? null;
339
+ const [records, fold, legacyOutbox] = await Promise.all([
340
+ this.counter.records(),
341
+ outbox !== null ? this.folds.get(outbox) : Promise.resolve(emptyDeadletterFold(null)),
342
+ // The legacy pointer is only meaningful when it is NOT this daemon's own outbox.
343
+ probeLegacyOutbox(this.legacyOutboxPath !== null && this.legacyOutboxPath !== outbox ? this.legacyOutboxPath : null),
344
+ ]);
345
+ return governanceHealth({ location: this.location, records, fold, legacyOutbox });
346
+ }
347
+ }
348
+ //# sourceMappingURL=governance-health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance-health.js","sourceRoot":"","sources":["../../src/api/governance-health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAA4D,MAAM,6BAA6B,CAAC;AA4C5H,gFAAgF;AAEhF;;;2CAG2C;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3D,MAAM,8BAA8B,GAAG,IAAI,GAAG,IAAI,CAAC;AACnD,gHAAgH;AAChH,MAAM,aAAa,GAAG,EAAE,CAAC;AAKzB,MAAM,UAAU,mBAAmB,CAAC,IAAmB;IACrD,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,CAAC;QACd,aAAa,EAAE,CAAC;QAChB,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC;AAUD;;8DAE8D;AAC9D,MA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MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAWnF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnE"}
@@ -8,6 +8,7 @@
8
8
  import { spawn } from 'node:child_process';
9
9
  import { realpathSync } from 'node:fs';
10
10
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
11
+ import { childEnvWithBootEstateDb } from '../core/governance-store.js';
11
12
  /**
12
13
  * Is `target` inside `root` (or `root` itself), after normalization? Traversal-safe: the check is
13
14
  * on the RESOLVED relative path's first segment, so `/root/../evil` never passes, and a sibling
@@ -90,7 +91,7 @@ export function platformOpenCommand(target) {
90
91
  export function openWithSystemDefault(target) {
91
92
  const { cmd, args } = platformOpenCommand(target);
92
93
  return new Promise((resolvePromise, rejectPromise) => {
93
- const child = spawn(cmd, args, { detached: true, stdio: 'ignore' });
94
+ const child = spawn(cmd, args, { detached: true, stdio: 'ignore', env: childEnvWithBootEstateDb() });
94
95
  child.once('error', rejectPromise);
95
96
  child.once('spawn', () => {
96
97
  child.unref();
@@ -1 +1 @@
1
- {"version":3,"file":"open-path.js","sourceRoot":"","sources":["../../src/api/open-path.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,EAAE;AACF,kGAAkG;AAClG,+FAA+F;AAC/F,kGAAkG;AAClG,gGAAgG;AAChG,6CAA6C;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAExF;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAc;IACvD,4EAA4E;IA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C,OAAO,EAAE,aAAa,CAAC,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YACvB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -15,6 +15,7 @@
15
15
  * (non-zero ⇒ a loud 4xx carrying the script's own words; zero ⇒ the PR URL is re-extracted
16
16
  * crew-side via `prUrlFrom`, the same grep the script itself ends with).
17
17
  */
18
+ import { type DeliverScriptOptions } from '../core/deliver.js';
18
19
  /** What one spawn of the deliver script produced: its exit status and merged output. */
19
20
  export interface DeliverScriptResult {
20
21
  /** 0 = the script itself reported a delivery; anything else is the script's loud refusal. */
@@ -26,8 +27,10 @@ export interface DeliverScriptResult {
26
27
  spawnFailure?: boolean;
27
28
  }
28
29
  /** The exec seam the deliver route runs the script through — injectable so route tests can
29
- * point HOME/PATH at a fixture (a stub `gh`, a temp home) without touching the daemon env. */
30
- export type DeliverExec = (workdir: string, intent?: string) => Promise<DeliverScriptResult>;
30
+ * point HOME/PATH at a fixture (a stub `gh`, a temp home) without touching the daemon env.
31
+ * `opts` is the script's PR/commit text context (crew#524): the run id, the facts the route
32
+ * already holds for the fallback text, and this daemon's own origin for the run-record fetch. */
33
+ export type DeliverExec = (workdir: string, intent?: string, opts?: DeliverScriptOptions) => Promise<DeliverScriptResult>;
31
34
  /** A worktree stood back up from a run's `wicked/<id>` branch, plus its teardown (crew#418). */
32
35
  export interface ReprovisionedWorktree {
33
36
  /** The path to deliver in — a throwaway checkout of `wicked/<runId>`. */
@@ -58,8 +61,9 @@ export declare const gitReprovisionWorktree: WorktreeReprovisioner;
58
61
  /**
59
62
  * The production {@link DeliverExec}: `bash -lc <script>` in the run's worktree — the exact
60
63
  * invocation core's `run_tool_cmd` uses for the deliver phase (login shell, so the operator's
61
- * PATH — where `gh` lives — is loaded). `env` overlays the daemon's own environment; tests use
62
- * it to substitute HOME (whose `.bash_profile` prepends a stub `gh`), production passes none.
64
+ * PATH — where `gh` lives — is loaded). `opts` is the PR/commit text context (crew#524). `env`
65
+ * overlays the daemon's own environment; tests use it to substitute HOME (whose `.bash_profile`
66
+ * prepends a stub `gh`), production passes none.
63
67
  */
64
- export declare function runDeliverScript(workdir: string, intent?: string, env?: Record<string, string>): Promise<DeliverScriptResult>;
68
+ export declare function runDeliverScript(workdir: string, intent?: string, opts?: DeliverScriptOptions, env?: Record<string, string>): Promise<DeliverScriptResult>;
65
69
  //# sourceMappingURL=post-hoc-deliver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"post-hoc-deliver.d.ts","sourceRoot":"","sources":["../../src/api/post-hoc-deliver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,wFAAwF;AACxF,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAC;IACf,gGAAgG;IAChG,MAAM,EAAE,MAAM,CAAC;IACf;+FAC2F;IAC3F,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;+FAC+F;AAC/F,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAE7F,gGAAgG;AAChG,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;kGACkG;AAClG,MAAM,MAAM,qBAAqB,GAAG,CAClC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,EAAE,qBAmCpC,CAAC;AAQF;;;;;GAKG;AACH,wBAAgB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E,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,OAAO,CAAC,mBAAmB,CAAC,CA2C9B"}
@@ -19,7 +19,8 @@ import { execFile } from 'node:child_process';
19
19
  import { mkdtemp, rm } from 'node:fs/promises';
20
20
  import { tmpdir } from 'node:os';
21
21
  import { join } from 'node:path';
22
- import { deliverPrScript } from '../core/deliver.js';
22
+ import { DELIVER_POSTHOC_ENV, DELIVER_VERIFIED_BASE_ENV, deliverPrScript, } from '../core/deliver.js';
23
+ import { childEnvWithBootEstateDb } from '../core/governance-store.js';
23
24
  /**
24
25
  * Stand a run's committed work back up from its `wicked/<runId>` branch (crew#418).
25
26
  *
@@ -39,7 +40,7 @@ import { deliverPrScript } from '../core/deliver.js';
39
40
  export const gitReprovisionWorktree = async (repoRoot, runId) => {
40
41
  const branch = `wicked/${runId}`;
41
42
  const run = (args) => new Promise((resolve, reject) => {
42
- execFile('git', ['-C', repoRoot, ...args], { windowsHide: true }, (err) => err === null ? resolve() : reject(err));
43
+ execFile('git', ['-C', repoRoot, ...args], { windowsHide: true, env: childEnvWithBootEstateDb() }, (err) => err === null ? resolve() : reject(err));
43
44
  });
44
45
  const dir = await mkdtemp(join(tmpdir(), `wicked-deliver-${runId.replace(/[^\w.-]/g, '_')}-`));
45
46
  // Is the run's branch even there? Absent ⇒ the work is genuinely GONE → null (the route answers
@@ -78,14 +79,27 @@ const SCRIPT_TIMEOUT_MS = 5 * 60_000;
78
79
  /**
79
80
  * The production {@link DeliverExec}: `bash -lc <script>` in the run's worktree — the exact
80
81
  * invocation core's `run_tool_cmd` uses for the deliver phase (login shell, so the operator's
81
- * PATH — where `gh` lives — is loaded). `env` overlays the daemon's own environment; tests use
82
- * it to substitute HOME (whose `.bash_profile` prepends a stub `gh`), production passes none.
82
+ * PATH — where `gh` lives — is loaded). `opts` is the PR/commit text context (crew#524). `env`
83
+ * overlays the daemon's own environment; tests use it to substitute HOME (whose `.bash_profile`
84
+ * prepends a stub `gh`), production passes none.
83
85
  */
84
- export function runDeliverScript(workdir, intent, env) {
86
+ export function runDeliverScript(workdir, intent, opts, env) {
87
+ // The daemon's governance-store variables never ride into the deliver shell: the helper is
88
+ // applied LAST, so a caller overlay that spreads `process.env` cannot put them back.
89
+ const shellEnv = childEnvWithBootEstateDb({ ...process.env, ...env });
90
+ // A post-hoc lift has NO engine verification to pin to — the daemon runs the script itself, no
91
+ // deliver lift preceded it — so the script's verified-base refusal (wicked-core#431,
92
+ // `WICKED_DELIVER_VERIFIED_BASE`) must not fire off a stray pin in the daemon's own environment:
93
+ // it would refuse a base that merely differs from something nobody verified THIS work against.
94
+ delete shellEnv[DELIVER_VERIFIED_BASE_ENV];
95
+ // …and the script is told this IS a post-hoc lift, so the crew#426 preflight may regenerate
96
+ // tracked files and deliver them (disclosed) instead of refusing as an engine-driven Tool unit
97
+ // must (wicked-core#433 review addendum — there is no verified tree here to weaken).
98
+ shellEnv[DELIVER_POSTHOC_ENV] = '1';
85
99
  return new Promise((resolve) => {
86
- execFile('bash', ['-lc', deliverPrScript(intent)], {
100
+ execFile('bash', ['-lc', deliverPrScript(intent, opts)], {
87
101
  cwd: workdir,
88
- env: { ...process.env, ...env },
102
+ env: shellEnv,
89
103
  maxBuffer: OUTPUT_CAP_BYTES,
90
104
  timeout: SCRIPT_TIMEOUT_MS,
91
105
  }, (err, stdout, stderr) => {
@@ -1 +1 @@
1
- {"version":3,"file":"post-hoc-deliver.js","sourceRoot":"","sources":["../../src/api/post-hoc-deliver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;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