From 4f5d0b1a7e622e6d4cb47d6bf080a7c5d162a00b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 23:32:54 +0200 Subject: [PATCH] Move the deferred-body bound to the wire vocabulary both sides read MAX_DEFERRED_BODY_BYTES was the daemon's constant, but a client caps its content fetch at the same number, and the client crate cannot depend on the daemon. It moves to huginn-mind::wire next to the response schema it bounds; the daemon imports it, the pin test stays in bodies.rs. Co-Authored-By: Claude Opus 5.5 --- crates/huginn-daemon/src/bodies.rs | 4 +--- crates/huginn-daemon/src/serve.rs | 3 ++- crates/huginn-mind/src/lib.rs | 2 +- crates/huginn-mind/src/wire.rs | 5 +++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/huginn-daemon/src/bodies.rs b/crates/huginn-daemon/src/bodies.rs index be6de34..2f21fa2 100644 --- a/crates/huginn-daemon/src/bodies.rs +++ b/crates/huginn-daemon/src/bodies.rs @@ -31,9 +31,6 @@ use cultnet_rs::{CultMeshCdnArtifactManifest, CultMeshCdnChunk}; /// The size of one chunk of a deferred body. Four fit one send with room for a /// control-plane answer beside them on the same session. pub const DEFERRED_CHUNK_BYTES: usize = 256 * 1024; -/// The largest answer that is deferred rather than refused, measured on the -/// encoded payload. -pub const MAX_DEFERRED_BODY_BYTES: u64 = 64 * 1024 * 1024; /// What the daemon keeps across all deferred bodies. pub const DEFERRED_BUDGET_BYTES: u64 = 256 * 1024 * 1024; @@ -163,6 +160,7 @@ impl DeferredBodies { mod tests { use super::*; use cultnet_rs::pack_content; + use huginn_mind::MAX_DEFERRED_BODY_BYTES; /// The three numbers a client author is told, spelled out: a chunk of /// 256 KiB, a largest deferred body of 64 MiB, a budget of 256 MiB that diff --git a/crates/huginn-daemon/src/serve.rs b/crates/huginn-daemon/src/serve.rs index bfc54b8..bb9fb8e 100644 --- a/crates/huginn-daemon/src/serve.rs +++ b/crates/huginn-daemon/src/serve.rs @@ -76,10 +76,11 @@ use huginn_mind::wire::{ use huginn_mind::{Mind, MindRefusal, MindStore, OwnedRedbMessagePackBackingStore}; use crate::bodies::{ - DEFERRED_BUDGET_BYTES, DEFERRED_CHUNK_BYTES, DeferredBodies, MAX_DEFERRED_BODY_BYTES, + DEFERRED_BUDGET_BYTES, DEFERRED_CHUNK_BYTES, DeferredBodies, }; use crate::daemon::{Daemon, Handled, IndexSink, Search, SearchTicket, runtime_id}; use huginn_mind::envelope::{OperationFailure, decode_request, encode_failure, encode_response}; +use huginn_mind::MAX_DEFERRED_BODY_BYTES; use crate::index::{Backoff, Embedder, VectorIndex, WorkerSink}; /// What the loop does when nothing is waiting. A deferred body untouched for diff --git a/crates/huginn-mind/src/lib.rs b/crates/huginn-mind/src/lib.rs index b791aac..29da386 100644 --- a/crates/huginn-mind/src/lib.rs +++ b/crates/huginn-mind/src/lib.rs @@ -52,7 +52,7 @@ pub use receipt::{DocumentVersion, Faculty, HuginnCommitReceipt, PipelineProvena pub use refusal::MindRefusal; pub use store::{MindStore, OwnedRedbMessagePackBackingStore}; pub use wire::{ - DeferredAnswer, HuginnMindRequest, HuginnMindResponse, IndexStatus, MIND_REQUEST_SCHEMA, MIND_REQUEST_SCHEMA_JSON, + DeferredAnswer, HuginnMindRequest, HuginnMindResponse, IndexStatus, MAX_DEFERRED_BODY_BYTES, MIND_REQUEST_SCHEMA, MIND_REQUEST_SCHEMA_JSON, MIND_RESPONSE_SCHEMA, MIND_RESPONSE_SCHEMA_JSON, MIND_SERVICE_ID, MindStatus, }; diff --git a/crates/huginn-mind/src/wire.rs b/crates/huginn-mind/src/wire.rs index dcbd491..54bce78 100644 --- a/crates/huginn-mind/src/wire.rs +++ b/crates/huginn-mind/src/wire.rs @@ -23,6 +23,11 @@ pub const MIND_SERVICE_ID: &str = "huginn.mind"; pub const MIND_REQUEST_SCHEMA: &str = "huginn.mind_request.v1"; pub const MIND_RESPONSE_SCHEMA: &str = "huginn.mind_response.v1"; +/// The largest answer that is deferred rather than refused, measured on the +/// encoded payload. The daemon refuses past it and a client caps its fetch at +/// it, so both sides read one number. +pub const MAX_DEFERRED_BODY_BYTES: u64 = 64 * 1024 * 1024; + /// The published JSON schema of each wire type, as the catalog advertises it. /// The files are derived from the types below and pinned byte for byte by /// `published_wire_schemas_match_derivation`, so the catalog cannot advertise