stitchkit 0.102.0 → 0.103.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 (32) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/application/diagnostic-journal-contract.d.ts +46 -7
  3. package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
  4. package/dist/application/diagnostic-journal-frame.d.ts +9 -0
  5. package/dist/application/diagnostic-journal-frame.d.ts.map +1 -0
  6. package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
  7. package/dist/application/diagnostic-journal-read-contract.d.ts +110 -0
  8. package/dist/application/diagnostic-journal-read-contract.d.ts.map +1 -0
  9. package/dist/application/diagnostic-journal-reader.d.ts +13 -0
  10. package/dist/application/diagnostic-journal-reader.d.ts.map +1 -0
  11. package/dist/application/diagnostic-journal-recovery.d.ts +4 -0
  12. package/dist/application/diagnostic-journal-recovery.d.ts.map +1 -0
  13. package/dist/application/diagnostic-journal-storage.d.ts +2 -0
  14. package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
  15. package/dist/entrypoints/application/diagnostic-journal.d.ts +1 -0
  16. package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -1
  17. package/dist/entrypoints/application/diagnostic-journal.js +213 -19
  18. package/dist/entrypoints/application.d.ts +1 -0
  19. package/dist/entrypoints/application.d.ts.map +1 -1
  20. package/dist/entrypoints/application.js +10 -2
  21. package/dist/index-z94wht4y.js +156 -0
  22. package/llms/application-diagnostic-journal.txt +2 -0
  23. package/llms/application.2.txt +157 -267
  24. package/llms/application.3.txt +278 -0
  25. package/llms/application.txt +43 -158
  26. package/llms/stitchkit.txt +4 -4
  27. package/llms/{upgrading-0.75.0-0.102.0.txt → upgrading-0.75.0-0.103.0.txt} +32 -3
  28. package/llms/upgrading.txt +1 -1
  29. package/llms-full.txt +80 -8
  30. package/llms.txt +4 -4
  31. package/package.json +1 -1
  32. package/dist/index-h124epcf.js +0 -103
@@ -1,13 +1,16 @@
1
1
  import {
2
+ DiagnosticJournalFrameSchema2,
3
+ createDiagnosticJournalReadResultSchema2,
4
+ DiagnosticJournalRecoveryStatusSchema2,
5
+ DiagnosticJournalRecoveryError2,
2
6
  DiagnosticJournalLimitsSchema2,
3
7
  DiagnosticJournalLockPolicySchema2,
4
8
  DiagnosticJournalStatusSchema2,
5
9
  DiagnosticJournalSubmitResultSchema2,
6
10
  DiagnosticJournalWaitResultSchema2,
7
11
  DiagnosticJournalCloseResultSchema2,
8
- DiagnosticJournalFrameSchema2,
9
12
  parseDiagnosticJournalMode
10
- } from "../../index-h124epcf.js";
13
+ } from "../../index-z94wht4y.js";
11
14
  import {
12
15
  createBoundedChannel2
13
16
  } from "../../index-w0eqdhyd.js";
