diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..0fe1b2f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1145 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "cc" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "005ec2760ca554fae18df7a11195552ec576cd665632a881bc011d5bb2fd4d80" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "typenum", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "cultcache-rs" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "cultcache-rs-derive", + "fs2", + "redb", + "rmp-serde", + "serde", + "serde_bytes", + "serde_json", + "uuid", + "windows-sys 0.59.0", +] + +[[package]] +name = "cultcache-rs-derive" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "cultmesh-rs" +version = "0.1.0" +dependencies = [ + "anyhow", + "cultcache-rs", + "cultnet-rs", + "serde", +] + +[[package]] +name = "cultnet-rs" +version = "0.1.0" +dependencies = [ + "aes-gcm", + "anyhow", + "base64", + "chrono", + "cultcache-rs", + "ed25519-dalek", + "hmac", + "rand", + "rmp-serde", + "rmpv", + "serde", + "serde_bytes", + "serde_json", + "sha2", + "socket2", + "uuid", + "windows-sys 0.61.2", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +dependencies = [ + "curve25519-dalek", + "ed25519", + "serde", + "sha2", + "subtle", + "zeroize", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "find-msvc-tools" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d" + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "muninn-daemon" +version = "0.1.0" +dependencies = [ + "anyhow", + "cultcache-rs", + "cultmesh-rs", + "cultnet-rs", + "libc", + "muninn-move-tracker", + "muninn-psmoveapi-tracker", + "odin-core", + "rmp-serde", + "serde", + "serde_bytes", + "serde_json", + "socket2", + "windows-sys 0.59.0", +] + +[[package]] +name = "muninn-move-tracker" +version = "0.1.0" + +[[package]] +name = "muninn-psmoveapi-tracker" +version = "0.1.0" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "odin-core" +version = "0.1.0" +source = "git+https://github.com/GameCult/Odin.git?rev=3a6368f93d36bf80af64779ed4a4c42fcf45cb2b#3a6368f93d36bf80af64779ed4a4c42fcf45cb2b" +dependencies = [ + "anyhow", + "cultcache-rs", + "cultmesh-rs", + "cultnet-rs", + "serde", + "serde_json", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "redb" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de6c3b63e007e90ce536ec2ae4690826136a20ec8dbbbb400daef1bb999d2e36" +dependencies = [ + "libc", +] + +[[package]] +name = "rmp" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ba8be72d372b2c9b35542551678538b562e7cf86c3315773cae48dfbfe7790c" +dependencies = [ + "num-traits", +] + +[[package]] +name = "rmp-serde" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f81bee8c8ef9b577d1681a70ebbc962c232461e397b22c208c43c04b67a155" +dependencies = [ + "rmp", + "serde", +] + +[[package]] +name = "rmpv" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a4e1d4b9b938a26d2996af33229f0ca0956c652c1375067f0b45291c1df8417" +dependencies = [ + "rmp", + "serde", + "serde_bytes", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "serde_json" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "uuid" +version = "1.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5772d71c9be8a8a6ac2117d949c5b224c1b72241bb611d9a3012edcf8af7812" +dependencies = [ + "getrandom 0.4.3", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.5", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "zerocopy" +version = "0.8.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d35102a9f36d089ccae9e4c6802bc118be4487b80aaffc0ab4e0cf5ce92d2873" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c01f5ab44258da43cf276c74a2763db2ff3969c9c652c3f2de07041d0b2bc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/crates/muninn-daemon/src/idunn_presence.rs b/crates/muninn-daemon/src/idunn_presence.rs new file mode 100644 index 0000000..f21c402 --- /dev/null +++ b/crates/muninn-daemon/src/idunn_presence.rs @@ -0,0 +1,223 @@ +//! Idunn runtime presence: what an Idunn-launched `serve` says about itself. +//! +//! When Idunn's host actuator starts `serve`, it hands over a runtime bundle +//! (the Expected incarnation and the activation Idunn issued), a one-shot +//! activation credential, and the path of this host's provider identity. +//! From those, `serve` publishes a dual-signed +//! `gamecult.runtime_presence_health.v2` record to Odin every few seconds. +//! Odin correlates it against Idunn's Expected projection and that +//! correlation is what admits the incarnation, fences the previous one, and +//! keeps this one alive. A `serve` started by an operator has no bundle and +//! publishes nothing here. +//! +//! The record shape and both signatures are CultLib's; this module only +//! carries Muninn's inputs to them. + +use std::env; +use std::fs; +use std::path::{Path, PathBuf}; + +use anyhow::{Context, Result, anyhow, ensure}; +use cultcache_rs::{DatabaseEntry, SingleFileMessagePackBackingStore}; +use cultnet_rs::{ + GAMECULT_RUNTIME_PRESENCE_HEALTH_SCHEMA, GameCultProviderHealthIdentity, + GameCultRuntimeCapability, GameCultRuntimePresenceHealthPurpose, + GameCultRuntimePresenceHealthRecord, IDUNN_EXPECTED_INCARNATION_SCHEMA, + IDUNN_RUNTIME_ACTIVATION_SCHEMA, IdunnExpectedIncarnationRecord, IdunnRuntimeActivationRecord, + IdunnRuntimeActivationSigner, ServiceIdentitySigner, open_service_identity_at, +}; + +pub const RUNTIME_BUNDLE_ENVIRONMENT: &str = "GAMECULT_IDUNN_RUNTIME_BUNDLE"; +pub const ACTIVATION_CREDENTIAL_ENVIRONMENT: &str = "GAMECULT_IDUNN_ACTIVATION_CREDENTIAL"; +pub const PROVIDER_IDENTITY_ENVIRONMENT: &str = "GAMECULT_RUNTIME_PRESENCE_IDENTITY"; + +/// Everything an Idunn-launched process needs to sign its presence. +pub struct IdunnRuntimeAuthority { + expected: IdunnExpectedIncarnationRecord, + expected_sha256: String, + activation: IdunnRuntimeActivationRecord, + activation_sha256: String, + activation_signer: IdunnRuntimeActivationSigner, + provider_signer: ServiceIdentitySigner, + publisher_sequence: u64, +} + +impl IdunnRuntimeAuthority { + /// `None` when this process was not started by Idunn. + pub fn from_environment() -> Result> { + let Some(bundle) = env::var_os(RUNTIME_BUNDLE_ENVIRONMENT) else { + return Ok(None); + }; + let bundle = PathBuf::from(bundle); + let credential = PathBuf::from( + env::var_os(ACTIVATION_CREDENTIAL_ENVIRONMENT) + .with_context(|| format!("{RUNTIME_BUNDLE_ENVIRONMENT} is set but {ACTIVATION_CREDENTIAL_ENVIRONMENT} is not"))?, + ); + let provider_identity = + PathBuf::from(env::var_os(PROVIDER_IDENTITY_ENVIRONMENT).with_context(|| { + format!( + "{RUNTIME_BUNDLE_ENVIRONMENT} is set but {PROVIDER_IDENTITY_ENVIRONMENT} is not" + ) + })?); + Self::open(&bundle, &credential, &provider_identity).map(Some) + } + + pub fn open(bundle: &Path, credential: &Path, provider_identity: &Path) -> Result { + ensure!(bundle.is_absolute(), "Idunn runtime bundle is not absolute"); + let (expected_key, expected_payload) = read_single_runtime_record( + &bundle.join("expected.cc"), + IdunnExpectedIncarnationRecord::TYPE, + IDUNN_EXPECTED_INCARNATION_SCHEMA, + )?; + let expected = IdunnExpectedIncarnationRecord::decode_canonical(&expected_payload)?; + ensure!( + expected_key == expected.target, + "Expected key is substituted" + ); + let (activation_key, activation_payload) = read_single_runtime_record( + &bundle.join("activation.cc"), + IdunnRuntimeActivationRecord::TYPE, + IDUNN_RUNTIME_ACTIVATION_SCHEMA, + )?; + let activation = IdunnRuntimeActivationRecord::decode_canonical(&activation_payload)?; + ensure!( + activation_key == expected.target, + "activation key is substituted" + ); + let expected_sha256 = expected.canonical_sha256()?; + ensure!( + activation.expected_projection_sha256 == expected_sha256 + && activation.runtime_id == expected.runtime_id, + "activation does not bind this Expected projection" + ); + let seed = fs::read(credential) + .with_context(|| format!("reading activation credential {}", credential.display()))?; + let activation_signer = + IdunnRuntimeActivationSigner::from_credential_reader(seed.as_slice())?; + // One-shot: the seed lives in this process now and nowhere else. + fs::remove_file(credential) + .with_context(|| format!("retiring activation credential {}", credential.display()))?; + ensure!( + activation_signer.identity_id() == activation.activation_signer_identity_id + && activation_signer.public_key() == activation.activation_signer_public_key, + "activation credential does not belong to this activation" + ); + let provider_signer = + open_service_identity_at::(provider_identity) + .context("opening the runtime presence identity")?; + ensure!( + provider_signer.entry().identity_id == expected.expected_signer_identity_id, + "provider identity is not the signer selected by Expected" + ); + Ok(Self { + expected_sha256, + activation_sha256: activation.canonical_sha256()?, + expected, + activation, + activation_signer, + provider_signer, + publisher_sequence: 0, + }) + } + + pub fn target(&self) -> &str { + &self.expected.target + } + + pub fn runtime_id(&self) -> &str { + &self.expected.runtime_id + } + + pub fn runtime_instance_id(&self) -> &str { + &self.activation.runtime_instance_id + } + + /// The next presence record, signed by the provider identity and the + /// activation. `warming` before the daemon can serve, `active` once it + /// can, `failed` with the reason when it cannot. + pub fn presence( + &mut self, + state: &str, + detail: &str, + observed_at_unix_millis: u64, + ) -> Result { + ensure!( + self.expected.write_lease_required == false, + "Muninn declares no process-bound state; a write lease cannot be presented" + ); + self.publisher_sequence = self + .publisher_sequence + .checked_add(1) + .ok_or_else(|| anyhow!("runtime presence publisher sequence exhausted"))?; + let expected = &self.expected; + let mut record = GameCultRuntimePresenceHealthRecord { + schema_version: GAMECULT_RUNTIME_PRESENCE_HEALTH_SCHEMA.into(), + target: expected.target.clone(), + expected_projection_sha256: self.expected_sha256.clone(), + plan_id: expected.plan_id.clone(), + incarnation_id: expected.incarnation_id.clone(), + sealed_release_id: expected.sealed_release_id.clone(), + activation_witness_sha256: self.activation_sha256.clone(), + state_schema_generation: expected.state_schema_generation.clone(), + state_contract_sha256: expected.state_contract_sha256.clone(), + runtime_id: expected.runtime_id.clone(), + runtime_instance_id: self.activation.runtime_instance_id.clone(), + bound_endpoint: expected + .route + .as_ref() + .map(|route| route.candidate_endpoint.clone()), + capabilities: expected + .capabilities + .iter() + .map(|capability| GameCultRuntimeCapability { + capability: capability.capability.clone(), + schema: capability.schema.clone(), + compatibility: capability.compatibility.clone(), + capacity: capability.minimum_capacity, + }) + .collect(), + health_contract: expected.health_contract.clone(), + state: state.into(), + detail: detail.into(), + write_lease_sha256: None, + signer_identity_id: self.provider_signer.entry().identity_id.clone(), + publisher_sequence: self.publisher_sequence, + observed_at_unix_millis, + signature_algorithm: "ed25519".into(), + signature: Vec::new(), + activation_signer_identity_id: self.activation.activation_signer_identity_id.clone(), + activation_signature: Vec::new(), + }; + let proof_payload = record.canonical_proof_payload()?; + record.signature = self + .provider_signer + .sign::(&proof_payload) + .signature; + record.activation_signature = self.activation_signer.sign_presence_proof(&record)?; + record.validate()?; + Ok(record) + } +} + +fn read_single_runtime_record( + path: &Path, + record_type: &str, + schema: &str, +) -> Result<(String, Vec)> { + let entries = SingleFileMessagePackBackingStore::new(path) + .pull_all_read_only_snapshot() + .with_context(|| format!("reading runtime record {}", path.display()))?; + let [envelope] = entries.as_slice() else { + anyhow::bail!( + "runtime record {} holds {} entries, expected one", + path.display(), + entries.len() + ); + }; + ensure!( + envelope.r#type == record_type && envelope.schema_id.as_deref() == Some(schema), + "runtime record {} is not a {record_type} under {schema}", + path.display() + ); + Ok((envelope.key.clone(), envelope.payload.clone())) +} diff --git a/crates/muninn-daemon/src/main.rs b/crates/muninn-daemon/src/main.rs index add3840..1ef8c93 100644 --- a/crates/muninn-daemon/src/main.rs +++ b/crates/muninn-daemon/src/main.rs @@ -1,9 +1,9 @@ +mod idunn_presence; mod media_packetizer; -use cultnet_rs::GameCultMediaReceiverFeedbackRecord; use crate::media_packetizer::{ - AudioPcmStreamSendConfig, AudioPcmStreamSendState, MuninnMediaSendPayload, - GameCultMediaWireRecord, VideoAnnexBStreamSendConfig, VideoAnnexBStreamSendState, + AudioPcmStreamSendConfig, AudioPcmStreamSendState, GameCultMediaWireRecord, + MuninnMediaSendPayload, VideoAnnexBStreamSendConfig, VideoAnnexBStreamSendState, decode_media_wire_record, }; use anyhow::{Context, Result, anyhow}; @@ -12,27 +12,28 @@ use cultmesh_rs::{ CultMeshSharedMemoryFrameRing, CultMeshStreamBodyTransport, CultMeshStreamCatalog, CultMeshStreamClock, CultMeshStreamDescriptor, CultMeshStreamKind, }; +use cultnet_rs::GameCultMediaReceiverFeedbackRecord; use cultnet_rs::{ - GAMECULT_MEDIA_STREAM_ADVERTISEMENT_SCHEMA, GAMECULT_MEDIA_STREAM_REQUEST_SCHEMA, + CultNetMessage, CultNetRawDocumentRecord, CultNetRawPayloadEncoding, CultNetRudpServerEvent, + CultNetRudpServerHub, CultNetRudpServerHubOptions, CultNetRudpServerSessionContext, + CultNetRudpSocketTransportConnection, CultNetRudpSocketTransportOptions, CultNetTransportFrame, + CultNetWireContract, GAMECULT_MEDIA_STREAM_ADVERTISEMENT_SCHEMA, + GAMECULT_MEDIA_STREAM_REQUEST_SCHEMA, GAMECULT_RUNTIME_PRESENCE_HEALTH_SCHEMA, GameCultMediaStreamAdvertisementRecord, GameCultMediaStreamRequestRecord, - media_stream_request_key, validate_media_stream_request, - CultNetMessage, CultNetRawDocumentRecord, CultNetRawPayloadEncoding, - CultNetRudpServerEvent, CultNetRudpServerHub, CultNetRudpServerHubOptions, - CultNetRudpServerSessionContext, CultNetRudpSocketTransportConnection, - CultNetRudpSocketTransportOptions, CultNetTransportFrame, - CultNetWireContract, decode_cultnet_message_from_slice, encode_cultnet_message_to_vec, + GameCultRuntimePresenceHealthRecord, decode_cultnet_message_from_slice, + encode_cultnet_message_to_vec, media_stream_request_key, validate_media_stream_request, }; #[cfg(feature = "psmoveapi-tracker")] use odin_core::MuninnMoveTrackerHealthRecord; use odin_core::{ - EveProviderAdvertisementRecord, EveSurfaceStateRecord, - IdunnDaemonHealthRecord, MUNINN_MOVE_HUE_PROGRAM_SCHEMA, MUNINN_OBS_STREAM_CATALOG_SCHEMA, + EveProviderAdvertisementRecord, EveSurfaceStateRecord, IdunnDaemonHealthRecord, + MUNINN_MOVE_HUE_PROGRAM_SCHEMA, MUNINN_OBS_STREAM_CATALOG_SCHEMA, MuninnCaptureStreamCommandRecord, MuninnCaptureStreamRecord, MuninnCommandBoundaryCompatRecord, - MuninnHidControllerStateRecord, - MuninnMoveControllerStateRecord, MuninnMoveEvidenceTransportHealthRecord, - MuninnMoveHueProgramRecord, MuninnMoveIdentityRecord, MuninnMoveLightCommandRecord, - MuninnMoveMarkerCandidateRecord, MuninnObsStreamCatalogRecord, MuninnQuestAccessRecord, - MuninnTelemetrySurfaceRecord, MuninnTransportProfileCompatRecord, OdinDocuments, + MuninnHidControllerStateRecord, MuninnMoveControllerStateRecord, + MuninnMoveEvidenceTransportHealthRecord, MuninnMoveHueProgramRecord, MuninnMoveIdentityRecord, + MuninnMoveLightCommandRecord, MuninnMoveMarkerCandidateRecord, MuninnObsStreamCatalogRecord, + MuninnQuestAccessRecord, MuninnTelemetrySurfaceRecord, MuninnTransportProfileCompatRecord, + OdinDocuments, }; use serde::{Deserialize, Serialize}; use serde_json::json; @@ -421,6 +422,7 @@ fn serve(options: Options) -> Result<()> { let mut active_move_states = active_move_state_sources(serve_move_state_sources(&options, move_runtime_enabled)); start_daemon_health_worker(&options); + start_idunn_presence_worker(&options); let mut active_move_marker_cameras = active_move_marker_camera_sources(&options, Arc::clone(&move_hue_program)); let mut active_capture_streams = Vec::new(); @@ -486,7 +488,11 @@ fn serve(options: Options) -> Result<()> { &suppressed_default_move_light_paths, &active_move_lights, ); - tick_move_light_commands(&mut node, &mut active_move_lights, &mut HidMoveLightWriter)?; + tick_move_light_commands( + &mut node, + &mut active_move_lights, + &mut HidMoveLightWriter, + )?; update_suppressed_default_move_light_paths( &suppressed_default_move_light_paths, &active_move_lights, @@ -562,6 +568,63 @@ fn serve(options: Options) -> Result<()> { } } +/// An Idunn-launched serve presents itself to Odin every few seconds: +/// `warming` until its own health check passes, `active` after, `failed` +/// with the reason when it stops passing. Odin's correlation of that record +/// is what Idunn admits and keeps alive. An operator-started serve has no +/// runtime bundle and this does nothing. +fn start_idunn_presence_worker(options: &Options) { + let mut authority = match idunn_presence::IdunnRuntimeAuthority::from_environment() { + Ok(Some(authority)) => authority, + Ok(None) => return, + Err(error) => { + eprintln!("Muninn was launched by Idunn but cannot present itself: {error:#}"); + return; + } + }; + eprintln!( + "Muninn presents to Idunn as {} instance {}", + authority.target(), + authority.runtime_instance_id() + ); + let options = options.clone(); + thread::spawn(move || { + let cadence = Duration::from_secs(2); + loop { + let published = (|| -> Result<()> { + let target = resolve_odin_cultmesh_uri(&options) + .context("Odin CultMesh URI does not resolve")?; + let (state, detail) = match evaluate_health(&options) { + Ok(detail) => ("active", detail), + Err(error) => ("warming", format!("{error:#}")), + }; + let observed_at = SystemTime::now() + .duration_since(UNIX_EPOCH)? + .as_millis() + .try_into()?; + let record = authority.presence(state, &detail, observed_at)?; + let node = activation_node(&options, "muninn-idunn-presence")?; + node.publish_document_to_rudp_catalog( + record.target.clone(), + &record, + CultMeshRudpDocumentPublishOptions { + target, + runtime_id: authority.runtime_id().to_string(), + source_agent_id: Some(record.signer_identity_id.clone()), + source_role: Some("runtime-presence-health-publisher".to_string()), + tags: vec!["cultnet.transport.rudp.v0".to_string()], + ..CultMeshRudpDocumentPublishOptions::default() + }, + ) + })(); + if let Err(error) = published { + eprintln!("Muninn could not publish its Idunn presence: {error:#}"); + } + thread::sleep(cadence); + } + }); +} + fn start_daemon_health_worker(options: &Options) { if options.idunn_rudp_health.is_none() { return; @@ -842,16 +905,22 @@ fn command_from_media_stream_request( request: &GameCultMediaStreamRequestRecord, ) -> Result { validate_media_stream_request(request)?; - if !request.video_source_id.is_empty() && !MUNINN_VIDEO_CODECS.contains(&request.video_codec.as_str()) { + if !request.video_source_id.is_empty() + && !MUNINN_VIDEO_CODECS.contains(&request.video_codec.as_str()) + { return Err(anyhow!( "this producer encodes video as {:?}, not {:?}", - MUNINN_VIDEO_CODECS, request.video_codec + MUNINN_VIDEO_CODECS, + request.video_codec )); } - if !request.audio_source_id.is_empty() && !MUNINN_AUDIO_CODECS.contains(&request.audio_codec.as_str()) { + if !request.audio_source_id.is_empty() + && !MUNINN_AUDIO_CODECS.contains(&request.audio_codec.as_str()) + { return Err(anyhow!( "this producer emits audio as {:?}, not {:?}", - MUNINN_AUDIO_CODECS, request.audio_codec + MUNINN_AUDIO_CODECS, + request.audio_codec )); } Ok(MuninnCaptureStreamCommandRecord { @@ -866,7 +935,11 @@ fn command_from_media_stream_request( obs_target_host: None, obs_port: 0, media_transport: "rudp".to_string(), - media_packet_bytes: if request.media_packet_bytes == 0 { options.media_packet_bytes as u32 } else { request.media_packet_bytes }, + media_packet_bytes: if request.media_packet_bytes == 0 { + options.media_packet_bytes as u32 + } else { + request.media_packet_bytes + }, requested_by: request.receiver_id.clone(), detail: format!("media stream request {}", request.request_id), // Muninn's own clock, in Muninn's own format. The command engine orders @@ -875,8 +948,16 @@ fn command_from_media_stream_request( updated_at: timestamp()?, rudp_video_bitrate_kbps: request.video_bitrate_kbps, rudp_latency_budget_ms: request.latency_budget_ms, - video_source_id: if request.video_source_id.is_empty() { MUNINN_DISABLED_VIDEO_SOURCE_ID.to_string() } else { request.video_source_id.clone() }, - audio_source_id: if request.audio_source_id.is_empty() { MUNINN_DISABLED_AUDIO_SOURCE_ID.to_string() } else { request.audio_source_id.clone() }, + video_source_id: if request.video_source_id.is_empty() { + MUNINN_DISABLED_VIDEO_SOURCE_ID.to_string() + } else { + request.video_source_id.clone() + }, + audio_source_id: if request.audio_source_id.is_empty() { + MUNINN_DISABLED_AUDIO_SOURCE_ID.to_string() + } else { + request.audio_source_id.clone() + }, }) } @@ -891,7 +972,9 @@ fn sync_media_stream_requests(options: &Options, answered: &mut HashMap node, Err(error) => { - eprintln!("Muninn could not open the activation store for media stream requests: {error:#}"); + eprintln!( + "Muninn could not open the activation store for media stream requests: {error:#}" + ); return; } }; @@ -927,19 +1010,32 @@ fn sync_media_stream_requests(options: &Options, answered: &mut HashMap command, Err(error) => { - answer_media_stream_request(options, target, &request, "failed", &format!("{error:#}"), answered); + answer_media_stream_request( + options, + target, + &request, + "failed", + &format!("{error:#}"), + answered, + ); continue; } }; if let Err(error) = node.put(&command.command_id, &command) { - eprintln!("Muninn could not record media stream request {} as a command: {error:#}", request.request_id); + eprintln!( + "Muninn could not record media stream request {} as a command: {error:#}", + request.request_id + ); } } } /// Writes each request-derived command's outcome back onto the request it /// came from, so the consumer watches one document. -fn answer_media_stream_requests(options: &Options, answered: &mut HashMap) { +fn answer_media_stream_requests( + options: &Options, + answered: &mut HashMap, +) { let Some(target) = resolve_odin_cultmesh_uri(options) else { return; }; @@ -953,7 +1049,8 @@ fn answer_media_stream_requests(options: &Options, answered: &mut HashMap(&request.request_id) else { + let Ok(Some(command)) = node.get::(&request.request_id) + else { continue; }; let state = match command.state.as_str() { @@ -975,7 +1072,9 @@ fn answer_media_stream_request( answered: &mut HashMap, ) { let already = answered.get(&request.request_id); - if already.is_some_and(|(previous_state, previous_detail)| previous_state == state && previous_detail == detail) { + if already.is_some_and(|(previous_state, previous_detail)| { + previous_state == state && previous_detail == detail + }) { return; } let Ok(updated_at) = timestamp() else { @@ -1002,16 +1101,25 @@ fn answer_media_stream_request( }, ) { Ok(()) => { - answered.insert(request.request_id.clone(), (state.to_string(), detail.to_string())); + answered.insert( + request.request_id.clone(), + (state.to_string(), detail.to_string()), + ); } - Err(error) => eprintln!("Muninn could not answer media stream request {}: {error:#}", request.request_id), + Err(error) => eprintln!( + "Muninn could not answer media stream request {}: {error:#}", + request.request_id + ), } } /// What this host offers, in the producer-agnostic shape a picker is built /// from. Published beside the Muninn-specific catalog so nothing that reads /// the old one breaks while consumers move. -fn media_stream_advertisement(options: &Options, streaming: bool) -> Result { +fn media_stream_advertisement( + options: &Options, + streaming: bool, +) -> Result { let video_sources = video_source_catalog(options); let audio_sources = audio_source_catalog(options); Ok(GameCultMediaStreamAdvertisementRecord { @@ -1019,12 +1127,30 @@ fn media_stream_advertisement(options: &Options, streaming: bool) -> Result Result<()> { /// raising the encoder in place took that to 116 and 60. #[cfg(windows)] fn raise_media_process_priority() { - use windows_sys::Win32::System::Threading::{GetCurrentProcess, HIGH_PRIORITY_CLASS, SetPriorityClass}; + use windows_sys::Win32::System::Threading::{ + GetCurrentProcess, HIGH_PRIORITY_CLASS, SetPriorityClass, + }; // SAFETY: the current process handle is always valid; SetPriorityClass // has no memory-safety preconditions. let raised = unsafe { SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS) }; @@ -2175,17 +2306,20 @@ fn run_rudp_mux_once( let mut loopback = if options.capture_audio { Some( - media_child_priority(&mut Command::new("powershell.exe"), MediaChildPriority::Audio) - .args(loopback_args(options)) - .stdout(Stdio::piped()) - .stderr(fs::File::create(&loopback_stderr)?) - .spawn() - .with_context(|| { - format!( - "starting loopback capture {}", - options.loopback_script.display() - ) - })?, + media_child_priority( + &mut Command::new("powershell.exe"), + MediaChildPriority::Audio, + ) + .args(loopback_args(options)) + .stdout(Stdio::piped()) + .stderr(fs::File::create(&loopback_stderr)?) + .spawn() + .with_context(|| { + format!( + "starting loopback capture {}", + options.loopback_script.display() + ) + })?, ) } else { None @@ -2203,13 +2337,16 @@ fn run_rudp_mux_once( let mut video_ffmpeg = if options.capture_video { Some( - media_child_priority(&mut Command::new(&options.ffmpeg_path), MediaChildPriority::Video) - .args(rudp_video_ffmpeg_args(options)) - .stdin(Stdio::null()) - .stdout(Stdio::piped()) - .stderr(fs::File::create(&video_ffmpeg_stderr)?) - .spawn() - .with_context(|| format!("starting {} video encoder", options.ffmpeg_path))?, + media_child_priority( + &mut Command::new(&options.ffmpeg_path), + MediaChildPriority::Video, + ) + .args(rudp_video_ffmpeg_args(options)) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(fs::File::create(&video_ffmpeg_stderr)?) + .spawn() + .with_context(|| format!("starting {} video encoder", options.ffmpeg_path))?, ) } else { None @@ -2226,13 +2363,16 @@ fn run_rudp_mux_once( }; let mut audio_ffmpeg = if options.capture_audio { Some( - media_child_priority(&mut Command::new(&options.ffmpeg_path), MediaChildPriority::Audio) - .args(rudp_audio_ffmpeg_args(options)) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(fs::File::create(&audio_ffmpeg_stderr)?) - .spawn() - .with_context(|| format!("starting {} audio encoder", options.ffmpeg_path))?, + media_child_priority( + &mut Command::new(&options.ffmpeg_path), + MediaChildPriority::Audio, + ) + .args(rudp_audio_ffmpeg_args(options)) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(fs::File::create(&audio_ffmpeg_stderr)?) + .spawn() + .with_context(|| format!("starting {} audio encoder", options.ffmpeg_path))?, ) } else { None @@ -2860,7 +3000,8 @@ fn send_rudp_media_payload_with_backpressure( thread::sleep(Duration::from_millis(1)); } Err(error) => { - return Err(error).context("sending typed Muninn media payload over RUDP media"); + return Err(error) + .context("sending typed Muninn media payload over RUDP media"); } } } @@ -3065,7 +3206,10 @@ fn open_media_rudp_hub( media_profile: &MuninnRudpMediaProfile, ) -> Result { let socket = UdpSocket::bind(options.media_rudp_bind).with_context(|| { - format!("binding Muninn media RUDP listener at {}", options.media_rudp_bind) + format!( + "binding Muninn media RUDP listener at {}", + options.media_rudp_bind + ) })?; configure_media_rudp_socket_buffers(&socket) .context("configuring Muninn media RUDP socket buffers")?; @@ -3081,8 +3225,6 @@ fn open_media_rudp_hub( Ok(hub) } - - fn configure_media_rudp_socket_buffers(socket: &UdpSocket) -> Result<()> { let socket = socket2::SockRef::from(socket); socket @@ -3978,7 +4120,9 @@ fn publish_obs_catalog( ) -> Result<()> { let video_sources = video_source_catalog(options); let audio_sources = audio_source_catalog(options); - let streaming = states.iter().any(|state| state == "running" || state == "streaming"); + let streaming = states + .iter() + .any(|state| state == "running" || state == "streaming"); let record = MuninnObsStreamCatalogRecord { catalog_id: "muninn.obs.streams".to_string(), host_id: options.host_id.clone(), @@ -4027,7 +4171,9 @@ fn publish_obs_catalog( }, ) { - eprintln!("Muninn could not publish its media stream advertisement to Odin: {error:#}"); + eprintln!( + "Muninn could not publish its media stream advertisement to Odin: {error:#}" + ); } } Err(error) => eprintln!("Muninn is not advertising its media stream: {error:#}"), @@ -9501,7 +9647,6 @@ fn request_capture_stream(options: Options) -> Result<()> { Ok(()) } - fn publish_capture_command_to_odin( options: &Options, command: &MuninnCaptureStreamCommandRecord, @@ -10353,6 +10498,7 @@ impl cultmesh_rs::CultMeshDocumentSet for MuninnDocuments { OdinDocuments.register_cache(cache)?; cache.register_entry_type::()?; cache.register_entry_type::()?; + cache.register_entry_type::()?; Ok(()) } @@ -10374,6 +10520,14 @@ impl cultmesh_rs::CultMeshDocumentSet for MuninnDocuments { GAMECULT_MEDIA_STREAM_REQUEST_SCHEMA.to_string(), ), ); + registry.register( + cultnet_rs::CultNetDocumentBinding::for_entry_with_schema_id::< + GameCultRuntimePresenceHealthRecord, + >( + GAMECULT_RUNTIME_PRESENCE_HEALTH_SCHEMA.to_string(), + GAMECULT_RUNTIME_PRESENCE_HEALTH_SCHEMA.to_string(), + ), + ); Ok(()) } } @@ -10520,7 +10674,8 @@ impl Options { .context("--media-rudp-bind must be a socket address")? } "--media-rudp-advertise" => { - options.media_rudp_advertise = Some(take_value(&mut args, "--media-rudp-advertise")?) + options.media_rudp_advertise = + Some(take_value(&mut args, "--media-rudp-advertise")?) } "--media-transport" => { options.media_transport = @@ -11080,14 +11235,24 @@ mod tests { assert_eq!(command.host_id, options.host_id); assert_eq!(command.action, "start"); assert_eq!(command.state, "pending"); - assert_eq!(command.obs_target_host, None, "the receiver dials Muninn, not the reverse"); + assert_eq!( + command.obs_target_host, None, + "the receiver dials Muninn, not the reverse" + ); assert_eq!(command.obs_port, 0); assert_eq!(command.rudp_video_bitrate_kbps, 8_000); assert_eq!(command.rudp_latency_budget_ms, 200); - assert_eq!(command.media_packet_bytes, options.media_packet_bytes as u32, "zero takes the producer default"); + assert_eq!( + command.media_packet_bytes, options.media_packet_bytes as u32, + "zero takes the producer default" + ); assert_eq!(command.video_source_id, "display:0"); assert_eq!(command.requested_by, "starfire.obs"); - assert!(command.updated_at.starts_with("unix-"), "stamped by Muninn's clock, not the consumer's: {}", command.updated_at); + assert!( + command.updated_at.starts_with("unix-"), + "stamped by Muninn's clock, not the consumer's: {}", + command.updated_at + ); assert!( command.updated_at.as_str() > "unix-1783295838", "a fresh request must outrank a command stored in July; the tick orders by this string" @@ -11099,11 +11264,15 @@ mod tests { let options = Options::parse(["serve"].into_iter().map(String::from)).unwrap(); let mut request = media_stream_request(); request.video_codec = "av1".into(); - let error = command_from_media_stream_request(&options, &request).unwrap_err().to_string(); + let error = command_from_media_stream_request(&options, &request) + .unwrap_err() + .to_string(); assert!(error.contains("h264") && error.contains("av1"), "{error}"); let mut request = media_stream_request(); request.audio_codec = "opus".into(); - let error = command_from_media_stream_request(&options, &request).unwrap_err().to_string(); + let error = command_from_media_stream_request(&options, &request) + .unwrap_err() + .to_string(); assert!(error.contains("pcm-f32le-interleaved"), "{error}"); } @@ -11137,25 +11306,50 @@ mod tests { fn the_advertised_media_endpoint_is_explicit_or_derived_never_guessed() { let mut options = Options::parse(["serve"].into_iter().map(String::from)).unwrap(); let error = advertised_media_endpoint(&options).unwrap_err().to_string(); - assert!(error.contains("0.0.0.0:5220") && error.contains("--media-rudp-advertise"), "{error}"); + assert!( + error.contains("0.0.0.0:5220") && error.contains("--media-rudp-advertise"), + "{error}" + ); options.command_rudp_advertise = Some("10.77.0.2:17886".into()); - assert_eq!(advertised_media_endpoint(&options).unwrap(), "10.77.0.2:5220", "the command host, on the media port"); + assert_eq!( + advertised_media_endpoint(&options).unwrap(), + "10.77.0.2:5220", + "the command host, on the media port" + ); options.media_rudp_bind = "192.168.1.84:5221".parse().unwrap(); - assert_eq!(advertised_media_endpoint(&options).unwrap(), "192.168.1.84:5221", "a real bind address is itself the endpoint"); + assert_eq!( + advertised_media_endpoint(&options).unwrap(), + "192.168.1.84:5221", + "a real bind address is itself the endpoint" + ); options.media_rudp_advertise = Some("raven.lan:5220".into()); - assert_eq!(advertised_media_endpoint(&options).unwrap(), "raven.lan:5220", "an explicit advertisement wins"); + assert_eq!( + advertised_media_endpoint(&options).unwrap(), + "raven.lan:5220", + "an explicit advertisement wins" + ); } #[test] fn the_activation_child_is_told_where_to_listen() { - let options = Options::parse(["serve", "--media-rudp-bind", "0.0.0.0:6001"].into_iter().map(String::from)).unwrap(); + let options = Options::parse( + ["serve", "--media-rudp-bind", "0.0.0.0:6001"] + .into_iter() + .map(String::from), + ) + .unwrap(); assert_eq!(options.media_rudp_bind.to_string(), "0.0.0.0:6001"); for removed in ["--obs-target-host", "--obs-port"] { - let error = Options::parse(["serve", removed, "x"].into_iter().map(String::from)).unwrap_err().to_string(); - assert!(error.contains("removed") && error.contains("--media-rudp-bind"), "{error}"); + let error = Options::parse(["serve", removed, "x"].into_iter().map(String::from)) + .unwrap_err() + .to_string(); + assert!( + error.contains("removed") && error.contains("--media-rudp-bind"), + "{error}" + ); } } use serde::Deserialize; @@ -11832,14 +12026,19 @@ mod tests { #[test] fn a_handled_newer_command_still_outranks_an_older_pending_one() { let options = Options::parse(["serve"].into_iter().map(String::from)).unwrap(); - let mut live = command_from_media_stream_request(&options, &media_stream_request()).unwrap(); + let mut live = + command_from_media_stream_request(&options, &media_stream_request()).unwrap(); live.updated_at = "unix-1789080649".to_string(); let mut handled = live.clone(); handled.command_id = "handled-later".to_string(); handled.state = "completed".to_string(); handled.updated_at = "unix-1789080650".to_string(); - let latest = latest_capture_stream_command_ids(&[live.clone(), handled.clone()], &options.host_id); - assert_eq!(latest.get("muninn.raven.av").map(String::as_str), Some("handled-later")); + let latest = + latest_capture_stream_command_ids(&[live.clone(), handled.clone()], &options.host_id); + assert_eq!( + latest.get("muninn.raven.av").map(String::as_str), + Some("handled-later") + ); } #[test] @@ -12239,9 +12438,21 @@ mod tests { ); let hub = CultNetRudpServerHub::new(options).unwrap(); let channels = hub.profile.transports.first().unwrap().channels.clone(); - let channel = |id: &str| channels.iter().find(|channel| channel.channel_id == id).unwrap().clone(); - assert_eq!(channel("media").delivery, cultnet_rs::CultNetTransportDelivery::Unreliable); - assert_eq!(channel("audio").delivery, cultnet_rs::CultNetTransportDelivery::Reliable); + let channel = |id: &str| { + channels + .iter() + .find(|channel| channel.channel_id == id) + .unwrap() + .clone() + }; + assert_eq!( + channel("media").delivery, + cultnet_rs::CultNetTransportDelivery::Unreliable + ); + assert_eq!( + channel("audio").delivery, + cultnet_rs::CultNetTransportDelivery::Reliable + ); assert_eq!( channel("audio").reliable_expire_after_ms, Some(profile.receiver_assembly_deadline_ms), @@ -12453,21 +12664,19 @@ mod tests { #[test] fn rudp_media_receiver_feedback_updates_sender_pressure_stats() { - let feedback = cultnet_rs::build_receiver_feedback( - cultnet_rs::ReceiverFeedbackOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "raven:session:video", - receiver_id: "starfire.obs", - highest_decodable_frame_id: Some(41), - missing_frame_ids: Vec::new(), - missing_video_chunk_keys: vec!["42:1".to_string(), "42:3".to_string()], - late_frame_ids: vec![42, 43], - requested_keyframe: true, - jitter_us: 500, - decode_queue_us: 2_000, - observed_at: "unix:1000", - }, - ) + let feedback = cultnet_rs::build_receiver_feedback(cultnet_rs::ReceiverFeedbackOptions { + stream_id: "muninn.raven.av.rudp", + session_id: "raven:session:video", + receiver_id: "starfire.obs", + highest_decodable_frame_id: Some(41), + missing_frame_ids: Vec::new(), + missing_video_chunk_keys: vec!["42:1".to_string(), "42:3".to_string()], + late_frame_ids: vec![42, 43], + requested_keyframe: true, + jitter_us: 500, + decode_queue_us: 2_000, + observed_at: "unix:1000", + }) .unwrap(); let payload = crate::media_packetizer::encode_media_wire_record( &crate::media_packetizer::GameCultMediaWireRecord::Feedback(feedback), @@ -12529,21 +12738,19 @@ mod tests { ) .unwrap(), }; - let feedback = cultnet_rs::build_receiver_feedback( - cultnet_rs::ReceiverFeedbackOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "raven:session:video", - receiver_id: "starfire.obs", - highest_decodable_frame_id: Some(41), - missing_frame_ids: Vec::new(), - missing_video_chunk_keys: vec!["42:3".to_string(), "42:4".to_string()], - late_frame_ids: vec![42], - requested_keyframe: true, - jitter_us: 500, - decode_queue_us: 2_000, - observed_at: "unix:1000", - }, - ) + let feedback = cultnet_rs::build_receiver_feedback(cultnet_rs::ReceiverFeedbackOptions { + stream_id: "muninn.raven.av.rudp", + session_id: "raven:session:video", + receiver_id: "starfire.obs", + highest_decodable_frame_id: Some(41), + missing_frame_ids: Vec::new(), + missing_video_chunk_keys: vec!["42:3".to_string(), "42:4".to_string()], + late_frame_ids: vec![42], + requested_keyframe: true, + jitter_us: 500, + decode_queue_us: 2_000, + observed_at: "unix:1000", + }) .unwrap(); let mut cache = RecentVideoChunkRepairCache::new(16); diff --git a/deployment/idunn/raven-muninn.toml b/deployment/idunn/raven-muninn.toml new file mode 100644 index 0000000..28c903e --- /dev/null +++ b/deployment/idunn/raven-muninn.toml @@ -0,0 +1,96 @@ +schema = "gamecult.idunn.target_declaration.v1" +target = "raven-muninn" +source_stamp_environment = "MUNINN_BUILD_COMMIT" +required_gitlinks = [] + +# Built on Raven itself by Idunn's host actuator: cargo on the host, no +# container. The runner's allowed programs are the whole build vocabulary. +[[steps]] +id = "build-muninn-daemon" +phase = "build" +runner = "rust-host" +required_environment = [] +argv = [ + "cargo", + "build", + "--locked", + "--release", + "-p", + "muninn-daemon", + "--bin", + "muninn", +] + +[[artifacts]] +id = "muninn" +source_kind = "runner-output" +runner = "rust-host" +source = "target/release/muninn.exe" +destination = "muninn.exe" +executable = true + +[[artifacts]] +id = "wasapi-loopback-capture" +source_kind = "worktree-tree" +source = "scripts/wasapi-loopback-capture.ps1" +destination = "wasapi-loopback-capture.ps1" + +# The launch contract. Host-specific values come from the operator binding's +# argument bindings; everything Raven-independent is literal. The loopback +# script is named relative to the installed release, which is the working +# directory the actuator starts serve in. +[service] +executable_artifact = "muninn" +arguments = [ + { kind = "literal", value = "serve" }, + { kind = "literal", value = "--store" }, + { kind = "binding", name = "store_path" }, + { kind = "literal", value = "--activate-store" }, + { kind = "binding", name = "activate_store_path" }, + { kind = "literal", value = "--log-root" }, + { kind = "binding", name = "log_root" }, + { kind = "literal", value = "--host" }, + { kind = "literal", value = "raven" }, + { kind = "literal", value = "--stream" }, + { kind = "literal", value = "muninn.raven.av.rudp" }, + { kind = "literal", value = "--target-host" }, + { kind = "binding", name = "media_target_uri" }, + { kind = "literal", value = "--media-transport" }, + { kind = "literal", value = "rudp" }, + { kind = "literal", value = "--odin-cultmesh-uri" }, + { kind = "literal", value = "cultmesh://odin/rendezvous/provider-catalog" }, + { kind = "literal", value = "--hid-controller-rudp-bind" }, + { kind = "literal", value = "0.0.0.0:17887" }, + { kind = "literal", value = "--hid-controller-rudp-advertise" }, + { kind = "binding", name = "hid_controller_rudp_advertise" }, + { kind = "literal", value = "--media-rudp-bind" }, + { kind = "literal", value = "0.0.0.0:5220" }, + { kind = "literal", value = "--media-rudp-advertise" }, + { kind = "binding", name = "media_rudp_advertise" }, + { kind = "literal", value = "--move-state" }, + { kind = "literal", value = "xbox-raven=xinput://0" }, + { kind = "literal", value = "--audio-device" }, + { kind = "literal", value = "Realtek" }, + { kind = "literal", value = "--ffmpeg" }, + { kind = "binding", name = "ffmpeg_path" }, + { kind = "literal", value = "--loopback-script" }, + { kind = "literal", value = "wasapi-loopback-capture.ps1" }, + { kind = "literal", value = "--interval-seconds" }, + { kind = "literal", value = "15" }, +] +transport = "rudp" +route_required = false +required_environment = [ + "CULTMESH_URI_ODIN_RUDP", + "GAMECULT_IDUNN_ACTIVATION_CREDENTIAL", + "GAMECULT_IDUNN_RUNTIME_BUNDLE", + "GAMECULT_RUNTIME_PRESENCE_IDENTITY", +] + +[service.health] +contract = "muninn.runtime-health.v1" + +[[provides]] +capability = "muninn.media-producer" +schema = "gamecult.media_stream_advertisement.v1" +compatibility = "v1"