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:
@@ -31,6 +31,8 @@
|
||||
//! `invoke()`, the inner call gets a fresh cx with `trigger_depth + 1`
|
||||
//! via the invoke bridge — retry doesn't see or interfere with that.
|
||||
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::Hasher;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -81,11 +83,7 @@ impl BackoffShape {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn register(
|
||||
engine: &mut RhaiEngine,
|
||||
_services: &Services,
|
||||
_cx: Arc<SdkCallCx>,
|
||||
) {
|
||||
pub(super) fn register(engine: &mut RhaiEngine, _services: &Services, _cx: Arc<SdkCallCx>) {
|
||||
// Custom type so scripts can pass Policy values around.
|
||||
engine.register_type_with_name::<Policy>("Policy");
|
||||
|
||||
@@ -125,9 +123,10 @@ pub(super) fn register(
|
||||
// not `with` because `with` is a Rhai reserved keyword.
|
||||
module.set_native_fn(
|
||||
"run",
|
||||
move |ctx: NativeCallContext, policy: Policy, fn_ptr: FnPtr| -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
retry_run(&ctx, &policy, &fn_ptr)
|
||||
},
|
||||
move |ctx: NativeCallContext,
|
||||
policy: Policy,
|
||||
fn_ptr: FnPtr|
|
||||
-> Result<Dynamic, Box<EvalAltResult>> { retry_run(&ctx, &policy, &fn_ptr) },
|
||||
);
|
||||
|
||||
engine.register_static_module("retry", module.into());
|
||||
@@ -147,20 +146,16 @@ fn build_policy(opts: rhai::Map) -> Result<Policy, Box<EvalAltResult>> {
|
||||
p.max_attempts = n.clamp(1, 20);
|
||||
}
|
||||
if let Some(v) = opts.get("backoff") {
|
||||
let s = v
|
||||
.clone()
|
||||
.into_string()
|
||||
.map_err(|_| -> Box<EvalAltResult> {
|
||||
EvalAltResult::ErrorRuntime(
|
||||
"retry::policy: backoff must be a string".into(),
|
||||
rhai::Position::NONE,
|
||||
)
|
||||
.into()
|
||||
})?;
|
||||
let s = v.clone().into_string().map_err(|_| -> Box<EvalAltResult> {
|
||||
EvalAltResult::ErrorRuntime(
|
||||
"retry::policy: backoff must be a string".into(),
|
||||
rhai::Position::NONE,
|
||||
)
|
||||
.into()
|
||||
})?;
|
||||
p.backoff = BackoffShape::from_wire(&s).ok_or_else(|| -> Box<EvalAltResult> {
|
||||
EvalAltResult::ErrorRuntime(
|
||||
"retry::policy: backoff must be \"exponential\" | \"linear\" | \"constant\""
|
||||
.into(),
|
||||
"retry::policy: backoff must be \"exponential\" | \"linear\" | \"constant\"".into(),
|
||||
rhai::Position::NONE,
|
||||
)
|
||||
.into()
|
||||
@@ -251,13 +246,16 @@ fn apply_jitter(raw: u32, pct: u32) -> u32 {
|
||||
// Deterministic-enough jitter without pulling rand into a hot path:
|
||||
// pick a small offset from the high bits of attempt's hash. Random
|
||||
// distribution doesn't matter for retry — bounded ± is what we want.
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::Hasher;
|
||||
let mut h = DefaultHasher::new();
|
||||
h.write_u64(span);
|
||||
h.write_u32(raw);
|
||||
let r = h.finish();
|
||||
let offset = (r % (2 * span + 1)) as i64 - span as i64;
|
||||
// span is bounded by raw*100/100 = raw ≤ u32::MAX, so 2*span+1 fits
|
||||
// in i64 without wrapping. `cast_signed` makes the intent explicit
|
||||
// for clippy::cast_possible_wrap.
|
||||
let modded = r % (2 * span + 1);
|
||||
let offset =
|
||||
i64::try_from(modded).unwrap_or(i64::MAX) - i64::try_from(span).unwrap_or(i64::MAX);
|
||||
let signed = i64::from(raw).saturating_add(offset).max(0);
|
||||
u32::try_from(signed.min(i64::from(u32::MAX))).unwrap_or(u32::MAX)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user