Implement workspace evolution, migrations, and runtime continuity
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.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import {relationshipMap, relationshipList, relationshipSet} from "../dist/index.js";
|
||||
import {referenceFromWire} from "../dist/references.js";
|
||||
test("relationship helpers preserve handles and require explicit collection revisions", async () => {
|
||||
let current = {revision: 0n, entries: []}, serial = 0;
|
||||
const port = {collection: async () => ({revision: current.revision, entries: current.entries.map((entry) => ({...entry}))}),
|
||||
replace: async (entries, revision) => {
|
||||
assert.equal(revision, current.revision);
|
||||
current = {revision: revision + 1n, entries: entries.map((entry) => ({...entry, edgeId: entry.edgeId ?? `edge:${++serial}`}))};
|
||||
return port.collection();
|
||||
}};
|
||||
const a = referenceFromWire("obj:a"), b = referenceFromWire("obj:b");
|
||||
const map = relationshipMap(port);
|
||||
await map.set("a1", a, 0n);
|
||||
assert.equal((await map.get("a1")).value.equals(a), true);
|
||||
await assert.rejects(() => map.set("b1", b, 0n), /STALE_COLLECTION/);
|
||||
await map.delete("a1", 1n);
|
||||
const list = relationshipList(port);
|
||||
const inserted = await list.insert(0, a, 2n);
|
||||
await list.insert(1, b, 3n);
|
||||
const moved = await list.move(inserted.entries[0].edgeId, 1, 4n);
|
||||
assert.equal(moved.entries[1].target.equals(a), true);
|
||||
const set = relationshipSet(port);
|
||||
const unchanged = await set.add(referenceFromWire("obj:a"), 5n);
|
||||
assert.equal(unchanged.revision, 5n);
|
||||
});
|
||||
Reference in New Issue
Block a user