diff --git a/pkgs/fleet/crates/fleet-queue/src/client.rs b/pkgs/fleet/crates/fleet-queue/src/client.rs index 6459bd4a3f..afb87c3fd9 100644 --- a/pkgs/fleet/crates/fleet-queue/src/client.rs +++ b/pkgs/fleet/crates/fleet-queue/src/client.rs @@ -579,12 +579,12 @@ mod tests { assert_eq!(batch_count_flag(Some(1)), Ok(1)); assert_eq!(batch_count_flag(Some(2)), Ok(2)); assert_eq!( - batch_count_flag(Some(crate::turso_queue::BATCH_CLAIM_MAX)), - Ok(crate::turso_queue::BATCH_CLAIM_MAX) + batch_count_flag(Some(crate::BATCH_CLAIM_MAX)), + Ok(crate::BATCH_CLAIM_MAX) ); assert!(batch_count_flag(Some(0)).is_err()); assert!(batch_count_flag(Some(-3)).is_err()); - assert!(batch_count_flag(Some(crate::turso_queue::BATCH_CLAIM_MAX + 1)).is_err()); + assert!(batch_count_flag(Some(crate::BATCH_CLAIM_MAX + 1)).is_err()); } #[test] diff --git a/pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs b/pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs index 236708bdc1..28895f1ab4 100644 --- a/pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs +++ b/pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs @@ -377,11 +377,11 @@ pub(super) fn batch_count_flag(n: Option) -> Result { match n { None => Ok(1), Some(n) if n == 1 => Ok(1), - Some(n) if (2..=crate::turso_queue::BATCH_CLAIM_MAX).contains(&n) => Ok(n), + Some(n) if (2..=crate::BATCH_CLAIM_MAX).contains(&n) => Ok(n), Some(n) => Err(format!( "claim --count {n} is out of range: a batch claim takes \ 1..={} items (#8217)", - crate::turso_queue::BATCH_CLAIM_MAX + crate::BATCH_CLAIM_MAX )), } } diff --git a/pkgs/fleet/crates/fleet-queue/src/lib.rs b/pkgs/fleet/crates/fleet-queue/src/lib.rs index 859dd70407..52fe0b5a5d 100644 --- a/pkgs/fleet/crates/fleet-queue/src/lib.rs +++ b/pkgs/fleet/crates/fleet-queue/src/lib.rs @@ -20,6 +20,21 @@ //! binaries under their historical names (src/bin/) — the //! migration's standing rollback inventory (design note §7). +/// The most tasks one batch claim may take (#8217). A batch is +/// only legitimate paired with immediate per-item dispatch, and +/// the dispatcher must launch + verify-bind every item inside one +/// touch before leases age: five dedicated launches fit that +/// window with margin, and a bigger batch would recreate the +/// claimed-and-idle pile the single-session design forbids. +/// +/// The bound lives at the crate root because both surfaces share +/// it: the client validates `--count` locally so a bad value +/// fails instantly, and the broker enforces the same bound on +/// the wire request (`turso_queue` re-exports it from here). +/// Before #13078 the definition sat inside the broker-gated +/// `turso_queue` tree, so a client-only build could not compile. +pub const BATCH_CLAIM_MAX: i64 = 5; + pub mod backoff; pub mod bin_args; pub mod creation_outbox; @@ -48,5 +63,10 @@ pub mod secrets_broker; pub mod turso_queue; #[cfg(any(feature = "queue-broker", feature = "secrets-broker"))] pub mod uds_http; -#[cfg(feature = "queue-broker")] +// The validation library is shared by both surfaces: the broker +// validates whole packets, and the client validates individual +// flag values (e.g. `--not-before`) against the same rules, so +// the module compiles for either surface (#13078). It depends +// only on serde_json, never on a broker-only dependency. +#[cfg(any(feature = "client", feature = "queue-broker"))] pub mod validate; diff --git a/pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs b/pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs index 3f3d950300..51d819baac 100644 --- a/pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs +++ b/pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs @@ -551,13 +551,11 @@ pub(crate) fn claim_pick_once( /// the quarantine rechecker's releases. pub const MAX_CLAIM_QUARANTINES_PER_CALL: usize = 512; -/// The most tasks one batch claim may take (#8217). A batch is -/// only legitimate paired with immediate per-item dispatch, and -/// the dispatcher must launch + verify-bind every item inside one -/// touch before leases age: five dedicated launches fit that -/// window with margin, and a bigger batch would recreate the -/// claimed-and-idle pile the single-session design forbids. -pub const BATCH_CLAIM_MAX: i64 = 5; +/// The batch-claim bound (#8217) is defined at the crate root so +/// the client surface validates `--count` against the same value +/// the broker enforces here; re-exported so this module's parse +/// path and the `turso_queue::BATCH_CLAIM_MAX` path keep working. +pub use crate::BATCH_CLAIM_MAX; /// Parse a claim request's batch count (#8217): absent means the /// single claim (1); anything outside 1..=BATCH_CLAIM_MAX is a