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.
99 lines
4.1 KiB
JavaScript
99 lines
4.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { readFile, writeFile } from "node:fs/promises";
|
|
import process from "node:process";
|
|
import { compileWorkspaceRepository } from "./assembly.js";
|
|
import { createGitCapabilityResolver } from "./git-resolver.js";
|
|
import { planEvolution, runtimeContracts, type EvolutionReview, type WorkspaceRevision } from "../capability-model/index.js";
|
|
|
|
const usage = `usage: quixos-workspace-compile --root DIRECTORY --checkout-root DIRECTORY
|
|
[--snapshot-map PATH] [--graph-out PATH] [--workspace-id ID] [--workspace-revision-id ID]
|
|
[--source-root-commit GIT_REV] [--baseline PLAN_JSON] [--evolution-out PATH]
|
|
[--reviews REVIEW_JSON]
|
|
|
|
Resolves a workspace's recursive resource-lock graph, clones every exact
|
|
resource revision, validates standalone interface/package manifests, and emits
|
|
the checked workspace plan as JSON.`;
|
|
|
|
const parseArgs = (args: string[]) => {
|
|
const values = new Map<string, string>();
|
|
for (let index = 0; index < args.length; index += 2) {
|
|
const key = args[index];
|
|
const value = args[index + 1];
|
|
if (!key?.startsWith("--") || !value) throw new Error(usage);
|
|
values.set(key, value);
|
|
}
|
|
const rootDirectory = values.get("--root");
|
|
const checkoutRoot = values.get("--checkout-root");
|
|
if (!rootDirectory || !checkoutRoot) throw new Error(usage);
|
|
return {
|
|
rootDirectory,
|
|
checkoutRoot,
|
|
graphOut: values.get("--graph-out"),
|
|
snapshotMap: values.get("--snapshot-map"),
|
|
workspaceId: values.get("--workspace-id"),
|
|
workspaceRevisionId: values.get("--workspace-revision-id"),
|
|
sourceRootCommit: values.get("--source-root-commit"),
|
|
baseline: values.get("--baseline"),
|
|
evolutionOut: values.get("--evolution-out"),
|
|
reviews: values.get("--reviews"),
|
|
};
|
|
};
|
|
|
|
const main = async () => {
|
|
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
process.stdout.write(`${usage}\n`);
|
|
return;
|
|
}
|
|
const options = parseArgs(process.argv.slice(2));
|
|
const resolveResource = await createGitCapabilityResolver({
|
|
checkoutRoot: options.checkoutRoot,
|
|
snapshotMap: options.snapshotMap,
|
|
});
|
|
const assembled = await compileWorkspaceRepository({
|
|
rootDirectory: options.rootDirectory,
|
|
workspaceId: options.workspaceId,
|
|
workspaceRevisionId: options.workspaceRevisionId,
|
|
sourceRootCommit: options.sourceRootCommit,
|
|
resolveResource,
|
|
});
|
|
|
|
if (options.graphOut) {
|
|
await writeFile(options.graphOut, `${JSON.stringify({
|
|
formatVersion: 1,
|
|
quixos: assembled.lock.quixos,
|
|
directResources: [...assembled.directResources.entries()].map(([bindingKey, node]) => {
|
|
const [kind, binding] = bindingKey.split("\0");
|
|
return { kind, binding, resourceKey: node.key, directory: node.directory };
|
|
}),
|
|
resources: assembled.resources.map((node) => ({
|
|
key: node.key,
|
|
kind: node.kind,
|
|
source: node.source,
|
|
directory: node.directory,
|
|
resourceId: node.resource.kind === "interface"
|
|
? node.resource.revision.interfaceId
|
|
: node.resource.revision.packageId,
|
|
revisionId: node.resource.revision.revisionId,
|
|
dependencies: [...node.dependencies.entries()].map(([binding, dependency]) => ({
|
|
binding,
|
|
resourceKey: dependency.key,
|
|
})),
|
|
})),
|
|
}, null, 2)}\n`);
|
|
}
|
|
const candidate = { ...assembled.workspace, executionContracts: runtimeContracts(assembled.workspace) };
|
|
if (options.evolutionOut) {
|
|
const baseline = options.baseline ? JSON.parse(await readFile(options.baseline, "utf8")) as WorkspaceRevision : null;
|
|
const reviews = options.reviews ? JSON.parse(await readFile(options.reviews, "utf8")) as EvolutionReview[] : [];
|
|
if (!Array.isArray(reviews)) throw new Error("Review file must contain an array");
|
|
await writeFile(options.evolutionOut, `${JSON.stringify(planEvolution(baseline, candidate, { reviews }), null, 2)}\n`);
|
|
}
|
|
process.stdout.write(`${JSON.stringify(candidate, null, 2)}\n`);
|
|
};
|
|
|
|
main().catch((error: unknown) => {
|
|
process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
|
|
process.exitCode = 1;
|
|
});
|