commit bd070be33bd5cba0f564a93be21db0f077497668
parent 2a92ea0492f0be4430cd8284c54a781ee2c170a4
Author: triesap <tyson@radroots.org>
Date: Tue, 28 Jul 2026 12:17:00 +0000
protocol: align package manifest and module root
- Establish the final version-neutral protocol package identity.
- Declare the exact std and serde feature vocabulary.
- Expose only the approved versioned module skeleton.
- Lock metadata, dependency, no-std, and root boundaries.
Diffstat:
3 files changed, 128 insertions(+), 3 deletions(-)
diff --git a/crates/protocol/Cargo.toml b/crates/protocol/Cargo.toml
@@ -1,18 +1,24 @@
[package]
name = "radroots_protocol"
-description = "Versioned wire contracts for Radroots"
+publish = false
version = "0.1.0"
edition.workspace = true
+authors.workspace = true
rust-version.workspace = true
license.workspace = true
+description = "Versioned wire contracts for Radroots"
repository.workspace = true
homepage.workspace = true
-authors.workspace = true
+documentation = "https://docs.rs/radroots_protocol"
readme = "README.md"
-publish = false
[lib]
name = "radroots_protocol"
+[features]
+default = ["std", "serde"]
+serde = []
+std = []
+
[lints]
workspace = true
diff --git a/crates/protocol/src/lib.rs b/crates/protocol/src/lib.rs
@@ -1 +1,42 @@
//! Versioned wire contracts for Radroots.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+#![forbid(unsafe_code)]
+
+extern crate alloc;
+
+/// Versioned capability catalog contracts.
+pub mod capability {
+ /// Capability contracts for generation 1.
+ pub mod v1 {}
+}
+
+/// Versioned stable error-report contracts.
+pub mod error {
+ /// Error-report contracts for generation 1.
+ pub mod v1 {}
+}
+
+/// Versioned event wire contracts.
+pub mod event {
+ /// Event wire contracts for generation 1.
+ pub mod v1 {}
+}
+
+/// Versioned daemon protocol contracts.
+pub mod radrootsd {
+ /// Versioned transport-publish contracts.
+ pub mod transport_publish {
+ /// Transport-publish contracts for generation 5.
+ pub mod v5 {}
+ }
+}
+
+/// Versioned runtime operation contracts.
+pub mod runtime {
+ /// Runtime operation contracts for generation 1.
+ pub mod v1 {}
+}
+
+/// Schema identity and structural validation contracts.
+pub mod schema {}
diff --git a/crates/protocol/tests/package_boundary.rs b/crates/protocol/tests/package_boundary.rs
@@ -0,0 +1,78 @@
+use std::collections::BTreeSet;
+
+const MANIFEST: &str = include_str!("../Cargo.toml");
+const ROOT: &str = include_str!("../src/lib.rs");
+
+#[test]
+fn manifest_has_final_identity_features_and_no_dependencies() {
+ assert!(MANIFEST.contains("name = \"radroots_protocol\""));
+ assert!(MANIFEST.contains("version = \"0.1.0\""));
+ assert!(MANIFEST.contains("publish = false"));
+ assert!(MANIFEST.contains("[lib]\nname = \"radroots_protocol\""));
+ assert!(MANIFEST.contains("default = [\"std\", \"serde\"]"));
+ assert_eq!(
+ table_keys(MANIFEST, "[features]"),
+ BTreeSet::from(["default", "serde", "std"])
+ );
+ assert_eq!(table_keys(MANIFEST, "[dependencies]"), BTreeSet::new());
+ assert_eq!(table_keys(MANIFEST, "[dev-dependencies]"), BTreeSet::new());
+}
+
+#[test]
+fn crate_root_exposes_only_the_approved_versioned_skeleton() {
+ assert!(ROOT.contains("#![cfg_attr(not(feature = \"std\"), no_std)]"));
+ assert_eq!(
+ root_declarations("pub mod "),
+ BTreeSet::from([
+ "capability",
+ "error",
+ "event",
+ "radrootsd",
+ "runtime",
+ "schema"
+ ])
+ );
+ assert!(ROOT.contains(
+ "pub mod capability {\n /// Capability contracts for generation 1.\n pub mod v1 {}"
+ ));
+ assert!(ROOT.contains(
+ "pub mod error {\n /// Error-report contracts for generation 1.\n pub mod v1 {}"
+ ));
+ assert!(ROOT.contains(
+ "pub mod event {\n /// Event wire contracts for generation 1.\n pub mod v1 {}"
+ ));
+ assert!(ROOT.contains("pub mod runtime {\n /// Runtime operation contracts for generation 1.\n pub mod v1 {}"));
+ assert!(ROOT.contains("pub mod transport_publish {\n /// Transport-publish contracts for generation 5.\n pub mod v5 {}"));
+ assert!(ROOT.contains("pub mod schema {}"));
+ assert!(
+ !ROOT
+ .lines()
+ .map(str::trim)
+ .any(|line| line.starts_with("pub use "))
+ );
+}
+
+fn table_keys<'a>(manifest: &'a str, heading: &str) -> BTreeSet<&'a str> {
+ let Some((_, table)) = manifest.split_once(heading) else {
+ return BTreeSet::new();
+ };
+ table
+ .lines()
+ .skip(1)
+ .take_while(|line| !line.trim_start().starts_with('['))
+ .filter_map(|line| {
+ let line = line.trim();
+ (!line.is_empty() && !line.starts_with('#'))
+ .then(|| line.split_once('=').map(|(key, _)| key.trim()))
+ .flatten()
+ })
+ .collect()
+}
+
+fn root_declarations(prefix: &str) -> BTreeSet<&str> {
+ ROOT.lines()
+ .filter(|line| !line.starts_with(char::is_whitespace))
+ .filter_map(|line| line.strip_prefix(prefix))
+ .filter_map(|name| name.strip_suffix(" {").or_else(|| name.strip_suffix(" {}")))
+ .collect()
+}