Build checked asynchronous service registries with Nix

This commit is contained in:
Timothy J. Aveni
2026-09-20 21:06:45 -07:00
parent c4ae58831d
commit 1dadc642d1
5 changed files with 50 additions and 4 deletions
+19 -1
View File
@@ -1,5 +1,5 @@
import { createHash } from "node:crypto";
import { generatePortableTypeScriptBindings } from "../bindings/portable.js";
import { generatePortableTypeScriptBindings, generateRemoteTypeScriptBindings } from "../bindings/portable.js";
import { type ExecutionPlan, ExecutionPlanError, hexDigest } from "./plan.js";
import { type ArtifactReader, type PackageArtifacts } from "./artifacts.js";
import { loadArtifactWorld, type LoadedArtifactWorld } from "./files.js";
@@ -53,6 +53,24 @@ export function expectedArtifactReceipt(
sources.set(path, bytes);
return { target, path, digest: hashBytes(bytes), bytes: bytes.length };
});
// Custom language services need no TypeScript adapter. A checked JS module
// exporting remote handlers does, and must carry the exact generated source.
if (
manifest.implementations.some(
(implementation) =>
implementation.compatibility === "quixos-js-module-v1" &&
implementation.exports.some((id) =>
pkg.exports.some((entry) => entry.id === id && entry.execution.kind === "remote"),
),
)
) {
const path = "share/quixos/generated/remote.ts";
const bytes = new TextEncoder().encode(
generateRemoteTypeScriptBindings(plan.definition.bindingSchema, pkg.revision),
);
sources.set(path, bytes);
generated.push({ target: "server", path, digest: hashBytes(bytes), bytes: bytes.length });
}
return {
receipt: {
schemaVersion: 1,