483bc68a94
Enable evolution by default for source-backed workspaces. Add stable conformance ownership, semantic-major review, candidate typechecking, and durable fenced cutover with explicit migrations and forward recovery. Independently supervise package runtimes so unchanged resource owners keep their processes and connections across cutover. Add scoped invocation authority, resource sessions, and typed callback rebinding. Wire opaque object references through generated bindings and RPCs. Add canonical relationship sets, keyed maps, and ordered lists with scoped transactional mutations, revision checks, and inverse consistency. Support planned cascade deletion, protection, tombstones, and lifecycle foundations. Add journaled structural edits, package/function/migration scaffolding, managed repository creation, and resumable bottom-up dependency pin publication. Document lifetime boundaries, revision pinning, prototype compatibility policy, commands, and deferred work. Validate with 210 tests, user-systemd process/connection continuity, generated-package TypeScript checks, and Nix host/protocol checks. TTL handoff, physical reclamation, general multi-step migrations, and root-systemd migration isolation acceptance remain deferred.
38 lines
2.5 KiB
TypeScript
38 lines
2.5 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { promisify } from "node:util";
|
|
import { execFile as callback } from "node:child_process";
|
|
import { planStructure, applyStructure, resumeStructure, type StructuralRequest } from "../src/capability-language/structural-plan.js";
|
|
const execFile = promisify(callback);
|
|
|
|
test("structural plans validate the graph, journal originals, and reject stale edits", async (context) => {
|
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), "qx-structural-test-"));
|
|
context.after(() => fs.rm(root, {recursive: true, force: true}));
|
|
await execFile("git", ["-C", root, "init"]);
|
|
await fs.writeFile(path.join(root, ".gitignore"), ".quixos/\n");
|
|
await fs.writeFile(path.join(root, "quixos.lock"), `quixos-lock version 1 { quixos source { repository "https://example.test/quixos.git"; commit "${"a".repeat(40)}"; } }`);
|
|
const before = `workspace Test id "workspace:test" revision "workspace:test@1" commit "${"b".repeat(40)}" { atom Subject id "atom:subject"; }`;
|
|
await fs.writeFile(path.join(root, "workspace.qx"), before);
|
|
const request: StructuralRequest = {kind: "workspace", files: [{file: "workspace.qx", edits: [{operation: "append", parent: {kind: "workspaceDecl"}, source: 'atom Game id "atom:game";'}]}]};
|
|
const plan = await planStructure(root, request);
|
|
assert.equal(await fs.readFile(path.join(root, "workspace.qx"), "utf8"), before);
|
|
await fs.writeFile(path.join(root, "workspace.qx"), `${before}\n// newer edit`);
|
|
await assert.rejects(() => applyStructure(plan), /Stale scaffold/);
|
|
await fs.writeFile(path.join(root, "workspace.qx"), before);
|
|
const applied = await applyStructure(plan);
|
|
assert.equal(applied.phase, "complete");
|
|
assert.ok((await fs.readFile(path.join(root, "workspace.qx"), "utf8")).includes("atom Game"));
|
|
const journal = JSON.parse(await fs.readFile(applied.journalPath, "utf8"));
|
|
assert.equal(journal.changes[0].before, before);
|
|
assert.equal((await resumeStructure(root, applied.id)).phase, "complete");
|
|
// Simulate a process interrupted after one file was written, before recording
|
|
// completion. Replay accepts the already-written exact after image.
|
|
journal.phase = "prepared";
|
|
await fs.writeFile(applied.journalPath, JSON.stringify(journal));
|
|
assert.equal((await resumeStructure(root, applied.id)).phase, "complete");
|
|
await assert.rejects(() => planStructure(root, request), /Duplicate|duplicate/);
|
|
});
|