oxirs-chat 0.3.1

RAG chat API with LLM integration and natural language to SPARQL translation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
//! # Workflow Types
//!
//! All public type definitions, structs, and enums used by the workflow
//! integration system: tasks, reports, exports, approvals, notifications,
//! audit trails, and collaborative workspace types.

use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
use std::time::{Duration, SystemTime};

// ============================================================================
// Configuration
// ============================================================================

/// Configuration for workflow integration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkflowConfig {
    pub enable_task_delegation: bool,
    pub enable_report_generation: bool,
    pub enable_data_export: bool,
    pub enable_notifications: bool,
    pub enable_approval_workflows: bool,
    pub enable_audit_trails: bool,
    pub export_directory: PathBuf,
    pub report_directory: PathBuf,
    pub audit_directory: PathBuf,
    pub max_concurrent_tasks: usize,
    pub task_timeout: Duration,
}

impl Default for WorkflowConfig {
    fn default() -> Self {
        Self {
            enable_task_delegation: true,
            enable_report_generation: true,
            enable_data_export: true,
            enable_notifications: true,
            enable_approval_workflows: true,
            enable_audit_trails: true,
            export_directory: PathBuf::from("./exports"),
            report_directory: PathBuf::from("./reports"),
            audit_directory: PathBuf::from("./audit"),
            max_concurrent_tasks: 10,
            task_timeout: Duration::from_secs(300),
        }
    }
}

// ============================================================================
// Task types
// ============================================================================

/// Task delegation request
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaskRequest {
    pub title: String,
    pub description: String,
    pub task_type: TaskType,
    pub assignee: String,
    pub deadline: Option<SystemTime>,
    pub priority: TaskPriority,
    pub dependencies: Vec<String>,
    pub metadata: HashMap<String, String>,
}

/// Active task record
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Task {
    pub id: TaskId,
    pub request: TaskRequest,
    pub status: TaskStatus,
    pub created_at: SystemTime,
    pub updated_at: SystemTime,
    pub assigned_to: String,
    pub deadline: Option<SystemTime>,
    pub priority: TaskPriority,
    pub dependencies: Vec<String>,
    pub metadata: HashMap<String, String>,
}

/// Newtype wrapper for task identifiers
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaskId(pub String);

/// Classification of a task
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TaskType {
    DataAnalysis,
    ReportGeneration,
    DataValidation,
    QueryOptimization,
    KnowledgeUpdate,
    UserSupport,
    SystemMaintenance,
    Custom(String),
}

/// Lifecycle state of a task
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TaskStatus {
    Pending,
    InProgress,
    Completed,
    Failed,
    Cancelled,
}

/// Urgency level of a task
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TaskPriority {
    Low,
    Medium,
    High,
    Critical,
}

// ============================================================================
// Report generation types
// ============================================================================

/// Report generation request
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReportRequest {
    pub title: String,
    pub report_type: ReportType,
    pub format: ReportFormat,
    pub time_range: TimeRange,
    pub filters: HashMap<String, String>,
    pub include_charts: bool,
    pub include_raw_data: bool,
}

/// Completed report metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReportResult {
    pub title: String,
    pub format: ReportFormat,
    pub file_path: PathBuf,
    pub generated_at: SystemTime,
    pub size_bytes: u64,
    pub metadata: HashMap<String, String>,
}

/// Category of the report
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ReportType {
    ConversationSummary,
    PerformanceMetrics,
    UsageAnalytics,
    ErrorReport,
    UserSatisfaction,
    QueryAnalysis,
    Custom(String),
}

/// Output format for a report
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ReportFormat {
    PDF,
    HTML,
    CSV,
    JSON,
    Excel,
    Markdown,
}

impl std::fmt::Display for ReportFormat {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            ReportFormat::PDF => write!(f, "PDF"),
            ReportFormat::HTML => write!(f, "HTML"),
            ReportFormat::CSV => write!(f, "CSV"),
            ReportFormat::JSON => write!(f, "JSON"),
            ReportFormat::Excel => write!(f, "Excel"),
            ReportFormat::Markdown => write!(f, "Markdown"),
        }
    }
}

// ============================================================================
// Data export types
// ============================================================================

