Odin/src/odin/documents.cjs
Meta Vens 20bacabf7c Reduce Odin's document catalog to a CultLib adapter
defineOdinDocuments was 536 lines defining 45 CultCache document types for Eve,
Ghostlight, Heimdall, Idunn, Muninn, Sleipnir, Aetheria, VoidBot and Stonks.
The name was the only part of it that was Odin's.

The catalog is now cultcache-ts's defineSwarmDocuments, verified byte-identical
to what this file produced. What remains here is 26 lines resolving CultLib and
re-exporting under the name Odin's consumers already call, so odin-coordinator
and the two discovery tests are untouched.

This was the last shared dependency between Odin and Hermodr. utils.cjs now has
exactly one consumer, hermodr-daemon, using exactly one of its six functions, so
it leaves with Hermodr rather than staying as a library nobody here reads.

CULTLIB_ROOT is honoured with the sibling walk as fallback, matching the health
adapter and hermodr-daemon.

22 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 19:41:28 +02:00

26 lines
1.1 KiB
JavaScript

"use strict";
// The swarm document-type catalog, as Odin consumes it.
//
// The 45 definitions used to live here. Almost none of them are Odin's: they
// describe documents that cross service boundaries, and every service that
// decodes another's documents needs the same ones. They lived here because Odin
// was written first. They now live in CultLib as cultcache-ts's
// defineSwarmDocuments, beside the defineDocumentType that builds them, so
// Hermodr can leave without forking a second definition of one wire format.
const path = require("path");
const { createRequire } = require("module");
const cultLibRoot = process.env.CULTLIB_ROOT
? path.resolve(process.env.CULTLIB_ROOT)
: path.resolve(__dirname, "..", "..", "..", "CultLib");
const requireCultCache = createRequire(path.resolve(cultLibRoot, "packages", "cultcache-ts", "package.json"));
const { defineSwarmDocuments } = requireCultCache("./dist/index.js");
// Odin's consumers know this name. The catalog is not Odin's, but the call is.
const defineOdinDocuments = defineSwarmDocuments;
module.exports = { defineOdinDocuments, defineSwarmDocuments };