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
//! Atomic file I/O operations for agent team inboxes
//!
//! This module provides safe, conflict-aware file operations for the `~/.claude/teams/`
//! file structure. Key features:
//!
//! - **Atomic swap**: Platform-specific atomic file exchange (macOS/Linux)
//! - **File locking**: Advisory locks with exponential backoff retry
//! - **Conflict detection**: BLAKE3 hashing to detect concurrent writes
//! - **Guaranteed delivery**: Spooling for messages that can't be delivered immediately
//! - **Round-trip preservation**: Unknown JSON fields preserved on read-modify-write
//!
//! # Example
//!
//! ```rust,no_run
//! use agent_team_mail_core::io::{inbox_append, WriteOutcome};
//! use agent_team_mail_core::InboxMessage;
//! use std::path::Path;
//! use std::collections::HashMap;
//!
//! let inbox_path = Path::new("/home/user/.claude/teams/my-team/inboxes/agent.json");
//! let message = InboxMessage {
//! from: "team-lead".to_string(),
//! text: "CI failure detected".to_string(),
//! timestamp: "2026-02-11T14:30:00Z".to_string(),
//! read: false,
//! summary: Some("CI failure detected".to_string()),
//! message_id: Some("msg-12345".to_string()),
//! unknown_fields: HashMap::new(),
//! };
//!
//! match inbox_append(inbox_path, &message, "my-team", "agent").unwrap() {
//! WriteOutcome::Success => println!("Message delivered"),
//! WriteOutcome::ConflictResolved { merged_messages } => {
//! println!("Conflict resolved, merged {} messages", merged_messages)
//! }
//! WriteOutcome::Queued { spool_path } => {
//! println!("Message queued at {:?}", spool_path)
//! }
//! }
//! ```
// Re-export primary API
pub use InboxError;
pub use ;
pub use ;