/// Data export request
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExportRequest {
    pub data_type: DataType,
    pub format: ExportFormat,
    pub time_range: TimeRange,
    pub filters: HashMap<String, String>,
    pub compression: bool,
}

/// Completed export metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExportResult {
    pub filename: String,
    pub format: ExportFormat,
    pub file_path: PathBuf,
    pub exported_at: SystemTime,
    pub record_count: usize,
    pub size_bytes: u64,
}

/// Categories of exportable data
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DataType {
    Messages,
    Sessions,
    Analytics,
    AuditLogs,
    UserProfiles,
    QueryHistory,
    All,
}

/// Output format for exported data
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ExportFormat {
    JSON,
    CSV,
    Parquet,
    Avro,
    XML,
}

impl std::fmt::Display for ExportFormat {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            ExportFormat::JSON => write!(f, "JSON"),
            ExportFormat::CSV => write!(f, "CSV"),
            ExportFormat::Parquet => write!(f, "Parquet"),
            ExportFormat::Avro => write!(f, "Avro"),
            ExportFormat::XML => write!(f, "XML"),
        }
    }
}

// ============================================================================
// Approval workflow types
// ============================================================================

/// Approval workflow request
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalRequest {
    pub id: Option<ApprovalId>,
    pub title: String,
    pub description: String,
    pub request_type: ApprovalType,
    pub requester: String,
    pub approvers: Vec<String>,
    pub required_approvals: usize,
    pub status: ApprovalStatus,
    pub submitted_at: Option<SystemTime>,
    pub processed_at: Option<SystemTime>,
    pub decision: Option<ApprovalDecision>,
    pub metadata: HashMap<String, String>,
}

/// Newtype wrapper for approval identifiers
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct ApprovalId(pub String);

/// Approval decision record
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalDecision {
    pub approved: bool,
    pub approver: String,
    pub comments: String,
    pub decided_at: SystemTime,
}

/// Category of an approval request
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ApprovalType {
    DataAccess,
    FeatureActivation,
    ConfigurationChange,
    UserPermission,
    DataExport,
    SystemUpgrade,
    Custom(String),
}

/// Lifecycle state of an approval request
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ApprovalStatus {
    Pending,
    Approved,
    Rejected,
    Expired,
}

// ============================================================================
// Notification types
// ============================================================================

/// Outbound notification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Notification {
    pub recipient: String,
    pub notification_type: NotificationType,
    pub title: String,
    pub message: String,
    pub priority: NotificationPriority,
    pub channel: NotificationChannel,
    pub metadata: HashMap<String, String>,
}

/// Category of a notification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NotificationType {
    TaskAssignment,
    TaskCompletion,
    ApprovalRequest,
    ApprovalDecision,
    SystemAlert,
    UserMessage,
    Custom(String),
}

/// Urgency level of a notification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NotificationPriority {
    Low,
    Medium,
    High,
    Urgent,
}

/// Delivery channel for notifications
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NotificationChannel {
    Email,
    SMS,
    InApp,
    Webhook,
    Slack,
    Teams,
}

// ============================================================================
// Shared time type
// ============================================================================

/// Time range for reports and exports
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TimeRange {
    pub start: SystemTime,
    pub end: SystemTime,
}

// ============================================================================
// Audit trail types
// ============================================================================

/// Single audit log entry
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuditEntry {
    pub id: String,
    pub entity_id: String,
    pub action: AuditAction,
    pub actor: String,
    pub timestamp: SystemTime,
    pub details: HashMap<String, String>,
    pub ip_address: Option<String>,
    pub user_agent: Option<String>,
}

/// Audit action classification
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AuditAction {
    TaskCreated,
    TaskUpdated,
    TaskCompleted,
    ReportGenerated,
    DataExported,
    ApprovalRequested,
    ApprovalDecided,
    ConfigurationChanged,
    UserAction(String),
}

// ============================================================================
// Collaborative workspace types
// ============================================================================

/// Collaborative workspace record
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CollaborativeWorkspace {
    pub id: WorkspaceId,
    pub name: String,
    pub description: Option<String>,
    pub owner: String,
    pub members: Vec<WorkspaceMember>,
    pub permissions: WorkspacePermissions,
    pub shared_documents: Vec<SharedDocument>,
    pub active_collaborations: Vec<ActiveCollaboration>,
    pub settings: WorkspaceSettings,
    pub created_at: SystemTime,
    pub updated_at: SystemTime,
}

