fix: address monitor ingest review blockers

This commit is contained in:
AgentRun Codex
2026-07-12 21:30:17 +00:00
parent 35a59b27c6
commit 9b9a460d37
8 changed files with 198 additions and 86 deletions
+4 -2
View File
@@ -2,7 +2,7 @@
// Responsibility: Explicit one-shot SQLite snapshot import through the central Monitor PostgreSQL store.
import { readFileSync } from "node:fs";
import { createPostgresMonitorCentralStore, structuredMonitorCentralError } from "./src/monitor-central-persistence";
import { createPostgresMonitorCentralStore, MONITOR_CENTRAL_SCHEMA_VERSION, structuredMonitorCentralError } from "./src/monitor-central-persistence";
import { importMonitorSqliteSnapshot, type MonitorSqliteSnapshot } from "./src/monitor-sqlite-migration";
function required(name: string): string {
@@ -22,7 +22,9 @@ try {
if (!snapshotPath) throw Object.assign(new Error("snapshot path is required"), { code: "monitor_migration_snapshot_missing" });
const snapshot = JSON.parse(readFileSync(snapshotPath, "utf8")) as MonitorSqliteSnapshot;
const store = createPostgresMonitorCentralStore(required("DATABASE_URL"), { poolMax: positive("MONITOR_CENTRAL_PG_POOL_MAX"), idleTimeoutSeconds: positive("MONITOR_CENTRAL_PG_IDLE_TIMEOUT_SECONDS") });
await store.migrate();
await store.ping();
if (await store.schemaVersion() !== MONITOR_CENTRAL_SCHEMA_VERSION) throw Object.assign(new Error("central monitor schema is not ready"), { code: "monitor_migration_schema_unready" });
if (!(await store.capability()).ingest) throw Object.assign(new Error("central monitor ingest capability is unavailable"), { code: "monitor_migration_capability_unavailable" });
console.log(JSON.stringify(await importMonitorSqliteSnapshot(snapshot, store)));
} catch (error) {
console.log(JSON.stringify({ ok: false, error: structuredMonitorCentralError(error), valuesRedacted: true }));