import { readFileSync, readdirSync } from "node:fs"; const directory = new URL("../deploy/ack/", import.meta.url); const files = readdirSync(directory).filter((name) => name.endsWith(".yaml")).sort(); for (const file of files) { const text = readFileSync(new URL(file, directory), "utf8"); assert(text.includes("apiVersion:"), `${file}: missing apiVersion`); assert(text.includes("kind:"), `${file}: missing kind`); assert(!text.includes("server-snippet"), `${file}: must not depend on disabled snippet annotations`); } const migrationJob = read("migration-job.yaml"); assert(migrationJob.includes("name: ZHINIAN_DATA_BACKEND\n value: postgres"), "migration Job must select postgres"); assert(migrationJob.includes("name: DATABASE_APP_ROLE"), "migration Job must provision the Web role"); assert(migrationJob.includes("secretName: zhinian-rds-ca"), "migration Job must mount the RDS CA"); const web = read("web.yaml"); assert(/^\s*replicas: 1\s*$/m.test(web), "Web must default to one replica until object storage is shared"); assert(web.includes("path: /api/health"), "Web must use process-level readiness (it is database-free in production)"); assert(!web.includes("zhinian-web-db"), "Web must not hold RDS credentials in production"); assert(!web.includes("rds-ca"), "Web must not mount the RDS CA in production"); const goApi = read("go-api.yaml"); assert(/^\s*replicas: 1\s*$/m.test(goApi), "Go API must default to one replica until object storage is shared"); assert(goApi.includes("path: /api/ready"), "Go API must use database-aware readiness"); assert(goApi.includes("runAsNonRoot: true"), "Go API must run as a non-root user"); assert(goApi.includes("name: zhinian-go-runtime"), "Go API must consume the Go runtime ConfigMap"); assert(goApi.includes("name: zhinian-go-bootstrap"), "Go API must receive bootstrap administrator credentials"); assert(goApi.includes("secretName: zhinian-rds-ca"), "Go API must mount the RDS CA"); const configMap = read("configmap.yaml"); assert(configMap.includes("ZHINIAN_GO_EMBEDDED_WORKER: \"true\""), "Go runtime ConfigMap must embed the WorkerLoop"); const ingress = read("ingress.yaml"); assert(ingress.includes("path: /api/internal/worker"), "Ingress must intercept the internal worker prefix"); assert(ingress.includes("name: zhinian-public-deny"), "Ingress must route the internal prefix away from the workloads"); assert(ingress.includes("name: zhinian-go-api"), "Ingress must route backend paths to the Go API Service"); assert(ingress.includes("path: /uploads"), "Ingress must route /uploads to the Go API"); assert(ingress.includes("path: /generated-results"), "Ingress must route /generated-results to the Go API"); assert(ingress.includes("name: zhinian-web"), "Ingress must route pages/static paths to Web"); const service = read("service.yaml"); assert(service.includes("name: zhinian-public-deny"), "selectorless deny Service is required"); console.log(`ACK manifest assertions passed (${files.length} files)`); function read(file) { return readFileSync(new URL(file, directory), "utf8").replace(/\r\n/g, "\n"); } function assert(condition, message) { if (!condition) throw new Error(message); }