Introduce repository-backed capability workspaces
- define and validate the capability and resource-lock languages - provision workspace source repositories through Central Gitea - build package runtimes from pinned standalone sources - replace legacy schema compilation with workspace persistence plans - add stable optimistic registers and Automerge CRDT documents - modernize TypeScript/Nix package builds and runtime activation readiness
This commit is contained in:
+15
-93
@@ -3,23 +3,7 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fromBinary, toJsonString } from "@bufbuild/protobuf";
|
||||
import type { PackageDescriptor } from "./gen/quixos/package_pb.js";
|
||||
import {
|
||||
FunctionCapabilityKind,
|
||||
PackageDescriptorSchema,
|
||||
} from "./gen/quixos/package_pb.js";
|
||||
|
||||
const functionKey = (value: {
|
||||
packageNamespace: string;
|
||||
packageName: string;
|
||||
symbol: string;
|
||||
versionRef: string;
|
||||
}) =>
|
||||
[
|
||||
value.packageNamespace,
|
||||
value.packageName,
|
||||
value.symbol,
|
||||
value.versionRef,
|
||||
].join(":");
|
||||
import { PackageDescriptorSchema } from "./gen/quixos/package_pb.js";
|
||||
|
||||
const protoPaths = () => {
|
||||
const candidates = [
|
||||
@@ -76,87 +60,25 @@ export const validatePackageDescriptor = (
|
||||
descriptor: PackageDescriptor,
|
||||
): string[] => {
|
||||
const errors: string[] = [];
|
||||
if (!descriptor.packageNamespace) {
|
||||
errors.push("packageNamespace is required");
|
||||
if (!descriptor.packageId) {
|
||||
errors.push("packageId is required");
|
||||
}
|
||||
if (!descriptor.packageName) {
|
||||
errors.push("packageName is required");
|
||||
if (!descriptor.packageRevisionId) {
|
||||
errors.push("packageRevisionId is required");
|
||||
}
|
||||
if (descriptor.descriptorVersion === 0) {
|
||||
errors.push("descriptorVersion must be greater than zero");
|
||||
if (!descriptor.runtimeProtocolVersion) {
|
||||
errors.push("runtimeProtocolVersion is required");
|
||||
}
|
||||
if (
|
||||
descriptor.interfaceCompatibleBackTo !== 0 &&
|
||||
descriptor.interfaceCompatibleBackTo > descriptor.descriptorVersion
|
||||
) {
|
||||
errors.push("interfaceCompatibleBackTo must not exceed descriptorVersion");
|
||||
}
|
||||
if (
|
||||
descriptor.runnerCompatibleBackTo !== 0 &&
|
||||
descriptor.runnerCompatibleBackTo > descriptor.descriptorVersion
|
||||
) {
|
||||
errors.push("runnerCompatibleBackTo must not exceed descriptorVersion");
|
||||
}
|
||||
|
||||
const seenFunctions = new Set<string>();
|
||||
for (const [index, entry] of descriptor.functionExports.entries()) {
|
||||
const fn = entry.function;
|
||||
if (!fn) {
|
||||
errors.push(`functionExports[${index}].function is required`);
|
||||
continue;
|
||||
const seenExports = new Set<string>();
|
||||
for (const [index, entry] of descriptor.exports.entries()) {
|
||||
if (!entry.exportId) errors.push(`exports[${index}].exportId is required`);
|
||||
if (!entry.runtimeSymbol) {
|
||||
errors.push(`exports[${index}].runtimeSymbol is required`);
|
||||
}
|
||||
if (!fn.packageNamespace) {
|
||||
fn.packageNamespace = descriptor.packageNamespace;
|
||||
}
|
||||
if (!fn.packageName) {
|
||||
fn.packageName = descriptor.packageName;
|
||||
}
|
||||
if (
|
||||
fn.packageNamespace !== descriptor.packageNamespace ||
|
||||
fn.packageName !== descriptor.packageName
|
||||
) {
|
||||
errors.push(
|
||||
`functionExports[${index}] must export from this package (${descriptor.packageNamespace}/${descriptor.packageName})`,
|
||||
);
|
||||
}
|
||||
if (!fn.symbol) {
|
||||
errors.push(`functionExports[${index}].function.symbol is required`);
|
||||
}
|
||||
if (entry.interfaceVersion === 0) {
|
||||
errors.push(`functionExports[${index}].interfaceVersion is required`);
|
||||
}
|
||||
if (entry.capabilityKind === FunctionCapabilityKind.FUNCTION_CAPABILITY_KIND_UNSPECIFIED) {
|
||||
errors.push(`functionExports[${index}].capabilityKind is required`);
|
||||
}
|
||||
if (
|
||||
entry.interfaceCompatibleBackTo !== 0 &&
|
||||
entry.interfaceCompatibleBackTo > entry.interfaceVersion
|
||||
) {
|
||||
errors.push(
|
||||
`functionExports[${index}].interfaceCompatibleBackTo must not exceed interfaceVersion`,
|
||||
);
|
||||
}
|
||||
const key = functionKey(fn);
|
||||
if (seenFunctions.has(key)) {
|
||||
errors.push(`duplicate function export: ${key}`);
|
||||
}
|
||||
seenFunctions.add(key);
|
||||
}
|
||||
|
||||
for (const [index, entry] of descriptor.dependencies.entries()) {
|
||||
if (!entry.package) {
|
||||
errors.push(`dependencies[${index}].package is required`);
|
||||
continue;
|
||||
}
|
||||
if (!entry.package.packageNamespace) {
|
||||
errors.push(`dependencies[${index}].package.packageNamespace is required`);
|
||||
}
|
||||
if (!entry.package.packageName) {
|
||||
errors.push(`dependencies[${index}].package.packageName is required`);
|
||||
}
|
||||
if (entry.package.descriptorVersion === 0) {
|
||||
errors.push(`dependencies[${index}].package.descriptorVersion is required`);
|
||||
if (seenExports.has(entry.exportId)) {
|
||||
errors.push(`duplicate export: ${entry.exportId}`);
|
||||
}
|
||||
seenExports.add(entry.exportId);
|
||||
}
|
||||
|
||||
return errors;
|
||||
|
||||
Reference in New Issue
Block a user