@@ -230,9 +230,9 @@ pub struct CallFromDatabaseParams {
230230pub struct CallFromDatabaseQuery {
231231 /// Hex-encoded [`Identity`] of the sending database.
232232 sender_identity : String ,
233- /// The commitlog offset of the message on the sender side .
234- /// Used for at-most-once delivery via `st_databases_tx_offset `.
235- tx_offset : u64 ,
233+ /// The inter-database message ID from the sender's st_msg_id .
234+ /// Used for at-most-once delivery via `st_inbound_msg_id `.
235+ msg_id : u64 ,
236236}
237237
238238/// Call a reducer on behalf of another database, with deduplication.
@@ -241,10 +241,10 @@ pub struct CallFromDatabaseQuery {
241241///
242242/// Required query params:
243243/// - `sender_identity` — hex-encoded identity of the sending database.
244- /// - `tx_offset ` — the sender's commitlog offset for this message .
244+ /// - `msg_id ` — the inter-database message ID from the sender's st_msg_id .
245245///
246- /// Before invoking the reducer, the receiver checks `st_databases_tx_offset `.
247- /// If the incoming `tx_offset ` is ≤ the last delivered offset for `sender_identity`,
246+ /// Before invoking the reducer, the receiver checks `st_inbound_msg_id `.
247+ /// If the incoming `msg_id ` is ≤ the last delivered msg_id for `sender_identity`,
248248/// the call is a duplicate and 200 OK is returned immediately without running the reducer.
249249/// Otherwise the reducer is invoked, the dedup index is updated atomically in the same
250250/// transaction, and an acknowledgment is returned on success.
@@ -257,19 +257,22 @@ pub async fn call_from_database<S: ControlStateDelegate + NodeDelegate>(
257257 } ) : Path < CallFromDatabaseParams > ,
258258 Query ( CallFromDatabaseQuery {
259259 sender_identity,
260- tx_offset ,
260+ msg_id ,
261261 } ) : Query < CallFromDatabaseQuery > ,
262262 TypedHeader ( content_type) : TypedHeader < headers:: ContentType > ,
263- ByteStringBody ( body) : ByteStringBody ,
263+ body : axum :: body :: Bytes ,
264264) -> axum:: response:: Result < impl IntoResponse > {
265- assert_content_type_json ( content_type) ?;
265+ // IDC callers send BSATN (application/octet-stream).
266+ if content_type != headers:: ContentType :: octet_stream ( ) {
267+ return Err ( ( StatusCode :: UNSUPPORTED_MEDIA_TYPE , "Expected application/octet-stream" ) . into ( ) ) ;
268+ }
266269
267270 let caller_identity = auth. claims . identity ;
268271
269272 let sender_identity = Identity :: from_hex ( & sender_identity)
270273 . map_err ( |_| ( StatusCode :: BAD_REQUEST , "Invalid sender_identity: expected hex-encoded identity" ) ) ?;
271274
272- let args = FunctionArgs :: Json ( body) ;
275+ let args = FunctionArgs :: Bsatn ( body) ;
273276 let connection_id = generate_random_connection_id ( ) ;
274277
275278 let ( module, Database { owner_identity, .. } ) = find_module_and_database ( & worker_ctx, name_or_identity) . await ?;
@@ -290,7 +293,7 @@ pub async fn call_from_database<S: ControlStateDelegate + NodeDelegate>(
290293 & reducer,
291294 args,
292295 sender_identity,
293- tx_offset ,
296+ msg_id ,
294297 )
295298 . await ;
296299
@@ -304,7 +307,9 @@ pub async fn call_from_database<S: ControlStateDelegate + NodeDelegate>(
304307 let ( status, body) = match rcr. outcome {
305308 ReducerOutcome :: Committed => ( StatusCode :: OK , "" . into ( ) ) ,
306309 ReducerOutcome :: Deduplicated => ( StatusCode :: OK , "deduplicated" . into ( ) ) ,
307- ReducerOutcome :: Failed ( errmsg) => ( StatusCode :: from_u16 ( 530 ) . unwrap ( ) , * errmsg) ,
310+ // 422 = reducer ran but returned Err; IDC runtime uses this to distinguish
311+ // reducer failures from transport errors (which it retries).
312+ ReducerOutcome :: Failed ( errmsg) => ( StatusCode :: UNPROCESSABLE_ENTITY , * errmsg) ,
308313 ReducerOutcome :: BudgetExceeded => {
309314 log:: warn!(
310315 "Node's energy budget exceeded for identity: {owner_identity} while executing {reducer}"
@@ -1300,7 +1305,7 @@ pub struct DatabaseRoutes<S> {
13001305 pub subscribe_get : MethodRouter < S > ,
13011306 /// POST: /database/:name_or_identity/call/:reducer
13021307 pub call_reducer_procedure_post : MethodRouter < S > ,
1303- /// POST: /database/:name_or_identity/call-from-database/:reducer?sender_identity=<hex>&tx_offset =<u64>
1308+ /// POST: /database/:name_or_identity/call-from-database/:reducer?sender_identity=<hex>&msg_id =<u64>
13041309 pub call_from_database_post : MethodRouter < S > ,
13051310 /// GET: /database/:name_or_identity/schema
13061311 pub schema_get : MethodRouter < S > ,
0 commit comments