Files
Kigi-CLI/crates/codegen/kigi-workspace/src/error.rs
T
ZacharyZhang-NY fa75eb139a M2 audit: excise the Computer Hub stack — Kigi's last remote-cloud surface
Removed root-and-branch for the zero-egress guarantee (the hub was xAI's
remote-workspace/cloud-sandbox service):

- Crates deleted: kigi-computer-hub-core, kigi-computer-hub-sdk,
  kigi-computer-hub-mcp-adapter, kigi-workspace-client (hub-proxied
  workspace RPC client), and kigi-tracing (its sole network path was the
  OTLP gRPC exporter; zero consumers remained). kigi-tracing-macros
  (purely local) stays.
- kigi-workspace: every hub surface deleted — hub server/channel/auth,
  HITL-over-hub permissions, donation/metrics pumps, file upload RPCs,
  hub tool-snapshot merge (resolve pipeline is MCP-only now),
  WorkspaceOps::Proxy. Local worktrees, sessions, leader IPC, MCP, and
  the ACP permission prompt path are untouched; LocalRegistry re-homed
  into kigi-tool-runtime on the existing ToolDyn types so in-process
  tool dispatch is unchanged.
- kigi-shell: leader workspace-exposure control surface (incl. the
  wss://computer-hub... URL), [hub] config, ObservabilityBridge, hub
  WebSocket proxy, dead OTLP config knobs. ClientMode::Headless (never
  constructed) removed.
- kigi-tui/bin: hidden `kigi workspace` command removed (`kigi
  worktree` stays).
- Renames: --xai-api-base-url → --api-base-url / KIGI_API_BASE_URL /
  [endpoints] api_base_url (serde alias keeps old configs working; the
  flag feeds BYOK/custom-endpoint routing, not main inference);
  grok_version → kigi_version in inspect/models-cache/trace metadata
  (old caches self-heal via version-mismatch refetch).
- Dependency tree: dropped fastrace*, opentelemetry-otlp/http/proto,
  tokio-tungstenite from the workspace; fixed the 4 real useless_format
  violations the fastrace lint allowance was masking and removed the
  allowance.
- marketplaceAllowlist kept: it gates the LOCAL plugin-marketplace
  feature, not an xAI service.

Known §9 leftover (deliberate, for the M3 sweep): the BYOK default base
URL string. Gates: workspace check/clippy 0/0, fmt, deny ok; suites
green (workspace 1042, shell 4918, tui 6634, tools 2608, tool-runtime
47, mcp 154).
2026-07-17 22:34:10 -04:00

87 lines
3.0 KiB
Rust

//! Workspace error types.
use crate::capability::CapabilityMode;
/// Errors surfaced by the workspace public API.
///
/// `#[non_exhaustive]` so adding new variants is a non-breaking change.
/// Tests should match on variants rather than scrape the `Display` text.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum WorkspaceError {
#[error("parent session not found: {0}")]
ParentSessionNotFound(String),
#[error("session not found: {0}")]
SessionNotFound(String),
#[error("session already exists: {0}")]
SessionAlreadyExists(String),
#[error("agent_id must be non-empty")]
EmptyAgentId,
#[error("the main session cannot be dropped")]
CannotDropMainSession,
#[error("toolset finalization failed: {0}")]
Finalize(String),
#[error("capability widening rejected: child {child:?} is not a subset of parent {parent:?}")]
CapabilityWidening {
parent: CapabilityMode,
child: CapabilityMode,
},
#[error("session {caller:?} is not authorised to operate on session {target:?}")]
Unauthorized { caller: String, target: String },
/// A toolset mutation was rejected because the target session has an
/// active turn. Retryable at the turn boundary (`after_turn`).
#[error("turn active for session {0}; retry the tool-config update at the turn boundary")]
TurnActive(String),
#[error("maximum fork depth exceeded for parent session {parent:?}")]
MaxDepthExceeded { parent: String },
#[error("internal task failure: {0}")]
JoinError(String),
#[error("invalid hunk action: {0}")]
InvalidHunkAction(String),
#[error("hunk action failed: {0}")]
HunkActionFailed(String),
/// An internal workspace error.
#[error("workspace error: {0}")]
Internal(String),
/// Deploy-service error tagged with its gRPC status class; see
/// [`DeployError`] for how the class crosses the workspace RPC boundary.
///
/// [`DeployError`]: kigi_workspace_types::rpc::deploy::DeployError
#[error("deploy error: {message}")]
DeployError {
kind: kigi_workspace_types::rpc::deploy::DeployError,
message: String,
},
/// The workspace is draining/shutting down and is no longer accepting new
/// sessions. Surfaced when a `bind`/create races a terminal drain so the
/// shared upload queue is never torn down out from under a fresh session.
#[error("workspace is shutting down; not accepting new sessions")]
ShuttingDown,
/// The session's toolset is externally owned — installed by a local
/// (shell) bind, its `Terminal` resource is not the session-owned
/// backend — so an RPC-driven toolset mutation is refused instead of
/// silently skipped. Hard error: retrying cannot succeed while the
/// local bind holds the toolset.
#[error("toolset externally owned (local bind), mutation refused: {0}")]
ToolsetExternallyOwned(String),
}
/// Convenience alias for the workspace's primary `Result` type.
pub type WorkspaceResult<T> = Result<T, WorkspaceError>;