We propose a general framework for trellis-based detection over channels with infinite memory. A general truncation assumption enables the definition of a trellis diagram, which takes into account a considered portion of the channel memory and possible coding memory at the transmitter side. It is shown that trellis-based maximum a posteriori (MAP) symbol detection algorithms, in the form of forward-backward (FB) algorithms, can be derived on the basis of this memory-truncation assumption. A general approach to the design of truncated -memory (TM) FB algorithms is proposed, and two main classes of algorithms, characterized by coupled and decoupled recursions, respectively, are presented. The complexity of the derived TM-FB algorithms is analyzed in detail. Moreover, it is shown that MAP sequence detection algorithms, based on the Viterbi algorithm, follow easily from one of the proposed classes. Looking backward at this duality between MAP symbol detection algorithms and MAP sequence detection algorithms, it is shown that previous solutions for one case can be systematically extended to the other case. The generality of the proposed framework is shown by considering various examples of stochastic channels. New detection algorithms, as well as generalizations of solutions previously published in the literature, are embedded in the proposed framework. The obtained results do suggest that the performance of the proposed detection algorithms ultimately depends on the truncation depth, almost regardless of the specific detection strategy.