commit d0c742963605afd896c088ad9dab08ad0002ac07996a8ce9610815bb0e755aef Author: Tyler King Date: Wed Mar 18 16:45:06 2026 -0400 initial: forge v0.1.0 Forge CLI workspace — Chronicle query and governance tooling for Substrate/Guildhouse FFCs. Crates: - forge: CLI binary (forge log, forge query) - forge-core: Chronicle query engine, ClickHouse adapter - forge-workspace: workspace management 33 tests passing. Queries forge_events materialized view in ClickHouse. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73bb5d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/target/ +**/target/ +**/*.rs.bk +.env +*.swp +*.swo diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f0f5215 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2699 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "accord-core" +version = "0.1.0" +dependencies = [ + "chrono", + "serde", + "serde_yaml", + "sha2", + "thiserror", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower 0.5.3", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "ceremony-engine" +version = "0.1.0" +dependencies = [ + "accord-core", + "async-trait", + "chrono", + "hex", + "registry-protocol", + "serde", + "serde_json", + "serde_json_canonicalizer", + "sha2", + "thiserror", + "tokio", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "colored" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" +dependencies = [ + "windows-sys 0.61.2", +] + +[[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", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "forge" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "clap", + "forge-core", + "forge-workspace", + "serde", + "serde_json", + "tokio", + "tonic", + "tracing", + "tracing-subscriber", + "uuid", +] + +[[package]] +name = "forge-core" +version = "0.1.0" +dependencies = [ + "accord-core", + "anyhow", + "async-trait", + "ceremony-engine", + "chrono", + "mockito", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "uuid", +] + +[[package]] +name = "forge-workspace" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "chrono", + "forge-core", + "guildhouse-proto", + "serde", + "serde_json", + "thiserror", + "tokio", + "tonic", + "tracing", + "uuid", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +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", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 5.3.0", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", + "wasip2", + "wasip3", +] + +[[package]] +name = "guildhouse-proto" +version = "0.1.0" +dependencies = [ + "prost", + "prost-types", + "tonic", + "tonic-build", +] + +[[package]] +name = "h2" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.13.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[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.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2 0.6.3", + "tokio", + "tower-service", + "tracing", +] + +[[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 = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + +[[package]] +name = "iri-string" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "mockito" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90820618712cab19cfc46b274c6c22546a82affcb3c3bdf0f29e3db8e1bb92c0" +dependencies = [ + "assert-json-diff", + "bytes", + "colored", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "log", + "pin-project-lite", + "rand 0.9.2", + "regex", + "serde_json", + "serde_urlencoded", + "similar", + "tokio", +] + +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[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 = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[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 = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset", + "indexmap 2.13.0", +] + +[[package]] +name = "pin-project" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" +dependencies = [ + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" +dependencies = [ + "prost", +] + +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2 0.6.3", + "thiserror", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" +dependencies = [ + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand 0.9.2", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2 0.6.3", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +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.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[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 = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "registry-protocol" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "hex", + "serde", + "serde_json", + "serde_json_canonicalizer", + "sha2", + "thiserror", + "tokio", + "tracing", + "uuid", +] + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower 0.5.3", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "ryu-js" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd29631678d6fb0903b69223673e122c32e9ae559d0960a38d574695ebc0ea15" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_json_canonicalizer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe52319a927259afbfa5180c5157cd8167edfd3e8c254f9558c7fef44c5649f2" +dependencies = [ + "ryu-js", + "serde", + "serde_json", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.13.0", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + +[[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 = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[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 = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[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 = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[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.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.2", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.6.3", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost", + "socket2 0.5.10", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand 0.8.5", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower 0.5.3", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[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", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" +dependencies = [ + "getrandom 0.4.2", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[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.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" +dependencies = [ + "cfg-if", + "futures-util", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap 2.13.0", + "semver", +] + +[[package]] +name = "web-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" +dependencies = [ + "rustls-pki-types", +] + +[[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", +] + +[[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", +] + +[[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.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.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.13.0", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap 2.13.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.13.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5e7ad2e --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,31 @@ +[workspace] +resolver = "2" +members = ["forge-core", "forge-workspace", "forge"] + +[workspace.dependencies] +serde = { version = "1", features = ["derive"] } +serde_json = "1" +thiserror = "2" +anyhow = "1" +tracing = "0.1" +uuid = { version = "1", features = ["v4", "v7", "serde"] } +chrono = { version = "0.4", features = ["serde"] } +async-trait = "0.1" +reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] } + +# Cross-workspace path dep. +# ceremony-engine is in the bascule workspace. +# Future: published to crates.io as version dep. +ceremony-engine = { path = "../bascule/ceremony-engine" } + +# CLI +clap = { version = "4", features = ["derive", "env"] } +tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] } + +# Internal +forge-core = { path = "./forge-core" } +forge-workspace = { path = "./forge-workspace" } + +# gRPC +tonic = "0.12" +tokio = { version = "1", features = ["full"] } diff --git a/forge-core/Cargo.toml b/forge-core/Cargo.toml new file mode 100644 index 0000000..bf93b21 --- /dev/null +++ b/forge-core/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "forge-core" +version = "0.1.0" +edition = "2021" +description = "Governed collaboration primitive for the Substrate governance fabric" + +[dependencies] +ceremony-engine = { workspace = true } +# Cross-workspace — CeremonyType/CeremonyReqs used by propose() +accord-core = { path = "../../guildhouse/services/accord-core" } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +anyhow = { workspace = true } +tracing = { workspace = true } +uuid = { workspace = true } +chrono = { workspace = true } +async-trait = { workspace = true } +reqwest = { workspace = true } +tokio = { workspace = true } + +[dev-dependencies] +mockito = "1" diff --git a/forge-core/src/chronicle.rs b/forge-core/src/chronicle.rs new file mode 100644 index 0000000..e07ed03 --- /dev/null +++ b/forge-core/src/chronicle.rs @@ -0,0 +1,417 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +/// The kind of Chronicle event emitted by a ForgeSession. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum ForgeEventKind { + ForgeSessionOpened, + ForgeParticipantJoined, + ForgeParticipantLeft, + ForgeChangeProposed, + ForgeChangeApproved, + ForgeChangeDenied, + ForgeChangeExecuted, + ForgeInvitationCreated, + ForgeInvitationAccepted, + ForgeSessionClosed, + ForgeSessionAbandoned, +} + +/// A Chronicle event emitted by forge-core. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ForgeChronicleEvent { + pub event_id: Uuid, + pub session_id: Uuid, + pub kind: ForgeEventKind, + pub actor_did: String, + pub accord_hash: [u8; 32], + pub occurred_at: DateTime, + pub payload: serde_json::Value, +} + +impl ForgeChronicleEvent { + pub fn new( + session_id: Uuid, + kind: ForgeEventKind, + actor_did: impl Into, + accord_hash: [u8; 32], + payload: serde_json::Value, + ) -> Self { + Self { + event_id: Uuid::now_v7(), + session_id, + kind, + actor_did: actor_did.into(), + accord_hash, + occurred_at: Utc::now(), + payload, + } + } +} + +// ── Chronicle warm-tier query client ────────────────────── + +/// A single row from the `chronicle.forge_events` materialized view. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ForgeLogEntry { + pub entry_id: String, + pub occurred_at: String, + pub sequence: u64, + pub actor_did: String, + pub accord_hash: String, + pub kind: String, + pub forge_session_id: Option, + pub proposal_id: Option, + pub message: Option, + pub merged_sha: Option, +} + +impl ForgeLogEntry { + /// Human-readable display of this event. + pub fn display(&self) -> String { + let mut out = format!("{} {}\n actor: {}", self.occurred_at, self.kind, self.actor_did); + if let Some(ref msg) = self.message { + if !msg.is_empty() { + out.push_str(&format!("\n {}", msg)); + } + } + if let Some(ref pid) = self.proposal_id { + if !pid.is_empty() { + out.push_str(&format!("\n proposal: {}", pid)); + } + } + if let Some(ref sha) = self.merged_sha { + if !sha.is_empty() { + out.push_str(&format!("\n sha: {}", sha)); + } + } + out + } +} + +/// Query parameters for reading forge events from the Chronicle warm tier. +#[derive(Debug, Clone)] +pub struct ForgeLogQuery { + /// Filter by forge session ID. None = all forge events. + pub session_id: Option, + /// Max entries. Default: 50. + pub limit: u64, + /// Kind prefix filter, e.g. `Some("APP_FORGE_CHANGE")`. + pub kind_filter: Option, +} + +impl Default for ForgeLogQuery { + fn default() -> Self { + Self { + session_id: None, + limit: 50, + kind_filter: None, + } + } +} + +/// HTTP client that queries the ClickHouse Chronicle warm tier directly. +/// +/// This is a read-only client. The drain crate writes; forge reads. +/// Never returns errors — all failures produce `vec![]` + `eprintln!`. +pub struct ChronicleClient { + clickhouse_url: String, + database: String, + http: reqwest::Client, +} + +impl ChronicleClient { + pub fn new() -> Self { + let clickhouse_url = std::env::var("CHRONICLE_DRAIN_CLICKHOUSE_URL") + .unwrap_or_else(|_| "http://localhost:8123".to_string()); + let database = std::env::var("CHRONICLE_DRAIN_DB") + .unwrap_or_else(|_| "chronicle".to_string()); + Self { + clickhouse_url, + database, + http: reqwest::Client::new(), + } + } + + /// Query forge events from the Chronicle warm tier. + /// NEVER returns Err — all failures produce an empty vec + stderr message. + pub async fn query_forge_log(&self, query: &ForgeLogQuery) -> Vec { + let sql = self.build_query(query); + let resp = match self + .http + .post(&self.clickhouse_url) + .query(&[("database", &self.database)]) + .body(sql) + .send() + .await + { + Ok(r) => r, + Err(e) => { + eprintln!("chronicle: ClickHouse unreachable: {e}"); + return vec![]; + } + }; + + if !resp.status().is_success() { + let status = resp.status(); + let body = resp.text().await.unwrap_or_default(); + eprintln!("chronicle: ClickHouse returned {status}: {body}"); + return vec![]; + } + + self.parse_response(resp).await + } + + fn build_query(&self, q: &ForgeLogQuery) -> String { + let mut conditions = Vec::new(); + + if let Some(ref sid) = q.session_id { + if is_safe_uuid(sid) { + conditions.push(format!("forge_session_id = '{sid}'")); + } + } + + if let Some(ref kind) = q.kind_filter { + let safe: String = kind + .chars() + .filter(|c| c.is_alphanumeric() || *c == '_') + .collect(); + if !safe.is_empty() { + conditions.push(format!("kind LIKE '{safe}%'")); + } + } + + let where_clause = if conditions.is_empty() { + String::new() + } else { + format!("WHERE {}", conditions.join(" AND ")) + }; + + format!( + "SELECT entry_id, toString(occurred_at) AS occurred_at, \ + sequence, actor_did, accord_hash, kind, \ + forge_session_id, proposal_id, message, merged_sha \ + FROM forge_events \ + {where_clause} \ + ORDER BY sequence ASC \ + LIMIT {} \ + FORMAT JSONEachRow", + q.limit + ) + } + + async fn parse_response(&self, resp: reqwest::Response) -> Vec { + let body = match resp.text().await { + Ok(b) => b, + Err(e) => { + eprintln!("chronicle: failed to read response body: {e}"); + return vec![]; + } + }; + + body.lines() + .filter(|line| !line.trim().is_empty()) + .filter_map(|line| { + serde_json::from_str::(line) + .map_err(|e| { + eprintln!("chronicle: skipping unparseable line: {e}"); + e + }) + .ok() + }) + .collect() + } +} + +impl Default for ChronicleClient { + fn default() -> Self { + Self::new() + } +} + +/// SQL injection prevention: only allow hex + hyphens, max 36 chars. +fn is_safe_uuid(s: &str) -> bool { + s.len() <= 36 && s.chars().all(|c| c.is_ascii_hexdigit() || c == '-') +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn event_serializes_to_json() { + let evt = ForgeChronicleEvent::new( + Uuid::now_v7(), + ForgeEventKind::ForgeSessionOpened, + "did:web:msp.local:eng:alice", + [0u8; 32], + serde_json::json!({"artifact_type": "workspace"}), + ); + let json = serde_json::to_string(&evt).unwrap(); + assert!(json.contains("FORGE_SESSION_OPENED")); + assert!(json.contains("did:web:msp.local:eng:alice")); + } + + #[test] + fn event_kind_screaming_snake_case() { + let kind = ForgeEventKind::ForgeChangeProposed; + let json = serde_json::to_string(&kind).unwrap(); + assert_eq!(json, "\"FORGE_CHANGE_PROPOSED\""); + } + + // ── ChronicleClient tests ────────────────── + + fn sample_entry(seq: u64, kind: &str) -> ForgeLogEntry { + ForgeLogEntry { + entry_id: format!("entry-{seq}"), + occurred_at: "2026-03-17 14:30:00".to_string(), + sequence: seq, + actor_did: "did:web:test".to_string(), + accord_hash: "bbb".to_string(), + kind: kind.to_string(), + forge_session_id: Some("550e8400-e29b-41d4-a716-446655440000".to_string()), + proposal_id: Some("prop-1".to_string()), + message: Some("add auth".to_string()), + merged_sha: None, + } + } + + fn sample_json_line(seq: u64, kind: &str) -> String { + serde_json::to_string(&sample_entry(seq, kind)).unwrap() + } + + #[tokio::test] + async fn test_query_returns_two_entries() { + let mut server = mockito::Server::new_async().await; + let body = format!( + "{}\n{}\n", + sample_json_line(1, "APP_FORGE_CHANGE_PROPOSED"), + sample_json_line(2, "APP_FORGE_CHANGE_APPROVED"), + ); + let mock = server + .mock("POST", "/") + .match_query(mockito::Matcher::UrlEncoded("database".into(), "chronicle".into())) + .with_status(200) + .with_body(&body) + .create_async() + .await; + + let client = ChronicleClient { + clickhouse_url: server.url(), + database: "chronicle".to_string(), + http: reqwest::Client::new(), + }; + let entries = client.query_forge_log(&ForgeLogQuery::default()).await; + + mock.assert_async().await; + assert_eq!(entries.len(), 2); + assert_eq!(entries[0].kind, "APP_FORGE_CHANGE_PROPOSED"); + } + + #[tokio::test] + async fn test_query_empty_response() { + let mut server = mockito::Server::new_async().await; + let mock = server + .mock("POST", "/") + .match_query(mockito::Matcher::UrlEncoded("database".into(), "chronicle".into())) + .with_status(200) + .with_body("") + .create_async() + .await; + + let client = ChronicleClient { + clickhouse_url: server.url(), + database: "chronicle".to_string(), + http: reqwest::Client::new(), + }; + let entries = client.query_forge_log(&ForgeLogQuery::default()).await; + + mock.assert_async().await; + assert!(entries.is_empty()); + } + + #[tokio::test] + async fn test_query_clickhouse_unreachable() { + let client = ChronicleClient { + clickhouse_url: "http://127.0.0.1:19999".to_string(), + database: "chronicle".to_string(), + http: reqwest::Client::new(), + }; + let entries = client.query_forge_log(&ForgeLogQuery::default()).await; + assert!(entries.is_empty()); + } + + #[tokio::test] + async fn test_query_clickhouse_500() { + let mut server = mockito::Server::new_async().await; + let mock = server + .mock("POST", "/") + .match_query(mockito::Matcher::UrlEncoded("database".into(), "chronicle".into())) + .with_status(500) + .with_body("internal error") + .create_async() + .await; + + let client = ChronicleClient { + clickhouse_url: server.url(), + database: "chronicle".to_string(), + http: reqwest::Client::new(), + }; + let entries = client.query_forge_log(&ForgeLogQuery::default()).await; + + mock.assert_async().await; + assert!(entries.is_empty()); + } + + #[test] + fn test_display_with_all_fields() { + let entry = ForgeLogEntry { + entry_id: "aaa".to_string(), + occurred_at: "2026-03-17 14:30:00".to_string(), + sequence: 1, + actor_did: "did:web:test".to_string(), + accord_hash: "bbb".to_string(), + kind: "APP_FORGE_CHANGE_PROPOSED".to_string(), + forge_session_id: Some("550e8400-e29b-41d4-a716-446655440000".to_string()), + proposal_id: Some("prop-1".to_string()), + message: Some("add auth middleware".to_string()), + merged_sha: Some("abc1234".to_string()), + }; + let out = entry.display(); + assert!(out.contains("add auth middleware")); + assert!(out.contains("proposal:")); + assert!(out.contains("sha:")); + } + + #[test] + fn test_display_minimal_no_options() { + let entry = ForgeLogEntry { + entry_id: "aaa".to_string(), + occurred_at: "2026-03-17 14:30:00".to_string(), + sequence: 1, + actor_did: "did:web:test".to_string(), + accord_hash: "bbb".to_string(), + kind: "APP_FORGE_SESSION_OPENED".to_string(), + forge_session_id: None, + proposal_id: None, + message: None, + merged_sha: None, + }; + let out = entry.display(); + assert!(out.contains("APP_FORGE_SESSION_OPENED")); + assert!(!out.contains("proposal:")); + assert!(!out.contains("sha:")); + } + + #[test] + fn test_is_safe_uuid_valid() { + assert!(is_safe_uuid("550e8400-e29b-41d4-a716-446655440000")); + } + + #[test] + fn test_is_safe_uuid_blocks_injection() { + assert!(!is_safe_uuid("'; DROP TABLE forge_events; --")); + } +} diff --git a/forge-core/src/invitation.rs b/forge-core/src/invitation.rs new file mode 100644 index 0000000..da7208f --- /dev/null +++ b/forge-core/src/invitation.rs @@ -0,0 +1,125 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use crate::participant::ForgeRole; + +/// An invitation for a principal to join a ForgeSession. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ForgeInvitation { + pub invitation_id: Uuid, + pub session_id: Uuid, + pub invitee_did: String, + pub role: ForgeRole, + pub invited_by: String, + pub expires_at: DateTime, + pub accepted: bool, + /// Phase A: None (no signature yet). + /// Phase B: DID signature from invited_by. + pub signature: Option, +} + +impl ForgeInvitation { + pub fn new( + session_id: Uuid, + invitee_did: impl Into, + role: ForgeRole, + invited_by: impl Into, + expires_in_secs: u64, + ) -> Self { + Self { + invitation_id: Uuid::now_v7(), + session_id, + invitee_did: invitee_did.into(), + role, + invited_by: invited_by.into(), + expires_at: Utc::now() + chrono::Duration::seconds(expires_in_secs as i64), + accepted: false, + signature: None, + } + } + + pub fn is_expired(&self) -> bool { + Utc::now() > self.expires_at + } + + pub fn accept(&mut self) -> Result<(), InvitationError> { + if self.is_expired() { + return Err(InvitationError::Expired); + } + if self.accepted { + return Err(InvitationError::AlreadyAccepted); + } + self.accepted = true; + Ok(()) + } +} + +#[derive(Debug, thiserror::Error)] +pub enum InvitationError { + #[error("invitation has expired")] + Expired, + + #[error("invitation already accepted")] + AlreadyAccepted, + + #[error("invitation is for a different DID")] + WrongInvitee, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn new_invitation_is_not_expired() { + let inv = ForgeInvitation::new( + Uuid::now_v7(), + "did:web:isv.local:eng:bob", + ForgeRole::Collaborator, + "did:web:msp.local:eng:alice", + 3600, + ); + assert!(!inv.is_expired()); + assert!(!inv.accepted); + } + + #[test] + fn accept_sets_accepted_flag() { + let mut inv = ForgeInvitation::new( + Uuid::now_v7(), + "did:web:isv.local:eng:bob", + ForgeRole::Collaborator, + "did:web:msp.local:eng:alice", + 3600, + ); + inv.accept().unwrap(); + assert!(inv.accepted); + } + + #[test] + fn double_accept_fails() { + let mut inv = ForgeInvitation::new( + Uuid::now_v7(), + "did:web:isv.local:eng:bob", + ForgeRole::Collaborator, + "did:web:msp.local:eng:alice", + 3600, + ); + inv.accept().unwrap(); + assert!(matches!(inv.accept(), Err(InvitationError::AlreadyAccepted))); + } + + #[test] + fn expired_invitation_cannot_be_accepted() { + let mut inv = ForgeInvitation::new( + Uuid::now_v7(), + "did:web:isv.local:eng:bob", + ForgeRole::Collaborator, + "did:web:msp.local:eng:alice", + 0, // expires immediately + ); + std::thread::sleep(std::time::Duration::from_millis(10)); + assert!(matches!(inv.accept(), Err(InvitationError::Expired))); + } +} diff --git a/forge-core/src/lib.rs b/forge-core/src/lib.rs new file mode 100644 index 0000000..7cf092b --- /dev/null +++ b/forge-core/src/lib.rs @@ -0,0 +1,33 @@ +//! forge-core — governed collaboration primitive +//! for the Substrate governance fabric. +//! +//! A ForgeSession is a multi-principal governed +//! workspace. Multiple participants with different +//! DIDs and different accords collaborate on the +//! same governed artifact in real time. +//! +//! Every action is Chronicle-attributed per +//! principal. The CeremonyEngine governs state +//! transitions. No change executes without the +//! correct ceremony completing. +//! +//! Design: +//! forge-core → ceremony-engine → accord-core +//! +//! Implementations: +//! forge-workspace — git worktree backend +//! forge-schematic — IaC artifact backend (future) +//! forge-dataset — ML dataset backend (future) +//! forge-policy — OPA policy backend (future) + +pub mod chronicle; +pub mod invitation; +pub mod participant; +pub mod proposal; +pub mod session; + +pub use chronicle::{ForgeChronicleEvent, ForgeEventKind}; +pub use invitation::{ForgeInvitation, InvitationError}; +pub use participant::{ForgeParticipant, ForgeRole, ParticipantCapability}; +pub use proposal::{ForgeProposal, ForgeProposalState}; +pub use session::{ForgeArtifact, ForgeError, ForgeSession, ForgeSessionState, ForgeSessionSummary}; diff --git a/forge-core/src/participant.rs b/forge-core/src/participant.rs new file mode 100644 index 0000000..cedebdd --- /dev/null +++ b/forge-core/src/participant.rs @@ -0,0 +1,139 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +/// The role a principal plays in a ForgeSession. +/// +/// Role determines the default capability ceiling. +/// Actual capability is: +/// min(role_ceiling, accord_capability_mask) +/// +/// A Collaborator with a GUILD accord gets +/// Collaborator ceiling, not Owner ceiling. +/// The accord is the structural limit; +/// the role is the session-level limit. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub enum ForgeRole { + /// Session owner. Full capability within their accord. + Owner, + /// Invited collaborator. Can propose but not execute directly. + Collaborator, + /// Read-only observer. Cannot propose or execute. + Observer, +} + +/// Capability flags for a ForgeParticipant. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct ParticipantCapability { + pub can_read: bool, + pub can_propose: bool, + pub can_execute: bool, + pub can_invite: bool, +} + +impl ParticipantCapability { + pub fn for_role(role: &ForgeRole) -> Self { + match role { + ForgeRole::Owner => Self { + can_read: true, + can_propose: true, + can_execute: true, + can_invite: true, + }, + ForgeRole::Collaborator => Self { + can_read: true, + can_propose: true, + can_execute: false, + can_invite: false, + }, + ForgeRole::Observer => Self { + can_read: true, + can_propose: false, + can_execute: false, + can_invite: false, + }, + } + } +} + +/// A principal participating in a ForgeSession. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ForgeParticipant { + /// W3C DID of this participant. + pub did: String, + /// Role in this session. + pub role: ForgeRole, + /// Accord hash governing this participant's actions. + pub accord_hash: [u8; 32], + /// Derived capability for this session. + pub capability: ParticipantCapability, + /// When this participant joined. + pub joined_at: DateTime, + /// When this participant left (None = still active). + pub left_at: Option>, +} + +impl ForgeParticipant { + pub fn new(did: impl Into, role: ForgeRole, accord_hash: [u8; 32]) -> Self { + let capability = ParticipantCapability::for_role(&role); + Self { + did: did.into(), + role, + accord_hash, + capability, + joined_at: Utc::now(), + left_at: None, + } + } + + pub fn is_active(&self) -> bool { + self.left_at.is_none() + } + + pub fn leave(&mut self) { + self.left_at = Some(Utc::now()); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn owner_has_full_capability() { + let p = ForgeParticipant::new("did:web:msp.local:eng:alice", ForgeRole::Owner, [0u8; 32]); + assert!(p.capability.can_execute); + assert!(p.capability.can_invite); + assert!(p.capability.can_propose); + assert!(p.capability.can_read); + } + + #[test] + fn collaborator_cannot_execute() { + let p = + ForgeParticipant::new("did:web:isv.local:eng:bob", ForgeRole::Collaborator, [0u8; 32]); + assert!(!p.capability.can_execute); + assert!(!p.capability.can_invite); + assert!(p.capability.can_propose); + assert!(p.capability.can_read); + } + + #[test] + fn observer_can_only_read() { + let p = + ForgeParticipant::new("did:web:customer.local:audit", ForgeRole::Observer, [0u8; 32]); + assert!(!p.capability.can_execute); + assert!(!p.capability.can_invite); + assert!(!p.capability.can_propose); + assert!(p.capability.can_read); + } + + #[test] + fn participant_leave_sets_left_at() { + let mut p = + ForgeParticipant::new("did:web:msp.local:eng:alice", ForgeRole::Owner, [0u8; 32]); + assert!(p.is_active()); + p.leave(); + assert!(!p.is_active()); + assert!(p.left_at.is_some()); + } +} diff --git a/forge-core/src/proposal.rs b/forge-core/src/proposal.rs new file mode 100644 index 0000000..d27ae91 --- /dev/null +++ b/forge-core/src/proposal.rs @@ -0,0 +1,138 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use ceremony_engine::GovernanceCeremonyRequest; + +/// The lifecycle state of a ForgeProposal. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub enum ForgeProposalState { + /// Proposal submitted, awaiting approval. + Pending, + /// Approved — ready to execute (merge). + Approved, + /// Denied — cannot be executed. A new proposal may be submitted. + Denied, + /// Executed — change merged to canonical. + Executed, +} + +/// A governed change proposal within a ForgeSession. +/// +/// Ties together: the git commit, the ceremony request, +/// the proposer's DID and accord, and the approval outcome. +/// +/// Only one proposal can be active at a time in a ForgeSession. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ForgeProposal { + pub proposal_id: Uuid, + pub session_id: Uuid, + pub proposer_did: String, + pub accord_hash: [u8; 32], + pub message: String, + pub commit_sha: String, + pub state: ForgeProposalState, + pub proposed_at: DateTime, + pub resolved_at: Option>, + pub approver_did: Option, + pub denial_reason: Option, + /// The backing CeremonyEngine request for this proposal. + pub ceremony: GovernanceCeremonyRequest, +} + +impl ForgeProposal { + pub fn new( + session_id: Uuid, + proposer_did: impl Into, + accord_hash: [u8; 32], + message: impl Into, + commit_sha: impl Into, + ceremony: GovernanceCeremonyRequest, + ) -> Self { + Self { + proposal_id: Uuid::now_v7(), + session_id, + proposer_did: proposer_did.into(), + accord_hash, + message: message.into(), + commit_sha: commit_sha.into(), + state: ForgeProposalState::Pending, + proposed_at: Utc::now(), + resolved_at: None, + approver_did: None, + denial_reason: None, + ceremony, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use accord_core::schema::{CeremonyReqs, CeremonyType}; + use ceremony_engine::{CeremonyEngine, CeremonySubject}; + + fn test_ceremony() -> GovernanceCeremonyRequest { + CeremonyEngine::create_request( + Uuid::now_v7().to_string(), + &CeremonyType::SingleApproval, + &CeremonyReqs::default(), + CeremonySubject::Custom { + subject_type: "forge-proposal".to_string(), + reference_id: "test".to_string(), + description: "test proposal".to_string(), + }, + 24, + ) + } + + #[test] + fn new_proposal_is_pending() { + let p = ForgeProposal::new( + Uuid::now_v7(), + "did:web:msp.local:eng:alice", + [0u8; 32], + "fix: timeout", + "abc1234", + test_ceremony(), + ); + assert_eq!(p.state, ForgeProposalState::Pending); + assert!(p.resolved_at.is_none()); + assert!(p.approver_did.is_none()); + } + + #[test] + fn proposal_fields_preserved() { + let p = ForgeProposal::new( + Uuid::now_v7(), + "did:web:msp.local:eng:alice", + [0u8; 32], + "fix: timeout", + "deadbeef", + test_ceremony(), + ); + assert_eq!(p.message, "fix: timeout"); + assert_eq!(p.commit_sha, "deadbeef"); + } + + #[test] + fn proposal_id_is_unique() { + let p1 = ForgeProposal::new( + Uuid::now_v7(), + "did:web:test", + [0u8; 32], + "a", + "a", + test_ceremony(), + ); + let p2 = ForgeProposal::new( + Uuid::now_v7(), + "did:web:test", + [0u8; 32], + "b", + "b", + test_ceremony(), + ); + assert_ne!(p1.proposal_id, p2.proposal_id); + } +} diff --git a/forge-core/src/session.rs b/forge-core/src/session.rs new file mode 100644 index 0000000..49e6e26 --- /dev/null +++ b/forge-core/src/session.rs @@ -0,0 +1,768 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use accord_core::schema::{CeremonyReqs, CeremonyType}; +use ceremony_engine::{ApprovalDecision, CeremonyEngine, CeremonySubject}; + +use crate::chronicle::{ForgeChronicleEvent, ForgeEventKind}; +use crate::invitation::{ForgeInvitation, InvitationError}; +use crate::participant::{ForgeParticipant, ForgeRole, ParticipantCapability}; +use crate::proposal::{ForgeProposal, ForgeProposalState}; + +/// The lifecycle state of a ForgeSession. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub enum ForgeSessionState { + Active, + CeremonyInProgress, + /// Ceremony approved — awaiting merge execution. + ReadyToExecute, + Closed, + Abandoned, +} + +/// The type of artifact this ForgeSession governs. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub enum ForgeArtifact { + Workspace { + worktree_path: String, + branch_name: String, + base_commit: String, + }, + Schematic { + schematic_hash: [u8; 32], + }, +} + +/// A governed multi-principal collaboration session. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ForgeSession { + pub session_id: Uuid, + pub name: String, + pub artifact: ForgeArtifact, + pub state: ForgeSessionState, + pub participants: Vec, + pub invitations: Vec, + pub chronicle: Vec, + /// The currently active proposal (if any). + pub active_proposal: Option, + /// History of all proposals (for Chronicle). + pub proposals: Vec, + pub opened_at: DateTime, + pub closed_at: Option>, +} + +/// Summary for listing sessions. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ForgeSessionSummary { + pub session_id: Uuid, + pub name: String, + pub state: ForgeSessionState, + pub participant_count: usize, + pub opened_at: DateTime, +} + +#[derive(Debug, thiserror::Error)] +pub enum ForgeError { + #[error("session is not active")] + NotActive, + + #[error("participant not found: {0}")] + ParticipantNotFound(String), + + #[error("insufficient capability for this action")] + InsufficientCapability, + + #[error("invitation error: {0}")] + Invitation(#[from] InvitationError), + + #[error("session already closed")] + AlreadyClosed, + + #[error("ceremony already in progress")] + CeremonyInProgress, + + #[error("no active proposal in this session")] + NoActiveProposal, + + #[error("a proposal is already pending — approve or deny it first")] + ProposalAlreadyPending, + + #[error("proposal is not approved — run 'forge approve' first")] + ProposalNotApproved, + + #[error("ceremony error: {0}")] + Ceremony(String), +} + +impl ForgeSession { + /// Open a new ForgeSession. The opener becomes the Owner. + pub fn open( + name: impl Into, + artifact: ForgeArtifact, + owner_did: impl Into, + accord_hash: [u8; 32], + ) -> (Self, ForgeChronicleEvent) { + let session_id = Uuid::now_v7(); + let owner_did = owner_did.into(); + let name = name.into(); + + let owner = ForgeParticipant::new(owner_did.clone(), ForgeRole::Owner, accord_hash); + + let evt = ForgeChronicleEvent::new( + session_id, + ForgeEventKind::ForgeSessionOpened, + &owner_did, + accord_hash, + serde_json::json!({ + "name": &name, + "artifact_type": artifact_type_str(&artifact), + }), + ); + + let session = Self { + session_id, + name, + artifact, + state: ForgeSessionState::Active, + participants: vec![owner], + invitations: vec![], + chronicle: vec![evt.clone()], + active_proposal: None, + proposals: vec![], + opened_at: Utc::now(), + closed_at: None, + }; + + (session, evt) + } + + /// Invite a principal to join. Only Owner can invite. + pub fn invite( + &mut self, + inviter_did: &str, + invitee_did: impl Into, + role: ForgeRole, + expires_in: u64, + ) -> Result<(ForgeInvitation, ForgeChronicleEvent), ForgeError> { + self.require_active()?; + self.require_capability(inviter_did, |c| c.can_invite)?; + + let invitee_did = invitee_did.into(); + let inv = ForgeInvitation::new( + self.session_id, + invitee_did.clone(), + role, + inviter_did, + expires_in, + ); + + let accord_hash = self.participant_accord(inviter_did); + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeInvitationCreated, + inviter_did, + accord_hash, + serde_json::json!({ + "invitee_did": &invitee_did, + "role": inv.role, + "invitation_id": inv.invitation_id.to_string(), + }), + ); + + self.invitations.push(inv.clone()); + self.chronicle.push(evt.clone()); + Ok((inv, evt)) + } + + /// Accept an invitation and join the session. + pub fn join( + &mut self, + invitee_did: &str, + accord_hash: [u8; 32], + invitation_id: Uuid, + ) -> Result { + self.require_active()?; + + let inv = self + .invitations + .iter_mut() + .find(|i| i.invitation_id == invitation_id && i.invitee_did == invitee_did) + .ok_or_else(|| ForgeError::ParticipantNotFound(invitee_did.to_string()))?; + + inv.accept()?; + + let role = inv.role.clone(); + let participant = ForgeParticipant::new(invitee_did, role, accord_hash); + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeParticipantJoined, + invitee_did, + accord_hash, + serde_json::json!({"role": participant.role}), + ); + + self.participants.push(participant); + self.chronicle.push(evt.clone()); + Ok(evt) + } + + /// A participant leaves the session. + pub fn leave(&mut self, participant_did: &str) -> Result { + let p = self + .participants + .iter_mut() + .find(|p| p.did == participant_did && p.is_active()) + .ok_or_else(|| ForgeError::ParticipantNotFound(participant_did.to_string()))?; + + let accord_hash = p.accord_hash; + p.leave(); + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeParticipantLeft, + participant_did, + accord_hash, + serde_json::json!({}), + ); + + self.chronicle.push(evt.clone()); + Ok(evt) + } + + /// Close the session normally. + pub fn close(&mut self, closer_did: &str) -> Result { + self.require_active()?; + self.require_capability(closer_did, |c| c.can_execute)?; + + self.state = ForgeSessionState::Closed; + self.closed_at = Some(Utc::now()); + + let accord_hash = self.participant_accord(closer_did); + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeSessionClosed, + closer_did, + accord_hash, + serde_json::json!({ + "participant_count": self.participants.len(), + "chronicle_events": self.chronicle.len(), + }), + ); + + self.chronicle.push(evt.clone()); + Ok(evt) + } + + /// Abandon the session — no changes executed, clean teardown. + pub fn abandon(&mut self, abandoner_did: &str) -> Result { + self.require_active()?; + self.require_capability(abandoner_did, |c| c.can_execute)?; + + self.state = ForgeSessionState::Abandoned; + self.closed_at = Some(Utc::now()); + + let accord_hash = self.participant_accord(abandoner_did); + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeSessionAbandoned, + abandoner_did, + accord_hash, + serde_json::json!({}), + ); + + self.chronicle.push(evt.clone()); + Ok(evt) + } + + pub fn summary(&self) -> ForgeSessionSummary { + ForgeSessionSummary { + session_id: self.session_id, + name: self.name.clone(), + state: self.state.clone(), + participant_count: self.active_participants().count(), + opened_at: self.opened_at, + } + } + + pub fn active_participants(&self) -> impl Iterator { + self.participants.iter().filter(|p| p.is_active()) + } + + // ── ceremony methods ───────────────────── + + /// Propose a change. Creates a CeremonyEngine request. + /// Transitions: Active → CeremonyInProgress. + pub fn propose( + &mut self, + proposer_did: &str, + accord_hash: [u8; 32], + message: impl Into, + commit_sha: impl Into, + ) -> Result<(ForgeProposal, ForgeChronicleEvent), ForgeError> { + // Check for pending proposal first — gives a more specific error + // than "session is not active" when state is CeremonyInProgress. + if let Some(ref p) = self.active_proposal { + if matches!(p.state, ForgeProposalState::Pending | ForgeProposalState::Approved) { + return Err(ForgeError::ProposalAlreadyPending); + } + } + + self.require_active()?; + self.require_capability(proposer_did, |c| c.can_propose)?; + + let message = message.into(); + let commit_sha = commit_sha.into(); + + // Create ceremony request via CeremonyEngine + let ceremony = CeremonyEngine::create_request( + Uuid::now_v7().to_string(), + &CeremonyType::SingleApproval, + &CeremonyReqs { + approver_roles: Some(vec!["owner".to_string()]), + ..Default::default() + }, + CeremonySubject::Custom { + subject_type: "forge-proposal".to_string(), + reference_id: self.session_id.to_string(), + description: message.clone(), + }, + 24, // 24 hour TTL + ); + + let proposal = ForgeProposal::new( + self.session_id, + proposer_did, + accord_hash, + &message, + &commit_sha, + ceremony, + ); + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeChangeProposed, + proposer_did, + accord_hash, + serde_json::json!({ + "proposal_id": proposal.proposal_id.to_string(), + "commit_sha": &commit_sha, + "message": &message, + "ceremony_id": &proposal.ceremony.ceremony_id, + }), + ); + + self.state = ForgeSessionState::CeremonyInProgress; + self.active_proposal = Some(proposal.clone()); + self.chronicle.push(evt.clone()); + + Ok((proposal, evt)) + } + + /// Approve the active proposal. Requires Owner (can_execute). + /// Transitions: CeremonyInProgress → ReadyToExecute. + pub fn approve( + &mut self, + approver_did: &str, + accord_hash: [u8; 32], + ) -> Result { + self.require_capability(approver_did, |c| c.can_execute)?; + + let proposal = self.active_proposal.as_mut().ok_or(ForgeError::NoActiveProposal)?; + + if proposal.state != ForgeProposalState::Pending { + return Err(ForgeError::NoActiveProposal); + } + + // Record approval in the ceremony request + proposal + .ceremony + .record_decision(approver_did, "owner", ApprovalDecision::Approve, None) + .map_err(|e| ForgeError::Ceremony(e.to_string()))?; + + // Evaluate — should transition to Approved (SingleApproval needs 1) + CeremonyEngine::evaluate(&mut proposal.ceremony); + + proposal.state = ForgeProposalState::Approved; + proposal.resolved_at = Some(Utc::now()); + proposal.approver_did = Some(approver_did.to_string()); + + self.state = ForgeSessionState::ReadyToExecute; + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeChangeApproved, + approver_did, + accord_hash, + serde_json::json!({ + "proposal_id": proposal.proposal_id.to_string(), + "approver": approver_did, + }), + ); + + self.chronicle.push(evt.clone()); + Ok(evt) + } + + /// Deny the active proposal. Returns session to Active. + pub fn deny( + &mut self, + denier_did: &str, + accord_hash: [u8; 32], + reason: Option, + ) -> Result { + self.require_capability(denier_did, |c| c.can_execute)?; + + let proposal = self.active_proposal.as_mut().ok_or(ForgeError::NoActiveProposal)?; + + if proposal.state != ForgeProposalState::Pending { + return Err(ForgeError::NoActiveProposal); + } + + // Record denial in ceremony + proposal + .ceremony + .record_decision( + denier_did, + "owner", + ApprovalDecision::Deny, + reason.clone(), + ) + .map_err(|e| ForgeError::Ceremony(e.to_string()))?; + + CeremonyEngine::evaluate(&mut proposal.ceremony); + + proposal.state = ForgeProposalState::Denied; + proposal.resolved_at = Some(Utc::now()); + proposal.denial_reason = reason.clone(); + + // Move to history, clear active + self.proposals.push(proposal.clone()); + self.active_proposal = None; + self.state = ForgeSessionState::Active; + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeChangeDenied, + denier_did, + accord_hash, + serde_json::json!({ + "reason": reason.as_deref().unwrap_or(""), + }), + ); + + self.chronicle.push(evt.clone()); + Ok(evt) + } + + /// Mark approved proposal as executed (called after merge succeeds). + /// Transitions: ReadyToExecute → Active. + pub fn mark_executed( + &mut self, + executor_did: &str, + accord_hash: [u8; 32], + merged_sha: &str, + ) -> Result { + if self.state != ForgeSessionState::ReadyToExecute { + return Err(ForgeError::ProposalNotApproved); + } + + let proposal = self.active_proposal.as_mut().ok_or(ForgeError::NoActiveProposal)?; + + if proposal.state != ForgeProposalState::Approved { + return Err(ForgeError::ProposalNotApproved); + } + + proposal.state = ForgeProposalState::Executed; + + // Move to history, clear active + self.proposals.push(proposal.clone()); + self.active_proposal = None; + self.state = ForgeSessionState::Active; + + let evt = ForgeChronicleEvent::new( + self.session_id, + ForgeEventKind::ForgeChangeExecuted, + executor_did, + accord_hash, + serde_json::json!({ + "merged_sha": merged_sha, + }), + ); + + self.chronicle.push(evt.clone()); + Ok(evt) + } + + // ── helpers ────────────────────────────── + + fn require_active(&self) -> Result<(), ForgeError> { + if self.state != ForgeSessionState::Active { + Err(ForgeError::NotActive) + } else { + Ok(()) + } + } + + fn require_capability( + &self, + did: &str, + check: impl Fn(&ParticipantCapability) -> bool, + ) -> Result<(), ForgeError> { + let p = self + .participants + .iter() + .find(|p| p.did == did && p.is_active()) + .ok_or_else(|| ForgeError::ParticipantNotFound(did.to_string()))?; + + if check(&p.capability) { + Ok(()) + } else { + Err(ForgeError::InsufficientCapability) + } + } + + fn participant_accord(&self, did: &str) -> [u8; 32] { + self.participants + .iter() + .find(|p| p.did == did) + .map(|p| p.accord_hash) + .unwrap_or([0u8; 32]) + } +} + +fn artifact_type_str(a: &ForgeArtifact) -> &str { + match a { + ForgeArtifact::Workspace { .. } => "workspace", + ForgeArtifact::Schematic { .. } => "schematic", + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn workspace_artifact() -> ForgeArtifact { + ForgeArtifact::Workspace { + worktree_path: "/forge/sessions/test".into(), + branch_name: "session-test".into(), + base_commit: "abc1234".into(), + } + } + + #[test] + fn open_creates_owner_participant() { + let (session, evt) = ForgeSession::open( + "test-session", + workspace_artifact(), + "did:web:msp.local:eng:alice", + [0u8; 32], + ); + assert_eq!(session.participants.len(), 1); + assert_eq!(session.participants[0].role, ForgeRole::Owner); + assert_eq!(evt.kind, ForgeEventKind::ForgeSessionOpened); + } + + #[test] + fn invite_and_join_flow() { + let (mut session, _) = ForgeSession::open( + "test-session", + workspace_artifact(), + "did:web:msp.local:eng:alice", + [0u8; 32], + ); + + let (inv, _) = session + .invite( + "did:web:msp.local:eng:alice", + "did:web:isv.local:eng:bob", + ForgeRole::Collaborator, + 3600, + ) + .unwrap(); + + session + .join("did:web:isv.local:eng:bob", [1u8; 32], inv.invitation_id) + .unwrap(); + + assert_eq!(session.active_participants().count(), 2); + } + + #[test] + fn collaborator_cannot_invite() { + let (mut session, _) = ForgeSession::open( + "test-session", + workspace_artifact(), + "did:web:msp.local:eng:alice", + [0u8; 32], + ); + + let (inv, _) = session + .invite( + "did:web:msp.local:eng:alice", + "did:web:isv.local:eng:bob", + ForgeRole::Collaborator, + 3600, + ) + .unwrap(); + + session + .join("did:web:isv.local:eng:bob", [1u8; 32], inv.invitation_id) + .unwrap(); + + let result = session.invite( + "did:web:isv.local:eng:bob", + "did:web:isv.local:eng:carol", + ForgeRole::Observer, + 3600, + ); + assert!(matches!(result, Err(ForgeError::InsufficientCapability))); + } + + #[test] + fn close_emits_chronicle_event() { + let (mut session, _) = ForgeSession::open( + "test-session", + workspace_artifact(), + "did:web:msp.local:eng:alice", + [0u8; 32], + ); + + let evt = session.close("did:web:msp.local:eng:alice").unwrap(); + assert_eq!(evt.kind, ForgeEventKind::ForgeSessionClosed); + assert_eq!(session.state, ForgeSessionState::Closed); + } + + #[test] + fn cannot_act_on_closed_session() { + let (mut session, _) = ForgeSession::open( + "test-session", + workspace_artifact(), + "did:web:msp.local:eng:alice", + [0u8; 32], + ); + + session.close("did:web:msp.local:eng:alice").unwrap(); + + let result = session.invite( + "did:web:msp.local:eng:alice", + "did:web:isv.local:eng:bob", + ForgeRole::Observer, + 3600, + ); + assert!(matches!(result, Err(ForgeError::NotActive))); + } + + #[test] + fn chronicle_grows_with_each_event() { + let (mut session, _) = ForgeSession::open( + "test-session", + workspace_artifact(), + "did:web:msp.local:eng:alice", + [0u8; 32], + ); + assert_eq!(session.chronicle.len(), 1); + + let (inv, _) = session + .invite( + "did:web:msp.local:eng:alice", + "did:web:isv.local:eng:bob", + ForgeRole::Collaborator, + 3600, + ) + .unwrap(); + assert_eq!(session.chronicle.len(), 2); + + session + .join("did:web:isv.local:eng:bob", [1u8; 32], inv.invitation_id) + .unwrap(); + assert_eq!(session.chronicle.len(), 3); + } + + // ── ceremony tests ────────────────────── + + const ALICE: &str = "did:web:msp.local:eng:alice"; + + #[test] + fn propose_transitions_to_ceremony_in_progress() { + let (mut s, _) = ForgeSession::open("test", workspace_artifact(), ALICE, [0u8; 32]); + + let (proposal, evt) = s.propose(ALICE, [0u8; 32], "fix: timeout", "abc1234").unwrap(); + + assert_eq!(s.state, ForgeSessionState::CeremonyInProgress); + assert!(s.active_proposal.is_some()); + assert_eq!(proposal.state, ForgeProposalState::Pending); + assert_eq!(evt.kind, ForgeEventKind::ForgeChangeProposed); + } + + #[test] + fn propose_requires_active_state() { + let (mut s, _) = ForgeSession::open("test", workspace_artifact(), ALICE, [0u8; 32]); + + s.propose(ALICE, [0u8; 32], "first", "abc").unwrap(); + let result = s.propose(ALICE, [0u8; 32], "second", "def"); + + assert!(matches!(result, Err(ForgeError::ProposalAlreadyPending))); + } + + #[test] + fn approve_transitions_to_ready_to_execute() { + let (mut s, _) = ForgeSession::open("test", workspace_artifact(), ALICE, [0u8; 32]); + + s.propose(ALICE, [0u8; 32], "fix", "abc").unwrap(); + let evt = s.approve(ALICE, [0u8; 32]).unwrap(); + + assert_eq!(s.state, ForgeSessionState::ReadyToExecute); + assert_eq!(s.active_proposal.as_ref().unwrap().state, ForgeProposalState::Approved); + assert_eq!(evt.kind, ForgeEventKind::ForgeChangeApproved); + } + + #[test] + fn deny_returns_session_to_active() { + let (mut s, _) = ForgeSession::open("test", workspace_artifact(), ALICE, [0u8; 32]); + + s.propose(ALICE, [0u8; 32], "fix", "abc").unwrap(); + let evt = s.deny(ALICE, [0u8; 32], None).unwrap(); + + assert_eq!(s.state, ForgeSessionState::Active); + assert!(s.active_proposal.is_none()); + assert_eq!(s.proposals.len(), 1); + assert_eq!(s.proposals[0].state, ForgeProposalState::Denied); + assert_eq!(evt.kind, ForgeEventKind::ForgeChangeDenied); + } + + #[test] + fn mark_executed_requires_ready_to_execute() { + let (mut s, _) = ForgeSession::open("test", workspace_artifact(), ALICE, [0u8; 32]); + + s.propose(ALICE, [0u8; 32], "fix", "abc").unwrap(); + // Try to execute without approving + let result = s.mark_executed(ALICE, [0u8; 32], "merged123"); + + assert!(matches!(result, Err(ForgeError::ProposalNotApproved))); + } + + #[test] + fn full_propose_approve_execute_flow() { + let (mut s, _) = ForgeSession::open("test", workspace_artifact(), ALICE, [0u8; 32]); + assert_eq!(s.chronicle.len(), 1); // opened + + s.propose(ALICE, [0u8; 32], "fix: timeout", "abc1234").unwrap(); + assert_eq!(s.chronicle.len(), 2); // + proposed + + s.approve(ALICE, [0u8; 32]).unwrap(); + assert_eq!(s.chronicle.len(), 3); // + approved + + s.mark_executed(ALICE, [0u8; 32], "merged5678").unwrap(); + assert_eq!(s.chronicle.len(), 4); // + executed + + assert_eq!(s.state, ForgeSessionState::Active); + assert!(s.active_proposal.is_none()); + assert_eq!(s.proposals.len(), 1); + assert_eq!(s.proposals[0].state, ForgeProposalState::Executed); + } +} diff --git a/forge-workspace/Cargo.toml b/forge-workspace/Cargo.toml new file mode 100644 index 0000000..18c2acc --- /dev/null +++ b/forge-workspace/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "forge-workspace" +version = "0.1.0" +edition = "2021" +description = "Git worktree backend for forge-core governed collaboration" + +[dependencies] +forge-core = { workspace = true } + +# Cross-workspace gRPC client dep. +# workspace-controller proto lives in guildhouse. +guildhouse-proto = { path = "../../guildhouse/services/guildhouse-proto" } + +tonic = { workspace = true } +tokio = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +anyhow = { workspace = true } +tracing = { workspace = true } +uuid = { workspace = true } +chrono = { workspace = true } +async-trait = { workspace = true } diff --git a/forge-workspace/src/client.rs b/forge-workspace/src/client.rs new file mode 100644 index 0000000..515e159 --- /dev/null +++ b/forge-workspace/src/client.rs @@ -0,0 +1,190 @@ +//! Workspace-controller gRPC client trait + real implementation. +//! +//! The trait-based design allows MockWorkspaceClient in tests +//! without needing a running workspace-controller. + +use crate::error::WorkspaceError; + +/// Abstraction over workspace-controller gRPC calls. +/// Implemented by `GrpcWorkspaceClient` (real) and +/// `MockWorkspaceClient` (tests). +#[async_trait::async_trait] +pub trait WorkspaceClient: Send + Sync { + /// Create a new workspace. Returns (worktree_path, branch_name, base_commit). + async fn create( + &mut self, + session_id: &str, + base_branch: &str, + author_name: &str, + author_email: &str, + read_only: bool, + ) -> Result<(String, String, String), WorkspaceError>; + + /// Get current diff as unified text. + async fn get_diff(&mut self, session_id: &str) -> Result; + + /// Stage all files and commit. Returns commit SHA. + async fn commit( + &mut self, + session_id: &str, + message: &str, + author_did: &str, + ) -> Result; + + /// Merge session branch to canonical. Returns merged commit SHA. + async fn merge_to_canonical(&mut self, session_id: &str) -> Result; + + /// Destroy the workspace (worktree + branch cleanup). + async fn destroy(&mut self, session_id: &str) -> Result<(), WorkspaceError>; +} + +/// Real gRPC client connecting to workspace-controller. +pub struct GrpcWorkspaceClient { + inner: guildhouse_proto::workspace::v1::workspace_controller_client::WorkspaceControllerClient< + tonic::transport::Channel, + >, +} + +impl GrpcWorkspaceClient { + pub async fn connect(addr: &str) -> Result { + let inner = guildhouse_proto::workspace::v1::workspace_controller_client::WorkspaceControllerClient::connect( + addr.to_string(), + ) + .await?; + Ok(Self { inner }) + } +} + +#[async_trait::async_trait] +impl WorkspaceClient for GrpcWorkspaceClient { + async fn create( + &mut self, + session_id: &str, + base_branch: &str, + author_name: &str, + author_email: &str, + read_only: bool, + ) -> Result<(String, String, String), WorkspaceError> { + let resp = self + .inner + .create_workspace(guildhouse_proto::workspace::v1::CreateWorkspaceRequest { + session_id: session_id.to_string(), + base_branch: base_branch.to_string(), + author_name: author_name.to_string(), + author_email: author_email.to_string(), + read_only, + }) + .await + .map_err(map_grpc_error)? + .into_inner(); + + Ok((resp.workspace_path, resp.branch_name, resp.base_commit)) + } + + async fn get_diff(&mut self, session_id: &str) -> Result { + let resp = self + .inner + .get_diff(guildhouse_proto::workspace::v1::GetDiffRequest { + session_id: session_id.to_string(), + uncommitted_only: false, + }) + .await + .map_err(map_grpc_error)? + .into_inner(); + + let combined: String = resp + .files + .iter() + .map(|f| format!("--- {}\n{}", f.path, f.diff_text)) + .collect::>() + .join("\n"); + + Ok(combined) + } + + async fn commit( + &mut self, + session_id: &str, + message: &str, + author_did: &str, + ) -> Result { + // Stage all files first + self.inner + .stage_files(guildhouse_proto::workspace::v1::StageFilesRequest { + session_id: session_id.to_string(), + paths: vec![], // empty = stage all + }) + .await + .map_err(map_grpc_error)?; + + let resp = self + .inner + .commit(guildhouse_proto::workspace::v1::CommitRequest { + session_id: session_id.to_string(), + message: message.to_string(), + author_name: author_did.to_string(), + author_email: String::new(), + }) + .await + .map_err(map_grpc_error)? + .into_inner(); + + Ok(resp.commit_hash) + } + + async fn merge_to_canonical(&mut self, session_id: &str) -> Result { + // Get the branch name for this session + let status = self + .inner + .get_workspace_status( + guildhouse_proto::workspace::v1::GetWorkspaceStatusRequest { + session_id: session_id.to_string(), + }, + ) + .await + .map_err(map_grpc_error)? + .into_inner(); + + let resp = self + .inner + .merge_to_canonical(guildhouse_proto::workspace::v1::MergeToCanonicalRequest { + branch_name: status.branch_name, + merge_message: format!("forge: merge session {session_id}"), + author_name: String::new(), + author_email: String::new(), + ceremony_id: String::new(), + }) + .await + .map_err(map_grpc_error)? + .into_inner(); + + if !resp.success { + if resp.error.contains("conflict") { + return Err(WorkspaceError::MergeConflict); + } + return Err(WorkspaceError::Unavailable(resp.error)); + } + + Ok(resp.new_head) + } + + async fn destroy(&mut self, session_id: &str) -> Result<(), WorkspaceError> { + self.inner + .destroy_workspace(guildhouse_proto::workspace::v1::DestroyWorkspaceRequest { + session_id: session_id.to_string(), + }) + .await + .map_err(map_grpc_error)?; + + Ok(()) + } +} + +fn map_grpc_error(status: tonic::Status) -> WorkspaceError { + match status.code() { + tonic::Code::NotFound => WorkspaceError::NotFound(status.message().to_string()), + tonic::Code::AlreadyExists => WorkspaceError::AlreadyExists(status.message().to_string()), + tonic::Code::FailedPrecondition => WorkspaceError::MergeConflict, + _ => WorkspaceError::Grpc(status), + } +} diff --git a/forge-workspace/src/error.rs b/forge-workspace/src/error.rs new file mode 100644 index 0000000..05d2204 --- /dev/null +++ b/forge-workspace/src/error.rs @@ -0,0 +1,23 @@ +#[derive(Debug, thiserror::Error)] +pub enum WorkspaceError { + #[error("workspace-controller unavailable: {0}")] + Unavailable(String), + + #[error("workspace not found: {0}")] + NotFound(String), + + #[error("workspace already exists for session: {0}")] + AlreadyExists(String), + + #[error("merge conflict — manual resolution required")] + MergeConflict, + + #[error("gRPC error: {0}")] + Grpc(#[from] tonic::Status), + + #[error("transport error: {0}")] + Transport(#[from] tonic::transport::Error), + + #[error("forge error: {0}")] + Forge(#[from] forge_core::session::ForgeError), +} diff --git a/forge-workspace/src/lib.rs b/forge-workspace/src/lib.rs new file mode 100644 index 0000000..827b079 --- /dev/null +++ b/forge-workspace/src/lib.rs @@ -0,0 +1,16 @@ +//! forge-workspace — git worktree backend for forge-core. +//! +//! Wraps workspace-controller gRPC to provide governed git worktree +//! sessions as the backing artifact for ForgeSession. +//! +//! forge-workspace is the bridge between: +//! forge-core (governance state machine) +//! workspace-controller (git operations) + +pub mod client; +pub mod error; +pub mod session; + +pub use client::{GrpcWorkspaceClient, WorkspaceClient}; +pub use error::WorkspaceError; +pub use session::WorkspaceForgeSession; diff --git a/forge-workspace/src/session.rs b/forge-workspace/src/session.rs new file mode 100644 index 0000000..dfee253 --- /dev/null +++ b/forge-workspace/src/session.rs @@ -0,0 +1,408 @@ +//! WorkspaceForgeSession — drives a ForgeSession backed by a git worktree +//! via workspace-controller gRPC. + +use forge_core::{ForgeArtifact, ForgeChronicleEvent, ForgeEventKind, ForgeSession}; +use uuid::Uuid; + +use crate::client::WorkspaceClient; +use crate::error::WorkspaceError; + +/// A ForgeSession backed by a git worktree. +pub struct WorkspaceForgeSession { + pub session: ForgeSession, + client: C, +} + +impl WorkspaceForgeSession { + /// Open a new governed workspace session. + pub async fn open( + mut client: C, + name: impl Into, + owner_did: impl Into, + accord_hash: [u8; 32], + base_branch: &str, + author_name: &str, + author_email: &str, + read_only: bool, + ) -> Result<(Self, ForgeChronicleEvent), WorkspaceError> { + let owner_did = owner_did.into(); + let name = name.into(); + let session_id = Uuid::now_v7(); + + let (worktree_path, branch_name, base_commit) = client + .create( + &session_id.to_string(), + base_branch, + author_name, + &owner_did, + read_only, + ) + .await?; + + tracing::info!( + session_id = %session_id, + worktree = %worktree_path, + branch = %branch_name, + "workspace created" + ); + + let artifact = ForgeArtifact::Workspace { + worktree_path, + branch_name, + base_commit, + }; + + let (forge_session, evt) = ForgeSession::open(name, artifact, &owner_did, accord_hash); + + Ok(( + Self { + session: forge_session, + client, + }, + evt, + )) + } + + /// Get the current diff. + pub async fn diff(&mut self) -> Result { + self.client + .get_diff(&self.session.session_id.to_string()) + .await + } + + /// Commit current changes. Returns commit SHA + Chronicle event. + pub async fn commit( + &mut self, + message: &str, + author_did: &str, + accord_hash: [u8; 32], + ) -> Result<(String, ForgeChronicleEvent), WorkspaceError> { + let commit_sha = self + .client + .commit(&self.session.session_id.to_string(), message, author_did) + .await?; + + let evt = ForgeChronicleEvent::new( + self.session.session_id, + ForgeEventKind::ForgeChangeProposed, + author_did, + accord_hash, + serde_json::json!({ + "commit_sha": &commit_sha, + "message": message, + }), + ); + + self.session.chronicle.push(evt.clone()); + + tracing::info!( + session_id = %self.session.session_id, + commit = %commit_sha, + author = %author_did, + "change committed" + ); + + Ok((commit_sha, evt)) + } + + /// Merge to canonical branch. Returns merge commit SHA + Chronicle event. + pub async fn execute( + &mut self, + executor_did: &str, + accord_hash: [u8; 32], + ) -> Result<(String, ForgeChronicleEvent), WorkspaceError> { + let merged_sha = self + .client + .merge_to_canonical(&self.session.session_id.to_string()) + .await?; + + let evt = ForgeChronicleEvent::new( + self.session.session_id, + ForgeEventKind::ForgeChangeExecuted, + executor_did, + accord_hash, + serde_json::json!({ + "merged_sha": &merged_sha, + }), + ); + + self.session.chronicle.push(evt.clone()); + + tracing::info!( + session_id = %self.session.session_id, + merged_sha = %merged_sha, + executor = %executor_did, + "change executed — merged to canonical" + ); + + Ok((merged_sha, evt)) + } + + /// Close the session and destroy the worktree. + pub async fn close(&mut self, closer_did: &str) -> Result { + let evt = self + .session + .close(closer_did) + .map_err(WorkspaceError::Forge)?; + + self.client + .destroy(&self.session.session_id.to_string()) + .await?; + + tracing::info!( + session_id = %self.session.session_id, + "session closed, worktree destroyed" + ); + + Ok(evt) + } + + /// Abandon the session — no changes merged. Destroys worktree. + pub async fn abandon( + &mut self, + abandoner_did: &str, + ) -> Result { + let evt = self + .session + .abandon(abandoner_did) + .map_err(WorkspaceError::Forge)?; + + self.client + .destroy(&self.session.session_id.to_string()) + .await?; + + tracing::info!( + session_id = %self.session.session_id, + "session abandoned, worktree destroyed" + ); + + Ok(evt) + } + + /// Full Chronicle log. + pub fn chronicle(&self) -> &[ForgeChronicleEvent] { + &self.session.chronicle + } + + /// Current worktree path. + pub fn worktree_path(&self) -> Option<&str> { + match &self.session.artifact { + ForgeArtifact::Workspace { worktree_path, .. } => Some(worktree_path), + _ => None, + } + } + + /// Current branch name. + pub fn branch_name(&self) -> Option<&str> { + match &self.session.artifact { + ForgeArtifact::Workspace { branch_name, .. } => Some(branch_name), + _ => None, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::client::WorkspaceClient; + use forge_core::{ForgeEventKind, ForgeSessionState}; + use std::sync::{Arc, Mutex}; + + /// Mock workspace-controller client for testing. + struct MockWorkspaceClient { + calls: Arc>>, + } + + impl MockWorkspaceClient { + fn new() -> Self { + Self { + calls: Arc::new(Mutex::new(Vec::new())), + } + } + + fn call_log(&self) -> Vec { + self.calls.lock().unwrap().clone() + } + } + + #[async_trait::async_trait] + impl WorkspaceClient for MockWorkspaceClient { + async fn create( + &mut self, + session_id: &str, + _base_branch: &str, + _author_name: &str, + _author_email: &str, + _read_only: bool, + ) -> Result<(String, String, String), WorkspaceError> { + self.calls.lock().unwrap().push(format!("create:{session_id}")); + Ok(( + "/mock/worktrees/test".to_string(), + "session-test".to_string(), + "abc1234".to_string(), + )) + } + + async fn get_diff(&mut self, session_id: &str) -> Result { + self.calls.lock().unwrap().push(format!("get_diff:{session_id}")); + Ok("mock diff output".to_string()) + } + + async fn commit( + &mut self, + session_id: &str, + _message: &str, + _author_did: &str, + ) -> Result { + self.calls.lock().unwrap().push(format!("commit:{session_id}")); + Ok("deadbeef1234".to_string()) + } + + async fn merge_to_canonical( + &mut self, + session_id: &str, + ) -> Result { + self.calls + .lock() + .unwrap() + .push(format!("merge_to_canonical:{session_id}")); + Ok("merged5678abcd".to_string()) + } + + async fn destroy(&mut self, session_id: &str) -> Result<(), WorkspaceError> { + self.calls.lock().unwrap().push(format!("destroy:{session_id}")); + Ok(()) + } + } + + #[tokio::test] + async fn test_open_creates_session_with_worktree() { + let mock = MockWorkspaceClient::new(); + + let (ws, evt) = WorkspaceForgeSession::open( + mock, + "test-session", + "did:web:msp.local:eng:alice", + [0u8; 32], + "main", + "Alice", + "alice@test.com", + false, + ) + .await + .unwrap(); + + assert_eq!(ws.session.state, ForgeSessionState::Active); + assert_eq!(ws.worktree_path(), Some("/mock/worktrees/test")); + assert_eq!(ws.branch_name(), Some("session-test")); + assert_eq!(ws.chronicle().len(), 1); + assert_eq!(evt.kind, ForgeEventKind::ForgeSessionOpened); + } + + #[tokio::test] + async fn test_commit_emits_chronicle_event() { + let mock = MockWorkspaceClient::new(); + let (mut ws, _) = WorkspaceForgeSession::open( + mock, + "test-session", + "did:web:msp.local:eng:alice", + [0u8; 32], + "main", + "Alice", + "alice@test.com", + false, + ) + .await + .unwrap(); + + let (sha, evt) = ws + .commit("fix: thing", "did:web:msp.local:eng:alice", [0u8; 32]) + .await + .unwrap(); + + assert_eq!(sha, "deadbeef1234"); + assert_eq!(evt.kind, ForgeEventKind::ForgeChangeProposed); + assert_eq!(ws.chronicle().len(), 2); + assert!(evt.payload.get("commit_sha").is_some()); + } + + #[tokio::test] + async fn test_execute_emits_chronicle_event() { + let mock = MockWorkspaceClient::new(); + let (mut ws, _) = WorkspaceForgeSession::open( + mock, + "test-session", + "did:web:msp.local:eng:alice", + [0u8; 32], + "main", + "Alice", + "alice@test.com", + false, + ) + .await + .unwrap(); + + ws.commit("fix: thing", "did:web:msp.local:eng:alice", [0u8; 32]) + .await + .unwrap(); + + let (sha, evt) = ws + .execute("did:web:msp.local:eng:alice", [0u8; 32]) + .await + .unwrap(); + + assert_eq!(sha, "merged5678abcd"); + assert_eq!(evt.kind, ForgeEventKind::ForgeChangeExecuted); + assert!(evt.payload.get("merged_sha").is_some()); + } + + #[tokio::test] + async fn test_close_destroys_worktree() { + let mock = MockWorkspaceClient::new(); + let calls = mock.calls.clone(); + + let (mut ws, _) = WorkspaceForgeSession::open( + mock, + "test-session", + "did:web:msp.local:eng:alice", + [0u8; 32], + "main", + "Alice", + "alice@test.com", + false, + ) + .await + .unwrap(); + + ws.close("did:web:msp.local:eng:alice").await.unwrap(); + + assert_eq!(ws.session.state, ForgeSessionState::Closed); + let log = calls.lock().unwrap(); + assert!(log.iter().any(|c| c.starts_with("destroy:"))); + } + + #[tokio::test] + async fn test_abandon_destroys_worktree() { + let mock = MockWorkspaceClient::new(); + let calls = mock.calls.clone(); + + let (mut ws, _) = WorkspaceForgeSession::open( + mock, + "test-session", + "did:web:msp.local:eng:alice", + [0u8; 32], + "main", + "Alice", + "alice@test.com", + false, + ) + .await + .unwrap(); + + ws.abandon("did:web:msp.local:eng:alice").await.unwrap(); + + assert_eq!(ws.session.state, ForgeSessionState::Abandoned); + let log = calls.lock().unwrap(); + assert!(log.iter().any(|c| c.starts_with("destroy:"))); + } +} diff --git a/forge/Cargo.toml b/forge/Cargo.toml new file mode 100644 index 0000000..cc06b55 --- /dev/null +++ b/forge/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "forge" +version = "0.1.0" +edition = "2021" +description = "Governed collaboration CLI — the Substrate equivalent of git" + +[[bin]] +name = "forge" +path = "src/main.rs" + +[dependencies] +forge-core = { workspace = true } +forge-workspace = { workspace = true } + +tokio = { workspace = true } +tonic = { workspace = true } +clap = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +anyhow = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } +uuid = { workspace = true } +chrono = { workspace = true } diff --git a/forge/src/approve.rs b/forge/src/approve.rs new file mode 100644 index 0000000..5c5281d --- /dev/null +++ b/forge/src/approve.rs @@ -0,0 +1,31 @@ +use crate::ForgeContext; + +pub async fn run(ctx: ForgeContext, proposal_id: Option) -> anyhow::Result<()> { + // Phase A: approve = immediately ready to merge (ceremony stub). + // Phase B: validate approver role, call CeremonyEngine::approve(), + // check accord permits approval. + + let evt = forge_core::ForgeChronicleEvent::new( + uuid::Uuid::parse_str(&ctx.session_id)?, + forge_core::ForgeEventKind::ForgeChangeApproved, + &ctx.caller_did, + ctx.accord_hash, + serde_json::json!({ + "proposal_id": proposal_id.map(|id| id.to_string()).unwrap_or_else(|| "latest".to_string()), + "approver": &ctx.caller_did, + }), + ); + + println!( + "Approved.\n\ + Session: {}\n\ + Approver: {}\n\ + \n\ + Ready to merge. Run:\n forge merge", + ctx.session_id, ctx.caller_did, + ); + + tracing::info!(event_id = %evt.event_id, "FORGE_CHANGE_APPROVED emitted"); + + Ok(()) +} diff --git a/forge/src/deny.rs b/forge/src/deny.rs new file mode 100644 index 0000000..74113e1 --- /dev/null +++ b/forge/src/deny.rs @@ -0,0 +1,34 @@ +use crate::ForgeContext; + +pub async fn run( + ctx: ForgeContext, + proposal_id: Option, + reason: String, +) -> anyhow::Result<()> { + let evt = forge_core::ForgeChronicleEvent::new( + uuid::Uuid::parse_str(&ctx.session_id)?, + forge_core::ForgeEventKind::ForgeChangeDenied, + &ctx.caller_did, + ctx.accord_hash, + serde_json::json!({ + "proposal_id": proposal_id.map(|id| id.to_string()).unwrap_or_else(|| "latest".to_string()), + "reason": &reason, + }), + ); + + println!( + "Denied.\n\ + Session: {}\n\ + Denier: {}\n\ + Reason: {}\n\ + Chronicle: {}", + ctx.session_id, + ctx.caller_did, + if reason.is_empty() { "(no reason given)" } else { &reason }, + evt.event_id, + ); + + tracing::info!(event_id = %evt.event_id, "FORGE_CHANGE_DENIED emitted"); + + Ok(()) +} diff --git a/forge/src/invite.rs b/forge/src/invite.rs new file mode 100644 index 0000000..3d2759a --- /dev/null +++ b/forge/src/invite.rs @@ -0,0 +1,63 @@ +use crate::ForgeContext; + +pub async fn run( + ctx: ForgeContext, + did: String, + role_str: String, + expires_in: u64, +) -> anyhow::Result<()> { + let role = parse_role(&role_str)?; + + // Phase A: create invitation locally. + // Phase B: send via bascule-gateway to notify the invitee. + let inv = forge_core::ForgeInvitation::new( + uuid::Uuid::parse_str(&ctx.session_id)?, + &did, + role, + &ctx.caller_did, + expires_in, + ); + + println!( + "Invitation created.\n\ + Invitee: {}\n\ + Role: {}\n\ + Expires: {} seconds\n\ + ID: {}\n\n\ + Share this invitation ID with the invitee.\n\ + They run:\n forge join --invitation-id {}", + did, role_str, expires_in, inv.invitation_id, inv.invitation_id, + ); + + Ok(()) +} + +fn parse_role(s: &str) -> anyhow::Result { + match s { + "owner" => Ok(forge_core::ForgeRole::Owner), + "collaborator" => Ok(forge_core::ForgeRole::Collaborator), + "observer" => Ok(forge_core::ForgeRole::Observer), + other => anyhow::bail!( + "Unknown role: '{}'. Valid roles: owner, collaborator, observer", + other + ), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_role_collaborator() { + let role = parse_role("collaborator").unwrap(); + assert_eq!(role, forge_core::ForgeRole::Collaborator); + } + + #[test] + fn parse_role_invalid_returns_error() { + let result = parse_role("admin"); + assert!(result.is_err()); + assert!(result.unwrap_err().to_string().contains("Unknown role")); + } +} diff --git a/forge/src/log.rs b/forge/src/log.rs new file mode 100644 index 0000000..58a94ee --- /dev/null +++ b/forge/src/log.rs @@ -0,0 +1,41 @@ +use forge_core::chronicle::{ChronicleClient, ForgeLogQuery}; + +use crate::ForgeContext; + +pub async fn run( + ctx: ForgeContext, + session: Option, + limit: u64, + json: bool, + kind: Option, +) -> anyhow::Result<()> { + let client = ChronicleClient::new(); + let query = ForgeLogQuery { + // Default to the current session if --session not provided. + session_id: session.or_else(|| Some(ctx.session_id.clone())), + limit, + kind_filter: kind, + }; + + let entries = client.query_forge_log(&query).await; + + if json { + println!( + "{}", + serde_json::to_string_pretty(&entries).unwrap_or_else(|_| "[]".to_string()) + ); + } else if entries.is_empty() { + println!( + "No forge events found.\n\ + (Chronicle warm tier running?)" + ); + } else { + for entry in &entries { + println!("{}", entry.display()); + println!("---"); + } + println!("{} event(s)", entries.len()); + } + + Ok(()) +} diff --git a/forge/src/main.rs b/forge/src/main.rs new file mode 100644 index 0000000..43b628e --- /dev/null +++ b/forge/src/main.rs @@ -0,0 +1,203 @@ +mod approve; +mod deny; +mod invite; +mod log; +mod merge; +mod propose; +mod review; +mod status; + +use clap::{Parser, Subcommand}; + +/// Session context loaded from environment. +/// Set by `bascule attach workspace/{name}`. +#[derive(Debug)] +pub struct ForgeContext { + pub session_id: String, + pub token: String, + pub gateway: String, + pub workspace_path: Option, + pub workspace_addr: String, + pub caller_did: String, + pub accord_hash: [u8; 32], +} + +impl ForgeContext { + pub fn from_env() -> anyhow::Result { + Ok(Self { + session_id: require_env("BASCULE_SESSION_ID")?, + token: require_env("BASCULE_TOKEN")?, + gateway: require_env("BASCULE_GATEWAY")?, + workspace_path: std::env::var("BASCULE_WORKSPACE").ok(), + workspace_addr: std::env::var("FORGE_WORKSPACE_ADDR").unwrap_or_else(|_| { + "http://workspace-controller.guildhouse-system.svc.cluster.local:50051".to_string() + }), + // Phase A: DID from env. Phase B: resolve from token. + caller_did: std::env::var("BASCULE_DID") + .unwrap_or_else(|_| "did:web:unknown".to_string()), + // Phase A: zeroed hash. Phase B: from active accord. + accord_hash: [0u8; 32], + }) + } +} + +fn require_env(key: &str) -> anyhow::Result { + std::env::var(key).map_err(|_| { + anyhow::anyhow!( + "Missing required env var: {}\nRun 'bascule attach workspace/{{name}}' first.", + key + ) + }) +} + +#[derive(Parser, Debug)] +#[command(name = "forge", about = "Governed collaboration — the Substrate equivalent of git", version)] +struct Args { + #[command(subcommand)] + command: Commands, +} + +#[derive(Subcommand, Debug)] +enum Commands { + /// Propose a change in the current workspace session. + /// Commits staged changes and initiates the ceremony approval flow. + Propose { + /// Commit message describing the change. + message: String, + }, + + /// Approve a pending proposal. Requires Owner role. + Approve { + /// Specific proposal ID to approve (defaults to most recent). + #[arg(long)] + proposal_id: Option, + }, + + /// Deny a pending proposal. + Deny { + #[arg(long)] + proposal_id: Option, + + #[arg(long, default_value = "")] + reason: String, + }, + + /// Merge an approved proposal to the canonical branch. + Merge, + + /// Invite a principal to join this ForgeSession. Requires Owner role. + Invite { + /// DID of the principal to invite. + did: String, + + /// Role to grant (owner, collaborator, observer). + #[arg(long, default_value = "collaborator")] + role: String, + + /// Invitation expiry in seconds. + #[arg(long, default_value = "3600")] + expires_in: u64, + }, + + /// Show current diff for this session. + Review, + + /// Show session status. + Status, + + /// Show Chronicle event log for this session. + Log { + /// Filter by forge session ID (defaults to current session). + #[arg(long)] + session: Option, + + /// Maximum number of events to display. + #[arg(long, default_value = "50")] + limit: u64, + + /// Output as newline-delimited JSON. + #[arg(long)] + json: bool, + + /// Filter by event kind prefix (e.g. APP_FORGE_CHANGE). + #[arg(long)] + kind: Option, + }, +} + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + tracing_subscriber::fmt() + .with_writer(std::io::stderr) + .with_env_filter( + std::env::var("RUST_LOG").unwrap_or_else(|_| "forge=info".into()), + ) + .init(); + + let args = Args::parse(); + let ctx = ForgeContext::from_env()?; + + match args.command { + Commands::Propose { message } => propose::run(ctx, message).await?, + Commands::Approve { proposal_id } => approve::run(ctx, proposal_id).await?, + Commands::Deny { + proposal_id, + reason, + } => deny::run(ctx, proposal_id, reason).await?, + Commands::Merge => merge::run(ctx).await?, + Commands::Invite { + did, + role, + expires_in, + } => invite::run(ctx, did, role, expires_in).await?, + Commands::Review => review::run(ctx).await?, + Commands::Status => status::run(ctx).await?, + Commands::Log { + session, + limit, + json, + kind, + } => log::run(ctx, session, limit, json, kind).await?, + } + + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn missing_env_returns_clear_error() { + // Ensure the var is unset for this test + std::env::remove_var("BASCULE_SESSION_ID"); + std::env::remove_var("BASCULE_TOKEN"); + std::env::remove_var("BASCULE_GATEWAY"); + + let result = ForgeContext::from_env(); + assert!(result.is_err()); + let err = result.unwrap_err().to_string(); + assert!(err.contains("BASCULE_SESSION_ID"), "error: {err}"); + assert!(err.contains("bascule attach"), "error: {err}"); + } + + #[test] + fn workspace_addr_has_default() { + std::env::set_var("BASCULE_SESSION_ID", "test-id"); + std::env::set_var("BASCULE_TOKEN", "test-token"); + std::env::set_var("BASCULE_GATEWAY", "http://localhost:50052"); + std::env::remove_var("FORGE_WORKSPACE_ADDR"); + + let ctx = ForgeContext::from_env().unwrap(); + assert!( + ctx.workspace_addr.contains("workspace-controller"), + "addr: {}", + ctx.workspace_addr + ); + + // Clean up + std::env::remove_var("BASCULE_SESSION_ID"); + std::env::remove_var("BASCULE_TOKEN"); + std::env::remove_var("BASCULE_GATEWAY"); + } +} diff --git a/forge/src/merge.rs b/forge/src/merge.rs new file mode 100644 index 0000000..c373db8 --- /dev/null +++ b/forge/src/merge.rs @@ -0,0 +1,41 @@ +use crate::ForgeContext; +use forge_workspace::{GrpcWorkspaceClient, WorkspaceClient}; + +pub async fn run(ctx: ForgeContext) -> anyhow::Result<()> { + let mut client = GrpcWorkspaceClient::connect(&ctx.workspace_addr).await?; + + // Phase A: merge without ceremony check. + // Phase B: verify ceremony is APPROVED before calling merge_to_canonical. + // The ceremony gate prevents unauthorized merges. + let merged_sha = client + .merge_to_canonical(&ctx.session_id) + .await + .map_err(|e| anyhow::anyhow!("Merge failed: {e}"))?; + + let evt = forge_core::ForgeChronicleEvent::new( + uuid::Uuid::parse_str(&ctx.session_id)?, + forge_core::ForgeEventKind::ForgeChangeExecuted, + &ctx.caller_did, + ctx.accord_hash, + serde_json::json!({ + "merged_sha": &merged_sha, + "session_id": &ctx.session_id, + }), + ); + + println!( + "Merged.\n\ + Commit: {}\n\ + Session: {}\n\ + Actor: {}\n\ + Chronicle: {}", + &merged_sha[..8.min(merged_sha.len())], + ctx.session_id, + ctx.caller_did, + evt.event_id, + ); + + tracing::info!(event_id = %evt.event_id, merged_sha = %merged_sha, "FORGE_CHANGE_EXECUTED emitted"); + + Ok(()) +} diff --git a/forge/src/propose.rs b/forge/src/propose.rs new file mode 100644 index 0000000..6d27a1b --- /dev/null +++ b/forge/src/propose.rs @@ -0,0 +1,45 @@ +use crate::ForgeContext; +use forge_workspace::{GrpcWorkspaceClient, WorkspaceClient}; + +pub async fn run(ctx: ForgeContext, message: String) -> anyhow::Result<()> { + let mut client = GrpcWorkspaceClient::connect(&ctx.workspace_addr).await?; + + // Phase A: commit directly via workspace-controller. + // Phase B: open a WorkspaceForgeSession and go through + // the full propose → ceremony → execute flow. + + // Stage all + commit + let commit_sha = client + .commit(&ctx.session_id, &message, &ctx.caller_did) + .await + .map_err(|e| anyhow::anyhow!("Commit failed: {e}"))?; + + println!( + "Proposed: {}\n\ + Commit: {}\n\ + \n\ + Ceremony approval required.\n\ + Waiting for: Owner approval\n\ + \n\ + Notify approver to run:\n forge approve", + message, + &commit_sha[..8.min(commit_sha.len())], + ); + + // Phase A: Chronicle event emitted to tracing only. + // Phase B: write to Chronicle via bascule-gateway. + let evt = forge_core::ForgeChronicleEvent::new( + uuid::Uuid::parse_str(&ctx.session_id)?, + forge_core::ForgeEventKind::ForgeChangeProposed, + &ctx.caller_did, + ctx.accord_hash, + serde_json::json!({ + "commit_sha": &commit_sha, + "message": &message, + }), + ); + + tracing::info!(event_id = %evt.event_id, "FORGE_CHANGE_PROPOSED emitted"); + + Ok(()) +} diff --git a/forge/src/review.rs b/forge/src/review.rs new file mode 100644 index 0000000..45d8eb9 --- /dev/null +++ b/forge/src/review.rs @@ -0,0 +1,22 @@ +use crate::ForgeContext; +use forge_workspace::{GrpcWorkspaceClient, WorkspaceClient}; + +pub async fn run(ctx: ForgeContext) -> anyhow::Result<()> { + let mut client = GrpcWorkspaceClient::connect(&ctx.workspace_addr).await?; + + let diff = client + .get_diff(&ctx.session_id) + .await + .map_err(|e| anyhow::anyhow!("Diff failed: {e}"))?; + + if diff.is_empty() { + println!("No changes in this session."); + } else { + println!( + "Session: {}\nActor: {}\n\n--- diff ---\n{}\n--- end diff ---", + ctx.session_id, ctx.caller_did, diff, + ); + } + + Ok(()) +} diff --git a/forge/src/status.rs b/forge/src/status.rs new file mode 100644 index 0000000..8ba513d --- /dev/null +++ b/forge/src/status.rs @@ -0,0 +1,20 @@ +use crate::ForgeContext; + +pub async fn run(ctx: ForgeContext) -> anyhow::Result<()> { + // Phase A: show context from env vars. + // Phase B: query ForgeSession state from forge-workspace or gateway. + + println!( + "Session: {}\n\ + Actor: {}\n\ + Workspace: {}\n\ + Gateway: {}\n\ + State: Active (Phase A stub)", + ctx.session_id, + ctx.caller_did, + ctx.workspace_path.as_deref().unwrap_or("(not set)"), + ctx.gateway, + ); + + Ok(()) +}