/// Newtype wrapper for workspace identifiers
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkspaceId(pub String);

/// Session token for collaborative sessions
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SessionToken(pub String);

/// Newtype wrapper for message identifiers
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageId(pub String);

/// Newtype wrapper for decision identifiers
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DecisionId(pub String);

/// Workspace member record
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkspaceMember {
    pub user_id: String,
    pub role: WorkspaceRole,
    pub permissions: UserPermissions,
    pub joined_at: SystemTime,
    pub last_active: SystemTime,
}

/// Role of a workspace member
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum WorkspaceRole {
    Owner,
    Admin,
    Editor,
    Viewer,
    Guest,
}

/// Fine-grained permissions for a workspace user
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserPermissions {
    pub can_edit_documents: bool,
    pub can_create_documents: bool,
    pub can_delete_documents: bool,
    pub can_invite_users: bool,
    pub can_manage_permissions: bool,
    pub can_start_decisions: bool,
    pub can_vote: bool,
    pub can_moderate: bool,
}

impl Default for UserPermissions {
    fn default() -> Self {
        Self {
            can_edit_documents: true,
            can_create_documents: true,
            can_delete_documents: false,
            can_invite_users: false,
            can_manage_permissions: false,
            can_start_decisions: true,
            can_vote: true,
            can_moderate: false,
        }
    }
}

/// Access-control settings for a workspace
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkspacePermissions {
    pub public_readable: bool,
    pub allow_anonymous_access: bool,
    pub require_approval_for_members: bool,
    pub default_member_permissions: UserPermissions,
}

/// Workspace behaviour configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkspaceSettings {
    pub enable_real_time_editing: bool,
    pub enable_presence_awareness: bool,
    pub enable_chat: bool,
    pub enable_video_calls: bool,
    pub enable_decision_voting: bool,
    pub auto_save_interval: std::time::Duration,
    pub max_concurrent_editors: usize,
    pub session_timeout: std::time::Duration,
}

impl Default for WorkspaceSettings {
    fn default() -> Self {
        Self {
            enable_real_time_editing: true,
            enable_presence_awareness: true,
            enable_chat: true,
            enable_video_calls: false,
            enable_decision_voting: true,
            auto_save_interval: std::time::Duration::from_secs(10),
            max_concurrent_editors: 50,
            session_timeout: std::time::Duration::from_secs(8 * 3600),
        }
    }
}

/// Request to create a new workspace
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateWorkspaceRequest {
    pub name: String,
    pub description: Option<String>,
    pub owner: String,
    pub initial_members: Vec<WorkspaceMember>,
    pub permissions: WorkspacePermissions,
    pub settings: Option<WorkspaceSettings>,
}

/// User identity and preferences for a collaborative session
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserInfo {
    pub name: String,
    pub email: String,
    pub avatar_url: Option<String>,
    pub timezone: String,
    pub preferences: UserPreferences,
}

/// User notification and presence preferences
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserPreferences {
    pub enable_notifications: bool,
    pub notification_types: Vec<NotificationType>,
    pub presence_status: PresenceStatus,
    pub auto_join_calls: bool,
}

/// Online presence status for a user
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PresenceStatus {
    Online,
    Away,
    Busy,
    DoNotDisturb,
    Offline,
}

/// Active collaborative session record
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CollaborativeSession {
    pub token: SessionToken,
    pub workspace_id: WorkspaceId,
    pub user_id: String,
    pub user_info: UserInfo,
    pub joined_at: SystemTime,
    pub last_activity: SystemTime,
    pub active_documents: Vec<String>,
    pub permissions: UserPermissions,
}

/// Real-time presence record for a user in a workspace
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserPresence {
    pub user_id: String,
    pub status: PresenceStatus,
    pub last_seen: SystemTime,
    pub current_activity: Option<String>,
    pub cursor_position: Option<CursorPosition>,
    pub viewing_document: Option<String>,
}

/// Cursor position within a document
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CursorPosition {
    pub document_id: String,
    pub line: u32,
    pub column: u32,
    pub selection_start: Option<(u32, u32)>,
    pub selection_end: Option<(u32, u32)>,
}

