summaryrefslogtreecommitdiff
path: root/makima/src/daemon
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-31 22:51:47 +0000
committersoryu <soryu@soryu.co>2026-01-31 22:51:47 +0000
commitc7336735050be3722d71a178dcbd180641043b72 (patch)
tree00a4018f374162d38e27f99174b432853d0a23db /makima/src/daemon
parent13a92411b6710da18952e5f5bf4043d0521da38b (diff)
downloadsoryu-makima/task-task-21748e1d-21748e1d.tar.gz
soryu-makima/task-task-21748e1d-21748e1d.zip
[WIP] Heartbeat checkpoint - 2026-01-31 22:51:47 UTCmakima/task-task-21748e1d-21748e1d
Diffstat (limited to 'makima/src/daemon')
-rw-r--r--makima/src/daemon/api/red_team.rs108
1 files changed, 106 insertions, 2 deletions
diff --git a/makima/src/daemon/api/red_team.rs b/makima/src/daemon/api/red_team.rs
index 6d3c969..845f8b8 100644
--- a/makima/src/daemon/api/red_team.rs
+++ b/makima/src/daemon/api/red_team.rs
@@ -1,6 +1,12 @@
//! Red team API methods.
+//!
+//! This module provides API client methods for red team tasks to:
+//! - Notify supervisors about potential issues
+//! - Get status of the red team monitoring
+//! - Access monitored task information
+//! - Request diffs from work tasks (read-only)
-use serde::Serialize;
+use serde::{Deserialize, Serialize};
use uuid::Uuid;
use super::client::{ApiClient, ApiError};
@@ -13,7 +19,7 @@ pub struct RedTeamNotifyRequest {
/// The issue message
pub message: String,
- /// Severity level: low, medium, high, critical
+ /// Severity level: info, warning, critical
pub severity: String,
/// The specific task this relates to (optional)
@@ -29,11 +35,109 @@ pub struct RedTeamNotifyRequest {
pub context: Option<String>,
}
+/// Response from the notify endpoint.
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct RedTeamNotifyResponse {
+ /// Unique ID for this notification
+ pub notification_id: Uuid,
+ /// Whether the notification was successfully delivered to the supervisor
+ pub delivered: bool,
+ /// The supervisor task ID that received the notification
+ pub supervisor_task_id: Option<Uuid>,
+}
+
+/// Response from the status endpoint.
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct RedTeamStatusResponse {
+ /// Contract ID being monitored
+ pub contract_id: Uuid,
+ /// Red team task ID
+ pub red_team_task_id: Uuid,
+ /// Current task status
+ pub status: String,
+ /// Number of notifications sent so far
+ pub notifications_sent: i64,
+}
+
+/// Information about a task being monitored.
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct MonitoredTaskInfo {
+ pub task_id: Uuid,
+ pub name: String,
+ pub status: String,
+ pub created_at: chrono::DateTime<chrono::Utc>,
+}
+
+/// Response from the monitored-tasks endpoint.
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct MonitoredTasksResponse {
+ /// Whether subscription was successful
+ pub success: bool,
+ /// Contract ID being monitored
+ pub contract_id: Uuid,
+ /// Message about the subscription
+ pub message: String,
+ /// List of work tasks currently active in the contract
+ pub active_tasks: Vec<MonitoredTaskInfo>,
+}
+
+/// Response from the task diff endpoint.
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct RedTeamDiffResponse {
+ /// Task ID that was queried
+ pub task_id: Uuid,
+ /// Whether the request was successful
+ pub success: bool,
+ /// The diff content (if available)
+ pub diff: Option<String>,
+ /// Error message if any
+ pub error: Option<String>,
+}
+
impl ApiClient {
/// Send a red team notification about an issue found during adversarial review.
///
/// POST /api/v1/mesh/red-team/notify
+ ///
+ /// This sends an alert to the supervisor task, who can then take action
+ /// such as pausing the work task or providing feedback.
pub async fn red_team_notify(&self, req: RedTeamNotifyRequest) -> Result<JsonValue, ApiError> {
self.post("/api/v1/mesh/red-team/notify", &req).await
}
+
+ /// Get the current status of the red team task.
+ ///
+ /// GET /api/v1/mesh/red-team/status
+ ///
+ /// Returns information about the red team task including the contract
+ /// being monitored and notification statistics.
+ pub async fn red_team_status(&self) -> Result<JsonValue, ApiError> {
+ self.get("/api/v1/mesh/red-team/status").await
+ }
+
+ /// Get the list of active work tasks that can be monitored.
+ ///
+ /// GET /api/v1/mesh/red-team/monitored-tasks
+ ///
+ /// Returns information about all active work tasks in the contract that
+ /// the red team can monitor. This helps understand what tasks are running.
+ pub async fn red_team_monitored_tasks(&self) -> Result<JsonValue, ApiError> {
+ self.get("/api/v1/mesh/red-team/monitored-tasks").await
+ }
+
+ /// Get the diff of changes for a specific work task (read-only).
+ ///
+ /// GET /api/v1/mesh/red-team/tasks/{task_id}/diff
+ ///
+ /// This allows the red team to see what code changes a work task has made.
+ /// Access is read-only - the red team cannot modify any code.
+ pub async fn red_team_task_diff(&self, task_id: Uuid) -> Result<JsonValue, ApiError> {
+ self.get(&format!("/api/v1/mesh/red-team/tasks/{}/diff", task_id))
+ .await
+ }
}