Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T02:01:03.936Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

room_header.rs

75 lines · 2.5 KB · rust
1//! Room header authority strip (not the conversation header).
2//!
3//! Spec §9.6: show the Sarah authority profile reference and revision in the
4//! room header **area**. The conversation header says only `Sarah`.
5
6use serde::{Deserialize, Serialize};
7
8use crate::public_ref::{sanitize_public_ref, PublicRef};
9
10/// Default profile ref from `@openagentsinc/sarah` / SARAH_AUTHORITY.md.
11///
12/// The live room projection supplies the authoritative value; this constant is
13/// a public-safe fallback label for offline/degraded presentation only.
14pub const DEFAULT_AUTHORITY_PROFILE_REF: &str = "openagents.sarah-owner-orchestrator";
15
16/// Authority profile strip for the room header area.
17#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
18pub struct RoomAuthorityHeader {
19    pub authority_profile_ref: PublicRef,
20    pub authority_revision: u32,
21}
22
23impl RoomAuthorityHeader {
24    pub fn new(authority_profile_ref: PublicRef, authority_revision: u32) -> Self {
25        Self {
26            authority_profile_ref,
27            authority_revision,
28        }
29    }
30
31    /// Project from raw room bootstrap fields.
32    pub fn from_raw(profile_ref: &str, revision: u32) -> Option<Self> {
33        if revision == 0 {
34            return None;
35        }
36        let authority_profile_ref = sanitize_public_ref(profile_ref)?;
37        Some(Self {
38            authority_profile_ref,
39            authority_revision: revision,
40        })
41    }
42
43    /// Public-safe fallback used when the room projection is degraded.
44    pub fn default_admitted() -> Self {
45        Self {
46            authority_profile_ref: PublicRef::new(DEFAULT_AUTHORITY_PROFILE_REF)
47                .expect("default profile ref is public-safe"),
48            // Live package pin at time of OMEGA-SW-05; room projection overrides.
49            authority_revision: 6,
50        }
51    }
52}
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57
58    #[test]
59    fn rejects_unsafe_profile_ref() {
60        assert!(RoomAuthorityHeader::from_raw("/Users/owner/profile", 6).is_none());
61        assert!(RoomAuthorityHeader::from_raw("openagents.sarah-owner-orchestrator", 0).is_none());
62    }
63
64    #[test]
65    fn accepts_live_profile() {
66        let header = RoomAuthorityHeader::from_raw("openagents.sarah-owner-orchestrator", 6)
67            .expect("valid");
68        assert_eq!(
69            header.authority_profile_ref.as_str(),
70            "openagents.sarah-owner-orchestrator"
71        );
72        assert_eq!(header.authority_revision, 6);
73    }
74}
75
Served at tenant.openagents/omega Member data and write actions are omitted.