lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

commit f6c67bf981dd183b81c57e8b3a048af126ffaa95
parent 4bc20bca66de47cebdea9d1967795bda31eac9e7
Author: triesap <tyson@radroots.org>
Date:   Thu, 22 Oct 2026 21:59:29 +0000

domain: Reject coincident bilateral participants

- Enforce distinct buyer and seller identities when constructing complete terms.
- Return a typed input-free failure and document the original participant rule.
- Retain the actual pre-guard failure against the unchanged original constructor.
- Verify the corrected suite, additive API, portable features, guards and coverage.

Diffstat:
Mcontracts/api_baselines/radroots_domain.txt | 1+
Mcrates/domain/README.md | 2+-
Mcrates/domain/src/agreement.rs | 6++++++
Mcrates/domain/tests/support/agreement.rs | 14++++++++++++++
4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/contracts/api_baselines/radroots_domain.txt b/contracts/api_baselines/radroots_domain.txt @@ -292,6 +292,7 @@ pub radroots_domain::TermsError::InvalidLineCount pub radroots_domain::TermsError::InvalidSelectedTier pub radroots_domain::TermsError::InvalidText pub radroots_domain::TermsError::OptionMismatch +pub radroots_domain::TermsError::PartiesCoincide pub radroots_domain::TermsError::Pricing(radroots_domain::PricingError) pub radroots_domain::TermsError::Purchase(radroots_domain::listing::ListingError) pub radroots_domain::TermsError::SellerMismatch diff --git a/crates/domain/README.md b/crates/domain/README.md @@ -89,7 +89,7 @@ serialization and grants no agreement, destination or delivery authority. `Terms` retains complete immutable bilateral values: one through32 uniquely identified lines, one through8 uniquely identified private fulfillment groups, -explicit participants, original listing revision/product/option snapshots, +explicit distinct buyer/seller participants, original listing revision/product/option snapshots, selected positive purchase amounts, fulfillment fee, aggregate cap and supply commitment. Every line names a declared group and a source coordinate for the named seller. Coordinate/revision bytes and snapshots remain unverified claims diff --git a/crates/domain/src/agreement.rs b/crates/domain/src/agreement.rs @@ -275,6 +275,9 @@ impl Terms { maximum_total: Money, supply: SupplyCommitment, ) -> Result<Self, TermsError> { + if buyer == seller { + return Err(TermsError::PartiesCoincide); + } if lines.is_empty() || lines.len() > MAX_PRICED_LINES { return Err(TermsError::InvalidLineCount); } @@ -374,6 +377,8 @@ fn text(value: &str, maximum: usize, nonempty: bool) -> Result<(), TermsError> { #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[non_exhaustive] pub enum TermsError { + /// Buyer and seller name the same participant in bilateral terms. + PartiesCoincide, /// The complete agreement requires one through32 lines. InvalidLineCount, /// The complete agreement requires one through8 private groups. @@ -402,6 +407,7 @@ pub enum TermsError { impl fmt::Display for TermsError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match self { + Self::PartiesCoincide => "bilateral participants must be distinct", Self::InvalidLineCount => "invalid agreement line count", Self::InvalidFulfillmentCount => "invalid private fulfillment count", Self::DuplicateLine => "duplicate agreement line", diff --git a/crates/domain/tests/support/agreement.rs b/crates/domain/tests/support/agreement.rs @@ -473,6 +473,19 @@ fn line_admission_refuses_snapshot_quantity_tier_text_and_claimed_total_mismatch #[test] fn complete_terms_enforce_collection_identity_seller_and_group_closure_before_capture() { assert_eq!( + Terms::new( + seller(), + seller(), + vec![line(1, 1)], + vec![group(1)], + money("0"), + money("650"), + SupplyCommitment::StockBacked + ) + .unwrap_err(), + TermsError::PartiesCoincide + ); + assert_eq!( terms(vec![], vec![group(1)], money("0"), money("0")).unwrap_err(), TermsError::InvalidLineCount ); @@ -664,6 +677,7 @@ fn exact_listing_source_references_retain_full_coordinate_and_signed_revision_id #[test] fn agreement_failures_remain_typed_bounded_and_input_free() { for error in [ + TermsError::PartiesCoincide, TermsError::InvalidLineCount, TermsError::InvalidFulfillmentCount, TermsError::DuplicateLine,