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:
@@ -264,16 +264,14 @@ pub async fn build_app(
|
||||
// v1.1.9 durable per-app queues. Producers write to queue_messages
|
||||
// via QueueService; the dispatcher's queue arm (commit 6) consumes
|
||||
// claimed messages and fires the registered queue:receive trigger.
|
||||
let queue_repo: Arc<dyn picloud_manager_core::queue_repo::QueueRepo> =
|
||||
Arc::new(picloud_manager_core::queue_repo::PostgresQueueRepo::new(
|
||||
pool.clone(),
|
||||
));
|
||||
let queue: Arc<dyn picloud_shared::QueueService> = Arc::new(
|
||||
picloud_manager_core::queue_service::QueueServiceImpl::new(
|
||||
let queue_repo: Arc<dyn picloud_manager_core::queue_repo::QueueRepo> = Arc::new(
|
||||
picloud_manager_core::queue_repo::PostgresQueueRepo::new(pool.clone()),
|
||||
);
|
||||
let queue: Arc<dyn picloud_shared::QueueService> =
|
||||
Arc::new(picloud_manager_core::queue_service::QueueServiceImpl::new(
|
||||
queue_repo.clone(),
|
||||
authz.clone(),
|
||||
),
|
||||
);
|
||||
));
|
||||
// Route table created early (before Services) so InvokeServiceImpl
|
||||
// can use it for path resolution. It's populated below from the
|
||||
// route_repo, then re-populated whenever the admin layer writes
|
||||
@@ -312,8 +310,10 @@ pub async fn build_app(
|
||||
);
|
||||
// v1.1.9: keep the invoke depth bound aligned with the dispatcher's
|
||||
// trigger-depth bound (same counter under the hood).
|
||||
let mut engine_limits = Limits::default();
|
||||
engine_limits.trigger_depth_max = trigger_config.max_trigger_depth;
|
||||
let engine_limits = Limits {
|
||||
trigger_depth_max: trigger_config.max_trigger_depth,
|
||||
..Limits::default()
|
||||
};
|
||||
let engine = Arc::new(Engine::new(engine_limits, services));
|
||||
// v1.1.9: install the back-reference the `invoke` SDK bridge needs
|
||||
// for synchronous re-entry. Weak so the Arc-cycle stays loose;
|
||||
|
||||
@@ -116,7 +116,9 @@ async fn poll_marker(pool: &PgPool, app_id: &str) -> Option<Value> {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn invoke_by_name_same_app_returns_value() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool.clone(), "invoke-name").await;
|
||||
|
||||
// Callee returns 42 — the simplest possible round-trip.
|
||||
@@ -124,7 +126,7 @@ async fn invoke_by_name_same_app_returns_value() {
|
||||
&server,
|
||||
&app_id,
|
||||
"callee",
|
||||
r#"#{ statusCode: 200, body: 42 }"#,
|
||||
r"#{ statusCode: 200, body: 42 }",
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -146,7 +148,9 @@ async fn invoke_by_name_same_app_returns_value() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn invoke_cross_app_rejects() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_a) = server_for(pool.clone(), "invoke-xa").await;
|
||||
// Create a second app via the SAME server / admin (Owner can manage
|
||||
// every app) so the script-create calls don't run into role gates.
|
||||
@@ -163,7 +167,7 @@ async fn invoke_cross_app_rejects() {
|
||||
&server,
|
||||
&app_b,
|
||||
"callee_b",
|
||||
r#"#{ statusCode: 200, body: 0 }"#,
|
||||
r"#{ statusCode: 200, body: 0 }",
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -193,7 +197,9 @@ async fn invoke_cross_app_rejects() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn invoke_depth_limit_exceeds_cleanly() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool.clone(), "invoke-depth").await;
|
||||
|
||||
// The recurser propagates any throw (no try-catch). At the depth
|
||||
@@ -235,7 +241,9 @@ async fn invoke_depth_limit_exceeds_cleanly() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn invoke_async_enqueues_outbox_row() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool.clone(), "invoke-async").await;
|
||||
|
||||
// Callee writes a marker the test polls — the dispatcher must fire
|
||||
|
||||
@@ -127,14 +127,13 @@ async fn poll_marker(pool: &PgPool, app_id: &str) -> Option<Value> {
|
||||
}
|
||||
|
||||
async fn count_queue_messages(pool: &PgPool, app_id: &str, queue: &str) -> i64 {
|
||||
let (n,): (i64,) = sqlx::query_as(
|
||||
"SELECT COUNT(*) FROM queue_messages WHERE app_id = $1 AND queue_name = $2",
|
||||
)
|
||||
.bind(Uuid::parse_str(app_id).expect("uuid"))
|
||||
.bind(queue)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.expect("queue count");
|
||||
let (n,): (i64,) =
|
||||
sqlx::query_as("SELECT COUNT(*) FROM queue_messages WHERE app_id = $1 AND queue_name = $2")
|
||||
.bind(Uuid::parse_str(app_id).expect("uuid"))
|
||||
.bind(queue)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.expect("queue count");
|
||||
n
|
||||
}
|
||||
|
||||
@@ -170,7 +169,9 @@ async fn enqueue_directly(pool: &PgPool, app_id: &str, queue: &str, payload: Val
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn queue_receive_acks_on_success() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool.clone(), "ack").await;
|
||||
|
||||
let script_id = create_script(&server, &app_id, "worker", ACK_HANDLER).await;
|
||||
@@ -186,9 +187,7 @@ async fn queue_receive_acks_on_success() {
|
||||
|
||||
enqueue_directly(&pool, &app_id, "jobs", json!({ "x": 42 })).await;
|
||||
|
||||
let marker = poll_marker(&pool, &app_id)
|
||||
.await
|
||||
.expect("handler fired");
|
||||
let marker = poll_marker(&pool, &app_id).await.expect("handler fired");
|
||||
assert_eq!(marker["source"], "queue");
|
||||
assert_eq!(marker["queue"]["queue_name"], "jobs");
|
||||
assert_eq!(marker["queue"]["message"]["x"], 42);
|
||||
@@ -199,7 +198,9 @@ async fn queue_receive_acks_on_success() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn queue_receive_dead_letters_after_max_attempts() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool.clone(), "dl").await;
|
||||
|
||||
let script_id = create_script(&server, &app_id, "fail", THROW_HANDLER).await;
|
||||
@@ -236,7 +237,9 @@ async fn queue_receive_dead_letters_after_max_attempts() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn queue_one_consumer_per_queue_rejected() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool.clone(), "onecon").await;
|
||||
|
||||
let s1 = create_script(&server, &app_id, "first", ACK_HANDLER).await;
|
||||
@@ -276,7 +279,9 @@ async fn queue_one_consumer_per_queue_rejected() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn queue_visibility_timeout_reclaim() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool.clone(), "vt").await;
|
||||
|
||||
let script_id = create_script(&server, &app_id, "slow", ACK_HANDLER).await;
|
||||
@@ -317,13 +322,12 @@ async fn queue_visibility_timeout_reclaim() {
|
||||
// Otherwise the reclaim path is the only way the message would
|
||||
// have been picked up. Poll the claim state.
|
||||
for _ in 0..50 {
|
||||
let row: Option<(Option<Uuid>,)> = sqlx::query_as(
|
||||
"SELECT claim_token FROM queue_messages WHERE id = $1",
|
||||
)
|
||||
.bind(msg_id)
|
||||
.fetch_optional(&pool)
|
||||
.await
|
||||
.expect("read");
|
||||
let row: Option<(Option<Uuid>,)> =
|
||||
sqlx::query_as("SELECT claim_token FROM queue_messages WHERE id = $1")
|
||||
.bind(msg_id)
|
||||
.fetch_optional(&pool)
|
||||
.await
|
||||
.expect("read");
|
||||
if let Some((token,)) = row {
|
||||
if token.is_none() {
|
||||
return; // reclaim succeeded — claim cleared
|
||||
|
||||
@@ -93,7 +93,9 @@ async fn execute(server: &TestServer, script_id: &str) -> Value {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn retry_run_eventually_succeeds_inside_http_handler() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool, "retry-succ").await;
|
||||
|
||||
// attempt counter mutates across retries; the 3rd attempt returns
|
||||
@@ -114,7 +116,9 @@ async fn retry_run_eventually_succeeds_inside_http_handler() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn retry_run_surfaces_last_error_after_max_attempts() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool, "retry-surf").await;
|
||||
|
||||
let src = r#"
|
||||
@@ -135,7 +139,9 @@ async fn retry_run_surfaces_last_error_after_max_attempts() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn retry_on_codes_filters_unmatched_errors() {
|
||||
let Some(pool) = pool_or_skip().await else { return };
|
||||
let Some(pool) = pool_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
let (server, app_id) = server_for(pool, "retry-codes").await;
|
||||
|
||||
// attempts is mutated on every entry; we throw a non-matching code
|
||||
@@ -156,5 +162,9 @@ async fn retry_on_codes_filters_unmatched_errors() {
|
||||
"#;
|
||||
let script_id = create_script(&server, &app_id, "codes", src).await;
|
||||
let body = execute(&server, &script_id).await;
|
||||
assert_eq!(body, json!(1), "non-matching error should surface immediately");
|
||||
assert_eq!(
|
||||
body,
|
||||
json!(1),
|
||||
"non-matching error should surface immediately"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user