From 64365af91e9baed22b8e38e541960d6395267293 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Wed, 24 Jun 2026 02:28:38 +0900 Subject: [PATCH 01/21] Add License descriptions --- crates/feder-core/src/lib.rs | 16 ++++++++++++++++ crates/feder-vocab/src/lib.rs | 16 ++++++++++++++++ crates/feder-vocab/tests/phase1_shapes.rs | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/crates/feder-core/src/lib.rs b/crates/feder-core/src/lib.rs index 8254263..c4c4631 100644 --- a/crates/feder-core/src/lib.rs +++ b/crates/feder-core/src/lib.rs @@ -1,3 +1,19 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + //! Portable ActivityPub core logic for Feder. #![no_std] diff --git a/crates/feder-vocab/src/lib.rs b/crates/feder-vocab/src/lib.rs index f806167..ab1a5b6 100644 --- a/crates/feder-vocab/src/lib.rs +++ b/crates/feder-vocab/src/lib.rs @@ -1,3 +1,19 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + //! Minimal Activity Vocabulary types for Feder. #![no_std] //! diff --git a/crates/feder-vocab/tests/phase1_shapes.rs b/crates/feder-vocab/tests/phase1_shapes.rs index 371e682..2526841 100644 --- a/crates/feder-vocab/tests/phase1_shapes.rs +++ b/crates/feder-vocab/tests/phase1_shapes.rs @@ -1,3 +1,19 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + use feder_vocab::{ ACTIVITYSTREAMS_CONTEXT, Accept, Create, Follow, Iri, Note, Reference, References, }; From bd3c889b822f95ae411df9681357a8a04123f3ab Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Wed, 24 Jun 2026 13:38:31 +0900 Subject: [PATCH 02/21] Add feder-runtime-linux crate --- Cargo.lock | 8 ++++++++ Cargo.toml | 1 + crates/feder-runtime-linux/Cargo.toml | 12 ++++++++++++ crates/feder-runtime-linux/src/lib.rs | 1 + crates/feder-runtime-linux/src/main.rs | 19 +++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 crates/feder-runtime-linux/Cargo.toml create mode 100644 crates/feder-runtime-linux/src/lib.rs create mode 100644 crates/feder-runtime-linux/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 7805f2c..7675367 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,6 +9,14 @@ dependencies = [ "feder-vocab", ] +[[package]] +name = "feder-runtime-linux" +version = "0.1.0" +dependencies = [ + "feder-core", + "feder-vocab", +] + [[package]] name = "feder-vocab" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index c56d565..fe79b67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ members = [ "crates/feder-core", "crates/feder-vocab", + "crates/feder-runtime-linux" ] resolver = "3" diff --git a/crates/feder-runtime-linux/Cargo.toml b/crates/feder-runtime-linux/Cargo.toml new file mode 100644 index 0000000..8f0390d --- /dev/null +++ b/crates/feder-runtime-linux/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "feder-runtime-linux" +version.workspace = true +edition.workspace = true +license.workspace = true + +[dependencies] +feder-core = { path = "../feder-core" } +feder-vocab = { path = "../feder-vocab" } + +[lints] +workspace = true diff --git a/crates/feder-runtime-linux/src/lib.rs b/crates/feder-runtime-linux/src/lib.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/crates/feder-runtime-linux/src/lib.rs @@ -0,0 +1 @@ + diff --git a/crates/feder-runtime-linux/src/main.rs b/crates/feder-runtime-linux/src/main.rs new file mode 100644 index 0000000..ed4509d --- /dev/null +++ b/crates/feder-runtime-linux/src/main.rs @@ -0,0 +1,19 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +fn main() { + println!("feder-runtime-linux starting") +} From 04af867a001fcdb25cab86771da4f4673fc9b83c Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Thu, 25 Jun 2026 13:18:24 +0900 Subject: [PATCH 03/21] Rename crate to feder-runtime-server since it will support Linux, Windows, and Mac OS --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/feder-runtime-linux/src/lib.rs | 1 - .../Cargo.toml | 2 +- crates/feder-runtime-server/src/lib.rs | 15 +++++++++++++++ .../src/main.rs | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-) delete mode 100644 crates/feder-runtime-linux/src/lib.rs rename crates/{feder-runtime-linux => feder-runtime-server}/Cargo.toml (87%) create mode 100644 crates/feder-runtime-server/src/lib.rs rename crates/{feder-runtime-linux => feder-runtime-server}/src/main.rs (94%) diff --git a/Cargo.lock b/Cargo.lock index 7675367..583a93f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ dependencies = [ ] [[package]] -name = "feder-runtime-linux" +name = "feder-runtime-server" version = "0.1.0" dependencies = [ "feder-core", diff --git a/Cargo.toml b/Cargo.toml index fe79b67..0ea3ccd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = [ "crates/feder-core", "crates/feder-vocab", - "crates/feder-runtime-linux" + "crates/feder-runtime-server" ] resolver = "3" diff --git a/crates/feder-runtime-linux/src/lib.rs b/crates/feder-runtime-linux/src/lib.rs deleted file mode 100644 index 8b13789..0000000 --- a/crates/feder-runtime-linux/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/feder-runtime-linux/Cargo.toml b/crates/feder-runtime-server/Cargo.toml similarity index 87% rename from crates/feder-runtime-linux/Cargo.toml rename to crates/feder-runtime-server/Cargo.toml index 8f0390d..44935e8 100644 --- a/crates/feder-runtime-linux/Cargo.toml +++ b/crates/feder-runtime-server/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "feder-runtime-linux" +name = "feder-runtime-server" version.workspace = true edition.workspace = true license.workspace = true diff --git a/crates/feder-runtime-server/src/lib.rs b/crates/feder-runtime-server/src/lib.rs new file mode 100644 index 0000000..f2bdf75 --- /dev/null +++ b/crates/feder-runtime-server/src/lib.rs @@ -0,0 +1,15 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . diff --git a/crates/feder-runtime-linux/src/main.rs b/crates/feder-runtime-server/src/main.rs similarity index 94% rename from crates/feder-runtime-linux/src/main.rs rename to crates/feder-runtime-server/src/main.rs index ed4509d..7f362f6 100644 --- a/crates/feder-runtime-linux/src/main.rs +++ b/crates/feder-runtime-server/src/main.rs @@ -15,5 +15,5 @@ // along with this program. If not, see . fn main() { - println!("feder-runtime-linux starting") + println!("feder-runtime-server starting") } From 87e64ac27a2cb924c687d858fcba816a2c634384 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Thu, 25 Jun 2026 16:48:06 +0900 Subject: [PATCH 04/21] Add server entry point that consumes config from env --- crates/feder-runtime-server/src/app.rs | 26 ++++++++++++++++++++ crates/feder-runtime-server/src/config.rs | 29 +++++++++++++++++++++++ crates/feder-runtime-server/src/error.rs | 17 +++++++++++++ crates/feder-runtime-server/src/lib.rs | 4 ++++ crates/feder-runtime-server/src/main.rs | 13 ++++++++-- 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 crates/feder-runtime-server/src/app.rs create mode 100644 crates/feder-runtime-server/src/config.rs create mode 100644 crates/feder-runtime-server/src/error.rs diff --git a/crates/feder-runtime-server/src/app.rs b/crates/feder-runtime-server/src/app.rs new file mode 100644 index 0000000..6437c6e --- /dev/null +++ b/crates/feder-runtime-server/src/app.rs @@ -0,0 +1,26 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +use crate::config::RuntimeConfig; +use axum::{Router, routing::get}; + +pub fn build_router(_config: &RuntimeConfig) -> Result { + Ok(Router::new().route("/healthz", get(healthz))) +} + +async fn healthz() -> &'static str { + "ok" +} diff --git a/crates/feder-runtime-server/src/config.rs b/crates/feder-runtime-server/src/config.rs new file mode 100644 index 0000000..763cc3f --- /dev/null +++ b/crates/feder-runtime-server/src/config.rs @@ -0,0 +1,29 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +use std::net::SocketAddr; + +pub struct RuntimeConfig { + pub bind: SocketAddr, +} + +impl RuntimeConfig { + pub fn from_env() -> Result { + Ok(Self { + bind: "127.0.0.1:3000".parse()?, + }) + } +} diff --git a/crates/feder-runtime-server/src/error.rs b/crates/feder-runtime-server/src/error.rs new file mode 100644 index 0000000..30ba25c --- /dev/null +++ b/crates/feder-runtime-server/src/error.rs @@ -0,0 +1,17 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +pub type Error = Box; diff --git a/crates/feder-runtime-server/src/lib.rs b/crates/feder-runtime-server/src/lib.rs index f2bdf75..193ab15 100644 --- a/crates/feder-runtime-server/src/lib.rs +++ b/crates/feder-runtime-server/src/lib.rs @@ -13,3 +13,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . + +pub mod app; +pub mod config; +pub mod error; diff --git a/crates/feder-runtime-server/src/main.rs b/crates/feder-runtime-server/src/main.rs index 7f362f6..844ce70 100644 --- a/crates/feder-runtime-server/src/main.rs +++ b/crates/feder-runtime-server/src/main.rs @@ -14,6 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -fn main() { - println!("feder-runtime-server starting") +use feder_runtime_server::{app::build_router, config::RuntimeConfig, error::Error}; + +#[tokio::main] +async fn main() -> Result<(), Error> { + let config = RuntimeConfig::from_env()?; + let app = build_router(&config)?; + + let listener = tokio::net::TcpListener::bind(config.bind).await?; + axum::serve(listener, app).await?; + + Ok(()) } From e91d12e4f833b9544e494ada39110be78d4ccdcd Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Fri, 26 Jun 2026 03:00:55 +0900 Subject: [PATCH 05/21] Add RuntimeConfig and tracing --- Cargo.lock | 516 ++++++++++++++++++++++ crates/feder-runtime-server/Cargo.toml | 4 + crates/feder-runtime-server/src/config.rs | 24 +- crates/feder-runtime-server/src/main.rs | 7 +- 4 files changed, 546 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 583a93f..8b549d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,85 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "axum" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "bytes" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + [[package]] name = "feder-core" version = "0.1.0" @@ -13,8 +92,12 @@ dependencies = [ name = "feder-runtime-server" version = "0.1.0" dependencies = [ + "axum", "feder-core", "feder-vocab", + "tokio", + "tracing", + "tracing-subscriber", ] [[package]] @@ -26,6 +109,128 @@ dependencies = [ "serde_json", ] +[[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-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 = "http" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6970f50e31d6fc17d3fa27329444bfa74e196cf62e95052a3f6fee181dba6425" +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.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55281c53a1894c864990125767da440a4e630446785086f52523b20033b74498" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "bytes", + "http", + "http-body", + "hyper", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "iri-string" version = "0.7.12" @@ -41,12 +246,89 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "log" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" + +[[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.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "memchr" version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" +dependencies = [ + "libc", + "wasi", + "windows-sys", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + [[package]] name = "proc-macro2" version = "1.0.106" @@ -65,6 +347,29 @@ dependencies = [ "proc-macro2", ] +[[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.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + [[package]] name = "serde" version = "1.0.228" @@ -108,6 +413,60 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[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 = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + +[[package]] +name = "socket2" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "syn" version = "2.0.117" @@ -119,12 +478,169 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[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 = "tokio" +version = "1.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +dependencies = [ + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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", + "tracing", +] + +[[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 = [ + "log", + "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-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", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + [[package]] name = "unicode-ident" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + [[package]] name = "zmij" version = "1.0.21" diff --git a/crates/feder-runtime-server/Cargo.toml b/crates/feder-runtime-server/Cargo.toml index 44935e8..d47ac66 100644 --- a/crates/feder-runtime-server/Cargo.toml +++ b/crates/feder-runtime-server/Cargo.toml @@ -7,6 +7,10 @@ license.workspace = true [dependencies] feder-core = { path = "../feder-core" } feder-vocab = { path = "../feder-vocab" } +axum = "0.8" +tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] workspace = true diff --git a/crates/feder-runtime-server/src/config.rs b/crates/feder-runtime-server/src/config.rs index 763cc3f..838d714 100644 --- a/crates/feder-runtime-server/src/config.rs +++ b/crates/feder-runtime-server/src/config.rs @@ -16,14 +16,30 @@ use std::net::SocketAddr; +use feder_vocab::Iri; + pub struct RuntimeConfig { pub bind: SocketAddr, + pub actor_id: Iri, + pub inbox: Iri, + pub outbox: Iri, } impl RuntimeConfig { - pub fn from_env() -> Result { - Ok(Self { - bind: "127.0.0.1:3000".parse()?, - }) + pub fn default_local() -> Self { + Self { + actor_id: "http://127.0.0.1:3000/users/alice" + .parse() + .expect("valid default actor IRI"), + inbox: "http://127.0.0.1:3000/users/alice/inbox" + .parse() + .expect("valid default inbox IRI"), + outbox: "http://127.0.0.1:3000/users/alice/outbox" + .parse() + .expect("valid default outbox IRI"), + bind: "127.0.0.1:3000" + .parse() + .expect("valid default bind address"), + } } } diff --git a/crates/feder-runtime-server/src/main.rs b/crates/feder-runtime-server/src/main.rs index 844ce70..ba8bf09 100644 --- a/crates/feder-runtime-server/src/main.rs +++ b/crates/feder-runtime-server/src/main.rs @@ -18,11 +18,16 @@ use feder_runtime_server::{app::build_router, config::RuntimeConfig, error::Erro #[tokio::main] async fn main() -> Result<(), Error> { - let config = RuntimeConfig::from_env()?; + let config = RuntimeConfig::default_local(); let app = build_router(&config)?; let listener = tokio::net::TcpListener::bind(config.bind).await?; axum::serve(listener, app).await?; + tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .init(); + tracing::info!(bind = %&config.bind, actor = %&config.actor_id, "Starting Feder runtime"); + Ok(()) } From 954d837c9824bb296988de7aea33ded85ff4612b Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Fri, 26 Jun 2026 17:08:20 +0900 Subject: [PATCH 06/21] Add AppState and attach it to the server --- crates/feder-runtime-server/src/app.rs | 33 +++++++++++++++++++++++-- crates/feder-runtime-server/src/main.rs | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/crates/feder-runtime-server/src/app.rs b/crates/feder-runtime-server/src/app.rs index 6437c6e..5581ebc 100644 --- a/crates/feder-runtime-server/src/app.rs +++ b/crates/feder-runtime-server/src/app.rs @@ -14,11 +14,40 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +use std::sync::{Arc, Mutex}; + use crate::config::RuntimeConfig; use axum::{Router, routing::get}; +use feder_core::{FederConfig, FederCore}; +use feder_vocab::Actor; + +#[derive(Clone)] +pub struct AppState { + pub core: Arc>, +} + +impl AppState { + pub fn from_config(config: &RuntimeConfig) -> Self { + let actor = Actor::person( + config.actor_id.clone(), + config.inbox.clone(), + config.outbox.clone(), + ); + + let core = FederCore::new(FederConfig::new(actor)); + + Self { + core: Arc::new(Mutex::new(core)), + } + } +} + +pub fn build_router(config: &RuntimeConfig) -> Router { + let state = AppState::from_config(config); -pub fn build_router(_config: &RuntimeConfig) -> Result { - Ok(Router::new().route("/healthz", get(healthz))) + Router::new() + .route("/healthz", get(healthz)) + .with_state(state) } async fn healthz() -> &'static str { diff --git a/crates/feder-runtime-server/src/main.rs b/crates/feder-runtime-server/src/main.rs index ba8bf09..e80d7ef 100644 --- a/crates/feder-runtime-server/src/main.rs +++ b/crates/feder-runtime-server/src/main.rs @@ -19,7 +19,7 @@ use feder_runtime_server::{app::build_router, config::RuntimeConfig, error::Erro #[tokio::main] async fn main() -> Result<(), Error> { let config = RuntimeConfig::default_local(); - let app = build_router(&config)?; + let app = build_router(&config); let listener = tokio::net::TcpListener::bind(config.bind).await?; axum::serve(listener, app).await?; From 2d3c74d85e7eecdb8503f376bb85f88ba2032b72 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Fri, 26 Jun 2026 17:57:30 +0900 Subject: [PATCH 07/21] Document runtime server startup Assisted-by: Codex:gpt-5.5 --- Cargo.toml | 2 +- crates/feder-runtime-server/README.md | 40 +++++++++++++++++++++++++ crates/feder-runtime-server/src/app.rs | 6 ++-- crates/feder-runtime-server/src/main.rs | 11 +++---- 4 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 crates/feder-runtime-server/README.md diff --git a/Cargo.toml b/Cargo.toml index 0ea3ccd..b7439be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = [ "crates/feder-core", "crates/feder-vocab", - "crates/feder-runtime-server" + "crates/feder-runtime-server", ] resolver = "3" diff --git a/crates/feder-runtime-server/README.md b/crates/feder-runtime-server/README.md new file mode 100644 index 0000000..b2ae621 --- /dev/null +++ b/crates/feder-runtime-server/README.md @@ -0,0 +1,40 @@ +Feder Runtime Server +==================== + +Runnable server runtime for Feder on standard operating systems. + +This crate currently starts a local development server with one configured +actor and a health check endpoint. ActivityPub discovery, inbox handling, +storage, signing, and delivery are intentionally left to later issues. + + +Run +--- + +~~~~ sh +RUST_LOG=info cargo run -p feder-runtime-server +~~~~ + +The default local actor is: + +~~~~ text +http://127.0.0.1:3000/users/alice +~~~~ + +The server listens on: + +~~~~ text +127.0.0.1:3000 +~~~~ + +Check the process: + +~~~~ sh +curl -i http://127.0.0.1:3000/healthz +~~~~ + +Expected response: + +~~~~ text +HTTP/1.1 204 No Content +~~~~ diff --git a/crates/feder-runtime-server/src/app.rs b/crates/feder-runtime-server/src/app.rs index 5581ebc..0480a75 100644 --- a/crates/feder-runtime-server/src/app.rs +++ b/crates/feder-runtime-server/src/app.rs @@ -17,7 +17,7 @@ use std::sync::{Arc, Mutex}; use crate::config::RuntimeConfig; -use axum::{Router, routing::get}; +use axum::{Router, http::StatusCode, routing::get}; use feder_core::{FederConfig, FederCore}; use feder_vocab::Actor; @@ -50,6 +50,6 @@ pub fn build_router(config: &RuntimeConfig) -> Router { .with_state(state) } -async fn healthz() -> &'static str { - "ok" +async fn healthz() -> StatusCode { + StatusCode::NO_CONTENT } diff --git a/crates/feder-runtime-server/src/main.rs b/crates/feder-runtime-server/src/main.rs index e80d7ef..92dfcee 100644 --- a/crates/feder-runtime-server/src/main.rs +++ b/crates/feder-runtime-server/src/main.rs @@ -18,16 +18,17 @@ use feder_runtime_server::{app::build_router, config::RuntimeConfig, error::Erro #[tokio::main] async fn main() -> Result<(), Error> { + tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .init(); + let config = RuntimeConfig::default_local(); let app = build_router(&config); + tracing::info!(bind = %&config.bind, actor = %&config.actor_id, "starting Feder runtime"); + let listener = tokio::net::TcpListener::bind(config.bind).await?; axum::serve(listener, app).await?; - tracing_subscriber::fmt() - .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) - .init(); - tracing::info!(bind = %&config.bind, actor = %&config.actor_id, "Starting Feder runtime"); - Ok(()) } From 0520f978f3fdcafce56f96c5e05421085ebe1798 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Fri, 26 Jun 2026 18:21:45 +0900 Subject: [PATCH 08/21] Add cross-platform Cargo test CI Assisted-by: Codex:gpt-5.5 --- .github/workflows/main.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0b0c314..029ac60 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -20,3 +20,18 @@ jobs: key: rustup-v1-${{ runner.os }}-${{ hashFiles('mise.toml') }} - uses: jdx/mise-action@v4 - run: mise run check + + cross-platform: + name: cargo test (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + steps: + - uses: actions/checkout@v6 + - uses: dtolnay/rust-toolchain@stable + - run: cargo test --workspace From 833c4d14471b24626d6991cce40e6c9c81d728ff Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Mon, 29 Jun 2026 00:55:57 +0900 Subject: [PATCH 09/21] Document Windows runtime server startup Assisted-by: Codex:gpt-5.5 --- crates/feder-runtime-server/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/feder-runtime-server/README.md b/crates/feder-runtime-server/README.md index b2ae621..77a93c1 100644 --- a/crates/feder-runtime-server/README.md +++ b/crates/feder-runtime-server/README.md @@ -11,10 +11,24 @@ storage, signing, and delivery are intentionally left to later issues. Run --- +On Unix shells: + ~~~~ sh RUST_LOG=info cargo run -p feder-runtime-server ~~~~ +On PowerShell: + +~~~~ powershell +$env:RUST_LOG = "info"; cargo run -p feder-runtime-server +~~~~ + +On cmd.exe: + +~~~~ bat +set RUST_LOG=info && cargo run -p feder-runtime-server +~~~~ + The default local actor is: ~~~~ text From 170b961f83647f49ce155567493d9fbf6572790a Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Mon, 29 Jun 2026 01:24:35 +0900 Subject: [PATCH 10/21] Update license description to allow only 3.0 --- crates/feder-core/src/lib.rs | 3 +-- crates/feder-runtime-server/src/app.rs | 3 +-- crates/feder-runtime-server/src/config.rs | 3 +-- crates/feder-runtime-server/src/error.rs | 3 +-- crates/feder-runtime-server/src/lib.rs | 3 +-- crates/feder-runtime-server/src/main.rs | 3 +-- crates/feder-vocab/src/lib.rs | 3 +-- crates/feder-vocab/tests/phase1_shapes.rs | 3 +-- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/crates/feder-core/src/lib.rs b/crates/feder-core/src/lib.rs index c4c4631..4808aea 100644 --- a/crates/feder-core/src/lib.rs +++ b/crates/feder-core/src/lib.rs @@ -3,8 +3,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/crates/feder-runtime-server/src/app.rs b/crates/feder-runtime-server/src/app.rs index 0480a75..bff8682 100644 --- a/crates/feder-runtime-server/src/app.rs +++ b/crates/feder-runtime-server/src/app.rs @@ -3,8 +3,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/crates/feder-runtime-server/src/config.rs b/crates/feder-runtime-server/src/config.rs index 838d714..d0bd2bd 100644 --- a/crates/feder-runtime-server/src/config.rs +++ b/crates/feder-runtime-server/src/config.rs @@ -3,8 +3,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/crates/feder-runtime-server/src/error.rs b/crates/feder-runtime-server/src/error.rs index 30ba25c..ae2a010 100644 --- a/crates/feder-runtime-server/src/error.rs +++ b/crates/feder-runtime-server/src/error.rs @@ -3,8 +3,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/crates/feder-runtime-server/src/lib.rs b/crates/feder-runtime-server/src/lib.rs index 193ab15..dcf01c5 100644 --- a/crates/feder-runtime-server/src/lib.rs +++ b/crates/feder-runtime-server/src/lib.rs @@ -3,8 +3,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/crates/feder-runtime-server/src/main.rs b/crates/feder-runtime-server/src/main.rs index 92dfcee..00da4f8 100644 --- a/crates/feder-runtime-server/src/main.rs +++ b/crates/feder-runtime-server/src/main.rs @@ -3,8 +3,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/crates/feder-vocab/src/lib.rs b/crates/feder-vocab/src/lib.rs index ab1a5b6..7e6ca95 100644 --- a/crates/feder-vocab/src/lib.rs +++ b/crates/feder-vocab/src/lib.rs @@ -3,8 +3,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/crates/feder-vocab/tests/phase1_shapes.rs b/crates/feder-vocab/tests/phase1_shapes.rs index 2526841..043f477 100644 --- a/crates/feder-vocab/tests/phase1_shapes.rs +++ b/crates/feder-vocab/tests/phase1_shapes.rs @@ -3,8 +3,7 @@ // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of From b8fe0ab2481253906792bc4993fe219c276049ec Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Mon, 29 Jun 2026 01:36:23 +0900 Subject: [PATCH 11/21] Add typed server runtime errors Assisted-by: Codex:gpt-5.5 --- Cargo.lock | 21 +++++++++++++++++++++ crates/feder-runtime-server/Cargo.toml | 1 + crates/feder-runtime-server/src/error.rs | 9 ++++++++- crates/feder-runtime-server/src/main.rs | 6 ++++-- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b549d7..ccab5e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,6 +95,7 @@ dependencies = [ "axum", "feder-core", "feder-vocab", + "thiserror", "tokio", "tracing", "tracing-subscriber", @@ -484,6 +485,26 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +[[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" diff --git a/crates/feder-runtime-server/Cargo.toml b/crates/feder-runtime-server/Cargo.toml index d47ac66..e9621d3 100644 --- a/crates/feder-runtime-server/Cargo.toml +++ b/crates/feder-runtime-server/Cargo.toml @@ -8,6 +8,7 @@ license.workspace = true feder-core = { path = "../feder-core" } feder-vocab = { path = "../feder-vocab" } axum = "0.8" +thiserror = "2" tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/crates/feder-runtime-server/src/error.rs b/crates/feder-runtime-server/src/error.rs index ae2a010..b6b8276 100644 --- a/crates/feder-runtime-server/src/error.rs +++ b/crates/feder-runtime-server/src/error.rs @@ -13,4 +13,11 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -pub type Error = Box; +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("failed to bind server socket")] + Bind(#[source] std::io::Error), + + #[error("server failed")] + Serve(#[source] std::io::Error), +} diff --git a/crates/feder-runtime-server/src/main.rs b/crates/feder-runtime-server/src/main.rs index 00da4f8..a13027b 100644 --- a/crates/feder-runtime-server/src/main.rs +++ b/crates/feder-runtime-server/src/main.rs @@ -26,8 +26,10 @@ async fn main() -> Result<(), Error> { tracing::info!(bind = %&config.bind, actor = %&config.actor_id, "starting Feder runtime"); - let listener = tokio::net::TcpListener::bind(config.bind).await?; - axum::serve(listener, app).await?; + let listener = tokio::net::TcpListener::bind(config.bind) + .await + .map_err(Error::Bind)?; + axum::serve(listener, app).await.map_err(Error::Serve)?; Ok(()) } From aceee502ef271231c5bf53fb6f57c63c9b6b7112 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Tue, 30 Jun 2026 15:45:45 +0900 Subject: [PATCH 12/21] Add webfinger query handling with default config --- Cargo.lock | 1 + crates/feder-runtime-server/Cargo.toml | 1 + crates/feder-runtime-server/src/app.rs | 10 ++- crates/feder-runtime-server/src/config.rs | 4 ++ crates/feder-runtime-server/src/lib.rs | 1 + crates/feder-runtime-server/src/webfinger.rs | 68 ++++++++++++++++++++ 6 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 crates/feder-runtime-server/src/webfinger.rs diff --git a/Cargo.lock b/Cargo.lock index ccab5e7..05553c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,6 +95,7 @@ dependencies = [ "axum", "feder-core", "feder-vocab", + "serde", "thiserror", "tokio", "tracing", diff --git a/crates/feder-runtime-server/Cargo.toml b/crates/feder-runtime-server/Cargo.toml index e9621d3..6014044 100644 --- a/crates/feder-runtime-server/Cargo.toml +++ b/crates/feder-runtime-server/Cargo.toml @@ -12,6 +12,7 @@ thiserror = "2" tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } +serde.workspace = true [lints] workspace = true diff --git a/crates/feder-runtime-server/src/app.rs b/crates/feder-runtime-server/src/app.rs index bff8682..50df99e 100644 --- a/crates/feder-runtime-server/src/app.rs +++ b/crates/feder-runtime-server/src/app.rs @@ -16,13 +16,17 @@ use std::sync::{Arc, Mutex}; use crate::config::RuntimeConfig; +use crate::webfinger::webfinger; use axum::{Router, http::StatusCode, routing::get}; use feder_core::{FederConfig, FederCore}; -use feder_vocab::Actor; +use feder_vocab::{Actor, Iri}; #[derive(Clone)] pub struct AppState { pub core: Arc>, + pub actor_id: Iri, + pub username: String, + pub handle_host: String, } impl AppState { @@ -37,6 +41,9 @@ impl AppState { Self { core: Arc::new(Mutex::new(core)), + actor_id: config.actor_id.clone(), + username: config.username.clone(), + handle_host: config.handle_host.clone(), } } } @@ -46,6 +53,7 @@ pub fn build_router(config: &RuntimeConfig) -> Router { Router::new() .route("/healthz", get(healthz)) + .route("/.well-known/webfinger", get(webfinger)) .with_state(state) } diff --git a/crates/feder-runtime-server/src/config.rs b/crates/feder-runtime-server/src/config.rs index d0bd2bd..80edbc2 100644 --- a/crates/feder-runtime-server/src/config.rs +++ b/crates/feder-runtime-server/src/config.rs @@ -22,6 +22,8 @@ pub struct RuntimeConfig { pub actor_id: Iri, pub inbox: Iri, pub outbox: Iri, + pub username: String, + pub handle_host: String, } impl RuntimeConfig { @@ -39,6 +41,8 @@ impl RuntimeConfig { bind: "127.0.0.1:3000" .parse() .expect("valid default bind address"), + username: "alice".to_string(), + handle_host: "127.0.0.1:3000".to_string(), } } } diff --git a/crates/feder-runtime-server/src/lib.rs b/crates/feder-runtime-server/src/lib.rs index dcf01c5..ffcf6c1 100644 --- a/crates/feder-runtime-server/src/lib.rs +++ b/crates/feder-runtime-server/src/lib.rs @@ -16,3 +16,4 @@ pub mod app; pub mod config; pub mod error; +pub mod webfinger; diff --git a/crates/feder-runtime-server/src/webfinger.rs b/crates/feder-runtime-server/src/webfinger.rs new file mode 100644 index 0000000..7ee6eaa --- /dev/null +++ b/crates/feder-runtime-server/src/webfinger.rs @@ -0,0 +1,68 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +use axum::{ + Json, + extract::{Query, State}, + http::StatusCode, +}; +use serde::{Deserialize, Serialize}; + +use crate::app::AppState; + +#[derive(Deserialize)] +pub struct WebFingerQuery { + resource: Option, +} + +#[derive(Serialize)] +pub struct WebFingerResponse { + subject: String, + aliases: Vec, + links: Vec, +} + +#[derive(Serialize)] +pub struct WebFingerLink { + rel: &'static str, + #[serde(rename = "type")] + media_type: &'static str, + href: String, +} +pub async fn webfinger( + State(state): State, + Query(query): Query, +) -> Result, StatusCode> { + let Some(resource) = query.resource else { + return Err(StatusCode::BAD_REQUEST); + }; + + let expected = format!("acct:{}@{}", state.username, state.handle_host); + if resource != expected { + return Err(StatusCode::NOT_FOUND); + } + + let actor_id = state.actor_id.to_string(); + + Ok(Json(WebFingerResponse { + subject: resource, + aliases: vec![actor_id.clone()], + links: vec![WebFingerLink { + rel: "self", + media_type: "application/activity+json", + href: actor_id, + }], + })) +} From c09097d0b28a5735f09b41b539ada916e15fa3dc Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Tue, 30 Jun 2026 16:24:27 +0900 Subject: [PATCH 13/21] Add response header and return response --- crates/feder-runtime-server/src/webfinger.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/feder-runtime-server/src/webfinger.rs b/crates/feder-runtime-server/src/webfinger.rs index 7ee6eaa..fcfc5ab 100644 --- a/crates/feder-runtime-server/src/webfinger.rs +++ b/crates/feder-runtime-server/src/webfinger.rs @@ -14,9 +14,7 @@ // along with this program. If not, see . use axum::{ - Json, - extract::{Query, State}, - http::StatusCode, + Json, extract::{Query, State}, http::{StatusCode, header}, response::{IntoResponse, Response}, }; use serde::{Deserialize, Serialize}; @@ -44,7 +42,7 @@ pub struct WebFingerLink { pub async fn webfinger( State(state): State, Query(query): Query, -) -> Result, StatusCode> { +) -> Result { let Some(resource) = query.resource else { return Err(StatusCode::BAD_REQUEST); }; @@ -56,7 +54,9 @@ pub async fn webfinger( let actor_id = state.actor_id.to_string(); - Ok(Json(WebFingerResponse { + Ok(( + [(header::CONTENT_TYPE, "application/jrd+json")], + Json(WebFingerResponse { subject: resource, aliases: vec![actor_id.clone()], links: vec![WebFingerLink { @@ -64,5 +64,6 @@ pub async fn webfinger( media_type: "application/activity+json", href: actor_id, }], - })) + }), + ).into_response()) } From 82da624c67db22e9ac05695208b4465b2850a7ab Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Tue, 30 Jun 2026 16:32:52 +0900 Subject: [PATCH 14/21] Add mise run test command --- mise.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mise.toml b/mise.toml index 8da167b..966f131 100644 --- a/mise.toml +++ b/mise.toml @@ -23,3 +23,7 @@ run = [ [tasks.fmt] description = "Format code and docs" run = ["cargo fmt", "hongdown --write", "mise fmt"] + +[tasks.test] +description = "Run the Rust tests" +run = "cargo test" From 0121411095bf1f8ce067a23b7821e68510c7ea79 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Tue, 30 Jun 2026 16:36:06 +0900 Subject: [PATCH 15/21] Test WebFinger discovery responses Assisted-by: Codex:gpt-5.5 --- Cargo.lock | 2 + crates/feder-runtime-server/Cargo.toml | 4 + crates/feder-runtime-server/src/webfinger.rs | 108 +++++++++++++++++-- 3 files changed, 104 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05553c5..e730504 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,8 +96,10 @@ dependencies = [ "feder-core", "feder-vocab", "serde", + "serde_json", "thiserror", "tokio", + "tower", "tracing", "tracing-subscriber", ] diff --git a/crates/feder-runtime-server/Cargo.toml b/crates/feder-runtime-server/Cargo.toml index 6014044..cd1cc4f 100644 --- a/crates/feder-runtime-server/Cargo.toml +++ b/crates/feder-runtime-server/Cargo.toml @@ -14,5 +14,9 @@ tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } serde.workspace = true +[dev-dependencies] +serde_json.workspace = true +tower = "0.5" + [lints] workspace = true diff --git a/crates/feder-runtime-server/src/webfinger.rs b/crates/feder-runtime-server/src/webfinger.rs index fcfc5ab..c190e12 100644 --- a/crates/feder-runtime-server/src/webfinger.rs +++ b/crates/feder-runtime-server/src/webfinger.rs @@ -14,7 +14,10 @@ // along with this program. If not, see . use axum::{ - Json, extract::{Query, State}, http::{StatusCode, header}, response::{IntoResponse, Response}, + Json, + extract::{Query, State}, + http::{StatusCode, header}, + response::{IntoResponse, Response}, }; use serde::{Deserialize, Serialize}; @@ -39,6 +42,7 @@ pub struct WebFingerLink { media_type: &'static str, href: String, } + pub async fn webfinger( State(state): State, Query(query): Query, @@ -57,13 +61,97 @@ pub async fn webfinger( Ok(( [(header::CONTENT_TYPE, "application/jrd+json")], Json(WebFingerResponse { - subject: resource, - aliases: vec![actor_id.clone()], - links: vec![WebFingerLink { - rel: "self", - media_type: "application/activity+json", - href: actor_id, - }], - }), - ).into_response()) + subject: resource, + aliases: vec![actor_id.clone()], + links: vec![WebFingerLink { + rel: "self", + media_type: "application/activity+json", + href: actor_id, + }], + }), + ) + .into_response()) +} + +#[cfg(test)] +mod tests { + use axum::{ + body::{Body, to_bytes}, + http::{Request, StatusCode, header}, + }; + use serde_json::Value; + use tower::ServiceExt; + + use crate::{app::build_router, config::RuntimeConfig}; + + const WEBFINGER_PATH: &str = "/.well-known/webfinger?resource=acct:alice@127.0.0.1:3000"; + + #[tokio::test] + async fn returns_webfinger_descriptor_for_local_actor() { + let app = build_router(&RuntimeConfig::default_local()); + + let response = app + .oneshot( + Request::builder() + .uri(WEBFINGER_PATH) + .body(Body::empty()) + .expect("valid request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::OK); + assert_eq!( + response.headers().get(header::CONTENT_TYPE).unwrap(), + "application/jrd+json" + ); + + let body = to_bytes(response.into_body(), 1024) + .await + .expect("read response body"); + let json: Value = serde_json::from_slice(&body).expect("valid json"); + + assert_eq!(json["subject"], "acct:alice@127.0.0.1:3000"); + assert_eq!(json["aliases"][0], "http://127.0.0.1:3000/users/alice"); + assert_eq!(json["links"][0]["rel"], "self"); + assert_eq!(json["links"][0]["type"], "application/activity+json"); + assert_eq!( + json["links"][0]["href"], + "http://127.0.0.1:3000/users/alice" + ); + } + + #[tokio::test] + async fn rejects_missing_resource() { + let app = build_router(&RuntimeConfig::default_local()); + + let response = app + .oneshot( + Request::builder() + .uri("/.well-known/webfinger") + .body(Body::empty()) + .expect("valid request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::BAD_REQUEST); + } + + #[tokio::test] + async fn rejects_non_local_actor_resource() { + let app = build_router(&RuntimeConfig::default_local()); + + let response = app + .oneshot( + Request::builder() + .uri("/.well-known/webfinger?resource=acct:bob@127.0.0.1:3000") + .body(Body::empty()) + .expect("valid request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::NOT_FOUND); + } } From 6278df4348a9bd816398ef9ce43c0a5145bc59a6 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Wed, 1 Jul 2026 13:28:18 +0900 Subject: [PATCH 16/21] Implement actor endpoint Expose GET /users/{username} from the server runtime and return the configured local actor as application/activity+json. Keep the local actor in AppState and pass a clone into FederCore so HTTP serving does not need to lock the core state. --- crates/feder-runtime-server/src/actor.rs | 40 ++++++++++++++++++++ crates/feder-runtime-server/src/app.rs | 14 ++++--- crates/feder-runtime-server/src/config.rs | 2 + crates/feder-runtime-server/src/lib.rs | 1 + crates/feder-runtime-server/src/webfinger.rs | 2 +- 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 crates/feder-runtime-server/src/actor.rs diff --git a/crates/feder-runtime-server/src/actor.rs b/crates/feder-runtime-server/src/actor.rs new file mode 100644 index 0000000..3e5e2cc --- /dev/null +++ b/crates/feder-runtime-server/src/actor.rs @@ -0,0 +1,40 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +use axum::{ + Json, + extract::{Path, State}, + http::{StatusCode, header}, + response::{IntoResponse, Response}, +}; + +use crate::app::AppState; + +pub async fn actor( + State(app_state): State, + Path(username): Path, +) -> Result { + if username != app_state.username { + return Err(StatusCode::NOT_FOUND); + } + // FederCore + let actor = app_state.local_actor.clone(); + + Ok(( + [(header::CONTENT_TYPE, "application/activity+json")], + Json(actor), + ) + .into_response()) +} diff --git a/crates/feder-runtime-server/src/app.rs b/crates/feder-runtime-server/src/app.rs index 50df99e..8cca69a 100644 --- a/crates/feder-runtime-server/src/app.rs +++ b/crates/feder-runtime-server/src/app.rs @@ -15,33 +15,36 @@ use std::sync::{Arc, Mutex}; +use crate::actor::actor; use crate::config::RuntimeConfig; use crate::webfinger::webfinger; use axum::{Router, http::StatusCode, routing::get}; use feder_core::{FederConfig, FederCore}; -use feder_vocab::{Actor, Iri}; +use feder_vocab::Actor; #[derive(Clone)] pub struct AppState { pub core: Arc>, - pub actor_id: Iri, + pub local_actor: Actor, pub username: String, pub handle_host: String, } impl AppState { pub fn from_config(config: &RuntimeConfig) -> Self { - let actor = Actor::person( + let mut actor = Actor::person( config.actor_id.clone(), config.inbox.clone(), config.outbox.clone(), ); + actor.preferred_username = Some(config.preferred_username.clone()); + actor.name = Some(config.username.clone()); - let core = FederCore::new(FederConfig::new(actor)); + let core = FederCore::new(FederConfig::new(actor.clone())); Self { core: Arc::new(Mutex::new(core)), - actor_id: config.actor_id.clone(), + local_actor: actor, username: config.username.clone(), handle_host: config.handle_host.clone(), } @@ -54,6 +57,7 @@ pub fn build_router(config: &RuntimeConfig) -> Router { Router::new() .route("/healthz", get(healthz)) .route("/.well-known/webfinger", get(webfinger)) + .route("/users/{username}", get(actor)) .with_state(state) } diff --git a/crates/feder-runtime-server/src/config.rs b/crates/feder-runtime-server/src/config.rs index 80edbc2..f3cd866 100644 --- a/crates/feder-runtime-server/src/config.rs +++ b/crates/feder-runtime-server/src/config.rs @@ -23,6 +23,7 @@ pub struct RuntimeConfig { pub inbox: Iri, pub outbox: Iri, pub username: String, + pub preferred_username: String, pub handle_host: String, } @@ -42,6 +43,7 @@ impl RuntimeConfig { .parse() .expect("valid default bind address"), username: "alice".to_string(), + preferred_username: "alice".to_string(), handle_host: "127.0.0.1:3000".to_string(), } } diff --git a/crates/feder-runtime-server/src/lib.rs b/crates/feder-runtime-server/src/lib.rs index ffcf6c1..2071764 100644 --- a/crates/feder-runtime-server/src/lib.rs +++ b/crates/feder-runtime-server/src/lib.rs @@ -13,6 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +pub mod actor; pub mod app; pub mod config; pub mod error; diff --git a/crates/feder-runtime-server/src/webfinger.rs b/crates/feder-runtime-server/src/webfinger.rs index c190e12..5eeee15 100644 --- a/crates/feder-runtime-server/src/webfinger.rs +++ b/crates/feder-runtime-server/src/webfinger.rs @@ -56,7 +56,7 @@ pub async fn webfinger( return Err(StatusCode::NOT_FOUND); } - let actor_id = state.actor_id.to_string(); + let actor_id = state.local_actor.id.to_string(); Ok(( [(header::CONTENT_TYPE, "application/jrd+json")], From 11e7af09edfcceda3aaa77304eed3d447bfb90c9 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Wed, 1 Jul 2026 13:30:46 +0900 Subject: [PATCH 17/21] Test local ActivityPub actor endpoint Cover the configured local actor route, unknown usernames, response content type, and serialized ActivityPub actor fields. Assisted-by: Codex:gpt-5.5 --- crates/feder-runtime-server/src/actor.rs | 68 ++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/crates/feder-runtime-server/src/actor.rs b/crates/feder-runtime-server/src/actor.rs index 3e5e2cc..daf6028 100644 --- a/crates/feder-runtime-server/src/actor.rs +++ b/crates/feder-runtime-server/src/actor.rs @@ -29,12 +29,74 @@ pub async fn actor( if username != app_state.username { return Err(StatusCode::NOT_FOUND); } - // FederCore - let actor = app_state.local_actor.clone(); + let local_actor = app_state.local_actor.clone(); Ok(( [(header::CONTENT_TYPE, "application/activity+json")], - Json(actor), + Json(local_actor), ) .into_response()) } + +#[cfg(test)] +mod tests { + use axum::{ + body::{Body, to_bytes}, + http::{Request, StatusCode, header}, + }; + use serde_json::Value; + use tower::ServiceExt; + + use crate::{app::build_router, config::RuntimeConfig}; + + #[tokio::test] + async fn returns_local_actor() { + let app = build_router(&RuntimeConfig::default_local()); + + let response = app + .oneshot( + Request::builder() + .uri("/users/alice") + .body(Body::empty()) + .expect("valid request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::OK); + assert_eq!( + response.headers().get(header::CONTENT_TYPE).unwrap(), + "application/activity+json" + ); + + let body = to_bytes(response.into_body(), 2048) + .await + .expect("read response body"); + let json: Value = serde_json::from_slice(&body).expect("valid json"); + + assert_eq!(json["@context"], "https://www.w3.org/ns/activitystreams"); + assert_eq!(json["type"], "Person"); + assert_eq!(json["id"], "http://127.0.0.1:3000/users/alice"); + assert_eq!(json["inbox"], "http://127.0.0.1:3000/users/alice/inbox"); + assert_eq!(json["outbox"], "http://127.0.0.1:3000/users/alice/outbox"); + assert_eq!(json["preferredUsername"], "alice"); + assert_eq!(json["name"], "alice"); + } + + #[tokio::test] + async fn rejects_unknown_actor() { + let app = build_router(&RuntimeConfig::default_local()); + + let response = app + .oneshot( + Request::builder() + .uri("/users/bob") + .body(Body::empty()) + .expect("valid request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::NOT_FOUND); + } +} From 7d67af1002c3f2283d0290129847cb3c67107f0e Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Thu, 2 Jul 2026 16:39:34 +0900 Subject: [PATCH 18/21] Implement note endpoint --- crates/feder-runtime-server/src/app.rs | 15 ++++++-- crates/feder-runtime-server/src/config.rs | 6 ++++ crates/feder-runtime-server/src/lib.rs | 1 + crates/feder-runtime-server/src/note.rs | 42 +++++++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 crates/feder-runtime-server/src/note.rs diff --git a/crates/feder-runtime-server/src/app.rs b/crates/feder-runtime-server/src/app.rs index 8cca69a..fa591b9 100644 --- a/crates/feder-runtime-server/src/app.rs +++ b/crates/feder-runtime-server/src/app.rs @@ -15,12 +15,12 @@ use std::sync::{Arc, Mutex}; -use crate::actor::actor; use crate::config::RuntimeConfig; use crate::webfinger::webfinger; +use crate::{actor::actor, note::note}; use axum::{Router, http::StatusCode, routing::get}; use feder_core::{FederConfig, FederCore}; -use feder_vocab::Actor; +use feder_vocab::{Actor, Note, Reference}; #[derive(Clone)] pub struct AppState { @@ -28,6 +28,8 @@ pub struct AppState { pub local_actor: Actor, pub username: String, pub handle_host: String, + // TODO(#25): Replace this seeded preview note with durable runtime storage. + pub notes: Vec, } impl AppState { @@ -40,6 +42,13 @@ impl AppState { actor.preferred_username = Some(config.preferred_username.clone()); actor.name = Some(config.username.clone()); + // TODO(#25): Replace this seeded preview note with durable runtime storage. + let mut note = Note::new(config.note_id.clone()); + note.attributed_to = Some(Reference::id(config.actor_id.clone())); + note.content = + Some("Hello, World! This is Feder, a portable AP core for many runtimes.".to_string()); + let notes = vec![note]; + let core = FederCore::new(FederConfig::new(actor.clone())); Self { @@ -47,6 +56,7 @@ impl AppState { local_actor: actor, username: config.username.clone(), handle_host: config.handle_host.clone(), + notes, } } } @@ -58,6 +68,7 @@ pub fn build_router(config: &RuntimeConfig) -> Router { .route("/healthz", get(healthz)) .route("/.well-known/webfinger", get(webfinger)) .route("/users/{username}", get(actor)) + .route("/notes/{id}", get(note)) .with_state(state) } diff --git a/crates/feder-runtime-server/src/config.rs b/crates/feder-runtime-server/src/config.rs index f3cd866..9039c9d 100644 --- a/crates/feder-runtime-server/src/config.rs +++ b/crates/feder-runtime-server/src/config.rs @@ -25,6 +25,8 @@ pub struct RuntimeConfig { pub username: String, pub preferred_username: String, pub handle_host: String, + // TODO(#25): Replace this seeded preview note with durable runtime storage. + pub note_id: Iri, } impl RuntimeConfig { @@ -45,6 +47,10 @@ impl RuntimeConfig { username: "alice".to_string(), preferred_username: "alice".to_string(), handle_host: "127.0.0.1:3000".to_string(), + // TODO(#25): Replace this seeded preview note with durable runtime storage. + note_id: "http://127.0.0.1:3000/notes/1" + .parse() + .expect("valid default note IRI"), } } } diff --git a/crates/feder-runtime-server/src/lib.rs b/crates/feder-runtime-server/src/lib.rs index 2071764..58c1a85 100644 --- a/crates/feder-runtime-server/src/lib.rs +++ b/crates/feder-runtime-server/src/lib.rs @@ -17,4 +17,5 @@ pub mod actor; pub mod app; pub mod config; pub mod error; +pub mod note; pub mod webfinger; diff --git a/crates/feder-runtime-server/src/note.rs b/crates/feder-runtime-server/src/note.rs new file mode 100644 index 0000000..70667ac --- /dev/null +++ b/crates/feder-runtime-server/src/note.rs @@ -0,0 +1,42 @@ +// Feder: A portable ActivityPub core for many runtimes. +// Copyright (C) 2026 Feder contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +use axum::{ + Json, + extract::{Path, State}, + http::{StatusCode, header}, + response::{IntoResponse, Response}, +}; + +use crate::app::AppState; + +pub async fn note( + State(app_state): State, + Path(id): Path, +) -> Result { + // TODO(#25): Replace this seeded preview note with durable runtime storage. + let note = app_state + .notes + .iter() + .find(|note| note.id.as_str() == format!("http://{}/notes/{id}", app_state.handle_host)) + .cloned() + .ok_or(StatusCode::NOT_FOUND)?; + + Ok(( + [(header::CONTENT_TYPE, "application/activity+json")], + Json(note), + ) + .into_response()) +} From 6cc594f51010f7fd00a1403c6d625c6de1314b1b Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Thu, 2 Jul 2026 16:46:51 +0900 Subject: [PATCH 19/21] Test public Note endpoint Cover the seeded public Note route, unknown Note IDs, response content type, and serialized ActivityPub Note fields. Assisted-by: Codex:gpt-5.5 --- crates/feder-runtime-server/src/note.rs | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/crates/feder-runtime-server/src/note.rs b/crates/feder-runtime-server/src/note.rs index 70667ac..94dca70 100644 --- a/crates/feder-runtime-server/src/note.rs +++ b/crates/feder-runtime-server/src/note.rs @@ -40,3 +40,67 @@ pub async fn note( ) .into_response()) } + +#[cfg(test)] +mod tests { + use axum::{ + body::{Body, to_bytes}, + http::{Request, StatusCode, header}, + }; + use serde_json::Value; + use tower::ServiceExt; + + use crate::{app::build_router, config::RuntimeConfig}; + + #[tokio::test] + async fn returns_public_note() { + let app = build_router(&RuntimeConfig::default_local()); + + let response = app + .oneshot( + Request::builder() + .uri("/notes/1") + .body(Body::empty()) + .expect("valid request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::OK); + assert_eq!( + response.headers().get(header::CONTENT_TYPE).unwrap(), + "application/activity+json" + ); + + let body = to_bytes(response.into_body(), 2048) + .await + .expect("read response body"); + let json: Value = serde_json::from_slice(&body).expect("valid json"); + + assert_eq!(json["@context"], "https://www.w3.org/ns/activitystreams"); + assert_eq!(json["type"], "Note"); + assert_eq!(json["id"], "http://127.0.0.1:3000/notes/1"); + assert_eq!(json["attributedTo"], "http://127.0.0.1:3000/users/alice"); + assert_eq!( + json["content"], + "Hello, World! This is Feder, a portable AP core for many runtimes." + ); + } + + #[tokio::test] + async fn rejects_unknown_note() { + let app = build_router(&RuntimeConfig::default_local()); + + let response = app + .oneshot( + Request::builder() + .uri("/notes/missing") + .body(Body::empty()) + .expect("valid request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::NOT_FOUND); + } +} From 07be8f96b8391bff1ab67fff8cfa30d4d20da8dc Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Fri, 3 Jul 2026 14:51:26 +0900 Subject: [PATCH 20/21] Fix hardcoded URL to suffix --- crates/feder-runtime-server/src/note.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/feder-runtime-server/src/note.rs b/crates/feder-runtime-server/src/note.rs index 94dca70..7fa92ef 100644 --- a/crates/feder-runtime-server/src/note.rs +++ b/crates/feder-runtime-server/src/note.rs @@ -27,10 +27,11 @@ pub async fn note( Path(id): Path, ) -> Result { // TODO(#25): Replace this seeded preview note with durable runtime storage. + let expected_suffix = format!("/notes/{id}"); let note = app_state .notes .iter() - .find(|note| note.id.as_str() == format!("http://{}/notes/{id}", app_state.handle_host)) + .find(|note| note.id.as_str().ends_with(&expected_suffix)) .cloned() .ok_or(StatusCode::NOT_FOUND)?; From 0cc162c0bb920ca1967c346513d85f43f6de0364 Mon Sep 17 00:00:00 2001 From: Jiwon Kwon Date: Fri, 3 Jul 2026 14:54:41 +0900 Subject: [PATCH 21/21] Enable tower's util --- Cargo.toml | 1 + crates/feder-runtime-server/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b7439be..f889890 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ license = "AGPL-3.0-only" iri-string = { version = "0.7.12", default-features = false, features = ["alloc", "serde"] } serde = { version = "1.0.219", default-features = false, features = ["alloc", "derive"] } serde_json = "1.0.140" +tower = { version = "0.5", features = ["util"]} [workspace.lints.rust] warnings = "deny" diff --git a/crates/feder-runtime-server/Cargo.toml b/crates/feder-runtime-server/Cargo.toml index cd1cc4f..d32af2b 100644 --- a/crates/feder-runtime-server/Cargo.toml +++ b/crates/feder-runtime-server/Cargo.toml @@ -16,7 +16,7 @@ serde.workspace = true [dev-dependencies] serde_json.workspace = true -tower = "0.5" +tower.workspace = true [lints] workspace = true