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:
@@ -36,6 +36,8 @@ import type {
|
||||
import { valueType } from "./types.js";
|
||||
|
||||
export type CapabilityValidationIssueCode =
|
||||
| "invalid-semantic-major"
|
||||
| "duplicate-conformance-id"
|
||||
| "required-value"
|
||||
| "invalid-source"
|
||||
| "invalid-value-type"
|
||||
@@ -562,6 +564,9 @@ const collectIdentityIndexes = (
|
||||
const packages = new Map<string, PackageIndexEntry>();
|
||||
for (const [packageIndex, revision] of workspace.packageImports.entries()) {
|
||||
const path = `packageImports[${packageIndex}]`;
|
||||
if (revision.semanticMajor !== undefined && (!Number.isSafeInteger(revision.semanticMajor) || revision.semanticMajor < 1)) {
|
||||
issue(issues, "invalid-semantic-major", `${path}.semanticMajor`, "Semantic major must be a positive safe integer");
|
||||
}
|
||||
requireText(issues, revision.packageId, `${path}.packageId`, "Package ID");
|
||||
requireText(
|
||||
issues,
|
||||
@@ -616,8 +621,17 @@ const collectIdentityIndexes = (
|
||||
|
||||
const conformances = new Map<string, Conformance>();
|
||||
const conformancePaths = new Map<string, string>();
|
||||
const conformanceIds = new Set<string>();
|
||||
for (const [index, conformance] of workspace.conformances.entries()) {
|
||||
const path = `conformances[${index}]`;
|
||||
if (conformance.semanticMajor !== undefined && (!Number.isSafeInteger(conformance.semanticMajor) || conformance.semanticMajor < 1)) {
|
||||
issue(issues, "invalid-semantic-major", `${path}.semanticMajor`, "Semantic major must be a positive safe integer");
|
||||
}
|
||||
if (conformance.id !== undefined) {
|
||||
requireText(issues, conformance.id, `${path}.id`, "Conformance ID");
|
||||
if (conformanceIds.has(conformance.id)) issue(issues, "duplicate-conformance-id", `${path}.id`, `Duplicate conformance ID ${conformance.id}`);
|
||||
conformanceIds.add(conformance.id);
|
||||
}
|
||||
const key = conformanceKey(conformance.atomId, conformance.interfaceRevisionId);
|
||||
if (conformances.has(key)) {
|
||||
issue(
|
||||
@@ -763,6 +777,10 @@ const validateAttachments = (
|
||||
);
|
||||
}
|
||||
validateValueType(issues, attachment.valueType, `${path}.valueType`, indexes);
|
||||
const containsReference = (type: ValueType): boolean => type.kind === "object-ref" || ((type.kind === "optional" || type.kind === "list") && containsReference(type.value));
|
||||
if (containsReference(attachment.valueType) || (attachment.storagePolicy.kind === "crdt-document" && containsReference(attachment.storagePolicy.updateType))) {
|
||||
issue(issues, "invalid-attachment", `${path}.valueType`, "Managed object references belong in graph relationships, not ordinary state");
|
||||
}
|
||||
if (attachment.storagePolicy.kind === "crdt-document") {
|
||||
validateValueType(
|
||||
issues,
|
||||
@@ -794,10 +812,17 @@ const validateAttachments = (
|
||||
}
|
||||
for (const [endpointIndex, endpoint] of attachment.endpoints.entries()) {
|
||||
const endpointPath = `${path}.endpoints[${endpointIndex}]`;
|
||||
if (endpoint.keyType !== undefined && (!["string", "boolean", "int64"].includes(endpoint.keyType) || endpoint.ordered || !["many", "many-unique"].includes(endpoint.cardinality))) {
|
||||
issue(issues, "invalid-attachment", `${endpointPath}.keyType`, "Keyed projections require string/boolean/int64 keys, many cardinality, and no ordering");
|
||||
}
|
||||
requireText(issues, endpoint.projectionId, `${endpointPath}.projectionId`, "Projection ID");
|
||||
if (endpoint.onDelete !== undefined && !["restrict", "detach", "cascade-other"].includes(endpoint.onDelete)) {
|
||||
issue(issues, "invalid-attachment", `${endpointPath}.onDelete`, "Deletion policy must be restrict, detach, or cascade-other");
|
||||
}
|
||||
requireText(issues, endpoint.displayName, `${endpointPath}.displayName`, "Projection name");
|
||||
validateConstraint(issues, endpoint.constraint, `${endpointPath}.constraint`, indexes);
|
||||
}
|
||||
if (attachment.endpoints.every((endpoint) => endpoint.keyType)) issue(issues, "invalid-attachment", `${path}.endpoints`, "A v0 map has one keyed projection and one unkeyed inverse");
|
||||
if (owner.kind === "conformance") {
|
||||
if (
|
||||
!attachment.endpoints.some((endpoint) =>
|
||||
@@ -989,7 +1014,6 @@ const validateTraversal = (
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
validateAttachmentAccess(issues, attachment, conformance, `${path}.edgeTypeId`);
|
||||
const projection = edgeProjection(attachment.attachment, traversal.projectionId);
|
||||
if (!projection) {
|
||||
issue(
|
||||
@@ -1000,6 +1024,7 @@ const validateTraversal = (
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
if (!projection.endpoint.publicTraversal) validateAttachmentAccess(issues, attachment, conformance, `${path}.edgeTypeId`);
|
||||
if (!atomSatisfiesConstraint(atomId, projection.endpoint.constraint, indexes.conformances)) {
|
||||
issue(
|
||||
issues,
|
||||
|
||||
Reference in New Issue
Block a user