target-supabase-sdk 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/chunks/{enable-log-persist-C_bSw6Kx.js → enable-log-persist-BH-tbKEj.js} +156 -37
- package/dist/chunks/enable-log-persist-BH-tbKEj.js.map +1 -0
- package/dist/node.js +2 -2
- package/dist/preload.js +1 -1
- package/dist/shared/log/log-persist-registry.d.ts +1 -0
- package/dist/shared/log/log-persist-registry.d.ts.map +1 -1
- package/dist/shared/log/log-persist.interface.d.ts +1 -1
- package/dist/shared/log/log-persist.interface.d.ts.map +1 -1
- package/package.json +1 -6
- package/src/shared/log/log-persist-flush.ts +2 -2
- package/src/shared/log/log-persist-registry.ts +176 -33
- package/src/shared/log/log-persist.interface.ts +1 -1
- package/dist/chunks/enable-log-persist-C_bSw6Kx.js.map +0 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ cp .env.example .env.local
|
|
|
35
35
|
| `SUPABASE_NEED_AUTH_URL` | No | Separate auth project URL |
|
|
36
36
|
| `SUPABASE_NEED_AUTH_ANON_KEY` | No | Separate auth project anon key |
|
|
37
37
|
|
|
38
|
-
Used by `scripts/` (`pnpm worker
|
|
38
|
+
Used by `scripts/` (`pnpm worker:trigger`) via `.env.local`. Browser apps pass the same values to `supabase.initialize()` (e.g. `import.meta.env.VITE_SUPABASE_URL` if your bundler uses a `VITE_` prefix).
|
|
39
39
|
|
|
40
40
|
### Security
|
|
41
41
|
|
|
@@ -64,6 +64,8 @@ Local task registry, repo script loading, TaskNode — use the `/node` entry:
|
|
|
64
64
|
import { TaskManager, RepoManager, TaskNode, postTaskWithValidation } from "target-supabase-sdk/node";
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
Consumer services (e.g. [`../download-service`](../download-service), [`../watch-service`](../watch-service)) run `TaskNode` / `TriggerNode` with their own `config/task.config.js` and `tasks/` packages.
|
|
68
|
+
|
|
67
69
|
> **Breaking change in 0.2.0:** `TaskManager`, `RepoManager`, and `postTaskWithValidation` are no longer the only task publish path on `/node`. **`postTask`** (no Repo validation) is on the **default** browser entry and re-exported from `/node`.
|
|
68
70
|
|
|
69
71
|
### Browser vs Node (package layout)
|
|
@@ -154,7 +156,7 @@ const { data: service } = await discoverService({ value: "storage-service" });
|
|
|
154
156
|
|
|
155
157
|
Types: `Service`, `Api`, `ApiDetails` (`method`, `path`, `endpoint`, `request`, `response`), `FieldDefinition` for inline schemas.
|
|
156
158
|
|
|
157
|
-
**Example
|
|
159
|
+
**Example consumers:** [`../storage-service`](../storage-service) (chunk upload/download), [`../watch-service`](../watch-service) (site scan scheduler), [`../download-service`](../download-service) (Chrome-backed `auto-chrome` executor).
|
|
158
160
|
|
|
159
161
|
### TriggerNode (local interval runners)
|
|
160
162
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { resolve, dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { readFile, mkdir, writeFile, rename } from 'node:fs/promises';
|
|
4
|
+
import { readFile, mkdir, writeFile, rename, readdir } from 'node:fs/promises';
|
|
5
5
|
import { d as createLogger, a as CategoryList, w as postLogListCreate, m as isCreateTargetAlreadyExistsError, L as LogLevel, F as registerLogPersistOffer } from './create-logger-DyH3mZ8p.js';
|
|
6
6
|
import 'lodash-es';
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
@@ -384,12 +384,12 @@ function buildLogListDraft(input) {
|
|
|
384
384
|
const first = entries[0];
|
|
385
385
|
const last = entries[entries.length - 1];
|
|
386
386
|
return {
|
|
387
|
-
name:
|
|
387
|
+
name: `log-batch:${service}:${process}:${lane}`,
|
|
388
388
|
value: idempotencyKey,
|
|
389
389
|
category: CategoryList.LIST,
|
|
390
390
|
tagList: ["log", lane, service],
|
|
391
391
|
details: {
|
|
392
|
-
manifestVersion:
|
|
392
|
+
manifestVersion: 0,
|
|
393
393
|
loaderKey: LOG_PERSIST_LOADER_KEY,
|
|
394
394
|
meta: JSON.stringify({
|
|
395
395
|
service,
|
|
@@ -484,9 +484,20 @@ const DEFAULT_REGISTRY = {
|
|
|
484
484
|
service: "",
|
|
485
485
|
processes: {},
|
|
486
486
|
};
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
const DEFAULT_SHARD = {
|
|
488
|
+
service: "",
|
|
489
|
+
updatedAt: new Date(0).toISOString(),
|
|
490
|
+
pid: 0,
|
|
491
|
+
enabledAt: new Date(0).toISOString(),
|
|
492
|
+
lastHeartbeatAt: new Date(0).toISOString(),
|
|
493
|
+
};
|
|
494
|
+
const legacyStores = new Map();
|
|
495
|
+
const shardStores = new Map();
|
|
496
|
+
function isLegacyRegistryFile(registryPath) {
|
|
497
|
+
return registryPath.endsWith(".json");
|
|
498
|
+
}
|
|
499
|
+
function legacyStoreFor(filePath) {
|
|
500
|
+
let store = legacyStores.get(filePath);
|
|
490
501
|
if (store == null) {
|
|
491
502
|
store = createJsonFileStateStore({
|
|
492
503
|
filePath,
|
|
@@ -494,12 +505,72 @@ function storeFor(filePath) {
|
|
|
494
505
|
nestedKeys: ["processes"],
|
|
495
506
|
updatedAtKey: "updatedAt",
|
|
496
507
|
});
|
|
497
|
-
|
|
508
|
+
legacyStores.set(filePath, store);
|
|
498
509
|
}
|
|
499
510
|
return store;
|
|
500
511
|
}
|
|
512
|
+
function shardStoreFor(shardFilePath) {
|
|
513
|
+
let store = shardStores.get(shardFilePath);
|
|
514
|
+
if (store == null) {
|
|
515
|
+
store = createJsonFileStateStore({
|
|
516
|
+
filePath: shardFilePath,
|
|
517
|
+
defaultState: DEFAULT_SHARD,
|
|
518
|
+
updatedAtKey: "updatedAt",
|
|
519
|
+
});
|
|
520
|
+
shardStores.set(shardFilePath, store);
|
|
521
|
+
}
|
|
522
|
+
return store;
|
|
523
|
+
}
|
|
524
|
+
function shardFilePath(registryDir, process) {
|
|
525
|
+
return join(registryDir, `${process}.json`);
|
|
526
|
+
}
|
|
527
|
+
/** Registry root directory — one shard file per process under this path. */
|
|
501
528
|
function defaultLogPersistRegistryPath(registryDir) {
|
|
502
|
-
return join(registryDir, "log-persist-registry
|
|
529
|
+
return join(registryDir, "log-persist-registry");
|
|
530
|
+
}
|
|
531
|
+
async function readShardedLogPersistRegistry(registryDir) {
|
|
532
|
+
await mkdir(registryDir, { recursive: true });
|
|
533
|
+
let entries;
|
|
534
|
+
try {
|
|
535
|
+
entries = await readdir(registryDir);
|
|
536
|
+
}
|
|
537
|
+
catch {
|
|
538
|
+
return { ...DEFAULT_REGISTRY };
|
|
539
|
+
}
|
|
540
|
+
const processes = {};
|
|
541
|
+
let service = "";
|
|
542
|
+
let updatedAt = new Date(0).toISOString();
|
|
543
|
+
for (const name of entries) {
|
|
544
|
+
if (!name.endsWith(".json")) {
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
const processName = name.slice(0, -".json".length);
|
|
548
|
+
if (processName === "" || processName.startsWith("_")) {
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
try {
|
|
552
|
+
const raw = await readFile(join(registryDir, name), "utf8");
|
|
553
|
+
const shard = JSON.parse(raw);
|
|
554
|
+
if (shard.service != null && shard.service !== "") {
|
|
555
|
+
service = shard.service;
|
|
556
|
+
}
|
|
557
|
+
if (shard.updatedAt != null && shard.updatedAt > updatedAt) {
|
|
558
|
+
updatedAt = shard.updatedAt;
|
|
559
|
+
}
|
|
560
|
+
processes[processName] = {
|
|
561
|
+
pid: shard.pid ?? 0,
|
|
562
|
+
enabledAt: shard.enabledAt ?? new Date(0).toISOString(),
|
|
563
|
+
lastHeartbeatAt: shard.lastHeartbeatAt ?? new Date(0).toISOString(),
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
catch {
|
|
567
|
+
persistLogger.warn("registry shard read skipped — corrupt or missing", {
|
|
568
|
+
registryDir,
|
|
569
|
+
shard: name,
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return { updatedAt, service, processes };
|
|
503
574
|
}
|
|
504
575
|
async function registerLogPersistProcess(input) {
|
|
505
576
|
const now = new Date().toISOString();
|
|
@@ -508,12 +579,22 @@ async function registerLogPersistProcess(input) {
|
|
|
508
579
|
enabledAt: now,
|
|
509
580
|
lastHeartbeatAt: now,
|
|
510
581
|
};
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
582
|
+
if (isLegacyRegistryFile(input.registryFilePath)) {
|
|
583
|
+
await legacyStoreFor(input.registryFilePath).write({
|
|
584
|
+
service: input.service,
|
|
585
|
+
processes: {
|
|
586
|
+
[input.process]: record,
|
|
587
|
+
},
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
await shardStoreFor(shardFilePath(input.registryFilePath, input.process)).write({
|
|
592
|
+
service: input.service,
|
|
593
|
+
pid: record.pid,
|
|
594
|
+
enabledAt: record.enabledAt,
|
|
595
|
+
lastHeartbeatAt: record.lastHeartbeatAt,
|
|
596
|
+
});
|
|
597
|
+
}
|
|
517
598
|
persistLogger.info("registry process registered", {
|
|
518
599
|
registryFilePath: input.registryFilePath,
|
|
519
600
|
service: input.service,
|
|
@@ -522,42 +603,77 @@ async function registerLogPersistProcess(input) {
|
|
|
522
603
|
});
|
|
523
604
|
}
|
|
524
605
|
async function heartbeatLogPersistProcess(input) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
606
|
+
if (isLegacyRegistryFile(input.registryFilePath)) {
|
|
607
|
+
const current = await legacyStoreFor(input.registryFilePath).read();
|
|
608
|
+
const existing = current.processes[input.process];
|
|
609
|
+
if (existing == null) {
|
|
610
|
+
persistLogger.warn("registry heartbeat skipped — process not registered", {
|
|
611
|
+
registryFilePath: input.registryFilePath,
|
|
612
|
+
process: input.process,
|
|
613
|
+
});
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
await legacyStoreFor(input.registryFilePath).write({
|
|
617
|
+
processes: {
|
|
618
|
+
[input.process]: {
|
|
619
|
+
...existing,
|
|
620
|
+
lastHeartbeatAt: new Date().toISOString(),
|
|
621
|
+
},
|
|
622
|
+
},
|
|
623
|
+
});
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const store = shardStoreFor(shardFilePath(input.registryFilePath, input.process));
|
|
627
|
+
const current = await store.read();
|
|
628
|
+
if (current.pid === 0) {
|
|
528
629
|
persistLogger.warn("registry heartbeat skipped — process not registered", {
|
|
529
630
|
registryFilePath: input.registryFilePath,
|
|
530
631
|
process: input.process,
|
|
531
632
|
});
|
|
532
633
|
return;
|
|
533
634
|
}
|
|
534
|
-
await
|
|
535
|
-
|
|
536
|
-
[input.process]: {
|
|
537
|
-
...existing,
|
|
538
|
-
lastHeartbeatAt: new Date().toISOString(),
|
|
539
|
-
},
|
|
540
|
-
},
|
|
635
|
+
await store.write({
|
|
636
|
+
lastHeartbeatAt: new Date().toISOString(),
|
|
541
637
|
});
|
|
542
638
|
}
|
|
543
639
|
async function unregisterLogPersistProcess(input) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
640
|
+
if (isLegacyRegistryFile(input.registryFilePath)) {
|
|
641
|
+
const current = await legacyStoreFor(input.registryFilePath).read();
|
|
642
|
+
const existing = current.processes[input.process];
|
|
643
|
+
if (existing == null) {
|
|
644
|
+
persistLogger.warn("registry unregister skipped — process not found", {
|
|
645
|
+
registryFilePath: input.registryFilePath,
|
|
646
|
+
process: input.process,
|
|
647
|
+
});
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
await legacyStoreFor(input.registryFilePath).write({
|
|
651
|
+
processes: {
|
|
652
|
+
[input.process]: {
|
|
653
|
+
...existing,
|
|
654
|
+
pid: 0,
|
|
655
|
+
lastHeartbeatAt: new Date(0).toISOString(),
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
});
|
|
659
|
+
persistLogger.info("registry process unregistered", {
|
|
660
|
+
registryFilePath: input.registryFilePath,
|
|
661
|
+
process: input.process,
|
|
662
|
+
});
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
const store = shardStoreFor(shardFilePath(input.registryFilePath, input.process));
|
|
666
|
+
const current = await store.read();
|
|
667
|
+
if (current.pid === 0) {
|
|
547
668
|
persistLogger.warn("registry unregister skipped — process not found", {
|
|
548
669
|
registryFilePath: input.registryFilePath,
|
|
549
670
|
process: input.process,
|
|
550
671
|
});
|
|
551
672
|
return;
|
|
552
673
|
}
|
|
553
|
-
await
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
...existing,
|
|
557
|
-
pid: 0,
|
|
558
|
-
lastHeartbeatAt: new Date(0).toISOString(),
|
|
559
|
-
},
|
|
560
|
-
},
|
|
674
|
+
await store.write({
|
|
675
|
+
pid: 0,
|
|
676
|
+
lastHeartbeatAt: new Date(0).toISOString(),
|
|
561
677
|
});
|
|
562
678
|
persistLogger.info("registry process unregistered", {
|
|
563
679
|
registryFilePath: input.registryFilePath,
|
|
@@ -565,7 +681,10 @@ async function unregisterLogPersistProcess(input) {
|
|
|
565
681
|
});
|
|
566
682
|
}
|
|
567
683
|
async function readLogPersistRegistry(registryFilePath) {
|
|
568
|
-
|
|
684
|
+
if (isLegacyRegistryFile(registryFilePath)) {
|
|
685
|
+
return legacyStoreFor(registryFilePath).read();
|
|
686
|
+
}
|
|
687
|
+
return readShardedLogPersistRegistry(registryFilePath);
|
|
569
688
|
}
|
|
570
689
|
|
|
571
690
|
var logPersistRegistry = /*#__PURE__*/Object.freeze({
|
|
@@ -1359,4 +1478,4 @@ function resolveLogPersistRegistryPath(registryDir) {
|
|
|
1359
1478
|
}
|
|
1360
1479
|
|
|
1361
1480
|
export { logPersistEnabledFromEnv as a, readEnv as b, requireEnv as c, createJsonFileStateStore as d, disableLogPersist as e, enableLogPersist as f, ensureLogPersistFromEnv as g, envBool as h, envInt as i, envMs as j, envNumber as k, loadEnvFiles as l, envPort as m, getLogPersistStats as n, parseEnvLine as o, parseEnvFile as p, pollUntil as q, resolveProjectRootByPackageName as r, resolveLogPersistRegistryPath as s, resolveProjectRootFromModule as t, snapshotLogPersistReady as u, validateLogPersistPreloadEnv as v, waitForLogPersistReady as w };
|
|
1362
|
-
//# sourceMappingURL=enable-log-persist-
|
|
1481
|
+
//# sourceMappingURL=enable-log-persist-BH-tbKEj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enable-log-persist-BH-tbKEj.js","sources":["../../src/node/env/require-env.ts","../../src/node/env/env-parsers.ts","../../src/node/env/load-env.ts","../../src/node/env/project-root.ts","../../src/node/fs/json-state-store.ts","../../src/node/readiness/poll-until.ts","../../src/shared/log/log-persist.config.ts","../../src/shared/log/log-persist-batch-id.ts","../../src/shared/log/log-persist-logger.ts","../../src/shared/log/log-persist-flush.ts","../../src/shared/log/log-persist-registry.ts","../../src/shared/log/log-persist.ts","../../src/shared/log/enable-log-persist.ts"],"sourcesContent":["export function readEnv(name: string, env: NodeJS.ProcessEnv = process.env): string | undefined {\n const value = env[name]?.trim();\n if (value == null || value === \"\") {\n return undefined;\n }\n return value;\n}\n\nexport function requireEnv(name: string, env: NodeJS.ProcessEnv = process.env): string {\n const value = readEnv(name, env);\n if (value == null) {\n throw new Error(`Missing required environment variable: ${name}`);\n }\n return value;\n}\n","import { readEnv } from \"./require-env\";\n\nexport interface EnvIntOptions {\n env?: NodeJS.ProcessEnv;\n min?: number;\n max?: number;\n}\n\nexport function envInt(name: string, defaultValue: number, options?: EnvIntOptions): number {\n const env = options?.env ?? process.env;\n const raw = readEnv(name, env);\n if (raw == null) {\n return defaultValue;\n }\n\n const value = Number(raw);\n if (!Number.isInteger(value)) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n const min = options?.min;\n if (min != null && value < min) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n const max = options?.max;\n if (max != null && value > max) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n return value;\n}\n\nexport function envMs(name: string, defaultMs: number, options?: EnvIntOptions): number {\n return envInt(name, defaultMs, { ...options, min: options?.min ?? 1 });\n}\n\nexport function envPort(defaultPort = 3100, options?: EnvIntOptions & { envKey?: string }): number {\n const envKey = options?.envKey ?? \"PORT\";\n return envInt(envKey, defaultPort, { ...options, min: 1, max: 65535 });\n}\n\nexport interface EnvNumberOptions {\n env?: NodeJS.ProcessEnv;\n min?: number;\n /** When true, use Math.floor on parsed value. */\n floor?: boolean;\n}\n\nexport function envNumber(name: string, defaultValue: number, options?: EnvNumberOptions): number {\n const env = options?.env ?? process.env;\n const raw = readEnv(name, env);\n if (raw == null) {\n return defaultValue;\n }\n\n const value = Number(raw);\n if (!Number.isFinite(value)) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n const min = options?.min;\n const resolved = options?.floor === true ? Math.floor(value) : value;\n if (min != null && resolved < min) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n return resolved;\n}\n\nexport function envBool(name: string, defaultValue = false, env: NodeJS.ProcessEnv = process.env): boolean {\n const raw = readEnv(name, env)?.toLowerCase();\n if (raw == null) {\n return defaultValue;\n }\n return raw === \"1\" || raw === \"true\" || raw === \"yes\";\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nconst DEFAULT_ENV_FILES = [\".env.local\", \".env\"] as const;\n\nexport interface LoadEnvFilesOptions {\n /** Files to load in order (later files do not override existing env). */\n files?: readonly string[];\n env?: NodeJS.ProcessEnv;\n /** Called after all files are merged (e.g. legacy alias normalization). */\n afterLoad?: () => void;\n}\n\nfunction stripQuotes(value: string): string {\n return value.replace(/^[\"']|[\"']$/g, \"\");\n}\n\n/** Parse one KEY=VALUE line; returns null if line should be skipped. */\nexport function parseEnvLine(line: string): { key: string; value: string } | null {\n const trimmed = line.trim();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) {\n return null;\n }\n\n const eq = trimmed.indexOf(\"=\");\n if (eq === -1) {\n return null;\n }\n\n const key = trimmed.slice(0, eq).trim();\n const raw = trimmed.slice(eq + 1).trim();\n return { key, value: stripQuotes(raw) };\n}\n\nexport function parseEnvFileContent(content: string, env: NodeJS.ProcessEnv): void {\n for (const line of content.split(\"\\n\")) {\n const parsed = parseEnvLine(line);\n if (parsed == null) {\n continue;\n }\n if (env[parsed.key] == null || env[parsed.key] === \"\") {\n env[parsed.key] = parsed.value;\n }\n }\n}\n\nexport function parseEnvFile(filePath: string, env: NodeJS.ProcessEnv): void {\n if (!existsSync(filePath)) {\n return;\n }\n parseEnvFileContent(readFileSync(filePath, \"utf8\"), env);\n}\n\n/**\n * Load `.env.local` then `.env` into `process.env` (or `options.env`).\n * Existing non-empty env values are not overwritten.\n */\nexport function loadEnvFiles(root: string, options?: LoadEnvFilesOptions): void {\n const env = options?.env ?? process.env;\n const files = options?.files ?? DEFAULT_ENV_FILES;\n\n for (const name of files) {\n parseEnvFile(resolve(root, name), env);\n }\n\n options?.afterLoad?.();\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Resolve project root from a module URL (typically `import.meta.url`).\n * @param relativePath Path relative to the module file (default `\"..\"` = parent directory).\n */\nexport function resolveProjectRootFromModule(importMetaUrl: string, relativePath = \"..\"): string {\n return resolve(fileURLToPath(new URL(relativePath, importMetaUrl)));\n}\n\n/**\n * Walk upward from `importMetaUrl` until a `package.json` with matching `name` is found.\n * Use for esbuild bundles under `dist/` where a single `..` hop lands in `dist/`, not repo root.\n */\nexport function resolveProjectRootByPackageName(importMetaUrl: string, packageName: string): string {\n let dir = dirname(fileURLToPath(importMetaUrl));\n for (;;) {\n const packageJsonPath = resolve(dir, \"package.json\");\n if (existsSync(packageJsonPath)) {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { name?: string };\n if (pkg.name === packageName) {\n return dir;\n }\n }\n const parent = dirname(dir);\n if (parent === dir) {\n break;\n }\n dir = parent;\n }\n throw new Error(`Could not find package root for \"${packageName}\" from ${importMetaUrl}`);\n}\n","import { mkdir, readFile, rename, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nexport type JsonStatePatch<T extends object, NK extends keyof T> = Partial<Omit<T, NK>> & {\n [K in NK]?: T[K] extends object ? Partial<T[K]> : T[K];\n};\n\nexport interface JsonFileStateStore<T extends object, NK extends keyof T = never> {\n read(): Promise<T>;\n write(patch: JsonStatePatch<T, NK>): Promise<T>;\n reset(): Promise<T>;\n}\n\nexport interface CreateJsonFileStateStoreOptions<T extends object, NK extends keyof T = never> {\n filePath: string;\n defaultState: T;\n /** Top-level keys shallow-merged one level deep on read and write. */\n nestedKeys?: NK[];\n /** When set, assigned `new Date().toISOString()` on write and reset. */\n updatedAtKey?: keyof T;\n}\n\nfunction mergeWithNested<T extends object>(\n defaults: T,\n current: Partial<T> | undefined,\n patch: Partial<T>,\n nestedKeys: (keyof T)[],\n): T {\n const merged = {\n ...defaults,\n ...current,\n ...patch,\n } as T;\n\n for (const key of nestedKeys) {\n const defaultNested = defaults[key];\n if (defaultNested != null && typeof defaultNested === \"object\") {\n (merged as Record<keyof T, unknown>)[key] = {\n ...defaultNested,\n ...(current?.[key] as object | undefined),\n ...(patch[key] as object | undefined),\n };\n }\n }\n\n return merged;\n}\n\nasync function atomicWriteJson(filePath: string, data: unknown): Promise<void> {\n await mkdir(dirname(filePath), { recursive: true });\n const content = `${JSON.stringify(data, null, 2)}\\n`;\n const tempPath = `${filePath}.${process.pid}.tmp`;\n await writeFile(tempPath, content, \"utf8\");\n await rename(tempPath, filePath);\n}\n\n/** JSON file-backed state with optional nested key merge and atomic writes. */\nexport function createJsonFileStateStore<T extends object, NK extends keyof T = never>(\n options: CreateJsonFileStateStoreOptions<T, NK>,\n): JsonFileStateStore<T, NK> {\n const { filePath, defaultState, nestedKeys = [] as NK[], updatedAtKey } = options;\n\n function touchUpdatedAt(state: T): T {\n if (updatedAtKey == null) {\n return state;\n }\n return {\n ...state,\n [updatedAtKey]: new Date().toISOString(),\n };\n }\n\n return {\n async read(): Promise<T> {\n try {\n const raw = await readFile(filePath, \"utf8\");\n const parsed = JSON.parse(raw) as Partial<T>;\n return mergeWithNested(defaultState, parsed, {}, nestedKeys);\n } catch {\n return { ...defaultState };\n }\n },\n\n async write(patch: JsonStatePatch<T, NK>): Promise<T> {\n const current = await this.read();\n const next = touchUpdatedAt(mergeWithNested(defaultState, current, patch as Partial<T>, nestedKeys));\n await atomicWriteJson(filePath, next);\n return next;\n },\n\n async reset(): Promise<T> {\n const next = touchUpdatedAt({ ...defaultState });\n await atomicWriteJson(filePath, next);\n return next;\n },\n };\n}\n","function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport interface PollUntilOptions {\n timeoutMs: number;\n intervalMs?: number;\n until: () => boolean | Promise<boolean>;\n}\n\n/**\n * Poll `until()` until it returns true or `timeoutMs` elapses.\n * @throws Error on timeout\n */\nexport async function pollUntil(options: PollUntilOptions): Promise<void> {\n const intervalMs = options.intervalMs ?? 500;\n const deadline = Date.now() + options.timeoutMs;\n\n while (Date.now() < deadline) {\n if (await options.until()) {\n return;\n }\n await sleep(intervalMs);\n }\n\n throw new Error(`pollUntil timeout after ${options.timeoutMs}ms`);\n}\n","import { envBool, envInt, envMs } from \"../../node/env/env-parsers\";\nimport type { LogPersistConfig } from \"./log-persist.interface\";\n\nexport const LOG_PERSIST_LOADER_KEY = \"LogBatch.0\";\n\nexport const DEFAULT_LOG_PERSIST_CONFIG: LogPersistConfig = {\n fast: {\n maxBufferEntries: 500,\n },\n medium: {\n debounceMs: 5_000,\n maxEntries: 20,\n maxBytes: 512 * 1024,\n maxBufferEntries: 1_000,\n },\n slow: {\n maxEntries: 400,\n maxBytes: 512 * 1024,\n maxAgeMs: 120_000,\n maxBufferEntries: 2_000,\n },\n postTimeoutMs: 30_000,\n shutdownDrainTimeoutMs: 15_000,\n};\n\nexport function resolveLogPersistConfig(partial?: Partial<LogPersistConfig>): LogPersistConfig {\n const defaults = DEFAULT_LOG_PERSIST_CONFIG;\n return {\n fast: { ...defaults.fast, ...partial?.fast },\n medium: { ...defaults.medium, ...partial?.medium },\n slow: { ...defaults.slow, ...partial?.slow },\n postTimeoutMs: partial?.postTimeoutMs ?? defaults.postTimeoutMs,\n shutdownDrainTimeoutMs: partial?.shutdownDrainTimeoutMs ?? defaults.shutdownDrainTimeoutMs,\n };\n}\n\nexport function logPersistEnabledFromEnv(env: NodeJS.ProcessEnv = process.env): boolean {\n return envBool(\"LOG_PERSIST_ENABLED\", false, env);\n}\n\nexport function logPersistServiceFromEnv(env: NodeJS.ProcessEnv = process.env): string | undefined {\n const raw = env.LOG_PERSIST_SERVICE?.trim();\n return raw != null && raw !== \"\" ? raw : undefined;\n}\n\nexport function logPersistProcessFromEnv(env: NodeJS.ProcessEnv = process.env): string | undefined {\n const raw = env.LOG_PERSIST_PROCESS?.trim();\n return raw != null && raw !== \"\" ? raw : undefined;\n}\n\nexport function logPersistRegistryDirFromEnv(env: NodeJS.ProcessEnv = process.env): string | undefined {\n const configured = env.LOG_PERSIST_REGISTRY_DIR?.trim();\n if (configured != null && configured !== \"\") {\n return configured;\n }\n const runtime = env.RUNTIME_DATA_DIR?.trim();\n return runtime != null && runtime !== \"\" ? runtime : undefined;\n}\n\nexport function logPersistConfigFromEnv(env: NodeJS.ProcessEnv = process.env): LogPersistConfig {\n return resolveLogPersistConfig({\n fast: {\n maxBufferEntries: envInt(\"LOG_FAST_MAX_BUFFER_ENTRIES\", DEFAULT_LOG_PERSIST_CONFIG.fast.maxBufferEntries, {\n env,\n min: 1,\n }),\n },\n medium: {\n debounceMs: envMs(\"LOG_MEDIUM_DEBOUNCE_MS\", DEFAULT_LOG_PERSIST_CONFIG.medium.debounceMs, { env }),\n maxEntries: envInt(\"LOG_MEDIUM_MAX_ENTRIES\", DEFAULT_LOG_PERSIST_CONFIG.medium.maxEntries, {\n env,\n min: 1,\n }),\n maxBytes: envInt(\"LOG_MEDIUM_MAX_BYTES\", DEFAULT_LOG_PERSIST_CONFIG.medium.maxBytes, { env, min: 1 }),\n maxBufferEntries: envInt(\n \"LOG_MEDIUM_MAX_BUFFER_ENTRIES\",\n DEFAULT_LOG_PERSIST_CONFIG.medium.maxBufferEntries,\n { env, min: 1 },\n ),\n },\n slow: {\n maxEntries: envInt(\"LOG_SLOW_MAX_ENTRIES\", DEFAULT_LOG_PERSIST_CONFIG.slow.maxEntries, { env, min: 1 }),\n maxBytes: envInt(\"LOG_SLOW_MAX_BYTES\", DEFAULT_LOG_PERSIST_CONFIG.slow.maxBytes, { env, min: 1 }),\n maxAgeMs: envMs(\"LOG_SLOW_MAX_AGE_MS\", DEFAULT_LOG_PERSIST_CONFIG.slow.maxAgeMs, { env }),\n maxBufferEntries: envInt(\"LOG_SLOW_MAX_BUFFER_ENTRIES\", DEFAULT_LOG_PERSIST_CONFIG.slow.maxBufferEntries, {\n env,\n min: 1,\n }),\n },\n postTimeoutMs: envMs(\"LOG_PERSIST_POST_TIMEOUT_MS\", DEFAULT_LOG_PERSIST_CONFIG.postTimeoutMs, { env }),\n shutdownDrainTimeoutMs: envMs(\n \"LOG_PERSIST_SHUTDOWN_DRAIN_MS\",\n DEFAULT_LOG_PERSIST_CONFIG.shutdownDrainTimeoutMs,\n { env },\n ),\n });\n}\n","import { createHash } from \"node:crypto\";\nimport type { LogEntry } from \"./log-manager\";\nimport type { LogPersistLane } from \"./log-persist.interface\";\n\nconst BATCH_ID_VERSION = 1;\n\n/** Stable subset of LogEntry for idempotency hashing (same batch → same key). */\nfunction canonicalLogEntry(entry: LogEntry): Record<string, unknown> {\n return {\n timestamp: entry.timestamp,\n level: entry.level,\n message: entry.message,\n topic: entry.topic,\n module: entry.module,\n traceId: entry.traceId,\n traceParentId: entry.traceParentId ?? null,\n extra: entry.extra ?? null,\n data: entry.data ?? null,\n labels: entry.labels ?? null,\n };\n}\n\n/**\n * Deterministic List.value for a log batch — retries after timeout map to the same row key.\n * SHA-256 over canonical JSON (service + process + lane + entries in order).\n */\nexport function computeLogBatchIdempotencyKey(input: {\n service: string;\n process: string;\n lane: LogPersistLane;\n entries: LogEntry[];\n}): string {\n const payload = {\n v: BATCH_ID_VERSION,\n service: input.service,\n process: input.process,\n lane: input.lane,\n entries: input.entries.map(canonicalLogEntry),\n };\n\n const hash = createHash(\"sha256\").update(JSON.stringify(payload), \"utf8\").digest(\"hex\");\n return `${hash.slice(0, 32)}`;\n}\n","import { createLogger } from \"./create-logger\";\n\n/** User-facing / lifecycle logs — may be persisted like normal app logs. */\nexport const LOG_PERSIST_TOPIC = \"log-persist\";\n\n/** Operational logs from the persist pipeline — never re-offered to avoid feedback loops. */\nexport const LOG_PERSIST_INTERNAL_TOPIC = \"log-persist-internal\";\n\nconst logger = createLogger({ module: \"log-persist\" });\n\nexport function isLogPersistInternalTopic(topic: string | undefined): boolean {\n return topic === LOG_PERSIST_INTERNAL_TOPIC;\n}\n\ntype PersistLogData = Record<string, unknown>;\n\nfunction write(level: \"debug\" | \"info\" | \"warn\" | \"error\", message: string, data?: PersistLogData): void {\n logger[level](message, {\n topic: LOG_PERSIST_INTERNAL_TOPIC,\n ...(data != null ? { data } : {}),\n });\n}\n\nexport const persistLogger = {\n debug: (message: string, data?: PersistLogData) => write(\"debug\", message, data),\n info: (message: string, data?: PersistLogData) => write(\"info\", message, data),\n warn: (message: string, data?: PersistLogData) => write(\"warn\", message, data),\n error: (message: string, data?: PersistLogData) => write(\"error\", message, data),\n};\n\nexport function patchPersistLoggerScope(labels: Record<string, string>): void {\n logger.resetScope({ labels });\n}\n","import { isCreateTargetAlreadyExistsError } from \"../../core.api\";\nimport { postLogListCreate } from \"../../list/list.api\";\nimport { CategoryList } from \"../../list/list.interface\";\nimport type { LogEntry } from \"./log-manager\";\nimport { LOG_PERSIST_LOADER_KEY } from \"./log-persist.config\";\nimport type { BuildLogListDraftInput, LogListDraft } from \"./log-persist.interface\";\nimport { persistLogger } from \"./log-persist-logger\";\n\nexport function estimateEntriesBytes(entries: LogEntry[]): number {\n if (entries.length === 0) {\n return 0;\n }\n try {\n return Buffer.byteLength(JSON.stringify(entries), \"utf8\");\n } catch {\n return entries.length * 512;\n }\n}\n\nexport function buildLogListDraft(input: BuildLogListDraftInput): LogListDraft {\n const { service, process, lane, idempotencyKey, entries } = input;\n const first = entries[0];\n const last = entries[entries.length - 1];\n\n return {\n name: `log-batch:${service}:${process}:${lane}`,\n value: idempotencyKey,\n category: CategoryList.LIST,\n tagList: [\"log\", lane, service],\n details: {\n manifestVersion: 0,\n loaderKey: LOG_PERSIST_LOADER_KEY,\n meta: JSON.stringify({\n service,\n process,\n pid: globalThis.process.pid,\n lane,\n count: entries.length,\n from: first?.timestamp ?? null,\n to: last?.timestamp ?? null,\n flushedAt: Date.now(),\n idempotencyKey,\n }),\n preview: first?.message ?? \"\",\n items: entries,\n },\n };\n}\n\nasync function withTimeout<T>(promise: Promise<T>, timeoutMs: number, label: string): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n return await Promise.race([\n promise,\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error(`${label} timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n }),\n ]);\n } finally {\n if (timer != null) {\n clearTimeout(timer);\n }\n }\n}\n\nexport async function postLogBatch(draft: LogListDraft, postTimeoutMs: number): Promise<void> {\n try {\n const result = await withTimeout(\n postLogListCreate({\n name: draft.name,\n value: draft.value,\n category: draft.category,\n details: draft.details,\n }),\n postTimeoutMs,\n \"postLogListCreate\",\n );\n\n if (!result.success) {\n const message = result.error?.message ?? \"postLogListCreate failed\";\n persistLogger.error(\"post log batch failed\", {\n idempotencyKey: draft.value,\n name: draft.name,\n error: message,\n });\n throw new Error(message);\n }\n } catch (error) {\n if (isCreateTargetAlreadyExistsError(error)) {\n persistLogger.error(\"post log batch idempotent duplicate — treating as success\", {\n idempotencyKey: draft.value,\n name: draft.name,\n });\n return;\n }\n throw error;\n }\n}\n\n/** Take a prefix of entries that fits within maxBytes. */\nexport function takeEntriesWithinBytes(entries: LogEntry[], maxBytes: number): LogEntry[] {\n if (entries.length === 0) {\n return [];\n }\n\n const taken: LogEntry[] = [];\n for (const entry of entries) {\n const candidate = [...taken, entry];\n if (taken.length > 0 && estimateEntriesBytes(candidate) > maxBytes) {\n break;\n }\n taken.push(entry);\n }\n\n const result = taken.length > 0 ? taken : [entries[0]];\n if (result.length < entries.length) {\n persistLogger.warn(\"trimmed batch to maxBytes\", {\n requested: entries.length,\n taken: result.length,\n maxBytes,\n takenBytes: estimateEntriesBytes(result),\n });\n }\n\n return result;\n}\n","import { mkdir, readdir, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { createJsonFileStateStore } from \"../../node/fs/json-state-store\";\nimport type { LogPersistProcessRecord, LogPersistRegistryState } from \"./log-persist.interface\";\nimport { persistLogger } from \"./log-persist-logger\";\n\nconst DEFAULT_REGISTRY: LogPersistRegistryState = {\n updatedAt: new Date(0).toISOString(),\n service: \"\",\n processes: {},\n};\n\n/** Per-process shard — each process owns one file; no cross-process RMW. */\ninterface LogPersistProcessShard extends LogPersistProcessRecord {\n service: string;\n updatedAt: string;\n}\n\nconst DEFAULT_SHARD: LogPersistProcessShard = {\n service: \"\",\n updatedAt: new Date(0).toISOString(),\n pid: 0,\n enabledAt: new Date(0).toISOString(),\n lastHeartbeatAt: new Date(0).toISOString(),\n};\n\nconst legacyStores = new Map<\n string,\n ReturnType<typeof createJsonFileStateStore<LogPersistRegistryState, \"processes\">>\n>();\n\nconst shardStores = new Map<string, ReturnType<typeof createJsonFileStateStore<LogPersistProcessShard>>>();\n\nfunction isLegacyRegistryFile(registryPath: string): boolean {\n return registryPath.endsWith(\".json\");\n}\n\nfunction legacyStoreFor(filePath: string) {\n let store = legacyStores.get(filePath);\n if (store == null) {\n store = createJsonFileStateStore<LogPersistRegistryState, \"processes\">({\n filePath,\n defaultState: DEFAULT_REGISTRY,\n nestedKeys: [\"processes\"],\n updatedAtKey: \"updatedAt\",\n });\n legacyStores.set(filePath, store);\n }\n return store;\n}\n\nfunction shardStoreFor(shardFilePath: string) {\n let store = shardStores.get(shardFilePath);\n if (store == null) {\n store = createJsonFileStateStore<LogPersistProcessShard>({\n filePath: shardFilePath,\n defaultState: DEFAULT_SHARD,\n updatedAtKey: \"updatedAt\",\n });\n shardStores.set(shardFilePath, store);\n }\n return store;\n}\n\nfunction shardFilePath(registryDir: string, process: string): string {\n return join(registryDir, `${process}.json`);\n}\n\n/** Registry root directory — one shard file per process under this path. */\nexport function defaultLogPersistRegistryPath(registryDir: string): string {\n return join(registryDir, \"log-persist-registry\");\n}\n\nasync function readShardedLogPersistRegistry(registryDir: string): Promise<LogPersistRegistryState> {\n await mkdir(registryDir, { recursive: true });\n\n let entries: string[];\n try {\n entries = await readdir(registryDir);\n } catch {\n return { ...DEFAULT_REGISTRY };\n }\n\n const processes: Record<string, LogPersistProcessRecord> = {};\n let service = \"\";\n let updatedAt = new Date(0).toISOString();\n\n for (const name of entries) {\n if (!name.endsWith(\".json\")) {\n continue;\n }\n\n const processName = name.slice(0, -\".json\".length);\n if (processName === \"\" || processName.startsWith(\"_\")) {\n continue;\n }\n\n try {\n const raw = await readFile(join(registryDir, name), \"utf8\");\n const shard = JSON.parse(raw) as Partial<LogPersistProcessShard>;\n if (shard.service != null && shard.service !== \"\") {\n service = shard.service;\n }\n if (shard.updatedAt != null && shard.updatedAt > updatedAt) {\n updatedAt = shard.updatedAt;\n }\n processes[processName] = {\n pid: shard.pid ?? 0,\n enabledAt: shard.enabledAt ?? new Date(0).toISOString(),\n lastHeartbeatAt: shard.lastHeartbeatAt ?? new Date(0).toISOString(),\n };\n } catch {\n persistLogger.warn(\"registry shard read skipped — corrupt or missing\", {\n registryDir,\n shard: name,\n });\n }\n }\n\n return { updatedAt, service, processes };\n}\n\nexport async function registerLogPersistProcess(input: {\n registryFilePath: string;\n service: string;\n process: string;\n}): Promise<void> {\n const now = new Date().toISOString();\n const record: LogPersistProcessRecord = {\n pid: process.pid,\n enabledAt: now,\n lastHeartbeatAt: now,\n };\n\n if (isLegacyRegistryFile(input.registryFilePath)) {\n await legacyStoreFor(input.registryFilePath).write({\n service: input.service,\n processes: {\n [input.process]: record,\n },\n });\n } else {\n await shardStoreFor(shardFilePath(input.registryFilePath, input.process)).write({\n service: input.service,\n pid: record.pid,\n enabledAt: record.enabledAt,\n lastHeartbeatAt: record.lastHeartbeatAt,\n });\n }\n\n persistLogger.info(\"registry process registered\", {\n registryFilePath: input.registryFilePath,\n service: input.service,\n process: input.process,\n pid: record.pid,\n });\n}\n\nexport async function heartbeatLogPersistProcess(input: { registryFilePath: string; process: string }): Promise<void> {\n if (isLegacyRegistryFile(input.registryFilePath)) {\n const current = await legacyStoreFor(input.registryFilePath).read();\n const existing = current.processes[input.process];\n if (existing == null) {\n persistLogger.warn(\"registry heartbeat skipped — process not registered\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n return;\n }\n\n await legacyStoreFor(input.registryFilePath).write({\n processes: {\n [input.process]: {\n ...existing,\n lastHeartbeatAt: new Date().toISOString(),\n },\n },\n });\n return;\n }\n\n const store = shardStoreFor(shardFilePath(input.registryFilePath, input.process));\n const current = await store.read();\n if (current.pid === 0) {\n persistLogger.warn(\"registry heartbeat skipped — process not registered\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n return;\n }\n\n await store.write({\n lastHeartbeatAt: new Date().toISOString(),\n });\n}\n\nexport async function unregisterLogPersistProcess(input: { registryFilePath: string; process: string }): Promise<void> {\n if (isLegacyRegistryFile(input.registryFilePath)) {\n const current = await legacyStoreFor(input.registryFilePath).read();\n const existing = current.processes[input.process];\n if (existing == null) {\n persistLogger.warn(\"registry unregister skipped — process not found\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n return;\n }\n\n await legacyStoreFor(input.registryFilePath).write({\n processes: {\n [input.process]: {\n ...existing,\n pid: 0,\n lastHeartbeatAt: new Date(0).toISOString(),\n },\n },\n });\n\n persistLogger.info(\"registry process unregistered\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n return;\n }\n\n const store = shardStoreFor(shardFilePath(input.registryFilePath, input.process));\n const current = await store.read();\n if (current.pid === 0) {\n persistLogger.warn(\"registry unregister skipped — process not found\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n return;\n }\n\n await store.write({\n pid: 0,\n lastHeartbeatAt: new Date(0).toISOString(),\n });\n\n persistLogger.info(\"registry process unregistered\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n}\n\nexport async function readLogPersistRegistry(registryFilePath: string): Promise<LogPersistRegistryState> {\n if (isLegacyRegistryFile(registryFilePath)) {\n return legacyStoreFor(registryFilePath).read();\n }\n return readShardedLogPersistRegistry(registryFilePath);\n}\n","import { type LogEntry, LogLevel } from \"./log-manager\";\nimport { DEFAULT_LOG_PERSIST_CONFIG, resolveLogPersistConfig } from \"./log-persist.config\";\nimport type {\n EnableLogPersistOptions,\n LogPersistConfig,\n LogPersistLane,\n LogPersistStats,\n} from \"./log-persist.interface\";\nimport { computeLogBatchIdempotencyKey } from \"./log-persist-batch-id\";\nimport { buildLogListDraft, estimateEntriesBytes, postLogBatch, takeEntriesWithinBytes } from \"./log-persist-flush\";\nimport { registerLogPersistOffer } from \"./log-persist-hook\";\nimport { isLogPersistInternalTopic, patchPersistLoggerScope, persistLogger } from \"./log-persist-logger\";\nimport { heartbeatLogPersistProcess } from \"./log-persist-registry\";\n\nconst FAST_RETRY_INTERVAL_MS = 5_000;\nconst HEARTBEAT_INTERVAL_MS = 30_000;\n\nfunction routeLane(level: LogLevel): LogPersistLane {\n if (level === LogLevel.CRITICAL) {\n return \"fast\";\n }\n if (level === LogLevel.ERROR || level === LogLevel.SUCCESS) {\n return \"medium\";\n }\n return \"slow\";\n}\n\nclass LogPersist {\n private static instance: LogPersist | null = null;\n\n private enabled = false;\n private draining = false;\n private service: string | null = null;\n private processName: string | null = null;\n private registryFilePath: string | null = null;\n private config: LogPersistConfig = DEFAULT_LOG_PERSIST_CONFIG;\n\n private fastQueue: LogEntry[] = [];\n private fastRetryQueue: LogEntry[] = [];\n private mediumQueue: LogEntry[] = [];\n private slowQueue: LogEntry[] = [];\n\n private mediumDebounceTimer: ReturnType<typeof setTimeout> | null = null;\n private slowQueueStartedAt: number | null = null;\n private fastRetryTimer: ReturnType<typeof setTimeout> | null = null;\n private heartbeatTimer: ReturnType<typeof setInterval> | null = null;\n private lastHeartbeatAt = 0;\n\n private laneFlushing: Record<LogPersistLane, boolean> = {\n fast: false,\n medium: false,\n slow: false,\n };\n\n private consecutiveFailures: Record<LogPersistLane, number> = {\n fast: 0,\n medium: 0,\n slow: 0,\n };\n\n private lastFlushAt: Record<LogPersistLane, string | null> = {\n fast: null,\n medium: null,\n slow: null,\n };\n\n private lastError: string | null = null;\n private lastErrorAt: string | null = null;\n private shutdownHookInstalled = false;\n private shutdownPromise: Promise<void> | null = null;\n\n static getInstance(): LogPersist {\n LogPersist.instance ??= new LogPersist();\n return LogPersist.instance;\n }\n\n async enable(options: EnableLogPersistOptions): Promise<void> {\n if (this.enabled) {\n persistLogger.warn(\"log persist core enable skipped — already enabled\", {\n service: this.service,\n process: this.processName,\n });\n return;\n }\n\n this.service = options.service;\n this.processName = options.process;\n this.registryFilePath = options.registryFilePath ?? null;\n this.config = resolveLogPersistConfig(options.config);\n this.draining = false;\n this.shutdownPromise = null;\n this.consecutiveFailures = { fast: 0, medium: 0, slow: 0 };\n this.lastError = null;\n this.lastErrorAt = null;\n this.enabled = true;\n\n patchPersistLoggerScope({\n service: options.service,\n process: options.process,\n });\n\n persistLogger.info(\"log persist core enabled\", {\n service: options.service,\n process: options.process,\n registryFilePath: this.registryFilePath,\n config: this.config,\n pid: process.pid,\n });\n\n registerLogPersistOffer((entry) => {\n this.offer(entry);\n });\n\n if (this.registryFilePath != null) {\n const { registerLogPersistProcess } = await import(\"./log-persist-registry\");\n await registerLogPersistProcess({\n registryFilePath: this.registryFilePath,\n service: options.service,\n process: options.process,\n });\n this.startHeartbeat();\n }\n\n this.installShutdownHook();\n }\n\n async disable(): Promise<void> {\n if (!this.enabled && !this.draining) {\n persistLogger.debug(\"disable skipped — not enabled\");\n return;\n }\n\n persistLogger.info(\"log persist core disabling\", this.queueSnapshot());\n this.cancelMediumDebounce();\n this.stopHeartbeat();\n await this.shutdown();\n persistLogger.info(\"log persist core disabled\");\n }\n\n offer(entry: LogEntry): void {\n if (isLogPersistInternalTopic(entry.topic)) {\n return;\n }\n\n if (!this.enabled || this.draining || this.service == null || this.processName == null) {\n return;\n }\n\n void this.touchRegistryHeartbeat();\n\n const lane = routeLane(entry.level);\n\n if (lane === \"fast\") {\n this.fastQueue.push(entry);\n this.evictFastOverflow();\n void this.flushFast();\n return;\n }\n\n if (lane === \"medium\") {\n this.mediumQueue.push(entry);\n this.evictMediumOverflow();\n this.scheduleMediumFlush();\n return;\n }\n\n this.slowQueue.push(entry);\n if (this.slowQueueStartedAt == null) {\n this.slowQueueStartedAt = Date.now();\n }\n this.evictSlowOverflow();\n this.scheduleSlowFlush();\n }\n\n getStats(): LogPersistStats {\n return {\n enabled: this.enabled,\n draining: this.draining,\n service: this.service,\n process: this.processName,\n queues: {\n fast: this.fastQueue.length,\n fastRetry: this.fastRetryQueue.length,\n medium: this.mediumQueue.length,\n slow: this.slowQueue.length,\n },\n queueBytes: {\n fast: estimateEntriesBytes(this.fastQueue),\n fastRetry: estimateEntriesBytes(this.fastRetryQueue),\n medium: estimateEntriesBytes(this.mediumQueue),\n slow: estimateEntriesBytes(this.slowQueue),\n },\n mediumDebouncePending: this.mediumDebounceTimer != null,\n laneFlushing: { ...this.laneFlushing },\n consecutiveFailures: { ...this.consecutiveFailures },\n config: this.config,\n lastFlushAt: { ...this.lastFlushAt },\n lastError: this.lastError,\n lastErrorAt: this.lastErrorAt,\n };\n }\n\n async shutdown(): Promise<void> {\n if (this.shutdownPromise != null) {\n return this.shutdownPromise;\n }\n\n this.shutdownPromise = this.shutdownInner();\n return this.shutdownPromise;\n }\n\n private async shutdownInner(): Promise<void> {\n if (this.draining) {\n return;\n }\n\n this.draining = true;\n this.enabled = false;\n registerLogPersistOffer(null);\n\n persistLogger.info(\"shutdown flush started\", this.queueSnapshot());\n\n this.cancelMediumDebounce();\n await this.drainQueues(this.config.shutdownDrainTimeoutMs);\n\n if (this.registryFilePath != null && this.processName != null) {\n const { unregisterLogPersistProcess } = await import(\"./log-persist-registry\");\n await unregisterLogPersistProcess({\n registryFilePath: this.registryFilePath,\n process: this.processName,\n });\n }\n\n if (this.hasQueued()) {\n persistLogger.warn(\"shutdown drain incomplete — queued logs dropped\", {\n ...this.queueSnapshot(),\n shutdownDrainTimeoutMs: this.config.shutdownDrainTimeoutMs,\n });\n this.fastQueue = [];\n this.fastRetryQueue = [];\n this.mediumQueue = [];\n this.slowQueue = [];\n this.slowQueueStartedAt = null;\n }\n\n persistLogger.info(\"shutdown flush completed\", this.queueSnapshot());\n }\n\n private hasQueued(): boolean {\n return (\n this.fastQueue.length > 0 ||\n this.fastRetryQueue.length > 0 ||\n this.mediumQueue.length > 0 ||\n this.slowQueue.length > 0\n );\n }\n\n private async drainQueues(timeoutMs: number): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (this.hasQueued() && Date.now() < deadline) {\n await this.flushFast();\n await this.flushMedium();\n await this.flushSlow();\n }\n }\n\n private recordLaneError(lane: LogPersistLane, error: unknown): void {\n const message = error instanceof Error ? error.message : String(error);\n this.lastError = message;\n this.lastErrorAt = new Date().toISOString();\n this.consecutiveFailures[lane] += 1;\n }\n\n private recordLaneSuccess(lane: LogPersistLane): void {\n this.lastError = null;\n this.consecutiveFailures[lane] = 0;\n }\n\n private queueSnapshot(): Record<string, unknown> {\n return {\n queues: {\n fast: this.fastQueue.length,\n fastRetry: this.fastRetryQueue.length,\n medium: this.mediumQueue.length,\n slow: this.slowQueue.length,\n },\n queueBytes: {\n fast: estimateEntriesBytes(this.fastQueue),\n fastRetry: estimateEntriesBytes(this.fastRetryQueue),\n medium: estimateEntriesBytes(this.mediumQueue),\n slow: estimateEntriesBytes(this.slowQueue),\n },\n laneFlushing: { ...this.laneFlushing },\n consecutiveFailures: { ...this.consecutiveFailures },\n lastError: this.lastError,\n };\n }\n\n private installShutdownHook(): void {\n if (this.shutdownHookInstalled) {\n return;\n }\n this.shutdownHookInstalled = true;\n\n const handler = (signal: NodeJS.Signals) => {\n persistLogger.info(\"shutdown signal received\", { signal });\n void this.shutdown();\n };\n process.once(\"SIGTERM\", handler);\n process.once(\"SIGINT\", handler);\n }\n\n private startHeartbeat(): void {\n this.stopHeartbeat();\n this.heartbeatTimer = setInterval(() => {\n void this.touchRegistryHeartbeat(true);\n }, HEARTBEAT_INTERVAL_MS);\n this.heartbeatTimer.unref?.();\n }\n\n private stopHeartbeat(): void {\n if (this.heartbeatTimer != null) {\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = null;\n }\n }\n\n private async touchRegistryHeartbeat(force = false): Promise<void> {\n if (this.registryFilePath == null || this.processName == null) {\n return;\n }\n const now = Date.now();\n if (!force && now - this.lastHeartbeatAt < HEARTBEAT_INTERVAL_MS) {\n return;\n }\n this.lastHeartbeatAt = now;\n await heartbeatLogPersistProcess({\n registryFilePath: this.registryFilePath,\n process: this.processName,\n });\n }\n\n private scheduleMediumFlush(): void {\n const { debounceMs, maxEntries, maxBytes } = this.config.medium;\n const queueBytes = estimateEntriesBytes(this.mediumQueue);\n if (this.mediumQueue.length >= maxEntries || queueBytes >= maxBytes) {\n persistLogger.warn(\"medium flush scheduled — threshold\", {\n reason: this.mediumQueue.length >= maxEntries ? \"maxEntries\" : \"maxBytes\",\n queueLength: this.mediumQueue.length,\n maxEntries,\n queueBytes,\n maxBytes,\n });\n this.cancelMediumDebounce();\n void this.flushMedium();\n return;\n }\n\n if (this.mediumDebounceTimer == null && this.mediumQueue.length > 0) {\n persistLogger.debug(\"medium flush debounce scheduled\", {\n debounceMs,\n queueLength: this.mediumQueue.length,\n queueBytes,\n });\n this.mediumDebounceTimer = setTimeout(() => {\n this.mediumDebounceTimer = null;\n persistLogger.debug(\"medium flush debounce fired\");\n void this.flushMedium();\n }, debounceMs);\n this.mediumDebounceTimer.unref?.();\n }\n }\n\n private cancelMediumDebounce(): void {\n if (this.mediumDebounceTimer != null) {\n clearTimeout(this.mediumDebounceTimer);\n this.mediumDebounceTimer = null;\n persistLogger.debug(\"medium flush debounce cancelled\");\n }\n }\n\n private scheduleSlowFlush(): void {\n const { maxEntries, maxBytes, maxAgeMs } = this.config.slow;\n const queueBytes = estimateEntriesBytes(this.slowQueue);\n const ageMs = this.slowQueueStartedAt != null ? Date.now() - this.slowQueueStartedAt : 0;\n if (this.slowQueue.length >= maxEntries || queueBytes >= maxBytes || ageMs >= maxAgeMs) {\n persistLogger.debug(\"slow flush scheduled — threshold\", {\n reason:\n this.slowQueue.length >= maxEntries\n ? \"maxEntries\"\n : queueBytes >= maxBytes\n ? \"maxBytes\"\n : \"maxAgeMs\",\n queueLength: this.slowQueue.length,\n maxEntries,\n queueBytes,\n maxBytes,\n ageMs,\n maxAgeMs,\n });\n void this.flushSlow();\n }\n }\n\n private evictFastOverflow(): void {\n const { maxBufferEntries } = this.config.fast;\n let evicted = 0;\n while (this.fastQueue.length + this.fastRetryQueue.length > maxBufferEntries) {\n const removed = this.fastQueue.length > 0 ? this.fastQueue.shift() : this.fastRetryQueue.shift();\n evicted += 1;\n persistLogger.warn(\"fast queue overflow — evicted entry\", {\n evictedLevel: removed?.level,\n evictedTopic: removed?.topic,\n fromRetryQueue: this.fastQueue.length === 0,\n maxBufferEntries,\n });\n }\n if (evicted > 0) {\n persistLogger.warn(\"fast queue overflow summary\", { evicted, maxBufferEntries });\n }\n }\n\n private evictMediumOverflow(): void {\n const { maxBufferEntries } = this.config.medium;\n let evicted = 0;\n while (this.mediumQueue.length > maxBufferEntries) {\n const successIndex = this.mediumQueue.findIndex((entry) => entry.level === LogLevel.SUCCESS);\n const removed = successIndex >= 0 ? this.mediumQueue.splice(successIndex, 1)[0] : this.mediumQueue.shift();\n evicted += 1;\n persistLogger.warn(\"medium queue overflow — evicted entry\", {\n evictedLevel: removed?.level,\n evictedTopic: removed?.topic,\n queueLength: this.mediumQueue.length,\n maxBufferEntries,\n });\n }\n if (evicted > 0) {\n persistLogger.warn(\"medium queue overflow summary\", {\n evicted,\n queueLength: this.mediumQueue.length,\n maxBufferEntries,\n });\n }\n }\n\n private evictSlowOverflow(): void {\n const { maxBufferEntries } = this.config.slow;\n let evicted = 0;\n while (this.slowQueue.length > maxBufferEntries) {\n const debugIndex = this.slowQueue.findIndex((entry) => entry.level === LogLevel.DEBUG);\n const removed = debugIndex >= 0 ? this.slowQueue.splice(debugIndex, 1)[0] : this.slowQueue.shift();\n evicted += 1;\n persistLogger.warn(\"slow queue overflow — evicted entry\", {\n evictedLevel: removed?.level,\n evictedTopic: removed?.topic,\n queueLength: this.slowQueue.length,\n maxBufferEntries,\n });\n }\n if (evicted > 0) {\n persistLogger.warn(\"slow queue overflow summary\", {\n evicted,\n queueLength: this.slowQueue.length,\n maxBufferEntries,\n });\n }\n if (this.slowQueue.length === 0) {\n this.slowQueueStartedAt = null;\n }\n }\n\n private async flushFast(): Promise<void> {\n if (this.laneFlushing.fast) {\n persistLogger.debug(\"fast flush skipped — already flushing\");\n return;\n }\n if (this.service == null || this.processName == null) {\n return;\n }\n\n this.laneFlushing.fast = true;\n try {\n while (this.fastQueue.length > 0 || this.fastRetryQueue.length > 0) {\n const fromRetry = this.fastQueue.length === 0;\n const entry = this.fastQueue.shift() ?? this.fastRetryQueue.shift();\n if (entry == null) {\n break;\n }\n\n const idempotencyKey = computeLogBatchIdempotencyKey({\n service: this.service,\n process: this.processName,\n lane: \"fast\",\n entries: [entry],\n });\n\n try {\n const draft = buildLogListDraft({\n service: this.service,\n process: this.processName,\n lane: \"fast\",\n idempotencyKey,\n entries: [entry],\n });\n persistLogger.debug(\"fast flush posting batch\", {\n idempotencyKey,\n fromRetry,\n level: entry.level,\n topic: entry.topic,\n });\n await postLogBatch(draft, this.config.postTimeoutMs);\n this.lastFlushAt.fast = new Date().toISOString();\n this.recordLaneSuccess(\"fast\");\n persistLogger.info(\"fast lane flushed\", {\n idempotencyKey,\n level: entry.level,\n topic: entry.topic,\n fastRetryRemaining: this.fastRetryQueue.length,\n });\n } catch (error) {\n this.recordLaneError(\"fast\", error);\n this.fastRetryQueue.push(entry);\n persistLogger.error(\"fast flush failed — queued for retry\", {\n idempotencyKey,\n error: this.lastError,\n retryInMs: FAST_RETRY_INTERVAL_MS,\n fastRetryQueue: this.fastRetryQueue.length,\n });\n this.scheduleFastRetry();\n break;\n }\n }\n } finally {\n this.laneFlushing.fast = false;\n }\n }\n\n private scheduleFastRetry(): void {\n if (this.fastRetryTimer != null) {\n return;\n }\n persistLogger.warn(\"fast flush retry scheduled\", { retryInMs: FAST_RETRY_INTERVAL_MS });\n this.fastRetryTimer = setTimeout(() => {\n this.fastRetryTimer = null;\n persistLogger.debug(\"fast flush retry timer fired\");\n void this.flushFast();\n }, FAST_RETRY_INTERVAL_MS);\n this.fastRetryTimer.unref?.();\n }\n\n private async flushMedium(): Promise<void> {\n if (this.laneFlushing.medium) {\n persistLogger.debug(\"medium flush skipped — already flushing\");\n return;\n }\n if (this.mediumQueue.length === 0) {\n return;\n }\n if (this.service == null || this.processName == null) {\n return;\n }\n\n this.laneFlushing.medium = true;\n try {\n while (this.mediumQueue.length > 0) {\n const batch = takeEntriesWithinBytes(this.mediumQueue, this.config.medium.maxBytes);\n if (batch.length === 0) {\n break;\n }\n\n const idempotencyKey = computeLogBatchIdempotencyKey({\n service: this.service,\n process: this.processName,\n lane: \"medium\",\n entries: batch,\n });\n const batchBytes = estimateEntriesBytes(batch);\n\n try {\n persistLogger.debug(\"medium flush posting batch\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n queueRemaining: this.mediumQueue.length,\n });\n const draft = buildLogListDraft({\n service: this.service,\n process: this.processName,\n lane: \"medium\",\n idempotencyKey,\n entries: batch,\n });\n await postLogBatch(draft, this.config.postTimeoutMs);\n this.mediumQueue.splice(0, batch.length);\n this.lastFlushAt.medium = new Date().toISOString();\n this.recordLaneSuccess(\"medium\");\n persistLogger.info(\"medium lane flushed\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n queueRemaining: this.mediumQueue.length,\n });\n } catch (error) {\n this.recordLaneError(\"medium\", error);\n persistLogger.error(\"medium flush failed — entries retained\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n error: this.lastError,\n queueRemaining: this.mediumQueue.length,\n });\n this.scheduleMediumFlush();\n break;\n }\n }\n } finally {\n this.laneFlushing.medium = false;\n }\n\n if (this.mediumQueue.length > 0 && !this.laneFlushing.medium) {\n this.scheduleMediumFlush();\n }\n }\n\n private async flushSlow(): Promise<void> {\n if (this.laneFlushing.slow) {\n persistLogger.debug(\"slow flush skipped — already flushing\");\n return;\n }\n if (this.slowQueue.length === 0) {\n return;\n }\n if (this.service == null || this.processName == null) {\n return;\n }\n\n this.laneFlushing.slow = true;\n try {\n while (this.slowQueue.length > 0) {\n const batch = takeEntriesWithinBytes(this.slowQueue, this.config.slow.maxBytes);\n if (batch.length === 0) {\n break;\n }\n\n const idempotencyKey = computeLogBatchIdempotencyKey({\n service: this.service,\n process: this.processName,\n lane: \"slow\",\n entries: batch,\n });\n const batchBytes = estimateEntriesBytes(batch);\n\n try {\n persistLogger.debug(\"slow flush posting batch\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n queueRemaining: this.slowQueue.length,\n });\n const draft = buildLogListDraft({\n service: this.service,\n process: this.processName,\n lane: \"slow\",\n idempotencyKey,\n entries: batch,\n });\n await postLogBatch(draft, this.config.postTimeoutMs);\n this.slowQueue.splice(0, batch.length);\n this.lastFlushAt.slow = new Date().toISOString();\n this.recordLaneSuccess(\"slow\");\n persistLogger.info(\"slow lane flushed\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n queueRemaining: this.slowQueue.length,\n });\n } catch (error) {\n this.recordLaneError(\"slow\", error);\n persistLogger.error(\"slow flush failed — entries retained\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n error: this.lastError,\n queueRemaining: this.slowQueue.length,\n });\n this.scheduleSlowFlush();\n break;\n }\n }\n\n if (this.slowQueue.length === 0) {\n this.slowQueueStartedAt = null;\n }\n } finally {\n this.laneFlushing.slow = false;\n }\n\n if (this.slowQueue.length > 0 && !this.laneFlushing.slow) {\n this.scheduleSlowFlush();\n }\n }\n}\n\nexport { LogPersist };\n","import { resolve } from \"node:path\";\nimport { envBool } from \"../../node/env/env-parsers\";\nimport { readEnv, requireEnv } from \"../../node/env/require-env\";\nimport { pollUntil } from \"../../node/readiness\";\nimport { createLogger } from \"./create-logger\";\nimport { LogPersist } from \"./log-persist\";\nimport {\n logPersistConfigFromEnv,\n logPersistEnabledFromEnv,\n logPersistProcessFromEnv,\n logPersistRegistryDirFromEnv,\n logPersistServiceFromEnv,\n resolveLogPersistConfig,\n} from \"./log-persist.config\";\nimport type {\n EnableLogPersistOptions,\n EnsureLogPersistFromEnvOptions,\n LogPersistReadySnapshot,\n LogPersistStats,\n WaitForLogPersistReadyOptions,\n} from \"./log-persist.interface\";\nimport { registerLogPersistOffer } from \"./log-persist-hook\";\nimport { LOG_PERSIST_TOPIC, persistLogger } from \"./log-persist-logger\";\nimport { defaultLogPersistRegistryPath, readLogPersistRegistry } from \"./log-persist-registry\";\n\nexport { logPersistEnabledFromEnv };\n\nfunction resolveRegistryFilePath(explicit?: string): string {\n if (explicit != null && explicit.trim() !== \"\") {\n return resolve(explicit);\n }\n const dir = logPersistRegistryDirFromEnv();\n if (dir == null) {\n throw new Error(\n \"[LogPersist] registry path required: set registryFilePath option or LOG_PERSIST_REGISTRY_DIR / RUNTIME_DATA_DIR\",\n );\n }\n return defaultLogPersistRegistryPath(resolve(dir));\n}\n\nexport async function enableLogPersist(options: EnableLogPersistOptions): Promise<void> {\n const registryFilePath = options.registryFilePath != null ? resolve(options.registryFilePath) : undefined;\n const resolvedRegistry = registryFilePath ?? resolveRegistryFilePath();\n\n const envConfig = logPersistConfigFromEnv();\n await LogPersist.getInstance().enable({\n ...options,\n registryFilePath: resolvedRegistry,\n config: resolveLogPersistConfig({\n fast: { ...envConfig.fast, ...options.config?.fast },\n medium: { ...envConfig.medium, ...options.config?.medium },\n slow: { ...envConfig.slow, ...options.config?.slow },\n postTimeoutMs: options.config?.postTimeoutMs ?? envConfig.postTimeoutMs,\n shutdownDrainTimeoutMs: options.config?.shutdownDrainTimeoutMs ?? envConfig.shutdownDrainTimeoutMs,\n }),\n });\n}\n\nexport async function disableLogPersist(): Promise<void> {\n await LogPersist.getInstance().disable();\n}\n\nexport function getLogPersistStats(): LogPersistStats {\n return LogPersist.getInstance().getStats();\n}\n\n/**\n * Enable log persistence when LOG_PERSIST_ENABLED=true.\n * `process` / `service` can be passed explicitly or via LOG_PERSIST_PROCESS / LOG_PERSIST_SERVICE.\n */\nexport async function ensureLogPersistFromEnv(options: EnsureLogPersistFromEnvOptions = {}): Promise<boolean> {\n if (!logPersistEnabledFromEnv()) {\n registerLogPersistOffer(null);\n return false;\n }\n\n const service = options.service ?? logPersistServiceFromEnv();\n const processName = options.process ?? logPersistProcessFromEnv();\n if (service == null || service === \"\") {\n throw new Error(\"[LogPersist] LOG_PERSIST_SERVICE is required when LOG_PERSIST_ENABLED=true\");\n }\n if (processName == null || processName === \"\") {\n throw new Error(\n \"[LogPersist] LOG_PERSIST_PROCESS is required when LOG_PERSIST_ENABLED=true (or pass process option)\",\n );\n }\n\n const registryFilePath =\n options.registryFilePath != null ? resolve(options.registryFilePath) : resolveRegistryFilePath();\n\n await enableLogPersist({\n service,\n process: processName,\n registryFilePath,\n config: options.config,\n });\n\n const lifecycleLogger = createLogger({ module: \"log-persist\" });\n lifecycleLogger.info(\"log persist enabled from env\", {\n topic: LOG_PERSIST_TOPIC,\n data: { service, process: processName, registryFilePath },\n });\n\n return true;\n}\n\n/**\n * Preload guard: when persistence is enabled, required env must be present before app code runs.\n */\nexport function validateLogPersistPreloadEnv(env: NodeJS.ProcessEnv = process.env): void {\n if (!envBool(\"LOG_PERSIST_ENABLED\", false, env)) {\n return;\n }\n\n const missing: string[] = [];\n if (readEnv(\"LOG_PERSIST_SERVICE\", env) == null) {\n missing.push(\"LOG_PERSIST_SERVICE\");\n }\n const registryDir = logPersistRegistryDirFromEnv(env);\n if (registryDir == null) {\n missing.push(\"LOG_PERSIST_REGISTRY_DIR or RUNTIME_DATA_DIR\");\n }\n\n if (missing.length > 0) {\n throw new Error(`[LogPersist] preload env incomplete: ${missing.join(\", \")}`);\n }\n}\n\nfunction evaluateLogPersistReady(\n state: Awaited<ReturnType<typeof readLogPersistRegistry>>,\n expectedProcesses: string[],\n staleMs: number,\n now: number,\n): LogPersistReadySnapshot {\n const missing: string[] = [];\n const stale: string[] = [];\n const registered: string[] = [];\n\n for (const processName of expectedProcesses) {\n const record = state.processes[processName];\n if (record == null) {\n missing.push(processName);\n continue;\n }\n\n const heartbeatAt = Date.parse(record.lastHeartbeatAt);\n if (!Number.isFinite(heartbeatAt) || now - heartbeatAt > staleMs) {\n stale.push(processName);\n continue;\n }\n\n registered.push(processName);\n }\n\n return {\n ok: missing.length === 0 && stale.length === 0,\n missing,\n stale,\n registered,\n };\n}\n\n/**\n * Wait until every expected process has registered in the shared registry with a fresh heartbeat.\n * Call from the service main process after spawning children.\n */\nexport async function waitForLogPersistReady(options: WaitForLogPersistReadyOptions): Promise<LogPersistReadySnapshot> {\n const timeoutMs = options.timeoutMs ?? 60_000;\n const pollIntervalMs = options.pollIntervalMs ?? 500;\n const staleMs = options.staleMs ?? 90_000;\n\n let last: LogPersistReadySnapshot = {\n ok: false,\n missing: [...options.expectedProcesses],\n stale: [],\n registered: [],\n };\n\n try {\n await pollUntil({\n intervalMs: pollIntervalMs,\n timeoutMs,\n until: async () => {\n const state = await readLogPersistRegistry(options.registryFilePath);\n if (state.service !== options.service) {\n last = {\n ok: false,\n missing: options.expectedProcesses,\n stale: [],\n registered: [],\n };\n return false;\n }\n last = evaluateLogPersistReady(state, options.expectedProcesses, staleMs, Date.now());\n return last.ok;\n },\n });\n } catch {\n persistLogger.warn(\"waitForLogPersistReady timed out\", {\n timeoutMs,\n expectedProcesses: options.expectedProcesses,\n ...last,\n });\n }\n\n return last;\n}\n\nexport async function snapshotLogPersistReady(options: {\n registryFilePath: string;\n service: string;\n expectedProcesses: string[];\n staleMs?: number;\n}): Promise<LogPersistReadySnapshot> {\n const state = await readLogPersistRegistry(options.registryFilePath);\n return evaluateLogPersistReady(state, options.expectedProcesses, options.staleMs ?? 90_000, Date.now());\n}\n\nexport function resolveLogPersistRegistryPath(registryDir?: string): string {\n const dir = registryDir ?? logPersistRegistryDirFromEnv();\n if (dir == null) {\n requireEnv(\"LOG_PERSIST_REGISTRY_DIR\");\n }\n return defaultLogPersistRegistryPath(resolve(dir ?? \"\"));\n}\n"],"names":[],"mappings":";;;;;;;;AAAM,SAAU,OAAO,CAAC,IAAY,EAAE,GAAA,GAAyB,OAAO,CAAC,GAAG,EAAA;IACtE,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE;IAC/B,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE;AAC/B,QAAA,OAAO,SAAS;IACpB;AACA,IAAA,OAAO,KAAK;AAChB;AAEM,SAAU,UAAU,CAAC,IAAY,EAAE,GAAA,GAAyB,OAAO,CAAC,GAAG,EAAA;IACzE,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;AAChC,IAAA,IAAI,KAAK,IAAI,IAAI,EAAE;AACf,QAAA,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,CAAA,CAAE,CAAC;IACrE;AACA,IAAA,OAAO,KAAK;AAChB;;SCNgB,MAAM,CAAC,IAAY,EAAE,YAAoB,EAAE,OAAuB,EAAA;IAC9E,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI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AC,GAAG,IAAI,EAAE,CAAC,CAAC;AAC5D;;;;"}
|
package/dist/node.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { M as MAX_POLL_TARGET_LIST_SIZE, E as validateWithSchema, d as createLogger, u as pollTargetList, g as generateResponse, e as createTarget, z as supabase, s as logManager, G as createScope, L as LogLevel, H as patchScope, y as scanTargetList, h as getPossibleTarget, p as isOptimisticLockResponse, I as withModule, A as updateTargetDetails } from './chunks/create-logger-DyH3mZ8p.js';
|
|
3
3
|
export { B as BaseValidator, C as CREATE_TARGET_ALREADY_EXISTS_MESSAGE, a as CategoryList, b as MAX_TARGET_LIST_PAGE_SIZE, O as OPTIMISTIC_LOCK_ERROR_CODE, c as OPTIMISTIC_LOCK_FAILED_MESSAGE, P as PostListValidator, S as StatusCode, f as deleteTarget, i as getTarget, j as getTargetList, k as getTargetTotalCount, l as handleSupabaseError, m as isCreateTargetAlreadyExistsError, n as isDevEnvironment, o as isOptimisticLockError, q as logDev, r as logDevGroup, t as patchTarget, v as postListCreate, w as postLogListCreate, x as postTarget, D as validateWith } from './chunks/create-logger-DyH3mZ8p.js';
|
|
4
|
-
import { l as loadEnvFiles, b as readEnv, c as requireEnv } from './chunks/enable-log-persist-
|
|
5
|
-
export { d as createJsonFileStateStore, e as disableLogPersist, f as enableLogPersist, g as ensureLogPersistFromEnv, h as envBool, i as envInt, j as envMs, k as envNumber, m as envPort, n as getLogPersistStats, a as logPersistEnabledFromEnv, p as parseEnvFile, o as parseEnvLine, q as pollUntil, s as resolveLogPersistRegistryPath, r as resolveProjectRootByPackageName, t as resolveProjectRootFromModule, u as snapshotLogPersistReady, v as validateLogPersistPreloadEnv, w as waitForLogPersistReady } from './chunks/enable-log-persist-
|
|
4
|
+
import { l as loadEnvFiles, b as readEnv, c as requireEnv } from './chunks/enable-log-persist-BH-tbKEj.js';
|
|
5
|
+
export { d as createJsonFileStateStore, e as disableLogPersist, f as enableLogPersist, g as ensureLogPersistFromEnv, h as envBool, i as envInt, j as envMs, k as envNumber, m as envPort, n as getLogPersistStats, a as logPersistEnabledFromEnv, p as parseEnvFile, o as parseEnvLine, q as pollUntil, s as resolveLogPersistRegistryPath, r as resolveProjectRootByPackageName, t as resolveProjectRootFromModule, u as snapshotLogPersistReady, v as validateLogPersistPreloadEnv, w as waitForLogPersistReady } from './chunks/enable-log-persist-BH-tbKEj.js';
|
|
6
6
|
import { access, stat, readFile, mkdir, writeFile, readdir } from 'node:fs/promises';
|
|
7
7
|
import { resolve, join, isAbsolute, dirname } from 'node:path';
|
|
8
8
|
import { aq as sha256Hex, as as getErrorMessage, a9 as postRegisterNode, U as patchChangeNodeStatus, N as NodeStatus, a0 as patchStopNode, _ as patchNodeHeartBeat, d as CategoryRepo, R as ResultCode, at as LOG_TOPIC_TASK, T as TASK_REPO_USAGE, D as getScanRemoteRepoValues, Y as patchClaimTask, au as CRITICAL_UNKNOWN_TASK_TRACE_ID, W as patchChangeTaskStatus, j as TaskStatusAction, av as toError, ae as postTaskSchema, aw as createTaskRow, i as TaskStatus } from './chunks/word.interface-DLgRobKV.js';
|
package/dist/preload.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
|
-
import { r as resolveProjectRootByPackageName, l as loadEnvFiles, v as validateLogPersistPreloadEnv, a as logPersistEnabledFromEnv } from './chunks/enable-log-persist-
|
|
2
|
+
import { r as resolveProjectRootByPackageName, l as loadEnvFiles, v as validateLogPersistPreloadEnv, a as logPersistEnabledFromEnv } from './chunks/enable-log-persist-BH-tbKEj.js';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:url';
|
|
5
5
|
import 'node:fs/promises';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LogPersistRegistryState } from "./log-persist.interface";
|
|
2
|
+
/** Registry root directory — one shard file per process under this path. */
|
|
2
3
|
export declare function defaultLogPersistRegistryPath(registryDir: string): string;
|
|
3
4
|
export declare function registerLogPersistProcess(input: {
|
|
4
5
|
registryFilePath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-persist-registry.d.ts","sourceRoot":"","sources":["../../../src/shared/log/log-persist-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log-persist-registry.d.ts","sourceRoot":"","sources":["../../../src/shared/log/log-persist-registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA2B,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAiEhG,4EAA4E;AAC5E,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzE;AAmDD,wBAAsB,yBAAyB,CAAC,KAAK,EAAE;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BhB;AAED,wBAAsB,0BAA0B,CAAC,KAAK,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCpH;AAED,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDrH;AAED,wBAAsB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAKvG"}
|
|
@@ -30,7 +30,7 @@ export interface LogPersistConfig {
|
|
|
30
30
|
export interface EnableLogPersistOptions {
|
|
31
31
|
service: string;
|
|
32
32
|
process: string;
|
|
33
|
-
/** Shared registry
|
|
33
|
+
/** Shared registry root directory — all processes use the same path; each writes its own shard file. */
|
|
34
34
|
registryFilePath?: string;
|
|
35
35
|
config?: Partial<LogPersistConfig>;
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-persist.interface.d.ts","sourceRoot":"","sources":["../../../src/shared/log/log-persist.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,gEAAgE;AAChE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAExD,MAAM,WAAW,oBAAoB;IACjC,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,iDAAiD;IACjD,aAAa,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,sBAAsB,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"log-persist.interface.d.ts","sourceRoot":"","sources":["../../../src/shared/log/log-persist.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE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;IAChB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACpC,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "target-supabase-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Supabase client initializer and data access APIs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "KyLoc20",
|
|
@@ -53,10 +53,7 @@
|
|
|
53
53
|
"format": "biome check --write .",
|
|
54
54
|
"format:check": "biome ci",
|
|
55
55
|
"lint": "biome lint .",
|
|
56
|
-
"worker": "tsx scripts/run-node-worker.ts",
|
|
57
56
|
"worker:trigger": "tsx scripts/run-trigger-node.ts",
|
|
58
|
-
"chrome-sidecar": "tsx scripts/chrome-sidecar-hub.ts",
|
|
59
|
-
"post-task": "tsx scripts/post-task.ts",
|
|
60
57
|
"post-command": "tsx scripts/post-command.ts",
|
|
61
58
|
"post-trigger": "tsx scripts/post-trigger.ts",
|
|
62
59
|
"parcel:split": "tsx scripts/parcel-split-local.ts",
|
|
@@ -79,13 +76,11 @@
|
|
|
79
76
|
"@supabase/supabase-js": "2.50.3",
|
|
80
77
|
"@types/lodash-es": "^4.17.12",
|
|
81
78
|
"@types/wicg-file-system-access": "^2023.10.7",
|
|
82
|
-
"@types/ws": "^8.18.1",
|
|
83
79
|
"lodash-es": "^4.17.21",
|
|
84
80
|
"rollup": "^4.40.2",
|
|
85
81
|
"tslib": "^2.8.1",
|
|
86
82
|
"tsx": "^4.19.4",
|
|
87
83
|
"typescript": "~5.7.2",
|
|
88
|
-
"ws": "^8.18.0",
|
|
89
84
|
"zod": "^3.24.0"
|
|
90
85
|
},
|
|
91
86
|
"publishConfig": {
|
|
@@ -23,12 +23,12 @@ export function buildLogListDraft(input: BuildLogListDraftInput): LogListDraft {
|
|
|
23
23
|
const last = entries[entries.length - 1];
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
|
-
name:
|
|
26
|
+
name: `log-batch:${service}:${process}:${lane}`,
|
|
27
27
|
value: idempotencyKey,
|
|
28
28
|
category: CategoryList.LIST,
|
|
29
29
|
tagList: ["log", lane, service],
|
|
30
30
|
details: {
|
|
31
|
-
manifestVersion:
|
|
31
|
+
manifestVersion: 0,
|
|
32
32
|
loaderKey: LOG_PERSIST_LOADER_KEY,
|
|
33
33
|
meta: JSON.stringify({
|
|
34
34
|
service,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mkdir, readdir, readFile } from "node:fs/promises";
|
|
1
2
|
import { join } from "node:path";
|
|
2
3
|
import { createJsonFileStateStore } from "../../node/fs/json-state-store";
|
|
3
4
|
import type { LogPersistProcessRecord, LogPersistRegistryState } from "./log-persist.interface";
|
|
@@ -9,10 +10,33 @@ const DEFAULT_REGISTRY: LogPersistRegistryState = {
|
|
|
9
10
|
processes: {},
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
/** Per-process shard — each process owns one file; no cross-process RMW. */
|
|
14
|
+
interface LogPersistProcessShard extends LogPersistProcessRecord {
|
|
15
|
+
service: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DEFAULT_SHARD: LogPersistProcessShard = {
|
|
20
|
+
service: "",
|
|
21
|
+
updatedAt: new Date(0).toISOString(),
|
|
22
|
+
pid: 0,
|
|
23
|
+
enabledAt: new Date(0).toISOString(),
|
|
24
|
+
lastHeartbeatAt: new Date(0).toISOString(),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const legacyStores = new Map<
|
|
28
|
+
string,
|
|
29
|
+
ReturnType<typeof createJsonFileStateStore<LogPersistRegistryState, "processes">>
|
|
30
|
+
>();
|
|
13
31
|
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
const shardStores = new Map<string, ReturnType<typeof createJsonFileStateStore<LogPersistProcessShard>>>();
|
|
33
|
+
|
|
34
|
+
function isLegacyRegistryFile(registryPath: string): boolean {
|
|
35
|
+
return registryPath.endsWith(".json");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function legacyStoreFor(filePath: string) {
|
|
39
|
+
let store = legacyStores.get(filePath);
|
|
16
40
|
if (store == null) {
|
|
17
41
|
store = createJsonFileStateStore<LogPersistRegistryState, "processes">({
|
|
18
42
|
filePath,
|
|
@@ -20,13 +44,80 @@ function storeFor(filePath: string) {
|
|
|
20
44
|
nestedKeys: ["processes"],
|
|
21
45
|
updatedAtKey: "updatedAt",
|
|
22
46
|
});
|
|
23
|
-
|
|
47
|
+
legacyStores.set(filePath, store);
|
|
24
48
|
}
|
|
25
49
|
return store;
|
|
26
50
|
}
|
|
27
51
|
|
|
52
|
+
function shardStoreFor(shardFilePath: string) {
|
|
53
|
+
let store = shardStores.get(shardFilePath);
|
|
54
|
+
if (store == null) {
|
|
55
|
+
store = createJsonFileStateStore<LogPersistProcessShard>({
|
|
56
|
+
filePath: shardFilePath,
|
|
57
|
+
defaultState: DEFAULT_SHARD,
|
|
58
|
+
updatedAtKey: "updatedAt",
|
|
59
|
+
});
|
|
60
|
+
shardStores.set(shardFilePath, store);
|
|
61
|
+
}
|
|
62
|
+
return store;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function shardFilePath(registryDir: string, process: string): string {
|
|
66
|
+
return join(registryDir, `${process}.json`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Registry root directory — one shard file per process under this path. */
|
|
28
70
|
export function defaultLogPersistRegistryPath(registryDir: string): string {
|
|
29
|
-
return join(registryDir, "log-persist-registry
|
|
71
|
+
return join(registryDir, "log-persist-registry");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function readShardedLogPersistRegistry(registryDir: string): Promise<LogPersistRegistryState> {
|
|
75
|
+
await mkdir(registryDir, { recursive: true });
|
|
76
|
+
|
|
77
|
+
let entries: string[];
|
|
78
|
+
try {
|
|
79
|
+
entries = await readdir(registryDir);
|
|
80
|
+
} catch {
|
|
81
|
+
return { ...DEFAULT_REGISTRY };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const processes: Record<string, LogPersistProcessRecord> = {};
|
|
85
|
+
let service = "";
|
|
86
|
+
let updatedAt = new Date(0).toISOString();
|
|
87
|
+
|
|
88
|
+
for (const name of entries) {
|
|
89
|
+
if (!name.endsWith(".json")) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const processName = name.slice(0, -".json".length);
|
|
94
|
+
if (processName === "" || processName.startsWith("_")) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
const raw = await readFile(join(registryDir, name), "utf8");
|
|
100
|
+
const shard = JSON.parse(raw) as Partial<LogPersistProcessShard>;
|
|
101
|
+
if (shard.service != null && shard.service !== "") {
|
|
102
|
+
service = shard.service;
|
|
103
|
+
}
|
|
104
|
+
if (shard.updatedAt != null && shard.updatedAt > updatedAt) {
|
|
105
|
+
updatedAt = shard.updatedAt;
|
|
106
|
+
}
|
|
107
|
+
processes[processName] = {
|
|
108
|
+
pid: shard.pid ?? 0,
|
|
109
|
+
enabledAt: shard.enabledAt ?? new Date(0).toISOString(),
|
|
110
|
+
lastHeartbeatAt: shard.lastHeartbeatAt ?? new Date(0).toISOString(),
|
|
111
|
+
};
|
|
112
|
+
} catch {
|
|
113
|
+
persistLogger.warn("registry shard read skipped — corrupt or missing", {
|
|
114
|
+
registryDir,
|
|
115
|
+
shard: name,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return { updatedAt, service, processes };
|
|
30
121
|
}
|
|
31
122
|
|
|
32
123
|
export async function registerLogPersistProcess(input: {
|
|
@@ -41,12 +132,21 @@ export async function registerLogPersistProcess(input: {
|
|
|
41
132
|
lastHeartbeatAt: now,
|
|
42
133
|
};
|
|
43
134
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
135
|
+
if (isLegacyRegistryFile(input.registryFilePath)) {
|
|
136
|
+
await legacyStoreFor(input.registryFilePath).write({
|
|
137
|
+
service: input.service,
|
|
138
|
+
processes: {
|
|
139
|
+
[input.process]: record,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
await shardStoreFor(shardFilePath(input.registryFilePath, input.process)).write({
|
|
144
|
+
service: input.service,
|
|
145
|
+
pid: record.pid,
|
|
146
|
+
enabledAt: record.enabledAt,
|
|
147
|
+
lastHeartbeatAt: record.lastHeartbeatAt,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
50
150
|
|
|
51
151
|
persistLogger.info("registry process registered", {
|
|
52
152
|
registryFilePath: input.registryFilePath,
|
|
@@ -57,9 +157,31 @@ export async function registerLogPersistProcess(input: {
|
|
|
57
157
|
}
|
|
58
158
|
|
|
59
159
|
export async function heartbeatLogPersistProcess(input: { registryFilePath: string; process: string }): Promise<void> {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
160
|
+
if (isLegacyRegistryFile(input.registryFilePath)) {
|
|
161
|
+
const current = await legacyStoreFor(input.registryFilePath).read();
|
|
162
|
+
const existing = current.processes[input.process];
|
|
163
|
+
if (existing == null) {
|
|
164
|
+
persistLogger.warn("registry heartbeat skipped — process not registered", {
|
|
165
|
+
registryFilePath: input.registryFilePath,
|
|
166
|
+
process: input.process,
|
|
167
|
+
});
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
await legacyStoreFor(input.registryFilePath).write({
|
|
172
|
+
processes: {
|
|
173
|
+
[input.process]: {
|
|
174
|
+
...existing,
|
|
175
|
+
lastHeartbeatAt: new Date().toISOString(),
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const store = shardStoreFor(shardFilePath(input.registryFilePath, input.process));
|
|
183
|
+
const current = await store.read();
|
|
184
|
+
if (current.pid === 0) {
|
|
63
185
|
persistLogger.warn("registry heartbeat skipped — process not registered", {
|
|
64
186
|
registryFilePath: input.registryFilePath,
|
|
65
187
|
process: input.process,
|
|
@@ -67,20 +189,43 @@ export async function heartbeatLogPersistProcess(input: { registryFilePath: stri
|
|
|
67
189
|
return;
|
|
68
190
|
}
|
|
69
191
|
|
|
70
|
-
await
|
|
71
|
-
|
|
72
|
-
[input.process]: {
|
|
73
|
-
...existing,
|
|
74
|
-
lastHeartbeatAt: new Date().toISOString(),
|
|
75
|
-
},
|
|
76
|
-
},
|
|
192
|
+
await store.write({
|
|
193
|
+
lastHeartbeatAt: new Date().toISOString(),
|
|
77
194
|
});
|
|
78
195
|
}
|
|
79
196
|
|
|
80
197
|
export async function unregisterLogPersistProcess(input: { registryFilePath: string; process: string }): Promise<void> {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
198
|
+
if (isLegacyRegistryFile(input.registryFilePath)) {
|
|
199
|
+
const current = await legacyStoreFor(input.registryFilePath).read();
|
|
200
|
+
const existing = current.processes[input.process];
|
|
201
|
+
if (existing == null) {
|
|
202
|
+
persistLogger.warn("registry unregister skipped — process not found", {
|
|
203
|
+
registryFilePath: input.registryFilePath,
|
|
204
|
+
process: input.process,
|
|
205
|
+
});
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
await legacyStoreFor(input.registryFilePath).write({
|
|
210
|
+
processes: {
|
|
211
|
+
[input.process]: {
|
|
212
|
+
...existing,
|
|
213
|
+
pid: 0,
|
|
214
|
+
lastHeartbeatAt: new Date(0).toISOString(),
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
persistLogger.info("registry process unregistered", {
|
|
220
|
+
registryFilePath: input.registryFilePath,
|
|
221
|
+
process: input.process,
|
|
222
|
+
});
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const store = shardStoreFor(shardFilePath(input.registryFilePath, input.process));
|
|
227
|
+
const current = await store.read();
|
|
228
|
+
if (current.pid === 0) {
|
|
84
229
|
persistLogger.warn("registry unregister skipped — process not found", {
|
|
85
230
|
registryFilePath: input.registryFilePath,
|
|
86
231
|
process: input.process,
|
|
@@ -88,14 +233,9 @@ export async function unregisterLogPersistProcess(input: { registryFilePath: str
|
|
|
88
233
|
return;
|
|
89
234
|
}
|
|
90
235
|
|
|
91
|
-
await
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
...existing,
|
|
95
|
-
pid: 0,
|
|
96
|
-
lastHeartbeatAt: new Date(0).toISOString(),
|
|
97
|
-
},
|
|
98
|
-
},
|
|
236
|
+
await store.write({
|
|
237
|
+
pid: 0,
|
|
238
|
+
lastHeartbeatAt: new Date(0).toISOString(),
|
|
99
239
|
});
|
|
100
240
|
|
|
101
241
|
persistLogger.info("registry process unregistered", {
|
|
@@ -105,5 +245,8 @@ export async function unregisterLogPersistProcess(input: { registryFilePath: str
|
|
|
105
245
|
}
|
|
106
246
|
|
|
107
247
|
export async function readLogPersistRegistry(registryFilePath: string): Promise<LogPersistRegistryState> {
|
|
108
|
-
|
|
248
|
+
if (isLegacyRegistryFile(registryFilePath)) {
|
|
249
|
+
return legacyStoreFor(registryFilePath).read();
|
|
250
|
+
}
|
|
251
|
+
return readShardedLogPersistRegistry(registryFilePath);
|
|
109
252
|
}
|
|
@@ -36,7 +36,7 @@ export interface LogPersistConfig {
|
|
|
36
36
|
export interface EnableLogPersistOptions {
|
|
37
37
|
service: string;
|
|
38
38
|
process: string;
|
|
39
|
-
/** Shared registry
|
|
39
|
+
/** Shared registry root directory — all processes use the same path; each writes its own shard file. */
|
|
40
40
|
registryFilePath?: string;
|
|
41
41
|
config?: Partial<LogPersistConfig>;
|
|
42
42
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enable-log-persist-C_bSw6Kx.js","sources":["../../src/node/env/require-env.ts","../../src/node/env/env-parsers.ts","../../src/node/env/load-env.ts","../../src/node/env/project-root.ts","../../src/node/fs/json-state-store.ts","../../src/node/readiness/poll-until.ts","../../src/shared/log/log-persist.config.ts","../../src/shared/log/log-persist-batch-id.ts","../../src/shared/log/log-persist-logger.ts","../../src/shared/log/log-persist-flush.ts","../../src/shared/log/log-persist-registry.ts","../../src/shared/log/log-persist.ts","../../src/shared/log/enable-log-persist.ts"],"sourcesContent":["export function readEnv(name: string, env: NodeJS.ProcessEnv = process.env): string | undefined {\n const value = env[name]?.trim();\n if (value == null || value === \"\") {\n return undefined;\n }\n return value;\n}\n\nexport function requireEnv(name: string, env: NodeJS.ProcessEnv = process.env): string {\n const value = readEnv(name, env);\n if (value == null) {\n throw new Error(`Missing required environment variable: ${name}`);\n }\n return value;\n}\n","import { readEnv } from \"./require-env\";\n\nexport interface EnvIntOptions {\n env?: NodeJS.ProcessEnv;\n min?: number;\n max?: number;\n}\n\nexport function envInt(name: string, defaultValue: number, options?: EnvIntOptions): number {\n const env = options?.env ?? process.env;\n const raw = readEnv(name, env);\n if (raw == null) {\n return defaultValue;\n }\n\n const value = Number(raw);\n if (!Number.isInteger(value)) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n const min = options?.min;\n if (min != null && value < min) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n const max = options?.max;\n if (max != null && value > max) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n return value;\n}\n\nexport function envMs(name: string, defaultMs: number, options?: EnvIntOptions): number {\n return envInt(name, defaultMs, { ...options, min: options?.min ?? 1 });\n}\n\nexport function envPort(defaultPort = 3100, options?: EnvIntOptions & { envKey?: string }): number {\n const envKey = options?.envKey ?? \"PORT\";\n return envInt(envKey, defaultPort, { ...options, min: 1, max: 65535 });\n}\n\nexport interface EnvNumberOptions {\n env?: NodeJS.ProcessEnv;\n min?: number;\n /** When true, use Math.floor on parsed value. */\n floor?: boolean;\n}\n\nexport function envNumber(name: string, defaultValue: number, options?: EnvNumberOptions): number {\n const env = options?.env ?? process.env;\n const raw = readEnv(name, env);\n if (raw == null) {\n return defaultValue;\n }\n\n const value = Number(raw);\n if (!Number.isFinite(value)) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n const min = options?.min;\n const resolved = options?.floor === true ? Math.floor(value) : value;\n if (min != null && resolved < min) {\n throw new Error(`Invalid ${name}: ${raw}`);\n }\n\n return resolved;\n}\n\nexport function envBool(name: string, defaultValue = false, env: NodeJS.ProcessEnv = process.env): boolean {\n const raw = readEnv(name, env)?.toLowerCase();\n if (raw == null) {\n return defaultValue;\n }\n return raw === \"1\" || raw === \"true\" || raw === \"yes\";\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nconst DEFAULT_ENV_FILES = [\".env.local\", \".env\"] as const;\n\nexport interface LoadEnvFilesOptions {\n /** Files to load in order (later files do not override existing env). */\n files?: readonly string[];\n env?: NodeJS.ProcessEnv;\n /** Called after all files are merged (e.g. legacy alias normalization). */\n afterLoad?: () => void;\n}\n\nfunction stripQuotes(value: string): string {\n return value.replace(/^[\"']|[\"']$/g, \"\");\n}\n\n/** Parse one KEY=VALUE line; returns null if line should be skipped. */\nexport function parseEnvLine(line: string): { key: string; value: string } | null {\n const trimmed = line.trim();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) {\n return null;\n }\n\n const eq = trimmed.indexOf(\"=\");\n if (eq === -1) {\n return null;\n }\n\n const key = trimmed.slice(0, eq).trim();\n const raw = trimmed.slice(eq + 1).trim();\n return { key, value: stripQuotes(raw) };\n}\n\nexport function parseEnvFileContent(content: string, env: NodeJS.ProcessEnv): void {\n for (const line of content.split(\"\\n\")) {\n const parsed = parseEnvLine(line);\n if (parsed == null) {\n continue;\n }\n if (env[parsed.key] == null || env[parsed.key] === \"\") {\n env[parsed.key] = parsed.value;\n }\n }\n}\n\nexport function parseEnvFile(filePath: string, env: NodeJS.ProcessEnv): void {\n if (!existsSync(filePath)) {\n return;\n }\n parseEnvFileContent(readFileSync(filePath, \"utf8\"), env);\n}\n\n/**\n * Load `.env.local` then `.env` into `process.env` (or `options.env`).\n * Existing non-empty env values are not overwritten.\n */\nexport function loadEnvFiles(root: string, options?: LoadEnvFilesOptions): void {\n const env = options?.env ?? process.env;\n const files = options?.files ?? DEFAULT_ENV_FILES;\n\n for (const name of files) {\n parseEnvFile(resolve(root, name), env);\n }\n\n options?.afterLoad?.();\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Resolve project root from a module URL (typically `import.meta.url`).\n * @param relativePath Path relative to the module file (default `\"..\"` = parent directory).\n */\nexport function resolveProjectRootFromModule(importMetaUrl: string, relativePath = \"..\"): string {\n return resolve(fileURLToPath(new URL(relativePath, importMetaUrl)));\n}\n\n/**\n * Walk upward from `importMetaUrl` until a `package.json` with matching `name` is found.\n * Use for esbuild bundles under `dist/` where a single `..` hop lands in `dist/`, not repo root.\n */\nexport function resolveProjectRootByPackageName(importMetaUrl: string, packageName: string): string {\n let dir = dirname(fileURLToPath(importMetaUrl));\n for (;;) {\n const packageJsonPath = resolve(dir, \"package.json\");\n if (existsSync(packageJsonPath)) {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { name?: string };\n if (pkg.name === packageName) {\n return dir;\n }\n }\n const parent = dirname(dir);\n if (parent === dir) {\n break;\n }\n dir = parent;\n }\n throw new Error(`Could not find package root for \"${packageName}\" from ${importMetaUrl}`);\n}\n","import { mkdir, readFile, rename, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nexport type JsonStatePatch<T extends object, NK extends keyof T> = Partial<Omit<T, NK>> & {\n [K in NK]?: T[K] extends object ? Partial<T[K]> : T[K];\n};\n\nexport interface JsonFileStateStore<T extends object, NK extends keyof T = never> {\n read(): Promise<T>;\n write(patch: JsonStatePatch<T, NK>): Promise<T>;\n reset(): Promise<T>;\n}\n\nexport interface CreateJsonFileStateStoreOptions<T extends object, NK extends keyof T = never> {\n filePath: string;\n defaultState: T;\n /** Top-level keys shallow-merged one level deep on read and write. */\n nestedKeys?: NK[];\n /** When set, assigned `new Date().toISOString()` on write and reset. */\n updatedAtKey?: keyof T;\n}\n\nfunction mergeWithNested<T extends object>(\n defaults: T,\n current: Partial<T> | undefined,\n patch: Partial<T>,\n nestedKeys: (keyof T)[],\n): T {\n const merged = {\n ...defaults,\n ...current,\n ...patch,\n } as T;\n\n for (const key of nestedKeys) {\n const defaultNested = defaults[key];\n if (defaultNested != null && typeof defaultNested === \"object\") {\n (merged as Record<keyof T, unknown>)[key] = {\n ...defaultNested,\n ...(current?.[key] as object | undefined),\n ...(patch[key] as object | undefined),\n };\n }\n }\n\n return merged;\n}\n\nasync function atomicWriteJson(filePath: string, data: unknown): Promise<void> {\n await mkdir(dirname(filePath), { recursive: true });\n const content = `${JSON.stringify(data, null, 2)}\\n`;\n const tempPath = `${filePath}.${process.pid}.tmp`;\n await writeFile(tempPath, content, \"utf8\");\n await rename(tempPath, filePath);\n}\n\n/** JSON file-backed state with optional nested key merge and atomic writes. */\nexport function createJsonFileStateStore<T extends object, NK extends keyof T = never>(\n options: CreateJsonFileStateStoreOptions<T, NK>,\n): JsonFileStateStore<T, NK> {\n const { filePath, defaultState, nestedKeys = [] as NK[], updatedAtKey } = options;\n\n function touchUpdatedAt(state: T): T {\n if (updatedAtKey == null) {\n return state;\n }\n return {\n ...state,\n [updatedAtKey]: new Date().toISOString(),\n };\n }\n\n return {\n async read(): Promise<T> {\n try {\n const raw = await readFile(filePath, \"utf8\");\n const parsed = JSON.parse(raw) as Partial<T>;\n return mergeWithNested(defaultState, parsed, {}, nestedKeys);\n } catch {\n return { ...defaultState };\n }\n },\n\n async write(patch: JsonStatePatch<T, NK>): Promise<T> {\n const current = await this.read();\n const next = touchUpdatedAt(mergeWithNested(defaultState, current, patch as Partial<T>, nestedKeys));\n await atomicWriteJson(filePath, next);\n return next;\n },\n\n async reset(): Promise<T> {\n const next = touchUpdatedAt({ ...defaultState });\n await atomicWriteJson(filePath, next);\n return next;\n },\n };\n}\n","function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport interface PollUntilOptions {\n timeoutMs: number;\n intervalMs?: number;\n until: () => boolean | Promise<boolean>;\n}\n\n/**\n * Poll `until()` until it returns true or `timeoutMs` elapses.\n * @throws Error on timeout\n */\nexport async function pollUntil(options: PollUntilOptions): Promise<void> {\n const intervalMs = options.intervalMs ?? 500;\n const deadline = Date.now() + options.timeoutMs;\n\n while (Date.now() < deadline) {\n if (await options.until()) {\n return;\n }\n await sleep(intervalMs);\n }\n\n throw new Error(`pollUntil timeout after ${options.timeoutMs}ms`);\n}\n","import { envBool, envInt, envMs } from \"../../node/env/env-parsers\";\nimport type { LogPersistConfig } from \"./log-persist.interface\";\n\nexport const LOG_PERSIST_LOADER_KEY = \"LogBatch.0\";\n\nexport const DEFAULT_LOG_PERSIST_CONFIG: LogPersistConfig = {\n fast: {\n maxBufferEntries: 500,\n },\n medium: {\n debounceMs: 5_000,\n maxEntries: 20,\n maxBytes: 512 * 1024,\n maxBufferEntries: 1_000,\n },\n slow: {\n maxEntries: 400,\n maxBytes: 512 * 1024,\n maxAgeMs: 120_000,\n maxBufferEntries: 2_000,\n },\n postTimeoutMs: 30_000,\n shutdownDrainTimeoutMs: 15_000,\n};\n\nexport function resolveLogPersistConfig(partial?: Partial<LogPersistConfig>): LogPersistConfig {\n const defaults = DEFAULT_LOG_PERSIST_CONFIG;\n return {\n fast: { ...defaults.fast, ...partial?.fast },\n medium: { ...defaults.medium, ...partial?.medium },\n slow: { ...defaults.slow, ...partial?.slow },\n postTimeoutMs: partial?.postTimeoutMs ?? defaults.postTimeoutMs,\n shutdownDrainTimeoutMs: partial?.shutdownDrainTimeoutMs ?? defaults.shutdownDrainTimeoutMs,\n };\n}\n\nexport function logPersistEnabledFromEnv(env: NodeJS.ProcessEnv = process.env): boolean {\n return envBool(\"LOG_PERSIST_ENABLED\", false, env);\n}\n\nexport function logPersistServiceFromEnv(env: NodeJS.ProcessEnv = process.env): string | undefined {\n const raw = env.LOG_PERSIST_SERVICE?.trim();\n return raw != null && raw !== \"\" ? raw : undefined;\n}\n\nexport function logPersistProcessFromEnv(env: NodeJS.ProcessEnv = process.env): string | undefined {\n const raw = env.LOG_PERSIST_PROCESS?.trim();\n return raw != null && raw !== \"\" ? raw : undefined;\n}\n\nexport function logPersistRegistryDirFromEnv(env: NodeJS.ProcessEnv = process.env): string | undefined {\n const configured = env.LOG_PERSIST_REGISTRY_DIR?.trim();\n if (configured != null && configured !== \"\") {\n return configured;\n }\n const runtime = env.RUNTIME_DATA_DIR?.trim();\n return runtime != null && runtime !== \"\" ? runtime : undefined;\n}\n\nexport function logPersistConfigFromEnv(env: NodeJS.ProcessEnv = process.env): LogPersistConfig {\n return resolveLogPersistConfig({\n fast: {\n maxBufferEntries: envInt(\"LOG_FAST_MAX_BUFFER_ENTRIES\", DEFAULT_LOG_PERSIST_CONFIG.fast.maxBufferEntries, {\n env,\n min: 1,\n }),\n },\n medium: {\n debounceMs: envMs(\"LOG_MEDIUM_DEBOUNCE_MS\", DEFAULT_LOG_PERSIST_CONFIG.medium.debounceMs, { env }),\n maxEntries: envInt(\"LOG_MEDIUM_MAX_ENTRIES\", DEFAULT_LOG_PERSIST_CONFIG.medium.maxEntries, {\n env,\n min: 1,\n }),\n maxBytes: envInt(\"LOG_MEDIUM_MAX_BYTES\", DEFAULT_LOG_PERSIST_CONFIG.medium.maxBytes, { env, min: 1 }),\n maxBufferEntries: envInt(\n \"LOG_MEDIUM_MAX_BUFFER_ENTRIES\",\n DEFAULT_LOG_PERSIST_CONFIG.medium.maxBufferEntries,\n { env, min: 1 },\n ),\n },\n slow: {\n maxEntries: envInt(\"LOG_SLOW_MAX_ENTRIES\", DEFAULT_LOG_PERSIST_CONFIG.slow.maxEntries, { env, min: 1 }),\n maxBytes: envInt(\"LOG_SLOW_MAX_BYTES\", DEFAULT_LOG_PERSIST_CONFIG.slow.maxBytes, { env, min: 1 }),\n maxAgeMs: envMs(\"LOG_SLOW_MAX_AGE_MS\", DEFAULT_LOG_PERSIST_CONFIG.slow.maxAgeMs, { env }),\n maxBufferEntries: envInt(\"LOG_SLOW_MAX_BUFFER_ENTRIES\", DEFAULT_LOG_PERSIST_CONFIG.slow.maxBufferEntries, {\n env,\n min: 1,\n }),\n },\n postTimeoutMs: envMs(\"LOG_PERSIST_POST_TIMEOUT_MS\", DEFAULT_LOG_PERSIST_CONFIG.postTimeoutMs, { env }),\n shutdownDrainTimeoutMs: envMs(\n \"LOG_PERSIST_SHUTDOWN_DRAIN_MS\",\n DEFAULT_LOG_PERSIST_CONFIG.shutdownDrainTimeoutMs,\n { env },\n ),\n });\n}\n","import { createHash } from \"node:crypto\";\nimport type { LogEntry } from \"./log-manager\";\nimport type { LogPersistLane } from \"./log-persist.interface\";\n\nconst BATCH_ID_VERSION = 1;\n\n/** Stable subset of LogEntry for idempotency hashing (same batch → same key). */\nfunction canonicalLogEntry(entry: LogEntry): Record<string, unknown> {\n return {\n timestamp: entry.timestamp,\n level: entry.level,\n message: entry.message,\n topic: entry.topic,\n module: entry.module,\n traceId: entry.traceId,\n traceParentId: entry.traceParentId ?? null,\n extra: entry.extra ?? null,\n data: entry.data ?? null,\n labels: entry.labels ?? null,\n };\n}\n\n/**\n * Deterministic List.value for a log batch — retries after timeout map to the same row key.\n * SHA-256 over canonical JSON (service + process + lane + entries in order).\n */\nexport function computeLogBatchIdempotencyKey(input: {\n service: string;\n process: string;\n lane: LogPersistLane;\n entries: LogEntry[];\n}): string {\n const payload = {\n v: BATCH_ID_VERSION,\n service: input.service,\n process: input.process,\n lane: input.lane,\n entries: input.entries.map(canonicalLogEntry),\n };\n\n const hash = createHash(\"sha256\").update(JSON.stringify(payload), \"utf8\").digest(\"hex\");\n return `${hash.slice(0, 32)}`;\n}\n","import { createLogger } from \"./create-logger\";\n\n/** User-facing / lifecycle logs — may be persisted like normal app logs. */\nexport const LOG_PERSIST_TOPIC = \"log-persist\";\n\n/** Operational logs from the persist pipeline — never re-offered to avoid feedback loops. */\nexport const LOG_PERSIST_INTERNAL_TOPIC = \"log-persist-internal\";\n\nconst logger = createLogger({ module: \"log-persist\" });\n\nexport function isLogPersistInternalTopic(topic: string | undefined): boolean {\n return topic === LOG_PERSIST_INTERNAL_TOPIC;\n}\n\ntype PersistLogData = Record<string, unknown>;\n\nfunction write(level: \"debug\" | \"info\" | \"warn\" | \"error\", message: string, data?: PersistLogData): void {\n logger[level](message, {\n topic: LOG_PERSIST_INTERNAL_TOPIC,\n ...(data != null ? { data } : {}),\n });\n}\n\nexport const persistLogger = {\n debug: (message: string, data?: PersistLogData) => write(\"debug\", message, data),\n info: (message: string, data?: PersistLogData) => write(\"info\", message, data),\n warn: (message: string, data?: PersistLogData) => write(\"warn\", message, data),\n error: (message: string, data?: PersistLogData) => write(\"error\", message, data),\n};\n\nexport function patchPersistLoggerScope(labels: Record<string, string>): void {\n logger.resetScope({ labels });\n}\n","import { isCreateTargetAlreadyExistsError } from \"../../core.api\";\nimport { postLogListCreate } from \"../../list/list.api\";\nimport { CategoryList } from \"../../list/list.interface\";\nimport type { LogEntry } from \"./log-manager\";\nimport { LOG_PERSIST_LOADER_KEY } from \"./log-persist.config\";\nimport type { BuildLogListDraftInput, LogListDraft } from \"./log-persist.interface\";\nimport { persistLogger } from \"./log-persist-logger\";\n\nexport function estimateEntriesBytes(entries: LogEntry[]): number {\n if (entries.length === 0) {\n return 0;\n }\n try {\n return Buffer.byteLength(JSON.stringify(entries), \"utf8\");\n } catch {\n return entries.length * 512;\n }\n}\n\nexport function buildLogListDraft(input: BuildLogListDraftInput): LogListDraft {\n const { service, process, lane, idempotencyKey, entries } = input;\n const first = entries[0];\n const last = entries[entries.length - 1];\n\n return {\n name: `${service}:${process}`,\n value: idempotencyKey,\n category: CategoryList.LIST,\n tagList: [\"log\", lane, service],\n details: {\n manifestVersion: 1,\n loaderKey: LOG_PERSIST_LOADER_KEY,\n meta: JSON.stringify({\n service,\n process,\n pid: globalThis.process.pid,\n lane,\n count: entries.length,\n from: first?.timestamp ?? null,\n to: last?.timestamp ?? null,\n flushedAt: Date.now(),\n idempotencyKey,\n }),\n preview: first?.message ?? \"\",\n items: entries,\n },\n };\n}\n\nasync function withTimeout<T>(promise: Promise<T>, timeoutMs: number, label: string): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n return await Promise.race([\n promise,\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error(`${label} timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n }),\n ]);\n } finally {\n if (timer != null) {\n clearTimeout(timer);\n }\n }\n}\n\nexport async function postLogBatch(draft: LogListDraft, postTimeoutMs: number): Promise<void> {\n try {\n const result = await withTimeout(\n postLogListCreate({\n name: draft.name,\n value: draft.value,\n category: draft.category,\n details: draft.details,\n }),\n postTimeoutMs,\n \"postLogListCreate\",\n );\n\n if (!result.success) {\n const message = result.error?.message ?? \"postLogListCreate failed\";\n persistLogger.error(\"post log batch failed\", {\n idempotencyKey: draft.value,\n name: draft.name,\n error: message,\n });\n throw new Error(message);\n }\n } catch (error) {\n if (isCreateTargetAlreadyExistsError(error)) {\n persistLogger.error(\"post log batch idempotent duplicate — treating as success\", {\n idempotencyKey: draft.value,\n name: draft.name,\n });\n return;\n }\n throw error;\n }\n}\n\n/** Take a prefix of entries that fits within maxBytes. */\nexport function takeEntriesWithinBytes(entries: LogEntry[], maxBytes: number): LogEntry[] {\n if (entries.length === 0) {\n return [];\n }\n\n const taken: LogEntry[] = [];\n for (const entry of entries) {\n const candidate = [...taken, entry];\n if (taken.length > 0 && estimateEntriesBytes(candidate) > maxBytes) {\n break;\n }\n taken.push(entry);\n }\n\n const result = taken.length > 0 ? taken : [entries[0]];\n if (result.length < entries.length) {\n persistLogger.warn(\"trimmed batch to maxBytes\", {\n requested: entries.length,\n taken: result.length,\n maxBytes,\n takenBytes: estimateEntriesBytes(result),\n });\n }\n\n return result;\n}\n","import { join } from \"node:path\";\nimport { createJsonFileStateStore } from \"../../node/fs/json-state-store\";\nimport type { LogPersistProcessRecord, LogPersistRegistryState } from \"./log-persist.interface\";\nimport { persistLogger } from \"./log-persist-logger\";\n\nconst DEFAULT_REGISTRY: LogPersistRegistryState = {\n updatedAt: new Date(0).toISOString(),\n service: \"\",\n processes: {},\n};\n\nconst stores = new Map<string, ReturnType<typeof createJsonFileStateStore<LogPersistRegistryState, \"processes\">>>();\n\nfunction storeFor(filePath: string) {\n let store = stores.get(filePath);\n if (store == null) {\n store = createJsonFileStateStore<LogPersistRegistryState, \"processes\">({\n filePath,\n defaultState: DEFAULT_REGISTRY,\n nestedKeys: [\"processes\"],\n updatedAtKey: \"updatedAt\",\n });\n stores.set(filePath, store);\n }\n return store;\n}\n\nexport function defaultLogPersistRegistryPath(registryDir: string): string {\n return join(registryDir, \"log-persist-registry.json\");\n}\n\nexport async function registerLogPersistProcess(input: {\n registryFilePath: string;\n service: string;\n process: string;\n}): Promise<void> {\n const now = new Date().toISOString();\n const record: LogPersistProcessRecord = {\n pid: process.pid,\n enabledAt: now,\n lastHeartbeatAt: now,\n };\n\n await storeFor(input.registryFilePath).write({\n service: input.service,\n processes: {\n [input.process]: record,\n },\n });\n\n persistLogger.info(\"registry process registered\", {\n registryFilePath: input.registryFilePath,\n service: input.service,\n process: input.process,\n pid: record.pid,\n });\n}\n\nexport async function heartbeatLogPersistProcess(input: { registryFilePath: string; process: string }): Promise<void> {\n const current = await storeFor(input.registryFilePath).read();\n const existing = current.processes[input.process];\n if (existing == null) {\n persistLogger.warn(\"registry heartbeat skipped — process not registered\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n return;\n }\n\n await storeFor(input.registryFilePath).write({\n processes: {\n [input.process]: {\n ...existing,\n lastHeartbeatAt: new Date().toISOString(),\n },\n },\n });\n}\n\nexport async function unregisterLogPersistProcess(input: { registryFilePath: string; process: string }): Promise<void> {\n const current = await storeFor(input.registryFilePath).read();\n const existing = current.processes[input.process];\n if (existing == null) {\n persistLogger.warn(\"registry unregister skipped — process not found\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n return;\n }\n\n await storeFor(input.registryFilePath).write({\n processes: {\n [input.process]: {\n ...existing,\n pid: 0,\n lastHeartbeatAt: new Date(0).toISOString(),\n },\n },\n });\n\n persistLogger.info(\"registry process unregistered\", {\n registryFilePath: input.registryFilePath,\n process: input.process,\n });\n}\n\nexport async function readLogPersistRegistry(registryFilePath: string): Promise<LogPersistRegistryState> {\n return storeFor(registryFilePath).read();\n}\n","import { type LogEntry, LogLevel } from \"./log-manager\";\nimport { DEFAULT_LOG_PERSIST_CONFIG, resolveLogPersistConfig } from \"./log-persist.config\";\nimport type {\n EnableLogPersistOptions,\n LogPersistConfig,\n LogPersistLane,\n LogPersistStats,\n} from \"./log-persist.interface\";\nimport { computeLogBatchIdempotencyKey } from \"./log-persist-batch-id\";\nimport { buildLogListDraft, estimateEntriesBytes, postLogBatch, takeEntriesWithinBytes } from \"./log-persist-flush\";\nimport { registerLogPersistOffer } from \"./log-persist-hook\";\nimport { isLogPersistInternalTopic, patchPersistLoggerScope, persistLogger } from \"./log-persist-logger\";\nimport { heartbeatLogPersistProcess } from \"./log-persist-registry\";\n\nconst FAST_RETRY_INTERVAL_MS = 5_000;\nconst HEARTBEAT_INTERVAL_MS = 30_000;\n\nfunction routeLane(level: LogLevel): LogPersistLane {\n if (level === LogLevel.CRITICAL) {\n return \"fast\";\n }\n if (level === LogLevel.ERROR || level === LogLevel.SUCCESS) {\n return \"medium\";\n }\n return \"slow\";\n}\n\nclass LogPersist {\n private static instance: LogPersist | null = null;\n\n private enabled = false;\n private draining = false;\n private service: string | null = null;\n private processName: string | null = null;\n private registryFilePath: string | null = null;\n private config: LogPersistConfig = DEFAULT_LOG_PERSIST_CONFIG;\n\n private fastQueue: LogEntry[] = [];\n private fastRetryQueue: LogEntry[] = [];\n private mediumQueue: LogEntry[] = [];\n private slowQueue: LogEntry[] = [];\n\n private mediumDebounceTimer: ReturnType<typeof setTimeout> | null = null;\n private slowQueueStartedAt: number | null = null;\n private fastRetryTimer: ReturnType<typeof setTimeout> | null = null;\n private heartbeatTimer: ReturnType<typeof setInterval> | null = null;\n private lastHeartbeatAt = 0;\n\n private laneFlushing: Record<LogPersistLane, boolean> = {\n fast: false,\n medium: false,\n slow: false,\n };\n\n private consecutiveFailures: Record<LogPersistLane, number> = {\n fast: 0,\n medium: 0,\n slow: 0,\n };\n\n private lastFlushAt: Record<LogPersistLane, string | null> = {\n fast: null,\n medium: null,\n slow: null,\n };\n\n private lastError: string | null = null;\n private lastErrorAt: string | null = null;\n private shutdownHookInstalled = false;\n private shutdownPromise: Promise<void> | null = null;\n\n static getInstance(): LogPersist {\n LogPersist.instance ??= new LogPersist();\n return LogPersist.instance;\n }\n\n async enable(options: EnableLogPersistOptions): Promise<void> {\n if (this.enabled) {\n persistLogger.warn(\"log persist core enable skipped — already enabled\", {\n service: this.service,\n process: this.processName,\n });\n return;\n }\n\n this.service = options.service;\n this.processName = options.process;\n this.registryFilePath = options.registryFilePath ?? null;\n this.config = resolveLogPersistConfig(options.config);\n this.draining = false;\n this.shutdownPromise = null;\n this.consecutiveFailures = { fast: 0, medium: 0, slow: 0 };\n this.lastError = null;\n this.lastErrorAt = null;\n this.enabled = true;\n\n patchPersistLoggerScope({\n service: options.service,\n process: options.process,\n });\n\n persistLogger.info(\"log persist core enabled\", {\n service: options.service,\n process: options.process,\n registryFilePath: this.registryFilePath,\n config: this.config,\n pid: process.pid,\n });\n\n registerLogPersistOffer((entry) => {\n this.offer(entry);\n });\n\n if (this.registryFilePath != null) {\n const { registerLogPersistProcess } = await import(\"./log-persist-registry\");\n await registerLogPersistProcess({\n registryFilePath: this.registryFilePath,\n service: options.service,\n process: options.process,\n });\n this.startHeartbeat();\n }\n\n this.installShutdownHook();\n }\n\n async disable(): Promise<void> {\n if (!this.enabled && !this.draining) {\n persistLogger.debug(\"disable skipped — not enabled\");\n return;\n }\n\n persistLogger.info(\"log persist core disabling\", this.queueSnapshot());\n this.cancelMediumDebounce();\n this.stopHeartbeat();\n await this.shutdown();\n persistLogger.info(\"log persist core disabled\");\n }\n\n offer(entry: LogEntry): void {\n if (isLogPersistInternalTopic(entry.topic)) {\n return;\n }\n\n if (!this.enabled || this.draining || this.service == null || this.processName == null) {\n return;\n }\n\n void this.touchRegistryHeartbeat();\n\n const lane = routeLane(entry.level);\n\n if (lane === \"fast\") {\n this.fastQueue.push(entry);\n this.evictFastOverflow();\n void this.flushFast();\n return;\n }\n\n if (lane === \"medium\") {\n this.mediumQueue.push(entry);\n this.evictMediumOverflow();\n this.scheduleMediumFlush();\n return;\n }\n\n this.slowQueue.push(entry);\n if (this.slowQueueStartedAt == null) {\n this.slowQueueStartedAt = Date.now();\n }\n this.evictSlowOverflow();\n this.scheduleSlowFlush();\n }\n\n getStats(): LogPersistStats {\n return {\n enabled: this.enabled,\n draining: this.draining,\n service: this.service,\n process: this.processName,\n queues: {\n fast: this.fastQueue.length,\n fastRetry: this.fastRetryQueue.length,\n medium: this.mediumQueue.length,\n slow: this.slowQueue.length,\n },\n queueBytes: {\n fast: estimateEntriesBytes(this.fastQueue),\n fastRetry: estimateEntriesBytes(this.fastRetryQueue),\n medium: estimateEntriesBytes(this.mediumQueue),\n slow: estimateEntriesBytes(this.slowQueue),\n },\n mediumDebouncePending: this.mediumDebounceTimer != null,\n laneFlushing: { ...this.laneFlushing },\n consecutiveFailures: { ...this.consecutiveFailures },\n config: this.config,\n lastFlushAt: { ...this.lastFlushAt },\n lastError: this.lastError,\n lastErrorAt: this.lastErrorAt,\n };\n }\n\n async shutdown(): Promise<void> {\n if (this.shutdownPromise != null) {\n return this.shutdownPromise;\n }\n\n this.shutdownPromise = this.shutdownInner();\n return this.shutdownPromise;\n }\n\n private async shutdownInner(): Promise<void> {\n if (this.draining) {\n return;\n }\n\n this.draining = true;\n this.enabled = false;\n registerLogPersistOffer(null);\n\n persistLogger.info(\"shutdown flush started\", this.queueSnapshot());\n\n this.cancelMediumDebounce();\n await this.drainQueues(this.config.shutdownDrainTimeoutMs);\n\n if (this.registryFilePath != null && this.processName != null) {\n const { unregisterLogPersistProcess } = await import(\"./log-persist-registry\");\n await unregisterLogPersistProcess({\n registryFilePath: this.registryFilePath,\n process: this.processName,\n });\n }\n\n if (this.hasQueued()) {\n persistLogger.warn(\"shutdown drain incomplete — queued logs dropped\", {\n ...this.queueSnapshot(),\n shutdownDrainTimeoutMs: this.config.shutdownDrainTimeoutMs,\n });\n this.fastQueue = [];\n this.fastRetryQueue = [];\n this.mediumQueue = [];\n this.slowQueue = [];\n this.slowQueueStartedAt = null;\n }\n\n persistLogger.info(\"shutdown flush completed\", this.queueSnapshot());\n }\n\n private hasQueued(): boolean {\n return (\n this.fastQueue.length > 0 ||\n this.fastRetryQueue.length > 0 ||\n this.mediumQueue.length > 0 ||\n this.slowQueue.length > 0\n );\n }\n\n private async drainQueues(timeoutMs: number): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (this.hasQueued() && Date.now() < deadline) {\n await this.flushFast();\n await this.flushMedium();\n await this.flushSlow();\n }\n }\n\n private recordLaneError(lane: LogPersistLane, error: unknown): void {\n const message = error instanceof Error ? error.message : String(error);\n this.lastError = message;\n this.lastErrorAt = new Date().toISOString();\n this.consecutiveFailures[lane] += 1;\n }\n\n private recordLaneSuccess(lane: LogPersistLane): void {\n this.lastError = null;\n this.consecutiveFailures[lane] = 0;\n }\n\n private queueSnapshot(): Record<string, unknown> {\n return {\n queues: {\n fast: this.fastQueue.length,\n fastRetry: this.fastRetryQueue.length,\n medium: this.mediumQueue.length,\n slow: this.slowQueue.length,\n },\n queueBytes: {\n fast: estimateEntriesBytes(this.fastQueue),\n fastRetry: estimateEntriesBytes(this.fastRetryQueue),\n medium: estimateEntriesBytes(this.mediumQueue),\n slow: estimateEntriesBytes(this.slowQueue),\n },\n laneFlushing: { ...this.laneFlushing },\n consecutiveFailures: { ...this.consecutiveFailures },\n lastError: this.lastError,\n };\n }\n\n private installShutdownHook(): void {\n if (this.shutdownHookInstalled) {\n return;\n }\n this.shutdownHookInstalled = true;\n\n const handler = (signal: NodeJS.Signals) => {\n persistLogger.info(\"shutdown signal received\", { signal });\n void this.shutdown();\n };\n process.once(\"SIGTERM\", handler);\n process.once(\"SIGINT\", handler);\n }\n\n private startHeartbeat(): void {\n this.stopHeartbeat();\n this.heartbeatTimer = setInterval(() => {\n void this.touchRegistryHeartbeat(true);\n }, HEARTBEAT_INTERVAL_MS);\n this.heartbeatTimer.unref?.();\n }\n\n private stopHeartbeat(): void {\n if (this.heartbeatTimer != null) {\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = null;\n }\n }\n\n private async touchRegistryHeartbeat(force = false): Promise<void> {\n if (this.registryFilePath == null || this.processName == null) {\n return;\n }\n const now = Date.now();\n if (!force && now - this.lastHeartbeatAt < HEARTBEAT_INTERVAL_MS) {\n return;\n }\n this.lastHeartbeatAt = now;\n await heartbeatLogPersistProcess({\n registryFilePath: this.registryFilePath,\n process: this.processName,\n });\n }\n\n private scheduleMediumFlush(): void {\n const { debounceMs, maxEntries, maxBytes } = this.config.medium;\n const queueBytes = estimateEntriesBytes(this.mediumQueue);\n if (this.mediumQueue.length >= maxEntries || queueBytes >= maxBytes) {\n persistLogger.warn(\"medium flush scheduled — threshold\", {\n reason: this.mediumQueue.length >= maxEntries ? \"maxEntries\" : \"maxBytes\",\n queueLength: this.mediumQueue.length,\n maxEntries,\n queueBytes,\n maxBytes,\n });\n this.cancelMediumDebounce();\n void this.flushMedium();\n return;\n }\n\n if (this.mediumDebounceTimer == null && this.mediumQueue.length > 0) {\n persistLogger.debug(\"medium flush debounce scheduled\", {\n debounceMs,\n queueLength: this.mediumQueue.length,\n queueBytes,\n });\n this.mediumDebounceTimer = setTimeout(() => {\n this.mediumDebounceTimer = null;\n persistLogger.debug(\"medium flush debounce fired\");\n void this.flushMedium();\n }, debounceMs);\n this.mediumDebounceTimer.unref?.();\n }\n }\n\n private cancelMediumDebounce(): void {\n if (this.mediumDebounceTimer != null) {\n clearTimeout(this.mediumDebounceTimer);\n this.mediumDebounceTimer = null;\n persistLogger.debug(\"medium flush debounce cancelled\");\n }\n }\n\n private scheduleSlowFlush(): void {\n const { maxEntries, maxBytes, maxAgeMs } = this.config.slow;\n const queueBytes = estimateEntriesBytes(this.slowQueue);\n const ageMs = this.slowQueueStartedAt != null ? Date.now() - this.slowQueueStartedAt : 0;\n if (this.slowQueue.length >= maxEntries || queueBytes >= maxBytes || ageMs >= maxAgeMs) {\n persistLogger.debug(\"slow flush scheduled — threshold\", {\n reason:\n this.slowQueue.length >= maxEntries\n ? \"maxEntries\"\n : queueBytes >= maxBytes\n ? \"maxBytes\"\n : \"maxAgeMs\",\n queueLength: this.slowQueue.length,\n maxEntries,\n queueBytes,\n maxBytes,\n ageMs,\n maxAgeMs,\n });\n void this.flushSlow();\n }\n }\n\n private evictFastOverflow(): void {\n const { maxBufferEntries } = this.config.fast;\n let evicted = 0;\n while (this.fastQueue.length + this.fastRetryQueue.length > maxBufferEntries) {\n const removed = this.fastQueue.length > 0 ? this.fastQueue.shift() : this.fastRetryQueue.shift();\n evicted += 1;\n persistLogger.warn(\"fast queue overflow — evicted entry\", {\n evictedLevel: removed?.level,\n evictedTopic: removed?.topic,\n fromRetryQueue: this.fastQueue.length === 0,\n maxBufferEntries,\n });\n }\n if (evicted > 0) {\n persistLogger.warn(\"fast queue overflow summary\", { evicted, maxBufferEntries });\n }\n }\n\n private evictMediumOverflow(): void {\n const { maxBufferEntries } = this.config.medium;\n let evicted = 0;\n while (this.mediumQueue.length > maxBufferEntries) {\n const successIndex = this.mediumQueue.findIndex((entry) => entry.level === LogLevel.SUCCESS);\n const removed = successIndex >= 0 ? this.mediumQueue.splice(successIndex, 1)[0] : this.mediumQueue.shift();\n evicted += 1;\n persistLogger.warn(\"medium queue overflow — evicted entry\", {\n evictedLevel: removed?.level,\n evictedTopic: removed?.topic,\n queueLength: this.mediumQueue.length,\n maxBufferEntries,\n });\n }\n if (evicted > 0) {\n persistLogger.warn(\"medium queue overflow summary\", {\n evicted,\n queueLength: this.mediumQueue.length,\n maxBufferEntries,\n });\n }\n }\n\n private evictSlowOverflow(): void {\n const { maxBufferEntries } = this.config.slow;\n let evicted = 0;\n while (this.slowQueue.length > maxBufferEntries) {\n const debugIndex = this.slowQueue.findIndex((entry) => entry.level === LogLevel.DEBUG);\n const removed = debugIndex >= 0 ? this.slowQueue.splice(debugIndex, 1)[0] : this.slowQueue.shift();\n evicted += 1;\n persistLogger.warn(\"slow queue overflow — evicted entry\", {\n evictedLevel: removed?.level,\n evictedTopic: removed?.topic,\n queueLength: this.slowQueue.length,\n maxBufferEntries,\n });\n }\n if (evicted > 0) {\n persistLogger.warn(\"slow queue overflow summary\", {\n evicted,\n queueLength: this.slowQueue.length,\n maxBufferEntries,\n });\n }\n if (this.slowQueue.length === 0) {\n this.slowQueueStartedAt = null;\n }\n }\n\n private async flushFast(): Promise<void> {\n if (this.laneFlushing.fast) {\n persistLogger.debug(\"fast flush skipped — already flushing\");\n return;\n }\n if (this.service == null || this.processName == null) {\n return;\n }\n\n this.laneFlushing.fast = true;\n try {\n while (this.fastQueue.length > 0 || this.fastRetryQueue.length > 0) {\n const fromRetry = this.fastQueue.length === 0;\n const entry = this.fastQueue.shift() ?? this.fastRetryQueue.shift();\n if (entry == null) {\n break;\n }\n\n const idempotencyKey = computeLogBatchIdempotencyKey({\n service: this.service,\n process: this.processName,\n lane: \"fast\",\n entries: [entry],\n });\n\n try {\n const draft = buildLogListDraft({\n service: this.service,\n process: this.processName,\n lane: \"fast\",\n idempotencyKey,\n entries: [entry],\n });\n persistLogger.debug(\"fast flush posting batch\", {\n idempotencyKey,\n fromRetry,\n level: entry.level,\n topic: entry.topic,\n });\n await postLogBatch(draft, this.config.postTimeoutMs);\n this.lastFlushAt.fast = new Date().toISOString();\n this.recordLaneSuccess(\"fast\");\n persistLogger.info(\"fast lane flushed\", {\n idempotencyKey,\n level: entry.level,\n topic: entry.topic,\n fastRetryRemaining: this.fastRetryQueue.length,\n });\n } catch (error) {\n this.recordLaneError(\"fast\", error);\n this.fastRetryQueue.push(entry);\n persistLogger.error(\"fast flush failed — queued for retry\", {\n idempotencyKey,\n error: this.lastError,\n retryInMs: FAST_RETRY_INTERVAL_MS,\n fastRetryQueue: this.fastRetryQueue.length,\n });\n this.scheduleFastRetry();\n break;\n }\n }\n } finally {\n this.laneFlushing.fast = false;\n }\n }\n\n private scheduleFastRetry(): void {\n if (this.fastRetryTimer != null) {\n return;\n }\n persistLogger.warn(\"fast flush retry scheduled\", { retryInMs: FAST_RETRY_INTERVAL_MS });\n this.fastRetryTimer = setTimeout(() => {\n this.fastRetryTimer = null;\n persistLogger.debug(\"fast flush retry timer fired\");\n void this.flushFast();\n }, FAST_RETRY_INTERVAL_MS);\n this.fastRetryTimer.unref?.();\n }\n\n private async flushMedium(): Promise<void> {\n if (this.laneFlushing.medium) {\n persistLogger.debug(\"medium flush skipped — already flushing\");\n return;\n }\n if (this.mediumQueue.length === 0) {\n return;\n }\n if (this.service == null || this.processName == null) {\n return;\n }\n\n this.laneFlushing.medium = true;\n try {\n while (this.mediumQueue.length > 0) {\n const batch = takeEntriesWithinBytes(this.mediumQueue, this.config.medium.maxBytes);\n if (batch.length === 0) {\n break;\n }\n\n const idempotencyKey = computeLogBatchIdempotencyKey({\n service: this.service,\n process: this.processName,\n lane: \"medium\",\n entries: batch,\n });\n const batchBytes = estimateEntriesBytes(batch);\n\n try {\n persistLogger.debug(\"medium flush posting batch\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n queueRemaining: this.mediumQueue.length,\n });\n const draft = buildLogListDraft({\n service: this.service,\n process: this.processName,\n lane: \"medium\",\n idempotencyKey,\n entries: batch,\n });\n await postLogBatch(draft, this.config.postTimeoutMs);\n this.mediumQueue.splice(0, batch.length);\n this.lastFlushAt.medium = new Date().toISOString();\n this.recordLaneSuccess(\"medium\");\n persistLogger.info(\"medium lane flushed\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n queueRemaining: this.mediumQueue.length,\n });\n } catch (error) {\n this.recordLaneError(\"medium\", error);\n persistLogger.error(\"medium flush failed — entries retained\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n error: this.lastError,\n queueRemaining: this.mediumQueue.length,\n });\n this.scheduleMediumFlush();\n break;\n }\n }\n } finally {\n this.laneFlushing.medium = false;\n }\n\n if (this.mediumQueue.length > 0 && !this.laneFlushing.medium) {\n this.scheduleMediumFlush();\n }\n }\n\n private async flushSlow(): Promise<void> {\n if (this.laneFlushing.slow) {\n persistLogger.debug(\"slow flush skipped — already flushing\");\n return;\n }\n if (this.slowQueue.length === 0) {\n return;\n }\n if (this.service == null || this.processName == null) {\n return;\n }\n\n this.laneFlushing.slow = true;\n try {\n while (this.slowQueue.length > 0) {\n const batch = takeEntriesWithinBytes(this.slowQueue, this.config.slow.maxBytes);\n if (batch.length === 0) {\n break;\n }\n\n const idempotencyKey = computeLogBatchIdempotencyKey({\n service: this.service,\n process: this.processName,\n lane: \"slow\",\n entries: batch,\n });\n const batchBytes = estimateEntriesBytes(batch);\n\n try {\n persistLogger.debug(\"slow flush posting batch\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n queueRemaining: this.slowQueue.length,\n });\n const draft = buildLogListDraft({\n service: this.service,\n process: this.processName,\n lane: \"slow\",\n idempotencyKey,\n entries: batch,\n });\n await postLogBatch(draft, this.config.postTimeoutMs);\n this.slowQueue.splice(0, batch.length);\n this.lastFlushAt.slow = new Date().toISOString();\n this.recordLaneSuccess(\"slow\");\n persistLogger.info(\"slow lane flushed\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n queueRemaining: this.slowQueue.length,\n });\n } catch (error) {\n this.recordLaneError(\"slow\", error);\n persistLogger.error(\"slow flush failed — entries retained\", {\n idempotencyKey,\n batchSize: batch.length,\n batchBytes,\n error: this.lastError,\n queueRemaining: this.slowQueue.length,\n });\n this.scheduleSlowFlush();\n break;\n }\n }\n\n if (this.slowQueue.length === 0) {\n this.slowQueueStartedAt = null;\n }\n } finally {\n this.laneFlushing.slow = false;\n }\n\n if (this.slowQueue.length > 0 && !this.laneFlushing.slow) {\n this.scheduleSlowFlush();\n }\n }\n}\n\nexport { LogPersist };\n","import { resolve } from \"node:path\";\nimport { envBool } from \"../../node/env/env-parsers\";\nimport { readEnv, requireEnv } from \"../../node/env/require-env\";\nimport { pollUntil } from \"../../node/readiness\";\nimport { createLogger } from \"./create-logger\";\nimport { LogPersist } from \"./log-persist\";\nimport {\n logPersistConfigFromEnv,\n logPersistEnabledFromEnv,\n logPersistProcessFromEnv,\n logPersistRegistryDirFromEnv,\n logPersistServiceFromEnv,\n resolveLogPersistConfig,\n} from \"./log-persist.config\";\nimport type {\n EnableLogPersistOptions,\n EnsureLogPersistFromEnvOptions,\n LogPersistReadySnapshot,\n LogPersistStats,\n WaitForLogPersistReadyOptions,\n} from \"./log-persist.interface\";\nimport { registerLogPersistOffer } from \"./log-persist-hook\";\nimport { LOG_PERSIST_TOPIC, persistLogger } from \"./log-persist-logger\";\nimport { defaultLogPersistRegistryPath, readLogPersistRegistry } from \"./log-persist-registry\";\n\nexport { logPersistEnabledFromEnv };\n\nfunction resolveRegistryFilePath(explicit?: string): string {\n if (explicit != null && explicit.trim() !== \"\") {\n return resolve(explicit);\n }\n const dir = logPersistRegistryDirFromEnv();\n if (dir == null) {\n throw new Error(\n \"[LogPersist] registry path required: set registryFilePath option or LOG_PERSIST_REGISTRY_DIR / RUNTIME_DATA_DIR\",\n );\n }\n return defaultLogPersistRegistryPath(resolve(dir));\n}\n\nexport async function enableLogPersist(options: EnableLogPersistOptions): Promise<void> {\n const registryFilePath = options.registryFilePath != null ? resolve(options.registryFilePath) : undefined;\n const resolvedRegistry = registryFilePath ?? resolveRegistryFilePath();\n\n const envConfig = logPersistConfigFromEnv();\n await LogPersist.getInstance().enable({\n ...options,\n registryFilePath: resolvedRegistry,\n config: resolveLogPersistConfig({\n fast: { ...envConfig.fast, ...options.config?.fast },\n medium: { ...envConfig.medium, ...options.config?.medium },\n slow: { ...envConfig.slow, ...options.config?.slow },\n postTimeoutMs: options.config?.postTimeoutMs ?? envConfig.postTimeoutMs,\n shutdownDrainTimeoutMs: options.config?.shutdownDrainTimeoutMs ?? envConfig.shutdownDrainTimeoutMs,\n }),\n });\n}\n\nexport async function disableLogPersist(): Promise<void> {\n await LogPersist.getInstance().disable();\n}\n\nexport function getLogPersistStats(): LogPersistStats {\n return LogPersist.getInstance().getStats();\n}\n\n/**\n * Enable log persistence when LOG_PERSIST_ENABLED=true.\n * `process` / `service` can be passed explicitly or via LOG_PERSIST_PROCESS / LOG_PERSIST_SERVICE.\n */\nexport async function ensureLogPersistFromEnv(options: EnsureLogPersistFromEnvOptions = {}): Promise<boolean> {\n if (!logPersistEnabledFromEnv()) {\n registerLogPersistOffer(null);\n return false;\n }\n\n const service = options.service ?? logPersistServiceFromEnv();\n const processName = options.process ?? logPersistProcessFromEnv();\n if (service == null || service === \"\") {\n throw new Error(\"[LogPersist] LOG_PERSIST_SERVICE is required when LOG_PERSIST_ENABLED=true\");\n }\n if (processName == null || processName === \"\") {\n throw new Error(\n \"[LogPersist] LOG_PERSIST_PROCESS is required when LOG_PERSIST_ENABLED=true (or pass process option)\",\n );\n }\n\n const registryFilePath =\n options.registryFilePath != null ? resolve(options.registryFilePath) : resolveRegistryFilePath();\n\n await enableLogPersist({\n service,\n process: processName,\n registryFilePath,\n config: options.config,\n });\n\n const lifecycleLogger = createLogger({ module: \"log-persist\" });\n lifecycleLogger.info(\"log persist enabled from env\", {\n topic: LOG_PERSIST_TOPIC,\n data: { service, process: processName, registryFilePath },\n });\n\n return true;\n}\n\n/**\n * Preload guard: when persistence is enabled, required env must be present before app code runs.\n */\nexport function validateLogPersistPreloadEnv(env: NodeJS.ProcessEnv = process.env): void {\n if (!envBool(\"LOG_PERSIST_ENABLED\", false, env)) {\n return;\n }\n\n const missing: string[] = [];\n if (readEnv(\"LOG_PERSIST_SERVICE\", env) == null) {\n missing.push(\"LOG_PERSIST_SERVICE\");\n }\n const registryDir = logPersistRegistryDirFromEnv(env);\n if (registryDir == null) {\n missing.push(\"LOG_PERSIST_REGISTRY_DIR or RUNTIME_DATA_DIR\");\n }\n\n if (missing.length > 0) {\n throw new Error(`[LogPersist] preload env incomplete: ${missing.join(\", \")}`);\n }\n}\n\nfunction evaluateLogPersistReady(\n state: Awaited<ReturnType<typeof readLogPersistRegistry>>,\n expectedProcesses: string[],\n staleMs: number,\n now: number,\n): LogPersistReadySnapshot {\n const missing: string[] = [];\n const stale: string[] = [];\n const registered: string[] = [];\n\n for (const processName of expectedProcesses) {\n const record = state.processes[processName];\n if (record == null) {\n missing.push(processName);\n continue;\n }\n\n const heartbeatAt = Date.parse(record.lastHeartbeatAt);\n if (!Number.isFinite(heartbeatAt) || now - heartbeatAt > staleMs) {\n stale.push(processName);\n continue;\n }\n\n registered.push(processName);\n }\n\n return {\n ok: missing.length === 0 && stale.length === 0,\n missing,\n stale,\n registered,\n };\n}\n\n/**\n * Wait until every expected process has registered in the shared registry with a fresh heartbeat.\n * Call from the service main process after spawning children.\n */\nexport async function waitForLogPersistReady(options: WaitForLogPersistReadyOptions): Promise<LogPersistReadySnapshot> {\n const timeoutMs = options.timeoutMs ?? 60_000;\n const pollIntervalMs = options.pollIntervalMs ?? 500;\n const staleMs = options.staleMs ?? 90_000;\n\n let last: LogPersistReadySnapshot = {\n ok: false,\n missing: [...options.expectedProcesses],\n stale: [],\n registered: [],\n };\n\n try {\n await pollUntil({\n intervalMs: pollIntervalMs,\n timeoutMs,\n until: async () => {\n const state = await readLogPersistRegistry(options.registryFilePath);\n if (state.service !== options.service) {\n last = {\n ok: false,\n missing: options.expectedProcesses,\n stale: [],\n registered: [],\n };\n return false;\n }\n last = evaluateLogPersistReady(state, options.expectedProcesses, staleMs, Date.now());\n return last.ok;\n },\n });\n } catch {\n persistLogger.warn(\"waitForLogPersistReady timed out\", {\n timeoutMs,\n expectedProcesses: options.expectedProcesses,\n ...last,\n });\n }\n\n return last;\n}\n\nexport async function snapshotLogPersistReady(options: {\n registryFilePath: string;\n service: string;\n expectedProcesses: string[];\n staleMs?: number;\n}): Promise<LogPersistReadySnapshot> {\n const state = await readLogPersistRegistry(options.registryFilePath);\n return evaluateLogPersistReady(state, options.expectedProcesses, options.staleMs ?? 90_000, Date.now());\n}\n\nexport function resolveLogPersistRegistryPath(registryDir?: string): string {\n const dir = registryDir ?? logPersistRegistryDirFromEnv();\n if (dir == null) {\n requireEnv(\"LOG_PERSIST_REGISTRY_DIR\");\n }\n return def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