From 34961d260ceaaf77c20936e622d0fef93f0f4d12 Mon Sep 17 00:00:00 2001 From: Pavel Isaev Date: Sat, 7 Nov 2026 16:43:05 +0300 Subject: [PATCH] Begin archipelagod with read-only bus service and durable admission foundation --- Cargo.lock | 1519 ++++++++++++++++- Cargo.toml | 5 + README.md | 10 + SERVICE.md | 78 + integrations/dbus/50-archipelago-system.rules | 12 + integrations/dbus/archipelagod.service | 23 + .../dbus/org.archipelago.System1.conf | 9 + .../dbus/org.archipelago.System1.service | 5 + .../dbus/org.archipelago.system.policy | 50 + integrations/discover/CMakeLists.txt | 6 +- src/lib.rs | 3 +- src/service/authorization.rs | 62 + src/service/journal.rs | 238 +++ src/service/mod.rs | 149 ++ src/service/observation.rs | 144 ++ src/updates.rs | 36 +- 16 files changed, 2339 insertions(+), 10 deletions(-) create mode 100644 SERVICE.md create mode 100644 integrations/dbus/50-archipelago-system.rules create mode 100644 integrations/dbus/archipelagod.service create mode 100644 integrations/dbus/org.archipelago.System1.conf create mode 100644 integrations/dbus/org.archipelago.System1.service create mode 100644 integrations/dbus/org.archipelago.system.policy create mode 100644 src/service/authorization.rs create mode 100644 src/service/journal.rs create mode 100644 src/service/mod.rs create mode 100644 src/service/observation.rs diff --git a/Cargo.lock b/Cargo.lock index 8a94a3d..3135a8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,11 +2,615 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "serde", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "archipelago-contracts" +version = "0.0.0" +dependencies = [ + "jsonschema", + "regex", + "serde", + "serde_json", + "yaml-rust2", +] + [[package]] name = "archipelago-system" version = "0.0.0" dependencies = [ + "archipelago-contracts", + "serde", "serde_json", + "zbus", + "zbus_macros", +] + +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix", + "slab", + "windows-sys", +] + +[[package]] +name = "async-lock" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "rustix", +] + +[[package]] +name = "async-recursion" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "async-signal" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix", + "signal-hook-registry", + "slab", + "windows-sys", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[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 = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "blocking" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "borrow-or-share" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0b364ead1874514c8c2855ab558056ebfeb775653e7ae45ff72f28f8f3166c" + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytecount" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e" + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" +dependencies = [ + "serde", +] + +[[package]] +name = "endi" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" + +[[package]] +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fancy-regex" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f" +dependencies = [ + "bit-set", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "fluent-uri" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1918b65d96df47d3591bed19c5cca17e3fa5d0707318e4b5ef2eae01764df7e5" +dependencies = [ + "borrow-or-share", + "ref-cast", + "serde", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "fraction" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076045bb43dac435333ed5f04caf35c7463631d0dae2deb2638d94dd0a5b872" +dependencies = [ + "lazy_static", + "num", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[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 = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.5", +] + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", ] [[package]] @@ -15,12 +619,288 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "jsonschema" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d46662859bc5f60a145b75f4632fbadc84e829e45df6c5de74cfc8e05acb96b5" +dependencies = [ + "ahash", + "base64", + "bytecount", + "email_address", + "fancy-regex", + "fraction", + "idna", + "itoa", + "num-cmp", + "num-traits", + "once_cell", + "percent-encoding", + "referencing", + "regex", + "regex-syntax", + "serde", + "serde_json", + "uuid-simd", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + [[package]] name = "memchr" version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "nix" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" +dependencies = [ + "bitflags", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", +] + +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-cmp" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa" + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "outref" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "piper" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix", + "windows-sys", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.107" @@ -39,6 +919,109 @@ 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 = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "referencing" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9c261f7ce75418b3beadfb3f0eb1299fe8eb9640deba45ffa2cb783098697d" +dependencies = [ + "ahash", + "fluent-uri", + "once_cell", + "parking_lot", + "percent-encoding", + "serde_json", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "serde" version = "1.0.229" @@ -46,6 +1029,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", + "serde_derive", ] [[package]] @@ -65,7 +1049,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -81,6 +1065,56 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[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.9" @@ -92,14 +1126,497 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow 1.0.5", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow 1.0.5", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "uds_windows" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset", + "tempfile", + "windows-sys", +] + [[package]] name = "unicode-ident" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "uuid" +version = "1.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" +dependencies = [ + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "uuid-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b082222b4f6619906941c17eb2297fff4c2fb96cb60164170522942a200bd8" +dependencies = [ + "outref", + "uuid", + "vsimd", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + +[[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.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[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 = "winnow" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yaml-rust2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2462ea039c445496d8793d052e13787f2b90e750b833afee748e601c17621ed9" +dependencies = [ + "arraydeque", + "hashlink", +] + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b622b18155f7a93d1cd2dc8c01d2d6a44e08fb9ebb7b3f9e6ed101488bad6c91" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-lite", + "hex", + "nix", + "ordered-stream", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "uuid", + "windows-sys", + "winnow 0.7.15", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "5.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cdb94821ca8a87ca9c298b5d1cbd80e2a8b67115d99f6e4551ac49e42b6a314" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", + "zbus_names", + "zvariant", + "zvariant_utils 3.5.0", +] + +[[package]] +name = "zbus_names" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd" +dependencies = [ + "serde", + "winnow 1.0.5", + "zvariant", +] + +[[package]] +name = "zcheapstr" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939f186d9ecebe044315a5cb6d6f78568bbc21152adc954d5a0c2f58bdbc9920" +dependencies = [ + "serde", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "zmij" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zvariant" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow 1.0.5", + "zcheapstr", + "zvariant_derive", + "zvariant_utils 4.2.0", +] + +[[package]] +name = "zvariant_derive" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.9", + "zvariant_utils 4.2.0", +] + +[[package]] +name = "zvariant_utils" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90cb9383f9b45290407a1258b202d3f8f01db719eb60b4e4055c6375af4fc7c7" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 2.0.119", + "winnow 1.0.5", +] + +[[package]] +name = "zvariant_utils" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 3.0.9", + "winnow 1.0.5", +] diff --git a/Cargo.toml b/Cargo.toml index 4732f29..0f8826e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,8 @@ publish = false [dependencies] serde_json = "1.0" +serde = { version = "1", features = ["derive"] } +archipelago-contracts = { path = "../contracts" } +zbus = { version = "=5.12.0", default-features = false, features = ["async-io", "blocking-api"] } +# Macro releases use private zbus dispatch APIs; pin the matching family too. +zbus_macros = "=5.12.0" diff --git a/README.md b/README.md index 6c58f74..00cfc9a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # Archipelago system +## Системная служба (D-092/D-093) + +Начат read-only срез `archipelagod`, общий wire-контракт, авторизация и durable +journal foundation. Текущая граница реализации/проверки описана в +[`SERVICE.md`](SERVICE.md); mutation engine и клиенты ещё не мигрированы. +Актуальные компиляции/VM выполняются на yabloko; terra публикует артефакты. +Матрица новых проверок включается в штатный release pipeline. + +## Исторический onboarding-прототип + Экспериментальная чистая модель первого запуска по D-036/D-064. Дизайн: `../installer/CONTROL-LAYER.md`. diff --git a/SERVICE.md b/SERVICE.md new file mode 100644 index 0000000..021d9ab --- /dev/null +++ b/SERVICE.md @@ -0,0 +1,78 @@ +# archipelagod implementation checkpoint + +2026-11-07. D-092/D-093 are accepted; the full service migration is in progress. + +## Implemented source slice + +- Thin `cli/src/bin/archipelagod.rs` entrypoint uses the existing system crate. +- System-bus Manager, Properties, Introspectable and ObjectManager. Only + GetCapabilities/GetStatus are advertised. Other Manager calls explicitly return + `org.archipelago.System1.Error.Unsupported`, without spawning a CLI or admitting + work. Extension/overlay/broker features are absent. +- Local OSTree observation on a worker outside the D-Bus executor. It takes the + existing `/run/archipelago-compose.lock` nonblocking, reads with a 10-second + command deadline, retains cached state with `reconciling=true` on failure and + emits StatusRevision after durable publication. Deployment IDs include serial; + unknown base/Purpose/snapshot/support fields are omitted. No mirror request. +- Private `/var/lib/archipelago/service/observation.json` contains versioned local + observations, not update intent or a second operation authority. Revisions + survive restart; unsupported schema stops startup without resetting it. +- Admission journal foundation: private bounded records, lifetime ownership lock, + UID/method/request-ID/canonical-input binding, reconnect deduplication, explicit + transitions, file+directory fsync, immutable terminal records and fail-closed + unknown schemas/durability errors. Surviving active work blocks new admission + until engine reconciliation. No auto-replay, guessed success or automatic GC. +- Async Polkit helper derives UID/unique sender from the bus, requires both + interactive flags and uses a service-selected action. PackageKit's current + owner is rejected from direct authorization: broker verification is still needed. + Cancellation-own checks compare authenticated UID to the retained initiator in + the service, not a caller option or an undocumented Polkit subject field. +- Unit, activation, bus policy, separate Polkit actions/rules are provided under + `integrations/dbus/`. They are **not installed by the image builder yet**. +- `updates::prepare` returns its result instead of formatting it internally; + current CLI wrappers preserve output. Exact-target callers cannot silently + follow a moved track. This legacy engine adapter is not yet admitted by D-Bus. +- Explicit development CLI: `archipelago service capabilities|status`. Ordinary + installed-host commands retain their existing path until coordinated migration. + +## Dependency and compilation + +Use pure-Rust zbus **5.12.0**, async-io executor and blocking client wrapper; no +new libdbus/GIO link dependency in the core Rust binary. Existing engine work is +blocking and stays outside the bus executor. Pin `zbus_macros=5.12.0` as well: +the initial resolver selected macros 5.19 against zbus 5.12, producing a private +DispatchResult2 API mismatch. Matching versions compile on the existing Rust 1.90 +tools image. CLI/system lockfiles retain exact checksums for transitive crates. + +Build preparation uses yabloko `/opt/archipelago/dbus-next/`, separate from frozen +release sources and the regular target directory. Rust release compilation and +compilation of the contract/system test executables have been checked there. +Tests are wired into the regular release-cycle compile stage; no separate VM or +standalone test run has been executed for this slice. Native proxy compilation, +activation, real bus calls and Polkit session behavior still need pipeline evidence. + +## Next integration boundary + +Do not install this read-only slice as a completed installed-host replacement. +Still required: typed execution/progress/results; one migrated legacy plan/operation +authority; durable terminal results and recovery against OSTree/boot state; bounded +worker admission and cache; fast refresh; exact plan Download/Stage; safe Cancel; +owned workers; full CLI routing and native GUI migration; measured limits; real +Host Extension/overlay/broker implementation and acceptance. Local-package trust +and future host method schemas remain governed by their RFC contracts. + +The service observer's output does not claim that a legacy update job is a durable +service transaction. The new journal is not connected to the mutation engine yet +and must not be used as an independent second writer. Keep old records/inputs for +migration. Feature policy and package plans must derive their required actions on +the service side; an eventual Stage handler must never select `stage-update` solely +because of its method name. Read-only compilation is not rollout or VM acceptance. + +Future packaging destinations: binary `/usr/bin/archipelagod`, unit +`/usr/lib/systemd/system/archipelagod.service`, bus activation +`/usr/share/dbus-1/system-services/`, bus policy `/usr/share/dbus-1/system.d/`, +Polkit action XML `/usr/share/polkit-1/actions/`, rules +`/usr/share/polkit-1/rules.d/`. Keep `KillMode=control-group`; sandbox changes require +real compose/mount acceptance. No service enablement or timer change is needed for +bus activation. Both native clients must transition together before old helpers +and their broad action are removed. diff --git a/integrations/dbus/50-archipelago-system.rules b/integrations/dbus/50-archipelago-system.rules new file mode 100644 index 0000000..286d09c --- /dev/null +++ b/integrations/dbus/50-archipelago-system.rules @@ -0,0 +1,12 @@ +polkit.addRule(function(action, subject) { + var actions = ["refresh", "download", "stage-update", "cancel", "read-logs", + "extension-enable", "extension-change", "extension-local", "extension-override", + "extension-restore", "overlay-change"]; + var prefix = "org.archipelago.system."; + if (action.id.indexOf(prefix) !== 0 || actions.indexOf(action.id.slice(prefix.length)) < 0) return; + if (subject.user === "root") return polkit.Result.YES; + if (!subject.local || !subject.active) return; + if ((action.id === prefix + "stage-update" || action.id === prefix + "read-logs") && subject.isInGroup("wheel")) return polkit.Result.YES; + if (action.id === prefix + "cancel" && action.lookup("cancel_own") === "true") return polkit.Result.YES; + // Host Extension / overlay actions retain admin authentication, including wheel. +}); diff --git a/integrations/dbus/archipelagod.service b/integrations/dbus/archipelagod.service new file mode 100644 index 0000000..06f37c6 --- /dev/null +++ b/integrations/dbus/archipelagod.service @@ -0,0 +1,23 @@ +[Unit] +Description=Archipelago installed-system service +Documentation=https://mirror.nw-sys.ru/archipelago/docs/#RFC-0012 +After=dbus.service +ConditionPathExists=/run/ostree-booted + +[Service] +Type=dbus +BusName=org.archipelago.System1 +ExecStart=/usr/bin/archipelagod +User=root +Group=root +StateDirectory=archipelago +UMask=0077 +KillMode=control-group +TimeoutStopSec=30s +Restart=on-failure +RestartSec=5s +# Do not impose filesystem/mount restrictions until the staging worker is integrated. +# No idle exit while work is accepted. No per-operation timeout on the bus unit. + +[Install] +Alias=archipelago-daemon.service diff --git a/integrations/dbus/org.archipelago.System1.conf b/integrations/dbus/org.archipelago.System1.conf new file mode 100644 index 0000000..7f9d55e --- /dev/null +++ b/integrations/dbus/org.archipelago.System1.conf @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/integrations/dbus/org.archipelago.System1.service b/integrations/dbus/org.archipelago.System1.service new file mode 100644 index 0000000..4f3d1d6 --- /dev/null +++ b/integrations/dbus/org.archipelago.System1.service @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=org.archipelago.System1 +Exec=/usr/bin/archipelagod +User=root +SystemdService=archipelagod.service diff --git a/integrations/dbus/org.archipelago.system.policy b/integrations/dbus/org.archipelago.system.policy new file mode 100644 index 0000000..91c14d4 --- /dev/null +++ b/integrations/dbus/org.archipelago.system.policy @@ -0,0 +1,50 @@ + + + + Archipelago + https://mirror.nw-sys.ru/archipelago/ + + Refresh Archipelago metadataAuthorization is required to refresh system metadata + nonoyes + + + Download a verified Archipelago updateAuthorization is required to download system inputs + nonoyes + + + Stage a trusted current-track OS updateAuthorization is required to stage the OS update + auth_adminauth_adminauth_admin_keep + + + Cancel an Archipelago operationAuthorization is required to cancel this operation + auth_adminauth_adminauth_admin_keep + + + Read protected Archipelago operation logsAuthorization is required to read operation logs + auth_adminauth_adminauth_admin_keep + + + Configure Host ExtensionsAuthorization is required to enable or disable Host Extensions + auth_adminauth_adminauth_admin_keep + + + Change repository Host ExtensionsAuthorization is required to change native package requests + auth_adminauth_adminauth_admin_keep + + + Import or apply local package inputsAuthorization is required to use local package inputs + auth_adminauth_adminauth_admin_keep + + + Replace managed packagesAuthorization is required to change package overrides + auth_adminauth_adminauth_admin_keep + + + Restore a Host Extension generationAuthorization is required to restore package requests + auth_adminauth_adminauth_admin_keep + + + Change Managed OverlaysAuthorization is required to change the ordered overlay selection + auth_adminauth_adminauth_admin_keep + + diff --git a/integrations/discover/CMakeLists.txt b/integrations/discover/CMakeLists.txt index 7cf1e6c..403effb 100644 --- a/integrations/discover/CMakeLists.txt +++ b/integrations/discover/CMakeLists.txt @@ -1,6 +1,8 @@ # Included inside the matching, checksum-pinned Discover source tree. -kcoreaddons_add_plugin(archipelago-backend SOURCES ArchipelagoBackend.cpp INSTALL_NAMESPACE "discover") -target_link_libraries(archipelago-backend Qt::Core KF6::CoreAddons Discover::Common) +find_package(Qt6 REQUIRED COMPONENTS DBus) +qt_add_dbus_interfaces(archipelago_bus_sources org.archipelago.System1.xml) +kcoreaddons_add_plugin(archipelago-backend SOURCES ArchipelagoBackend.cpp ${archipelago_bus_sources} INSTALL_NAMESPACE "discover") +target_link_libraries(archipelago-backend Qt::Core Qt::DBus KF6::CoreAddons Discover::Common) set_target_properties(archipelago-backend PROPERTIES INSTALL_RPATH "/usr/lib/plasma-discover" BUILD_WITH_INSTALL_RPATH TRUE) diff --git a/src/lib.rs b/src/lib.rs index 8d32490..b161d41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -//! Installed-host lifecycle prototypes. No host mutations are implemented yet. +//! Installed-host lifecycle engine and service integration. pub mod onboarding; pub mod extensions; pub mod desktop; @@ -6,6 +6,7 @@ pub mod updates; pub mod package_diff; pub mod software; mod progress; +pub mod service; pub const HOST: &str = include_str!("../adapters/host.sh"); pub const FIRSTBOOT: &str = include_str!("../adapters/firstboot.sh"); diff --git a/src/service/authorization.rs b/src/service/authorization.rs new file mode 100644 index 0000000..5cb7186 --- /dev/null +++ b/src/service/authorization.rs @@ -0,0 +1,62 @@ +//! Polkit boundary for future admitted operations. No client selects action IDs. +//! The original sender comes from the authenticated message header, never a map. +use super::{BusError, text}; +use archipelago_contracts::system_bus::{Caller, Options}; +use std::collections::HashMap; +use zbus::{Connection, message::{Header, Flags}}; + +#[derive(Clone, Copy, Debug)] +pub enum Action { + Refresh, Download, StageUpdate, Cancel, ReadLogs, ExtensionEnable, + ExtensionChange, ExtensionLocal, ExtensionOverride, ExtensionRestore, OverlayChange, +} +impl Action { + fn id(self) -> &'static str { + match self { + Self::Refresh => "org.archipelago.system.refresh", + Self::Download => "org.archipelago.system.download", + Self::StageUpdate => "org.archipelago.system.stage-update", + Self::Cancel => "org.archipelago.system.cancel", + Self::ReadLogs => "org.archipelago.system.read-logs", + Self::ExtensionEnable => "org.archipelago.system.extension-enable", + Self::ExtensionChange => "org.archipelago.system.extension-change", + Self::ExtensionLocal => "org.archipelago.system.extension-local", + Self::ExtensionOverride => "org.archipelago.system.extension-override", + Self::ExtensionRestore => "org.archipelago.system.extension-restore", + Self::OverlayChange => "org.archipelago.system.overlay-change", + } + } +} + +/// `initiator_uid` is from the retained operation, only for Cancel. All other +/// details are service-controlled. Broker delegation needs its separate verifier; +/// this direct-client helper must not be used to authorize PackageKit as root. +pub async fn authorize(connection: &Connection, header: &Header<'_>, options: &Options, + action: Action, initiator_uid: Option) -> Result { + let sender = header.sender().ok_or_else(|| BusError::NotAuthorized("Authenticated sender required".into()))?; + let bus = zbus::fdo::DBusProxy::new(connection).await + .map_err(|_| BusError::Unavailable("Cannot contact system bus authority".into()))?; + let uid = bus.get_connection_unix_user(sender.clone().into()).await + .map_err(|_| BusError::NotAuthorized("Sender is no longer connected".into()))?; + if let Ok(owner) = bus.get_name_owner(zbus::names::BusName::try_from("org.freedesktop.PackageKit").expect("constant bus name")).await { + if owner.as_str() == sender.as_str() { + return Err(BusError::NotAuthorized("PackageKit must use the verified original-caller broker".into())); + } + } + let subject = ("system-bus-name", HashMap::from([("name", text(sender.as_str()))])); + let mut details: HashMap<&str, String> = HashMap::new(); + if let Action::Cancel = action { + let initiator = initiator_uid.ok_or_else(|| BusError::InvalidArgument("Cancellation requires retained initiator".into()))?; + details.insert("cancel_own", (uid == initiator).to_string()); + } else if initiator_uid.is_some() { return Err(BusError::InvalidArgument("Unexpected initiator detail".into())); } + let flags = if options.may_prompt(header.primary().flags().contains(Flags::AllowInteractiveAuth)) { 1_u32 } else { 0 }; + let proxy = zbus::Proxy::new(connection, "org.freedesktop.PolicyKit1", "/org/freedesktop/PolicyKit1/Authority", + "org.freedesktop.PolicyKit1.Authority").await + .map_err(|_| BusError::Unavailable("Authorization service unavailable".into()))?; + let (authorized, challenge, _details): (bool, bool, HashMap) = proxy + .call("CheckAuthorization", &(subject, action.id(), details, flags, "")).await + .map_err(|_| BusError::Unavailable("Authorization check failed".into()))?; + if authorized { Ok(Caller { uid, unique_sender: sender.to_string() }) } + else if challenge { Err(BusError::AuthenticationRequired("Administrator authorization required; use an explicit interactive request and an authorization agent".into())) } + else { Err(BusError::NotAuthorized("Operation is not authorized for this session".into())) } +} diff --git a/src/service/journal.rs b/src/service/journal.rs new file mode 100644 index 0000000..ecce87c --- /dev/null +++ b/src/service/journal.rs @@ -0,0 +1,238 @@ +//! Private durable admission journal. One owner, fsynced records, no replay of work. +//! This is not an OSTree authority: critical effects require engine reconciliation. +use archipelago_contracts::system_bus::{self as protocol, Caller, Method, Options, Phase, State}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::{collections::BTreeMap, fs::{self, File, OpenOptions}, io::{Read, Write}, + os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt}, path::{Path, PathBuf}, + time::{SystemTime, UNIX_EPOCH}}; + +const MAX_RECORD_BYTES: u64 = 256 * 1024; +const MAX_RECORDS: usize = 4096; + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +#[serde(deny_unknown_fields)] +pub struct Binding { + pub uid: u32, + pub method: Method, + pub request_id: Option, + pub inputs: Value, + pub offline: bool, + pub force: bool, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Record { + pub version: u32, + pub id: String, + pub binding: Binding, + pub original_sender: String, + pub state: State, + pub phase: Phase, + pub revision: u64, + pub created_at_usec: u64, + pub updated_at_usec: u64, + pub retained_until_usec: u64, + pub effects: Value, +} + +pub struct Journal { + directory: PathBuf, + _owner: File, + records: BTreeMap, + poisoned: bool, +} + +#[derive(Debug)] +pub enum Admission { Accepted(Record), Existing(Record) } + +fn now() -> Result { + SystemTime::now().duration_since(UNIX_EPOCH).map_err(|e| e.to_string())? + .as_micros().try_into().map_err(|_| "timestamp overflow".into()) +} + +fn random_id() -> Result { + let mut bytes = [0_u8; 16]; + File::open("/dev/urandom").and_then(|mut f| f.read_exact(&mut bytes)).map_err(|e| e.to_string())?; + Ok(bytes.iter().map(|b| format!("{b:02x}")).collect()) +} + +fn private(path: &Path, directory: bool) -> Result<(), String> { + let m = fs::symlink_metadata(path).map_err(|e| e.to_string())?; + if m.file_type().is_symlink() || m.is_dir() != directory || (!directory && !m.is_file()) || m.mode() & 0o077 != 0 { + return Err("journal entry must be a private regular file/directory".into()); + } + // Same owner as the service process; production entrypoint requires root. + let uid = fs::metadata("/proc/self").map_err(|e| e.to_string())?.uid(); + if m.uid() != uid { return Err("journal ownership mismatch".into()); } + Ok(()) +} + +impl Journal { + /// Parent must be a service-owned directory. No client selects this path. + /// Unknown versions/corruption stop admission; never reset or remove history. + pub fn open(directory: &Path) -> Result { + if !directory.exists() { + fs::DirBuilder::new().mode(0o700).create(directory).map_err(|e| e.to_string())?; + File::open(directory.parent().ok_or("journal parent missing")?).and_then(|f| f.sync_all()).map_err(|e| e.to_string())?; + } + private(directory, true)?; + let lock_path = directory.join("owner.lock"); + if lock_path.exists() { private(&lock_path, false)?; } + let owner = OpenOptions::new().write(true).create(true).truncate(false).mode(0o600) + .open(&lock_path).map_err(|e| e.to_string())?; + owner.try_lock().map_err(|_| "journal already owned")?; + let mut records = BTreeMap::new(); + for entry in fs::read_dir(directory).map_err(|e| e.to_string())? { + let path = entry.map_err(|e| e.to_string())?.path(); + let name = path.file_name().and_then(|n| n.to_str()).ok_or("invalid journal filename")?; + if name == "owner.lock" || (name.starts_with("partial-") && protocol::operation_id(&name[8..])) { continue; } + let id = name.strip_suffix(".json").filter(|s| protocol::operation_id(s)).ok_or("unrecognized journal entry; retained")?; + if records.len() >= MAX_RECORDS { return Err("journal capacity exceeded; explicit maintenance required".into()); } + private(&path, false)?; + let mut file = File::open(&path).map_err(|e| e.to_string())?; + if file.metadata().map_err(|e| e.to_string())?.len() > MAX_RECORD_BYTES { return Err("journal record too large".into()); } + let mut bytes = Vec::new(); + Read::by_ref(&mut file).take(MAX_RECORD_BYTES + 1).read_to_end(&mut bytes).map_err(|e| e.to_string())?; + if bytes.len() as u64 > MAX_RECORD_BYTES { return Err("journal record too large".into()); } + let value: Value = serde_json::from_slice(&bytes).map_err(|e| format!("invalid journal JSON: {e}"))?; + if value["version"].as_u64() != Some(protocol::JOURNAL_VERSION.into()) { + return Err("unsupported journal version; retained without modification".into()); + } + let record: Record = serde_json::from_value(value).map_err(|e| e.to_string())?; + if record.id != id || record.revision == 0 || !record.effects.is_object() || + record.binding.request_id.as_deref().is_some_and(|s| !protocol::request_id(s)) || + (record.binding.method.requires_request_id() && record.binding.request_id.is_none()) { + return Err("invalid journal identity/state".into()); + } + if records.values().any(|r: &Record| record.binding.request_id.is_some() && + r.binding.uid == record.binding.uid && r.binding.method == record.binding.method && + r.binding.request_id == record.binding.request_id) { + return Err("duplicate durable request binding; reconciliation required".into()); + } + records.insert(id.to_owned(), record); + } + Ok(Self { directory: directory.into(), _owner: owner, records, poisoned: false }) + } + + pub fn records(&self) -> impl Iterator { self.records.values() } + + /// Call only after authorization and validation. Persist before RPC replies. + /// Any surviving active record blocks fresh work until explicit reconciliation. + pub fn admit(&mut self, caller: &Caller, method: Method, options: &Options, inputs: Value) -> Result { + if self.poisoned { return Err("journal durability uncertain; restart and reconcile".into()); } + if matches!(method, Method::Cancel | Method::GetLog) || + (options.force && !matches!(method, Method::Refresh | Method::RefreshCatalog)) || + options.request_id.as_deref().is_some_and(|id| !protocol::request_id(id)) || + (method.requires_request_id() && options.request_id.is_none()) || + !inputs.is_object() || serde_json::to_vec(&inputs).map_err(|e| e.to_string())?.len() > protocol::MAX_REQUEST_BYTES { + return Err("invalid admission inputs".into()); + } + let binding = Binding { uid: caller.uid, method, request_id: options.request_id.clone(), inputs, + offline: options.offline, force: options.force }; + if binding.request_id.is_some() { + if let Some(prior) = self.records.values().find(|r| r.binding.uid == binding.uid && + r.binding.method == method && r.binding.request_id == binding.request_id) { + return if prior.binding == binding { Ok(Admission::Existing(prior.clone())) } + else { Err("request ID reused with different canonical inputs".into()) }; + } + } + if self.records.values().any(|r| !r.state.terminal()) { return Err("active or unreconciled operation; admission blocked".into()); } + if self.records.len() >= MAX_RECORDS { return Err("journal capacity reached; protected records retained".into()); } + let timestamp = now()?; + let id = random_id()?; + if self.records.contains_key(&id) { return Err("operation identity collision".into()); } + let record = Record { version: protocol::JOURNAL_VERSION, id: id.clone(), binding, + original_sender: caller.unique_sender.clone(), state: State::Queued, phase: Phase::Admission, + revision: 1, created_at_usec: timestamp, updated_at_usec: timestamp, + retained_until_usec: 0, effects: serde_json::json!({}) }; + self.persist(&record)?; + self.records.insert(id, record.clone()); + Ok(Admission::Accepted(record)) + } + + /// Before critical effects, persist the new phase. Terminal records are immutable. + /// `effects` comes from engine observation, never from the transport caller. + pub fn transition(&mut self, id: &str, state: State, phase: Phase, effects: Value) -> Result { + if self.poisoned { return Err("journal durability uncertain; restart and reconcile".into()); } + if !protocol::operation_id(id) || !effects.is_object() { return Err("invalid transition".into()); } + let mut record = self.records.get(id).ok_or("unknown operation")?.clone(); + if record.state.terminal() { return Err("terminal record is immutable".into()); } + let allowed = match record.state { + State::Queued => matches!(state, State::Running | State::Cancelled | State::Reconciling | State::Interrupted | State::Failed), + State::Running => !matches!(state, State::Queued), + State::Cancelling => matches!(state, State::Cancelling | State::Cancelled | State::Failed | State::Reconciling | State::Interrupted), + State::Reconciling => matches!(state, State::Succeeded | State::Failed | State::Interrupted | State::Reconciling), + _ => false, + }; + if !allowed { return Err("invalid state transition".into()); } + record.state = state; + record.phase = phase; + record.effects = effects; + record.revision = record.revision.checked_add(1).ok_or("revision overflow")?; + record.updated_at_usec = now()?.max(record.updated_at_usec); + // No automatic GC until deployment/plan protection is wired into the engine. + self.persist(&record)?; + self.records.insert(id.into(), record.clone()); + Ok(record) + } + + fn persist(&mut self, record: &Record) -> Result<(), String> { + let bytes = serde_json::to_vec(record).map_err(|e| e.to_string())?; + if bytes.len() as u64 > MAX_RECORD_BYTES { return Err("record too large".into()); } + let temp = self.directory.join(format!("partial-{}", random_id()?)); + let result = (|| -> std::io::Result<()> { + let mut file = OpenOptions::new().write(true).create_new(true).mode(0o600).open(&temp)?; + file.write_all(&bytes)?; + file.sync_all()?; + fs::rename(&temp, self.directory.join(format!("{}.json", record.id)))?; + File::open(&self.directory)?.sync_all() + })(); + if let Err(error) = result { + self.poisoned = true; + return Err(format!("journal write failed; admission stopped: {error}")); + } + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + fn fixture() -> PathBuf { std::env::temp_dir().join(format!("archipelago-journal-{}", random_id().unwrap())) } + #[test] + fn restart_reattaches_same_request_and_blocks_ambiguous_new_work() { + let path = fixture(); + let caller = Caller { uid: 1000, unique_sender: ":1.20".into() }; + let options = Options { request_id: Some("12345678-1234-1234-1234-123456789abc".into()), ..Default::default() }; + let mut j = Journal::open(&path).unwrap(); + let Admission::Accepted(first) = j.admit(&caller, Method::Stage, &options, json!({"plan_id":"a".repeat(64)})).unwrap() else { panic!() }; + assert!(Journal::open(&path).is_err()); + j.transition(&first.id, State::Running, Phase::Staging, json!({})).unwrap(); + drop(j); + let mut j = Journal::open(&path).unwrap(); + let reconnected = Caller { unique_sender: ":1.42".into(), ..caller }; + assert!(matches!(j.admit(&reconnected, Method::Stage, &options, json!({"plan_id":"a".repeat(64)})), Ok(Admission::Existing(r)) if r.id == first.id)); + assert!(j.admit(&reconnected, Method::Stage, &options, json!({"plan_id":"b".repeat(64)})).is_err()); + assert!(j.admit(&reconnected, Method::Refresh, &Options::default(), json!({})).is_err()); + j.transition(&first.id, State::Reconciling, Phase::Reconciling, json!({"deployment_seen":true})).unwrap(); + j.transition(&first.id, State::Interrupted, Phase::Reconciling, json!({"deployment_seen":true})).unwrap(); + assert!(j.transition(&first.id, State::Succeeded, Phase::Finished, json!({})).is_err()); + drop(j); + fs::remove_dir_all(path).unwrap(); + } + #[test] + fn newer_schema_is_retained_byte_for_byte() { + let path = fixture(); + drop(Journal::open(&path).unwrap()); + let record = path.join(format!("{}.json", "a".repeat(32))); + let bytes = b"{\"version\":999,\"future\":true}"; + let mut f = OpenOptions::new().create_new(true).write(true).mode(0o600).open(&record).unwrap(); + f.write_all(bytes).unwrap(); + assert!(Journal::open(&path).is_err()); + assert_eq!(fs::read(&record).unwrap(), bytes); + fs::remove_dir_all(path).unwrap(); + } +} diff --git a/src/service/mod.rs b/src/service/mod.rs new file mode 100644 index 0000000..a0398e9 --- /dev/null +++ b/src/service/mod.rs @@ -0,0 +1,149 @@ +//! Incremental service frontend. Only local observation is enabled in this slice. +//! Mutation capabilities stay absent until engine/journal/policy integration passes. +pub mod journal; +pub mod authorization; +mod observation; + +use archipelago_contracts::system_bus::{self as protocol, BUS_NAME, MANAGER_INTERFACE, MANAGER_PATH}; +use std::{collections::HashMap, fs, os::unix::fs::MetadataExt, + path::Path, sync::{Arc, RwLock}, time::Duration}; +use zbus::zvariant::{OwnedObjectPath, OwnedValue, Str, Value}; + +pub type Dictionary = HashMap; +fn text(s: impl Into) -> OwnedValue { OwnedValue::from(Str::from(s.into())) } +fn strings(values: Vec) -> OwnedValue { + OwnedValue::try_from(Value::from(values)).expect("string arrays contain no file descriptors") +} +fn dictionary(value: Dictionary) -> OwnedValue { OwnedValue::from(value) } + +#[derive(Debug, zbus::DBusError)] +#[zbus(prefix = "org.archipelago.System1.Error")] +pub enum BusError { + Unsupported(String), + Unavailable(String), + InvalidArgument(String), + PlanStale(String), + NotAuthorized(String), + AuthenticationRequired(String), +} + +struct Manager { + status: Arc>, +} + +#[zbus::interface(name = "org.archipelago.System1.Manager")] +#[allow(unused_variables)] +impl Manager { + #[zbus(out_args("capabilities"))] + fn get_capabilities(&self) -> Dictionary { + HashMap::from([ + ("api_major".into(), OwnedValue::from(1_u32)), + ("api_minor".into(), OwnedValue::from(1_u32)), + ("operations".into(), strings(vec!["GetCapabilities".into(), "GetStatus".into()])), + ("features".into(), strings(vec![])), + ("limits".into(), dictionary(HashMap::from([ + ("max_page_entries".into(), OwnedValue::from(protocol::MAX_PAGE_ENTRIES)), + ("max_request_bytes".into(), OwnedValue::from(protocol::MAX_REQUEST_BYTES as u32)), + ]))), + ]) + } + + #[zbus(out_args("status"))] + fn get_status(&self) -> Result { + self.status.read().map_err(|_| BusError::Unavailable("Status observer unavailable".into())).map(|s| s.wire()) + } + + #[zbus(property)] + fn status_revision(&self) -> zbus::fdo::Result { + self.status.read().map(|s| s.revision).map_err(|_| zbus::fdo::Error::Failed("Status observer unavailable".into())) + } + + // No admission, journal write or implicit privileged CLI fallback on these paths. + #[zbus(out_args("transaction"))] + fn refresh(&self, options: Dictionary) -> Result { unsupported() } + #[zbus(out_args("transaction"))] + fn get_update_details(&self, target: &str, options: Dictionary) -> Result { unsupported() } + #[zbus(out_args("transaction"))] + fn prepare_update(&self, target: &str, options: Dictionary) -> Result { unsupported() } + #[zbus(out_args("transaction"))] + fn download(&self, plan_id: &str, options: Dictionary) -> Result { unsupported() } + #[zbus(out_args("transaction"))] + fn stage(&self, plan_id: &str, options: Dictionary) -> Result { unsupported() } + #[zbus(out_args("transaction"))] + fn get_transaction(&self, operation_id: &str) -> Result { unsupported() } + #[zbus(out_args("records", "next_cursor"))] + fn list_transactions(&self, cursor: &str, limit: u32) -> Result<(Vec, String), BusError> { unsupported() } + #[zbus(out_args("result"))] + fn validate_pending(&self, deployment_id: &str) -> Result { unsupported() } +} + +struct ObjectRegistry { status: Arc> } + +// RFC-0012 additionally includes the manager itself in its root snapshot. +#[zbus::interface(name = "org.freedesktop.DBus.ObjectManager")] +impl ObjectRegistry { + fn get_managed_objects(&self) -> Result>, BusError> { + let revision = self.status.read().map_err(|_| BusError::Unavailable("Status observer unavailable".into()))?.revision; + Ok(HashMap::from([(OwnedObjectPath::try_from(MANAGER_PATH).expect("constant object path"), + HashMap::from([(MANAGER_INTERFACE.into(), HashMap::from([("StatusRevision".into(), OwnedValue::from(revision))]))]))])) + } + #[zbus(signal)] + async fn interfaces_added(emitter: &zbus::object_server::SignalEmitter<'_>, + object_path: OwnedObjectPath, interfaces_and_properties: HashMap) -> zbus::Result<()>; + #[zbus(signal)] + async fn interfaces_removed(emitter: &zbus::object_server::SignalEmitter<'_>, + object_path: OwnedObjectPath, interfaces: Vec) -> zbus::Result<()>; +} + +fn unsupported() -> Result { + Err(BusError::Unsupported("Operation is not enabled in this service build; inspect GetCapabilities".into())) +} + +pub fn run() -> Result<(), String> { + if fs::metadata("/proc/self").map_err(|e| e.to_string())?.uid() != 0 { + return Err("archipelagod requires the system service identity".into()); + } + if !Path::new("/run/ostree-booted").exists() { + return Err("archipelagod only supports installed OSTree systems".into()); + } + let directory = Path::new("/var/lib/archipelago/service"); + let observer = observation::Store::open(directory)?; + let status = Arc::new(RwLock::new(observer.initial()?)); + let connection = zbus::blocking::connection::Builder::system().map_err(|e| e.to_string())? + .serve_at(MANAGER_PATH, Manager { status: status.clone() }).map_err(|e| e.to_string())? + .serve_at(MANAGER_PATH, ObjectRegistry { status: status.clone() }).map_err(|e| e.to_string())? + .name(BUS_NAME).map_err(|e| e.to_string())?.build().map_err(|e| e.to_string())?; + // Blocking local I/O is outside zbus' dispatch executor. No network here. + // Keep ownership even if a second manual service invocation is attempted. + loop { + let before = status.read().map_err(|_| "status observer poisoned")?.clone(); + let next = match observation::observe() { + Ok(next) => next, + Err(error) => { + eprintln!("local deployment observation failed: {error}"); + let mut next = before.clone(); + next.reconciling = true; + next + } + }; + if next.content_changed(&before) { + let next = observer.save(next, before.revision)?; + let revision = next.revision; + *status.write().map_err(|_| "status observer poisoned")? = next; + connection.emit_signal(None::<&str>, MANAGER_PATH, "org.freedesktop.DBus.Properties", + "PropertiesChanged", &(MANAGER_INTERFACE, + HashMap::from([("StatusRevision", OwnedValue::from(revision))]), Vec::::new())) + .map_err(|e| e.to_string())?; + } + std::thread::sleep(Duration::from_secs(5)); + } +} + +/// Explicit development client, not an automatic fallback or installed CLI cutover. +pub fn inspect(capabilities: bool) -> Result<(), String> { + let bus = zbus::blocking::Connection::system().map_err(|e| e.to_string())?; + let proxy = zbus::blocking::Proxy::new(&bus, BUS_NAME, MANAGER_PATH, MANAGER_INTERFACE).map_err(|e| e.to_string())?; + let fields: Dictionary = proxy.call(if capabilities { "GetCapabilities" } else { "GetStatus" }, &()).map_err(|e| e.to_string())?; + println!("{}", serde_json::to_string_pretty(&fields).map_err(|e| e.to_string())?); + Ok(()) +} diff --git a/src/service/observation.rs b/src/service/observation.rs new file mode 100644 index 0000000..f2d3bca --- /dev/null +++ b/src/service/observation.rs @@ -0,0 +1,144 @@ +//! Durable revision for local OSTree observations; not the legacy software cache. +use super::{Dictionary, dictionary, text}; +use archipelago_contracts::system_bus::checksum; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::{fs::{self, File, OpenOptions}, io::Write, + os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt}, path::{Path, PathBuf}, process::Command}; +use zbus::zvariant::{OwnedObjectPath, OwnedValue}; + +#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)] +#[serde(deny_unknown_fields)] +pub struct Deployment { + pub deployment_id: String, + pub checksum: String, +} +impl Deployment { + fn wire(&self, pending: bool) -> Dictionary { + let mut map = Dictionary::from([ + ("deployment_id".into(), text(&self.deployment_id)), + ("checksum".into(), text(&self.checksum)), + ]); + if pending { map.insert("reboot_required".into(), OwnedValue::from(true)); } + map + } +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +#[serde(deny_unknown_fields)] +pub struct Snapshot { + pub version: u32, + pub revision: u64, + pub booted: Option, + pub pending: Option, + pub reconciling: bool, +} +impl Snapshot { + pub fn wire(&self) -> Dictionary { + Dictionary::from([ + ("revision".into(), OwnedValue::from(self.revision)), + ("booted".into(), dictionary(self.booted.as_ref().map(|d| d.wire(false)).unwrap_or_default())), + ("pending".into(), dictionary(self.pending.as_ref().map(|d| d.wire(true)).unwrap_or_default())), + ("desired".into(), dictionary(Dictionary::new())), + ("reconciling".into(), OwnedValue::from(self.reconciling)), + ("active_transactions".into(), OwnedValue::try_from(zbus::zvariant::Value::from(Vec::::new())).expect("object paths contain no FDs")), + ("update".into(), dictionary(Dictionary::from([ + ("state".into(), text("unknown")), ("target".into(), text("")), + ("checked_at_usec".into(), OwnedValue::from(0_u64)), + ("stale".into(), OwnedValue::from(true)), + ("details_state".into(), text("unknown")), + ("last_error".into(), dictionary(Dictionary::new())), + ]))), + ]) + } + pub fn content_changed(&self, other: &Self) -> bool { + self.booted != other.booted || self.pending != other.pending || self.reconciling != other.reconciling + } +} + +pub struct Store { directory: PathBuf, _owner: File } +impl Store { + pub fn open(directory: &Path) -> Result { + // systemd creates the parent StateDirectory before the service starts. + if !directory.exists() { + fs::DirBuilder::new().mode(0o700).create(directory).map_err(|e| e.to_string())?; + File::open(directory.parent().ok_or("missing state parent")?).and_then(|f| f.sync_all()).map_err(|e| e.to_string())?; + } + let metadata = fs::symlink_metadata(directory).map_err(|e| e.to_string())?; + if !metadata.is_dir() || metadata.uid() != 0 || metadata.mode() & 0o077 != 0 { + return Err("service state directory must be private and root-owned".into()); + } + let lock = OpenOptions::new().create(true).truncate(false).write(true).mode(0o600) + .open(directory.join("owner.lock")).map_err(|e| e.to_string())?; + lock.try_lock().map_err(|_| "service observer already owned")?; + Ok(Self { directory: directory.into(), _owner: lock }) + } + pub fn initial(&self) -> Result { + let path = self.directory.join("observation.json"); + let old = if path.exists() { + let meta = fs::symlink_metadata(&path).map_err(|e| e.to_string())?; + if !meta.is_file() || meta.len() > 65536 || meta.uid() != 0 || meta.mode() & 0o077 != 0 { return Err("invalid observation file".into()); } + let value: Value = serde_json::from_slice(&fs::read(path).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?; + if value["version"] != 1 { return Err("unsupported observation version; retained".into()); } + serde_json::from_value::(value).map_err(|e| e.to_string())? + } else { Snapshot { version: 1, revision: 0, booted: None, pending: None, reconciling: true } }; + let mut next = old.clone(); + next.reconciling = true; + self.save(next, old.revision) + } + pub fn save(&self, mut next: Snapshot, revision: u64) -> Result { + next.revision = revision.checked_add(1).ok_or("status revision overflow")?; + let temp = self.directory.join("observation.tmp"); + // The private directory and lifetime lock exclude competing writers. + let mut file = OpenOptions::new().write(true).create(true).truncate(true).mode(0o600) + .open(&temp).map_err(|e| e.to_string())?; + file.write_all(&serde_json::to_vec(&next).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?; + file.sync_all().map_err(|e| e.to_string())?; + fs::rename(temp, self.directory.join("observation.json")).map_err(|e| e.to_string())?; + File::open(&self.directory).and_then(|f| f.sync_all()).map_err(|e| e.to_string())?; + Ok(next) + } +} + +pub fn observe() -> Result { + let lock = OpenOptions::new().create(true).truncate(false).write(true).mode(0o600) + .open("/run/archipelago-compose.lock").map_err(|e| e.to_string())?; + lock.try_lock().map_err(|_| "host engine busy; cached observation remains reconciling")?; + let result = Command::new("timeout").args(["--kill-after=2", "10", "ostree", "admin", "status", "--json"]) + .env("LC_ALL", "C").output().map_err(|e| e.to_string())?; + if !result.status.success() || result.stdout.len() > 1024 * 1024 { return Err("local OSTree status unavailable".into()); } + parse(&serde_json::from_slice(&result.stdout).map_err(|e| e.to_string())?) +} + +fn parse(value: &Value) -> Result { + let mut next = Snapshot { version: 1, revision: 0, booted: None, pending: None, reconciling: false }; + for entry in value["deployments"].as_array().ok_or("missing deployments")? { + if entry["stateroot"] != "archipelago" { continue; } + let booted = entry["booted"] == true; + let pending = entry["pending"] == true || entry["staged"] == true; + if !booted && !pending { continue; } + let commit = entry["checksum"].as_str().filter(|s| checksum(s)).ok_or("invalid deployment checksum")?; + let serial = entry["serial"].as_u64().ok_or("missing deployment serial")?; + let deployment = Deployment { deployment_id: format!("archipelago/{commit}.{serial}"), checksum: commit.into() }; + if booted && pending { return Err("ambiguous booted/pending role".into()); } + let slot = if booted { &mut next.booted } else { &mut next.pending }; + if slot.replace(deployment).is_some() { return Err("ambiguous deployment identity".into()); } + } + if next.booted.is_none() { return Err("no booted Archipelago deployment".into()); } + Ok(next) +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + #[test] + fn same_commit_different_serials_remain_distinct() { + let hash = "a".repeat(64); + let s = parse(&json!({"deployments":[ + {"stateroot":"archipelago","checksum":hash,"serial":0,"booted":true}, + {"stateroot":"archipelago","checksum":hash,"serial":1,"staged":true}]})).unwrap(); + assert_ne!(s.booted.unwrap().deployment_id, s.pending.unwrap().deployment_id); + assert!(parse(&json!({"deployments":[{"stateroot":"archipelago","checksum":hash,"booted":true}]})).is_err()); + } +} diff --git a/src/updates.rs b/src/updates.rs index 098f1b7..2eb256a 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -177,7 +177,16 @@ pub fn plan_json(save: bool) -> Result<(), String> { plan_output(save, true, true) } pub fn diff() -> Result<(), String> { plan_output(false, false, true) } -fn plan_output(save: bool, json_output: bool, include_diff: bool) -> Result<(), String> { + +/// Shared planning result. Formatting is a client concern; the future service +/// admission layer must bind this to its journal before advertising PrepareUpdate. +pub(crate) struct PreparedUpdate { + pub plan: Value, + pub plan_id: Option, +} + +pub(crate) fn prepare(save: bool, include_diff: bool, exact_target: Option<&str>) -> Result { + if exact_target.is_some_and(|s| !digest(s)) { return Err("invalid exact target checksum".into()); } let _lock = lock()?; reconcile_operations()?; let binding = binding()?; @@ -191,6 +200,9 @@ fn plan_output(save: bool, json_output: bool, include_diff: bool) -> Result<(), } let reference = binding["reference"].as_str().ok_or("missing reference")?; let target = summary_commit(&repo(&["remote", "summary", REMOTE])?, &reference)?; + if exact_target.is_some_and(|expected| expected != target) { + return Err("verified track target differs from the requested target; no implicit retarget".into()); + } require_newer(&base, &target)?; let mut plan = json!({"version":3,"binding":binding,"variant":variant()?,"reference":reference, "target":target,"base":base,"requested":requested,"initial":state}); @@ -202,7 +214,22 @@ fn plan_output(save: bool, json_output: bool, include_diff: bool) -> Result<(), plan["package_changes"] = json!(crate::package_diff::between(&before, &after)?); plan["package_changes_scope"] = json!("managed-base"); } - if !save { + let plan_id = if save { + let temp = Path::new(STATE).join("plan.tmp"); + write(&temp, &plan)?; + let hash = output("sha256sum", &[temp.to_str().unwrap()])?.split_whitespace().next().ok_or("missing digest")?.to_string(); + fs::rename(&temp, plan_path(&hash)?).map_err(|e| e.to_string())?; + Some(hash) + } else { None }; + Ok(PreparedUpdate { plan, plan_id }) +} + +fn plan_output(save: bool, json_output: bool, include_diff: bool) -> Result<(), String> { + let PreparedUpdate { plan, plan_id } = prepare(save, include_diff, None)?; + let reference = plan["reference"].as_str().ok_or("missing plan reference")?; + let base = plan["base"].as_str().ok_or("missing plan base")?; + let target = plan["target"].as_str().ok_or("missing plan target")?; + if plan_id.is_none() { if json_output { println!("{}", serde_json::to_string_pretty(&plan).unwrap()); } else { println!("Track: {reference}\nCurrent: {base}\nTarget: {target}"); @@ -217,10 +244,7 @@ fn plan_output(save: bool, json_output: bool, include_diff: bool) -> Result<(), } return Ok(()); } - let temp = Path::new(STATE).join("plan.tmp"); - write(&temp, &plan)?; - let hash = output("sha256sum", &[temp.to_str().unwrap()])?.split_whitespace().next().ok_or("missing digest")?.to_string(); - fs::rename(&temp, plan_path(&hash)?).map_err(|e| e.to_string())?; + let hash = plan_id.ok_or("missing saved plan identity")?; if json_output { println!("{}", serde_json::to_string_pretty(&json!({"plan_id":hash,"plan":plan})).unwrap()); } else {