Implement main-thread Camino sessions and synchronous CRDT editing
This commit is contained in:
@@ -9,10 +9,15 @@ import type {
|
||||
} from "../capability-model/types.js";
|
||||
import { type ExecutionPlan, ExecutionPlanError, hexDigest } from "./plan.js";
|
||||
import { portableValueSchema } from "../bindings/portable.js";
|
||||
function preparedInputPaths(type: ValueType, path: (string | null)[] = []): (string | null)[][] {
|
||||
type PreparedStep = string | null | { case: string; id: string };
|
||||
function preparedInputPaths(type: ValueType, path: PreparedStep[] = []): PreparedStep[][] {
|
||||
if (type.kind === "change") return [path];
|
||||
if (type.kind === "optional") return preparedInputPaths(type.value, path);
|
||||
if (type.kind === "list") return preparedInputPaths(type.value, [...path, null]);
|
||||
if (type.kind === "variant")
|
||||
return Object.entries(type.cases).flatMap(([label, entry]) =>
|
||||
preparedInputPaths(entry.value, [...path, { case: label, id: entry.id }]),
|
||||
);
|
||||
if (type.kind === "record")
|
||||
return Object.entries(type.fields).flatMap(([key, value]) => preparedInputPaths(value, [...path, key]));
|
||||
return [];
|
||||
@@ -210,6 +215,7 @@ export function compileKernelProgram(plan: ExecutionPlan): unknown {
|
||||
package: binding.packageRevisionId,
|
||||
export: binding.exportId,
|
||||
ports,
|
||||
...(entry.preparation ? { preparation: entry.preparation } : {}),
|
||||
...(check
|
||||
? { acceptance: { export: check.id, ports: compilePorts(check, binding.acceptanceDependencies ?? []) } }
|
||||
: {}),
|
||||
@@ -237,6 +243,7 @@ export function compileKernelProgram(plan: ExecutionPlan): unknown {
|
||||
revision: pkg.revisionId,
|
||||
exports: pkg.exports.map((entry) => ({
|
||||
id: entry.id,
|
||||
...(entry.preparation ? { preparation: entry.preparation } : {}),
|
||||
...(entry.acceptanceExportId ? { acceptance: entry.acceptanceExportId } : {}),
|
||||
effect: entry.execution?.kind ?? "remote",
|
||||
targets: entry.execution && entry.execution.kind !== "remote" ? entry.execution.targets : [],
|
||||
|
||||
@@ -142,6 +142,9 @@ export function resolvePlannedOperation(
|
||||
/** Bound argument/state codec subset. A parsed type alone does not mean a runtime implements it. */
|
||||
function checkValue(type: ValueType, path: string, allowChange = false): void {
|
||||
switch (type.kind) {
|
||||
case "variant":
|
||||
for (const [label, entry] of Object.entries(type.cases)) checkValue(entry.value, `${path}.${label}`, allowChange);
|
||||
return;
|
||||
case "scalar":
|
||||
case "object-ref":
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user