/// Collaborative chat/event message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CollaborativeMessage {
    pub id: Option<MessageId>,
    pub sender_id: String,
    pub message_type: MessageType,
    pub content: String,
    pub thread_id: Option<String>,
    pub reply_to: Option<MessageId>,
    pub mentions: Vec<String>,
    pub attachments: Vec<MessageAttachment>,
    pub reactions: Vec<MessageReaction>,
    pub timestamp: Option<SystemTime>,
    pub edited_at: Option<SystemTime>,
}

/// Classification of a collaborative message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MessageType {
    Text,
    System,
    Notification,
    DocumentUpdate,
    VideoCall,
    Decision,
    Poll,
}

/// File attachment on a message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageAttachment {
    pub file_id: String,
    pub filename: String,
    pub file_type: String,
    pub size_bytes: u64,
    pub url: String,
}

/// Emoji reaction on a message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageReaction {
    pub emoji: String,
    pub user_id: String,
    pub timestamp: SystemTime,
}

/// Shared document record
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SharedDocument {
    pub id: String,
    pub name: String,
    pub document_type: DocumentType,
    pub content: String,
    pub version: u64,
    pub created_by: String,
    pub created_at: SystemTime,
    pub last_modified_by: String,
    pub last_modified_at: SystemTime,
    pub collaborators: Vec<String>,
    pub permissions: DocumentPermissions,
}

/// Classification of a shared document
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DocumentType {
    SparqlQuery,
    MarkdownDocument,
    JsonDocument,
    CodeFile { language: String },
    Whiteboard,
    Spreadsheet,
    Presentation,
}

/// Access-control settings for a shared document
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DocumentPermissions {
    pub public_readable: bool,
    pub editors: Vec<String>,
    pub viewers: Vec<String>,
    pub allow_comments: bool,
    pub allow_suggestions: bool,
}

/// An active collaborative editing session on a document
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CollaborativeEditingSession {
    pub session_id: String,
    pub workspace_id: WorkspaceId,
    pub document_id: String,
    pub user_id: String,
    pub document_type: DocumentType,
    pub started_at: SystemTime,
    pub last_edit: SystemTime,
    pub cursor_position: Option<CursorPosition>,
    pub pending_operations: Vec<EditOperation>,
}

/// Atomic text editing operation
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EditOperation {
    pub operation_id: String,
    pub operation_type: OperationType,
    pub position: TextPosition,
    pub content: String,
    pub timestamp: SystemTime,
    pub user_id: String,
}

/// Classification of an edit operation
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OperationType {
    Insert,
    Delete,
    Replace,
    FormatApply,
    Comment,
    Suggestion,
}

/// Position within a text document
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TextPosition {
    pub line: u32,
    pub column: u32,
    pub offset: u32,
}

/// Active collaboration record within a workspace
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActiveCollaboration {
    pub collaboration_id: String,
    pub collaboration_type: CollaborationType,
    pub participants: Vec<String>,
    pub started_by: String,
    pub started_at: SystemTime,
    pub status: CollaborationStatus,
    pub context: serde_json::Value,
}

/// Category of a collaboration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CollaborationType {
    DocumentEditing,
    VideoCall,
    ScreenShare,
    Brainstorming,
    DecisionMaking,
    ReviewSession,
}

/// Lifecycle state of a collaboration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CollaborationStatus {
    Active,
    Paused,
    Completed,
    Cancelled,
}

// ============================================================================
// Decision-making types
// ============================================================================

/// Request to start a collaborative decision process
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DecisionRequest {
    pub title: String,
    pub description: String,
    pub decision_type: DecisionType,
    pub options: Vec<DecisionOption>,
    pub eligible_voters: Vec<String>,
    pub deadline: Option<SystemTime>,
}

/// Active decision process record
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DecisionProcess {
    pub id: DecisionId,
    pub workspace_id: WorkspaceId,
    pub initiator_id: String,
    pub title: String,
    pub description: String,
    pub decision_type: DecisionType,
    pub options: Vec<DecisionOption>,
    pub eligible_voters: Vec<String>,
    pub votes: HashMap<String, Vote>,
    pub comments: Vec<DecisionComment>,
    pub deadline: Option<SystemTime>,
    pub status: DecisionStatus,
    pub created_at: SystemTime,
    pub updated_at: SystemTime,
}