@@ -22,12 +25,12 @@ import {
22
25
  import { randomUUID } from "node:crypto";
23
26
 
24
27
  // src/application/diagnostic-journal-manager.ts
25
- import { z } from "zod";
28
+ import { z as z3 } from "zod";
26
29
 
27
30
  // src/application/diagnostic-journal-storage.ts
28
- import { constants } from "node:fs";
29
- import { lstat, open, readdir, realpath, rename, unlink } from "node:fs/promises";
30
- import { basename, dirname, isAbsolute, resolve } from "node:path";
31
+ import { constants as constants2 } from "node:fs";
32
+ import { lstat as lstat2, open as open2, readdir, realpath, rename, unlink } from "node:fs/promises";
33
+ import { basename, dirname, isAbsolute as isAbsolute2, resolve as resolve2 } from "node:path";
31
34
 
32
35
  // src/application/diagnostic-journal-lock.ts
33
36
  async function acquireDiagnosticJournalLock(lockPath, mode, policy, declaredIdentity) {
@@ -46,6 +49,175 @@ async function acquireDiagnosticJournalLock(lockPath, mode, policy, declaredIden
46
49
  throw error;
47
50
  }
48
51
 
52
+ // src/application/diagnostic-journal-recovery.ts
53
+ import { z as z2 } from "zod";
54
+
55
+ // src/application/diagnostic-journal-reader.ts
56
+ import { constants } from "node:fs";
57
+ import { lstat, open } from "node:fs/promises";
58
+ import { isAbsolute, resolve } from "node:path";
59
+ import { z } from "zod";
60
+ function decodeLine(schema, location, body) {
61
+ const anomaly = (reason, skippedBytes = location.bytes) => schema.parse({
62
+ type: "anomaly",
63
+ anomaly: {
64
+ file: location.file,
65
+ offset: location.offset,
66
+ line: location.line,
67
+ reason,
68
+ position: location.position,
69
+ terminated: location.terminated,
70
+ skippedBytes
71
+ }
72
+ });
73
+ if (body === undefined)
74
+ return [anomaly("oversized-line")];
75
+ if (body.includes(0))
76
+ return [anomaly("nul-byte")];
77
+ let text;
78
+ try {
79
+ text = new TextDecoder("utf-8", { fatal: true }).decode(body);
80
+ } catch {
81
+ return [anomaly("invalid-utf8")];
82
+ }
83
+ let frame;
84
+ try {
85
+ frame = JSON.parse(text);
86
+ } catch {
87
+ return [anomaly(location.terminated ? "invalid-json" : "unterminated-line")];
88
+ }
89
+ const parsed = schema.safeParse({
90
+ type: "frame",
91
+ file: location.file,
92
+ offset: location.offset,
93
+ line: location.line,
94
+ bytes: location.bytes,
95
+ frame
96
+ });
97
+ if (!parsed.success) {
98
+ const frameInvalid = parsed.error.issues.some((issue) => issue.path[0] !== "frame" || issue.path[1] !== "event");
99
+ return [anomaly(frameInvalid ? "invalid-frame" : "invalid-event")];
100
+ }
101
+ return location.terminated ? [parsed.data] : [anomaly("unterminated-line", 0), parsed.data];
102
+ }
103
+ async function openRegularFile(path) {
104
+ const before = await lstat(path);
105
+ if (before.isSymbolicLink() || !before.isFile()) {
106
+ throw new TypeError("Diagnostic journal reader requires a regular file, never a symlink");
107
+ }
108
+ const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
109
+ try {
110
+ const info = await handle.stat();
111
+ if (!info.isFile())
112
+ throw new TypeError("Diagnostic journal reader requires a regular file");
113
+ return { handle, size: z.number().int().nonnegative().parse(info.size) };
114
+ } catch (error) {
115
+ await handle.close();
116
+ throw error;
117
+ }
118
+ }
119
+ async function* readDiagnosticJournal(config) {
120
+ const maxLineBytes = z.number().int().positive().parse(config.maxLineBytes);
121
+ if (config.paths.length === 0)
122
+ throw new TypeError("Diagnostic journal reader needs at least one path");
123
+ for (const path of config.paths) {
124
+ if (!isAbsolute(path) || resolve(path) !== path) {
125
+ throw new TypeError("Diagnostic journal reader paths must be normalized and absolute");
126
+ }
127
+ }
128
+ const schema = createDiagnosticJournalReadResultSchema2(config.eventSchema);
129
+ for (const file of config.paths) {
130
+ config.signal?.throwIfAborted();
131
+ const { handle, size } = await openRegularFile(file);
132
+ try {
133
+ const chunk = Buffer.alloc(64 * 1024);
134
+ let offset = 0;
135
+ let lineOffset = 0;
136
+ let line = 1;
137
+ let lineBytes = 0;
138
+ let oversized = false;
139
+ let parts = [];
140
+ while (offset < size) {
141
+ config.signal?.throwIfAborted();
142
+ const { bytesRead } = await handle.read(chunk, 0, Math.min(chunk.length, size - offset), offset);
143
+ if (bytesRead === 0)
144
+ throw new Error(`Diagnostic journal file was truncated during read: ${file}`);
145
+ let start = 0;
146
+ while (start < bytesRead) {
147
+ config.signal?.throwIfAborted();
148
+ const found = chunk.indexOf(10, start);
149
+ const terminated = found >= start && found < bytesRead;
150
+ const end = terminated ? found : bytesRead;
151
+ lineBytes += end - start;
152
+ if (lineBytes > maxLineBytes) {
153
+ oversized = true;
154
+ parts = [];
155
+ } else if (!oversized && end > start) {
156
+ parts.push(Buffer.from(chunk.subarray(start, end)));
157
+ }
158
+ start = end + (terminated ? 1 : 0);
159
+ if (terminated) {
160
+ const nextOffset = offset + start;
161
+ yield* decodeLine(schema, {
162
+ file,
163
+ offset: lineOffset,
164
+ line,
165
+ bytes: lineBytes + 1,
166
+ terminated: true,
167
+ position: nextOffset === size ? "tail" : "interior"
168
+ }, oversized ? undefined : Buffer.concat(parts, lineBytes));
169
+ lineOffset = nextOffset;
170
+ line += 1;
171
+ lineBytes = 0;
172
+ oversized = false;
173
+ parts = [];
174
+ }
175
+ }
176
+ offset += bytesRead;
177
+ }
178
+ if (lineBytes > 0) {
179
+ yield* decodeLine(schema, {
180
+ file,
181
+ offset: lineOffset,
182
+ line,
183
+ bytes: lineBytes,
184
+ terminated: false,
185
+ position: "tail"
186
+ }, oversized ? undefined : Buffer.concat(parts, lineBytes));
187
+ }
188
+ } finally {
189
+ await handle.close();
190
+ }
191
+ }
192
+ }
193
+
194
+ // src/application/diagnostic-journal-recovery.ts
195
+ async function inspectDiagnosticJournalRecovery(paths, maxLineBytes) {
196
+ let anomalies = 0;
197
+ let skippedBytes = 0;
198
+ let firstAnomaly;
199
+ let lastAnomaly;
200
+ for await (const result of readDiagnosticJournal({
201
+ paths,
202
+ maxLineBytes,
203
+ eventSchema: z2.json()
204
+ })) {
205
+ if (result.type !== "anomaly")
206
+ continue;
207
+ anomalies += 1;
208
+ skippedBytes += result.anomaly.skippedBytes;
209
+ firstAnomaly ??= result.anomaly;
210
+ lastAnomaly = result.anomaly;
211
+ }
212
+ return DiagnosticJournalRecoveryStatusSchema2.parse({
213
+ filesChecked: paths.length,
214
+ anomalies,
215
+ skippedBytes,
216
+ ...firstAnomaly && { firstAnomaly },
217
+ ...lastAnomaly && { lastAnomaly }
218
+ });
219
+ }
220
+
49
221
  // src/application/diagnostic-journal-storage.ts
50
222
  class DiagnosticJournalStorageError extends Error {
51
223
  phase;
@@ -60,7 +232,7 @@ function isMissing(error) {
60
232
  }
61
233
  async function removeIfPresent(path) {
62
234
  try {
63
- const info = await lstat(path);
235
+ const info = await lstat2(path);
64
236
  if (info.isSymbolicLink() || !info.isFile()) {
65
237
  throw new Error("Diagnostic journal generations must be regular files");
66
238
  }
@@ -72,7 +244,7 @@ async function removeIfPresent(path) {
72
244
  }
73
245
  async function moveIfPresent(from, to) {
74
246
  try {
75
- const info = await lstat(from);
247
+ const info = await lstat2(from);
76
248
  if (info.isSymbolicLink() || !info.isFile()) {
77
249
  throw new Error("Diagnostic journal generations must be regular files");
78
250
  }
@@ -97,11 +269,11 @@ function generationIndex(name, prefix) {
97
269
  return Number.isSafeInteger(value) && value > 0 ? value : undefined;
98
270
  }
99
271
  async function createRotatingDiagnosticJournalStorage(config) {
100
- if (!isAbsolute(config.path) || resolve(config.path) !== config.path) {
272
+ if (!isAbsolute2(config.path) || resolve2(config.path) !== config.path) {
101
273
  throw new TypeError("Diagnostic journal path must be normalized and absolute");
102
274
  }
103
275
  const parent = await realpath(dirname(config.path));
104
- const journalPath = resolve(parent, basename(config.path));
276
+ const journalPath = resolve2(parent, basename(config.path));
105
277
  const lockPath = `${journalPath}.lock`;
106
278
  const { lock, reclaimedStale } = await acquireDiagnosticJournalLock(lockPath, config.mode, config.lock, config.machineIdentity);
107
279
  let handle;
@@ -109,9 +281,10 @@ async function createRotatingDiagnosticJournalStorage(config) {
109
281
  let retainedFiles = 1;
110
282
  let rotations = 0;
111
283
  let partialTails = 0;
284
+ let recovery;
112
285
  let closed = false;
113
286
  const openCurrent = async () => {
114
- handle = await open(journalPath, constants.O_APPEND | constants.O_CREAT | constants.O_RDWR | constants.O_NOFOLLOW, config.mode);
287
+ handle = await open2(journalPath, constants2.O_APPEND | constants2.O_CREAT | constants2.O_RDWR | constants2.O_NOFOLLOW, config.mode);
115
288
  const info = await handle.stat();
116
289
  if (!info.isFile()) {
117
290
  await handle.close();
@@ -143,18 +316,20 @@ async function createRotatingDiagnosticJournalStorage(config) {
143
316
  try {
144
317
  const names = await readdir(parent);
145
318
  const prefix = `${basename(journalPath)}.`;
319
+ const expiredGenerations = [];
146
320
  let existingGenerations = 0;
147
321
  for (const name of names) {
148
322
  const index = generationIndex(name, prefix);
149
323
  if (index === undefined)
150
324
  continue;
325
+ const path = resolve2(parent, name);
326
+ const info = await lstat2(path);
327
+ if (info.isSymbolicLink() || !info.isFile()) {
328
+ throw new Error("Diagnostic journal generations must be regular files");
329
+ }
151
330
  if (index >= config.maxFiles) {
152
- await removeIfPresent(resolve(parent, name));
331
+ expiredGenerations.push(path);
153
332
  } else {
154
- const info = await lstat(resolve(parent, name));
155
- if (info.isSymbolicLink() || !info.isFile()) {
156
- throw new Error("Diagnostic journal generations must be regular files");
157
- }
158
333
  existingGenerations += 1;
159
334
  }
160
335
  }
@@ -164,10 +339,26 @@ async function createRotatingDiagnosticJournalStorage(config) {
164
339
  const tail = new Uint8Array(1);
165
340
  const read = await handle?.read(tail, 0, 1, currentFileBytes - 1);
166
341
  if (read?.bytesRead === 1 && tail[0] !== 10) {
342
+ if (config.maxFiles === 1) {
343
+ throw new DiagnosticJournalRecoveryError2(await inspectDiagnosticJournalRecovery([journalPath], config.maxFileBytes));
344
+ }
167
345
  partialTails += 1;
168
346
  await rotate();
169
347
  }
170
348
  }
349
+ for (const path of expiredGenerations)
350
+ await removeIfPresent(path);
351
+ const paths = [];
352
+ for (const name of await readdir(parent)) {
353
+ const index = generationIndex(name, prefix);
354
+ if (index !== undefined && index < config.maxFiles) {
355
+ paths.push({ index, path: resolve2(parent, name) });
356
+ }
357
+ }
358
+ paths.sort((left, right) => right.index - left.index);
359
+ const inspected = await inspectDiagnosticJournalRecovery([...paths.map((file) => file.path), journalPath], config.maxFileBytes);
360
+ if (inspected.anomalies > 0)
361
+ recovery = inspected;
171
362
  } catch (error) {
172
363
  await handle?.close().catch(() => {
173
364
  return;
@@ -181,7 +372,8 @@ async function createRotatingDiagnosticJournalStorage(config) {
181
372
  currentFileBytes,
182
373
  retainedFiles,
183
374
  rotations,
184
- partialTails
375
+ partialTails,
376
+ ...recovery && { recovery }
185
377
  });
186
378
  return {
187
379
  reclaimedStale,
@@ -389,6 +581,7 @@ function createDiagnosticJournalManager(config, storage) {
389
581
  partialTails: file.partialTails,
390
582
  currentFileBytes: file.currentFileBytes,
391
583
  retainedFiles: file.retainedFiles,
584
+ ...file.recovery && { recovery: file.recovery },
392
585
  ...lastAcceptedSequence > 0 && { lastAcceptedSequence },
393
586
  ...lastWrittenSequence > 0 && { lastWrittenSequence },
394
587
  ...lastSettledSequence > 0 && { lastSettledSequence },
@@ -405,7 +598,7 @@ function createDiagnosticJournalManager(config, storage) {
405
598
  const parsed = config.eventSchema.safeParse(event);
406
599
  if (!parsed.success)
407
600
  return refuse("invalid");
408
- const json = z.json().safeParse(parsed.data);
601
+ const json = z3.json().safeParse(parsed.data);
409
602
  if (!json.success)
410
603
  return refuse("invalid");
411
604
  const payload = encoder.encode(JSON.stringify(json.data));
@@ -488,5 +681,6 @@ async function createDiagnosticJournal(config) {
488
681
  }, storage);
489
682
  }
490
683
  export {
491
- createDiagnosticJournal
684
+ createDiagnosticJournal,
685
+ readDiagnosticJournal
492
686
  };
@@ -3,6 +3,7 @@ export { type BoundedAdmission, type BoundedAdmissionClock, type BoundedAdmissio
3
3
  export { type ChangeConnection, type ChangeReconciliation, type ChangeSubscriptionConfig, changeSubscriptionResource, } from '../application/change-subscription.js';
4
4
  export { createDecisionPipeline, type DecisionPipeline, type DecisionPipelineConfig, type DecisionPolicy, DecisionPolicyError, type DecisionResult, type DecisionTraceEntry, DecisionUndecidedError, type PolicyDecision, PolicyDecisionSchema, } from '../application/decisions.js';
5
5
  export { type DiagnosticJournal, type DiagnosticJournalCloseResult, DiagnosticJournalCloseResultSchema, type DiagnosticJournalConfig, type DiagnosticJournalFailure, type DiagnosticJournalFailurePhase, DiagnosticJournalFailurePhaseSchema, type DiagnosticJournalFrame, DiagnosticJournalFrameSchema, type DiagnosticJournalLimits, DiagnosticJournalLimitsSchema, type DiagnosticJournalLockDiagnosis, type DiagnosticJournalLockPolicy, DiagnosticJournalLockPolicySchema, type DiagnosticJournalRefusalReason, DiagnosticJournalRefusalReasonSchema, type DiagnosticJournalState, DiagnosticJournalStateSchema, type DiagnosticJournalStatus, DiagnosticJournalStatusSchema, type DiagnosticJournalSubmitResult, DiagnosticJournalSubmitResultSchema, type DiagnosticJournalWaitOptions, type DiagnosticJournalWaitResult, DiagnosticJournalWaitResultSchema, readDiagnosticJournalLockDiagnosis, } from '../application/diagnostic-journal-contract.js';
6
+ export { createDiagnosticJournalReadResultSchema, type DiagnosticJournalAnomaly, DiagnosticJournalAnomalySchema, type DiagnosticJournalReadResult, DiagnosticJournalRecoveryError, type DiagnosticJournalRecoveryStatus, DiagnosticJournalRecoveryStatusSchema, } from '../application/diagnostic-journal-read-contract.js';
6
7
  export { type DirectoryInbox, type DirectoryInboxConfig, type DirectoryInboxDelivery, type DirectoryInboxRejection, type DirectoryInboxRejectionReason, DirectoryInboxRejectionReasonSchema, type DirectoryInboxResource, type DirectoryInboxState, DirectoryInboxStateSchema, } from '../application/directory-inbox-contract.js';
7
8
  export { type ApplicationEventSink, type ApplicationEventSinkConfig, type ApplicationLifecycleEvent, ApplicationLifecycleEventSchema, applicationLifecycleEvent, createApplicationEventSink, } from '../application/events.js';
8
9
  export { type ApplicationHealthHandlerOptions, ApplicationHealthHandlerOptionsSchema, type ApplicationOperationalHandlers, type ApplicationOperationalHandlersOptions, ApplicationOperationalHandlersOptionsSchema, createApplicationHealthHandler, createApplicationOperationalHandlers, } from '../application/health.js';
@@ -1 +1 @@
1
- {"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/entrypoints/application.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACtC,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,aAAa,EAClB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,mCAAmC,EACxC,KAAK,4BAA4B,EACjC,kCAAkC,EAClC,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,KAAK,6BAA6B,EAClC,mCAAmC,EACnC,KAAK,6BAA6B,EAClC,KA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BAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACvF,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/entrypoints/application.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACtC,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,aAAa,EAClB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,mCAAmC,EACxC,KAAK,4BAA4B,EACjC,kCAAkC,EAClC,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,KAAK,6BAA6B,EAClC,mCAAmC,EACnC,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,yBAAyB,EACzB,KAAK,iBAAiB,E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AC7B,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACvF,cAAc,uBAAuB,CAAC"}
@@ -31,6 +31,11 @@ import {
31
31
  createBackoff2
32
32
  } from "../index-g6a3na27.js";
33
33
  import {
34
+ DiagnosticJournalFrameSchema2,
35
+ DiagnosticJournalAnomalySchema2,
36
+ createDiagnosticJournalReadResultSchema2,
37
+ DiagnosticJournalRecoveryStatusSchema2,
38
+ DiagnosticJournalRecoveryError2,
34
39
  DiagnosticJournalLimitsSchema2,
35
40
  DiagnosticJournalLockPolicySchema2,
36
41
  DiagnosticJournalStateSchema2,
@@ -40,9 +45,8 @@ import {
40
45
  DiagnosticJournalSubmitResultSchema2,
41
46
  DiagnosticJournalWaitResultSchema2,
42
47
  DiagnosticJournalCloseResultSchema2,
43
- DiagnosticJournalFrameSchema2,
44
48
  readDiagnosticJournalLockDiagnosis2
45
- } from "../index-h124epcf.js";
49
+ } from "../index-z94wht4y.js";
46
50
  import {
47
51
  DirectoryInboxRejectionReasonSchema2,
48
52
  DirectoryInboxStateSchema2
@@ -2574,11 +2578,14 @@ export {
2574
2578
  CreditWindowSnapshotSchema2 as CreditWindowSnapshotSchema,
2575
2579
  DecisionPolicyError,
2576
2580
  DecisionUndecidedError,
2581
+ DiagnosticJournalAnomalySchema2 as DiagnosticJournalAnomalySchema,
2577
2582
  DiagnosticJournalCloseResultSchema2 as DiagnosticJournalCloseResultSchema,
2578
2583
  DiagnosticJournalFailurePhaseSchema2 as DiagnosticJournalFailurePhaseSchema,
2579
2584
  DiagnosticJournalFrameSchema2 as DiagnosticJournalFrameSchema,
2580
2585
  DiagnosticJournalLimitsSchema2 as DiagnosticJournalLimitsSchema,
2581
2586
  DiagnosticJournalLockPolicySchema2 as DiagnosticJournalLockPolicySchema,
2587
+ DiagnosticJournalRecoveryError2 as DiagnosticJournalRecoveryError,
2588
+ DiagnosticJournalRecoveryStatusSchema2 as DiagnosticJournalRecoveryStatusSchema,
2582
2589
  DiagnosticJournalRefusalReasonSchema2 as DiagnosticJournalRefusalReasonSchema,
2583
2590
  DiagnosticJournalStateSchema2 as DiagnosticJournalStateSchema,
2584
2591
  DiagnosticJournalStatusSchema2 as DiagnosticJournalStatusSchema,
@@ -2616,6 +2623,7 @@ export {
2616
2623
  createBoundedChannel2 as createBoundedChannel,
2617
2624
  createCreditWindow2 as createCreditWindow,
2618
2625
  createDecisionPipeline,
2626
+ createDiagnosticJournalReadResultSchema2 as createDiagnosticJournalReadResultSchema,
2619
2627
  createManagedSchedule2 as createManagedSchedule,
2620
2628
  createNotificationOutbox,
2621
2629
  createProcessLifecycleLedger,
@@ -0,0 +1,156 @@
1
+ import {
2
+ isRecord
3
+ } from "./index-9jfdm5tg.js";
4
+
5
+ // src/application/diagnostic-journal-frame.ts
6
+ import { z } from "zod";
7
+ var DiagnosticJournalFrameSchema2 = z.object({
8
+ schemaVersion: z.literal(1),
9
+ epoch: z.uuid(),
10
+ sequence: z.number().int().positive(),
11
+ event: z.json()
12
+ }).strict().readonly();
13
+
14
+ // src/application/diagnostic-journal-read-contract.ts
15
+ import { z as z2 } from "zod";
16
+ var ByteCountSchema = z2.number().int().nonnegative();
17
+ var LocationSchema = z2.object({
18
+ file: z2.string(),
19
+ offset: ByteCountSchema,
20
+ line: z2.number().int().positive()
21
+ });
22
+ var DiagnosticJournalAnomalySchema2 = LocationSchema.extend({
23
+ reason: z2.enum([
24
+ "nul-byte",
25
+ "unterminated-line",
26
+ "invalid-utf8",
27
+ "invalid-json",
28
+ "invalid-frame",
29
+ "invalid-event",
30
+ "oversized-line"
31
+ ]),
32
+ position: z2.enum(["tail", "interior"]),
33
+ terminated: z2.boolean(),
34
+ skippedBytes: ByteCountSchema
35
+ }).strict().readonly();
36
+ function createDiagnosticJournalReadResultSchema2(eventSchema) {
37
+ return z2.discriminatedUnion("type", [
38
+ LocationSchema.extend({
39
+ type: z2.literal("frame"),
40
+ bytes: ByteCountSchema,
41
+ frame: DiagnosticJournalFrameSchema2.unwrap().extend({ event: eventSchema }).readonly()
42
+ }).strict().readonly(),
43
+ z2.object({ type: z2.literal("anomaly"), anomaly: DiagnosticJournalAnomalySchema2 }).strict().readonly()
44
+ ]);
45
+ }
46
+ var DiagnosticJournalRecoveryStatusSchema2 = z2.object({
47
+ filesChecked: ByteCountSchema,
48
+ anomalies: ByteCountSchema,
49
+ skippedBytes: ByteCountSchema,
50
+ firstAnomaly: DiagnosticJournalAnomalySchema2.optional(),
51
+ lastAnomaly: DiagnosticJournalAnomalySchema2.optional()
52
+ }).strict().readonly();
53
+
54
+ class DiagnosticJournalRecoveryError2 extends Error {
55
+ recovery;
56
+ constructor(recovery) {
57
+ super("Diagnostic journal tail recovery requires maxFiles >= 2; no data was removed");
58
+ this.recovery = recovery;
59
+ this.name = "DiagnosticJournalRecoveryError";
60
+ }
61
+ }
62
+
63
+ // src/application/diagnostic-journal-contract.ts
64
+ import { z as z3 } from "zod";
65
+ var PositiveSafeIntegerSchema = z3.number().int().positive();
66
+ var FileModeSchema = z3.number().int().min(0).max(511);
67
+ var DiagnosticJournalLimitsSchema2 = z3.object({
68
+ maxEventBytes: PositiveSafeIntegerSchema,
69
+ maxPendingItems: PositiveSafeIntegerSchema,
70
+ maxPendingBytes: PositiveSafeIntegerSchema,
71
+ maxFileBytes: PositiveSafeIntegerSchema,
72
+ maxFiles: PositiveSafeIntegerSchema
73
+ }).strict().readonly();
74
+ var DiagnosticJournalLockPolicySchema2 = z3.enum(["refuse", "reclaim-stale"]);
75
+ var DiagnosticJournalStateSchema2 = z3.enum(["open", "draining", "closed", "failed"]);
76
+ var DiagnosticJournalRefusalReasonSchema2 = z3.enum([
77
+ "closed",
78
+ "failed",
79
+ "invalid",
80
+ "oversized",
81
+ "item-capacity",
82
+ "byte-capacity"
83
+ ]);
84
+ var DiagnosticJournalRefusalCountersSchema = z3.object({
85
+ closed: z3.number().int().nonnegative(),
86
+ failed: z3.number().int().nonnegative(),
87
+ invalid: z3.number().int().nonnegative(),
88
+ oversized: z3.number().int().nonnegative(),
89
+ "item-capacity": z3.number().int().nonnegative(),
90
+ "byte-capacity": z3.number().int().nonnegative()
91
+ }).strict().readonly();
92
+ var DiagnosticJournalFailurePhaseSchema2 = z3.enum(["write", "rotation", "close"]);
93
+ var DiagnosticJournalStatusSchema2 = z3.object({
94
+ state: DiagnosticJournalStateSchema2,
95
+ epoch: z3.uuid(),
96
+ limits: DiagnosticJournalLimitsSchema2,
97
+ lock: z3.object({
98
+ policy: DiagnosticJournalLockPolicySchema2,
99
+ reclaimedStale: z3.boolean()
100
+ }).strict().readonly(),
101
+ received: z3.number().int().nonnegative(),
102
+ accepted: z3.number().int().nonnegative(),
103
+ refused: z3.number().int().nonnegative(),
104
+ refusals: DiagnosticJournalRefusalCountersSchema,
105
+ written: z3.number().int().nonnegative(),
106
+ failedRecords: z3.number().int().nonnegative(),
107
+ pendingItems: z3.number().int().nonnegative(),
108
+ pendingBytes: z3.number().int().nonnegative(),
109
+ inFlight: z3.boolean(),
110
+ rotations: z3.number().int().nonnegative(),
111
+ rotationFailures: z3.number().int().nonnegative(),
112
+ partialTails: z3.number().int().nonnegative(),
113
+ currentFileBytes: z3.number().int().nonnegative(),
114
+ retainedFiles: z3.number().int().nonnegative(),
115
+ recovery: DiagnosticJournalRecoveryStatusSchema2.optional(),
116
+ lastAcceptedSequence: z3.number().int().positive().optional(),
117
+ lastWrittenSequence: z3.number().int().positive().optional(),
118
+ lastSettledSequence: z3.number().int().positive().optional(),
119
+ lastFailure: z3.object({
120
+ phase: DiagnosticJournalFailurePhaseSchema2,
121
+ sequence: z3.number().int().positive().optional()
122
+ }).strict().readonly().optional()
123
+ }).strict().readonly();
124
+ var DiagnosticJournalSubmitResultSchema2 = z3.discriminatedUnion("outcome", [
125
+ z3.object({
126
+ outcome: z3.literal("accepted"),
127
+ epoch: z3.uuid(),
128
+ sequence: z3.number().int().positive()
129
+ }).strict().readonly(),
130
+ z3.object({
131
+ outcome: z3.literal("refused"),
132
+ reason: DiagnosticJournalRefusalReasonSchema2
133
+ }).strict().readonly()
134
+ ]);
135
+ var DiagnosticJournalWaitResultSchema2 = z3.object({
136
+ outcome: z3.enum(["settled", "timed-out", "cancelled"]),
137
+ state: DiagnosticJournalStateSchema2,
138
+ throughSequence: z3.number().int().nonnegative(),
139
+ settledSequence: z3.number().int().nonnegative()
140
+ }).strict().readonly();
141
+ var DiagnosticJournalCloseResultSchema2 = z3.object({
142
+ outcome: z3.enum(["closed", "timed-out", "cancelled"]),
143
+ state: DiagnosticJournalStateSchema2,
144
+ pendingItems: z3.number().int().nonnegative()
145
+ }).strict().readonly();
146
+ function parseDiagnosticJournalMode(mode) {
147
+ return FileModeSchema.parse(mode ?? 384);
148
+ }
149
+ function readDiagnosticJournalLockDiagnosis2(error) {
150
+ if (!isRecord(error))
151
+ return;
152
+ const diagnosis = error.journalLock;
153
+ return isRecord(diagnosis) ? diagnosis : undefined;
154
+ }
155
+
156
+ export { DiagnosticJournalFrameSchema2, DiagnosticJournalAnomalySchema2, createDiagnosticJournalReadResultSchema2, DiagnosticJournalRecoveryStatusSchema2, DiagnosticJournalRecoveryError2, DiagnosticJournalLimitsSchema2, DiagnosticJournalLockPolicySchema2, DiagnosticJournalStateSchema2, DiagnosticJournalRefusalReasonSchema2, DiagnosticJournalFailurePhaseSchema2, DiagnosticJournalStatusSchema2, DiagnosticJournalSubmitResultSchema2, DiagnosticJournalWaitResultSchema2, DiagnosticJournalCloseResultSchema2, parseDiagnosticJournalMode, readDiagnosticJournalLockDiagnosis2 };
@@ -17,6 +17,8 @@ Also read:
17
17
  | Export | Kind | Summary |
18
18
  |--------|------|---------|
19
19
  | `createDiagnosticJournal` | function | the bounded local journal: a file lock, a spawn to diagnose a stale one, and framed writes |
20
+ | `readDiagnosticJournal` | function | bounded async stream of validated frames and explicit anomalies from finite snapshots of caller-selected files; I/O failures throw |
21
+ | `DiagnosticJournalReaderConfig` | _type_ | normalized absolute `paths`, owner `eventSchema`, positive safe-integer `maxLineBytes` and optional cancellation `signal` |
20
22
 
21
23
  Its own entrypoint because of what it reaches — `node:child_process`,
22
24
  `node:fs`, `node:os`, `node:util` — with `promisify(execFile)` evaluated while