Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(storage): add scope parsing and display implementation

Steven Enamakel26692616c7ec
diff --git a/crates/openhuman-core/src/storage/scope.rs b/crates/openhuman-core/src/storage/scope.rs
index 2cc8bde84d..df8b3cbc60 100644
--- a/crates/openhuman-core/src/storage/scope.rs
+++ b/crates/openhuman-core/src/storage/scope.rs
@@ -6,6 +6,7 @@
//! Invalid or oversized identity segments use the same stable SHA-256/base32
//! representation as the previous scope implementation.
+use std::fmt;
use std::ops::Deref;
use serde::{Deserialize, Serialize};
@@ -37,6 +38,12 @@ impl Scope {
tinystoragedrivers::Scope::new(value).map(Self)
}
+ /// Parses an opaque stored scope without interpreting its host grammar.
+ /// Use [`Scope::parsed`] when a caller needs OpenHuman tenant semantics.
+ pub fn parse(value: impl AsRef<str>) -> Result<Self, StorageError> {
+ Self::new(value)
+ }
+
/// The host's single-operator tenant scope.
#[must_use]
pub fn local() -> Self {
@@ -139,6 +146,12 @@ impl AsRef<str> for Scope {
}
}
+impl fmt::Display for Scope {
+ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
+ formatter.write_str(self.as_str())
+ }
+}
+
impl From<tinystoragedrivers::Scope> for Scope {
fn from(scope: tinystoragedrivers::Scope) -> Self {
Self(scope)
@@ -286,7 +299,7 @@ fn valid_segment(segment: &str) -> bool {
hashed.len() == MAX_HASH_SEGMENT_LEN
&& hashed
.bytes()
- .all(|byte| byte.is_ascii_lowercase() && byte.is_ascii_alphabetic() || (b'2'..=b'7').contains(&byte))
+ .all(|byte| byte.is_ascii_lowercase() || (b'2'..=b'7').contains(&byte))
}) {
return true;
}