Publish documentation / publish (push) Successful in 1m27s
Add PostgreSQL-backed memory, editable evidence with source review and activation, and human-approved archive repairs across the harness, API, and UI. Include migrations, deployment support, regression coverage, and validation documentation. Refresh permissions from validated session roles so existing administrator logins can access newly deployed archive management features.
24 lines
1.4 KiB
TypeScript
24 lines
1.4 KiB
TypeScript
import type { ThtRunner } from "../tht/tht-runner.js";
|
|
import type { SemanticRuntimeConfig } from "../workspaces/runtime-renderer.js";
|
|
import type { CatalogSyncRun, WorkspaceDatabase } from "./types.js";
|
|
|
|
/** Internal continuation of an applied physical sync, using the harness Memory boundary. */
|
|
export function createMemoryCleanup(runner: Pick<ThtRunner, "withPrincipal">, runtime: SemanticRuntimeConfig) {
|
|
return async (database: WorkspaceDatabase, run: CatalogSyncRun): Promise<number> => {
|
|
if (run.phase !== "memory_cleanup" || !run.plannedDiff) throw new Error("Physical cleanup is not committed");
|
|
const result = await runner.withPrincipal({ issuer: "installation", subject: "catalog-sync",
|
|
roles: ["admin"], permissions: ["memory.manage"], isAdmin: true,
|
|
}).runWithRuntimeSnapshot(["memory", "admin", "--workspace", database.workspaceId], JSON.stringify({
|
|
action: "cleanup", runtime, request: { sync_id: run.id, database: database.databaseName,
|
|
schema_name: database.schema, removed_tables: run.plannedDiff.deletedTables,
|
|
removed_columns: run.plannedDiff.deletedColumns.map(column => ({ table: column.tableName, column: column.columnName })),
|
|
},
|
|
}));
|
|
const payload = JSON.parse(result.stdout);
|
|
if (result.code !== 0 || payload.indexed !== true || !Number.isInteger(payload.deleted) || payload.deleted < 0) {
|
|
throw new Error("Memory cleanup is incomplete");
|
|
}
|
|
return payload.deleted;
|
|
};
|
|
}
|