communitas-core 0.12.0

Core business logic for Communitas - PQC collaboration with virtual disks
Documentation
// SPDX-License-Identifier: MIT OR Apache-2.0

// Copyright (c) 2025 Saorsa Labs Limited
//
// This file is part of the Saorsa P2P network.
//
// Licensed under the AGPL-3.0 license:
// <https://www.gnu.org/licenses/agpl-3.0.html>
//
// 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 <https://www.gnu.org/licenses/>.

//! Communitas Core - Business logic for the Communitas P2P collaboration platform
//!
//! This crate contains all the core functionality shared between the desktop app
//! and the headless node/CLI, without any UI dependencies.

// Security: Enforce no-panic policy in production code
// Using `deny` instead of `forbid` to allow module-level overrides for generated code
#![cfg_attr(
    not(test),
    deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)
)]
// Allow these in tests for convenience
#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used, clippy::panic))]
pub mod app; // CommunitasApp - The headless core with execute/query/subscribe API
pub mod auth_service;
pub mod command; // Command/Event/Query architecture for headless core
pub mod connectivity_watchdog; // Internet collapse detection (MESH_CAPABILITIES.md §3.2)
pub mod core_context;
pub mod crdt; // New pure CRDT infrastructure
pub mod crdt_manager;
pub mod disk_service; // Per-entity virtual disk management
pub mod legacy_crdt;
pub mod ui_core; // Shared UI API surface for native shells // Legacy vector clock CRDT (to be phased out)
// pub mod dht_identity; // Removed: DHT not used in RC1b (gossip-based architecture)
// pub mod dht_schemas; // Removed: DHT not used in RC1b (gossip-based architecture)
pub mod doc_replicator;
pub mod encrypted_storage;
pub mod entity_service;
pub mod entity_type;
pub mod error;
pub mod identity;
pub mod invite; // Cross-organization collaboration via four-word invites
pub mod invite_service;
pub mod keystore;
pub mod linking_service;
pub mod message_service;
pub mod message_sync;
pub mod metrics;
pub mod peer_presence; // Network-wide peer discovery (ADR-014)
pub mod permissions; // Granular per-resource permission system // Invite service with CRDT persistence
pub mod presence_service;
pub mod recovery; // Vault recovery with BIP-39 mnemonic phrases (ADR-016)
pub mod resource_limits; // Resource management and limits (MESH_CAPABILITIES.md §8.3)
pub mod retry_utils; // Exponential backoff for resilient retries (MESH_CAPABILITIES.md §3.2)
pub mod security;
pub mod services;
pub mod storage;
pub mod telemetry;
pub mod test_harness;
pub mod types;
pub mod validation;
pub mod website;

// Re-export commonly used types
pub use auth_service::{AuthService, SessionInfo};
pub use connectivity_watchdog::{ConnectivityWatchdog, WatchdogConfig};
pub use core_context::CoreContext;
pub use crdt_manager::{CrdtError, CrdtManager, CrdtResult};
pub use entity_service::{
    CascadeRemovalResult, Entity, EntityService, EntityServiceError, EntityServiceResult,
};
pub use entity_type::EntityType;
pub use error::{AppError, AppResult as Result};
pub use linking_service::{LinkingError, LinkingResult, LinkingService, SyncResult};
pub use message_service::{MessageService, MessageServiceError, MessageServiceResult};
pub use resource_limits::{ResourceLimitError, ResourceLimits};
pub use retry_utils::{RetryConfig, retry_dial, retry_with_backoff};
pub use services::CoreServices;
pub use validation::{InputType, ValidationError, ValidationService};

// Re-export identity helpers for convenience
pub use identity::{
    IdentityError, IdentityResult, conn_from_words, conn_words, generate_id_words,
    identity_to_seed, validate_id_words,
};

// Re-export disk service types
pub use disk_service::{DiskStats, DiskType, EntityDiskService, FileInfo};

// Re-export permissions system types
pub use permissions::{AccessLevel, MemberPermissions, ResourceType, role_defaults};

// Re-export invite system types for cross-organization collaboration
pub use invite::{Invite, InviteStatus};
pub use invite_service::{InviteRequest, InviteService, InviteServiceError, InviteServiceResult};

// Re-export peer presence types for network-wide discovery (ADR-014)
pub use peer_presence::{
    PresenceCache, PresenceError, PresenceQuery, PresenceRecord, PresenceResponse, PresenceResult,
};

// Re-export recovery types for vault backup/restore (ADR-016)
pub use recovery::{RecoveryConfig, RecoveryError, RecoveryResult};