feat: add module runtime lifecycle
CI / verify (push) Successful in 2m14s
CI / infrastructure-smoke (push) Failing after 1m36s

This commit is contained in:
ekklesia
2026-07-12 22:49:51 -05:00
parent 57552a21a4
commit 7b448d8706
28 changed files with 1382 additions and 203 deletions
@@ -0,0 +1,25 @@
import { describe, expect, it, vi } from "vitest";
import { defineModuleRuntime } from "../src/index.js";
describe("defineModuleRuntime", () => {
it("defines a frozen server runtime without duplicating the static manifest", async () => {
const start = vi.fn();
const runtime = defineModuleRuntime({
id: "example",
start,
version: "0.1.0",
});
expect(runtime).toEqual({ id: "example", start, version: "0.1.0" });
expect(Object.isFrozen(runtime)).toBe(true);
});
it("rejects invalid runtime definitions", () => {
expect(() =>
defineModuleRuntime({
id: "Not Valid",
version: "0.1.0",
}),
).toThrow("Invalid Ekklesia module runtime definition.");
});
});
@@ -1,42 +0,0 @@
import { describe, expect, it } from "vitest";
import { defineModule } from "../src/index.js";
describe("defineModule", () => {
it("returns a validated and normalized public manifest", () => {
const module = defineModule({
manifestVersion: 1,
id: "example",
name: "Example",
version: "0.1.0",
compatibility: {
platform: "^0.1.0",
moduleSdk: "^0.1.0",
},
entrypoints: {
server: "./src/server/index.ts",
},
});
expect(module.capabilities).toEqual([]);
expect(module.permissions).toEqual([]);
expect(module.storage.buckets).toEqual([]);
});
it("rejects invalid module definitions before runtime registration", () => {
expect(() =>
defineModule({
manifestVersion: 1,
id: "Not Valid",
name: "Invalid",
version: "0.1.0",
compatibility: {
platform: "^0.1.0",
moduleSdk: "^0.1.0",
},
entrypoints: {
server: "./src/server/index.ts",
},
}),
).toThrow();
});
});