Preserve nested CRDT recovery and serialize compound editor submissions

This commit is contained in:
Timothy J. Aveni
2026-09-20 23:26:13 -07:00
parent 2056c1e352
commit 47a3fe9eae
5 changed files with 37 additions and 1 deletions
+10
View File
@@ -8,6 +8,14 @@ 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)[][] {
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 === "record")
return Object.entries(type.fields).flatMap(([key, value]) => preparedInputPaths(value, [...path, key]));
return [];
}
/** Small data-only interpreter input; no compiler, parser, Node module or SQL dependency reaches the browser. */
export function compileKernelProgram(plan: ExecutionPlan): unknown {
if (hexDigest(plan.definition) !== plan.digest)
@@ -172,6 +180,7 @@ export function compileKernelProgram(plan: ExecutionPlan): unknown {
: {}),
};
}
const inputChanges = preparedInputPaths(operation.input);
const input = schema(operation.input),
output = schema(operation.output);
return {
@@ -183,6 +192,7 @@ export function compileKernelProgram(plan: ExecutionPlan): unknown {
effect: operation.execution.kind,
targets: operation.execution.kind === "remote" ? [] : operation.execution.targets,
input,
...(inputChanges.length ? { inputChanges } : {}),
output,
unsupported: unsupported ?? (input && output ? null : "UNSUPPORTED_OPERATION_CODEC"),
binding: target,