pub struct ProtocolContext { /* private fields */ }Expand description
Cross-tool state collector for protocol commands.
Provides cached access to bus claims and maw workspaces (fetched on construction), plus lazy on-demand methods for bone/review status.
Implementations§
Source§impl ProtocolContext
impl ProtocolContext
Sourcepub fn collect(project: &str, agent: &str) -> Result<Self, ContextError>
pub fn collect(project: &str, agent: &str) -> Result<Self, ContextError>
Collect shared state from bus and maw.
Calls:
bus claims list --format json --agent <agent>maw ws list --format json
Returns error if either subprocess fails or output is unparseable.
Sourcepub fn held_bone_claims(&self) -> Vec<(&str, &str)>
pub fn held_bone_claims(&self) -> Vec<(&str, &str)>
Get all held bone claims as (bone_id, pattern) tuples.
Sourcepub fn held_workspace_claims(&self) -> Vec<(&str, &str)>
pub fn held_workspace_claims(&self) -> Vec<(&str, &str)>
Get all held workspace claims as (workspace_name, pattern) tuples.
Sourcepub fn find_workspace(&self, name: &str) -> Option<&Workspace>
pub fn find_workspace(&self, name: &str) -> Option<&Workspace>
Find a workspace by name.
Sourcepub fn workspace_for_bone(&self, bone_id: &str) -> Option<&str>
pub fn workspace_for_bone(&self, bone_id: &str) -> Option<&str>
Correlate a bone claim with its workspace claim.
Tries memo-based correlation first (most precise), then falls back to
finding any non-default workspace claim from this agent. The fallback
is needed because bus claims list --format json currently omits the
memo field, making memo-based lookup fail.
Sourcepub fn bone_status(&self, bone_id: &str) -> Result<BoneInfo, ContextError>
pub fn bone_status(&self, bone_id: &str) -> Result<BoneInfo, ContextError>
Fetch bone status by calling maw exec default -- bn show <id> --format json.
Sourcepub fn reviews_in_workspace(
&self,
workspace: &str,
) -> Result<Vec<ReviewSummary>, ContextError>
pub fn reviews_in_workspace( &self, workspace: &str, ) -> Result<Vec<ReviewSummary>, ContextError>
List reviews in a workspace by calling maw exec <ws> -- crit reviews list --format json.
Returns empty list if no reviews exist or crit is not configured.
Sourcepub fn review_status(
&self,
review_id: &str,
workspace: &str,
) -> Result<ReviewDetail, ContextError>
pub fn review_status( &self, review_id: &str, workspace: &str, ) -> Result<ReviewDetail, ContextError>
Fetch review status by calling maw exec <ws> -- crit review <id> --format json.
Sourcepub fn check_bone_claim_conflict(
&self,
bone_id: &str,
) -> Result<Option<String>, ContextError>
pub fn check_bone_claim_conflict( &self, bone_id: &str, ) -> Result<Option<String>, ContextError>
Check for claim conflicts by querying all claims.
Returns the conflicting claim if another agent holds the bone.
pub fn project(&self) -> &str
pub fn agent(&self) -> &str
pub fn claims(&self) -> &[Claim]
pub fn workspaces(&self) -> &[Workspace]
Trait Implementations§
Source§impl Clone for ProtocolContext
impl Clone for ProtocolContext
Source§fn clone(&self) -> ProtocolContext
fn clone(&self) -> ProtocolContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more