Admit Odin as a signed Idunn target

This commit is contained in:
Meta Vens 2026-08-21 19:50:24 +02:00
commit c7012a87c9
10 changed files with 314 additions and 30 deletions

View file

@ -80,6 +80,11 @@ Local package surfaces:
- Hosted VoidBot release: upstream `main` -> Yggdrasil-local Idunn -> the
root-owned `/srv/odin/deploy-manifests/voidbot` actuator. Local checkouts are
development and diagnostics only; do not create a local deployment.
- Hosted Odin release: branch `codex/ygg-idunn-independent-bootstrap` plus the
exact CultLib commit in `deploy/cultlib.commit` -> one immutable
`/srv/odin/releases/<commit>` body -> `/srv/odin/current`. Odin signs its own
liveness to Idunn, while Idunn starts independently and owns later restart or
deployment actuation.
- Operator escalation: Bifrost-owned CultMesh crossing; current compatibility
delivery calls `scripts\notify-idunn-operator-alarm.ps1`, which asks Bifrost
to publish a typed `gamecult.operator_dm_request.v1` CultMesh command document

View file

@ -4157,6 +4157,25 @@ fn release_target(
}
}
fn release_target_on_branch(
repo: &str,
repo_path: PathBuf,
upstream_branch: &str,
rollout_strategy: &str,
state_migration_command: Option<&str>,
zero_downtime_capability: &str,
) -> ReleaseTarget {
let mut target = release_target(
repo,
repo_path,
rollout_strategy,
state_migration_command,
zero_downtime_capability,
);
target.upstream_branch = upstream_branch.to_string();
target
}
fn requiring_bifrost_authority(mut release: ReleaseTarget) -> ReleaseTarget {
release.requires_bifrost_authority = true;
release
@ -4923,6 +4942,57 @@ fn swarm_targets(options: &SwarmOptions) -> Result<Vec<DaemonTarget>> {
match options.profile.as_str() {
"yggdrasil-local" => Ok(vec![
DaemonTarget {
daemon_id: "yggdrasil-odin".to_string(),
verse_id: "yggdrasil.local".to_string(),
name: "Yggdrasil Odin all-seer".to_string(),
health_contract: locally_supervised_health_contract(
"odin.cultnet-rudp-provider-health",
"failed",
),
deploy_command: Some(yggdrasil_actuator("deploy", "odin")),
restart_command: Some(yggdrasil_actuator("restart", "odin")),
release: Some(with_deployed_revision_witness(
release_target_on_branch(
"Odin",
PathBuf::from("/srv/build/Odin"),
"codex/ygg-idunn-independent-bootstrap",
"restart-after-verified-build",
None,
"restart-required",
),
PathBuf::from("/srv/odin/deploy/deployment.env"),
)),
enabled: true,
interval_seconds: 30,
},
DaemonTarget {
daemon_id: "yggdrasil-ghostlight".to_string(),
verse_id: "yggdrasil.local".to_string(),
name: "Yggdrasil Ghostlight Dungeon".to_string(),
health_contract: locally_supervised_health_contract(
"ghostlight.cultnet-rudp-service-health",
"failed",
),
deploy_command: Some(yggdrasil_actuator("deploy", "ghostlight")),
restart_command: Some(yggdrasil_actuator("restart", "ghostlight")),
release: Some(with_deployed_revision_witness(
release_target_on_branch(
"Ghostlight",
PathBuf::from("/srv/build/Ghostlight"),
"codex/ghostlight-dungeon-mvp",
"restart-after-verified-build",
None,
"restart-required",
),
PathBuf::from("/srv/ghostlight/deploy/deployment.env"),
)),
// Ghostlight becomes a continuity target only after its Linux
// body and signed-health identity have been admitted. A
// missing service is not an unhealthy installed service.
enabled: false,
interval_seconds: 30,
},
DaemonTarget {
daemon_id: "yggdrasil-voidbot".to_string(),
verse_id: "yggdrasil.local".to_string(),
@ -4968,9 +5038,10 @@ fn swarm_targets(options: &SwarmOptions) -> Result<Vec<DaemonTarget>> {
deploy_command: Some(yggdrasil_actuator("deploy", "epiphany")),
restart_command: Some(yggdrasil_actuator("restart", "epiphany")),
release: Some(requiring_bifrost_authority(with_deployed_revision_witness(
release_target(
release_target_on_branch(
"Epiphany",
PathBuf::from("/srv/build/Epiphany"),
"codex/epiphany-shakedown-live",
"restart-after-verified-build",
None,
"restart-required",
@ -7706,7 +7777,7 @@ mod tests {
assert_eq!(release.repository_full_name, "GameCult/Epiphany");
assert_eq!(release.repo_path, PathBuf::from("/srv/build/Epiphany"));
assert_eq!(release.upstream_remote, "origin");
assert_eq!(release.upstream_branch, "main");
assert_eq!(release.upstream_branch, "codex/epiphany-shakedown-live");
assert_eq!(release.rollout_strategy, "restart-after-verified-build");
assert_eq!(release.state_migration_command, None);
assert_eq!(release.zero_downtime_capability, "restart-required");
@ -7760,7 +7831,7 @@ mod tests {
)
);
assert!(actuator.contains(
"voidbot|heimdall|repixelizer|streampixels) target_requires_bifrost_authority=false"
"voidbot|heimdall|repixelizer|streampixels|odin|ghostlight) target_requires_bifrost_authority=false"
));
assert!(
actuator
@ -7785,6 +7856,58 @@ mod tests {
);
}
#[test]
fn yggdrasil_runtime_catalog_includes_discovery_and_dungeon_bodies() {
let targets = swarm_targets(&SwarmOptions {
profile: "yggdrasil-local".to_string(),
repo_root: PathBuf::from("/srv/odin/source"),
})
.expect("yggdrasil-local targets");
for (daemon_id, repo, branch, witness, actuator_name) in [
(
"yggdrasil-odin",
"Odin",
"codex/ygg-idunn-independent-bootstrap",
"/srv/odin/deploy/deployment.env",
"odin",
),
(
"yggdrasil-ghostlight",
"Ghostlight",
"codex/ghostlight-dungeon-mvp",
"/srv/ghostlight/deploy/deployment.env",
"ghostlight",
),
] {
let target = targets
.iter()
.find(|target| target.daemon_id == daemon_id)
.unwrap_or_else(|| panic!("missing {daemon_id}"));
assert!(target.health_contract.restart_on_missing_publication);
assert_eq!(
target.restart_command.as_deref(),
Some(format!(
"sudo -n /usr/local/libexec/idunn-yggdrasil restart {actuator_name}"
))
.as_deref()
);
let release = target.release.as_ref().expect("release target");
assert_eq!(release.repo, repo);
assert_eq!(release.upstream_branch, branch);
assert_eq!(
release.deployed_revision_witness,
Some(PathBuf::from(witness))
);
assert!(!release.requires_bifrost_authority);
assert_eq!(target.enabled, daemon_id == "yggdrasil-odin");
}
let actuator = include_str!("../../../scripts/linux/idunn-yggdrasil");
assert!(actuator.contains("deploy:odin|restart:odin"));
assert!(actuator.contains("deploy:ghostlight|restart:ghostlight"));
}
struct FakeReleaseStatePort {
fetch_error: Option<String>,
desired: std::result::Result<String, String>,

1
deploy/cultlib.commit Normal file
View file

@ -0,0 +1 @@
21163d83fa2670dbcc9cdd57c6c1776b33a91d62

View file

@ -44,6 +44,13 @@ The daemon-authored statement binds:
The Idunn trust binding names the only public key allowed to speak for that
daemon/contract/runtime tuple and whether release identity is required.
Yggdrasil Odin uses the generic signed contract with daemon
`yggdrasil-odin`, source runtime `odin-yggdrasil`, and a root-provisioned
Ed25519 key readable only by the Odin runtime group. Its health signature owns
liveness. Exact Odin and CultLib revisions remain deployment authority in the
immutable release and `/srv/odin/deploy/deployment.env`; neither Docker health
nor the signed liveness statement may rewrite that witness.
## Outputs
Idunn persists two separate facts:

View file

@ -13,10 +13,11 @@ escalation, and continuity witness state.
## Authority Map
- Owner: Idunn owns daemon lifecycle management after Odin has accepted where a
daemon lives: bring-up after host reboot, deployment freshness, crash
- Owner: Idunn owns daemon lifecycle management from its root-admitted target
catalog: bring-up after host reboot, deployment freshness, crash
recovery, health watching, deploy/restart policy, and operator escalation.
- Inputs: Odin's accepted service records, provider advertisements, `.cc`
- Inputs: its admitted target catalog, Odin's accepted service records when
Odin is available, provider advertisements, `.cc`
witnesses, advertised command boundaries, CultNet/RUDP health contracts,
freshness windows, operator policy, local service manager state, and explicit
deployment/debug witnesses that cannot satisfy daemon health.
@ -35,6 +36,8 @@ escalation, and continuity witness state.
Agents are also forbidden deploy writers: they configure Idunn release
targets, command boundaries, migration commands, and rollout policy, then let
Idunn actuate and witness deployment. They do not run deploy scripts by hand.
Odin is itself an Idunn target; Odin discovery is never a prerequisite for
starting Idunn or recovering Odin.
- Shared paths: manual operator deploy/restart, scheduled deploy/restart,
degraded-health repair, boot rehydration, and future remote worker recovery
must pass through the same Idunn command primitive.
@ -317,8 +320,13 @@ idunn.rudp_health_ingress.v1
lacks hot reload, blue/green routing, rolling instances, or another named
in-place swap mechanism, Idunn records `restart-required` and verifies the
restart path honestly.
- Yggdrasil Heimdall, repixelizer, and StreamPixels are enforced through the
- Yggdrasil Odin, Heimdall, repixelizer, and StreamPixels are enforced through the
generic source artifact lane and their existing `gamecult-ops` runbooks.
Odin publishes `idunn.signed_daemon_health.v1` with its root-bound Ed25519
identity. Its immutable release pins both the Odin commit and the exact
CultLib commit, then switches them through one `/srv/odin/current` link.
Ghostlight is present but disabled in the catalog until its Linux runtime and
signed-health identity are admitted; absence is not treated as failed health.
Bifrost is explicitly blocked as of 2026-06-09: committed Bifrost `HEAD`
expects `UserAccounts.HeimdallAccountId`, while Yggdrasil's production
database lacks that column and EF reports no pending migration. Idunn must

View file

@ -20,7 +20,7 @@ compose=/srv/compose/yggdrasil-apps.yaml
require_release_lineage() {
case "$target" in
epiphany|bifrost-persona-feedback) target_requires_bifrost_authority=true ;;
voidbot|heimdall|repixelizer|streampixels) target_requires_bifrost_authority=false ;;
voidbot|heimdall|repixelizer|streampixels|odin|ghostlight) target_requires_bifrost_authority=false ;;
*) echo "deployment target has no release-authority policy: $target" >&2; exit 1 ;;
esac
if [ "$requires_bifrost_authority" != "$target_requires_bifrost_authority" ]; then
@ -69,7 +69,7 @@ case "$action:$target" in
restart:streampixels)
docker compose -f "$compose" restart streampixels-service streampixels-web
;;
deploy:voidbot|restart:voidbot|deploy:epiphany|restart:epiphany)
deploy:voidbot|restart:voidbot|deploy:epiphany|restart:epiphany|deploy:odin|restart:odin|deploy:ghostlight|restart:ghostlight)
manifest="/srv/odin/deploy-manifests/$target"
if [ ! -x "$manifest" ] || [ ! -O "$manifest" ]; then
echo "root-owned executable deploy manifest is not installed: $manifest" >&2

View file

@ -55,7 +55,9 @@ instead of building one more private watchdog.
Idunn is a Rust daemon inside Odin's Cargo workspace. Starfire and Yggdrasil
run separate host-local swarm profiles. Starfire owns its local adjunct daemons
and remote display/telemetry lanes. Yggdrasil owns its hosted release targets,
including VoidBot. Each target declares a daemon-owned health contract and keeps
including Odin and VoidBot. Idunn starts independently of every managed target,
so an Odin outage cannot remove the organ responsible for recovering Odin.
Each target declares a daemon-owned health contract and keeps
its own interval and deploy/restart authority. Daemon truth comes from typed
CultNet/RUDP publication and daemon-owned boundary stores. Shell scripts remain
deployment, restart, and manual diagnostic lowerings only; they do not satisfy
@ -177,7 +179,9 @@ The enforced targets are Nightwing Gjallar plus the Yggdrasil source artifact
lanes whose ops runbooks can produce and verify deployment manifests. Each
enforced target must declare upstream remote/branch, rollout strategy, state
migration authority, and zero-downtime capability. Idunn deploys the declared
upstream `main` revision, not arbitrary local `HEAD`. Bifrost is blocked until
declared upstream revision, not arbitrary local `HEAD`. Ghostlight's catalog
entry remains disabled until its Linux body and signed health identity are
admitted. Bifrost is blocked until
its production database migration path is coherent; mobile device installs
remain blocked at their physical approval boundaries; GitHub Pages remains
external-owned.

View file

@ -29,6 +29,10 @@ function buildConfig(argv) {
endpoint: String(args["idunn-rudp-health"]),
daemonId: String(args["idunn-daemon"] || "odin"),
healthContract: String(args["idunn-health-contract"] || "odin.cultnet-rudp-provider-health"),
privateKeyPath: args["idunn-health-private-key"]
? String(args["idunn-health-private-key"])
: "",
sourceRuntimeId: String(args["idunn-source-runtime"] || "odin-coordinator"),
} : null;
const interfaceBindingStores = String(
args.interfaceBindingStore ||

View file

@ -1,6 +1,8 @@
"use strict";
const dgram = require("dgram");
const crypto = require("crypto");
const fs = require("fs");
const path = require("path");
const { createRequire } = require("module");
@ -26,15 +28,32 @@ const { encode } = requireCultNet("@msgpack/msgpack");
const CULTNET_RUDP_PROTOCOL_ID = "cultnet.transport.rudp.v0";
const IDUNN_HEALTH_RUDP_CONNECTION_ID = 0x1d0d0001;
const SIGNED_HEALTH_SCHEMA = "idunn.signed_daemon_health.v1";
const SIGNATURE_DOMAIN = Buffer.from("gamecult.provider-health.signature.v1\0", "utf8");
const ID_DOMAIN = Buffer.from("gamecult.provider-health.identity.v1\0", "utf8");
const SIGNING_PURPOSE = Buffer.from(SIGNED_HEALTH_SCHEMA, "utf8");
function createIdunnRudpHealthPublisher(options) {
if (!options) return null;
const endpoint = parseEndpoint(options.endpoint);
return {
const publisher = {
daemonId: options.daemonId,
endpoint,
healthContract: options.healthContract,
publisherIncarnationId: crypto.randomUUID(),
publisherSequence: 0,
sourceRuntimeId: options.sourceRuntimeId || "odin-coordinator",
};
if (options.privateKeyPath) {
publisher.privateKey = crypto.createPrivateKey(fs.readFileSync(options.privateKeyPath));
publisher.publicKey = rawEd25519PublicKey(publisher.privateKey);
publisher.signerIdentityId = crypto
.createHash("sha256")
.update(ID_DOMAIN)
.update(publisher.publicKey)
.digest("hex");
}
return publisher;
}
async function publishIdunnRudpHealth(publisher, health) {
@ -61,34 +80,28 @@ async function publishIdunnRudpHealth(publisher, health) {
);
const observedAt = health.observedAt || new Date().toISOString();
const record = {
daemonId: publisher.daemonId,
state: health.state,
detail: health.detail,
const signed = publisher.privateKey
? signedHealthPayload(publisher, health, observedAt)
: null;
const payload = signed?.payload || encode([
publisher.daemonId,
health.state,
String(health.detail || "").slice(0, 512),
observedAt,
healthContract: publisher.healthContract,
publicationSource: "daemon-published",
transport: CULTNET_RUDP_PROTOCOL_ID,
};
const payload = encode([
record.daemonId,
record.state,
record.detail,
record.observedAt,
record.healthContract,
record.publicationSource,
record.transport,
publisher.healthContract,
"daemon-published",
CULTNET_RUDP_PROTOCOL_ID,
]);
const message = {
schemaVersion: "cultnet.document_put_raw.v0",
messageId: `odin-health:${publisher.daemonId}:${observedAt.replace(/[:.]/g, "-")}`,
document: {
schemaId: "idunn.daemon_health",
schemaId: signed ? SIGNED_HEALTH_SCHEMA : "idunn.daemon_health",
recordKey: publisher.daemonId,
storedAt: observedAt,
payloadEncoding: "messagepack",
payload,
sourceRuntimeId: "odin-coordinator",
sourceRuntimeId: publisher.sourceRuntimeId,
sourceRole: "daemon-health-publisher",
tags: [CULTNET_RUDP_PROTOCOL_ID],
},
@ -117,6 +130,58 @@ async function publishIdunnRudpHealth(publisher, health) {
}
}
function signedHealthPayload(publisher, health, observedAt) {
publisher.publisherSequence += 1;
const observedAtUnixMillis = Date.parse(observedAt);
if (!Number.isSafeInteger(observedAtUnixMillis) || observedAtUnixMillis <= 0) {
throw new Error("Idunn signed health observation time is invalid.");
}
const unsigned = [
SIGNED_HEALTH_SCHEMA,
publisher.daemonId,
publisher.healthContract,
publisher.sourceRuntimeId,
health.state,
String(health.detail || "").slice(0, 512),
publisher.signerIdentityId,
publisher.publisherIncarnationId,
publisher.publisherSequence,
observedAtUnixMillis,
null,
null,
null,
null,
"ed25519",
new Uint8Array(),
false,
];
const unsignedPayload = encode(unsigned);
const signature = crypto.sign(null, signingMessage(unsignedPayload), publisher.privateKey);
const statement = unsigned.slice();
statement[15] = new Uint8Array(signature);
return { payload: encode(statement), statement, unsignedPayload };
}
function signingMessage(payload) {
const purposeLength = Buffer.alloc(8);
purposeLength.writeBigUInt64BE(BigInt(SIGNING_PURPOSE.length));
const payloadLength = Buffer.alloc(8);
payloadLength.writeBigUInt64BE(BigInt(payload.length));
return Buffer.concat([
SIGNATURE_DOMAIN,
purposeLength,
SIGNING_PURPOSE,
payloadLength,
Buffer.from(payload),
]);
}
function rawEd25519PublicKey(privateKey) {
const der = crypto.createPublicKey(privateKey).export({ type: "spki", format: "der" });
if (der.length < 32) throw new Error("Ed25519 public key export is too short.");
return Buffer.from(der.subarray(der.length - 32));
}
async function bindSocket(socket, endpoint) {
await new Promise((resolve, reject) => {
socket.once("error", reject);
@ -254,4 +319,6 @@ module.exports = {
CULTNET_RUDP_PROTOCOL_ID,
createIdunnRudpHealthPublisher,
publishIdunnRudpHealth,
signedHealthPayload,
signingMessage,
};

View file

@ -0,0 +1,65 @@
"use strict";
const assert = require("node:assert/strict");
const crypto = require("node:crypto");
const test = require("node:test");
const {
signedHealthPayload,
signingMessage,
} = require("../src/odin/idunn-rudp.cjs");
test("Odin signs the complete canonical provider-health statement", () => {
const { privateKey, publicKey } = crypto.generateKeyPairSync("ed25519");
const publicDer = publicKey.export({ type: "spki", format: "der" });
const rawPublicKey = Buffer.from(publicDer.subarray(publicDer.length - 32));
const signerIdentityId = crypto
.createHash("sha256")
.update(Buffer.from("gamecult.provider-health.identity.v1\0"))
.update(rawPublicKey)
.digest("hex");
const publisher = {
daemonId: "yggdrasil-odin",
healthContract: "odin.cultnet-rudp-provider-health",
privateKey,
publisherIncarnationId: "24e0dc7f-6a92-4aa8-9f56-fb513d265e13",
publisherSequence: 0,
signerIdentityId,
sourceRuntimeId: "odin-yggdrasil",
};
const signed = signedHealthPayload(
publisher,
{ state: "active", detail: "catalog current" },
"2026-08-21T12:34:56.789Z",
);
assert.equal(signed.statement[0], "idunn.signed_daemon_health.v1");
assert.equal(signed.statement[1], "yggdrasil-odin");
assert.equal(signed.statement[2], "odin.cultnet-rudp-provider-health");
assert.equal(signed.statement[3], "odin-yggdrasil");
assert.equal(signed.statement[8], 1);
assert.equal(signed.statement[9], 1787315696789);
assert.equal(signed.statement[15].byteLength, 64);
assert.equal(
crypto.verify(
null,
signingMessage(signed.unsignedPayload),
publicKey,
Buffer.from(signed.statement[15]),
),
true,
);
const tampered = Buffer.from(signed.unsignedPayload);
tampered[tampered.length - 1] ^= 1;
assert.equal(
crypto.verify(
null,
signingMessage(tampered),
publicKey,
Buffer.from(signed.statement[15]),
),
false,
);
});