feat: prepare installation workspaces through existing readiness services
This commit is contained in:
@@ -95,7 +95,7 @@ export async function publishInstallation(options) {
|
||||
await run('docker', ['info', '--format', '{{.OSType}}']);
|
||||
await run('docker', ['buildx', 'version']);
|
||||
const registry = dockerHub(await dockerCredentials(run));
|
||||
const hosting = await giteaHosting({ run, repository: options.repository, identity, body: `Installer prerelease for ${identity.platforms.join(', ')}.\n\nImages: docker.io/${identity.namespace}/thothii-core:${identity.version} and docker.io/${identity.namespace}/thothii-frontend:${identity.version}.\n\nDownload the native operator bundle and SHA256SUMS.txt below. This release supplies images, document validation, preflight and non-interactive platform apply. Database binding import, workspace readiness and Windows/Omarchy/macOS acceptance remain subsequent steps. No example databases, credentials or user workspace data are included.` });
|
||||
const hosting = await giteaHosting({ run, repository: options.repository, identity, body: `Installer prerelease for ${identity.platforms.join(', ')}.\n\nImages: docker.io/${identity.namespace}/thothii-core:${identity.version} and docker.io/${identity.namespace}/thothii-frontend:${identity.version}.\n\nDownload the native operator bundle and SHA256SUMS.txt below. This release supplies images, document validation, preflight, non-interactive platform apply, prepared binding import and workspace/runtime readiness checks. Destructive schema review remains a human decision. Windows/Omarchy/macOS and human-reviewed question acceptance remain subsequent steps. No example databases, credentials or user workspace data are included.` });
|
||||
async function prepare() {
|
||||
if (state.assets) {
|
||||
const names = [...identity.platforms.map((platform) => `thothii-${identity.version}-${platform.replace('/', '-')}.tar.gz`), 'SHA256SUMS.txt'];
|
||||
|
||||
@@ -46,8 +46,8 @@ export function prepareBundle({ source, destination, platform, version, revision
|
||||
|
||||
Source / Sorgente: ${revision}
|
||||
|
||||
This prerelease provides images, document/preflight tools and non-interactive platform apply. Database binding import, workspace readiness and Windows/Omarchy/macOS acceptance remain separate steps; this is not a certified complete installation.
|
||||
Questa prerelease fornisce immagini, preparazione/preflight e avvio non interattivo della piattaforma. Import dei binding, readiness workspace e collaudi Windows/Omarchy/macOS restano passi separati: non è ancora un'installazione completa certificata.
|
||||
This prerelease provides images, document/preflight tools, non-interactive platform apply, prepared binding import and workspace/runtime readiness checks. A pending destructive schema review stops apply for a human decision. Windows/Omarchy/macOS and human-reviewed question acceptance remain separate; this is not a certified complete installation.
|
||||
Questa prerelease fornisce immagini, preparazione/preflight, avvio non interattivo, import dei binding e controlli di readiness workspace/runtime. Una revisione distruttiva dello schema ferma apply per una decisione umana. Collaudi Windows/Omarchy/macOS e domanda con revisione umana restano separati: non è ancora un'installazione completa certificata.
|
||||
|
||||
Use bin/tht and its sibling bin/tht-workspace-documents together; no Node, Python, Bun or application checkout is required on the consumer host.
|
||||
Windows: use the Linux amd64 bundle inside Ubuntu WSL2, not a native Windows shell.
|
||||
|
||||
@@ -15,10 +15,34 @@ import {
|
||||
import { WorkspaceSecretStore } from "../src/workspaces/secret-store.js";
|
||||
import type { WorkspaceRegistry, WorkspaceRevision } from "../src/workspaces/registry.js";
|
||||
import type { WorkspaceDescriptor } from "../src/workspaces/schema.js";
|
||||
// @ts-expect-error The native operator embeds this plain ESM client.
|
||||
import { prepareWorkspace } from "../../tools/tht/internal/installapply/import-bindings.mjs";
|
||||
|
||||
const roots: string[] = [];
|
||||
afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
|
||||
|
||||
test("installation retry preserves the durable destructive review and source comments", async () => {
|
||||
const { app, repository, database, setObserved } = await setup();
|
||||
try {
|
||||
await seedCatalog(repository, database);
|
||||
const tablesBefore = await repository.listTables(database.id);
|
||||
setObserved({ schemaVersion: 1, capabilities: { tables: "available", columns: "available", relationships: "available" }, tables: [], columns: [], relationships: [] });
|
||||
const started = await app.inject({ method: "POST", url: `/catalog/databases/${database.id}/sync-runs`, payload: { version: database.version, scope: "all", tableIds: [] } });
|
||||
const run = await waitFor(repository, started.json().id, "awaiting_confirmation");
|
||||
const request = async (path: string, body?: unknown) => {
|
||||
expect(body).toBeUndefined();
|
||||
const response = await app.inject({ method: "GET", url: path });
|
||||
return new Response(response.body, { status: response.statusCode, headers: { "content-type": "application/json" } });
|
||||
};
|
||||
for (let attempt = 0; attempt < 2; attempt++) {
|
||||
await expect(prepareWorkspace(request, "psd-clinical", revision.commit)).rejects.toMatchObject({ code: "schema_review_required", runId: run.id });
|
||||
}
|
||||
expect(await repository.listTables(database.id)).toEqual(tablesBefore);
|
||||
expect(await repository.listSyncRuns(database.id)).toHaveLength(1);
|
||||
expect((await repository.getSyncRun(run.id))?.state).toBe("awaiting_confirmation");
|
||||
} finally { await app.close(); }
|
||||
});
|
||||
|
||||
const workspace: WorkspaceDescriptor = {
|
||||
workspace: { schema_version: 4, id: "psd-clinical", name: "Policlinico San Donato", language: "it" },
|
||||
dwh: { engine: "postgres", database: "warehouse", schema: "datawarehouse", port: 5432, supported_transports: ["postgres_direct"] },
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { expect, test } from "vitest";
|
||||
// The shipped operator client is plain ESM, shared by the embedded command and these API-boundary tests.
|
||||
// @ts-expect-error JavaScript operator module has no separate declaration file.
|
||||
import { prepareWorkspace } from "../../tools/tht/internal/installapply/import-bindings.mjs";
|
||||
|
||||
const revision = "a".repeat(40);
|
||||
|
||||
test.each(["blocked", "failed"])("configured Evidence/index failure (%s) remains a real stop", async state => {
|
||||
const request = async (path: string, body?: unknown): Promise<Response> => {
|
||||
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2, schemaSyncedVersion: 2,
|
||||
binding: { transport: "postgres_direct" }, workspaceRevision: { commit: revision } }]);
|
||||
if (path.endsWith("/sync-runs")) return Response.json([]);
|
||||
if (path.endsWith("/preprocessing")) return Response.json({ state }, { status: body === undefined ? 200 : 422 });
|
||||
throw Error("unexpected destructive operation");
|
||||
};
|
||||
await expect(prepareWorkspace(request, "chinook", revision, async () => {})).rejects.toMatchObject({ code: `preprocessing_${state}` });
|
||||
});
|
||||
|
||||
test("SSH metadata connectivity cannot be mistaken for session transport support", async () => {
|
||||
const calls: string[] = [];
|
||||
const request = async (path: string) => {
|
||||
calls.push(path);
|
||||
return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2,
|
||||
binding: { transport: "ssh_tunnel" }, workspaceRevision: { commit: revision } }]);
|
||||
};
|
||||
await expect(prepareWorkspace(request, "chinook", revision)).rejects.toMatchObject({ code: "session_transport_unsupported" });
|
||||
expect(calls).toEqual(["/catalog/databases"]);
|
||||
});
|
||||
test("a destructive synchronization stops at the existing domain gate without confirmation", async () => {
|
||||
const calls: string[] = [];
|
||||
const request = async (path: string) => {
|
||||
calls.push(path);
|
||||
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2,
|
||||
binding: { transport: "postgres_direct" }, workspaceRevision: { commit: revision } }]);
|
||||
if (path.endsWith("/sync-runs")) return Response.json([{ id: "run-id", state: "awaiting_confirmation", scope: "all" }]);
|
||||
throw Error("unexpected operation");
|
||||
};
|
||||
await expect(prepareWorkspace(request, "chinook", revision)).rejects.toMatchObject({ code: "schema_review_required", runId: "run-id" });
|
||||
expect(calls).toEqual(["/catalog/databases", "/catalog/databases/database-id/sync-runs"]);
|
||||
});
|
||||
|
||||
test("fresh additive sync and preprocessing use existing APIs once, then repeat as a no-op", async () => {
|
||||
const writes: string[] = [];
|
||||
let synchronized = false, preprocessed = false;
|
||||
const request = async (path: string, body?: unknown) => {
|
||||
if (body !== undefined) writes.push(path);
|
||||
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2,
|
||||
schemaSyncedVersion: synchronized ? 2 : undefined,
|
||||
binding: { transport: "postgres_direct" }, workspaceRevision: { commit: revision } }]);
|
||||
if (path === "/catalog/databases/database-id") return Response.json({ version: 2, schemaSyncedVersion: 2 });
|
||||
if (path.endsWith("/sync-runs")) {
|
||||
if (body) { expect(body).toEqual({ version: 2, scope: "all", tableIds: [] }); return Response.json({ id: "run-id", state: "queued", scope: "all" }); }
|
||||
return Response.json(synchronized ? [{ id: "run-id", state: "succeeded", scope: "all" }] : []);
|
||||
}
|
||||
if (path === "/catalog/sync-runs/run-id") { synchronized = true; return Response.json({ id: "run-id", state: "succeeded", scope: "all" }); }
|
||||
if (path === "/workspaces/chinook/preprocessing") {
|
||||
if (body) preprocessed = true;
|
||||
return Response.json({ state: preprocessed ? "ready" : "required" });
|
||||
}
|
||||
throw Error("unexpected operation");
|
||||
};
|
||||
expect(await prepareWorkspace(request, "chinook", revision, async () => {})).toEqual({ workspaceId: "chinook", state: "ready" });
|
||||
expect(await prepareWorkspace(request, "chinook", revision, async () => {})).toEqual({ workspaceId: "chinook", state: "ready" });
|
||||
expect(writes).toEqual(["/catalog/databases/database-id/sync-runs", "/workspaces/chinook/preprocessing"]);
|
||||
});
|
||||
Reference in New Issue
Block a user