Skip to main content

agent_runtime/tool/
family_context.rs

1//! Trusted family membership details resolved by the host platform.
2
3use chrono::NaiveDate;
4use serde::Serialize;
5
6/// One member of a family roster verified for the authenticated user.
7#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
8pub struct FamilyMemberContext {
9    /// Stable EME user identifier exposed as the model-facing `recipient_id`.
10    #[serde(rename = "recipient_id")]
11    pub user_id: String,
12    /// Display name from the platform identity record, when available.
13    pub name: Option<String>,
14    /// Calendar date of birth from the member's EME user profile, when available.
15    pub birthday: Option<NaiveDate>,
16    /// Telegram account identifier linked to this EME user, when available.
17    #[serde(skip)]
18    pub telegram_id: Option<String>,
19    /// Platform permission within the family (owner, admin, member).
20    pub role: String,
21    /// Family relationship (father, mother, son, daughter, etc.).
22    pub relationship: String,
23}
24
25/// Trusted family information resolved by the platform for an authenticated user.
26#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
27pub struct FamilyContext {
28    pub family_id: String,
29    pub family_name: String,
30    /// The authenticated user's permission within this family.
31    pub family_role: String,
32    /// The authenticated user's relationship within this family.
33    pub relationship: String,
34    /// Complete active family roster, exposed to the model using EME recipient IDs.
35    pub members: Vec<FamilyMemberContext>,
36}
37
38#[cfg(test)]
39mod tests {
40    use super::FamilyMemberContext;
41
42    #[test]
43    fn serializes_recipient_id_without_exposing_telegram_identity() {
44        let member = FamilyMemberContext {
45            user_id: "internal-user-id".to_owned(),
46            name: Some("Javier".to_owned()),
47            birthday: None,
48            telegram_id: Some("123456789".to_owned()),
49            role: "owner".to_owned(),
50            relationship: "father".to_owned(),
51        };
52
53        let value = serde_json::to_value(member).unwrap();
54
55        assert_eq!(value["recipient_id"], "internal-user-id");
56        assert!(value.get("user_id").is_none());
57        assert!(value.get("telegram_id").is_none());
58    }
59}