In order to avoid the extensive code duplication that is currently spread across the interfaces we need the core Stan API to start providing analysis routes, including the calculation of effective sample size, rhat, divergences, E-FMI, etc. This will require some reorganization of the `stan`

source.

First and foremost we need to decide on the exact format for I/O, in particular how sample output must be input to the API and how messages and error status is returned by the API. Much of this can be cribbed from the recent discussion about exposing C++ effective sample size functions .

Then we need to reorganize the `stan`

source. Namely we need all analysis code collected together (in particular, effective sample size and rhat functionality should be removed from the chains class as the OO structure is not needed). The combined functionality then needs to be exposed via appropriate services.

Given the partial steps that are being discussed we might as well do this systematically.