The input to the system will be an Analysis::InboundEmail . We create a separated entity in case we want to incorporate more elements in the future.
An Analysis contains a series of Analysis::Rules. When a rule executes, it receives an Analysis::InboundEmail and returns a list of Analysis::Insights.
The result of executing an Analysis is an Analysis::Result that contains a series of Analysis::Insights.
When the analysis is not ok, we store the analysis along with the ActionMailbox::InboundEmail that originated it. This way we can act before even an entry is created.
An AnalysisInsight has a code, a AnalysisInsightDecision . A decision carries a type and a magnitude. The types can be: bounce, spam.
When the aggregated magnitude for a set of rules is > 1 for a given decision, that decision becomes the result of the analysis.