chore(fleet): satisfy lint cleanups

Keep fleet protocol and manager cleanup warning-clean with derived defaults, boxed task-spec parsing, and collapsed control flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hunter B
2026-06-13 13:01:45 -07:00
parent 262f535eb9
commit 90f58261da
4 changed files with 47 additions and 55 deletions
+2 -7
View File
@@ -317,11 +317,12 @@ pub enum FleetHostSpec {
/// The trust level determines what a worker is allowed to do and what
/// secrets it may access. The default for new workers is [`FleetTrustLevel::Sandbox`];
/// operators must explicitly raise trust for SSH or container workers.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Default)]
#[serde(rename_all = "snake_case")]
pub enum FleetTrustLevel {
/// Fully isolated: no network, no secrets, no writes outside `.codewhale/fleet/`.
/// Suitable for untrusted code review, community PR checks, or third-party tool runs.
#[default]
Sandbox = 0,
/// Local-only worker with access to the workspace and configured secrets.
/// Default for local workers. May read repo files but writes are gated.
@@ -337,12 +338,6 @@ pub enum FleetTrustLevel {
Operator = 3,
}
impl Default for FleetTrustLevel {
fn default() -> Self {
Self::Sandbox
}
}
impl FleetTrustLevel {
/// Whether this trust level is allowed to access provider secrets.
#[must_use]
+3 -3
View File
@@ -652,8 +652,9 @@ impl FleetManager {
// Register with the sub-agent manager for headless worker tracking.
// The engine's agent_open path handles actual sub-agent spawning.
if let Some(ref mgr) = self.sub_agent_manager {
if let Ok(guard) = mgr.try_write() {
if let Some(ref mgr) = self.sub_agent_manager
&& let Ok(guard) = mgr.try_write()
{
let run = self
.ledger
.rebuild_state()
@@ -686,7 +687,6 @@ impl FleetManager {
guard.register_worker(worker);
}
}
}
Ok(())
}
+3 -7
View File
@@ -178,10 +178,7 @@ impl FleetScheduler {
worker_id: &str,
report: &mut FleetSchedulerReport,
) -> Result<()> {
let retry_policy = task_spec
.retry_policy
.clone()
.unwrap_or_else(FleetRetryPolicy::default);
let retry_policy = task_spec.retry_policy.clone().unwrap_or_default();
if task.entry.attempts < retry_policy.max_attempts {
let lease_expires_at = self.lease_expires_at();
self.ledger.lease_task(
@@ -342,8 +339,8 @@ impl FleetScheduler {
}
fn task_is_stale(&self, task: &FleetTaskState, state: &FleetLedgerState) -> bool {
if let Some(worker_id) = task.leased_to.as_deref() {
if let Some(heartbeat) = state.heartbeats.get(worker_id)
if let Some(worker_id) = task.leased_to.as_deref()
&& let Some(heartbeat) = state.heartbeats.get(worker_id)
&& let Ok(last) = DateTime::parse_from_rfc3339(&heartbeat.timestamp)
{
let age = self.now.signed_duration_since(last.with_timezone(&Utc));
@@ -351,7 +348,6 @@ impl FleetScheduler {
.to_std()
.map_or(true, |age| age > self.policy.heartbeat_timeout);
}
}
if let Some(deadline) = task.entry.lease_deadline.as_deref()
&& let Ok(deadline) = DateTime::parse_from_rfc3339(deadline)
{
+3 -2
View File
@@ -37,7 +37,7 @@ pub struct FleetTaskSpecDocument {
enum FleetTaskSpecFile {
Document(FleetTaskSpecDocument),
Tasks(Vec<FleetTaskSpec>),
Single(FleetTaskSpec),
Single(Box<FleetTaskSpec>),
}
impl FleetTaskSpecFile {
@@ -61,7 +61,7 @@ impl FleetTaskSpecFile {
labels: BTreeMap::new(),
security_policy: None,
workers: Vec::new(),
tasks: vec![task],
tasks: vec![*task],
},
}
}
@@ -133,6 +133,7 @@ pub fn validate_task_spec_document(doc: &FleetTaskSpecDocument) -> Result<()> {
Ok(())
}
#[allow(clippy::too_many_arguments)]
pub fn write_fleet_artifact_ref(
workspace: &Path,
run_id: &FleetRunId,