Skip to main content

communitas_core/
lib.rs

1// Copyright (c) 2025 Saorsa Labs Limited
2//
3// This file is part of the Saorsa P2P network.
4//
5// Licensed under the AGPL-3.0 license:
6// <https://www.gnu.org/licenses/agpl-3.0.html>
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU Affero General Public License for more details.
12//
13// You should have received a copy of the GNU Affero General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16//! Communitas Core - Business logic for the Communitas P2P collaboration platform
17//!
18//! This crate contains all the core functionality shared between the desktop app
19//! and the headless node/CLI, without any UI dependencies.
20
21// Security: Enforce no-panic policy in production code
22#![cfg_attr(
23    not(test),
24    forbid(clippy::unwrap_used, clippy::expect_used, clippy::panic)
25)]
26// Allow these in tests for convenience
27#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used, clippy::panic))]
28
29pub mod app; // CommunitasApp - The headless core with execute/query/subscribe API
30pub mod auth_service;
31// pub mod bootstrap_integration; // TODO: Reimplement in Sprint 2 with gossip-based bootstrap
32pub mod command; // Command/Event/Query architecture for headless core
33pub mod connectivity_watchdog; // Internet collapse detection (MESH_CAPABILITIES.md §3.2)
34pub mod core_context;
35pub mod crdt; // New pure CRDT infrastructure
36pub mod crdt_manager;
37pub mod disk_service; // Per-entity virtual disk management
38pub mod legacy_crdt; // Legacy vector clock CRDT (to be phased out)
39// pub mod dht_identity; // Removed: DHT not used in RC1b (gossip-based architecture)
40// pub mod dht_schemas; // Removed: DHT not used in RC1b (gossip-based architecture)
41pub mod doc_replicator;
42pub mod encrypted_storage;
43pub mod entity_service;
44pub mod error;
45pub mod identity;
46pub mod invite; // Cross-organization collaboration via four-word invites
47pub mod invite_service;
48pub mod keystore;
49pub mod linking_service;
50pub mod message_service;
51pub mod message_sync;
52pub mod permissions; // Granular per-resource permission system // Invite service with CRDT persistence
53// pub mod messaging; // TODO: Refactor in Sprint 3 for gossip pubsub
54pub mod presence_service;
55pub mod resource_limits; // Resource management and limits (MESH_CAPABILITIES.md §8.3)
56pub mod retry_utils; // Exponential backoff for resilient retries (MESH_CAPABILITIES.md §3.2)
57pub mod security;
58pub mod services;
59pub mod storage;
60pub mod test_harness;
61pub mod types;
62pub mod validation;
63pub mod website;
64
65// Gossip overlay system (now default, no longer feature-gated)
66pub mod gossip;
67
68// WebRTC real-time multimedia (voice, video, screen sharing)
69pub mod webrtc;
70
71// Re-export commonly used types
72pub use auth_service::{AuthService, SessionInfo};
73pub use connectivity_watchdog::{ConnectivityWatchdog, WatchdogConfig};
74pub use core_context::CoreContext;
75pub use crdt_manager::{CrdtError, CrdtManager, CrdtResult};
76pub use entity_service::{
77    CascadeRemovalResult, Entity, EntityService, EntityServiceError, EntityServiceResult,
78};
79pub use error::{AppError, AppResult as Result};
80pub use legacy_crdt::EntityType;
81pub use linking_service::{LinkingError, LinkingResult, LinkingService, SyncResult};
82pub use message_service::{MessageService, MessageServiceError, MessageServiceResult};
83pub use resource_limits::{ResourceLimitError, ResourceLimits};
84pub use retry_utils::{RetryConfig, retry_dial, retry_with_backoff};
85pub use services::CoreServices;
86pub use validation::{InputType, ValidationError, ValidationService};
87
88// Re-export gossip context and presence types (now default, no longer feature-gated)
89pub use gossip::{GossipContext, PresenceInfo, PresenceStatus, PresenceWrapper};
90
91// Re-export identity helpers for convenience
92pub use identity::{
93    IdentityError, IdentityResult, conn_from_words, conn_words, generate_id_words,
94    identity_to_seed, validate_id_words,
95};
96
97// Re-export disk service types
98pub use disk_service::{DiskStats, DiskType, EntityDiskService, FileInfo};
99
100// Re-export permissions system types
101pub use permissions::{AccessLevel, MemberPermissions, ResourceType, role_defaults};
102
103// Re-export invite system types for cross-organization collaboration
104pub use invite::{Invite, InviteStatus};
105pub use invite_service::{InviteRequest, InviteService, InviteServiceError, InviteServiceResult};