feat: implement metadata catalog database management

This commit is contained in:
Codex
2026-08-27 22:43:54 +02:00
parent 705af3aeb2
commit 79c4c925b5
86 changed files with 12566 additions and 135 deletions
+22 -1
View File
@@ -6,6 +6,9 @@ cd "$(dirname "$0")/.."
test -f .env.example
test -f deploy/env/local.env.example
test -f deploy/env/server.env.example
test -f docker/catalog-db-init.sql
grep -q "pg_read_file('/run/secrets/catalog_runtime_password')" docker/catalog-db-init.sql
grep -q "CREATE ROLE thothii_catalog_runtime" docker/catalog-db-init.sql
rendered=$(mktemp)
trap 'rm -f "$rendered"' EXIT HUP INT TERM
@@ -18,7 +21,7 @@ const fs = require("fs");
const config = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
const services = Object.keys(config.services).sort();
if (services.join(",") !== "core,embedding,embedding-model-init,frontend,qdrant") {
if (services.join(",") !== "catalog-db,core,embedding,embedding-model-init,frontend,qdrant") {
throw new Error(`unexpected service set: ${services.join(",")}`);
}
if (/omics_portal|chirone|localllm_default|\/home\/chirone/i.test(JSON.stringify(config))) {
@@ -26,6 +29,7 @@ if (/omics_portal|chirone|localllm_default|\/home\/chirone/i.test(JSON.stringify
}
const expectedVolumes = [
"auth-state",
"catalog-data",
"embedding-models",
"pi-state",
"qdrant-data",
@@ -43,12 +47,19 @@ const frontend = config.services.frontend;
const qdrant = config.services.qdrant;
const embedding = config.services.embedding;
const modelInit = config.services["embedding-model-init"];
const catalog = config.services["catalog-db"];
if (!frontend.ports?.some((port) => port.host_ip === "127.0.0.1")) {
throw new Error("local frontend must publish a loopback port");
}
for (const service of [embedding, modelInit]) {
if ((service.ports || []).length !== 0) throw new Error("private semantic services must not publish host ports");
}
if ((catalog.ports || []).length !== 0) throw new Error("catalog database must not publish host ports");
if (!catalog.healthcheck) throw new Error("catalog database must define a healthcheck");
const catalogHealthcheck = JSON.stringify(catalog.healthcheck.test || []);
if (!catalogHealthcheck.includes("pg_isready") || !catalogHealthcheck.includes("thothii_catalog_runtime")) {
throw new Error("catalog database healthcheck must verify readiness and the runtime role");
}
if (!qdrant.ports?.some((port) => port.host_ip === "127.0.0.1" && Number(port.target) === 6333)) {
throw new Error("local Qdrant dashboard must publish only its loopback port");
}
@@ -65,6 +76,9 @@ if (embedding.image !== "ollama/ollama:0.32.0@sha256:57f573b47f1f71ebb445789f279
if (modelInit.image !== "ollama/ollama:0.32.0@sha256:57f573b47f1f71ebb445789f279fe3e596a8beab182f7cf486db9205bad87c5a") {
throw new Error("embedding-model-init image must be pinned by version and digest");
}
if (catalog.image !== "postgres:17.6-bookworm@sha256:f3bd19c606e442c3d7bdfa8002e03fe260a1023351e0ea4598032022b68dd6e3") {
throw new Error("catalog PostgreSQL image must be pinned by version and digest");
}
const env = core.environment || {};
for (const [key, value] of Object.entries({
THT_WORKSPACE_INSTALLATION_ID: "local",
@@ -74,6 +88,10 @@ for (const [key, value] of Object.entries({
THT_INTERNAL_EMBEDDING_URL: "http://embedding:11434",
THT_INTERNAL_EMBEDDING_MODEL: "qwen3-embedding:0.6b",
THT_INTERNAL_EMBEDDING_DIMENSIONS: "1024",
THT_CATALOG_DB_HOST: "catalog-db",
THT_CATALOG_DB_NAME: "thothii_catalog",
THT_CATALOG_RUNTIME_USER: "thothii_catalog_runtime",
THT_CATALOG_RUNTIME_PASSWORD_FILE: "/run/secrets/catalog_runtime_password",
})) {
if (env[key] !== value) throw new Error(`unexpected core ${key}: ${env[key]}`);
}
@@ -98,6 +116,9 @@ const depends = core.depends_on || {};
if (depends.qdrant?.condition !== "service_healthy") {
throw new Error("core must wait for qdrant health");
}
if (depends["catalog-db"]?.condition !== "service_healthy") {
throw new Error("core must wait for catalog database health");
}
if (depends["embedding-model-init"]?.condition !== "service_completed_successfully") {
throw new Error("core must wait for embedding-model-init success");
}