pub struct Hat {
pub id: HatId,
pub name: String,
pub description: String,
pub subscriptions: Vec<Topic>,
pub publishes: Vec<Topic>,
pub instructions: String,
}Expand description
A hat (persona) that defines agent behavior.
Fields§
§id: HatIdUnique identifier for this hat.
name: StringHuman-readable name for the hat.
description: StringShort description of the hat’s purpose. Used in the HATS table to help Ralph understand when to delegate.
subscriptions: Vec<Topic>Topic patterns this hat subscribes to.
publishes: Vec<Topic>Topics this hat is expected to publish.
instructions: StringInstructions prepended to prompts for this hat.
Implementations§
Source§impl Hat
impl Hat
Sourcepub fn new(id: impl Into<HatId>, name: impl Into<String>) -> Self
pub fn new(id: impl Into<HatId>, name: impl Into<String>) -> Self
Creates a new hat with the given ID and name.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Sets the description for this hat.
Sourcepub fn default_single() -> Self
👎Deprecated: Use default_planner() and default_builder() instead
pub fn default_single() -> Self
Use default_planner() and default_builder() instead
Creates the default hat for single-hat mode.
Sourcepub fn default_planner() -> Self
pub fn default_planner() -> Self
Creates the default planner hat.
Per spec: Planner triggers on task.start, task.resume, build.done, build.blocked
and publishes build.task.
Sourcepub fn default_builder() -> Self
pub fn default_builder() -> Self
Creates the default builder hat.
Per spec: Builder triggers on build.task and publishes
build.done or build.blocked.
Sourcepub fn with_instructions(self, instructions: impl Into<String>) -> Self
pub fn with_instructions(self, instructions: impl Into<String>) -> Self
Sets the instructions for this hat.
Sourcepub fn with_publishes(self, publishes: Vec<Topic>) -> Self
pub fn with_publishes(self, publishes: Vec<Topic>) -> Self
Sets the topics this hat publishes.
Sourcepub fn is_subscribed(&self, topic: &Topic) -> bool
pub fn is_subscribed(&self, topic: &Topic) -> bool
Checks if this hat is subscribed to the given topic.
Sourcepub fn is_subscribed_str(&self, topic: &str) -> bool
pub fn is_subscribed_str(&self, topic: &str) -> bool
Checks if this hat is subscribed to the given topic string.
Zero-allocation variant of is_subscribed() for hot paths.
Sourcepub fn has_specific_subscription(&self, topic: &Topic) -> bool
pub fn has_specific_subscription(&self, topic: &Topic) -> bool
Checks if this hat has a specific (non-global-wildcard) subscription for the topic.
Returns true if the hat matches via a specific pattern (e.g., task.*, build.done)
rather than a global wildcard *. Used for routing priority - specific subscriptions
take precedence over fallback wildcards.
Sourcepub fn is_fallback_only(&self) -> bool
pub fn is_fallback_only(&self) -> bool
Returns true if all subscriptions are global wildcards (*).
Used to identify fallback handlers like Ralph.