/// Voting methodology for a decision
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DecisionType {
    SingleChoice,
    MultipleChoice,
    Ranking,
    YesNo,
    Consensus,
    Budget,
}

/// A votable option in a decision
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DecisionOption {
    pub id: String,
    pub title: String,
    pub description: Option<String>,
    pub proposed_by: String,
    pub vote_count: u32,
}

/// A vote cast by a participant
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Vote {
    pub voter_id: String,
    pub option_ids: Vec<String>,
    pub ranking: Option<Vec<String>>,
    pub comment: Option<String>,
    pub timestamp: SystemTime,
}

/// A comment on a decision
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DecisionComment {
    pub id: String,
    pub author_id: String,
    pub content: String,
    pub timestamp: SystemTime,
    pub replies: Vec<DecisionComment>,
}

/// Lifecycle state of a decision process
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DecisionStatus {
    Open,
    Closed,
    Cancelled,
    Implemented,
}

// ============================================================================
// Activity feed types
// ============================================================================

/// A workspace activity feed event
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActivityEvent {
    pub id: String,
    pub workspace_id: WorkspaceId,
    pub event_type: ActivityEventType,
    pub actor_id: String,
    pub target_id: Option<String>,
    pub description: String,
    pub timestamp: SystemTime,
    pub metadata: HashMap<String, String>,
}

/// Classification of a workspace activity event
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ActivityEventType {
    UserJoined,
    UserLeft,
    DocumentCreated,
    DocumentEdited,
    DocumentShared,
    MessageSent,
    DecisionStarted,
    DecisionVoted,
    CollaborationStarted,
    CollaborationEnded,
}

// ============================================================================
// Service struct declarations (implementations live in workflow_engine.rs)
// ============================================================================

/// Workflow manager for business process integration
pub struct WorkflowManager {
    pub(crate) config: WorkflowConfig,
    pub(crate) active_tasks: HashMap<String, Task>,
    pub(crate) approval_queue: Vec<ApprovalRequest>,
    pub(crate) audit_logger: AuditLogger,
    pub(crate) notification_service: NotificationService,
    pub(crate) report_generator: ReportGenerator,
    pub(crate) data_exporter: DataExporter,
}

/// Internal audit logging service (implementation in workflow_engine.rs)
pub(crate) struct AuditLogger {
    pub(crate) config: WorkflowConfig,
}

/// Notification delivery service
pub(crate) struct NotificationService {
    #[allow(dead_code)]
    pub(crate) config: WorkflowConfig,
}

/// Report generation service
pub(crate) struct ReportGenerator {
    pub(crate) config: WorkflowConfig,
}

/// Data export service
pub(crate) struct DataExporter {
    pub(crate) config: WorkflowConfig,
}

/// Collaborative workspace manager for real-time team coordination
pub struct CollaborativeWorkspaceManager {
    pub(crate) workspaces: HashMap<String, CollaborativeWorkspace>,
    pub(crate) active_sessions: HashMap<String, CollaborativeSession>,
    pub(crate) presence_tracker: PresenceTracker,
    pub(crate) message_bus: CollaborativeMessageBus,
    pub(crate) shared_document_manager: SharedDocumentManager,
    pub(crate) decision_tracker: CollaborativeDecisionTracker,
}

/// Presence tracking for real-time collaboration awareness
pub struct PresenceTracker {
    pub(crate) workspace_presence: HashMap<String, Vec<UserPresence>>,
}

/// Real-time messaging system for collaboration
pub struct CollaborativeMessageBus {
    pub(crate) message_history: HashMap<String, Vec<CollaborativeMessage>>,
    pub(crate) _subscribers: HashMap<String, Vec<String>>,
}

/// Shared document management for collaborative editing
pub struct SharedDocumentManager {
    pub(crate) _documents: HashMap<String, SharedDocument>,
    pub(crate) editing_sessions: HashMap<String, Vec<CollaborativeEditingSession>>,
}

/// Collaborative decision-making system
pub struct CollaborativeDecisionTracker {
    pub(crate) active_decisions: HashMap<String, DecisionProcess>,
}