Skip to content

Classify inbound messages by kind and gate attachment processing on it #2

Description

@jbagsik

What to build

Every stored inbound message carries a kind, and only ordinary messages continue into attachment processing.

A mailbox that sends mail also receives what comes back from it: non-delivery reports, automatic absence replies, and human answers. Today all three are indistinguishable from an ordinary message, so any consumer downstream treats them as one — which is how a delivery report, carrying the original message and its attachments back, ends up feeding an attachment pipeline built for something else entirely.

Four kinds, detected from what the message itself declares rather than from the transport that fetched it:

| Kind | Detected by |
| Delivery report | Content-Type: multipart/report with report-type=delivery-status |
| Auto-reply | Auto-Submitted present and not no (RFC 3834) |
| Ordinary | neither |

A delivery report additionally carries a status class — permanent or transient, from the per-recipient status field of the report (RFC 3463: 5.x.x versus 4.x.x). The distinction is recorded here because it is in the message; what to do about it is not this package's business.

Detection must sit above the driver, not inside one: the headers it reads are properties of the message, and a second transport must not need its own copy of the rules. The raw headers are already stored, so no re-fetch is required.

This package classifies and stops. It does not interpret a report's meaning, correlate it to anything, or act on it.

Acceptance criteria

  • Every stored message carries a kind; existing messages get a defined value rather than null semantics
  • A multipart/report; report-type=delivery-status message is classified as a delivery report, and its permanent/transient class is recorded
  • A message with Auto-Submitted: auto-replied (and other values that are not no) is classified as an auto-reply
  • A message carrying both traits resolves deterministically, and the rule is documented
  • An ordinary message is classified as ordinary and behaves exactly as today
  • Only ordinary messages continue into attachment processing — a delivery report carrying attachments produces none
  • A non-ordinary message is still stored in full and remains queryable by kind
  • Classification is driver-independent and covered by tests that construct messages directly, with no transport involved
  • README documents the kinds and the detection rules; CHANGELOG updated

Blocked by

None — can start immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentSpec is ready for an agent to implement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions