@@ -1488,6 +1488,23 @@ async fn process_via_router(
14881488 }
14891489}
14901490
1491+ /// Remove the engine's stored-input lag note from the client warnings.
1492+ fn extract_stored_input_lag ( value : & mut serde_json:: Value ) -> Option < u64 > {
1493+ let warnings = value. get_mut ( "warnings" ) ?. as_array_mut ( ) ?;
1494+ let mut lag = None ;
1495+ warnings. retain ( |warning| {
1496+ let Some ( text) = warning
1497+ . as_str ( )
1498+ . and_then ( |text| text. strip_prefix ( "asap_stored_input_lag_ms:" ) )
1499+ else {
1500+ return true ;
1501+ } ;
1502+ lag = text. parse ( ) . ok ( ) ;
1503+ false
1504+ } ) ;
1505+ lag
1506+ }
1507+
14911508fn extract_logical_provenance (
14921509 value : & mut serde_json:: Value ,
14931510) -> Option < Result < ( u64 , u64 , u64 , u64 , u64 , u64 , u64 ) , ( ) > > {
@@ -1622,6 +1639,12 @@ async fn annotate_data_source(response: Response, data_source_id: &'static str)
16221639 return Response :: from_parts ( parts, axum:: body:: Body :: from ( bytes) ) ;
16231640 }
16241641 if data_source_id == "asap_query" {
1642+ if let Some ( lag) = extract_stored_input_lag ( & mut value) {
1643+ parts. headers . insert (
1644+ "x-asap-stored-input-lag-ms" ,
1645+ axum:: http:: HeaderValue :: from ( lag) ,
1646+ ) ;
1647+ }
16251648 if let Some ( provenance) = extract_logical_provenance ( & mut value) {
16261649 let ( route, detail) = match provenance {
16271650 Ok ( ( raw, summary, memo, remote, _legacy_indexes, rpcs, branches) ) => {
@@ -6477,6 +6500,22 @@ mod logical_provenance_tests {
64776500 assert_eq ! ( value[ "warnings" ] , serde_json:: json!( [ "partial data" ] ) ) ;
64786501 }
64796502
6503+ // The stored-input lag of a mixed program becomes response metadata, not a client warning.
6504+ #[ tokio:: test]
6505+ async fn stored_input_lag_is_a_response_header ( ) {
6506+ let response = Json ( serde_json:: json!( { "status" : "success" , "warnings" : [
6507+ "asap_stored_input_lag_ms:40000" , "asap_logical_stats:raw=0,summary=2,memo_hits=0,remote=0,remote_rpcs=0,remote_branches=0"
6508+ ] , "data" : { "resultType" : "vector" , "result" : [ ] } } ) ) . into_response ( ) ;
6509+ let response = annotate_data_source ( response, "asap_query" ) . await ;
6510+ assert_eq ! ( response. headers( ) [ "x-asap-stored-input-lag-ms" ] , "40000" ) ;
6511+ assert_eq ! ( response. headers( ) [ "x-asap-execution" ] , "warm" ) ;
6512+ let bytes = axum:: body:: to_bytes ( response. into_body ( ) , 4096 )
6513+ . await
6514+ . unwrap ( ) ;
6515+ let value: serde_json:: Value = serde_json:: from_slice ( & bytes) . unwrap ( ) ;
6516+ assert ! ( value[ "warnings" ] . as_array( ) . unwrap( ) . is_empty( ) ) ;
6517+ }
6518+
64806519 #[ test]
64816520 fn contradictory_provenance_is_not_warm ( ) {
64826521 // Any observed local raw branch invalidates a deployed plan.
0 commit comments