chore(v1.1.9): clippy clean — workspace -D warnings
Surfaced + fixed during the F3 attestation:
- executor-core/sdk/queue.rs: drop redundant .map(|()| ()) call sites;
enqueue_blocking discards QueueMessageId via .map(|_id| ()) (intentional)
- executor-core/sdk/retry.rs: hoist use std::collections::hash_map::DefaultHasher
+ use std::hash::Hasher to the top of the file (clippy::items_after_statements);
replace `as i64` casts with i64::try_from + clear comment about jitter
bound (clippy::cast_possible_wrap)
- executor-core/sdk/invoke.rs: move _LIMITS_IS_COPY const before #[cfg(test)]
mod tests (clippy::items_after_test_module)
- manager-core/dispatcher.rs: dispatch_one_queue gains #[allow(too_many_lines)]
(it's the queue tick's whole logic — split makes it less readable than
the lint); .map(...).unwrap_or(default) → .map_or(default, ...)
- picloud/lib.rs: Limits { trigger_depth_max, ..Limits::default() } via
struct-update instead of let-mut-assign (clippy::field_reassign_with_default)
- tests: r#"..."# → r"..." where there are no `"` inside (clippy::needless_raw_string_hashes);
combine InvokeTarget::Name | InvokeTarget::Path arms with identical bodies
in sdk_invoke.rs (clippy::match_same_arms)
cargo fmt --all -- --check 2>&1 | tail -3: no output (exit 0)
cargo clippy --workspace --all-targets --all-features -- -D warnings:
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.41s
Workspace lib smoke: 432 passing (306 manager-core + 74 executor-core + 34 shared + 18 orchestrator-core).
DB-gated E2E (against docker compose postgres on localhost:15432):
queue_e2e: 4 ok / invoke_e2e: 4 ok / retry_e2e: 3 ok / migration_queue_messages: 4 ok / schema_snapshot: 1 ok
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -92,11 +92,7 @@ async fn login(State(state): State<AuthState>, Json(input): Json<LoginRequest>)
|
||||
// canonical row used in the response DTO.
|
||||
let (stored_hash, user_id, is_active) = match creds {
|
||||
Some(c) => (c.password_hash, Some(c.id), c.is_active),
|
||||
None => (
|
||||
crate::auth::TIMING_FLAT_DUMMY_HASH.to_string(),
|
||||
None,
|
||||
false,
|
||||
),
|
||||
None => (crate::auth::TIMING_FLAT_DUMMY_HASH.to_string(), None, false),
|
||||
};
|
||||
|
||||
let password_ok = verify_password(&stored_hash, &input.password);
|
||||
|
||||
@@ -163,6 +163,7 @@ impl Dispatcher {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
async fn dispatch_one_queue(
|
||||
&self,
|
||||
consumer: &ActiveQueueConsumer,
|
||||
@@ -183,7 +184,11 @@ impl Dispatcher {
|
||||
let Ok(permit) = self.gate.try_acquire() else {
|
||||
let _ = self
|
||||
.queue
|
||||
.nack(claimed.id, claimed.claim_token, chrono::Duration::milliseconds(100))
|
||||
.nack(
|
||||
claimed.id,
|
||||
claimed.claim_token,
|
||||
chrono::Duration::milliseconds(100),
|
||||
)
|
||||
.await;
|
||||
return Ok(());
|
||||
};
|
||||
@@ -299,7 +304,11 @@ impl Dispatcher {
|
||||
self.config.retry_jitter_pct,
|
||||
);
|
||||
let delay = chrono::Duration::milliseconds(i64::from(delay_ms));
|
||||
if let Err(e) = self.queue.nack(claimed.id, claimed.claim_token, delay).await {
|
||||
if let Err(e) = self
|
||||
.queue
|
||||
.nack(claimed.id, claimed.claim_token, delay)
|
||||
.await
|
||||
{
|
||||
tracing::warn!(?e, "queue nack failed");
|
||||
}
|
||||
return;
|
||||
@@ -621,12 +630,14 @@ impl Dispatcher {
|
||||
));
|
||||
}
|
||||
|
||||
let args = payload.get("args").cloned().unwrap_or(serde_json::Value::Null);
|
||||
let args = payload
|
||||
.get("args")
|
||||
.cloned()
|
||||
.unwrap_or(serde_json::Value::Null);
|
||||
let trigger_depth = payload
|
||||
.get("trigger_depth")
|
||||
.and_then(serde_json::Value::as_u64)
|
||||
.map(|n| u32::try_from(n).unwrap_or(u32::MAX))
|
||||
.unwrap_or(row.trigger_depth);
|
||||
.map_or(row.trigger_depth, |n| u32::try_from(n).unwrap_or(u32::MAX));
|
||||
|
||||
let execution_id = ExecutionId::new();
|
||||
let req = ExecRequest {
|
||||
|
||||
@@ -94,9 +94,8 @@ impl InvokeServiceImpl {
|
||||
// most route-resolution invokes target write endpoints; a more
|
||||
// exact API would surface method via the SDK in a future bump.
|
||||
let app_routes = self.routes.snapshot_for_app(cx.app_id);
|
||||
let m = matcher::r#match(&app_routes, "invoke.local", "POST", path).or_else(|| {
|
||||
matcher::r#match(&app_routes, "invoke.local", "GET", path)
|
||||
});
|
||||
let m = matcher::r#match(&app_routes, "invoke.local", "POST", path)
|
||||
.or_else(|| matcher::r#match(&app_routes, "invoke.local", "GET", path));
|
||||
let m = m.ok_or_else(|| InvokeError::NotFound(format!("path {path:?}")))?;
|
||||
// Resolve the script the matched route bound. Cross-app
|
||||
// re-check via the script row (defense in depth — RouteTable
|
||||
@@ -175,10 +174,7 @@ mod tests {
|
||||
}
|
||||
#[async_trait]
|
||||
impl ScriptRepository for OneScriptRepo {
|
||||
async fn get(
|
||||
&self,
|
||||
id: ScriptId,
|
||||
) -> Result<Option<Script>, ScriptRepositoryError> {
|
||||
async fn get(&self, id: ScriptId) -> Result<Option<Script>, ScriptRepositoryError> {
|
||||
Ok(if id == self.script.id {
|
||||
Some(self.script.clone())
|
||||
} else {
|
||||
@@ -190,19 +186,18 @@ mod tests {
|
||||
app_id: AppId,
|
||||
name: &str,
|
||||
) -> Result<Option<Script>, ScriptRepositoryError> {
|
||||
Ok(if app_id == self.script.app_id && name == self.script.name {
|
||||
Some(self.script.clone())
|
||||
} else {
|
||||
None
|
||||
})
|
||||
Ok(
|
||||
if app_id == self.script.app_id && name == self.script.name {
|
||||
Some(self.script.clone())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
)
|
||||
}
|
||||
async fn list(&self) -> Result<Vec<Script>, ScriptRepositoryError> {
|
||||
Ok(vec![self.script.clone()])
|
||||
}
|
||||
async fn list_for_app(
|
||||
&self,
|
||||
_app_id: AppId,
|
||||
) -> Result<Vec<Script>, ScriptRepositoryError> {
|
||||
async fn list_for_app(&self, _app_id: AppId) -> Result<Vec<Script>, ScriptRepositoryError> {
|
||||
unimplemented!()
|
||||
}
|
||||
async fn list_for_user(
|
||||
@@ -331,7 +326,9 @@ mod tests {
|
||||
let app_b = AppId::new();
|
||||
let script = make_script(app_a, "worker");
|
||||
let svc = InvokeServiceImpl::new(
|
||||
Arc::new(OneScriptRepo { script: script.clone() }),
|
||||
Arc::new(OneScriptRepo {
|
||||
script: script.clone(),
|
||||
}),
|
||||
Arc::new(RouteTable::new()),
|
||||
Arc::new(CapturingOutbox {
|
||||
last: tokio::sync::Mutex::new(None),
|
||||
@@ -339,7 +336,10 @@ mod tests {
|
||||
);
|
||||
// Caller is in app_b but the script belongs to app_a.
|
||||
let cx = anon_cx(app_b);
|
||||
let err = svc.resolve(&cx, InvokeTarget::Id(script.id)).await.unwrap_err();
|
||||
let err = svc
|
||||
.resolve(&cx, InvokeTarget::Id(script.id))
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert!(matches!(err, InvokeError::CrossApp));
|
||||
}
|
||||
|
||||
@@ -348,7 +348,9 @@ mod tests {
|
||||
let app_id = AppId::new();
|
||||
let script = make_script(app_id, "worker");
|
||||
let svc = InvokeServiceImpl::new(
|
||||
Arc::new(OneScriptRepo { script: script.clone() }),
|
||||
Arc::new(OneScriptRepo {
|
||||
script: script.clone(),
|
||||
}),
|
||||
Arc::new(RouteTable::new()),
|
||||
Arc::new(CapturingOutbox {
|
||||
last: tokio::sync::Mutex::new(None),
|
||||
@@ -389,7 +391,9 @@ mod tests {
|
||||
last: tokio::sync::Mutex::new(None),
|
||||
});
|
||||
let svc = InvokeServiceImpl::new(
|
||||
Arc::new(OneScriptRepo { script: script.clone() }),
|
||||
Arc::new(OneScriptRepo {
|
||||
script: script.clone(),
|
||||
}),
|
||||
Arc::new(RouteTable::new()),
|
||||
outbox.clone(),
|
||||
);
|
||||
|
||||
@@ -45,6 +45,7 @@ pub mod files_service;
|
||||
pub mod files_sweep;
|
||||
pub mod gc;
|
||||
pub mod http_service;
|
||||
pub mod invoke_service;
|
||||
pub mod kv_repo;
|
||||
pub mod kv_service;
|
||||
pub mod log_sink;
|
||||
@@ -55,7 +56,6 @@ pub mod outbox_repo;
|
||||
pub mod principal_resolver;
|
||||
pub mod pubsub_repo;
|
||||
pub mod pubsub_service;
|
||||
pub mod invoke_service;
|
||||
pub mod queue_repo;
|
||||
pub mod queue_service;
|
||||
pub mod queues_api;
|
||||
|
||||
@@ -114,8 +114,7 @@ pub trait QueueRepo: Send + Sync {
|
||||
async fn depth(&self, app_id: AppId, queue_name: &str) -> Result<u64, QueueRepoError>;
|
||||
|
||||
/// `queue::depth_pending(name)` — currently claimable rows.
|
||||
async fn depth_pending(&self, app_id: AppId, queue_name: &str)
|
||||
-> Result<u64, QueueRepoError>;
|
||||
async fn depth_pending(&self, app_id: AppId, queue_name: &str) -> Result<u64, QueueRepoError>;
|
||||
|
||||
/// Dashboard read-only view: every distinct queue name in `app_id`
|
||||
/// with its aggregate counts.
|
||||
@@ -217,13 +216,11 @@ impl QueueRepo for PostgresQueueRepo {
|
||||
message_id: QueueMessageId,
|
||||
claim_token: Uuid,
|
||||
) -> Result<bool, QueueRepoError> {
|
||||
let res = sqlx::query(
|
||||
"DELETE FROM queue_messages WHERE id = $1 AND claim_token = $2",
|
||||
)
|
||||
.bind(message_id.into_inner())
|
||||
.bind(claim_token)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
let res = sqlx::query("DELETE FROM queue_messages WHERE id = $1 AND claim_token = $2")
|
||||
.bind(message_id.into_inner())
|
||||
.bind(claim_token)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
Ok(res.rows_affected() == 1)
|
||||
}
|
||||
|
||||
@@ -275,11 +272,7 @@ impl QueueRepo for PostgresQueueRepo {
|
||||
Ok(u64::try_from(n).unwrap_or(0))
|
||||
}
|
||||
|
||||
async fn depth_pending(
|
||||
&self,
|
||||
app_id: AppId,
|
||||
queue_name: &str,
|
||||
) -> Result<u64, QueueRepoError> {
|
||||
async fn depth_pending(&self, app_id: AppId, queue_name: &str) -> Result<u64, QueueRepoError> {
|
||||
let (n,): (i64,) = sqlx::query_as(
|
||||
"SELECT COUNT(*) FROM queue_messages \
|
||||
WHERE app_id = $1 AND queue_name = $2 \
|
||||
|
||||
@@ -1323,13 +1323,11 @@ impl TriggerRepo for PostgresTriggerRepo {
|
||||
trigger_id: TriggerId,
|
||||
at: DateTime<Utc>,
|
||||
) -> Result<(), TriggerRepoError> {
|
||||
sqlx::query(
|
||||
"UPDATE queue_trigger_details SET last_fired_at = $2 WHERE trigger_id = $1",
|
||||
)
|
||||
.bind(trigger_id.into_inner())
|
||||
.bind(at)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
sqlx::query("UPDATE queue_trigger_details SET last_fired_at = $2 WHERE trigger_id = $1")
|
||||
.bind(trigger_id.into_inner())
|
||||
.bind(at)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user