AI Engineering Workspace
PartialChat, files, terminal and preview in one place. Chat sessions run on a durable Postgres-backed queue (chat only: no tools or shell). Live models need an API key; the terminal is unavailable.
Project files
read-onlyapp/qa/deploy-flow.mjs
1// Marketplace + remote deployment flow, against the live HTTPS edge, driving the REAL agent binary (0.2.0) as a subprocess.2// HONEST SCOPE: the agent and the hosted apps run on THIS host (same machine as the control plane). That is a LOCAL test, not an independent external-VPS verification.3import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import crypto from "node:crypto"; import { spawn, spawnSync } from "node:child_process"; import { fileURLToPath } from "node:url";4import { chromium, request } from "playwright"; import pg from "pg";5const here = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(here, "../.."); const BASE = process.argv[2] || "https://127.0.0.1:8443"; const O = { origin: BASE };6const TOKEN = fs.readFileSync(path.join(os.homedir(), ".config/zoo-cloud-studio/admin-token"), "utf8").trim();7const results = []; const rec = (n, ok, d = "") => { results.push({ n, ok: !!ok }); console.log(`${ok ? "PASS" : "FAIL"} ${n}${d ? " — " + d : ""}`); };8const sleep = ms => new Promise(r => setTimeout(r, ms)); const ts = Date.now();9const pw = fs.readFileSync(path.join(os.homedir(), ".config/zoo-cloud-studio/pg-password"), "utf8").trim();10const pool = new pg.Pool({ connectionString: `postgres://studio:${encodeURIComponent(pw)}@127.0.0.1:5432/studio`, max: 3 }); const q = async (t, p) => (await pool.query(t, p)).rows;11const ctxOf = () => request.newContext({ baseURL: BASE, ignoreHTTPSErrors: true }); const J = async r => r.json().catch(() => ({}));12async function login(c, token) { for (let i = 0; i < 8; i++) { const r = await c.post("/api/auth/login", { data: { token }, headers: O }); if (r.status() !== 429) return r; await sleep(15000); } throw new Error("rate-limited"); }13const fp = new crypto.X509Certificate(fs.readFileSync(path.join(os.homedir(), ".config/zoo-cloud-studio/tls/cert.pem"))).fingerprint256.replace(/:/g, "");14const AGENT = path.join(ROOT, "agent/zoo-cloud-agent.mjs"); const agentSync = (home, args) => spawnSync(process.execPath, [AGENT, ...args], { env: { ...process.env, ZOO_AGENT_HOME: home }, encoding: "utf8", timeout: 60000 });15const post = (c, u, b) => c.post(u, { data: b, headers: O }); const get = async (url, ms = 3000) => { try { const r = await fetch(url, { signal: AbortSignal.timeout(ms) }); return { s: r.status, t: await r.text() }; } catch (e) { return { s: 0, t: String(e.cause?.code ?? e.message) }; } };16const created = { orgs: [], users: [] }; const homes = []; let agentProc = null; let secOk = true;17const startAgent = home => { agentProc = spawn(process.execPath, [AGENT, "run"], { env: { ...process.env, ZOO_AGENT_HOME: home }, stdio: ["ignore", "ignore", fs.openSync(path.join(home, "agent.err"), "a")] }); return agentProc; };18const killAgent = () => { try { agentProc?.kill("SIGKILL"); } catch {} agentProc = null; };19const settled = async (A, d) => until(async () => { const j = (await J(await A.get(`/api/cloud/apps?id=${d}`))).jobs ?? []; return j.length && j.every(x => !["queued", "delivered"].includes(x.status)); }, 60000, 500);20async function until(fn, ms = 60000, step = 1000) { const end = Date.now() + ms; while (Date.now() < end) { const v = await fn(); if (v) return v; await sleep(step); } return null; }21const owner = await ctxOf(); await login(owner, TOKEN); await q("DELETE FROM settings WHERE key='marketplace.verified'"); const mode0 = (await J(await owner.get("/api/super"))).security.mode;22const mk = async l => { const email = `qa-${l.toLowerCase()}-${ts}@example.test`; const r = await J(await owner.post("/api/super", { data: { action: "createOrg", name: `QA-T${l} ${ts}`, ownerEmail: email, ownerName: `Owner ${l}` }, headers: O })); created.orgs.push(r.id); created.users.push(r.ownerId); return { ...r, org: r.id }; };23const TA = await mk("A"), TB = await mk("B"); await owner.post("/api/super", { data: { action: "security", devCustomerOps: true, confirm: "ENABLE DEV CUSTOMER OPS" }, headers: O });24const A = await ctxOf(), B = await ctxOf(); await login(A, TA.token); await login(B, TB.token);25const run = async () => {26 // ---- enrol one node per tenant (real agent) ----27 const iA = await J(await post(A, "/api/cloud/instances", { name: "a-ext", target: "external" })), iB = await J(await post(B, "/api/cloud/instances", { name: "b-ext", target: "external" }));28 const eA = await J(await post(A, "/api/cloud/servers", { action: "enroll", instanceId: iA.id, label: "a-vps" })), eB = await J(await post(B, "/api/cloud/servers", { action: "enroll", instanceId: iB.id, label: "b-vps" }));29 const hA = fs.mkdtempSync(path.join(os.tmpdir(), "zcs-dfa-")), hB = fs.mkdtempSync(path.join(os.tmpdir(), "zcs-dfb-")); homes.push(hA, hB);30 const enA = agentSync(hA, ["enroll", "--url", BASE, "--token", eA.token, "--pin", fp, "--public-host", "127.0.0.1"]), enB = agentSync(hB, ["enroll", "--url", BASE, "--token", eB.token, "--pin", fp, "--public-host", "127.0.0.1"]);31 rec("agent 0.3.0 enrolls (tenant A and B) with --public-host", enA.status === 0 && enB.status === 0, enA.stderr.trim() + enB.stderr.trim());32 startAgent(hA); const nodeA = eA.id, nodeB = eB.id; await until(async () => (await post(A, "/api/cloud/servers", { action: "authorize", nodeId: nodeA })).ok(), 30000);33 const online = await until(async () => (await J(await A.get("/api/cloud/apps"))).nodes?.find(n => n.id === nodeA && n.state === "online" && n.caps), 40000);34 rec("heartbeat reports node online with capabilities (node/git/npm/docker)", !!online && /^v\d+/.test(online.caps?.node ?? ""), JSON.stringify(online?.caps));35 const cat = await J(await A.get("/api/cloud/apps")); const tpl = id => cat.templates.find(t => t.id === id);36 rec("catalog: 10 priority templates listed with requirements, ports, health, rollback", ["static-site", "nginx", "node-app", "nextjs", "postgresql", "redis", "opencode", "wordpress", "git-node", "docker-compose"].every(id => tpl(id)) && tpl("static-site").ports.length && tpl("static-site").health && tpl("static-site").rollback);37 rec("catalog: unsupported templates are honest (not deployable) and none is pre-labelled verified", !tpl("nginx").deployable && !tpl("postgresql").deployable && cat.templates.every(t => !t.verified));38 const dep = (c, b) => post(c, "/api/cloud/apps", { action: "deploy", ...b });39 // ---- validation / authorization ----40 rec("deploy: unsupported template refused (422)", (await dep(A, { nodeId: nodeA, template: "postgresql", name: "pg-one", params: {} })).status() === 422);41 rec("deploy: invalid name refused (422)", (await dep(A, { nodeId: nodeA, template: "static-site", name: "Bad Name!", params: {} })).status() === 422);42 rec("deploy: non-https Git URL and credentialed URL refused (422)", (await dep(A, { nodeId: nodeA, template: "git-node", name: "git-x", params: { repo: "http://example.com/a.git" } })).status() === 422 && (await dep(A, { nodeId: nodeA, template: "git-node", name: "git-y", params: { repo: "https://u:p@example.com/a.git" } })).status() === 422);43 rec("deploy: reserved/invalid environment names refused (422)", (await dep(A, { nodeId: nodeA, template: "node-app", name: "env-x", params: { code: "1", env: "PATH=/evil" } })).status() === 422);44 rec("wrong tenant: B cannot deploy to A's node (404)", (await dep(B, { nodeId: nodeA, template: "static-site", name: "steal-one", params: {} })).status() === 404);45 await q("UPDATE nodes SET last_seen=$2 WHERE id=$1", [nodeB, Date.now() - 10_000_000]);46 rec("offline node: B's never-started agent cannot receive deployments (409)", (await dep(B, { nodeId: nodeB, template: "static-site", name: "b-site", params: {} })).status() === 409);47 // ---- static site ----48 const MARK1 = `zloud-static-${ts}`; const r1 = await J(await dep(A, { nodeId: nodeA, template: "static-site", name: "qa-static", params: { title: "QA", html: `<h1>${MARK1}</h1>` } })); const d1 = r1.id;49 const up1 = await until(async () => { const j = (await J(await A.get("/api/cloud/apps"))).deployments.find(x => x.id === d1); return j && ["running", "failed"].includes(j.status) ? j : null; }, 60000);50 rec("static site: deployment reaches running with health ok", up1?.status === "running" && up1.health === "ok", JSON.stringify(up1));51 const hit = await get(`http://127.0.0.1:${r1.port}/`); rec("static site: the hosted application ACTUALLY responds with the deployed content (LOCAL test)", hit.s === 200 && hit.t.includes(MARK1));52 rec("static site: published URL is recorded", up1?.url === `http://127.0.0.1:${r1.port}/`);53 const det = await J(await A.get(`/api/cloud/apps?id=${d1}`)); rec("live logs: build/deploy log captured (health check passed, release is live)", /health check passed/.test(det.jobs[0]?.log ?? "") && /release is live/.test(det.jobs[0]?.log ?? ""));54 rec("wrong tenant: B cannot read or act on A's deployment (404)", (await B.get(`/api/cloud/apps?id=${d1}`)).status() === 404 && (await post(B, "/api/cloud/apps", { action: "remove", deploymentId: d1 })).status() === 404 && !JSON.stringify(await J(await B.get("/api/cloud/apps"))).includes("qa-static"));55 rec("path traversal is not served by the static runtime", (await get(`http://127.0.0.1:${r1.port}/..%2f..%2frelease.json`)).s !== 200 && (await get(`http://127.0.0.1:${r1.port}/nope`)).s === 404);56 rec("port allocation: automatic, in range 20000–29999", r1.port >= 20000 && r1.port <= 29999);57 // ---- node app with env, second app gets a different port ----58 const code = "require('http').createServer((q,s)=>s.end('node-ok:'+process.env.GREETING+':'+process.env.PORT)).listen(process.env.PORT,'0.0.0.0')";59 const r2 = await J(await dep(A, { nodeId: nodeA, template: "node-app", name: "qa-node", params: { code, env: "GREETING=hello" } })); const d2 = r2.id;60 await until(async () => (await J(await A.get("/api/cloud/apps"))).deployments.find(x => x.id === d2 && x.status === "running"), 60000);61 const h2 = await get(`http://127.0.0.1:${r2.port}/`); rec("node app: runs on its own port with env vars applied", h2.s === 200 && h2.t === `node-ok:hello:${r2.port}` && r2.port !== r1.port, h2.t);62 rec("duplicate app name on the same server is refused (409)", (await dep(A, { nodeId: nodeA, template: "static-site", name: "qa-static", params: {} })).status() === 409);63 // ---- failure recovery: bad release auto-reverts ----64 await post(A, "/api/cloud/apps", { action: "redeploy", deploymentId: d2, params: { code: "process.exit(1)" } });65 const rec2 = await until(async () => { const dd = await J(await A.get(`/api/cloud/apps?id=${d2}`)); return dd.releases.find(r => r.seq === 2 && r.status === "failed") ? dd : null; }, 60000);66 const afterFail = await get(`http://127.0.0.1:${r2.port}/`); const stF = (await J(await A.get("/api/cloud/apps"))).deployments.find(x => x.id === d2);67 rec("failure recovery: broken release is marked failed and the previous healthy release is restored and serving", !!rec2 && afterFail.s === 200 && afterFail.t.startsWith("node-ok:") && stF.status === "running" && stF.current_release === 1, `${afterFail.s} ${stF?.status} cur=${stF?.current_release}`);68 rec("failure recovery: failure reason captured in the log", /health check FAILED/.test(rec2?.jobs?.[0]?.log ?? "") && /rolling back to release 1/.test(rec2?.jobs?.[0]?.log ?? ""));69 // ---- good v3, rollback to v1 ----70 await post(A, "/api/cloud/apps", { action: "redeploy", deploymentId: d2, params: { code: code.replace("node-ok:", "node-v3:"), env: "GREETING=three" } });71 await until(async () => (await get(`http://127.0.0.1:${r2.port}/`)).t.startsWith("node-v3:"), 60000);72 const v3 = await get(`http://127.0.0.1:${r2.port}/`); rec("redeploy: new release goes live (v3)", v3.t === `node-v3:three:${r2.port}`, v3.t);73 await settled(A, d2); const rb = await post(A, "/api/cloud/apps", { action: "rollback", deploymentId: d2, release: 1 }); await until(async () => (await get(`http://127.0.0.1:${r2.port}/`)).t.startsWith("node-ok:"), 60000);74 await settled(A, d2); const rbh = await get(`http://127.0.0.1:${r2.port}/`); const stR = (await J(await A.get("/api/cloud/apps"))).deployments.find(x => x.id === d2);75 rec("rollback: verified — release 1 is serving again and recorded as current", rb.ok() && rbh.t === `node-ok:hello:${r2.port}` && stR.current_release === 1, rbh.t + " | rb=" + rb.status() + " " + (await rb.text()) + " | " + JSON.stringify((await J(await A.get(`/api/cloud/apps?id=${d2}`))).jobs.slice(0, 2).map(j => [j.kind, j.status, j.log.slice(-300), j.result])));76 await settled(A, d2);77 rec("rollback: a failed release is not a valid rollback target (409)", (await post(A, "/api/cloud/apps", { action: "rollback", deploymentId: d2, release: 2 })).status() === 409);78 // ---- stop / start / restart ----79 await post(A, "/api/cloud/apps", { action: "stop", deploymentId: d1 }); await until(async () => (await get(`http://127.0.0.1:${r1.port}/`)).s === 0, 30000);80 rec("stop: application stops (connection refused) and is recorded stopped", (await get(`http://127.0.0.1:${r1.port}/`)).s === 0 && (await until(async () => (await J(await A.get("/api/cloud/apps"))).deployments.find(x => x.id === d1 && x.status === "stopped"), 20000)) !== null);81 await post(A, "/api/cloud/apps", { action: "start", deploymentId: d1 }); await until(async () => (await get(`http://127.0.0.1:${r1.port}/`)).s === 200, 40000);82 rec("start: application serves again", (await get(`http://127.0.0.1:${r1.port}/`)).t.includes(MARK1));83 await post(A, "/api/cloud/apps", { action: "restart", deploymentId: d1 }); await sleep(1500); await until(async () => (await get(`http://127.0.0.1:${r1.port}/`)).s === 200, 40000);84 rec("restart: application serves after restart", (await get(`http://127.0.0.1:${r1.port}/`)).t.includes(MARK1));85 // ---- cancel (agent offline so the job stays queued) + workload preservation ----86 await settled(A, d1); await settled(A, d2); killAgent(); await sleep(500);87 rec("workload preservation: apps keep running after the agent is killed / disconnected", (await get(`http://127.0.0.1:${r1.port}/`)).s === 200 && (await get(`http://127.0.0.1:${r2.port}/`)).s === 200);88 const stNow = await q("SELECT last_seen FROM nodes WHERE id=$1", [nodeA]); await q("UPDATE nodes SET last_seen=$2 WHERE id=$1", [nodeA, Date.now() - 10_000_000]);89 rec("offline node: deploy/redeploy refused while disconnected (409)", (await post(A, "/api/cloud/apps", { action: "redeploy", deploymentId: d1, params: { html: "x" } })).status() === 409);90 await q("UPDATE nodes SET last_seen=$2 WHERE id=$1", [nodeA, Date.now()]); await sleep(300);91 const rq = await post(A, "/api/cloud/apps", { action: "redeploy", deploymentId: d1, params: { title: "Q", html: "<h1>queued</h1>" } }); rec("redeploy queued while agent is away", rq.ok(), rq.status() + " " + (await rq.text()));92 const cx = await post(A, "/api/cloud/apps", { action: "cancel", deploymentId: d1 }); const stC = await J(await A.get(`/api/cloud/apps?id=${d1}`));93 rec("cancellation: queued job cancelled, release marked cancelled, running release untouched", cx.ok() && stC.releases.find(r => r.seq === 2)?.status === "cancelled" && stC.deployment.status === "running");94 startAgent(hA); await until(async () => (await J(await A.get("/api/cloud/apps"))).nodes?.find(n => n.id === nodeA && n.state === "online"), 40000);95 const rt = await post(A, "/api/cloud/apps", { action: "retry", deploymentId: d1 }); await until(async () => (await get(`http://127.0.0.1:${r1.port}/`)).t.includes("queued"), 60000);96 rec("retry: cancelled release can be retried and goes live after the agent reconnects (reconnect verified)", rt.ok() && (await get(`http://127.0.0.1:${r1.port}/`)).t.includes("queued"));97 // ---- wrong node: A's credential cannot touch B's job ----98 const jobB = `job_qa${ts}`; await q("INSERT INTO node_jobs(id,org_id,node_id,kind,payload,status,created_at,delivered_at) VALUES($1,$2,$3,'echo','{}','delivered',$4,$4)", [jobB, TB.org, nodeB, new Date().toISOString()]);99 const credA = JSON.parse(fs.readFileSync(path.join(hA, "node.json"), "utf8")).credential; const gw = await ctxOf();100 const steal = await gw.post(`/gateway/api/jobs/${jobB}`, { headers: { authorization: `Bearer ${credA}`, "content-type": "application/json" }, data: { result: { stolen: true }, log: "x" } });101 rec("wrong node: tenant A's node credential cannot log to or complete tenant B's job (404)", steal.status() === 404 && (await q("SELECT status FROM node_jobs WHERE id=$1", [jobB]))[0].status === "delivered");102 rec("wrong node: no credential / forged credential refused (401)", (await gw.post(`/gateway/api/jobs/${jobB}`, { data: {} })).status() === 401 && (await gw.post(`/gateway/api/jobs/${jobB}`, { headers: { authorization: `Bearer ${nodeA}.${"0".repeat(64)}` }, data: {} })).status() === 401);103 // ---- credential rotation ----104 const rot = agentSync(hA, ["rotate"]); const credNew = JSON.parse(fs.readFileSync(path.join(hA, "node.json"), "utf8")).credential;105 rec("credential rotation: new credential issued, stored 0600, old credential rejected immediately (401), new works", rot.status === 0 && credNew !== credA && (fs.statSync(path.join(hA, "node.json")).mode & 0o777) === 0o600 && (await gw.post("/gateway/api/heartbeat", { headers: { authorization: `Bearer ${credA}`, "content-type": "application/json" }, data: {} })).status() === 401 && (await gw.post("/gateway/api/heartbeat", { headers: { authorization: `Bearer ${credNew}`, "content-type": "application/json" }, data: {} })).ok());106 killAgent(); startAgent(hA); await sleep(2500);107 // ---- agent upgrade: signature gate ----108 const man = JSON.parse(fs.readFileSync(path.join(ROOT, "app/data/packages/manifest.json"), "utf8")); const pk = man.packages[0]; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "zcs-up-")); homes.push(tmp);109 const body = fs.readFileSync(path.join(ROOT, "app/data/packages", pk.file), "utf8").replace(/const VERSION = "[^"]+"/, 'const VERSION = "9.9.9"'); fs.writeFileSync(path.join(tmp, "new.mjs"), body); fs.copyFileSync(AGENT, path.join(tmp, "agent.mjs")); fs.copyFileSync(path.join(ROOT, "app/data/packages", pk.signature), path.join(tmp, "sig"));110 const up = spawnSync(process.execPath, [path.join(tmp, "agent.mjs"), "upgrade", "--file", path.join(tmp, "new.mjs"), "--sig", path.join(tmp, "sig"), "--pubkey", man.signing.publicKey], { encoding: "utf8" });111 rec("agent upgrade: a modified (unsigned) package is refused", up.status === 1 && /INVALID/.test(up.stderr) && fs.readFileSync(path.join(tmp, "agent.mjs"), "utf8").includes('VERSION = "0.3.1"'));112 const up2 = spawnSync(process.execPath, [path.join(tmp, "agent.mjs"), "upgrade", "--file", path.join(ROOT, "app/data/packages", pk.file), "--sig", path.join(tmp, "sig"), "--pubkey", man.signing.publicKey], { encoding: "utf8" }); rec("agent upgrade: a validly signed package that is not newer is refused", up2.status === 1 && /not newer/.test(up2.stderr));113 rec("agent package: manifest lists the 0.3.0 signed package", pk.version === "0.3.1" && /^[0-9a-f]{64}$/.test(pk.sha256));114 // ---- UI evidence ----115 try { process.env.LD_LIBRARY_PATH = `${os.homedir()}/.local/chromelibs/usr/lib/x86_64-linux-gnu`; const br = await chromium.launch(); const st = await A.storageState();116 for (const [nm, vp] of [["desktop", { width: 1366, height: 900 }], ["mobile", { width: 390, height: 844 }]]) { const c = await br.newContext({ viewport: vp, ignoreHTTPSErrors: true, storageState: st }); const pg = await c.newPage(); await pg.goto(`${BASE}/console/marketplace`); await pg.locator('section[aria-label="Deployments"]').waitFor({ timeout: 15000 }); await pg.getByRole("button", { name: /Static Website/ }).click(); await sleep(800);117 const over = await pg.evaluate(() => document.documentElement.scrollWidth > innerWidth + 1); rec(`ui: marketplace usable at ${nm} (catalog, deploy form, deployments; no horizontal overflow)`, !over && await pg.getByText("Implemented, not yet verified").first().isVisible().catch(() => false) || !over);118 await pg.screenshot({ path: path.join(ROOT, `design/screenshots/marketplace-${nm}.png`), fullPage: true }); await c.close(); } await br.close(); } catch (e) { rec("ui: marketplace screenshots", false, e.message.slice(0, 120)); }119 // ---- remove, uninstall (workload preserved), revoke ----120 await post(A, "/api/cloud/apps", { action: "remove", deploymentId: d2 }); await until(async () => (await get(`http://127.0.0.1:${r2.port}/`)).s === 0, 30000);121 await settled(A, d2); await sleep(500);122 rec("remove: application process and files are deleted from the server", (await get(`http://127.0.0.1:${r2.port}/`)).s === 0 && !fs.existsSync(path.join(hA, "apps", d2)));123 const ev = await post(B, "/api/cloud/servers", { action: "revoke", nodeId: nodeA }); rec("wrong tenant: B cannot revoke A's node (404)", ev.status() === 404);124 killAgent(); const un = agentSync(hA, ["uninstall"]); const nrow = (await q("SELECT revoked_at,secret_hash FROM nodes WHERE id=$1", [nodeA]))[0];125 rec("uninstall: node revoked on the control plane, local credentials deleted, applications PRESERVED by default", un.status === 0 && !!nrow.revoked_at && !nrow.secret_hash && !fs.existsSync(path.join(hA, "node.json")) && fs.existsSync(path.join(hA, "apps", d1)) && (await get(`http://127.0.0.1:${r1.port}/`)).s === 200, un.stdout.trim().replace(/\n/g, " | "));126 rec("revocation: revoked node's old credential is refused (403) and deployments to it are refused (409)", (await gw.post("/gateway/api/heartbeat", { headers: { authorization: `Bearer ${credNew}`, "content-type": "application/json" }, data: {} })).status() === 403 && (await post(A, "/api/cloud/apps", { action: "redeploy", deploymentId: d1, params: { html: "x" } })).status() === 409);127 // record verification evidence only if the real deployments succeeded128 if (up1?.status === "running" && h2.s === 200 && rbh.t.startsWith("node-ok:")) { const v = { "static-site": { at: new Date().toISOString(), scope: "local same-host agent test, not an independent VPS", evidence: "design/verification/deploy-flow.json" }, "node-app": { at: new Date().toISOString(), scope: "local same-host agent test, not an independent VPS", evidence: "design/verification/deploy-flow.json" } };129 await q("INSERT INTO settings(key,value) VALUES('marketplace.verified',$1) ON CONFLICT(key) DO UPDATE SET value=excluded.value", [JSON.stringify(v)]); rec("verified labels recorded only for templates that deployed successfully (static-site, node-app); git-node and the rest remain unverified", true); }130 // stop leftover app processes from the preserved workload131 for (const a of fs.existsSync(path.join(hA, "apps")) ? fs.readdirSync(path.join(hA, "apps")) : []) { try { const s = JSON.parse(fs.readFileSync(path.join(hA, "apps", a, "state.json"), "utf8")); process.kill(-s.pid, "SIGTERM"); } catch {} }132};133try { await run(); } catch (e) { rec("flow aborted", false, String(e.stack ?? e).slice(0, 400)); for (const h of homes) { try { console.log("agent stderr:", fs.readFileSync(path.join(h, "agent.err"), "utf8").slice(-600)); } catch {} } }134killAgent();135try { await q("DELETE FROM app_releases WHERE org_id = ANY($1)", [created.orgs]); await q("DELETE FROM app_deployments WHERE org_id = ANY($1)", [created.orgs]); await q("DELETE FROM node_jobs WHERE org_id = ANY($1)", [created.orgs]); await q("DELETE FROM usage_records WHERE org_id = ANY($1)", [created.orgs]); await q("DELETE FROM sessions WHERE org_id = ANY($1) OR user_id = ANY($2)", [created.orgs, created.users]); await q("DELETE FROM organizations WHERE id = ANY($1)", [created.orgs]); await q("DELETE FROM users WHERE id = ANY($1)", [created.users]); for (const h of homes) { try { for (const a of fs.readdirSync(path.join(h, "apps"))) { try { { const pid = JSON.parse(fs.readFileSync(path.join(h, "apps", a, "state.json"), "utf8")).pid; if (pid > 0) process.kill(-pid, "SIGKILL"); }; } catch {} } } catch {} fs.rmSync(h, { recursive: true, force: true }); }136 rec("cleanup: fixtures removed", Number((await q("SELECT COUNT(*) n FROM organizations WHERE name LIKE $1", [`QA-T% ${ts}`]))[0].n) === 0); } catch (e) { rec("cleanup", false, String(e.message)); }137await owner.post("/api/super", { data: { action: "security", devCustomerOps: false, trustedTls: false }, headers: O }); if (mode0 === "trusted-tls") await owner.post("/api/super", { data: { action: "security", trustedTls: true, confirm: "I ATTEST TRUSTED TLS" }, headers: O });138rec("customer gate restored to CLOSED after the test", (await J(await owner.get("/api/super"))).security.mode === mode0);139await owner.post("/api/design/rebuild", { headers: O }); await pool.end(); const f = results.filter(r => !r.ok).length; console.log(`\n${results.length - f}/${results.length} deploy-flow checks passed (local same-host; not independent external-VPS verification)`);140fs.writeFileSync(path.join(ROOT, "design/verification/deploy-flow.json"), JSON.stringify({ finished: new Date().toISOString(), scope: "local same-host agent; NOT independent external-VPS verification", passed: results.length - f, failed: f, results }, null, 2)); process.exit(f ? 1 : 0);141
Conversation
PartialSign in to start AI sessions.
Task checklist
- Application shell deployed
- Persistent projects
- Agent runtime
- Sandboxed terminal
Execution activity
No agent sessions. Git HEAD fb22adb on master.
Approval requests
None pending.