commit a4c9f542d50475f1d0f290214e29f68d3aa75e1f
parent f4a352183041e288c605fe4d840d19f1131af94a
Author: triesap <tyson@radroots.org>
Date: Tue, 30 Jun 2026 23:58:55 +0000
sdk: normalize private helper cfgs
- rely on runtime-gated helper modules
- simplify order draft helper feature gates
- guard the private module boundary
- prove SDK feature matrix checks
Diffstat:
3 files changed, 48 insertions(+), 12 deletions(-)
diff --git a/crates/sdk/src/farm.rs b/crates/sdk/src/farm.rs
@@ -1,12 +1,9 @@
pub use radroots_events::farm::*;
-#[cfg(feature = "runtime")]
pub use radroots_events_codec::error::EventEncodeError;
-#[cfg(feature = "runtime")]
use radroots_events_codec::wire::WireEventParts;
-#[cfg(feature = "runtime")]
pub fn build_draft(farm: &RadrootsFarm) -> Result<WireEventParts, EventEncodeError> {
radroots_events_codec::farm::encode::to_wire_parts(farm)
}
diff --git a/crates/sdk/src/order.rs b/crates/sdk/src/order.rs
@@ -1,12 +1,10 @@
pub use radroots_events::order::*;
#[cfg(any(feature = "signer-adapters", test))]
pub use radroots_events_codec::error::EventEncodeError;
-#[cfg(feature = "runtime")]
pub use radroots_events_codec::order::RadrootsOrderEnvelopeParseError;
-#[cfg(feature = "runtime")]
use radroots_events::RadrootsNostrEvent;
-#[cfg(all(feature = "serde_json", any(feature = "signer-adapters", test)))]
+#[cfg(any(feature = "signer-adapters", test))]
use radroots_events::{RadrootsNostrEventPtr, ids::RadrootsEventId};
#[cfg(any(feature = "signer-adapters", test))]
use radroots_events_codec::wire::WireEventParts;
@@ -76,7 +74,7 @@ impl RadrootsOrderCancellationDraft {
}
}
-#[cfg(all(feature = "serde_json", any(feature = "signer-adapters", test)))]
+#[cfg(any(feature = "signer-adapters", test))]
pub fn build_order_request_draft(
listing_event: &RadrootsNostrEventPtr,
payload: &RadrootsOrderRequest,
@@ -86,7 +84,7 @@ pub fn build_order_request_draft(
})
}
-#[cfg(all(feature = "serde_json", any(feature = "signer-adapters", test)))]
+#[cfg(any(feature = "signer-adapters", test))]
pub fn build_order_decision_draft(
root_event_id: &RadrootsEventId,
prev_event_id: &RadrootsEventId,
@@ -101,7 +99,7 @@ pub fn build_order_decision_draft(
})
}
-#[cfg(all(feature = "serde_json", any(feature = "signer-adapters", test)))]
+#[cfg(any(feature = "signer-adapters", test))]
pub fn build_order_revision_proposal_draft(
root_event_id: &RadrootsEventId,
prev_event_id: &RadrootsEventId,
@@ -116,7 +114,7 @@ pub fn build_order_revision_proposal_draft(
})
}
-#[cfg(all(feature = "serde_json", any(feature = "signer-adapters", test)))]
+#[cfg(any(feature = "signer-adapters", test))]
pub fn build_order_revision_decision_draft(
root_event_id: &RadrootsEventId,
prev_event_id: &RadrootsEventId,
@@ -131,7 +129,7 @@ pub fn build_order_revision_decision_draft(
})
}
-#[cfg(all(feature = "serde_json", any(feature = "signer-adapters", test)))]
+#[cfg(any(feature = "signer-adapters", test))]
pub fn build_order_cancellation_draft(
root_event_id: &RadrootsEventId,
prev_event_id: &RadrootsEventId,
@@ -146,7 +144,6 @@ pub fn build_order_cancellation_draft(
})
}
-#[cfg(feature = "runtime")]
pub fn parse_order_request(
event: &RadrootsNostrEvent,
) -> Result<RadrootsOrderEnvelope<RadrootsOrderRequest>, RadrootsOrderEnvelopeParseError> {
diff --git a/crates/sdk/tests/source_boundary.rs b/crates/sdk/tests/source_boundary.rs
@@ -531,6 +531,48 @@ fn migrated_runtime_tests_stay_on_product_runtime_boundary() {
}
#[test]
+fn private_protocol_helper_modules_are_runtime_gated_by_lib() {
+ let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
+ let lib_source = read_source(manifest_dir.join("src/lib.rs").as_path());
+
+ for module in ["farm", "order"] {
+ let module_gate = format!("#[cfg(feature = \"runtime\")]\nmod {module};");
+ assert!(
+ lib_source.contains(module_gate.as_str()),
+ "src/lib.rs must keep private protocol helper module `{module}` behind runtime"
+ );
+ }
+
+ for relative_path in ["src/farm.rs", "src/order.rs"] {
+ let source = read_source(manifest_dir.join(relative_path).as_path());
+ assert!(
+ !source.contains("feature = \"runtime\""),
+ "{relative_path} must rely on the lib.rs module-level runtime gate"
+ );
+ assert!(
+ !source.contains("feature = \"serde_json\""),
+ "{relative_path} must rely on the runtime feature's serde_json contract instead of duplicating it"
+ );
+ }
+
+ let order_source = read_source(manifest_dir.join("src/order.rs").as_path());
+ for helper in [
+ "build_order_request_draft",
+ "build_order_decision_draft",
+ "build_order_revision_proposal_draft",
+ "build_order_revision_decision_draft",
+ "build_order_cancellation_draft",
+ ] {
+ let helper_gate =
+ format!("#[cfg(any(feature = \"signer-adapters\", test))]\npub fn {helper}(");
+ assert!(
+ order_source.contains(helper_gate.as_str()),
+ "src/order.rs must keep `{helper}` available only for signer adapters and unit tests"
+ );
+ }
+}
+
+#[test]
fn default_status_noise_test_uses_production_ingest_not_perf_sql_ballast() {
let orders_runtime_tests = read_source(
Path::new(env!("CARGO_MANIFEST_DIR"))