Hermodr leaves Odin
Hermodr is a browser lowering, not an all-seer organ. It lived here as Node inside a Rust repository, sharing a module directory with the coordinator, and until this week it ran its own provider ingress and accepted publications into a private store. The ingress went first on purpose: extracting it beforehand would have relocated a second acceptance authority and called that progress. Removed: the daemon, its provider subscription source and state stream, both test files, four lifecycle scripts, the persona avatar, the hermodr:start script, and src/odin/utils.cjs, whose only remaining consumer was Hermodr and which it used for one of six functions. src/odin/ falls from fourteen modules to eleven. The CommonJS surface falls from sixteen files to twelve. What is left is the coordinator, the Rust organs, and two adapters declaring contracts other repositories own. The plan document stays as the record of what left and why. Phase 5, static lowering, is Hermodr's business now. 5 tests pass, syntax check clean over twelve files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
20bacabf7c
commit
3f22fd1d76
13 changed files with 20 additions and 2173 deletions
|
|
@ -1,70 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
const test = require("node:test");
|
||||
|
||||
const {
|
||||
createBrowserCatalog,
|
||||
findProviderCdnRoute,
|
||||
hermodrRudpPeerOptions,
|
||||
normalizeProviderAdvertisement,
|
||||
normalizeSurfaceState,
|
||||
surfaceRecordKeys,
|
||||
} = require("../src/hermodr-daemon.cjs");
|
||||
|
||||
test("Hermodr outbound RUDP peers bind beyond loopback", () => {
|
||||
const options = hermodrRudpPeerOptions();
|
||||
assert.equal(options.bindHost, "0.0.0.0");
|
||||
assert.equal(options.connectTimeoutMs, 2_000);
|
||||
});
|
||||
|
||||
const provider = normalizeProviderAdvertisement({
|
||||
providerId: "fixture.game",
|
||||
title: "Fixture game",
|
||||
surfaces: [
|
||||
{ surfaceId: "fixture.menu", surfaceKind: "menu", recordRef: "cultmesh://fixture/surfaces/menu" },
|
||||
{ surfaceId: "fixture.world", surfaceKind: "interactive-world", recordRef: "cultmesh://fixture/surfaces/world" },
|
||||
],
|
||||
routes: [{
|
||||
id: "fixture-cdn",
|
||||
uri: "rudp://127.0.0.1:3000",
|
||||
tags: ["cultmesh-cdn", "asset_blob"],
|
||||
}],
|
||||
});
|
||||
|
||||
test("Hermodr preserves every advertised surface and its semantic kind", () => {
|
||||
const catalog = createBrowserCatalog([provider], { odinCultMeshUri: "cultmesh://odin/providers" });
|
||||
assert.deepEqual(catalog.surfaces.map(surface => surface.surfaceId), ["fixture.menu", "fixture.world"]);
|
||||
assert.equal(catalog.surfaces[1].surfaceKind, "interactive-world");
|
||||
assert.equal(catalog.providers[0].surfaces[1].recordRef, "cultmesh://fixture/surfaces/world");
|
||||
});
|
||||
|
||||
test("surface reads prefer the provider-advertised record reference", () => {
|
||||
const catalog = createBrowserCatalog([provider]);
|
||||
assert.equal(surfaceRecordKeys(catalog, "fixture.game", "fixture.world")[0], "cultmesh://fixture/surfaces/world");
|
||||
});
|
||||
|
||||
test("surface-state normalization lowers MessagePack array records", () => {
|
||||
const state = normalizeSurfaceState([
|
||||
"gjallar.overview",
|
||||
"Gjallar",
|
||||
7,
|
||||
"2026-08-25T00:00:00Z",
|
||||
[
|
||||
"gjallar.overview.surface",
|
||||
["root", "dashboard", { title: "Gjallar" }, [], [], [], { mode: "weighted-bisect" }, {}],
|
||||
[],
|
||||
],
|
||||
], "gjallar.overview");
|
||||
|
||||
assert.equal(state.surface.id, "gjallar.overview.surface");
|
||||
assert.equal(state.surface.root.kind, "dashboard");
|
||||
assert.equal(state.surface.root.layout.mode, "weighted-bisect");
|
||||
});
|
||||
|
||||
test("CDN routing follows the asset URI provider instead of a product name", () => {
|
||||
const catalog = createBrowserCatalog([provider]);
|
||||
const route = findProviderCdnRoute(catalog, "cultmesh://fixture.game/assets/player");
|
||||
assert.equal(route.providerId, "fixture.game");
|
||||
assert.equal(route.endpoint, "rudp://127.0.0.1:3000");
|
||||
});
|
||||
|
|
@ -1,188 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const { ProviderSubscriptionSource } = require("../src/hermodr-provider-subscription.cjs");
|
||||
|
||||
function harness(reads) {
|
||||
const state = { value: reads.shift(), calls: 0, cleared: 0 };
|
||||
let tick = null;
|
||||
const source = new ProviderSubscriptionSource(
|
||||
async () => {
|
||||
state.calls += 1;
|
||||
if (state.value instanceof Error) throw state.value;
|
||||
return state.value;
|
||||
},
|
||||
{
|
||||
setInterval: (fn) => { tick = fn; return { unref() {} }; },
|
||||
clearInterval: () => { state.cleared += 1; tick = null; },
|
||||
onError: () => {},
|
||||
},
|
||||
);
|
||||
return {
|
||||
source,
|
||||
state,
|
||||
set: (value) => { state.value = value; },
|
||||
poll: async () => { if (tick) tick(); await flush(); },
|
||||
hasTimer: () => tick !== null,
|
||||
};
|
||||
}
|
||||
|
||||
async function flush() {
|
||||
for (let i = 0; i < 4; i += 1) await new Promise((resolve) => setImmediate(resolve));
|
||||
}
|
||||
|
||||
function collect(source, providerId = "erycina", schemaId = "gamecult.eve.surface_state.v1", recordKey = "erycina") {
|
||||
const events = [];
|
||||
const release = source.forProvider(providerId).watchLifecycle(schemaId, recordKey, (event) => events.push(event));
|
||||
return { events, release };
|
||||
}
|
||||
|
||||
test("first watch emits a snapshot of the provider's document", async () => {
|
||||
const h = harness([{ title: "Erycina" }]);
|
||||
const { events } = collect(h.source);
|
||||
await flush();
|
||||
|
||||
assert.equal(events.length, 1);
|
||||
assert.equal(events[0].kind, "snapshot");
|
||||
assert.deepEqual(events[0].value, { title: "Erycina" });
|
||||
});
|
||||
|
||||
test("an unchanged document emits nothing further", async () => {
|
||||
const h = harness([{ title: "Erycina" }]);
|
||||
const { events } = collect(h.source);
|
||||
await flush();
|
||||
await h.poll();
|
||||
await h.poll();
|
||||
|
||||
assert.equal(events.length, 1);
|
||||
});
|
||||
|
||||
test("a changed document emits an update", async () => {
|
||||
const h = harness([{ version: 1 }]);
|
||||
const { events } = collect(h.source);
|
||||
await flush();
|
||||
h.set({ version: 2 });
|
||||
await h.poll();
|
||||
|
||||
assert.equal(events.length, 2);
|
||||
assert.equal(events[1].kind, "update");
|
||||
assert.deepEqual(events[1].value, { version: 2 });
|
||||
assert.ok(events[1].sequence > events[0].sequence);
|
||||
});
|
||||
|
||||
test("a document that disappears is withdrawn", async () => {
|
||||
const h = harness([{ version: 1 }]);
|
||||
const { events } = collect(h.source);
|
||||
await flush();
|
||||
h.set(null);
|
||||
await h.poll();
|
||||
|
||||
assert.equal(events.at(-1).kind, "withdrawn");
|
||||
assert.equal(events.at(-1).reason, "withdrawn");
|
||||
});
|
||||
|
||||
test("a document that returns after withdrawal emits a fresh snapshot", async () => {
|
||||
const h = harness([{ version: 1 }]);
|
||||
const { events } = collect(h.source);
|
||||
await flush();
|
||||
h.set(null);
|
||||
await h.poll();
|
||||
h.set({ version: 3 });
|
||||
await h.poll();
|
||||
|
||||
assert.equal(events.at(-1).kind, "snapshot");
|
||||
assert.deepEqual(events.at(-1).value, { version: 3 });
|
||||
});
|
||||
|
||||
test("a read failure is not a withdrawal", async () => {
|
||||
// A provider restart or a dropped packet must not look like the provider
|
||||
// retracting state it still holds. This is the invariant that stops a
|
||||
// transport hiccup from being rendered as authoritative absence.
|
||||
const h = harness([{ version: 1 }]);
|
||||
const { events } = collect(h.source);
|
||||
await flush();
|
||||
const before = events.length;
|
||||
|
||||
h.set(new Error("rudp timeout"));
|
||||
await h.poll();
|
||||
await h.poll();
|
||||
|
||||
assert.equal(events.length, before);
|
||||
assert.equal(events.at(-1).kind, "snapshot");
|
||||
});
|
||||
|
||||
test("state survives the failure and updates once reads recover", async () => {
|
||||
const h = harness([{ version: 1 }]);
|
||||
const { events } = collect(h.source);
|
||||
await flush();
|
||||
h.set(new Error("rudp timeout"));
|
||||
await h.poll();
|
||||
h.set({ version: 9 });
|
||||
await h.poll();
|
||||
|
||||
assert.equal(events.at(-1).kind, "update");
|
||||
assert.deepEqual(events.at(-1).value, { version: 9 });
|
||||
});
|
||||
|
||||
test("releasing the last listener stops polling", async () => {
|
||||
const h = harness([{ version: 1 }]);
|
||||
const { release } = collect(h.source);
|
||||
await flush();
|
||||
assert.ok(h.hasTimer());
|
||||
|
||||
release();
|
||||
|
||||
assert.equal(h.state.cleared, 1);
|
||||
assert.equal(h.hasTimer(), false);
|
||||
});
|
||||
|
||||
test("a second listener shares one poll and receives the current snapshot", async () => {
|
||||
const h = harness([{ version: 1 }]);
|
||||
const first = collect(h.source);
|
||||
await flush();
|
||||
const callsAfterFirst = h.state.calls;
|
||||
|
||||
const second = collect(h.source);
|
||||
await flush();
|
||||
|
||||
assert.equal(second.events[0].kind, "snapshot");
|
||||
assert.deepEqual(second.events[0].value, { version: 1 });
|
||||
// The shared entry polls once per interval regardless of listener count.
|
||||
await h.poll();
|
||||
assert.ok(h.state.calls <= callsAfterFirst + 2);
|
||||
|
||||
first.release();
|
||||
assert.equal(h.state.cleared, 0, "the entry survives while one listener remains");
|
||||
second.release();
|
||||
assert.equal(h.state.cleared, 1);
|
||||
});
|
||||
|
||||
test("watch skips withdrawal events and yields values only", async () => {
|
||||
const h = harness([{ version: 1 }]);
|
||||
const values = [];
|
||||
h.source.forProvider("erycina").watch("s", "k", (value) => values.push(value));
|
||||
await flush();
|
||||
h.set(null);
|
||||
await h.poll();
|
||||
h.set({ version: 2 });
|
||||
await h.poll();
|
||||
|
||||
assert.deepEqual(values, [{ version: 1 }, { version: 2 }]);
|
||||
});
|
||||
|
||||
test("latest refuses to invent a document the provider does not publish", async () => {
|
||||
const h = harness([null]);
|
||||
await assert.rejects(
|
||||
() => h.source.forProvider("erycina").latest("gamecult.eve.surface_state.v1", "erycina"),
|
||||
/published no/,
|
||||
);
|
||||
});
|
||||
|
||||
test("a subscription requires provider, schema, and record key", () => {
|
||||
const h = harness([{}]);
|
||||
assert.throws(() => h.source.forProvider("").watchLifecycle("s", "k", () => {}), /requires providerId/);
|
||||
assert.throws(() => h.source.forProvider("p").watchLifecycle("", "k", () => {}), /requires providerId/);
|
||||
assert.throws(() => h.source.forProvider("p").watchLifecycle("s", "", () => {}), /requires providerId/);
|
||||
});
|
||||
Loading…
Reference in a new issue