email-connect/tests/test_mas_gateway_evidence.py
tegwick bdf95c1af8
Some checks failed
Transactional mail acceptance / mail (push) Failing after 1m22s
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Container Image / build-and-push (push) Successful in 32s
Record the shipped mail slices and the MAS evidence mapping.
SCOPE.md now describes the mailbox scanner and the transactional receiver.
The generic provider API and UI stay intent. A MAS gateway event maps into
the existing evidence ceiling without a claim that a person read the mail.

Assistant: grok
Assistant-Session: 01a198fa-fd27-7e41-a0a2-57355c3e4efd
2026-11-01 23:13:12 +01:00

60 lines
2.3 KiB
Python

"""MAS gateway event to email-connect evidence ceiling (mas-email-evidence 0.1)."""
from email_connect.mas_gateway_evidence import from_gateway_event
def event(**message):
base = {"from": "a@example.org", "subject": "hello", "text": "body"}
base.update(message)
return {
"mas_event_version": "0.1",
"recipient": "ticket=GS-1@mas.coulomb.social",
"mas": {"valid": True},
"message": base,
}
def test_ordinary_mail_is_mx_acceptance_only():
got = from_gateway_event(event())
assert got["outcome"] == "mx_accepted"
assert got["event_type"] == "notification.endpoint.accepted"
assert got["assessment_subclass"] == "undef.endpoint_accepted_only"
assert got["evidence_ceiling"]["can_prove_human_awareness"] is False
assert got["evidence_ceiling"]["max_positive_strength"] == "medium"
def test_reply_is_medium_and_does_not_prove_a_person_read_it():
got = from_gateway_event(event(in_reply_to="<m@x>", text="I saw this"))
assert got["outcome"] == "reply_received"
assert got["evidence_strength"] == "medium"
assert "does not prove" in got["normalized_meaning"]
assert got["evidence_ceiling"]["can_prove_human_awareness"] is False
def test_automatic_reply_is_not_a_human_reply():
got = from_gateway_event(event(in_reply_to="<m@x>", auto_submitted="auto-replied", text="away"))
assert got["outcome"] == "out_of_office"
assert got["event_type"] == "interaction.out_of_office_received"
def test_permanent_and_temporary_bounces():
hard = from_gateway_event(event(**{
"from": "mailer-daemon@mx.example",
"subject": "Undelivered Mail Returned to Sender",
"text": "Final-Recipient: rfc822; b@example.org\nStatus: 5.1.1\nuser unknown",
}))
soft = from_gateway_event(event(**{
"from": "mailer-daemon@mx.example",
"subject": "Delivery Status Notification",
"text": "Final-Recipient: rfc822; b@example.org\nStatus: 4.2.2\nmailbox full",
}))
assert hard["outcome"] == "bounced_permanent"
assert soft["outcome"] == "bounced_temporary"
assert hard["evidence_ceiling"] == soft["evidence_ceiling"]
def test_a_non_event_makes_no_channel_claim():
got = from_gateway_event({"hello": "no"})
assert got["outcome"] == "parse_failed"
assert got["evidence_strength"] == "none"
assert got["recipient"] is None