Refactor remaining tools to tagged enums

Refactored DecisionsTool, TechDebtTool, ManageCheckpointTool, HypothesesTool, AgentSignalsTool to use tagged enums for precise JSON schemas, and updated their handlers.
This commit is contained in:
Riz Ashraf committed 2026-10-10 10:23:58 +01:00
1 parent 8ff43487bc
commit 2cfaeda0cb
3 files changed
+438 -497

No files matched your search

+308 -289
View File
@@ -186,26 +186,38 @@ pub struct GetSubgraphTool {
pub max_tokens: Option<usize>,
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum CheckpointAction {
Create,
Restore,
List,
Delete,
}
/// Save, restore, list, or delete point-in-time memory state snapshot checkpoints.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct ManageCheckpointTool {
/// Action to perform: 'create', 'restore', 'list', or 'delete'.
pub action: CheckpointAction,
/// Unique name or ID for the snapshot checkpoint.
pub name_or_id: Option<String>,
/// Optional description of why this checkpoint was created.
pub description: Option<String>,
/// Optional namespace filter.
pub namespace: Option<String>,
#[serde(tag = "action", rename_all = "snake_case")]
pub enum ManageCheckpointTool {
/// Save a checkpoint.
Create {
/// Unique name or ID for the snapshot checkpoint.
name_or_id: Option<String>,
/// Optional description of why this checkpoint was created.
description: Option<String>,
/// Optional namespace filter.
namespace: Option<String>,
},
/// Restore a checkpoint.
Restore {
/// Unique name or ID for the snapshot checkpoint.
name_or_id: Option<String>,
/// Optional namespace filter.
namespace: Option<String>,
},
/// List checkpoints.
List {
/// Optional namespace filter.
namespace: Option<String>,
},
/// Delete a checkpoint.
Delete {
/// Unique name or ID for the snapshot checkpoint.
name_or_id: Option<String>,
/// Optional namespace filter.
namespace: Option<String>,
}
}
/// Merge two entities in the knowledge graph into one.
@@ -360,28 +372,30 @@ pub struct GetNextActionableTasksTool {
pub limit: Option<usize>,
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum HypothesisAction {
Log,
Query,
}
/// Manage diagnostic hypotheses, tested evidence, and status during problem solving.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct HypothesesTool {
/// Action to perform: 'log' or 'query'.
pub action: HypothesisAction,
/// Optional task ID associated with this hypothesis or to filter hypotheses.
pub task_id: Option<String>,
/// The diagnostic hypothesis or potential root cause (required for action 'log').
pub hypothesis: Option<String>,
/// Status: 'unverified', 'verified', or 'rejected'. Defaults to 'unverified'.
pub status: Option<String>,
/// Evidence or test results supporting or disproving the hypothesis.
pub evidence: Option<String>,
/// Optional search query text (for action 'query').
pub query: Option<String>,
#[serde(tag = "action", rename_all = "snake_case")]
pub enum HypothesesTool {
/// Log a new diagnostic hypothesis.
Log {
/// The diagnostic hypothesis or potential root cause.
hypothesis: String,
/// Optional task ID associated with this hypothesis.
task_id: Option<String>,
/// Status: 'unverified', 'verified', or 'rejected'. Defaults to 'unverified'.
status: Option<String>,
/// Evidence or test results supporting or disproving the hypothesis.
evidence: Option<String>,
},
/// Query existing hypotheses.
Query {
/// Optional search query text.
query: Option<String>,
/// Optional task ID to filter hypotheses.
task_id: Option<String>,
/// Optional status filter.
status: Option<String>,
}
}
#[cfg(test)]
mod tests {
@@ -577,28 +591,30 @@ pub struct SummarizeSubgraphTool {
pub max_tokens: Option<usize>,
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum AgentSignalAction {
Broadcast,
Query,
}
/// Real-time inter-agent communication bus: broadcast signals or query active signals from peer subagents.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct AgentSignalsTool {
/// Action to perform: 'broadcast' or 'query'.
pub action: AgentSignalAction,
/// Sender agent ID or role (e.g. 'PrePushAuditor', 'MemoryLibrarian'). Required for broadcast; optional filter for query.
pub sender: Option<String>,
/// Signal type or event category (e.g. 'AUDIT_PASSED', 'REPRODUCER_READY', 'TESTS_FAILED'). Required for broadcast; optional filter for query.
pub signal_type: Option<String>,
/// JSON or text payload containing event details or artifact URIs (required for action 'broadcast').
pub payload: Option<String>,
/// Optional Time-To-Live in seconds for the signal. Defaults to 3600 (1 hour).
pub ttl_seconds: Option<u64>,
/// Optional limit on returned signals (for action 'query'). Defaults to 20.
pub limit: Option<usize>,
#[serde(tag = "action", rename_all = "snake_case")]
pub enum AgentSignalsTool {
/// Broadcast a signal to peer subagents.
Broadcast {
/// Sender agent ID or role (e.g. 'PrePushAuditor', 'MemoryLibrarian').
sender: String,
/// Signal type or event category (e.g. 'AUDIT_PASSED', 'REPRODUCER_READY', 'TESTS_FAILED').
signal_type: String,
/// JSON or text payload containing event details or artifact URIs.
payload: String,
/// Optional Time-To-Live in seconds for the signal. Defaults to 3600 (1 hour).
ttl_seconds: Option<u64>,
},
/// Query active signals.
Query {
/// Optional sender agent ID or role filter.
sender: Option<String>,
/// Optional signal type filter.
signal_type: Option<String>,
/// Optional limit on returned signals. Defaults to 20.
limit: Option<usize>,
}
}
/// Trigger an automated context checkpoint, summarizing active tasks, hypotheses, recent commits, and open tech debt into a permanent HandoffMemo.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
@@ -620,12 +636,6 @@ pub enum HandoffMemoAction {
}
/// Persistent handoff memos for passing session context to future agents.
/// Actions:
/// - 'leave': Post a handoff memo. Required: content. Optional: namespace.
/// - 'read': Inspect active memos. Optional: namespace.
/// - 'clear': Clear memos. Optional: namespace, ids.
///
/// Next steps on error: Check parameter requirements for 'leave' or 'clear' actions.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct HandoffMemosTool {
/// Action to perform: 'leave', 'read', or 'clear'.
@@ -638,105 +648,113 @@ pub struct HandoffMemosTool {
pub ids: Option<Vec<String>>,
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TaskAction {
Add,
Update,
Delete,
List,
SetCriteria,
Verify,
}
/// Action-oriented task tracking system (add, update, delete, list, set_criteria, verify).
/// Actions:
/// - 'add': Create task. Required: title. Optional: description, git_branch, parent_id, dependencies.
/// - 'update': Update task status. Required: id, status ('pending'|'completed'|'cancelled').
/// - 'delete': Delete task & subtasks. Required: id.
/// - 'list': List active tasks. Optional: git_branch, summary_level ('compact'|'detailed'|'full'), max_tokens.
/// - 'set_criteria': Set acceptance criteria. Required: id, criteria (array of strings).
/// - 'verify': Verify criteria met. Required: id.
///
/// Next steps on error: Check required parameters or call list to verify task IDs.
/// Action-oriented task tracking system.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct TasksTool {
/// Action to perform: 'add', 'update', 'delete', 'list', 'set_criteria', or 'verify'.
pub action: TaskAction,
/// Task ID (required for 'update', 'delete', 'set_criteria', 'verify').
pub id: Option<String>,
/// Task title (required for 'add').
pub title: Option<String>,
/// Task description (optional for 'add').
pub description: Option<String>,
/// New status: 'pending', 'completed', or 'cancelled' (for 'update').
pub status: Option<String>,
/// Parent task ID (optional for 'add').
pub parent_id: Option<String>,
/// List of dependency task IDs (optional for 'add').
pub dependencies: Option<Vec<String>>,
/// Git branch filter or assignment.
pub git_branch: Option<String>,
/// Acceptance criteria (required for 'set_criteria').
pub criteria: Option<Vec<String>>,
/// Verification proof or details (optional for 'verify').
pub proof: Option<String>,
/// Summary level: 'compact', 'detailed', or 'full' (for 'list').
pub summary_level: Option<String>,
/// Maximum tokens budget cap (for 'list').
pub max_tokens: Option<usize>,
/// Optional namespace filter or assignment (defaults to 'default').
pub namespace: Option<String>,
/// Optional repository name.
pub repo_name: Option<String>,
/// Optional task priority: 'low', 'medium', 'high', 'urgent'.
pub priority: Option<String>,
/// Optional assigned subagent role or identifier.
pub assigned_agent: Option<String>,
/// Optional verification command to validate criteria completion.
pub verification_command: Option<String>,
/// Optional pagination offset for 'list'.
pub offset: Option<usize>,
#[serde(tag = "action", rename_all = "snake_case")]
pub enum TasksTool {
/// Create a new task.
Add {
/// Task title.
title: String,
/// Task description.
description: Option<String>,
/// Optional parent task ID for subtasks.
parent_id: Option<String>,
/// List of dependent task IDs.
dependencies: Option<Vec<String>>,
/// Branch associated with this task.
git_branch: Option<String>,
/// Optional namespace filter or assignment.
namespace: Option<String>,
/// Repository name.
repo_name: Option<String>,
/// Priority: 'low', 'medium', 'high', 'critical'.
priority: Option<String>,
/// Assigned agent or subagent.
assigned_agent: Option<String>,
/// Command used to verify completion.
verification_command: Option<String>,
},
/// Update task status.
Update {
/// Task ID.
id: String,
/// New status: 'pending', 'completed', or 'cancelled'.
status: String,
},
/// Delete a task and its subtasks.
Delete {
/// Task ID.
id: String,
},
/// List active tasks.
List {
/// Optional Git branch filter.
git_branch: Option<String>,
/// Optional status filter.
status: Option<String>,
/// Summary level: 'compact', 'detailed', or 'full'. Defaults to 'detailed'.
summary_level: Option<String>,
/// Maximum tokens budget cap.
max_tokens: Option<usize>,
/// Optional pagination offset.
offset: Option<usize>,
},
/// Set a checklist of acceptance criteria.
SetCriteria {
/// Task ID or title.
id: String,
/// Acceptance criteria list.
criteria: Vec<String>,
},
/// Mark an acceptance criteria as met with cryptographic-like proof.
Verify {
/// Task ID or title.
id: String,
/// Verification proof or details.
proof: Option<String>,
}
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum MilestoneAction {
Add,
Update,
List,
}
/// Project milestone management (add, update, list).
/// Actions:
/// - 'add': Create milestone. Required: title. Optional: namespace.
/// - 'update': Update milestone status. Required: id, status.
/// - 'list': List milestones. Optional: namespace.
///
/// Next steps on error: Provide required title for 'add' or id/status for 'update'.
/// Project milestone management.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct MilestonesTool {
/// Action to perform: 'add', 'update', or 'list'.
pub action: MilestoneAction,
/// Milestone ID (required for 'update').
pub id: Option<String>,
/// Milestone title (required for 'add').
pub title: Option<String>,
/// New status (for 'update').
pub status: Option<String>,
/// Optional namespace filter or assignment.
pub namespace: Option<String>,
/// Optional target completion date.
pub target_date: Option<String>,
/// Optional description of milestone scope.
pub description: Option<String>,
/// Optional deliverables or task checklist.
pub deliverables: Option<Vec<String>>,
/// Optional list of task IDs associated with this milestone.
#[serde(default)]
pub task_ids: Option<Vec<String>>,
/// Optional repository name.
pub repo_name: Option<String>,
#[serde(tag = "action", rename_all = "snake_case")]
pub enum MilestonesTool {
/// Create a new milestone.
Add {
/// Milestone title.
title: String,
/// Optional namespace filter or assignment.
namespace: Option<String>,
/// Optional target completion date.
target_date: Option<String>,
/// Optional description of milestone scope.
description: Option<String>,
/// Optional deliverables or task checklist.
deliverables: Option<Vec<String>>,
/// Optional list of task IDs associated with this milestone.
#[serde(default)]
task_ids: Option<Vec<String>>,
/// Optional repository name.
repo_name: Option<String>,
},
/// Update milestone status.
Update {
/// Milestone ID.
id: String,
/// New status.
status: String,
/// Optional deliverables or task checklist.
deliverables: Option<Vec<String>>,
/// Optional list of task IDs associated with this milestone.
#[serde(default)]
task_ids: Option<Vec<String>>,
},
/// List milestones.
List {
/// Optional namespace.
namespace: Option<String>,
}
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
@@ -748,13 +766,6 @@ pub enum SnippetAction {
}
/// Syntactically preserved reusable code snippets vault (store, search, delete, tag).
/// Actions:
/// - 'store': Store snippet. Required: query (or id) as snippet name. Optional: language, code, description, tags.
/// - 'search': Search snippets. Optional: query, tags, hybrid (boolean for BM25+vector search).
/// - 'delete': Delete snippet. Required: id (or query) as snippet name.
/// - 'tag': Tag snippet. Required: id (or query), tags (array of strings).
///
/// Next steps on error: Ensure snippet name/query or id is provided.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct SnippetsTool {
/// Action to perform: 'store', 'search', 'delete', or 'tag'.
@@ -785,118 +796,141 @@ pub struct SnippetsTool {
pub line_range: Option<String>,
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq, Clone)]
#[serde(rename_all = "snake_case")]
pub enum DecisionAction {
Log,
Query,
Delete,
Update,
}
/// Architectural Decision Records (ADRs) log (log, query, update, delete).
/// Actions:
/// - 'log': Record ADR. Required: title. Optional: status, context, decision, consequences, namespace.
/// - 'query': Search ADRs. Optional: query, namespace.
/// - 'update': Update ADR status or implementation info. Required: id. Optional: status, git_commit, git_branch, task_id, context, decision, consequences, title.
/// - 'delete': Remove ADR. Required: id.
///
/// Next steps on error: Provide title for 'log' or id for 'update'/'delete'.
/// Architectural Decision Records (ADRs) log.
#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
pub struct DecisionsTool {
/// Action to perform: 'log', 'query', 'update', or 'delete'.
pub action: DecisionAction,
/// ADR ID (required for 'delete').
pub id: Option<String>,
/// ADR title (required for 'log').
pub title: Option<String>,
/// ADR status (for 'log').
pub status: Option<String>,
/// Context & problem statement (for 'log').
pub context: Option<String>,
/// Decision made (for 'log').
pub decision: Option<String>,
/// Consequences & tradeoffs (for 'log').
pub consequences: Option<String>,
/// Search query string (for 'query').
pub query: Option<String>,
/// Optional namespace.
pub namespace: Option<String>,
/// Optional repository name.
pub repo_name: Option<String>,
/// Optional author or architect behind the decision.
pub author: Option<String>,
/// Optional affected system components or crates.
pub affected_components: Option<Vec<String>>,
/// Optional alternative designs or libraries considered.
pub alternatives_considered: Option<Vec<String>>,
/// Optional superseded ADR ID.
pub supersedes: Option<String>,
/// Limit the number of query results. Defaults to 20.
pub limit: Option<usize>,
/// Include the full body of the matched decisions. Defaults to true.
pub include_body: Option<bool>,
/// Optional Git commit where decision was implemented.
pub git_commit: Option<String>,
/// Optional Git branch where decision was implemented.
pub git_branch: Option<String>,
/// Optional task ID linked to this decision.
pub task_id: Option<String>,
#[serde(tag = "action", rename_all = "snake_case")]
pub enum DecisionsTool {
/// Record an ADR.
Log {
/// ADR title.
title: String,
/// ADR status.
status: Option<String>,
/// Context & problem statement.
context: Option<String>,
/// Decision made.
decision: Option<String>,
/// Consequences & tradeoffs.
consequences: Option<String>,
/// Optional namespace.
namespace: Option<String>,
/// Optional repository name.
repo_name: Option<String>,
/// Optional author or architect behind the decision.
author: Option<String>,
/// Optional affected system components or crates.
affected_components: Option<Vec<String>>,
/// Optional alternative designs or libraries considered.
alternatives_considered: Option<Vec<String>>,
/// Optional superseded ADR ID.
supersedes: Option<String>,
/// Optional Git commit where decision was implemented.
git_commit: Option<String>,
/// Optional Git branch where decision was implemented.
git_branch: Option<String>,
/// Optional task ID linked to this decision.
task_id: Option<String>,
},
/// Search ADRs.
Query {
/// Search query string.
query: Option<String>,
/// Optional namespace.
namespace: Option<String>,
/// Limit the number of query results. Defaults to 20.
limit: Option<usize>,
/// Include the full body of the matched decisions. Defaults to true.
include_body: Option<bool>,
},
/// Update ADR status or implementation info.
Update {
/// ADR ID.
id: String,
/// ADR title.
title: Option<String>,
/// ADR status.
status: Option<String>,
/// Context & problem statement.
context: Option<String>,
/// Decision made.
decision: Option<String>,
/// Consequences & tradeoffs.
consequences: Option<String>,
/// Optional Git commit where decision was implemented.
git_commit: Option<String>,
/// Optional Git branch where decision was implemented.
git_branch: Option<String>,
/// Optional task ID linked to this decision.
task_id: Option<String>,
/// Optional namespace.
namespace: Option<String>,
/// Optional repository name.
repo_name: Option<String>,
/// Optional author or architect behind the decision.
author: Option<String>,
/// Optional affected system components or crates.
affected_components: Option<Vec<String>>,
/// Optional alternative designs or libraries considered.
alternatives_considered: Option<Vec<String>>,
/// Optional superseded ADR ID.
supersedes: Option<String>,
},
/// Remove an ADR.
Delete {
/// ADR ID.
id: String,
}
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TechDebtAction {
Log,
Resolve,
List,
}
/// Technical debt backlog management (log, resolve, list).
/// Actions:
/// - 'log': Record technical debt. Required: description. Optional: ideal_solution, git_commit, git_branch, symbol_references, line_range, namespace.
/// - 'resolve': Mark tech debt resolved. Required: id.
/// - 'list': List tech debt items. Optional: include_resolved, namespace.
///
/// Next steps on error: Provide description for 'log' or valid ID for 'resolve'.
/// Technical debt backlog management.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct TechDebtTool {
/// Action to perform: 'log', 'resolve', or 'list'.
pub action: TechDebtAction,
/// Tech debt ID (required for 'resolve').
pub id: Option<String>,
/// Tech debt description (required for 'log').
pub description: Option<String>,
/// Optional title or summary of tech debt.
pub title: Option<String>,
/// Ideal solution (optional for 'log').
pub ideal_solution: Option<String>,
/// Include resolved tech debt items (for 'list').
pub include_resolved: Option<bool>,
/// Associated git commit hash.
pub git_commit: Option<String>,
/// Associated git branch.
pub git_branch: Option<String>,
/// Symbol references associated with the tech debt.
pub symbol_references: Option<Vec<String>>,
/// Line range associated with the tech debt.
pub line_range: Option<String>,
/// Optional namespace.
pub namespace: Option<String>,
/// Optional debt severity: 'low', 'medium', 'high', 'critical'.
pub severity: Option<String>,
/// Optional repository name.
pub repo_name: Option<String>,
/// Optional file path where debt exists.
pub file_path: Option<String>,
/// Optional workaround currently in place.
pub workaround: Option<String>,
/// Optional effort estimate to fix.
pub effort_estimate: Option<String>,
/// Summary level for list action: 'compact', 'detailed', or 'full'.
pub summary_level: Option<String>,
/// Optional token budget cap for list output.
pub max_tokens: Option<usize>,
#[serde(tag = "action", rename_all = "snake_case")]
pub enum TechDebtTool {
/// Record technical debt.
Log {
/// Tech debt description.
description: String,
/// Optional title or summary of tech debt.
title: Option<String>,
/// Ideal solution.
ideal_solution: Option<String>,
/// Associated git commit hash.
git_commit: Option<String>,
/// Associated git branch.
git_branch: Option<String>,
/// Symbol references associated with the tech debt.
symbol_references: Option<Vec<String>>,
/// Line range associated with the tech debt.
line_range: Option<String>,
/// Optional namespace.
namespace: Option<String>,
/// Optional debt severity: 'low', 'medium', 'high', 'critical'.
severity: Option<String>,
/// Optional repository name.
repo_name: Option<String>,
/// Optional file path where debt exists.
file_path: Option<String>,
/// Optional workaround currently in place.
workaround: Option<String>,
/// Optional effort estimate to fix.
effort_estimate: Option<String>,
},
/// Mark tech debt resolved.
Resolve {
/// Tech debt ID.
id: String,
},
/// List tech debt items.
List {
/// Include resolved tech debt items.
include_resolved: Option<bool>,
/// Optional namespace.
namespace: Option<String>,
/// Summary level for list action: 'compact', 'detailed', or 'full'.
summary_level: Option<String>,
/// Optional token budget cap for list output.
max_tokens: Option<usize>,
}
}
#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
@@ -910,14 +944,6 @@ pub enum EnvAction {
}
/// Environment requirements, tool fingerprints & infrastructure management.
/// Actions:
/// - 'update_fingerprint': Update tool versions. Optional: tool_versions map, namespace.
/// - 'read_fingerprint': Read current environment fingerprint. Optional: namespace.
/// - 'log_requirement': Log environment variable requirement. Required: key. Optional: description, is_secret, namespace.
/// - 'register': Register remote target environment. Required: name. Optional: url, description, requires_vpn, namespace.
/// - 'get_details': Get full environment details. Optional: namespace.
///
/// Next steps on error: Provide key for 'log_requirement' or name for 'register'.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
pub struct EnvironmentTool {
/// Action to perform: 'update_fingerprint', 'read_fingerprint', 'log_requirement', 'register', or 'get_details'.
@@ -954,14 +980,7 @@ pub enum ClipboardAction {
Write,
}
/// Smart OS Clipboard management with overwrite-immune screenshot caching and OCR.
/// Actions:
/// - 'image': Get latest screenshot image path (Windows + WSL) and extracted verbatim OCR text.
/// Returns cached screenshot even if text was copied afterwards!
/// - 'text': Get latest clipboard text (or normalized Markdown if HTML was copied).
/// - 'history': View recent clipboard history ring buffer (images and text with timestamps).
/// - 'clear': Clear OS clipboard and memory cache.
/// - 'write': Write content to OS clipboard. Optional: text, html, files, image_path.
///
/// Triggers: Call 'image' immediately when user says "look at image in clipboard", "see screenshot",
/// "look at clipboard", "what I copied", or shares terminal error captures.
#[derive(Debug, Deserialize, Serialize, JsonSchema)]