Compare commits

6 Commits

Author SHA1 Message Date
c541577788 updated docs strings and added README.md 2026-03-08 17:59:53 +05:30
0453fdd88a mcp docs 2026-03-08 00:41:26 +05:30
9f9e472ada google styled doc 2026-03-08 00:29:24 +05:30
9f37af5761 module as source doc fixes (#2)
Reviewed-on: #2
Co-authored-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com>
Co-committed-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com>
2026-02-21 16:47:18 +00:00
346cc5f6fb Merge remote-tracking branch 'origin/main'
# Conflicts:
#	manage_docs.py
#	requirements.txt
2026-01-22 17:25:31 +05:30
f7f9744e47 docs-and-mcps (#1)
Reviewed-on: #1
Co-authored-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com>
Co-committed-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com>
2026-01-22 11:28:23 +00:00
99 changed files with 6647 additions and 895 deletions

1
.gitignore vendored
View File

@@ -38,6 +38,7 @@ Thumbs.db
*.swo *.swo
*~ *~
*.tmp *.tmp
site
# Credentials # Credentials
client_secret_*.json client_secret_*.json

138
README.md Normal file
View File

@@ -0,0 +1,138 @@
# mail_intake
# Summary
Mail Intake — provider-agnostic, read-only email ingestion framework.
Mail Intake is a **contract-first library** designed to ingest, parse, and
normalize email data from external providers (such as Gmail) into clean,
provider-agnostic domain models.
The library is intentionally structured around clear layers, each exposed
as a first-class module at the package root:
- `adapters`: Provider-specific access (e.g., Gmail).
- `auth`: Authentication providers and credential lifecycle management.
- `credentials`: Credential persistence abstractions and implementations.
- `parsers`: Extraction and normalization of message content.
- `ingestion`: Orchestration and high-level ingestion workflows.
- `models`: Canonical, provider-agnostic data representations.
- `config`: Explicit global configuration.
- `exceptions`: Library-defined error hierarchy.
The package root acts as a **namespace**, not a facade. Consumers are
expected to import functionality explicitly from the appropriate module.
---
# Installation
Install using pip:
```bash
pip install mail-intake
```
Or with Poetry:
```bash
poetry add mail-intake
```
Mail Intake is pure Python and has no runtime dependencies beyond those
required by the selected provider (for example, Google APIs for Gmail).
---
# Quick Start
Minimal Gmail ingestion example (local development):
```python
from mail_intake.ingestion import MailIntakeReader
from mail_intake.adapters import MailIntakeGmailAdapter
from mail_intake.auth import MailIntakeGoogleAuth
from mail_intake.credentials import PickleCredentialStore
store = PickleCredentialStore(path="token.pickle")
auth = MailIntakeGoogleAuth(
credentials_path="credentials.json",
store=store,
scopes=["https://www.googleapis.com/auth/gmail.readonly"],
)
adapter = MailIntakeGmailAdapter(auth_provider=auth)
reader = MailIntakeReader(adapter)
for message in reader.iter_messages("from:recruiter@example.com"):
print(message.subject, message.from_email)
```
Iterating over threads:
```python
for thread in reader.iter_threads("subject:Interview"):
print(thread.normalized_subject, len(thread.messages))
```
---
# Architecture
Mail Intake is designed to be extensible via **public contracts** exposed
through its modules:
- Users MAY implement their own mail adapters by subclassing
`adapters.MailIntakeAdapter`.
- Users MAY implement their own authentication providers by subclassing
`auth.MailIntakeAuthProvider[T]`.
- Users MAY implement their own credential persistence layers by implementing
`credentials.CredentialStore[T]`.
Users SHOULD NOT subclass built-in adapter implementations. Built-in
adapters (such as Gmail) are reference implementations and may change
internally without notice.
**Design Guarantees:**
- Read-only access: no mutation of provider state.
- Provider-agnostic domain models.
- Explicit configuration and dependency injection.
- No implicit global state or environment reads.
- Deterministic, testable behavior.
- Distributed-safe authentication design.
Mail Intake favors correctness, clarity, and explicitness over convenience
shortcuts.
**Core Philosophy:**
`Mail Intake` is built as a **contract-first ingestion pipeline**:
1. **Layered Decoupling**: Adapters handle transport, Parsers handle format
normalization, and Ingestion orchestrates.
2. **Provider Agnosticism**: Domain models and core logic never depend on
provider-specific (e.g., Gmail) API internals.
3. **Stateless Workflows**: The library functions as a read-only pipe, ensuring
side-effect-free ingestion.
---
# Public API
The supported public API consists of the following top-level modules:
- `mail_intake.ingestion`
- `mail_intake.adapters`
- `mail_intake.auth`
- `mail_intake.credentials`
- `mail_intake.parsers`
- `mail_intake.models`
- `mail_intake.config`
- `mail_intake.exceptions`
Classes and functions should be imported explicitly from these modules.
No individual symbols are re-exported at the package root.
---

29
docforge.nav.yml Normal file
View File

@@ -0,0 +1,29 @@
home: index.md
groups:
Core API:
- ingestion/index.md
- ingestion/reader.md
Domain Models:
- models/index.md
- models/message.md
- models/thread.md
Provider Adapters:
- adapters/index.md
- adapters/base.md
- adapters/gmail.md
Authentication & Storage:
- auth/index.md
- auth/base.md
- auth/google.md
- credentials/index.md
- credentials/store.md
- credentials/pickle.md
- credentials/redis.md
Normalization & Parsing:
- parsers/index.md
- parsers/body.md
- parsers/headers.md
- parsers/subject.md
Configuration & Errors:
- config.md
- exceptions.md

View File

@@ -1,3 +1,3 @@
# Mail Intake # mail_intake
::: mail_intake ::: mail_intake

22
fetch_emails.py Normal file
View File

@@ -0,0 +1,22 @@
from mail_intake.ingestion import MailIntakeReader
from mail_intake.adapters import MailIntakeGmailAdapter
from mail_intake.auth import MailIntakeGoogleAuth
from mail_intake.credentials.pickle import PickleCredentialStore
store = PickleCredentialStore(path="token.pickle")
auth = MailIntakeGoogleAuth(
credentials_path="credentials.json",
store=store,
scopes=["https://www.googleapis.com/auth/gmail.readonly"],
)
auth.get_credentials()
adapter = MailIntakeGmailAdapter(auth_provider=auth)
reader = MailIntakeReader(adapter)
for message in reader.iter_messages("from:roshnisingh009@gmail.com"):
print(message.subject, message.from_email)
break
from pdb import set_trace;set_trace()

View File

@@ -1,176 +0,0 @@
"""
Generate a fully-contained MCP bundle by reading Python docstrings directly.
Uses Griffe (the same library mkdocstrings-python uses internally),
but without MkDocs, Markdown, or HTML.
Output:
mcp/
├── index.json
├── nav.json
└── modules/
└── package.module.json
"""
from __future__ import annotations
import json
import argparse
from pathlib import Path
from typing import Iterable
from griffe import GriffeLoader, ModulesCollection, LinesCollection, AliasResolutionError
PROJECT_ROOT = Path(__file__).resolve().parent
DEFAULT_PACKAGE_ROOT = "mail_intake"
DEFAULT_MCP_DIR = PROJECT_ROOT / "mcp"
# -------------------------
# Utilities
# -------------------------
def iter_modules(package_root: Path, package_name: str) -> Iterable[str]:
for py in package_root.rglob("*.py"):
rel = py.relative_to(package_root.parent)
if py.name == "__init__.py":
yield ".".join(rel.parent.parts)
else:
yield ".".join(rel.with_suffix("").parts)
def serialize_object(obj) -> dict:
"""Convert a Griffe object into MCP-friendly JSON (alias-safe)."""
try:
docstring = obj.docstring.value if obj.docstring else None
except AliasResolutionError:
docstring = None
data = {
"name": obj.name,
"kind": obj.kind.value,
"path": obj.path,
"docstring": docstring,
}
# Signature may also trigger alias resolution
try:
if hasattr(obj, "signature") and obj.signature:
data["signature"] = str(obj.signature)
except AliasResolutionError:
pass
# Recurse into members, but never allow alias failure to bubble up
members = {}
if hasattr(obj, "members"):
for name, member in obj.members.items():
if name.startswith("_"):
continue
try:
members[name] = serialize_object(member)
except AliasResolutionError:
continue
if members:
data["members"] = members
return data
# -------------------------
# MCP generation
# -------------------------
def build_mcp(package_root: Path, package_name: str, mcp_root: Path) -> None:
modules_dir = mcp_root / "modules"
modules_dir.mkdir(parents=True, exist_ok=True)
loader = GriffeLoader(
search_paths=[str(package_root.parent)],
modules_collection=ModulesCollection(),
lines_collection=LinesCollection(),
)
nav = []
count = 0
for module in sorted(iter_modules(package_root, package_name)):
loader.load(module)
mod = loader.modules_collection[module]
payload = {
"module": module,
"content": serialize_object(mod),
}
out = modules_dir / f"{module}.json"
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(json.dumps(payload, indent=2), encoding="utf-8")
nav.append({
"module": module,
"resource": f"docs://module/{module}",
})
count += 1
(mcp_root / "nav.json").write_text(
json.dumps(nav, indent=2),
encoding="utf-8",
)
(mcp_root / "index.json").write_text(
json.dumps(
{
"project": package_name,
"type": "docstrings-direct",
"modules_count": count,
"source": "griffe",
},
indent=2,
),
encoding="utf-8",
)
print(f"MCP generated at: {mcp_root}")
# -------------------------
# CLI
# -------------------------
def main() -> None:
parser = argparse.ArgumentParser(
description="Generate MCP directly from Python docstrings (Griffe-based)",
)
parser.add_argument(
"--package-root",
default=DEFAULT_PACKAGE_ROOT,
help="Root Python package name",
)
parser.add_argument(
"--mcp-dir",
type=Path,
default=DEFAULT_MCP_DIR,
help="Output MCP directory",
)
args = parser.parse_args()
package_root = PROJECT_ROOT / args.package_root
if not package_root.exists():
raise FileNotFoundError(package_root)
build_mcp(
package_root=package_root,
package_name=args.package_root,
mcp_root=args.mcp_dir,
)
if __name__ == "__main__":
main()

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Mail Intake — provider-agnostic, read-only email ingestion framework. Mail Intake — provider-agnostic, read-only email ingestion framework.
Mail Intake is a **contract-first library** designed to ingest, parse, and Mail Intake is a **contract-first library** designed to ingest, parse, and
@@ -8,112 +10,131 @@ provider-agnostic domain models.
The library is intentionally structured around clear layers, each exposed The library is intentionally structured around clear layers, each exposed
as a first-class module at the package root: as a first-class module at the package root:
- adapters: provider-specific access (e.g. Gmail) - `adapters`: Provider-specific access (e.g., Gmail).
- auth: authentication providers and credential lifecycle management - `auth`: Authentication providers and credential lifecycle management.
- credentials: credential persistence abstractions and implementations - `credentials`: Credential persistence abstractions and implementations.
- parsers: extraction and normalization of message content - `parsers`: Extraction and normalization of message content.
- ingestion: orchestration and high-level ingestion workflows - `ingestion`: Orchestration and high-level ingestion workflows.
- models: canonical, provider-agnostic data representations - `models`: Canonical, provider-agnostic data representations.
- config: explicit global configuration - `config`: Explicit global configuration.
- exceptions: library-defined error hierarchy - `exceptions`: Library-defined error hierarchy.
The package root acts as a **namespace**, not a facade. Consumers are The package root acts as a **namespace**, not a facade. Consumers are
expected to import functionality explicitly from the appropriate module. expected to import functionality explicitly from the appropriate module.
---------------------------------------------------------------------- ---
Installation
---------------------------------------------------------------------- # Installation
Install using pip: Install using pip:
pip install mail-intake ```bash
pip install mail-intake
```
Or with Poetry: Or with Poetry:
poetry add mail-intake ```bash
poetry add mail-intake
```
Mail Intake is pure Python and has no runtime dependencies beyond those Mail Intake is pure Python and has no runtime dependencies beyond those
required by the selected provider (for example, Google APIs for Gmail). required by the selected provider (for example, Google APIs for Gmail).
---------------------------------------------------------------------- ---
Basic Usage
---------------------------------------------------------------------- # Quick Start
Minimal Gmail ingestion example (local development): Minimal Gmail ingestion example (local development):
from mail_intake.ingestion import MailIntakeReader ```python
from mail_intake.adapters import MailIntakeGmailAdapter from mail_intake.ingestion import MailIntakeReader
from mail_intake.auth import MailIntakeGoogleAuth from mail_intake.adapters import MailIntakeGmailAdapter
from mail_intake.credentials import PickleCredentialStore from mail_intake.auth import MailIntakeGoogleAuth
from mail_intake.credentials import PickleCredentialStore
store = PickleCredentialStore(path="token.pickle") store = PickleCredentialStore(path="token.pickle")
auth = MailIntakeGoogleAuth( auth = MailIntakeGoogleAuth(
credentials_path="credentials.json", credentials_path="credentials.json",
store=store, store=store,
scopes=["https://www.googleapis.com/auth/gmail.readonly"], scopes=["https://www.googleapis.com/auth/gmail.readonly"],
) )
adapter = MailIntakeGmailAdapter(auth_provider=auth) adapter = MailIntakeGmailAdapter(auth_provider=auth)
reader = MailIntakeReader(adapter) reader = MailIntakeReader(adapter)
for message in reader.iter_messages("from:recruiter@example.com"): for message in reader.iter_messages("from:recruiter@example.com"):
print(message.subject, message.from_email) print(message.subject, message.from_email)
```
Iterating over threads: Iterating over threads:
for thread in reader.iter_threads("subject:Interview"): ```python
print(thread.normalized_subject, len(thread.messages)) for thread in reader.iter_threads("subject:Interview"):
print(thread.normalized_subject, len(thread.messages))
```
---------------------------------------------------------------------- ---
Extensibility Model
---------------------------------------------------------------------- # Architecture
Mail Intake is designed to be extensible via **public contracts** exposed Mail Intake is designed to be extensible via **public contracts** exposed
through its modules: through its modules:
- Users MAY implement their own mail adapters by subclassing - Users MAY implement their own mail adapters by subclassing
``adapters.MailIntakeAdapter`` `adapters.MailIntakeAdapter`.
- Users MAY implement their own authentication providers by subclassing - Users MAY implement their own authentication providers by subclassing
``auth.MailIntakeAuthProvider[T]`` `auth.MailIntakeAuthProvider[T]`.
- Users MAY implement their own credential persistence layers by - Users MAY implement their own credential persistence layers by implementing
implementing ``credentials.CredentialStore[T]`` `credentials.CredentialStore[T]`.
Users SHOULD NOT subclass built-in adapter implementations. Built-in Users SHOULD NOT subclass built-in adapter implementations. Built-in
adapters (such as Gmail) are reference implementations and may change adapters (such as Gmail) are reference implementations and may change
internally without notice. internally without notice.
---------------------------------------------------------------------- **Design Guarantees:**
Public API Surface
---------------------------------------------------------------------- - Read-only access: no mutation of provider state.
- Provider-agnostic domain models.
- Explicit configuration and dependency injection.
- No implicit global state or environment reads.
- Deterministic, testable behavior.
- Distributed-safe authentication design.
Mail Intake favors correctness, clarity, and explicitness over convenience
shortcuts.
**Core Philosophy:**
`Mail Intake` is built as a **contract-first ingestion pipeline**:
1. **Layered Decoupling**: Adapters handle transport, Parsers handle format
normalization, and Ingestion orchestrates.
2. **Provider Agnosticism**: Domain models and core logic never depend on
provider-specific (e.g., Gmail) API internals.
3. **Stateless Workflows**: The library functions as a read-only pipe, ensuring
side-effect-free ingestion.
---
# Public API
The supported public API consists of the following top-level modules: The supported public API consists of the following top-level modules:
- mail_intake.ingestion - `mail_intake.ingestion`
- mail_intake.adapters - `mail_intake.adapters`
- mail_intake.auth - `mail_intake.auth`
- mail_intake.credentials - `mail_intake.credentials`
- mail_intake.parsers - `mail_intake.parsers`
- mail_intake.models - `mail_intake.models`
- mail_intake.config - `mail_intake.config`
- mail_intake.exceptions - `mail_intake.exceptions`
Classes and functions should be imported explicitly from these modules. Classes and functions should be imported explicitly from these modules.
No individual symbols are re-exported at the package root. No individual symbols are re-exported at the package root.
---------------------------------------------------------------------- ---
Design Guarantees
----------------------------------------------------------------------
- Read-only access: no mutation of provider state
- Provider-agnostic domain models
- Explicit configuration and dependency injection
- No implicit global state or environment reads
- Deterministic, testable behavior
- Distributed-safe authentication design
Mail Intake favors correctness, clarity, and explicitness over convenience
shortcuts.
""" """

17
mail_intake/__init__.pyi Normal file
View File

@@ -0,0 +1,17 @@
from . import ingestion
from . import adapters
from . import auth
from . import credentials
from . import models
from . import config
from . import exceptions
__all__ = [
"ingestion",
"adapters",
"auth",
"credentials",
"models",
"config",
"exceptions",
]

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Mail provider adapter implementations for Mail Intake. Mail provider adapter implementations for Mail Intake.
This package contains **adapter-layer implementations** responsible for This package contains **adapter-layer implementations** responsible for
@@ -6,17 +8,24 @@ interfacing with external mail providers and exposing a normalized,
provider-agnostic contract to the rest of the system. provider-agnostic contract to the rest of the system.
Adapters in this package: Adapters in this package:
- Implement the `MailIntakeAdapter` interface
- Encapsulate all provider-specific APIs and semantics - Implement the `MailIntakeAdapter` interface.
- Perform read-only access to mail data - Encapsulate all provider-specific APIs and semantics.
- Return provider-native payloads without interpretation - Perform read-only access to mail data.
- Return provider-native payloads without interpretation.
Provider-specific logic **must not leak** outside of adapter implementations. Provider-specific logic **must not leak** outside of adapter implementations.
All parsings, normalizations, and transformations must be handled by downstream All parsings, normalizations, and transformations must be handled by downstream
components. components.
Public adapters exported from this package are considered the supported ---
integration surface for mail providers.
# Public API
- `MailIntakeAdapter`
- `MailIntakeGmailAdapter`
---
""" """
from .base import MailIntakeAdapter from .base import MailIntakeAdapter

View File

@@ -0,0 +1,4 @@
from .base import MailIntakeAdapter
from .gmail import MailIntakeGmailAdapter
__all__ = ["MailIntakeAdapter", "MailIntakeGmailAdapter"]

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Mail provider adapter contracts for Mail Intake. Mail provider adapter contracts for Mail Intake.
This module defines the **provider-agnostic adapter interface** used for This module defines the **provider-agnostic adapter interface** used for
@@ -17,12 +19,16 @@ class MailIntakeAdapter(ABC):
""" """
Base adapter interface for mail providers. Base adapter interface for mail providers.
This interface defines the minimal contract required to: Notes:
- Discover messages matching a query **Guarantees:**
- Retrieve full message payloads
- Retrieve full thread payloads
Adapters are intentionally read-only and must not mutate provider state. - Discover messages matching a query.
- Retrieve full message payloads.
- Retrieve full thread payloads.
**Lifecycle:**
- Adapters are intentionally read-only and must not mutate provider state.
""" """
@abstractmethod @abstractmethod
@@ -30,21 +36,29 @@ class MailIntakeAdapter(ABC):
""" """
Iterate over lightweight message references matching a query. Iterate over lightweight message references matching a query.
Implementations must yield dictionaries containing at least:
- ``message_id``: Provider-specific message identifier
- ``thread_id``: Provider-specific thread identifier
Args: Args:
query: Provider-specific query string used to filter messages. query (str):
Provider-specific query string used to filter messages.
Yields: Yields:
Dictionaries containing message and thread identifiers. Dict[str, str]:
Dictionaries containing message and thread identifiers.
Example yield: Notes:
**Guarantees:**
- Implementations must yield dictionaries containing at least
`message_id` and `thread_id`.
Example:
Typical yield:
```python
{ {
"message_id": "...", "message_id": "...",
"thread_id": "..." "thread_id": "..."
} }
```
""" """
raise NotImplementedError raise NotImplementedError
@@ -54,11 +68,12 @@ class MailIntakeAdapter(ABC):
Fetch a full raw message by message identifier. Fetch a full raw message by message identifier.
Args: Args:
message_id: Provider-specific message identifier. message_id (str):
Provider-specific message identifier.
Returns: Returns:
Provider-native message payload Dict[str, Any]:
(e.g., Gmail message JSON structure). Provider-native message payload (e.g., Gmail message JSON structure).
""" """
raise NotImplementedError raise NotImplementedError
@@ -68,9 +83,11 @@ class MailIntakeAdapter(ABC):
Fetch a full raw thread by thread identifier. Fetch a full raw thread by thread identifier.
Args: Args:
thread_id: Provider-specific thread identifier. thread_id (str):
Provider-specific thread identifier.
Returns: Returns:
Provider-native thread payload. Dict[str, Any]:
Provider-native thread payload.
""" """
raise NotImplementedError raise NotImplementedError

View File

@@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
from typing import Iterator, Dict, Any
class MailIntakeAdapter(ABC):
@abstractmethod
def iter_message_refs(self, query: str) -> Iterator[Dict[str, str]]: ...
@abstractmethod
def fetch_message(self, message_id: str) -> Dict[str, Any]: ...
@abstractmethod
def fetch_thread(self, thread_id: str) -> Dict[str, Any]: ...

View File

@@ -1,13 +1,16 @@
""" """
# Summary
Gmail adapter implementation for Mail Intake. Gmail adapter implementation for Mail Intake.
This module provides a **Gmail-specific implementation** of the This module provides a **Gmail-specific implementation** of the
`MailIntakeAdapter` contract. `MailIntakeAdapter` contract.
It is the only place in the codebase where: It is the only place in the codebase where:
- `googleapiclient` is imported
- Gmail REST API semantics are known - `googleapiclient` is imported.
- Low-level `.execute()` calls are made - Gmail REST API semantics are known.
- Low-level `.execute()` calls are made.
All Gmail-specific behavior must be strictly contained within this module. All Gmail-specific behavior must be strictly contained within this module.
""" """
@@ -30,15 +33,18 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
Gmail REST API. It translates the generic mail intake contract into Gmail REST API. It translates the generic mail intake contract into
Gmail-specific API calls. Gmail-specific API calls.
This class is the ONLY place where: Notes:
- googleapiclient is imported **Responsibilities:**
- Gmail REST semantics are known
- .execute() is called
Design constraints: - This class is the ONLY place where `googleapiclient` is imported.
- Must remain thin and imperative - Gmail REST semantics are known.
- Must not perform parsing or interpretation - `.execute()` is called.
- Must not expose Gmail-specific types beyond this class
**Constraints:**
- Must remain thin and imperative.
- Must not perform parsing or interpretation.
- Must not expose Gmail-specific types beyond this class.
""" """
def __init__( def __init__(
@@ -50,9 +56,11 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
Initialize the Gmail adapter. Initialize the Gmail adapter.
Args: Args:
auth_provider: Authentication provider capable of supplying auth_provider (MailIntakeAuthProvider):
valid Gmail API credentials. Authentication provider capable of supplying valid Gmail API credentials.
user_id: Gmail user identifier. Defaults to `"me"`.
user_id (str):
Gmail user identifier. Defaults to `"me"`.
""" """
self._auth_provider = auth_provider self._auth_provider = auth_provider
self._user_id = user_id self._user_id = user_id
@@ -64,10 +72,12 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
Lazily initialize and return the Gmail API service client. Lazily initialize and return the Gmail API service client.
Returns: Returns:
Initialized Gmail API service instance. Any:
Initialized Gmail API service instance.
Raises: Raises:
MailIntakeAdapterError: If the Gmail service cannot be initialized. MailIntakeAdapterError:
If the Gmail service cannot be initialized.
""" """
if self._service is None: if self._service is None:
try: try:
@@ -84,15 +94,16 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
Iterate over message references matching the query. Iterate over message references matching the query.
Args: Args:
query: Gmail search query string. query (str):
Gmail search query string.
Yields: Yields:
Dictionaries containing: Dict[str, str]:
- ``message_id``: Gmail message ID Dictionaries containing ``message_id`` and ``thread_id``.
- ``thread_id``: Gmail thread ID
Raises: Raises:
MailIntakeAdapterError: If the Gmail API returns an error. MailIntakeAdapterError:
If the Gmail API returns an error.
""" """
try: try:
request = ( request = (
@@ -126,13 +137,16 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
Fetch a full Gmail message by message ID. Fetch a full Gmail message by message ID.
Args: Args:
message_id: Gmail message identifier. message_id (str):
Gmail message identifier.
Returns: Returns:
Provider-native Gmail message payload. Dict[str, Any]:
Provider-native Gmail message payload.
Raises: Raises:
MailIntakeAdapterError: If the Gmail API returns an error. MailIntakeAdapterError:
If the Gmail API returns an error.
""" """
try: try:
return ( return (
@@ -151,13 +165,16 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
Fetch a full Gmail thread by thread ID. Fetch a full Gmail thread by thread ID.
Args: Args:
thread_id: Gmail thread identifier. thread_id (str):
Gmail thread identifier.
Returns: Returns:
Provider-native Gmail thread payload. Dict[str, Any]:
Provider-native Gmail thread payload.
Raises: Raises:
MailIntakeAdapterError: If the Gmail API returns an error. MailIntakeAdapterError:
If the Gmail API returns an error.
""" """
try: try:
return ( return (

View File

@@ -0,0 +1,11 @@
from typing import Iterator, Dict, Any
from mail_intake.adapters.base import MailIntakeAdapter
from mail_intake.auth.base import MailIntakeAuthProvider
class MailIntakeGmailAdapter(MailIntakeAdapter):
def __init__(self, auth_provider: MailIntakeAuthProvider, user_id: str = ...) -> None: ...
@property
def service(self) -> Any: ...
def iter_message_refs(self, query: str) -> Iterator[Dict[str, str]]: ...
def fetch_message(self, message_id: str) -> Dict[str, Any]: ...
def fetch_thread(self, thread_id: str) -> Dict[str, Any]: ...

View File

@@ -1,20 +1,33 @@
""" """
# Summary
Authentication provider implementations for Mail Intake. Authentication provider implementations for Mail Intake.
This package defines the **authentication layer** used by mail adapters This package defines the **authentication layer** used by mail adapters
to obtain provider-specific credentials. to obtain provider-specific credentials.
It exposes: It exposes:
- A stable, provider-agnostic authentication contract
- Concrete authentication providers for supported platforms - A stable, provider-agnostic authentication contract.
- Concrete authentication providers for supported platforms.
Authentication providers: Authentication providers:
- Are responsible for credential acquisition and lifecycle management
- Are intentionally decoupled from adapter logic - Are responsible for credential acquisition and lifecycle management.
- May be extended by users to support additional providers - Are intentionally decoupled from adapter logic.
- May be extended by users to support additional providers.
Consumers should depend on the abstract interface and use concrete Consumers should depend on the abstract interface and use concrete
implementations only where explicitly required. implementations only where explicitly required.
---
# Public API
- `MailIntakeAuthProvider`
- `MailIntakeGoogleAuth`
---
""" """
from .base import MailIntakeAuthProvider from .base import MailIntakeAuthProvider

View File

@@ -0,0 +1,4 @@
from .base import MailIntakeAuthProvider
from .google import MailIntakeGoogleAuth
__all__ = ["MailIntakeAuthProvider", "MailIntakeGoogleAuth"]

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Authentication provider contracts for Mail Intake. Authentication provider contracts for Mail Intake.
This module defines the **authentication abstraction layer** used by mail This module defines the **authentication abstraction layer** used by mail
@@ -23,15 +25,20 @@ class MailIntakeAuthProvider(ABC, Generic[T]):
providers and mail adapters by requiring providers to explicitly providers and mail adapters by requiring providers to explicitly
declare the type of credentials they return. declare the type of credentials they return.
Authentication providers encapsulate all logic required to: Notes:
- Acquire credentials from an external provider **Responsibilities:**
- Refresh or revalidate credentials as needed
- Handle authentication-specific failure modes
- Coordinate with credential persistence layers where applicable
Mail adapters must treat returned credentials as opaque and - Acquire credentials from an external provider.
provider-specific, relying only on the declared credential type - Refresh or revalidate credentials as needed.
expected by the adapter. - Handle authentication-specific failure modes.
- Coordinate with credential persistence layers where applicable.
**Constraints:**
- Mail adapters must treat returned credentials as opaque and
provider-specific.
- Mail adapters rely only on the declared credential type expected
by the adapter.
""" """
@abstractmethod @abstractmethod
@@ -39,21 +46,23 @@ class MailIntakeAuthProvider(ABC, Generic[T]):
""" """
Retrieve valid, provider-specific credentials. Retrieve valid, provider-specific credentials.
This method is synchronous by design and represents the sole
entry point through which adapters obtain authentication
material.
Implementations must either return credentials of the declared
type ``T`` that are valid at the time of return or raise an
authentication-specific exception.
Returns: Returns:
Credentials of type ``T`` suitable for immediate use by the T:
corresponding mail adapter. Credentials of type `T` suitable for immediate use by the
corresponding mail adapter.
Raises: Raises:
Exception: Exception:
An authentication-specific exception indicating that An authentication-specific exception indicating that
credentials could not be obtained or validated. credentials could not be obtained or validated.
Notes:
**Guarantees:**
- This method is synchronous by design.
- Represents the sole entry point through which adapters obtain
authentication material.
- Implementations must either return credentials of the declared
type `T` that are valid at the time of return or raise an exception.
""" """
raise NotImplementedError raise NotImplementedError

View File

@@ -0,0 +1,8 @@
from abc import ABC, abstractmethod
from typing import Generic, TypeVar
T = TypeVar("T")
class MailIntakeAuthProvider(ABC, Generic[T]):
@abstractmethod
def get_credentials(self) -> T: ...

View File

@@ -1,14 +1,17 @@
""" """
# Summary
Google authentication provider implementation for Mail Intake. Google authentication provider implementation for Mail Intake.
This module provides a **Google OAuthbased authentication provider** This module provides a **Google OAuthbased authentication provider**
used primarily for Gmail access. used primarily for Gmail access.
It encapsulates all Google-specific authentication concerns, including: It encapsulates all Google-specific authentication concerns, including:
- Credential loading and persistence
- Token refresh handling - Credential loading and persistence.
- Interactive OAuth flow initiation - Token refresh handling.
- Coordination with a credential persistence layer - Interactive OAuth flow initiation.
- Coordination with a credential persistence layer.
No Google authentication details should leak outside this module. No Google authentication details should leak outside this module.
""" """
@@ -33,13 +36,18 @@ class MailIntakeGoogleAuth(MailIntakeAuthProvider):
This provider implements the `MailIntakeAuthProvider` interface using This provider implements the `MailIntakeAuthProvider` interface using
Google's OAuth 2.0 flow and credential management libraries. Google's OAuth 2.0 flow and credential management libraries.
Responsibilities: Notes:
- Load cached credentials from a credential store when available **Responsibilities:**
- Refresh expired credentials when possible
- Initiate an interactive OAuth flow only when required
- Persist refreshed or newly obtained credentials via the store
This class is synchronous by design and maintains a minimal internal state. - Load cached credentials from a credential store when available.
- Refresh expired credentials when possible.
- Initiate an interactive OAuth flow only when required.
- Persist refreshed or newly obtained credentials via the store.
**Guarantees:**
- This class is synchronous by design and maintains a minimal
internal state.
""" """
def __init__( def __init__(
@@ -52,15 +60,13 @@ class MailIntakeGoogleAuth(MailIntakeAuthProvider):
Initialize the Google authentication provider. Initialize the Google authentication provider.
Args: Args:
credentials_path: credentials_path (str):
Path to the Google OAuth client secrets file used to Path to the Google OAuth client secrets file used to initiate the OAuth 2.0 flow.
initiate the OAuth 2.0 flow.
store: store (CredentialStore[Credentials]):
Credential store responsible for persisting and Credential store responsible for persisting and retrieving Google OAuth credentials.
retrieving Google OAuth credentials.
scopes: scopes (Sequence[str]):
OAuth scopes required for Gmail access. OAuth scopes required for Gmail access.
""" """
self.credentials_path = credentials_path self.credentials_path = credentials_path
@@ -71,19 +77,23 @@ class MailIntakeGoogleAuth(MailIntakeAuthProvider):
""" """
Retrieve valid Google OAuth credentials. Retrieve valid Google OAuth credentials.
This method attempts to:
1. Load cached credentials from the configured credential store
2. Refresh expired credentials when possible
3. Perform an interactive OAuth login as a fallback
4. Persist valid credentials for future use
Returns: Returns:
A ``google.oauth2.credentials.Credentials`` instance suitable Credentials:
for use with Google API clients. A `google.oauth2.credentials.Credentials` instance suitable
for use with Google API clients.
Raises: Raises:
MailIntakeAuthError: If credentials cannot be loaded, refreshed, MailIntakeAuthError:
If credentials cannot be loaded, refreshed,
or obtained via interactive authentication. or obtained via interactive authentication.
Notes:
**Lifecycle:**
- Load cached credentials from the configured credential store.
- Refresh expired credentials when possible.
- Perform an interactive OAuth login as a fallback.
- Persist valid credentials for future use.
""" """
creds = self.store.load() creds = self.store.load()

View File

@@ -0,0 +1,7 @@
from typing import Sequence, Any
from mail_intake.auth.base import MailIntakeAuthProvider
from mail_intake.credentials.store import CredentialStore
class MailIntakeGoogleAuth(MailIntakeAuthProvider[Any]):
def __init__(self, credentials_path: str, store: CredentialStore[Any], scopes: Sequence[str]) -> None: ...
def get_credentials(self) -> Any: ...

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Global configuration models for Mail Intake. Global configuration models for Mail Intake.
This module defines the **top-level configuration object** used to control This module defines the **top-level configuration object** used to control
@@ -16,30 +18,40 @@ from typing import Optional
@dataclass(frozen=True) @dataclass(frozen=True)
class MailIntakeConfig: class MailIntakeConfig:
""" """
Global configuration for mail-intake. Global configuration for `mail-intake`.
This configuration is intentionally explicit and immutable. Notes:
No implicit environment reads or global state. **Guarantees:**
Design principles: - This configuration is intentionally explicit and immutable.
- Immutable once constructed - No implicit environment reads or global state.
- Explicit configuration over implicit defaults - Explicit configuration over implicit defaults.
- No direct environment or filesystem access - No direct environment or filesystem access.
- This model is safe to pass across layers and suitable for
This model is safe to pass across layers and suitable for serialization. serialization.
""" """
provider: str = "gmail" provider: str = "gmail"
"""Identifier of the mail provider to use (e.g., ``"gmail"``).""" """
Identifier of the mail provider to use (e.g., ``"gmail"``).
"""
user_id: str = "me" user_id: str = "me"
"""Provider-specific user identifier. Defaults to the authenticated user.""" """
Provider-specific user identifier. Defaults to the authenticated user.
"""
readonly: bool = True readonly: bool = True
"""Whether ingestion should operate in read-only mode.""" """
Whether ingestion should operate in read-only mode.
"""
credentials_path: Optional[str] = None credentials_path: Optional[str] = None
"""Optional path to provider credentials configuration.""" """
Optional path to provider credentials configuration.
"""
token_path: Optional[str] = None token_path: Optional[str] = None
"""Optional path to persisted authentication tokens.""" """
Optional path to persisted authentication tokens.
"""

9
mail_intake/config.pyi Normal file
View File

@@ -0,0 +1,9 @@
from typing import Optional
class MailIntakeConfig:
provider: str
user_id: str
readonly: bool
credentials_path: Optional[str]
token_path: Optional[str]
def __init__(self, provider: str = ..., user_id: str = ..., readonly: bool = ..., credentials_path: Optional[str] = ..., token_path: Optional[str] = ...) -> None: ...

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Credential persistence interfaces and implementations for Mail Intake. Credential persistence interfaces and implementations for Mail Intake.
This package defines the abstractions and concrete implementations used This package defines the abstractions and concrete implementations used
@@ -10,12 +12,23 @@ credential acquisition, validation, and refresh, while implementations
within this package are responsible solely for storage and retrieval. within this package are responsible solely for storage and retrieval.
The package provides: The package provides:
- A generic ``CredentialStore`` abstraction defining the persistence contract
- Local filesystembased storage for development and single-node use - A generic `CredentialStore` abstraction defining the persistence contract.
- Distributed, Redis-backed storage for production and scaled deployments - Local filesystembased storage for development and single-node use.
- Distributed, Redis-backed storage for production and scaled deployments.
Credential lifecycle management, interpretation, and security policy Credential lifecycle management, interpretation, and security policy
decisions remain the responsibility of authentication providers. decisions remain the responsibility of authentication providers.
---
# Public API
- `CredentialStore`
- `PickleCredentialStore`
- `RedisCredentialStore`
---
""" """
from mail_intake.credentials.store import CredentialStore from mail_intake.credentials.store import CredentialStore

View File

@@ -0,0 +1,5 @@
from .store import CredentialStore
from .pickle import PickleCredentialStore
from .redis import RedisCredentialStore
__all__ = ["CredentialStore", "PickleCredentialStore", "RedisCredentialStore"]

View File

@@ -1,14 +1,16 @@
""" """
# Summary
Local filesystembased credential persistence for Mail Intake. Local filesystembased credential persistence for Mail Intake.
This module provides a file-backed implementation of the This module provides a file-backed implementation of the
``CredentialStore`` abstraction using Python's ``pickle`` module. `CredentialStore` abstraction using Python's `pickle` module.
The pickle-based credential store is intended for local development, The `pickle`-based credential store is intended for local development,
single-node deployments, and controlled environments where credentials single-node deployments, and controlled environments where credentials
do not need to be shared across processes or machines. do not need to be shared across processes or machines.
Due to the security and portability risks associated with pickle-based Due to the security and portability risks associated with `pickle`-based
serialization, this implementation is not suitable for distributed or serialization, this implementation is not suitable for distributed or
untrusted environments. untrusted environments.
""" """
@@ -29,13 +31,17 @@ class PickleCredentialStore(CredentialStore[T]):
filesystem. It is a simple implementation intended primarily for filesystem. It is a simple implementation intended primarily for
development, testing, and single-process execution contexts. development, testing, and single-process execution contexts.
This implementation: Notes:
- Stores credentials on the local filesystem **Guarantees:**
- Uses pickle for serialization and deserialization
- Does not provide encryption, locking, or concurrency guarantees
Credential lifecycle management, validation, and refresh logic are - Stores credentials on the local filesystem.
explicitly out of scope for this class. - Uses `pickle` for serialization and deserialization.
- Does not provide encryption, locking, or concurrency guarantees.
**Constraints:**
- Credential lifecycle management, validation, and refresh logic are
explicitly out of scope for this class.
""" """
def __init__(self, path: str): def __init__(self, path: str):
@@ -43,7 +49,7 @@ class PickleCredentialStore(CredentialStore[T]):
Initialize a pickle-backed credential store. Initialize a pickle-backed credential store.
Args: Args:
path: path (str):
Filesystem path where credentials will be stored. Filesystem path where credentials will be stored.
The file will be created or overwritten as needed. The file will be created or overwritten as needed.
""" """
@@ -53,15 +59,18 @@ class PickleCredentialStore(CredentialStore[T]):
""" """
Load credentials from the local filesystem. Load credentials from the local filesystem.
If the credential file does not exist or cannot be successfully
deserialized, this method returns ``None``.
The store does not attempt to validate or interpret the returned
credentials.
Returns: Returns:
An instance of type ``T`` if credentials are present and Optional[T]:
successfully deserialized; otherwise ``None``. An instance of type `T` if credentials are present and
successfully deserialized; otherwise `None`.
Notes:
**Guarantees:**
- If the credential file does not exist or cannot be successfully
deserialized, this method returns `None`.
- The store does not attempt to validate or interpret the
returned credentials.
""" """
try: try:
with open(self.path, "rb") as fh: with open(self.path, "rb") as fh:
@@ -73,12 +82,14 @@ class PickleCredentialStore(CredentialStore[T]):
""" """
Persist credentials to the local filesystem. Persist credentials to the local filesystem.
Any previously stored credentials at the configured path are
overwritten.
Args: Args:
credentials: credentials (T):
The credential object to persist. The credential object to persist.
Notes:
**Responsibilities:**
- Any previously stored credentials at the configured path are overwritten
""" """
with open(self.path, "wb") as fh: with open(self.path, "wb") as fh:
pickle.dump(credentials, fh) pickle.dump(credentials, fh)
@@ -87,8 +98,10 @@ class PickleCredentialStore(CredentialStore[T]):
""" """
Remove persisted credentials from the local filesystem. Remove persisted credentials from the local filesystem.
This method deletes the credential file if it exists and should Notes:
be treated as an idempotent operation. **Lifecycle:**
- This method deletes the credential file if it exists and should be treated as an idempotent operation
""" """
import os import os

View File

@@ -0,0 +1,11 @@
from typing import Optional, TypeVar
from .store import CredentialStore
T = TypeVar("T")
class PickleCredentialStore(CredentialStore[T]):
path: str
def __init__(self, path: str) -> None: ...
def load(self) -> Optional[T]: ...
def save(self, credentials: T) -> None: ...
def clear(self) -> None: ...

View File

@@ -1,8 +1,10 @@
""" """
# Summary
Redis-backed credential persistence for Mail Intake. Redis-backed credential persistence for Mail Intake.
This module provides a Redis-based implementation of the This module provides a Redis-based implementation of the
``CredentialStore`` abstraction, enabling credential persistence `CredentialStore` abstraction, enabling credential persistence
across distributed and horizontally scaled deployments. across distributed and horizontally scaled deployments.
The Redis credential store is designed for environments where The Redis credential store is designed for environments where
@@ -11,10 +13,11 @@ processes, containers, or nodes, such as container orchestration
platforms and microservice architectures. platforms and microservice architectures.
Key characteristics: Key characteristics:
- Distributed-safe, shared storage using Redis
- Explicit, caller-defined serialization and deserialization - Distributed-safe, shared storage using Redis.
- No reliance on unsafe mechanisms such as pickle - Explicit, caller-defined serialization and deserialization.
- Optional time-to-live (TTL) support for automatic credential expiry - No reliance on unsafe mechanisms such as `pickle`.
- Optional time-to-live (TTL) support for automatic credential expiry.
This module is responsible solely for persistence concerns. This module is responsible solely for persistence concerns.
Credential validation, refresh, rotation, and acquisition remain the Credential validation, refresh, rotation, and acquisition remain the
@@ -31,20 +34,25 @@ T = TypeVar("T")
class RedisCredentialStore(CredentialStore[T]): class RedisCredentialStore(CredentialStore[T]):
""" """
Redis-backed implementation of ``CredentialStore``. Redis-backed implementation of `CredentialStore`.
This store persists credentials in Redis and is suitable for This store persists credentials in Redis and is suitable for
distributed and horizontally scaled deployments where credentials distributed and horizontally scaled deployments where credentials
must be shared across multiple processes or nodes. must be shared across multiple processes or nodes.
The store is intentionally generic and delegates all serialization Notes:
concerns to caller-provided functions. This avoids unsafe mechanisms **Responsibilities:**
such as pickle and allows credential formats to be explicitly
controlled and audited.
This class is responsible only for persistence and retrieval. - This class is responsible only for persistence and retrieval.
It does not interpret, validate, refresh, or otherwise manage - It does not interpret, validate, refresh, or otherwise manage the
the lifecycle of the credentials being stored. lifecycle of the credentials being stored.
**Guarantees:**
- The store is intentionally generic and delegates all serialization
concerns to caller-provided functions.
- This avoids unsafe mechanisms such as `pickle` and allows
credential formats to be explicitly controlled and audited.
""" """
def __init__( def __init__(
@@ -59,31 +67,20 @@ class RedisCredentialStore(CredentialStore[T]):
Initialize a Redis-backed credential store. Initialize a Redis-backed credential store.
Args: Args:
redis_client: redis_client (Any):
An initialized Redis client instance (for example, An initialized Redis client instance (for example, ``redis.Redis`` or a compatible interface) used to communicate with the Redis server.
``redis.Redis`` or a compatible interface) used to
communicate with the Redis server.
key: key (str):
The Redis key under which credentials are stored. The Redis key under which credentials are stored. Callers are responsible for applying appropriate namespacing to avoid collisions.
Callers are responsible for applying appropriate
namespacing to avoid collisions.
serialize: serialize (Callable[[T], bytes]):
A callable that converts a credential object of type A callable that converts a credential object of type ``T`` into a ``bytes`` representation suitable for storage in Redis.
``T`` into a ``bytes`` representation suitable for
storage in Redis.
deserialize: deserialize (Callable[[bytes], T]):
A callable that converts a ``bytes`` payload retrieved A callable that converts a ``bytes`` payload retrieved from Redis back into a credential object of type ``T``.
from Redis back into a credential object of type ``T``.
ttl_seconds: ttl_seconds (Optional[int]):
Optional time-to-live (TTL) for the stored credentials, Optional time-to-live (TTL) for the stored credentials, expressed in seconds. When provided, Redis will automatically expire the stored credentials after the specified duration. If ``None``, credentials are stored without an expiration.
expressed in seconds. When provided, Redis will
automatically expire the stored credentials after the
specified duration. If ``None``, credentials are stored
without an expiration.
""" """
self.redis = redis_client self.redis = redis_client
self.key = key self.key = key
@@ -95,16 +92,20 @@ class RedisCredentialStore(CredentialStore[T]):
""" """
Load credentials from Redis. Load credentials from Redis.
If no value exists for the configured key, or if the stored
payload cannot be successfully deserialized, this method
returns ``None``.
The store does not attempt to validate the returned credentials
or determine whether they are expired or otherwise usable.
Returns: Returns:
An instance of type ``T`` if credentials are present and Optional[T]:
successfully deserialized; otherwise ``None``. An instance of type `T` if credentials are present and
successfully deserialized; otherwise `None`.
Notes:
**Guarantees:**
- If no value exists for the configured key, or if the stored
payload cannot be successfully deserialized, this method
returns `None`.
- The store does not attempt to validate the returned
credentials or determine whether they are expired or
otherwise usable.
""" """
raw = self.redis.get(self.key) raw = self.redis.get(self.key)
if not raw: if not raw:
@@ -118,13 +119,15 @@ class RedisCredentialStore(CredentialStore[T]):
""" """
Persist credentials to Redis. Persist credentials to Redis.
Any previously stored credentials under the same key are
overwritten. If a TTL is configured, the credentials will
expire automatically after the specified duration.
Args: Args:
credentials: credentials (T):
The credential object to persist. The credential object to persist.
Notes:
**Responsibilities:**
- Any previously stored credentials under the same key are overwritten
- If a TTL is configured, the credentials will expire automatically after the specified duration
""" """
payload = self.serialize(credentials) payload = self.serialize(credentials)
if self.ttl_seconds: if self.ttl_seconds:
@@ -136,7 +139,10 @@ class RedisCredentialStore(CredentialStore[T]):
""" """
Remove stored credentials from Redis. Remove stored credentials from Redis.
This operation deletes the configured Redis key if it exists. Notes:
Implementations should treat this method as idempotent. **Lifecycle:**
- This operation deletes the configured Redis key if it exists
- Implementations should treat this method as idempotent
""" """
self.redis.delete(self.key) self.redis.delete(self.key)

View File

@@ -0,0 +1,15 @@
from typing import Optional, TypeVar, Callable, Any
from .store import CredentialStore
T = TypeVar("T")
class RedisCredentialStore(CredentialStore[T]):
redis: Any
key: str
serialize: Callable[[T], bytes]
deserialize: Callable[[bytes], T]
ttl_seconds: Optional[int]
def __init__(self, redis_client: Any, key: str, serialize: Callable[[T], bytes], deserialize: Callable[[bytes], T], ttl_seconds: Optional[int] = ...) -> None: ...
def load(self) -> Optional[T]: ...
def save(self, credentials: T) -> None: ...
def clear(self) -> None: ...

View File

@@ -1,10 +1,12 @@
""" """
# Summary
Credential persistence abstractions for Mail Intake. Credential persistence abstractions for Mail Intake.
This module defines the generic persistence contract used to store and This module defines the generic persistence contract used to store and
retrieve authentication credentials across Mail Intake components. retrieve authentication credentials across Mail Intake components.
The ``CredentialStore`` abstraction establishes a strict separation The `CredentialStore` abstraction establishes a strict separation
between credential *lifecycle management* and credential *storage*. between credential *lifecycle management* and credential *storage*.
Authentication providers are responsible for acquiring, validating, Authentication providers are responsible for acquiring, validating,
refreshing, and revoking credentials, while concrete store refreshing, and revoking credentials, while concrete store
@@ -26,25 +28,23 @@ T = TypeVar("T")
class CredentialStore(ABC, Generic[T]): class CredentialStore(ABC, Generic[T]):
""" """
Abstract base class defining a generic persistence interface for Abstract base class defining a generic persistence interface.
authentication credentials.
This interface separates *credential lifecycle management* from Used for authentication credentials across different backends.
*credential storage mechanics*. Implementations are responsible
only for persistence concerns, while authentication providers
retain full control over credential creation, validation, refresh,
and revocation logic.
The store is intentionally agnostic to: Notes:
- The concrete credential type being stored **Responsibilities:**
- The serialization format used to persist credentials
- The underlying storage backend or durability guarantees
Type Parameters: - Provide persistent storage separating life-cycle management from
T: storage mechanics.
The concrete credential type managed by the store. This may - Keep implementation focused only on persistence.
represent OAuth credentials, API tokens, session objects,
or any other authentication material. **Constraints:**
- The store is intentionally agnostic to:
- The concrete credential type being stored.
- The serialization format used to persist credentials.
- The underlying storage backend or durability guarantees.
""" """
@abstractmethod @abstractmethod
@@ -52,16 +52,19 @@ class CredentialStore(ABC, Generic[T]):
""" """
Load previously persisted credentials. Load previously persisted credentials.
Implementations should return ``None`` when no credentials are
present or when stored credentials cannot be successfully
decoded or deserialized.
The store must not attempt to validate, refresh, or otherwise
interpret the returned credentials.
Returns: Returns:
An instance of type ``T`` if credentials are available and Optional[T]:
loadable; otherwise ``None``. An instance of type `T` if credentials are available and
loadable; otherwise `None`.
Notes:
**Guarantees:**
- Implementations should return `None` when no credentials are
present or when stored credentials cannot be successfully
decoded or deserialized.
- The store must not attempt to validate, refresh, or otherwise
interpret the returned credentials.
""" """
@abstractmethod @abstractmethod
@@ -69,18 +72,20 @@ class CredentialStore(ABC, Generic[T]):
""" """
Persist credentials to the underlying storage backend. Persist credentials to the underlying storage backend.
This method is invoked when credentials are newly obtained or
have been refreshed and are known to be valid at the time of
persistence.
Implementations are responsible for:
- Ensuring durability appropriate to the deployment context
- Applying encryption or access controls where required
- Overwriting any previously stored credentials
Args: Args:
credentials: credentials (T):
The credential object to persist. The credential object to persist.
Notes:
**Lifecycle:**
- This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence
**Responsibilities:**
- Ensuring durability appropriate to the deployment context
- Applying encryption or access controls where required
- Overwriting any previously stored credentials
""" """
@abstractmethod @abstractmethod
@@ -88,9 +93,13 @@ class CredentialStore(ABC, Generic[T]):
""" """
Remove any persisted credentials from the store. Remove any persisted credentials from the store.
This method is called when credentials are known to be invalid, Notes:
revoked, corrupted, or otherwise unusable, and must ensure that **Lifecycle:**
no stale authentication material remains accessible.
Implementations should treat this operation as idempotent. - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable
- Must ensure that no stale authentication material remains accessible
**Guarantees:**
- Implementations should treat this operation as idempotent
""" """

View File

@@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
from typing import Generic, Optional, TypeVar
T = TypeVar("T")
class CredentialStore(ABC, Generic[T]):
@abstractmethod
def load(self) -> Optional[T]: ...
@abstractmethod
def save(self, credentials: T) -> None: ...
@abstractmethod
def clear(self) -> None: ...

View File

@@ -1,6 +1,10 @@
""" """
Exception hierarchy for Mail Intake. Exception hierarchy for Mail Intake.
---
## Summary
This module defines the **canonical exception types** used throughout the This module defines the **canonical exception types** used throughout the
Mail Intake library. Mail Intake library.
@@ -14,11 +18,12 @@ class MailIntakeError(Exception):
""" """
Base exception for all Mail Intake errors. Base exception for all Mail Intake errors.
This is the root of the Mail Intake exception hierarchy. Notes:
All errors raised by the library must derive from this class. **Guarantees:**
Consumers should generally catch this type when handling - This is the root of the Mail Intake exception hierarchy
library-level failures. - All errors raised by the library must derive from this class
- Consumers should generally catch this type when handling library-level failures
""" """
@@ -26,8 +31,11 @@ class MailIntakeAuthError(MailIntakeError):
""" """
Authentication and credential-related failures. Authentication and credential-related failures.
Raised when authentication providers are unable to acquire, Notes:
refresh, or persist valid credentials. **Lifecycle:**
- Raised when authentication providers are unable to acquire,
refresh, or persist valid credentials.
""" """
@@ -35,8 +43,11 @@ class MailIntakeAdapterError(MailIntakeError):
""" """
Errors raised by mail provider adapters. Errors raised by mail provider adapters.
Raised when a provider adapter encounters API errors, Notes:
transport failures, or invalid provider responses. **Lifecycle:**
- Raised when a provider adapter encounters API errors, transport
failures, or invalid provider responses.
""" """
@@ -44,6 +55,9 @@ class MailIntakeParsingError(MailIntakeError):
""" """
Errors encountered while parsing message content. Errors encountered while parsing message content.
Raised when raw provider payloads cannot be interpreted Notes:
or normalized into internal domain models. **Lifecycle:**
- Raised when raw provider payloads cannot be interpreted or
normalized into internal domain models.
""" """

View File

@@ -0,0 +1,4 @@
class MailIntakeError(Exception): ...
class MailIntakeAuthError(MailIntakeError): ...
class MailIntakeAdapterError(MailIntakeError): ...
class MailIntakeParsingError(MailIntakeError): ...

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Mail ingestion orchestration for Mail Intake. Mail ingestion orchestration for Mail Intake.
This package contains **high-level ingestion components** responsible for This package contains **high-level ingestion components** responsible for
@@ -8,13 +10,22 @@ It represents the **top of the ingestion pipeline** and is intended to be the
primary interaction surface for library consumers. primary interaction surface for library consumers.
Components in this package: Components in this package:
- Are provider-agnostic
- Depend only on adapter and parser contracts - Are provider-agnostic.
- Contain no provider-specific API logic - Depend only on adapter and parser contracts.
- Expose read-only ingestion workflows - Contain no provider-specific API logic.
- Expose read-only ingestion workflows.
Consumers are expected to construct a mail adapter and pass it to the Consumers are expected to construct a mail adapter and pass it to the
ingestion layer to begin processing messages and threads. ingestion layer to begin processing messages and threads.
---
# Public API
- `MailIntakeReader`
---
""" """
from .reader import MailIntakeReader from .reader import MailIntakeReader

View File

@@ -0,0 +1,3 @@
from .reader import MailIntakeReader
__all__ = ["MailIntakeReader"]

View File

@@ -1,14 +1,17 @@
""" """
# Summary
High-level mail ingestion orchestration for Mail Intake. High-level mail ingestion orchestration for Mail Intake.
This module provides the primary, provider-agnostic entry point for This module provides the primary, provider-agnostic entry point for
reading and processing mail data. reading and processing mail data.
It coordinates: It coordinates:
- Mail adapter access
- Message and thread iteration - Mail adapter access.
- Header and body parsing - Message and thread iteration.
- Normalization and model construction - Header and body parsing.
- Normalization and model construction.
No provider-specific logic or API semantics are permitted in this layer. No provider-specific logic or API semantics are permitted in this layer.
""" """
@@ -29,19 +32,21 @@ class MailIntakeReader:
""" """
High-level read-only ingestion interface. High-level read-only ingestion interface.
This class is the **primary entry point** for consumers of the Mail Notes:
Intake library. **Responsibilities:**
It orchestrates the full ingestion pipeline: - This class is the primary entry point for consumers of the
- Querying the adapter for message references Mail Intake library.
- Fetching raw provider messages - It orchestrates the full ingestion pipeline:
- Parsing and normalizing message data - Querying the adapter for message references.
- Constructing domain models - Fetching raw provider messages.
- Parsing and normalizing message data.
- Constructing domain models.
This class is intentionally: **Constraints:**
- Provider-agnostic
- Stateless beyond iteration scope - This class is intentionally: Provider-agnostic, stateless beyond
- Read-only iteration scope, read-only.
""" """
def __init__(self, adapter: MailIntakeAdapter): def __init__(self, adapter: MailIntakeAdapter):
@@ -49,8 +54,8 @@ class MailIntakeReader:
Initialize the mail reader. Initialize the mail reader.
Args: Args:
adapter: Mail adapter implementation used to retrieve raw adapter (MailIntakeAdapter):
messages and threads from a mail provider. Mail adapter implementation used to retrieve raw messages and threads from a mail provider.
""" """
self._adapter = adapter self._adapter = adapter
@@ -59,13 +64,16 @@ class MailIntakeReader:
Iterate over parsed messages matching a provider query. Iterate over parsed messages matching a provider query.
Args: Args:
query: Provider-specific query string used to filter messages. query (str):
Provider-specific query string used to filter messages.
Yields: Yields:
Fully parsed and normalized `MailIntakeMessage` instances. MailIntakeMessage:
Fully parsed and normalized `MailIntakeMessage` instances.
Raises: Raises:
MailIntakeParsingError: If a message cannot be parsed. MailIntakeParsingError:
If a message cannot be parsed.
""" """
for ref in self._adapter.iter_message_refs(query): for ref in self._adapter.iter_message_refs(query):
raw = self._adapter.fetch_message(ref["message_id"]) raw = self._adapter.fetch_message(ref["message_id"])
@@ -75,17 +83,23 @@ class MailIntakeReader:
""" """
Iterate over threads constructed from messages matching a query. Iterate over threads constructed from messages matching a query.
Messages are grouped by `thread_id` and yielded as complete thread
objects containing all associated messages.
Args: Args:
query: Provider-specific query string used to filter messages. query (str):
Provider-specific query string used to filter messages.
Returns: Yields:
An iterator of `MailIntakeThread` instances. MailIntakeThread:
An iterator of `MailIntakeThread` instances.
Raises: Raises:
MailIntakeParsingError: If a message cannot be parsed. `MailIntakeParsingError`:
If a message cannot be parsed.
Notes:
**Guarantees:**
- Messages are grouped by `thread_id` and yielded as complete
thread objects containing all associated messages.
""" """
threads: Dict[str, MailIntakeThread] = {} threads: Dict[str, MailIntakeThread] = {}
@@ -110,14 +124,16 @@ class MailIntakeReader:
Parse a raw provider message into a `MailIntakeMessage`. Parse a raw provider message into a `MailIntakeMessage`.
Args: Args:
raw_message: Provider-native message payload. raw_message (Dict[str, Any]):
Provider-native message payload.
Returns: Returns:
A fully populated `MailIntakeMessage` instance. MailIntakeMessage:
A fully populated `MailIntakeMessage` instance.
Raises: Raises:
MailIntakeParsingError: If the message payload is missing required MailIntakeParsingError:
fields or cannot be parsed. If the message payload is missing required fields or cannot be parsed.
""" """
try: try:
message_id = raw_message["id"] message_id = raw_message["id"]

View File

@@ -0,0 +1,10 @@
from typing import Iterator, Dict, Any
from mail_intake.adapters.base import MailIntakeAdapter
from mail_intake.models.message import MailIntakeMessage
from mail_intake.models.thread import MailIntakeThread
class MailIntakeReader:
def __init__(self, adapter: MailIntakeAdapter) -> None: ...
def iter_messages(self, query: str) -> Iterator[MailIntakeMessage]: ...
def iter_threads(self, query: str) -> Iterator[MailIntakeThread]: ...
def _parse_message(self, raw_message: Dict[str, Any]) -> MailIntakeMessage: ...

View File

@@ -1,16 +1,28 @@
""" """
# Summary
Domain models for Mail Intake. Domain models for Mail Intake.
This package defines the **canonical, provider-agnostic data models** This package defines the **canonical, provider-agnostic data models**
used throughout the Mail Intake ingestion pipeline. used throughout the Mail Intake ingestion pipeline.
Models in this package: Models in this package:
- Represent fully parsed and normalized mail data
- Are safe to persist, serialize, and index - Represent fully parsed and normalized mail data.
- Contain no provider-specific payloads or API semantics - Are safe to persist, serialize, and index.
- Serve as stable inputs for downstream processing and analysis - Contain no provider-specific payloads or API semantics.
- Serve as stable inputs for downstream processing and analysis.
These models form the core internal data contract of the library. These models form the core internal data contract of the library.
---
# Public API
- `MailIntakeMessage`
- `MailIntakeThread`
---
""" """
from .message import MailIntakeMessage from .message import MailIntakeMessage

View File

@@ -0,0 +1,4 @@
from .message import MailIntakeMessage
from .thread import MailIntakeThread
__all__ = ["MailIntakeMessage", "MailIntakeThread"]

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Message domain models for Mail Intake. Message domain models for Mail Intake.
This module defines the **canonical, provider-agnostic representation** This module defines the **canonical, provider-agnostic representation**
@@ -19,37 +21,60 @@ class MailIntakeMessage:
""" """
Canonical internal representation of a single email message. Canonical internal representation of a single email message.
This model represents a fully parsed and normalized email message. Notes:
It is intentionally provider-agnostic and suitable for persistence, **Guarantees:**
indexing, and downstream processing.
No provider-specific identifiers, payloads, or API semantics - This model represents a fully parsed and normalized email message.
should appear in this model. - It is intentionally provider-agnostic and suitable for
persistence, indexing, and downstream processing.
**Constraints:**
- No provider-specific identifiers, payloads, or API semantics
should appear in this model.
""" """
message_id: str message_id: str
"""Provider-specific message identifier.""" """
Provider-specific message identifier.
"""
thread_id: str thread_id: str
"""Provider-specific thread identifier to which this message belongs.""" """
Provider-specific thread identifier to which this message belongs.
"""
timestamp: datetime timestamp: datetime
"""Message timestamp as a timezone-naive UTC datetime.""" """
Message timestamp as a timezone-naive UTC datetime.
"""
from_email: str from_email: str
"""Sender email address.""" """
Sender email address.
"""
from_name: Optional[str] from_name: Optional[str]
"""Optional human-readable sender name.""" """
Optional human-readable sender name.
"""
subject: str subject: str
"""Raw subject line of the message.""" """
Raw subject line of the message.
"""
body_text: str body_text: str
"""Extracted plain-text body content of the message.""" """
Extracted plain-text body content of the message.
"""
snippet: str snippet: str
"""Short provider-supplied preview snippet of the message.""" """
Short provider-supplied preview snippet of the message.
"""
raw_headers: Dict[str, str] raw_headers: Dict[str, str]
"""Normalized mapping of message headers (header name → value).""" """
Normalized mapping of message headers (header name → value).
"""

View File

@@ -0,0 +1,14 @@
from datetime import datetime
from typing import Optional, Dict
class MailIntakeMessage:
message_id: str
thread_id: str
timestamp: datetime
from_email: str
from_name: Optional[str]
subject: str
body_text: str
snippet: str
raw_headers: Dict[str, str]
def __init__(self, message_id: str, thread_id: str, timestamp: datetime, from_email: str, from_name: Optional[str], subject: str, body_text: str, snippet: str, raw_headers: Dict[str, str]) -> None: ...

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Thread domain models for Mail Intake. Thread domain models for Mail Intake.
This module defines the **canonical, provider-agnostic representation** This module defines the **canonical, provider-agnostic representation**
@@ -20,40 +22,55 @@ class MailIntakeThread:
""" """
Canonical internal representation of an email thread. Canonical internal representation of an email thread.
A thread groups multiple related messages under a single subject Notes:
and participant set. It is designed to support reasoning over **Guarantees:**
conversational context such as job applications, interviews,
follow-ups, and ongoing discussions.
This model is provider-agnostic and safe to persist. - A thread groups multiple related messages under a single subject
and participant set.
- It is designed to support reasoning over conversational context
such as job applications, interviews, follow-ups, and ongoing discussions.
- This model is provider-agnostic and safe to persist.
""" """
thread_id: str thread_id: str
"""Provider-specific thread identifier.""" """
Provider-specific thread identifier.
"""
normalized_subject: str normalized_subject: str
"""Normalized subject line used to group related messages.""" """
Normalized subject line used to group related messages.
"""
participants: Set[str] = field(default_factory=set) participants: Set[str] = field(default_factory=set)
"""Set of unique participant email addresses observed in the thread.""" """
Set of unique participant email addresses observed in the thread.
"""
messages: List[MailIntakeMessage] = field(default_factory=list) messages: List[MailIntakeMessage] = field(default_factory=list)
"""Ordered list of messages belonging to this thread.""" """
Ordered list of messages belonging to this thread.
"""
last_activity_at: datetime | None = None last_activity_at: datetime | None = None
"""Timestamp of the most recent message in the thread.""" """
Timestamp of the most recent message in the thread.
"""
def add_message(self, message: MailIntakeMessage) -> None: def add_message(self, message: MailIntakeMessage) -> None:
""" """
Add a message to the thread and update derived fields. Add a message to the thread and update derived fields.
This method:
- Appends the message to the thread
- Tracks unique participants
- Updates the last activity timestamp
Args: Args:
message: Parsed mail message to add to the thread. message (MailIntakeMessage):
Parsed mail message to add to the thread.
Notes:
**Responsibilities:**
- Appends the message to the thread.
- Tracks unique participants.
- Updates the last activity timestamp.
""" """
self.messages.append(message) self.messages.append(message)

View File

@@ -0,0 +1,12 @@
from datetime import datetime
from typing import List, Set, Optional
from .message import MailIntakeMessage
class MailIntakeThread:
thread_id: str
normalized_subject: str
participants: Set[str]
messages: List[MailIntakeMessage]
last_activity_at: Optional[datetime]
def __init__(self, thread_id: str, normalized_subject: str, participants: Set[str] = ..., messages: List[MailIntakeMessage] = ..., last_activity_at: Optional[datetime] = ...) -> None: ...
def add_message(self, message: MailIntakeMessage) -> None: ...

View File

@@ -1,21 +1,36 @@
""" """
# Summary
Message parsing utilities for Mail Intake. Message parsing utilities for Mail Intake.
This package contains **provider-aware but adapter-agnostic parsing helpers** This package contains **provider-aware but adapter-agnostic parsing helpers**
used to extract and normalize structured information from raw mail payloads. used to extract and normalize structured information from raw mail payloads.
Parsers in this package are responsible for: Parsers in this package are responsible for:
- Interpreting provider-native message structures
- Extracting meaningful fields such as headers, body text, and subjects - Interpreting provider-native message structures.
- Normalizing data into consistent internal representations - Extracting meaningful fields such as headers, body text, and subjects.
- Normalizing data into consistent internal representations.
This package does not: This package does not:
- Perform network or IO operations
- Contain provider API logic - Perform network or IO operations.
- Construct domain models directly - Contain provider API logic.
- Construct domain models directly.
Parsing functions are designed to be composable and are orchestrated by the Parsing functions are designed to be composable and are orchestrated by the
ingestion layer. ingestion layer.
---
# Public API
- `extract_body`
- `parse_headers`
- `extract_sender`
- `normalize_subject`
---
""" """
from .body import extract_body from .body import extract_body

View File

@@ -0,0 +1,5 @@
from .body import extract_body
from .headers import parse_headers, extract_sender
from .subject import normalize_subject
__all__ = ["extract_body", "parse_headers", "extract_sender", "normalize_subject"]

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Message body extraction utilities for Mail Intake. Message body extraction utilities for Mail Intake.
This module contains helper functions for extracting a best-effort This module contains helper functions for extracting a best-effort
@@ -24,13 +26,16 @@ def _decode_base64(data: str) -> str:
omit padding and use non-standard characters. omit padding and use non-standard characters.
Args: Args:
data: URL-safe base64-encoded string. data (str):
URL-safe base64-encoded string.
Returns: Returns:
Decoded UTF-8 text with replacement for invalid characters. str:
Decoded UTF-8 text with replacement for invalid characters.
Raises: Raises:
MailIntakeParsingError: If decoding fails. MailIntakeParsingError:
If decoding fails.
""" """
try: try:
padded = data.replace("-", "+").replace("_", "/") padded = data.replace("-", "+").replace("_", "/")
@@ -45,14 +50,17 @@ def _extract_from_part(part: Dict[str, Any]) -> Optional[str]:
Extract text content from a single MIME part. Extract text content from a single MIME part.
Supports: Supports:
- text/plain
- text/html (converted to plain text) - `text/plain`
- `text/html` (converted to plain text)
Args: Args:
part: MIME part dictionary from a provider payload. part (Dict[str, Any]):
MIME part dictionary from a provider payload.
Returns: Returns:
Extracted plain-text content, or None if unsupported or empty. Optional[str]:
Extracted plain-text content, or `None` if unsupported or empty.
""" """
mime_type = part.get("mimeType") mime_type = part.get("mimeType")
body = part.get("body", {}) body = part.get("body", {})
@@ -79,16 +87,19 @@ def extract_body(payload: Dict[str, Any]) -> str:
Extract the best-effort message body from a Gmail payload. Extract the best-effort message body from a Gmail payload.
Priority: Priority:
1. text/plain
2. text/html (stripped to text) 1. `text/plain`
2. `text/html` (stripped to text)
3. Single-part body 3. Single-part body
4. empty string (if nothing usable found) 4. Empty string (if nothing usable found)
Args: Args:
payload: Provider-native message payload dictionary. payload (Dict[str, Any]):
Provider-native message payload dictionary.
Returns: Returns:
Extracted plain-text message body. str:
Extracted plain-text message body.
""" """
if not payload: if not payload:
return "" return ""

View File

@@ -0,0 +1,3 @@
from typing import Dict, Any
def extract_body(payload: Dict[str, Any]) -> str: ...

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Message header parsing utilities for Mail Intake. Message header parsing utilities for Mail Intake.
This module provides helper functions for normalizing and extracting This module provides helper functions for normalizing and extracting
@@ -15,18 +17,26 @@ def parse_headers(raw_headers: List[Dict[str, str]]) -> Dict[str, str]:
""" """
Convert a list of Gmail-style headers into a normalized dict. Convert a list of Gmail-style headers into a normalized dict.
Provider payloads (such as Gmail) typically represent headers as a list
of name/value mappings. This function normalizes them into a
case-insensitive dictionary keyed by lowercase header names.
Args: Args:
raw_headers: List of header dictionaries, each containing raw_headers (List[Dict[str, str]]):
``name`` and ``value`` keys. List of header dictionaries, each containing `name` and `value` keys.
Returns: Returns:
Dictionary mapping lowercase header names to stripped values. Dict[str, str]:
Dictionary mapping lowercase header names to stripped values.
Notes:
**Guarantees:**
- Provider payloads (such as Gmail) typically represent headers as a
list of name/value mappings.
- This function normalizes them into a case-insensitive dictionary
keyed by lowercase header names.
Example: Example:
Typical usage:
```python
Input: Input:
[ [
{"name": "From", "value": "John Doe <john@example.com>"}, {"name": "From", "value": "John Doe <john@example.com>"},
@@ -38,6 +48,7 @@ def parse_headers(raw_headers: List[Dict[str, str]]) -> Dict[str, str]:
"from": "John Doe <john@example.com>", "from": "John Doe <john@example.com>",
"subject": "Re: Interview Update", "subject": "Re: Interview Update",
} }
```
""" """
headers: Dict[str, str] = {} headers: Dict[str, str] = {}
@@ -57,22 +68,26 @@ def extract_sender(headers: Dict[str, str]) -> Tuple[str, Optional[str]]:
""" """
Extract sender email and optional display name from headers. Extract sender email and optional display name from headers.
This function parses the ``From`` header and attempts to extract:
- Sender email address
- Optional human-readable display name
Args: Args:
headers: Normalized header dictionary as returned by headers (Dict[str, str]):
:func:`parse_headers`. Normalized header dictionary as returned by `parse_headers()`.
Returns: Returns:
A tuple ``(email, name)`` where: Tuple[str, Optional[str]]:
- ``email`` is the sender email address A tuple `(email, name)` where `email` is the sender email address
- ``name`` is the display name, or ``None`` if unavailable and `name` is the display name, or `None` if unavailable.
Examples: Notes:
``"John Doe <john@example.com>"`` → ``("john@example.com", "John Doe")`` **Responsibilities:**
``"john@example.com"`` → ``("john@example.com", None)``
- This function parses the `From` header and attempts to extract
sender email address and optional human-readable display name.
Example:
Typical values:
- `"John Doe <john@example.com>"` -> `("john@example.com", "John Doe")`
- `"john@example.com"` -> `("john@example.com", None)`
""" """
from_header = headers.get("from") from_header = headers.get("from")
if not from_header: if not from_header:

View File

@@ -0,0 +1,4 @@
from typing import Dict, List, Tuple, Optional
def parse_headers(raw_headers: List[Dict[str, str]]) -> Dict[str, str]: ...
def extract_sender(headers: Dict[str, str]) -> Tuple[str, Optional[str]]: ...

View File

@@ -1,4 +1,6 @@
""" """
# Summary
Subject line normalization utilities for Mail Intake. Subject line normalization utilities for Mail Intake.
This module provides helper functions for normalizing email subject lines This module provides helper functions for normalizing email subject lines
@@ -12,27 +14,35 @@ import re
_PREFIX_RE = re.compile(r"^(re|fw|fwd)\s*:\s*", re.IGNORECASE) _PREFIX_RE = re.compile(r"^(re|fw|fwd)\s*:\s*", re.IGNORECASE)
"""Regular expression matching common reply/forward subject prefixes.""" """
Regular expression matching common reply/forward subject prefixes.
"""
def normalize_subject(subject: str) -> str: def normalize_subject(subject: str) -> str:
""" """
Normalize an email subject for thread-level comparison. Normalize an email subject for thread-level comparison.
Operations:
- Strips common prefixes such as ``Re:``, ``Fwd:``, and ``FW:``
- Repeats prefix stripping to handle stacked prefixes
- Collapses excessive whitespace
- Preserves original casing (no lowercasing)
This function is intentionally conservative and avoids aggressive
transformations that could alter the semantic meaning of the subject.
Args: Args:
subject: Raw subject line from a message header. subject (str):
Raw subject line from a message header.
Returns: Returns:
Normalized subject string suitable for thread grouping. str:
Normalized subject string suitable for thread grouping.
Notes:
**Responsibilities:**
- Strips common prefixes such as `Re:`, `Fwd:`, and `FW:`.
- Repeats prefix stripping to handle stacked prefixes.
- Collapses excessive whitespace.
- Preserves original casing (no lowercasing).
**Guarantees:**
- This function is intentionally conservative and avoids aggressive
transformations that could alter the semantic meaning of the subject.
""" """
if not subject: if not subject:
return "" return ""

View File

@@ -0,0 +1 @@
def normalize_subject(subject: str) -> str: ...

View File

@@ -1,186 +0,0 @@
"""
MkDocs documentation management CLI.
This script provides a proper CLI interface to:
- Generate MkDocs Markdown files with mkdocstrings directives
- Build the documentation site
- Serve the documentation site locally
All operations are performed by calling MkDocs as a Python library
(no shell command invocation).
Requirements:
- mkdocs
- mkdocs-material
- mkdocstrings[python]
Usage:
python manage_docs.py generate
python manage_docs.py build
python manage_docs.py serve
python manage_docs.py build_mcp
Optional flags:
--docs-dir PATH Path to docs directory (default: ./docs)
--package-root NAME Root Python package name (default: mail_intake)
"""
import re
import argparse
from pathlib import Path
from typing import Iterable
from mkdocs.commands import build as mkdocs_build
from mkdocs.commands import serve as mkdocs_serve
from mkdocs.config import load_config
PROJECT_ROOT = Path(__file__).resolve().parent
DEFAULT_DOCS_DIR = PROJECT_ROOT / "docs"
DEFAULT_PACKAGE_ROOT = "mail_intake"
MKDOCS_YML = PROJECT_ROOT / "mkdocs.yml"
DEFAULT_MCP_DIR = PROJECT_ROOT / "mcp"
MKDOCSTRINGS_DIRECTIVE = re.compile(r"^:::\s+([a-zA-Z0-9_.]+)", re.MULTILINE)
# -------------------------
# Existing functionality
# -------------------------
def generate_docs_from_nav(
project_root: Path,
docs_root: Path,
package_root: str,
) -> None:
"""
Create and populate MkDocs Markdown files with mkdocstrings directives.
This function:
- Walks the Python package structure
- Mirrors it under the docs directory
- Creates missing .md files
- Creates index.md for packages (__init__.py)
- Overwrites content with ::: package.module
Examples:
mail_intake/__init__.py -> docs/mail_intake/index.md
mail_intake/config.py -> docs/mail_intake/config.md
mail_intake/adapters/__init__.py -> docs/mail_intake/adapters/index.md
mail_intake/adapters/base.py -> docs/mail_intake/adapters/base.md
"""
package_dir = project_root / package_root
if not package_dir.exists():
raise FileNotFoundError(f"Package not found: {package_dir}")
docs_root.mkdir(parents=True, exist_ok=True)
for py_file in package_dir.rglob("*.py"):
rel = py_file.relative_to(project_root)
if py_file.name == "__init__.py":
# Package → index.md
module_path = ".".join(rel.parent.parts)
md_path = docs_root / rel.parent / "index.md"
title = rel.parent.name.replace("_", " ").title()
else:
# Regular module → <module>.md
module_path = ".".join(rel.with_suffix("").parts)
md_path = docs_root / rel.with_suffix(".md")
title = md_path.stem.replace("_", " ").title()
md_path.parent.mkdir(parents=True, exist_ok=True)
content = f"""# {title}
::: {module_path}
"""
md_path.write_text(content, encoding="utf-8")
def load_mkdocs_config():
if not MKDOCS_YML.exists():
raise FileNotFoundError("mkdocs.yml not found at project root")
return load_config(str(MKDOCS_YML))
def cmd_generate(args: argparse.Namespace) -> None:
generate_docs_from_nav(
project_root=PROJECT_ROOT,
docs_root=args.docs_dir,
package_root=args.package_root,
)
def cmd_build(_: argparse.Namespace) -> None:
config = load_mkdocs_config()
mkdocs_build.build(config)
def cmd_serve(_: argparse.Namespace) -> None:
mkdocs_serve.serve(
config_file=str(MKDOCS_YML)
)
# -------------------------
# MCP generation
# -------------------------
def iter_markdown_files(docs_root: Path) -> Iterable[Path]:
yield from docs_root.rglob("*.md")
def extract_modules(md_file: Path) -> list[str]:
content = md_file.read_text(encoding="utf-8")
return MKDOCSTRINGS_DIRECTIVE.findall(content)
# -------------------------
# CLI
# -------------------------
def main() -> None:
parser = argparse.ArgumentParser(
prog="manage_docs.py",
description="Manage MkDocs documentation and MCP exports for the project",
)
parser.add_argument(
"--docs-dir",
type=Path,
default=DEFAULT_DOCS_DIR,
help="Path to the docs directory",
)
parser.add_argument(
"--package-root",
default=DEFAULT_PACKAGE_ROOT,
help="Root Python package name",
)
subparsers = parser.add_subparsers(dest="command", required=True)
subparsers.add_parser(
"generate",
help="Generate Markdown files with mkdocstrings directives",
).set_defaults(func=cmd_generate)
subparsers.add_parser(
"build",
help="Build the MkDocs site",
).set_defaults(func=cmd_build)
subparsers.add_parser(
"serve",
help="Serve the MkDocs site locally",
).set_defaults(func=cmd_serve)
args = parser.parse_args()
args.func(args)
if __name__ == "__main__":
main()

6
mcp_docs/index.json Normal file
View File

@@ -0,0 +1,6 @@
{
"project": "mail_intake",
"type": "docforge-model",
"modules_count": 22,
"source": "docforge"
}

View File

@@ -0,0 +1,74 @@
{
"module": "mail_intake.adapters.base",
"content": {
"path": "mail_intake.adapters.base",
"docstring": "# Summary\n\nMail provider adapter contracts for Mail Intake.\n\nThis module defines the **provider-agnostic adapter interface** used for\nread-only mail ingestion.\n\nAdapters encapsulate all provider-specific access logic and expose a\nminimal, normalized contract to the rest of the system. No provider-specific\ntypes or semantics should leak beyond implementations of this interface.",
"objects": {
"ABC": {
"name": "ABC",
"kind": "alias",
"path": "mail_intake.adapters.base.ABC",
"signature": "<bound method Alias.signature of Alias('ABC', 'abc.ABC')>",
"docstring": null
},
"abstractmethod": {
"name": "abstractmethod",
"kind": "alias",
"path": "mail_intake.adapters.base.abstractmethod",
"signature": "<bound method Alias.signature of Alias('abstractmethod', 'abc.abstractmethod')>",
"docstring": null
},
"Iterator": {
"name": "Iterator",
"kind": "alias",
"path": "mail_intake.adapters.base.Iterator",
"signature": "<bound method Alias.signature of Alias('Iterator', 'typing.Iterator')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.adapters.base.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.adapters.base.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"MailIntakeAdapter": {
"name": "MailIntakeAdapter",
"kind": "class",
"path": "mail_intake.adapters.base.MailIntakeAdapter",
"signature": "<bound method Class.signature of Class('MailIntakeAdapter', 18, 93)>",
"docstring": "Base adapter interface for mail providers.\n\nNotes:\n **Guarantees:**\n\n - Discover messages matching a query.\n - Retrieve full message payloads.\n - Retrieve full thread payloads.\n\n **Lifecycle:**\n\n - Adapters are intentionally read-only and must not mutate provider state.",
"members": {
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.adapters.base.MailIntakeAdapter.iter_message_refs",
"signature": "<bound method Function.signature of Function('iter_message_refs', 34, 63)>",
"docstring": "Iterate over lightweight message references matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n Dict[str, str]:\n Dictionaries containing message and thread identifiers.\n\nNotes:\n **Guarantees:**\n\n - Implementations must yield dictionaries containing at least\n `message_id` and `thread_id`.\n\nExample:\n Typical yield:\n\n ```python\n {\n \"message_id\": \"...\",\n \"thread_id\": \"...\"\n }\n ```"
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.adapters.base.MailIntakeAdapter.fetch_message",
"signature": "<bound method Function.signature of Function('fetch_message', 65, 78)>",
"docstring": "Fetch a full raw message by message identifier.\n\nArgs:\n message_id (str):\n Provider-specific message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native message payload (e.g., Gmail message JSON structure)."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.adapters.base.MailIntakeAdapter.fetch_thread",
"signature": "<bound method Function.signature of Function('fetch_thread', 80, 93)>",
"docstring": "Fetch a full raw thread by thread identifier.\n\nArgs:\n thread_id (str):\n Provider-specific thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native thread payload."
}
}
}
}
}
}

View File

@@ -0,0 +1,134 @@
{
"module": "mail_intake.adapters.gmail",
"content": {
"path": "mail_intake.adapters.gmail",
"docstring": "# Summary\n\nGmail adapter implementation for Mail Intake.\n\nThis module provides a **Gmail-specific implementation** of the\n`MailIntakeAdapter` contract.\n\nIt is the only place in the codebase where:\n\n- `googleapiclient` is imported.\n- Gmail REST API semantics are known.\n- Low-level `.execute()` calls are made.\n\nAll Gmail-specific behavior must be strictly contained within this module.",
"objects": {
"Iterator": {
"name": "Iterator",
"kind": "alias",
"path": "mail_intake.adapters.gmail.Iterator",
"signature": "<bound method Alias.signature of Alias('Iterator', 'typing.Iterator')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.adapters.gmail.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.adapters.gmail.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"build": {
"name": "build",
"kind": "alias",
"path": "mail_intake.adapters.gmail.build",
"signature": "<bound method Alias.signature of Alias('build', 'googleapiclient.discovery.build')>",
"docstring": null
},
"HttpError": {
"name": "HttpError",
"kind": "alias",
"path": "mail_intake.adapters.gmail.HttpError",
"signature": "<bound method Alias.signature of Alias('HttpError', 'googleapiclient.errors.HttpError')>",
"docstring": null
},
"MailIntakeAdapter": {
"name": "MailIntakeAdapter",
"kind": "class",
"path": "mail_intake.adapters.gmail.MailIntakeAdapter",
"signature": "<bound method Alias.signature of Alias('MailIntakeAdapter', 'mail_intake.adapters.base.MailIntakeAdapter')>",
"docstring": "Base adapter interface for mail providers.\n\nNotes:\n **Guarantees:**\n\n - Discover messages matching a query.\n - Retrieve full message payloads.\n - Retrieve full thread payloads.\n\n **Lifecycle:**\n\n - Adapters are intentionally read-only and must not mutate provider state.",
"members": {
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeAdapter.iter_message_refs",
"signature": "<bound method Alias.signature of Alias('iter_message_refs', 'mail_intake.adapters.base.MailIntakeAdapter.iter_message_refs')>",
"docstring": "Iterate over lightweight message references matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n Dict[str, str]:\n Dictionaries containing message and thread identifiers.\n\nNotes:\n **Guarantees:**\n\n - Implementations must yield dictionaries containing at least\n `message_id` and `thread_id`.\n\nExample:\n Typical yield:\n\n ```python\n {\n \"message_id\": \"...\",\n \"thread_id\": \"...\"\n }\n ```"
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeAdapter.fetch_message",
"signature": "<bound method Alias.signature of Alias('fetch_message', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_message')>",
"docstring": "Fetch a full raw message by message identifier.\n\nArgs:\n message_id (str):\n Provider-specific message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native message payload (e.g., Gmail message JSON structure)."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeAdapter.fetch_thread",
"signature": "<bound method Alias.signature of Alias('fetch_thread', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_thread')>",
"docstring": "Fetch a full raw thread by thread identifier.\n\nArgs:\n thread_id (str):\n Provider-specific thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native thread payload."
}
}
},
"MailIntakeAdapterError": {
"name": "MailIntakeAdapterError",
"kind": "class",
"path": "mail_intake.adapters.gmail.MailIntakeAdapterError",
"signature": "<bound method Alias.signature of Alias('MailIntakeAdapterError', 'mail_intake.exceptions.MailIntakeAdapterError')>",
"docstring": "Errors raised by mail provider adapters.\n\nNotes:\n **Lifecycle:**\n\n - Raised when a provider adapter encounters API errors, transport\n failures, or invalid provider responses."
},
"MailIntakeAuthProvider": {
"name": "MailIntakeAuthProvider",
"kind": "class",
"path": "mail_intake.adapters.gmail.MailIntakeAuthProvider",
"signature": "<bound method Alias.signature of Alias('MailIntakeAuthProvider', 'mail_intake.auth.base.MailIntakeAuthProvider')>",
"docstring": "Abstract base class for authentication providers.\n\nThis interface enforces a strict contract between authentication\nproviders and mail adapters by requiring providers to explicitly\ndeclare the type of credentials they return.\n\nNotes:\n **Responsibilities:**\n\n - Acquire credentials from an external provider.\n - Refresh or revalidate credentials as needed.\n - Handle authentication-specific failure modes.\n - Coordinate with credential persistence layers where applicable.\n\n **Constraints:**\n\n - Mail adapters must treat returned credentials as opaque and\n provider-specific.\n - Mail adapters rely only on the declared credential type expected\n by the adapter.",
"members": {
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeAuthProvider.get_credentials",
"signature": "<bound method Alias.signature of Alias('get_credentials', 'mail_intake.auth.base.MailIntakeAuthProvider.get_credentials')>",
"docstring": "Retrieve valid, provider-specific credentials.\n\nReturns:\n T:\n Credentials of type `T` suitable for immediate use by the\n corresponding mail adapter.\n\nRaises:\n Exception:\n An authentication-specific exception indicating that\n credentials could not be obtained or validated.\n\nNotes:\n **Guarantees:**\n\n - This method is synchronous by design.\n - Represents the sole entry point through which adapters obtain\n authentication material.\n - Implementations must either return credentials of the declared\n type `T` that are valid at the time of return or raise an exception."
}
}
},
"MailIntakeGmailAdapter": {
"name": "MailIntakeGmailAdapter",
"kind": "class",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter",
"signature": "<bound method Class.signature of Class('MailIntakeGmailAdapter', 28, 189)>",
"docstring": "Gmail read-only adapter.\n\nThis adapter implements the `MailIntakeAdapter` interface using the\nGmail REST API. It translates the generic mail intake contract into\nGmail-specific API calls.\n\nNotes:\n **Responsibilities:**\n\n - This class is the ONLY place where `googleapiclient` is imported.\n - Gmail REST semantics are known.\n - `.execute()` is called.\n\n **Constraints:**\n\n - Must remain thin and imperative.\n - Must not perform parsing or interpretation.\n - Must not expose Gmail-specific types beyond this class.",
"members": {
"service": {
"name": "service",
"kind": "attribute",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter.service",
"signature": null,
"docstring": "Lazily initialize and return the Gmail API service client.\n\nReturns:\n Any:\n Initialized Gmail API service instance.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail service cannot be initialized."
},
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter.iter_message_refs",
"signature": "<bound method Function.signature of Function('iter_message_refs', 92, 133)>",
"docstring": "Iterate over message references matching the query.\n\nArgs:\n query (str):\n Gmail search query string.\n\nYields:\n Dict[str, str]:\n Dictionaries containing ``message_id`` and ``thread_id``.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter.fetch_message",
"signature": "<bound method Function.signature of Function('fetch_message', 135, 161)>",
"docstring": "Fetch a full Gmail message by message ID.\n\nArgs:\n message_id (str):\n Gmail message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native Gmail message payload.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter.fetch_thread",
"signature": "<bound method Function.signature of Function('fetch_thread', 163, 189)>",
"docstring": "Fetch a full Gmail thread by thread ID.\n\nArgs:\n thread_id (str):\n Gmail thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native Gmail thread payload.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
}
}
}
}
}
}

View File

@@ -0,0 +1,284 @@
{
"module": "mail_intake.adapters",
"content": {
"path": "mail_intake.adapters",
"docstring": "# Summary\n\nMail provider adapter implementations for Mail Intake.\n\nThis package contains **adapter-layer implementations** responsible for\ninterfacing with external mail providers and exposing a normalized,\nprovider-agnostic contract to the rest of the system.\n\nAdapters in this package:\n\n- Implement the `MailIntakeAdapter` interface.\n- Encapsulate all provider-specific APIs and semantics.\n- Perform read-only access to mail data.\n- Return provider-native payloads without interpretation.\n\nProvider-specific logic **must not leak** outside of adapter implementations.\nAll parsings, normalizations, and transformations must be handled by downstream\ncomponents.\n\n---\n\n# Public API\n\n- `MailIntakeAdapter`\n- `MailIntakeGmailAdapter`\n\n---",
"objects": {
"MailIntakeAdapter": {
"name": "MailIntakeAdapter",
"kind": "class",
"path": "mail_intake.adapters.MailIntakeAdapter",
"signature": "<bound method Alias.signature of Alias('MailIntakeAdapter', 'mail_intake.adapters.base.MailIntakeAdapter')>",
"docstring": "Base adapter interface for mail providers.\n\nNotes:\n **Guarantees:**\n\n - Discover messages matching a query.\n - Retrieve full message payloads.\n - Retrieve full thread payloads.\n\n **Lifecycle:**\n\n - Adapters are intentionally read-only and must not mutate provider state.",
"members": {
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.adapters.MailIntakeAdapter.iter_message_refs",
"signature": "<bound method Alias.signature of Alias('iter_message_refs', 'mail_intake.adapters.base.MailIntakeAdapter.iter_message_refs')>",
"docstring": "Iterate over lightweight message references matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n Dict[str, str]:\n Dictionaries containing message and thread identifiers.\n\nNotes:\n **Guarantees:**\n\n - Implementations must yield dictionaries containing at least\n `message_id` and `thread_id`.\n\nExample:\n Typical yield:\n\n ```python\n {\n \"message_id\": \"...\",\n \"thread_id\": \"...\"\n }\n ```"
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.adapters.MailIntakeAdapter.fetch_message",
"signature": "<bound method Alias.signature of Alias('fetch_message', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_message')>",
"docstring": "Fetch a full raw message by message identifier.\n\nArgs:\n message_id (str):\n Provider-specific message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native message payload (e.g., Gmail message JSON structure)."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.adapters.MailIntakeAdapter.fetch_thread",
"signature": "<bound method Alias.signature of Alias('fetch_thread', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_thread')>",
"docstring": "Fetch a full raw thread by thread identifier.\n\nArgs:\n thread_id (str):\n Provider-specific thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native thread payload."
}
}
},
"MailIntakeGmailAdapter": {
"name": "MailIntakeGmailAdapter",
"kind": "class",
"path": "mail_intake.adapters.MailIntakeGmailAdapter",
"signature": "<bound method Alias.signature of Alias('MailIntakeGmailAdapter', 'mail_intake.adapters.gmail.MailIntakeGmailAdapter')>",
"docstring": "Gmail read-only adapter.\n\nThis adapter implements the `MailIntakeAdapter` interface using the\nGmail REST API. It translates the generic mail intake contract into\nGmail-specific API calls.\n\nNotes:\n **Responsibilities:**\n\n - This class is the ONLY place where `googleapiclient` is imported.\n - Gmail REST semantics are known.\n - `.execute()` is called.\n\n **Constraints:**\n\n - Must remain thin and imperative.\n - Must not perform parsing or interpretation.\n - Must not expose Gmail-specific types beyond this class.",
"members": {
"service": {
"name": "service",
"kind": "attribute",
"path": "mail_intake.adapters.MailIntakeGmailAdapter.service",
"signature": "<bound method Alias.signature of Alias('service', 'mail_intake.adapters.gmail.MailIntakeGmailAdapter.service')>",
"docstring": "Lazily initialize and return the Gmail API service client.\n\nReturns:\n Any:\n Initialized Gmail API service instance.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail service cannot be initialized."
},
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.adapters.MailIntakeGmailAdapter.iter_message_refs",
"signature": "<bound method Alias.signature of Alias('iter_message_refs', 'mail_intake.adapters.gmail.MailIntakeGmailAdapter.iter_message_refs')>",
"docstring": "Iterate over message references matching the query.\n\nArgs:\n query (str):\n Gmail search query string.\n\nYields:\n Dict[str, str]:\n Dictionaries containing ``message_id`` and ``thread_id``.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.adapters.MailIntakeGmailAdapter.fetch_message",
"signature": "<bound method Alias.signature of Alias('fetch_message', 'mail_intake.adapters.gmail.MailIntakeGmailAdapter.fetch_message')>",
"docstring": "Fetch a full Gmail message by message ID.\n\nArgs:\n message_id (str):\n Gmail message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native Gmail message payload.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.adapters.MailIntakeGmailAdapter.fetch_thread",
"signature": "<bound method Alias.signature of Alias('fetch_thread', 'mail_intake.adapters.gmail.MailIntakeGmailAdapter.fetch_thread')>",
"docstring": "Fetch a full Gmail thread by thread ID.\n\nArgs:\n thread_id (str):\n Gmail thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native Gmail thread payload.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
}
}
},
"base": {
"name": "base",
"kind": "module",
"path": "mail_intake.adapters.base",
"signature": null,
"docstring": "# Summary\n\nMail provider adapter contracts for Mail Intake.\n\nThis module defines the **provider-agnostic adapter interface** used for\nread-only mail ingestion.\n\nAdapters encapsulate all provider-specific access logic and expose a\nminimal, normalized contract to the rest of the system. No provider-specific\ntypes or semantics should leak beyond implementations of this interface.",
"members": {
"ABC": {
"name": "ABC",
"kind": "alias",
"path": "mail_intake.adapters.base.ABC",
"signature": "<bound method Alias.signature of Alias('ABC', 'abc.ABC')>",
"docstring": null
},
"abstractmethod": {
"name": "abstractmethod",
"kind": "alias",
"path": "mail_intake.adapters.base.abstractmethod",
"signature": "<bound method Alias.signature of Alias('abstractmethod', 'abc.abstractmethod')>",
"docstring": null
},
"Iterator": {
"name": "Iterator",
"kind": "alias",
"path": "mail_intake.adapters.base.Iterator",
"signature": "<bound method Alias.signature of Alias('Iterator', 'typing.Iterator')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.adapters.base.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.adapters.base.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"MailIntakeAdapter": {
"name": "MailIntakeAdapter",
"kind": "class",
"path": "mail_intake.adapters.base.MailIntakeAdapter",
"signature": "<bound method Class.signature of Class('MailIntakeAdapter', 18, 93)>",
"docstring": "Base adapter interface for mail providers.\n\nNotes:\n **Guarantees:**\n\n - Discover messages matching a query.\n - Retrieve full message payloads.\n - Retrieve full thread payloads.\n\n **Lifecycle:**\n\n - Adapters are intentionally read-only and must not mutate provider state.",
"members": {
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.adapters.base.MailIntakeAdapter.iter_message_refs",
"signature": "<bound method Function.signature of Function('iter_message_refs', 34, 63)>",
"docstring": "Iterate over lightweight message references matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n Dict[str, str]:\n Dictionaries containing message and thread identifiers.\n\nNotes:\n **Guarantees:**\n\n - Implementations must yield dictionaries containing at least\n `message_id` and `thread_id`.\n\nExample:\n Typical yield:\n\n ```python\n {\n \"message_id\": \"...\",\n \"thread_id\": \"...\"\n }\n ```"
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.adapters.base.MailIntakeAdapter.fetch_message",
"signature": "<bound method Function.signature of Function('fetch_message', 65, 78)>",
"docstring": "Fetch a full raw message by message identifier.\n\nArgs:\n message_id (str):\n Provider-specific message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native message payload (e.g., Gmail message JSON structure)."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.adapters.base.MailIntakeAdapter.fetch_thread",
"signature": "<bound method Function.signature of Function('fetch_thread', 80, 93)>",
"docstring": "Fetch a full raw thread by thread identifier.\n\nArgs:\n thread_id (str):\n Provider-specific thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native thread payload."
}
}
}
}
},
"gmail": {
"name": "gmail",
"kind": "module",
"path": "mail_intake.adapters.gmail",
"signature": null,
"docstring": "# Summary\n\nGmail adapter implementation for Mail Intake.\n\nThis module provides a **Gmail-specific implementation** of the\n`MailIntakeAdapter` contract.\n\nIt is the only place in the codebase where:\n\n- `googleapiclient` is imported.\n- Gmail REST API semantics are known.\n- Low-level `.execute()` calls are made.\n\nAll Gmail-specific behavior must be strictly contained within this module.",
"members": {
"Iterator": {
"name": "Iterator",
"kind": "alias",
"path": "mail_intake.adapters.gmail.Iterator",
"signature": "<bound method Alias.signature of Alias('Iterator', 'typing.Iterator')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.adapters.gmail.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.adapters.gmail.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"build": {
"name": "build",
"kind": "alias",
"path": "mail_intake.adapters.gmail.build",
"signature": "<bound method Alias.signature of Alias('build', 'googleapiclient.discovery.build')>",
"docstring": null
},
"HttpError": {
"name": "HttpError",
"kind": "alias",
"path": "mail_intake.adapters.gmail.HttpError",
"signature": "<bound method Alias.signature of Alias('HttpError', 'googleapiclient.errors.HttpError')>",
"docstring": null
},
"MailIntakeAdapter": {
"name": "MailIntakeAdapter",
"kind": "class",
"path": "mail_intake.adapters.gmail.MailIntakeAdapter",
"signature": "<bound method Alias.signature of Alias('MailIntakeAdapter', 'mail_intake.adapters.base.MailIntakeAdapter')>",
"docstring": "Base adapter interface for mail providers.\n\nNotes:\n **Guarantees:**\n\n - Discover messages matching a query.\n - Retrieve full message payloads.\n - Retrieve full thread payloads.\n\n **Lifecycle:**\n\n - Adapters are intentionally read-only and must not mutate provider state.",
"members": {
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeAdapter.iter_message_refs",
"signature": "<bound method Alias.signature of Alias('iter_message_refs', 'mail_intake.adapters.base.MailIntakeAdapter.iter_message_refs')>",
"docstring": "Iterate over lightweight message references matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n Dict[str, str]:\n Dictionaries containing message and thread identifiers.\n\nNotes:\n **Guarantees:**\n\n - Implementations must yield dictionaries containing at least\n `message_id` and `thread_id`.\n\nExample:\n Typical yield:\n\n ```python\n {\n \"message_id\": \"...\",\n \"thread_id\": \"...\"\n }\n ```"
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeAdapter.fetch_message",
"signature": "<bound method Alias.signature of Alias('fetch_message', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_message')>",
"docstring": "Fetch a full raw message by message identifier.\n\nArgs:\n message_id (str):\n Provider-specific message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native message payload (e.g., Gmail message JSON structure)."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeAdapter.fetch_thread",
"signature": "<bound method Alias.signature of Alias('fetch_thread', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_thread')>",
"docstring": "Fetch a full raw thread by thread identifier.\n\nArgs:\n thread_id (str):\n Provider-specific thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native thread payload."
}
}
},
"MailIntakeAdapterError": {
"name": "MailIntakeAdapterError",
"kind": "class",
"path": "mail_intake.adapters.gmail.MailIntakeAdapterError",
"signature": "<bound method Alias.signature of Alias('MailIntakeAdapterError', 'mail_intake.exceptions.MailIntakeAdapterError')>",
"docstring": "Errors raised by mail provider adapters.\n\nNotes:\n **Lifecycle:**\n\n - Raised when a provider adapter encounters API errors, transport\n failures, or invalid provider responses."
},
"MailIntakeAuthProvider": {
"name": "MailIntakeAuthProvider",
"kind": "class",
"path": "mail_intake.adapters.gmail.MailIntakeAuthProvider",
"signature": "<bound method Alias.signature of Alias('MailIntakeAuthProvider', 'mail_intake.auth.base.MailIntakeAuthProvider')>",
"docstring": "Abstract base class for authentication providers.\n\nThis interface enforces a strict contract between authentication\nproviders and mail adapters by requiring providers to explicitly\ndeclare the type of credentials they return.\n\nNotes:\n **Responsibilities:**\n\n - Acquire credentials from an external provider.\n - Refresh or revalidate credentials as needed.\n - Handle authentication-specific failure modes.\n - Coordinate with credential persistence layers where applicable.\n\n **Constraints:**\n\n - Mail adapters must treat returned credentials as opaque and\n provider-specific.\n - Mail adapters rely only on the declared credential type expected\n by the adapter.",
"members": {
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeAuthProvider.get_credentials",
"signature": "<bound method Alias.signature of Alias('get_credentials', 'mail_intake.auth.base.MailIntakeAuthProvider.get_credentials')>",
"docstring": "Retrieve valid, provider-specific credentials.\n\nReturns:\n T:\n Credentials of type `T` suitable for immediate use by the\n corresponding mail adapter.\n\nRaises:\n Exception:\n An authentication-specific exception indicating that\n credentials could not be obtained or validated.\n\nNotes:\n **Guarantees:**\n\n - This method is synchronous by design.\n - Represents the sole entry point through which adapters obtain\n authentication material.\n - Implementations must either return credentials of the declared\n type `T` that are valid at the time of return or raise an exception."
}
}
},
"MailIntakeGmailAdapter": {
"name": "MailIntakeGmailAdapter",
"kind": "class",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter",
"signature": "<bound method Class.signature of Class('MailIntakeGmailAdapter', 28, 189)>",
"docstring": "Gmail read-only adapter.\n\nThis adapter implements the `MailIntakeAdapter` interface using the\nGmail REST API. It translates the generic mail intake contract into\nGmail-specific API calls.\n\nNotes:\n **Responsibilities:**\n\n - This class is the ONLY place where `googleapiclient` is imported.\n - Gmail REST semantics are known.\n - `.execute()` is called.\n\n **Constraints:**\n\n - Must remain thin and imperative.\n - Must not perform parsing or interpretation.\n - Must not expose Gmail-specific types beyond this class.",
"members": {
"service": {
"name": "service",
"kind": "attribute",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter.service",
"signature": null,
"docstring": "Lazily initialize and return the Gmail API service client.\n\nReturns:\n Any:\n Initialized Gmail API service instance.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail service cannot be initialized."
},
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter.iter_message_refs",
"signature": "<bound method Function.signature of Function('iter_message_refs', 92, 133)>",
"docstring": "Iterate over message references matching the query.\n\nArgs:\n query (str):\n Gmail search query string.\n\nYields:\n Dict[str, str]:\n Dictionaries containing ``message_id`` and ``thread_id``.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter.fetch_message",
"signature": "<bound method Function.signature of Function('fetch_message', 135, 161)>",
"docstring": "Fetch a full Gmail message by message ID.\n\nArgs:\n message_id (str):\n Gmail message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native Gmail message payload.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.adapters.gmail.MailIntakeGmailAdapter.fetch_thread",
"signature": "<bound method Function.signature of Function('fetch_thread', 163, 189)>",
"docstring": "Fetch a full Gmail thread by thread ID.\n\nArgs:\n thread_id (str):\n Gmail thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native Gmail thread payload.\n\nRaises:\n MailIntakeAdapterError:\n If the Gmail API returns an error."
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,60 @@
{
"module": "mail_intake.auth.base",
"content": {
"path": "mail_intake.auth.base",
"docstring": "# Summary\n\nAuthentication provider contracts for Mail Intake.\n\nThis module defines the **authentication abstraction layer** used by mail\nadapters to obtain provider-specific credentials.\n\nAuthentication concerns are intentionally decoupled from adapter logic.\nAdapters depend only on this interface and must not be aware of how\ncredentials are acquired, refreshed, or persisted.",
"objects": {
"ABC": {
"name": "ABC",
"kind": "alias",
"path": "mail_intake.auth.base.ABC",
"signature": "<bound method Alias.signature of Alias('ABC', 'abc.ABC')>",
"docstring": null
},
"abstractmethod": {
"name": "abstractmethod",
"kind": "alias",
"path": "mail_intake.auth.base.abstractmethod",
"signature": "<bound method Alias.signature of Alias('abstractmethod', 'abc.abstractmethod')>",
"docstring": null
},
"Generic": {
"name": "Generic",
"kind": "alias",
"path": "mail_intake.auth.base.Generic",
"signature": "<bound method Alias.signature of Alias('Generic', 'typing.Generic')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mail_intake.auth.base.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"T": {
"name": "T",
"kind": "attribute",
"path": "mail_intake.auth.base.T",
"signature": null,
"docstring": null
},
"MailIntakeAuthProvider": {
"name": "MailIntakeAuthProvider",
"kind": "class",
"path": "mail_intake.auth.base.MailIntakeAuthProvider",
"signature": "<bound method Class.signature of Class('MailIntakeAuthProvider', 20, 68)>",
"docstring": "Abstract base class for authentication providers.\n\nThis interface enforces a strict contract between authentication\nproviders and mail adapters by requiring providers to explicitly\ndeclare the type of credentials they return.\n\nNotes:\n **Responsibilities:**\n\n - Acquire credentials from an external provider.\n - Refresh or revalidate credentials as needed.\n - Handle authentication-specific failure modes.\n - Coordinate with credential persistence layers where applicable.\n\n **Constraints:**\n\n - Mail adapters must treat returned credentials as opaque and\n provider-specific.\n - Mail adapters rely only on the declared credential type expected\n by the adapter.",
"members": {
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.auth.base.MailIntakeAuthProvider.get_credentials",
"signature": "<bound method Function.signature of Function('get_credentials', 44, 68)>",
"docstring": "Retrieve valid, provider-specific credentials.\n\nReturns:\n T:\n Credentials of type `T` suitable for immediate use by the\n corresponding mail adapter.\n\nRaises:\n Exception:\n An authentication-specific exception indicating that\n credentials could not be obtained or validated.\n\nNotes:\n **Guarantees:**\n\n - This method is synchronous by design.\n - Represents the sole entry point through which adapters obtain\n authentication material.\n - Implementations must either return credentials of the declared\n type `T` that are valid at the time of return or raise an exception."
}
}
}
}
}
}

View File

@@ -0,0 +1,148 @@
{
"module": "mail_intake.auth.google",
"content": {
"path": "mail_intake.auth.google",
"docstring": "# Summary\n\nGoogle authentication provider implementation for Mail Intake.\n\nThis module provides a **Google OAuthbased authentication provider**\nused primarily for Gmail access.\n\nIt encapsulates all Google-specific authentication concerns, including:\n\n- Credential loading and persistence.\n- Token refresh handling.\n- Interactive OAuth flow initiation.\n- Coordination with a credential persistence layer.\n\nNo Google authentication details should leak outside this module.",
"objects": {
"os": {
"name": "os",
"kind": "alias",
"path": "mail_intake.auth.google.os",
"signature": "<bound method Alias.signature of Alias('os', 'os')>",
"docstring": null
},
"Sequence": {
"name": "Sequence",
"kind": "alias",
"path": "mail_intake.auth.google.Sequence",
"signature": "<bound method Alias.signature of Alias('Sequence', 'typing.Sequence')>",
"docstring": null
},
"google": {
"name": "google",
"kind": "alias",
"path": "mail_intake.auth.google.google",
"signature": "<bound method Alias.signature of Alias('google', 'google')>",
"docstring": null
},
"Request": {
"name": "Request",
"kind": "alias",
"path": "mail_intake.auth.google.Request",
"signature": "<bound method Alias.signature of Alias('Request', 'google.auth.transport.requests.Request')>",
"docstring": null
},
"InstalledAppFlow": {
"name": "InstalledAppFlow",
"kind": "alias",
"path": "mail_intake.auth.google.InstalledAppFlow",
"signature": "<bound method Alias.signature of Alias('InstalledAppFlow', 'google_auth_oauthlib.flow.InstalledAppFlow')>",
"docstring": null
},
"Credentials": {
"name": "Credentials",
"kind": "alias",
"path": "mail_intake.auth.google.Credentials",
"signature": "<bound method Alias.signature of Alias('Credentials', 'google.oauth2.credentials.Credentials')>",
"docstring": null
},
"MailIntakeAuthProvider": {
"name": "MailIntakeAuthProvider",
"kind": "class",
"path": "mail_intake.auth.google.MailIntakeAuthProvider",
"signature": "<bound method Alias.signature of Alias('MailIntakeAuthProvider', 'mail_intake.auth.base.MailIntakeAuthProvider')>",
"docstring": "Abstract base class for authentication providers.\n\nThis interface enforces a strict contract between authentication\nproviders and mail adapters by requiring providers to explicitly\ndeclare the type of credentials they return.\n\nNotes:\n **Responsibilities:**\n\n - Acquire credentials from an external provider.\n - Refresh or revalidate credentials as needed.\n - Handle authentication-specific failure modes.\n - Coordinate with credential persistence layers where applicable.\n\n **Constraints:**\n\n - Mail adapters must treat returned credentials as opaque and\n provider-specific.\n - Mail adapters rely only on the declared credential type expected\n by the adapter.",
"members": {
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.auth.google.MailIntakeAuthProvider.get_credentials",
"signature": "<bound method Alias.signature of Alias('get_credentials', 'mail_intake.auth.base.MailIntakeAuthProvider.get_credentials')>",
"docstring": "Retrieve valid, provider-specific credentials.\n\nReturns:\n T:\n Credentials of type `T` suitable for immediate use by the\n corresponding mail adapter.\n\nRaises:\n Exception:\n An authentication-specific exception indicating that\n credentials could not be obtained or validated.\n\nNotes:\n **Guarantees:**\n\n - This method is synchronous by design.\n - Represents the sole entry point through which adapters obtain\n authentication material.\n - Implementations must either return credentials of the declared\n type `T` that are valid at the time of return or raise an exception."
}
}
},
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.auth.google.CredentialStore",
"signature": "<bound method Alias.signature of Alias('CredentialStore', 'mail_intake.credentials.store.CredentialStore')>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.auth.google.CredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.store.CredentialStore.load')>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.auth.google.CredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.store.CredentialStore.save')>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.auth.google.CredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.store.CredentialStore.clear')>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
},
"MailIntakeAuthError": {
"name": "MailIntakeAuthError",
"kind": "class",
"path": "mail_intake.auth.google.MailIntakeAuthError",
"signature": "<bound method Alias.signature of Alias('MailIntakeAuthError', 'mail_intake.exceptions.MailIntakeAuthError')>",
"docstring": "Authentication and credential-related failures.\n\nNotes:\n **Lifecycle:**\n\n - Raised when authentication providers are unable to acquire,\n refresh, or persist valid credentials."
},
"MailIntakeGoogleAuth": {
"name": "MailIntakeGoogleAuth",
"kind": "class",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth",
"signature": "<bound method Class.signature of Class('MailIntakeGoogleAuth', 32, 135)>",
"docstring": "Google OAuth provider for Gmail access.\n\nThis provider implements the `MailIntakeAuthProvider` interface using\nGoogle's OAuth 2.0 flow and credential management libraries.\n\nNotes:\n **Responsibilities:**\n\n - Load cached credentials from a credential store when available.\n - Refresh expired credentials when possible.\n - Initiate an interactive OAuth flow only when required.\n - Persist refreshed or newly obtained credentials via the store.\n\n **Guarantees:**\n\n - This class is synchronous by design and maintains a minimal\n internal state.",
"members": {
"credentials_path": {
"name": "credentials_path",
"kind": "attribute",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth.credentials_path",
"signature": null,
"docstring": null
},
"store": {
"name": "store",
"kind": "attribute",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth.store",
"signature": null,
"docstring": null
},
"scopes": {
"name": "scopes",
"kind": "attribute",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth.scopes",
"signature": null,
"docstring": null
},
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth.get_credentials",
"signature": "<bound method Function.signature of Function('get_credentials', 76, 135)>",
"docstring": "Retrieve valid Google OAuth credentials.\n\nReturns:\n Credentials:\n A `google.oauth2.credentials.Credentials` instance suitable\n for use with Google API clients.\n\nRaises:\n MailIntakeAuthError:\n If credentials cannot be loaded, refreshed,\n or obtained via interactive authentication.\n\nNotes:\n **Lifecycle:**\n\n - Load cached credentials from the configured credential store.\n - Refresh expired credentials when possible.\n - Perform an interactive OAuth login as a fallback.\n - Persist valid credentials for future use."
}
}
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.auth.google.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
}
}
}
}

View File

@@ -0,0 +1,270 @@
{
"module": "mail_intake.auth",
"content": {
"path": "mail_intake.auth",
"docstring": "# Summary\n\nAuthentication provider implementations for Mail Intake.\n\nThis package defines the **authentication layer** used by mail adapters\nto obtain provider-specific credentials.\n\nIt exposes:\n\n- A stable, provider-agnostic authentication contract.\n- Concrete authentication providers for supported platforms.\n\nAuthentication providers:\n\n- Are responsible for credential acquisition and lifecycle management.\n- Are intentionally decoupled from adapter logic.\n- May be extended by users to support additional providers.\n\nConsumers should depend on the abstract interface and use concrete\nimplementations only where explicitly required.\n\n---\n\n# Public API\n\n- `MailIntakeAuthProvider`\n- `MailIntakeGoogleAuth`\n\n---",
"objects": {
"MailIntakeAuthProvider": {
"name": "MailIntakeAuthProvider",
"kind": "class",
"path": "mail_intake.auth.MailIntakeAuthProvider",
"signature": "<bound method Alias.signature of Alias('MailIntakeAuthProvider', 'mail_intake.auth.base.MailIntakeAuthProvider')>",
"docstring": "Abstract base class for authentication providers.\n\nThis interface enforces a strict contract between authentication\nproviders and mail adapters by requiring providers to explicitly\ndeclare the type of credentials they return.\n\nNotes:\n **Responsibilities:**\n\n - Acquire credentials from an external provider.\n - Refresh or revalidate credentials as needed.\n - Handle authentication-specific failure modes.\n - Coordinate with credential persistence layers where applicable.\n\n **Constraints:**\n\n - Mail adapters must treat returned credentials as opaque and\n provider-specific.\n - Mail adapters rely only on the declared credential type expected\n by the adapter.",
"members": {
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.auth.MailIntakeAuthProvider.get_credentials",
"signature": "<bound method Alias.signature of Alias('get_credentials', 'mail_intake.auth.base.MailIntakeAuthProvider.get_credentials')>",
"docstring": "Retrieve valid, provider-specific credentials.\n\nReturns:\n T:\n Credentials of type `T` suitable for immediate use by the\n corresponding mail adapter.\n\nRaises:\n Exception:\n An authentication-specific exception indicating that\n credentials could not be obtained or validated.\n\nNotes:\n **Guarantees:**\n\n - This method is synchronous by design.\n - Represents the sole entry point through which adapters obtain\n authentication material.\n - Implementations must either return credentials of the declared\n type `T` that are valid at the time of return or raise an exception."
}
}
},
"MailIntakeGoogleAuth": {
"name": "MailIntakeGoogleAuth",
"kind": "class",
"path": "mail_intake.auth.MailIntakeGoogleAuth",
"signature": "<bound method Alias.signature of Alias('MailIntakeGoogleAuth', 'mail_intake.auth.google.MailIntakeGoogleAuth')>",
"docstring": "Google OAuth provider for Gmail access.\n\nThis provider implements the `MailIntakeAuthProvider` interface using\nGoogle's OAuth 2.0 flow and credential management libraries.\n\nNotes:\n **Responsibilities:**\n\n - Load cached credentials from a credential store when available.\n - Refresh expired credentials when possible.\n - Initiate an interactive OAuth flow only when required.\n - Persist refreshed or newly obtained credentials via the store.\n\n **Guarantees:**\n\n - This class is synchronous by design and maintains a minimal\n internal state.",
"members": {
"credentials_path": {
"name": "credentials_path",
"kind": "attribute",
"path": "mail_intake.auth.MailIntakeGoogleAuth.credentials_path",
"signature": "<bound method Alias.signature of Alias('credentials_path', 'mail_intake.auth.google.MailIntakeGoogleAuth.credentials_path')>",
"docstring": null
},
"store": {
"name": "store",
"kind": "attribute",
"path": "mail_intake.auth.MailIntakeGoogleAuth.store",
"signature": "<bound method Alias.signature of Alias('store', 'mail_intake.auth.google.MailIntakeGoogleAuth.store')>",
"docstring": null
},
"scopes": {
"name": "scopes",
"kind": "attribute",
"path": "mail_intake.auth.MailIntakeGoogleAuth.scopes",
"signature": "<bound method Alias.signature of Alias('scopes', 'mail_intake.auth.google.MailIntakeGoogleAuth.scopes')>",
"docstring": null
},
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.auth.MailIntakeGoogleAuth.get_credentials",
"signature": "<bound method Alias.signature of Alias('get_credentials', 'mail_intake.auth.google.MailIntakeGoogleAuth.get_credentials')>",
"docstring": "Retrieve valid Google OAuth credentials.\n\nReturns:\n Credentials:\n A `google.oauth2.credentials.Credentials` instance suitable\n for use with Google API clients.\n\nRaises:\n MailIntakeAuthError:\n If credentials cannot be loaded, refreshed,\n or obtained via interactive authentication.\n\nNotes:\n **Lifecycle:**\n\n - Load cached credentials from the configured credential store.\n - Refresh expired credentials when possible.\n - Perform an interactive OAuth login as a fallback.\n - Persist valid credentials for future use."
}
}
},
"base": {
"name": "base",
"kind": "module",
"path": "mail_intake.auth.base",
"signature": null,
"docstring": "# Summary\n\nAuthentication provider contracts for Mail Intake.\n\nThis module defines the **authentication abstraction layer** used by mail\nadapters to obtain provider-specific credentials.\n\nAuthentication concerns are intentionally decoupled from adapter logic.\nAdapters depend only on this interface and must not be aware of how\ncredentials are acquired, refreshed, or persisted.",
"members": {
"ABC": {
"name": "ABC",
"kind": "alias",
"path": "mail_intake.auth.base.ABC",
"signature": "<bound method Alias.signature of Alias('ABC', 'abc.ABC')>",
"docstring": null
},
"abstractmethod": {
"name": "abstractmethod",
"kind": "alias",
"path": "mail_intake.auth.base.abstractmethod",
"signature": "<bound method Alias.signature of Alias('abstractmethod', 'abc.abstractmethod')>",
"docstring": null
},
"Generic": {
"name": "Generic",
"kind": "alias",
"path": "mail_intake.auth.base.Generic",
"signature": "<bound method Alias.signature of Alias('Generic', 'typing.Generic')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mail_intake.auth.base.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"T": {
"name": "T",
"kind": "attribute",
"path": "mail_intake.auth.base.T",
"signature": null,
"docstring": null
},
"MailIntakeAuthProvider": {
"name": "MailIntakeAuthProvider",
"kind": "class",
"path": "mail_intake.auth.base.MailIntakeAuthProvider",
"signature": "<bound method Class.signature of Class('MailIntakeAuthProvider', 20, 68)>",
"docstring": "Abstract base class for authentication providers.\n\nThis interface enforces a strict contract between authentication\nproviders and mail adapters by requiring providers to explicitly\ndeclare the type of credentials they return.\n\nNotes:\n **Responsibilities:**\n\n - Acquire credentials from an external provider.\n - Refresh or revalidate credentials as needed.\n - Handle authentication-specific failure modes.\n - Coordinate with credential persistence layers where applicable.\n\n **Constraints:**\n\n - Mail adapters must treat returned credentials as opaque and\n provider-specific.\n - Mail adapters rely only on the declared credential type expected\n by the adapter.",
"members": {
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.auth.base.MailIntakeAuthProvider.get_credentials",
"signature": "<bound method Function.signature of Function('get_credentials', 44, 68)>",
"docstring": "Retrieve valid, provider-specific credentials.\n\nReturns:\n T:\n Credentials of type `T` suitable for immediate use by the\n corresponding mail adapter.\n\nRaises:\n Exception:\n An authentication-specific exception indicating that\n credentials could not be obtained or validated.\n\nNotes:\n **Guarantees:**\n\n - This method is synchronous by design.\n - Represents the sole entry point through which adapters obtain\n authentication material.\n - Implementations must either return credentials of the declared\n type `T` that are valid at the time of return or raise an exception."
}
}
}
}
},
"google": {
"name": "google",
"kind": "module",
"path": "mail_intake.auth.google",
"signature": null,
"docstring": "# Summary\n\nGoogle authentication provider implementation for Mail Intake.\n\nThis module provides a **Google OAuthbased authentication provider**\nused primarily for Gmail access.\n\nIt encapsulates all Google-specific authentication concerns, including:\n\n- Credential loading and persistence.\n- Token refresh handling.\n- Interactive OAuth flow initiation.\n- Coordination with a credential persistence layer.\n\nNo Google authentication details should leak outside this module.",
"members": {
"os": {
"name": "os",
"kind": "alias",
"path": "mail_intake.auth.google.os",
"signature": "<bound method Alias.signature of Alias('os', 'os')>",
"docstring": null
},
"Sequence": {
"name": "Sequence",
"kind": "alias",
"path": "mail_intake.auth.google.Sequence",
"signature": "<bound method Alias.signature of Alias('Sequence', 'typing.Sequence')>",
"docstring": null
},
"google": {
"name": "google",
"kind": "alias",
"path": "mail_intake.auth.google.google",
"signature": "<bound method Alias.signature of Alias('google', 'google')>",
"docstring": null
},
"Request": {
"name": "Request",
"kind": "alias",
"path": "mail_intake.auth.google.Request",
"signature": "<bound method Alias.signature of Alias('Request', 'google.auth.transport.requests.Request')>",
"docstring": null
},
"InstalledAppFlow": {
"name": "InstalledAppFlow",
"kind": "alias",
"path": "mail_intake.auth.google.InstalledAppFlow",
"signature": "<bound method Alias.signature of Alias('InstalledAppFlow', 'google_auth_oauthlib.flow.InstalledAppFlow')>",
"docstring": null
},
"Credentials": {
"name": "Credentials",
"kind": "alias",
"path": "mail_intake.auth.google.Credentials",
"signature": "<bound method Alias.signature of Alias('Credentials', 'google.oauth2.credentials.Credentials')>",
"docstring": null
},
"MailIntakeAuthProvider": {
"name": "MailIntakeAuthProvider",
"kind": "class",
"path": "mail_intake.auth.google.MailIntakeAuthProvider",
"signature": "<bound method Alias.signature of Alias('MailIntakeAuthProvider', 'mail_intake.auth.base.MailIntakeAuthProvider')>",
"docstring": "Abstract base class for authentication providers.\n\nThis interface enforces a strict contract between authentication\nproviders and mail adapters by requiring providers to explicitly\ndeclare the type of credentials they return.\n\nNotes:\n **Responsibilities:**\n\n - Acquire credentials from an external provider.\n - Refresh or revalidate credentials as needed.\n - Handle authentication-specific failure modes.\n - Coordinate with credential persistence layers where applicable.\n\n **Constraints:**\n\n - Mail adapters must treat returned credentials as opaque and\n provider-specific.\n - Mail adapters rely only on the declared credential type expected\n by the adapter.",
"members": {
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.auth.google.MailIntakeAuthProvider.get_credentials",
"signature": "<bound method Alias.signature of Alias('get_credentials', 'mail_intake.auth.base.MailIntakeAuthProvider.get_credentials')>",
"docstring": "Retrieve valid, provider-specific credentials.\n\nReturns:\n T:\n Credentials of type `T` suitable for immediate use by the\n corresponding mail adapter.\n\nRaises:\n Exception:\n An authentication-specific exception indicating that\n credentials could not be obtained or validated.\n\nNotes:\n **Guarantees:**\n\n - This method is synchronous by design.\n - Represents the sole entry point through which adapters obtain\n authentication material.\n - Implementations must either return credentials of the declared\n type `T` that are valid at the time of return or raise an exception."
}
}
},
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.auth.google.CredentialStore",
"signature": "<bound method Alias.signature of Alias('CredentialStore', 'mail_intake.credentials.store.CredentialStore')>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.auth.google.CredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.store.CredentialStore.load')>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.auth.google.CredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.store.CredentialStore.save')>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.auth.google.CredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.store.CredentialStore.clear')>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
},
"MailIntakeAuthError": {
"name": "MailIntakeAuthError",
"kind": "class",
"path": "mail_intake.auth.google.MailIntakeAuthError",
"signature": "<bound method Alias.signature of Alias('MailIntakeAuthError', 'mail_intake.exceptions.MailIntakeAuthError')>",
"docstring": "Authentication and credential-related failures.\n\nNotes:\n **Lifecycle:**\n\n - Raised when authentication providers are unable to acquire,\n refresh, or persist valid credentials."
},
"MailIntakeGoogleAuth": {
"name": "MailIntakeGoogleAuth",
"kind": "class",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth",
"signature": "<bound method Class.signature of Class('MailIntakeGoogleAuth', 32, 135)>",
"docstring": "Google OAuth provider for Gmail access.\n\nThis provider implements the `MailIntakeAuthProvider` interface using\nGoogle's OAuth 2.0 flow and credential management libraries.\n\nNotes:\n **Responsibilities:**\n\n - Load cached credentials from a credential store when available.\n - Refresh expired credentials when possible.\n - Initiate an interactive OAuth flow only when required.\n - Persist refreshed or newly obtained credentials via the store.\n\n **Guarantees:**\n\n - This class is synchronous by design and maintains a minimal\n internal state.",
"members": {
"credentials_path": {
"name": "credentials_path",
"kind": "attribute",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth.credentials_path",
"signature": null,
"docstring": null
},
"store": {
"name": "store",
"kind": "attribute",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth.store",
"signature": null,
"docstring": null
},
"scopes": {
"name": "scopes",
"kind": "attribute",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth.scopes",
"signature": null,
"docstring": null
},
"get_credentials": {
"name": "get_credentials",
"kind": "function",
"path": "mail_intake.auth.google.MailIntakeGoogleAuth.get_credentials",
"signature": "<bound method Function.signature of Function('get_credentials', 76, 135)>",
"docstring": "Retrieve valid Google OAuth credentials.\n\nReturns:\n Credentials:\n A `google.oauth2.credentials.Credentials` instance suitable\n for use with Google API clients.\n\nRaises:\n MailIntakeAuthError:\n If credentials cannot be loaded, refreshed,\n or obtained via interactive authentication.\n\nNotes:\n **Lifecycle:**\n\n - Load cached credentials from the configured credential store.\n - Refresh expired credentials when possible.\n - Perform an interactive OAuth login as a fallback.\n - Persist valid credentials for future use."
}
}
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.auth.google.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
}
}
}
}
}
}

View File

@@ -0,0 +1,67 @@
{
"module": "mail_intake.config",
"content": {
"path": "mail_intake.config",
"docstring": "# Summary\n\nGlobal configuration models for Mail Intake.\n\nThis module defines the **top-level configuration object** used to control\nmail ingestion behavior across adapters, authentication providers, and\ningestion workflows.\n\nConfiguration is intentionally explicit, immutable, and free of implicit\nenvironment reads to ensure predictability and testability.",
"objects": {
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mail_intake.config.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.config.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"MailIntakeConfig": {
"name": "MailIntakeConfig",
"kind": "class",
"path": "mail_intake.config.MailIntakeConfig",
"signature": "<bound method Class.signature of Class('MailIntakeConfig', 18, 57)>",
"docstring": "Global configuration for `mail-intake`.\n\nNotes:\n **Guarantees:**\n\n - This configuration is intentionally explicit and immutable.\n - No implicit environment reads or global state.\n - Explicit configuration over implicit defaults.\n - No direct environment or filesystem access.\n - This model is safe to pass across layers and suitable for\n serialization.",
"members": {
"provider": {
"name": "provider",
"kind": "attribute",
"path": "mail_intake.config.MailIntakeConfig.provider",
"signature": null,
"docstring": "Identifier of the mail provider to use (e.g., ``\"gmail\"``)."
},
"user_id": {
"name": "user_id",
"kind": "attribute",
"path": "mail_intake.config.MailIntakeConfig.user_id",
"signature": null,
"docstring": "Provider-specific user identifier. Defaults to the authenticated user."
},
"readonly": {
"name": "readonly",
"kind": "attribute",
"path": "mail_intake.config.MailIntakeConfig.readonly",
"signature": null,
"docstring": "Whether ingestion should operate in read-only mode."
},
"credentials_path": {
"name": "credentials_path",
"kind": "attribute",
"path": "mail_intake.config.MailIntakeConfig.credentials_path",
"signature": null,
"docstring": "Optional path to provider credentials configuration."
},
"token_path": {
"name": "token_path",
"kind": "attribute",
"path": "mail_intake.config.MailIntakeConfig.token_path",
"signature": null,
"docstring": "Optional path to persisted authentication tokens."
}
}
}
}
}
}

View File

@@ -0,0 +1,465 @@
{
"module": "mail_intake.credentials",
"content": {
"path": "mail_intake.credentials",
"docstring": "# Summary\n\nCredential persistence interfaces and implementations for Mail Intake.\n\nThis package defines the abstractions and concrete implementations used\nto persist authentication credentials across Mail Intake components.\n\nThe credential persistence layer is intentionally decoupled from\nauthentication logic. Authentication providers are responsible for\ncredential acquisition, validation, and refresh, while implementations\nwithin this package are responsible solely for storage and retrieval.\n\nThe package provides:\n\n- A generic `CredentialStore` abstraction defining the persistence contract.\n- Local filesystembased storage for development and single-node use.\n- Distributed, Redis-backed storage for production and scaled deployments.\n\nCredential lifecycle management, interpretation, and security policy\ndecisions remain the responsibility of authentication providers.\n\n---\n\n# Public API\n\n- `CredentialStore`\n- `PickleCredentialStore`\n- `RedisCredentialStore`\n\n---",
"objects": {
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.credentials.CredentialStore",
"signature": "<bound method Alias.signature of Alias('CredentialStore', 'mail_intake.credentials.store.CredentialStore')>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.CredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.store.CredentialStore.load')>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.CredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.store.CredentialStore.save')>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.CredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.store.CredentialStore.clear')>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
},
"PickleCredentialStore": {
"name": "PickleCredentialStore",
"kind": "class",
"path": "mail_intake.credentials.PickleCredentialStore",
"signature": "<bound method Alias.signature of Alias('PickleCredentialStore', 'mail_intake.credentials.pickle.PickleCredentialStore')>",
"docstring": "Filesystem-backed credential store using pickle serialization.\n\nThis store persists credentials as a pickled object on the local\nfilesystem. It is a simple implementation intended primarily for\ndevelopment, testing, and single-process execution contexts.\n\nNotes:\n **Guarantees:**\n\n - Stores credentials on the local filesystem.\n - Uses `pickle` for serialization and deserialization.\n - Does not provide encryption, locking, or concurrency guarantees.\n\n **Constraints:**\n\n - Credential lifecycle management, validation, and refresh logic are\n explicitly out of scope for this class.",
"members": {
"path": {
"name": "path",
"kind": "attribute",
"path": "mail_intake.credentials.PickleCredentialStore.path",
"signature": "<bound method Alias.signature of Alias('path', 'mail_intake.credentials.pickle.PickleCredentialStore.path')>",
"docstring": null
},
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.PickleCredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.pickle.PickleCredentialStore.load')>",
"docstring": "Load credentials from the local filesystem.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If the credential file does not exist or cannot be successfully\n deserialized, this method returns `None`.\n - The store does not attempt to validate or interpret the\n returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.PickleCredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.pickle.PickleCredentialStore.save')>",
"docstring": "Persist credentials to the local filesystem.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials at the configured path are overwritten"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.PickleCredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.pickle.PickleCredentialStore.clear')>",
"docstring": "Remove persisted credentials from the local filesystem.\n\nNotes:\n **Lifecycle:**\n\n - This method deletes the credential file if it exists and should be treated as an idempotent operation"
}
}
},
"RedisCredentialStore": {
"name": "RedisCredentialStore",
"kind": "class",
"path": "mail_intake.credentials.RedisCredentialStore",
"signature": "<bound method Alias.signature of Alias('RedisCredentialStore', 'mail_intake.credentials.redis.RedisCredentialStore')>",
"docstring": "Redis-backed implementation of `CredentialStore`.\n\nThis store persists credentials in Redis and is suitable for\ndistributed and horizontally scaled deployments where credentials\nmust be shared across multiple processes or nodes.\n\nNotes:\n **Responsibilities:**\n\n - This class is responsible only for persistence and retrieval.\n - It does not interpret, validate, refresh, or otherwise manage the\n lifecycle of the credentials being stored.\n\n **Guarantees:**\n\n - The store is intentionally generic and delegates all serialization\n concerns to caller-provided functions.\n - This avoids unsafe mechanisms such as `pickle` and allows\n credential formats to be explicitly controlled and audited.",
"members": {
"redis": {
"name": "redis",
"kind": "attribute",
"path": "mail_intake.credentials.RedisCredentialStore.redis",
"signature": "<bound method Alias.signature of Alias('redis', 'mail_intake.credentials.redis.RedisCredentialStore.redis')>",
"docstring": null
},
"key": {
"name": "key",
"kind": "attribute",
"path": "mail_intake.credentials.RedisCredentialStore.key",
"signature": "<bound method Alias.signature of Alias('key', 'mail_intake.credentials.redis.RedisCredentialStore.key')>",
"docstring": null
},
"serialize": {
"name": "serialize",
"kind": "attribute",
"path": "mail_intake.credentials.RedisCredentialStore.serialize",
"signature": "<bound method Alias.signature of Alias('serialize', 'mail_intake.credentials.redis.RedisCredentialStore.serialize')>",
"docstring": null
},
"deserialize": {
"name": "deserialize",
"kind": "attribute",
"path": "mail_intake.credentials.RedisCredentialStore.deserialize",
"signature": "<bound method Alias.signature of Alias('deserialize', 'mail_intake.credentials.redis.RedisCredentialStore.deserialize')>",
"docstring": null
},
"ttl_seconds": {
"name": "ttl_seconds",
"kind": "attribute",
"path": "mail_intake.credentials.RedisCredentialStore.ttl_seconds",
"signature": "<bound method Alias.signature of Alias('ttl_seconds', 'mail_intake.credentials.redis.RedisCredentialStore.ttl_seconds')>",
"docstring": null
},
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.RedisCredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.redis.RedisCredentialStore.load')>",
"docstring": "Load credentials from Redis.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If no value exists for the configured key, or if the stored\n payload cannot be successfully deserialized, this method\n returns `None`.\n - The store does not attempt to validate the returned\n credentials or determine whether they are expired or\n otherwise usable."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.RedisCredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.redis.RedisCredentialStore.save')>",
"docstring": "Persist credentials to Redis.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials under the same key are overwritten\n - If a TTL is configured, the credentials will expire automatically after the specified duration"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.RedisCredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.redis.RedisCredentialStore.clear')>",
"docstring": "Remove stored credentials from Redis.\n\nNotes:\n **Lifecycle:**\n\n - This operation deletes the configured Redis key if it exists\n - Implementations should treat this method as idempotent"
}
}
},
"pickle": {
"name": "pickle",
"kind": "module",
"path": "mail_intake.credentials.pickle",
"signature": null,
"docstring": "# Summary\n\nLocal filesystembased credential persistence for Mail Intake.\n\nThis module provides a file-backed implementation of the\n`CredentialStore` abstraction using Python's `pickle` module.\n\nThe `pickle`-based credential store is intended for local development,\nsingle-node deployments, and controlled environments where credentials\ndo not need to be shared across processes or machines.\n\nDue to the security and portability risks associated with `pickle`-based\nserialization, this implementation is not suitable for distributed or\nuntrusted environments.",
"members": {
"pickle": {
"name": "pickle",
"kind": "alias",
"path": "mail_intake.credentials.pickle.pickle",
"signature": "<bound method Alias.signature of Alias('pickle', 'pickle')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.credentials.pickle.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mail_intake.credentials.pickle.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.credentials.pickle.CredentialStore",
"signature": "<bound method Alias.signature of Alias('CredentialStore', 'mail_intake.credentials.store.CredentialStore')>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.pickle.CredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.store.CredentialStore.load')>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.pickle.CredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.store.CredentialStore.save')>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.pickle.CredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.store.CredentialStore.clear')>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
},
"T": {
"name": "T",
"kind": "attribute",
"path": "mail_intake.credentials.pickle.T",
"signature": null,
"docstring": null
},
"PickleCredentialStore": {
"name": "PickleCredentialStore",
"kind": "class",
"path": "mail_intake.credentials.pickle.PickleCredentialStore",
"signature": "<bound method Class.signature of Class('PickleCredentialStore', 26, 109)>",
"docstring": "Filesystem-backed credential store using pickle serialization.\n\nThis store persists credentials as a pickled object on the local\nfilesystem. It is a simple implementation intended primarily for\ndevelopment, testing, and single-process execution contexts.\n\nNotes:\n **Guarantees:**\n\n - Stores credentials on the local filesystem.\n - Uses `pickle` for serialization and deserialization.\n - Does not provide encryption, locking, or concurrency guarantees.\n\n **Constraints:**\n\n - Credential lifecycle management, validation, and refresh logic are\n explicitly out of scope for this class.",
"members": {
"path": {
"name": "path",
"kind": "attribute",
"path": "mail_intake.credentials.pickle.PickleCredentialStore.path",
"signature": null,
"docstring": null
},
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.pickle.PickleCredentialStore.load",
"signature": "<bound method Function.signature of Function('load', 58, 79)>",
"docstring": "Load credentials from the local filesystem.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If the credential file does not exist or cannot be successfully\n deserialized, this method returns `None`.\n - The store does not attempt to validate or interpret the\n returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.pickle.PickleCredentialStore.save",
"signature": "<bound method Function.signature of Function('save', 81, 95)>",
"docstring": "Persist credentials to the local filesystem.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials at the configured path are overwritten"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.pickle.PickleCredentialStore.clear",
"signature": "<bound method Function.signature of Function('clear', 97, 109)>",
"docstring": "Remove persisted credentials from the local filesystem.\n\nNotes:\n **Lifecycle:**\n\n - This method deletes the credential file if it exists and should be treated as an idempotent operation"
}
}
}
}
},
"redis": {
"name": "redis",
"kind": "module",
"path": "mail_intake.credentials.redis",
"signature": null,
"docstring": "# Summary\n\nRedis-backed credential persistence for Mail Intake.\n\nThis module provides a Redis-based implementation of the\n`CredentialStore` abstraction, enabling credential persistence\nacross distributed and horizontally scaled deployments.\n\nThe Redis credential store is designed for environments where\nauthentication credentials must be shared safely across multiple\nprocesses, containers, or nodes, such as container orchestration\nplatforms and microservice architectures.\n\nKey characteristics:\n\n- Distributed-safe, shared storage using Redis.\n- Explicit, caller-defined serialization and deserialization.\n- No reliance on unsafe mechanisms such as `pickle`.\n- Optional time-to-live (TTL) support for automatic credential expiry.\n\nThis module is responsible solely for persistence concerns.\nCredential validation, refresh, rotation, and acquisition remain the\nresponsibility of authentication provider implementations.",
"members": {
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.credentials.redis.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mail_intake.credentials.redis.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"Callable": {
"name": "Callable",
"kind": "alias",
"path": "mail_intake.credentials.redis.Callable",
"signature": "<bound method Alias.signature of Alias('Callable', 'typing.Callable')>",
"docstring": null
},
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.credentials.redis.CredentialStore",
"signature": "<bound method Alias.signature of Alias('CredentialStore', 'mail_intake.credentials.store.CredentialStore')>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.redis.CredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.store.CredentialStore.load')>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.redis.CredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.store.CredentialStore.save')>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.redis.CredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.store.CredentialStore.clear')>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
},
"T": {
"name": "T",
"kind": "attribute",
"path": "mail_intake.credentials.redis.T",
"signature": null,
"docstring": null
},
"RedisCredentialStore": {
"name": "RedisCredentialStore",
"kind": "class",
"path": "mail_intake.credentials.redis.RedisCredentialStore",
"signature": "<bound method Class.signature of Class('RedisCredentialStore', 35, 148)>",
"docstring": "Redis-backed implementation of `CredentialStore`.\n\nThis store persists credentials in Redis and is suitable for\ndistributed and horizontally scaled deployments where credentials\nmust be shared across multiple processes or nodes.\n\nNotes:\n **Responsibilities:**\n\n - This class is responsible only for persistence and retrieval.\n - It does not interpret, validate, refresh, or otherwise manage the\n lifecycle of the credentials being stored.\n\n **Guarantees:**\n\n - The store is intentionally generic and delegates all serialization\n concerns to caller-provided functions.\n - This avoids unsafe mechanisms such as `pickle` and allows\n credential formats to be explicitly controlled and audited.",
"members": {
"redis": {
"name": "redis",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.redis",
"signature": null,
"docstring": null
},
"key": {
"name": "key",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.key",
"signature": null,
"docstring": null
},
"serialize": {
"name": "serialize",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.serialize",
"signature": null,
"docstring": null
},
"deserialize": {
"name": "deserialize",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.deserialize",
"signature": null,
"docstring": null
},
"ttl_seconds": {
"name": "ttl_seconds",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.ttl_seconds",
"signature": null,
"docstring": null
},
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.redis.RedisCredentialStore.load",
"signature": "<bound method Function.signature of Function('load', 91, 116)>",
"docstring": "Load credentials from Redis.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If no value exists for the configured key, or if the stored\n payload cannot be successfully deserialized, this method\n returns `None`.\n - The store does not attempt to validate the returned\n credentials or determine whether they are expired or\n otherwise usable."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.redis.RedisCredentialStore.save",
"signature": "<bound method Function.signature of Function('save', 118, 136)>",
"docstring": "Persist credentials to Redis.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials under the same key are overwritten\n - If a TTL is configured, the credentials will expire automatically after the specified duration"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.redis.RedisCredentialStore.clear",
"signature": "<bound method Function.signature of Function('clear', 138, 148)>",
"docstring": "Remove stored credentials from Redis.\n\nNotes:\n **Lifecycle:**\n\n - This operation deletes the configured Redis key if it exists\n - Implementations should treat this method as idempotent"
}
}
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.credentials.redis.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
}
}
},
"store": {
"name": "store",
"kind": "module",
"path": "mail_intake.credentials.store",
"signature": null,
"docstring": "# Summary\n\nCredential persistence abstractions for Mail Intake.\n\nThis module defines the generic persistence contract used to store and\nretrieve authentication credentials across Mail Intake components.\n\nThe `CredentialStore` abstraction establishes a strict separation\nbetween credential *lifecycle management* and credential *storage*.\nAuthentication providers are responsible for acquiring, validating,\nrefreshing, and revoking credentials, while concrete store\nimplementations are responsible solely for persistence concerns.\n\nBy remaining agnostic to credential structure, serialization format,\nand storage backend, this module enables multiple persistence\nstrategies—such as local files, in-memory caches, distributed stores,\nor secrets managers—without coupling authentication logic to any\nspecific storage mechanism.",
"members": {
"ABC": {
"name": "ABC",
"kind": "alias",
"path": "mail_intake.credentials.store.ABC",
"signature": "<bound method Alias.signature of Alias('ABC', 'abc.ABC')>",
"docstring": null
},
"abstractmethod": {
"name": "abstractmethod",
"kind": "alias",
"path": "mail_intake.credentials.store.abstractmethod",
"signature": "<bound method Alias.signature of Alias('abstractmethod', 'abc.abstractmethod')>",
"docstring": null
},
"Generic": {
"name": "Generic",
"kind": "alias",
"path": "mail_intake.credentials.store.Generic",
"signature": "<bound method Alias.signature of Alias('Generic', 'typing.Generic')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.credentials.store.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mail_intake.credentials.store.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"T": {
"name": "T",
"kind": "attribute",
"path": "mail_intake.credentials.store.T",
"signature": null,
"docstring": null
},
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.credentials.store.CredentialStore",
"signature": "<bound method Class.signature of Class('CredentialStore', 29, 105)>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.store.CredentialStore.load",
"signature": "<bound method Function.signature of Function('load', 50, 68)>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.store.CredentialStore.save",
"signature": "<bound method Function.signature of Function('save', 70, 89)>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.store.CredentialStore.clear",
"signature": "<bound method Function.signature of Function('clear', 91, 105)>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,104 @@
{
"module": "mail_intake.credentials.pickle",
"content": {
"path": "mail_intake.credentials.pickle",
"docstring": "# Summary\n\nLocal filesystembased credential persistence for Mail Intake.\n\nThis module provides a file-backed implementation of the\n`CredentialStore` abstraction using Python's `pickle` module.\n\nThe `pickle`-based credential store is intended for local development,\nsingle-node deployments, and controlled environments where credentials\ndo not need to be shared across processes or machines.\n\nDue to the security and portability risks associated with `pickle`-based\nserialization, this implementation is not suitable for distributed or\nuntrusted environments.",
"objects": {
"pickle": {
"name": "pickle",
"kind": "alias",
"path": "mail_intake.credentials.pickle.pickle",
"signature": "<bound method Alias.signature of Alias('pickle', 'pickle')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.credentials.pickle.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mail_intake.credentials.pickle.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.credentials.pickle.CredentialStore",
"signature": "<bound method Alias.signature of Alias('CredentialStore', 'mail_intake.credentials.store.CredentialStore')>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.pickle.CredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.store.CredentialStore.load')>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.pickle.CredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.store.CredentialStore.save')>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.pickle.CredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.store.CredentialStore.clear')>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
},
"T": {
"name": "T",
"kind": "attribute",
"path": "mail_intake.credentials.pickle.T",
"signature": null,
"docstring": null
},
"PickleCredentialStore": {
"name": "PickleCredentialStore",
"kind": "class",
"path": "mail_intake.credentials.pickle.PickleCredentialStore",
"signature": "<bound method Class.signature of Class('PickleCredentialStore', 26, 109)>",
"docstring": "Filesystem-backed credential store using pickle serialization.\n\nThis store persists credentials as a pickled object on the local\nfilesystem. It is a simple implementation intended primarily for\ndevelopment, testing, and single-process execution contexts.\n\nNotes:\n **Guarantees:**\n\n - Stores credentials on the local filesystem.\n - Uses `pickle` for serialization and deserialization.\n - Does not provide encryption, locking, or concurrency guarantees.\n\n **Constraints:**\n\n - Credential lifecycle management, validation, and refresh logic are\n explicitly out of scope for this class.",
"members": {
"path": {
"name": "path",
"kind": "attribute",
"path": "mail_intake.credentials.pickle.PickleCredentialStore.path",
"signature": null,
"docstring": null
},
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.pickle.PickleCredentialStore.load",
"signature": "<bound method Function.signature of Function('load', 58, 79)>",
"docstring": "Load credentials from the local filesystem.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If the credential file does not exist or cannot be successfully\n deserialized, this method returns `None`.\n - The store does not attempt to validate or interpret the\n returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.pickle.PickleCredentialStore.save",
"signature": "<bound method Function.signature of Function('save', 81, 95)>",
"docstring": "Persist credentials to the local filesystem.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials at the configured path are overwritten"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.pickle.PickleCredentialStore.clear",
"signature": "<bound method Function.signature of Function('clear', 97, 109)>",
"docstring": "Remove persisted credentials from the local filesystem.\n\nNotes:\n **Lifecycle:**\n\n - This method deletes the credential file if it exists and should be treated as an idempotent operation"
}
}
}
}
}
}

View File

@@ -0,0 +1,139 @@
{
"module": "mail_intake.credentials.redis",
"content": {
"path": "mail_intake.credentials.redis",
"docstring": "# Summary\n\nRedis-backed credential persistence for Mail Intake.\n\nThis module provides a Redis-based implementation of the\n`CredentialStore` abstraction, enabling credential persistence\nacross distributed and horizontally scaled deployments.\n\nThe Redis credential store is designed for environments where\nauthentication credentials must be shared safely across multiple\nprocesses, containers, or nodes, such as container orchestration\nplatforms and microservice architectures.\n\nKey characteristics:\n\n- Distributed-safe, shared storage using Redis.\n- Explicit, caller-defined serialization and deserialization.\n- No reliance on unsafe mechanisms such as `pickle`.\n- Optional time-to-live (TTL) support for automatic credential expiry.\n\nThis module is responsible solely for persistence concerns.\nCredential validation, refresh, rotation, and acquisition remain the\nresponsibility of authentication provider implementations.",
"objects": {
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.credentials.redis.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mail_intake.credentials.redis.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"Callable": {
"name": "Callable",
"kind": "alias",
"path": "mail_intake.credentials.redis.Callable",
"signature": "<bound method Alias.signature of Alias('Callable', 'typing.Callable')>",
"docstring": null
},
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.credentials.redis.CredentialStore",
"signature": "<bound method Alias.signature of Alias('CredentialStore', 'mail_intake.credentials.store.CredentialStore')>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.redis.CredentialStore.load",
"signature": "<bound method Alias.signature of Alias('load', 'mail_intake.credentials.store.CredentialStore.load')>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.redis.CredentialStore.save",
"signature": "<bound method Alias.signature of Alias('save', 'mail_intake.credentials.store.CredentialStore.save')>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.redis.CredentialStore.clear",
"signature": "<bound method Alias.signature of Alias('clear', 'mail_intake.credentials.store.CredentialStore.clear')>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
},
"T": {
"name": "T",
"kind": "attribute",
"path": "mail_intake.credentials.redis.T",
"signature": null,
"docstring": null
},
"RedisCredentialStore": {
"name": "RedisCredentialStore",
"kind": "class",
"path": "mail_intake.credentials.redis.RedisCredentialStore",
"signature": "<bound method Class.signature of Class('RedisCredentialStore', 35, 148)>",
"docstring": "Redis-backed implementation of `CredentialStore`.\n\nThis store persists credentials in Redis and is suitable for\ndistributed and horizontally scaled deployments where credentials\nmust be shared across multiple processes or nodes.\n\nNotes:\n **Responsibilities:**\n\n - This class is responsible only for persistence and retrieval.\n - It does not interpret, validate, refresh, or otherwise manage the\n lifecycle of the credentials being stored.\n\n **Guarantees:**\n\n - The store is intentionally generic and delegates all serialization\n concerns to caller-provided functions.\n - This avoids unsafe mechanisms such as `pickle` and allows\n credential formats to be explicitly controlled and audited.",
"members": {
"redis": {
"name": "redis",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.redis",
"signature": null,
"docstring": null
},
"key": {
"name": "key",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.key",
"signature": null,
"docstring": null
},
"serialize": {
"name": "serialize",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.serialize",
"signature": null,
"docstring": null
},
"deserialize": {
"name": "deserialize",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.deserialize",
"signature": null,
"docstring": null
},
"ttl_seconds": {
"name": "ttl_seconds",
"kind": "attribute",
"path": "mail_intake.credentials.redis.RedisCredentialStore.ttl_seconds",
"signature": null,
"docstring": null
},
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.redis.RedisCredentialStore.load",
"signature": "<bound method Function.signature of Function('load', 91, 116)>",
"docstring": "Load credentials from Redis.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If no value exists for the configured key, or if the stored\n payload cannot be successfully deserialized, this method\n returns `None`.\n - The store does not attempt to validate the returned\n credentials or determine whether they are expired or\n otherwise usable."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.redis.RedisCredentialStore.save",
"signature": "<bound method Function.signature of Function('save', 118, 136)>",
"docstring": "Persist credentials to Redis.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials under the same key are overwritten\n - If a TTL is configured, the credentials will expire automatically after the specified duration"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.redis.RedisCredentialStore.clear",
"signature": "<bound method Function.signature of Function('clear', 138, 148)>",
"docstring": "Remove stored credentials from Redis.\n\nNotes:\n **Lifecycle:**\n\n - This operation deletes the configured Redis key if it exists\n - Implementations should treat this method as idempotent"
}
}
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.credentials.redis.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
}
}
}
}

View File

@@ -0,0 +1,81 @@
{
"module": "mail_intake.credentials.store",
"content": {
"path": "mail_intake.credentials.store",
"docstring": "# Summary\n\nCredential persistence abstractions for Mail Intake.\n\nThis module defines the generic persistence contract used to store and\nretrieve authentication credentials across Mail Intake components.\n\nThe `CredentialStore` abstraction establishes a strict separation\nbetween credential *lifecycle management* and credential *storage*.\nAuthentication providers are responsible for acquiring, validating,\nrefreshing, and revoking credentials, while concrete store\nimplementations are responsible solely for persistence concerns.\n\nBy remaining agnostic to credential structure, serialization format,\nand storage backend, this module enables multiple persistence\nstrategies—such as local files, in-memory caches, distributed stores,\nor secrets managers—without coupling authentication logic to any\nspecific storage mechanism.",
"objects": {
"ABC": {
"name": "ABC",
"kind": "alias",
"path": "mail_intake.credentials.store.ABC",
"signature": "<bound method Alias.signature of Alias('ABC', 'abc.ABC')>",
"docstring": null
},
"abstractmethod": {
"name": "abstractmethod",
"kind": "alias",
"path": "mail_intake.credentials.store.abstractmethod",
"signature": "<bound method Alias.signature of Alias('abstractmethod', 'abc.abstractmethod')>",
"docstring": null
},
"Generic": {
"name": "Generic",
"kind": "alias",
"path": "mail_intake.credentials.store.Generic",
"signature": "<bound method Alias.signature of Alias('Generic', 'typing.Generic')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.credentials.store.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mail_intake.credentials.store.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"T": {
"name": "T",
"kind": "attribute",
"path": "mail_intake.credentials.store.T",
"signature": null,
"docstring": null
},
"CredentialStore": {
"name": "CredentialStore",
"kind": "class",
"path": "mail_intake.credentials.store.CredentialStore",
"signature": "<bound method Class.signature of Class('CredentialStore', 29, 105)>",
"docstring": "Abstract base class defining a generic persistence interface.\n\nUsed for authentication credentials across different backends.\n\nNotes:\n **Responsibilities:**\n\n - Provide persistent storage separating life-cycle management from\n storage mechanics.\n - Keep implementation focused only on persistence.\n\n **Constraints:**\n\n - The store is intentionally agnostic to:\n - The concrete credential type being stored.\n - The serialization format used to persist credentials.\n - The underlying storage backend or durability guarantees.",
"members": {
"load": {
"name": "load",
"kind": "function",
"path": "mail_intake.credentials.store.CredentialStore.load",
"signature": "<bound method Function.signature of Function('load', 50, 68)>",
"docstring": "Load previously persisted credentials.\n\nReturns:\n Optional[T]:\n An instance of type `T` if credentials are available and\n loadable; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - Implementations should return `None` when no credentials are\n present or when stored credentials cannot be successfully\n decoded or deserialized.\n - The store must not attempt to validate, refresh, or otherwise\n interpret the returned credentials."
},
"save": {
"name": "save",
"kind": "function",
"path": "mail_intake.credentials.store.CredentialStore.save",
"signature": "<bound method Function.signature of Function('save', 70, 89)>",
"docstring": "Persist credentials to the underlying storage backend.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Lifecycle:**\n\n - This method is invoked when credentials are newly obtained or have been refreshed and are known to be valid at the time of persistence\n\n **Responsibilities:**\n\n - Ensuring durability appropriate to the deployment context\n - Applying encryption or access controls where required\n - Overwriting any previously stored credentials"
},
"clear": {
"name": "clear",
"kind": "function",
"path": "mail_intake.credentials.store.CredentialStore.clear",
"signature": "<bound method Function.signature of Function('clear', 91, 105)>",
"docstring": "Remove any persisted credentials from the store.\n\nNotes:\n **Lifecycle:**\n\n - This method is called when credentials are known to be invalid, revoked, corrupted, or otherwise unusable\n - Must ensure that no stale authentication material remains accessible\n\n **Guarantees:**\n\n - Implementations should treat this operation as idempotent"
}
}
}
}
}
}

View File

@@ -0,0 +1,37 @@
{
"module": "mail_intake.exceptions",
"content": {
"path": "mail_intake.exceptions",
"docstring": "Exception hierarchy for Mail Intake.\n\n---\n\n## Summary\n\nThis module defines the **canonical exception types** used throughout the\nMail Intake library.\n\nAll library-raised errors derive from `MailIntakeError`. Consumers are\nencouraged to catch this base type (or specific subclasses) rather than\nprovider-specific or third-party exceptions.",
"objects": {
"MailIntakeError": {
"name": "MailIntakeError",
"kind": "class",
"path": "mail_intake.exceptions.MailIntakeError",
"signature": "<bound method Class.signature of Class('MailIntakeError', 17, 27)>",
"docstring": "Base exception for all Mail Intake errors.\n\nNotes:\n **Guarantees:**\n\n - This is the root of the Mail Intake exception hierarchy\n - All errors raised by the library must derive from this class\n - Consumers should generally catch this type when handling library-level failures"
},
"MailIntakeAuthError": {
"name": "MailIntakeAuthError",
"kind": "class",
"path": "mail_intake.exceptions.MailIntakeAuthError",
"signature": "<bound method Class.signature of Class('MailIntakeAuthError', 30, 39)>",
"docstring": "Authentication and credential-related failures.\n\nNotes:\n **Lifecycle:**\n\n - Raised when authentication providers are unable to acquire,\n refresh, or persist valid credentials."
},
"MailIntakeAdapterError": {
"name": "MailIntakeAdapterError",
"kind": "class",
"path": "mail_intake.exceptions.MailIntakeAdapterError",
"signature": "<bound method Class.signature of Class('MailIntakeAdapterError', 42, 51)>",
"docstring": "Errors raised by mail provider adapters.\n\nNotes:\n **Lifecycle:**\n\n - Raised when a provider adapter encounters API errors, transport\n failures, or invalid provider responses."
},
"MailIntakeParsingError": {
"name": "MailIntakeParsingError",
"kind": "class",
"path": "mail_intake.exceptions.MailIntakeParsingError",
"signature": "<bound method Class.signature of Class('MailIntakeParsingError', 54, 63)>",
"docstring": "Errors encountered while parsing message content.\n\nNotes:\n **Lifecycle:**\n\n - Raised when raw provider payloads cannot be interpreted or\n normalized into internal domain models."
}
}
}
}

View File

@@ -0,0 +1,280 @@
{
"module": "mail_intake.ingestion",
"content": {
"path": "mail_intake.ingestion",
"docstring": "# Summary\n\nMail ingestion orchestration for Mail Intake.\n\nThis package contains **high-level ingestion components** responsible for\ncoordinating mail retrieval, parsing, normalization, and model construction.\n\nIt represents the **top of the ingestion pipeline** and is intended to be the\nprimary interaction surface for library consumers.\n\nComponents in this package:\n\n- Are provider-agnostic.\n- Depend only on adapter and parser contracts.\n- Contain no provider-specific API logic.\n- Expose read-only ingestion workflows.\n\nConsumers are expected to construct a mail adapter and pass it to the\ningestion layer to begin processing messages and threads.\n\n---\n\n# Public API\n\n- `MailIntakeReader`\n\n---",
"objects": {
"MailIntakeReader": {
"name": "MailIntakeReader",
"kind": "class",
"path": "mail_intake.ingestion.MailIntakeReader",
"signature": "<bound method Alias.signature of Alias('MailIntakeReader', 'mail_intake.ingestion.reader.MailIntakeReader')>",
"docstring": "High-level read-only ingestion interface.\n\nNotes:\n **Responsibilities:**\n\n - This class is the primary entry point for consumers of the\n Mail Intake library.\n - It orchestrates the full ingestion pipeline:\n - Querying the adapter for message references.\n - Fetching raw provider messages.\n - Parsing and normalizing message data.\n - Constructing domain models.\n\n **Constraints:**\n\n - This class is intentionally: Provider-agnostic, stateless beyond\n iteration scope, read-only.",
"members": {
"iter_messages": {
"name": "iter_messages",
"kind": "function",
"path": "mail_intake.ingestion.MailIntakeReader.iter_messages",
"signature": "<bound method Alias.signature of Alias('iter_messages', 'mail_intake.ingestion.reader.MailIntakeReader.iter_messages')>",
"docstring": "Iterate over parsed messages matching a provider query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n MailIntakeMessage:\n Fully parsed and normalized `MailIntakeMessage` instances.\n\nRaises:\n MailIntakeParsingError:\n If a message cannot be parsed."
},
"iter_threads": {
"name": "iter_threads",
"kind": "function",
"path": "mail_intake.ingestion.MailIntakeReader.iter_threads",
"signature": "<bound method Alias.signature of Alias('iter_threads', 'mail_intake.ingestion.reader.MailIntakeReader.iter_threads')>",
"docstring": "Iterate over threads constructed from messages matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n MailIntakeThread:\n An iterator of `MailIntakeThread` instances.\n\nRaises:\n `MailIntakeParsingError`:\n If a message cannot be parsed.\n\nNotes:\n **Guarantees:**\n\n - Messages are grouped by `thread_id` and yielded as complete\n thread objects containing all associated messages."
}
}
},
"reader": {
"name": "reader",
"kind": "module",
"path": "mail_intake.ingestion.reader",
"signature": null,
"docstring": "# Summary\n\nHigh-level mail ingestion orchestration for Mail Intake.\n\nThis module provides the primary, provider-agnostic entry point for\nreading and processing mail data.\n\nIt coordinates:\n\n- Mail adapter access.\n- Message and thread iteration.\n- Header and body parsing.\n- Normalization and model construction.\n\nNo provider-specific logic or API semantics are permitted in this layer.",
"members": {
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mail_intake.ingestion.reader.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"Iterator": {
"name": "Iterator",
"kind": "alias",
"path": "mail_intake.ingestion.reader.Iterator",
"signature": "<bound method Alias.signature of Alias('Iterator', 'typing.Iterator')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.ingestion.reader.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.ingestion.reader.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"MailIntakeAdapter": {
"name": "MailIntakeAdapter",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeAdapter",
"signature": "<bound method Alias.signature of Alias('MailIntakeAdapter', 'mail_intake.adapters.base.MailIntakeAdapter')>",
"docstring": "Base adapter interface for mail providers.\n\nNotes:\n **Guarantees:**\n\n - Discover messages matching a query.\n - Retrieve full message payloads.\n - Retrieve full thread payloads.\n\n **Lifecycle:**\n\n - Adapters are intentionally read-only and must not mutate provider state.",
"members": {
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeAdapter.iter_message_refs",
"signature": "<bound method Alias.signature of Alias('iter_message_refs', 'mail_intake.adapters.base.MailIntakeAdapter.iter_message_refs')>",
"docstring": "Iterate over lightweight message references matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n Dict[str, str]:\n Dictionaries containing message and thread identifiers.\n\nNotes:\n **Guarantees:**\n\n - Implementations must yield dictionaries containing at least\n `message_id` and `thread_id`.\n\nExample:\n Typical yield:\n\n ```python\n {\n \"message_id\": \"...\",\n \"thread_id\": \"...\"\n }\n ```"
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeAdapter.fetch_message",
"signature": "<bound method Alias.signature of Alias('fetch_message', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_message')>",
"docstring": "Fetch a full raw message by message identifier.\n\nArgs:\n message_id (str):\n Provider-specific message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native message payload (e.g., Gmail message JSON structure)."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeAdapter.fetch_thread",
"signature": "<bound method Alias.signature of Alias('fetch_thread', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_thread')>",
"docstring": "Fetch a full raw thread by thread identifier.\n\nArgs:\n thread_id (str):\n Provider-specific thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native thread payload."
}
}
},
"MailIntakeMessage": {
"name": "MailIntakeMessage",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeMessage",
"signature": "<bound method Alias.signature of Alias('MailIntakeMessage', 'mail_intake.models.message.MailIntakeMessage')>",
"docstring": "Canonical internal representation of a single email message.\n\nNotes:\n **Guarantees:**\n\n - This model represents a fully parsed and normalized email message.\n - It is intentionally provider-agnostic and suitable for\n persistence, indexing, and downstream processing.\n\n **Constraints:**\n\n - No provider-specific identifiers, payloads, or API semantics\n should appear in this model.",
"members": {
"message_id": {
"name": "message_id",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.message_id",
"signature": "<bound method Alias.signature of Alias('message_id', 'mail_intake.models.message.MailIntakeMessage.message_id')>",
"docstring": "Provider-specific message identifier."
},
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.thread_id",
"signature": "<bound method Alias.signature of Alias('thread_id', 'mail_intake.models.message.MailIntakeMessage.thread_id')>",
"docstring": "Provider-specific thread identifier to which this message belongs."
},
"timestamp": {
"name": "timestamp",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.timestamp",
"signature": "<bound method Alias.signature of Alias('timestamp', 'mail_intake.models.message.MailIntakeMessage.timestamp')>",
"docstring": "Message timestamp as a timezone-naive UTC datetime."
},
"from_email": {
"name": "from_email",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.from_email",
"signature": "<bound method Alias.signature of Alias('from_email', 'mail_intake.models.message.MailIntakeMessage.from_email')>",
"docstring": "Sender email address."
},
"from_name": {
"name": "from_name",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.from_name",
"signature": "<bound method Alias.signature of Alias('from_name', 'mail_intake.models.message.MailIntakeMessage.from_name')>",
"docstring": "Optional human-readable sender name."
},
"subject": {
"name": "subject",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.subject",
"signature": "<bound method Alias.signature of Alias('subject', 'mail_intake.models.message.MailIntakeMessage.subject')>",
"docstring": "Raw subject line of the message."
},
"body_text": {
"name": "body_text",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.body_text",
"signature": "<bound method Alias.signature of Alias('body_text', 'mail_intake.models.message.MailIntakeMessage.body_text')>",
"docstring": "Extracted plain-text body content of the message."
},
"snippet": {
"name": "snippet",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.snippet",
"signature": "<bound method Alias.signature of Alias('snippet', 'mail_intake.models.message.MailIntakeMessage.snippet')>",
"docstring": "Short provider-supplied preview snippet of the message."
},
"raw_headers": {
"name": "raw_headers",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.raw_headers",
"signature": "<bound method Alias.signature of Alias('raw_headers', 'mail_intake.models.message.MailIntakeMessage.raw_headers')>",
"docstring": "Normalized mapping of message headers (header name → value)."
}
}
},
"MailIntakeThread": {
"name": "MailIntakeThread",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeThread",
"signature": "<bound method Alias.signature of Alias('MailIntakeThread', 'mail_intake.models.thread.MailIntakeThread')>",
"docstring": "Canonical internal representation of an email thread.\n\nNotes:\n **Guarantees:**\n\n - A thread groups multiple related messages under a single subject\n and participant set.\n - It is designed to support reasoning over conversational context\n such as job applications, interviews, follow-ups, and ongoing discussions.\n - This model is provider-agnostic and safe to persist.",
"members": {
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.thread_id",
"signature": "<bound method Alias.signature of Alias('thread_id', 'mail_intake.models.thread.MailIntakeThread.thread_id')>",
"docstring": "Provider-specific thread identifier."
},
"normalized_subject": {
"name": "normalized_subject",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.normalized_subject",
"signature": "<bound method Alias.signature of Alias('normalized_subject', 'mail_intake.models.thread.MailIntakeThread.normalized_subject')>",
"docstring": "Normalized subject line used to group related messages."
},
"participants": {
"name": "participants",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.participants",
"signature": "<bound method Alias.signature of Alias('participants', 'mail_intake.models.thread.MailIntakeThread.participants')>",
"docstring": "Set of unique participant email addresses observed in the thread."
},
"messages": {
"name": "messages",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.messages",
"signature": "<bound method Alias.signature of Alias('messages', 'mail_intake.models.thread.MailIntakeThread.messages')>",
"docstring": "Ordered list of messages belonging to this thread."
},
"last_activity_at": {
"name": "last_activity_at",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.last_activity_at",
"signature": "<bound method Alias.signature of Alias('last_activity_at', 'mail_intake.models.thread.MailIntakeThread.last_activity_at')>",
"docstring": "Timestamp of the most recent message in the thread."
},
"add_message": {
"name": "add_message",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeThread.add_message",
"signature": "<bound method Alias.signature of Alias('add_message', 'mail_intake.models.thread.MailIntakeThread.add_message')>",
"docstring": "Add a message to the thread and update derived fields.\n\nArgs:\n message (MailIntakeMessage):\n Parsed mail message to add to the thread.\n\nNotes:\n **Responsibilities:**\n\n - Appends the message to the thread.\n - Tracks unique participants.\n - Updates the last activity timestamp."
}
}
},
"parse_headers": {
"name": "parse_headers",
"kind": "function",
"path": "mail_intake.ingestion.reader.parse_headers",
"signature": "<bound method Alias.signature of Alias('parse_headers', 'mail_intake.parsers.headers.parse_headers')>",
"docstring": "Convert a list of Gmail-style headers into a normalized dict.\n\nArgs:\n raw_headers (List[Dict[str, str]]):\n List of header dictionaries, each containing `name` and `value` keys.\n\nReturns:\n Dict[str, str]:\n Dictionary mapping lowercase header names to stripped values.\n\nNotes:\n **Guarantees:**\n\n - Provider payloads (such as Gmail) typically represent headers as a\n list of name/value mappings.\n - This function normalizes them into a case-insensitive dictionary\n keyed by lowercase header names.\n\nExample:\n Typical usage:\n\n ```python\n Input:\n [\n {\"name\": \"From\", \"value\": \"John Doe <john@example.com>\"},\n {\"name\": \"Subject\", \"value\": \"Re: Interview Update\"},\n ]\n\n Output:\n {\n \"from\": \"John Doe <john@example.com>\",\n \"subject\": \"Re: Interview Update\",\n }\n ```"
},
"extract_sender": {
"name": "extract_sender",
"kind": "function",
"path": "mail_intake.ingestion.reader.extract_sender",
"signature": "<bound method Alias.signature of Alias('extract_sender', 'mail_intake.parsers.headers.extract_sender')>",
"docstring": "Extract sender email and optional display name from headers.\n\nArgs:\n headers (Dict[str, str]):\n Normalized header dictionary as returned by `parse_headers()`.\n\nReturns:\n Tuple[str, Optional[str]]:\n A tuple `(email, name)` where `email` is the sender email address\n and `name` is the display name, or `None` if unavailable.\n\nNotes:\n **Responsibilities:**\n\n - This function parses the `From` header and attempts to extract\n sender email address and optional human-readable display name.\n\nExample:\n Typical values:\n\n - `\"John Doe <john@example.com>\"` -> `(\"john@example.com\", \"John Doe\")`\n - `\"john@example.com\"` -> `(\"john@example.com\", None)`"
},
"extract_body": {
"name": "extract_body",
"kind": "function",
"path": "mail_intake.ingestion.reader.extract_body",
"signature": "<bound method Alias.signature of Alias('extract_body', 'mail_intake.parsers.body.extract_body')>",
"docstring": "Extract the best-effort message body from a Gmail payload.\n\nPriority:\n\n1. `text/plain`\n2. `text/html` (stripped to text)\n3. Single-part body\n4. Empty string (if nothing usable found)\n\nArgs:\n payload (Dict[str, Any]):\n Provider-native message payload dictionary.\n\nReturns:\n str:\n Extracted plain-text message body."
},
"normalize_subject": {
"name": "normalize_subject",
"kind": "function",
"path": "mail_intake.ingestion.reader.normalize_subject",
"signature": "<bound method Alias.signature of Alias('normalize_subject', 'mail_intake.parsers.subject.normalize_subject')>",
"docstring": "Normalize an email subject for thread-level comparison.\n\nArgs:\n subject (str):\n Raw subject line from a message header.\n\nReturns:\n str:\n Normalized subject string suitable for thread grouping.\n\nNotes:\n **Responsibilities:**\n\n - Strips common prefixes such as `Re:`, `Fwd:`, and `FW:`.\n - Repeats prefix stripping to handle stacked prefixes.\n - Collapses excessive whitespace.\n - Preserves original casing (no lowercasing).\n\n **Guarantees:**\n\n - This function is intentionally conservative and avoids aggressive\n transformations that could alter the semantic meaning of the subject."
},
"MailIntakeParsingError": {
"name": "MailIntakeParsingError",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeParsingError",
"signature": "<bound method Alias.signature of Alias('MailIntakeParsingError', 'mail_intake.exceptions.MailIntakeParsingError')>",
"docstring": "Errors encountered while parsing message content.\n\nNotes:\n **Lifecycle:**\n\n - Raised when raw provider payloads cannot be interpreted or\n normalized into internal domain models."
},
"MailIntakeReader": {
"name": "MailIntakeReader",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeReader",
"signature": "<bound method Class.signature of Class('MailIntakeReader', 31, 171)>",
"docstring": "High-level read-only ingestion interface.\n\nNotes:\n **Responsibilities:**\n\n - This class is the primary entry point for consumers of the\n Mail Intake library.\n - It orchestrates the full ingestion pipeline:\n - Querying the adapter for message references.\n - Fetching raw provider messages.\n - Parsing and normalizing message data.\n - Constructing domain models.\n\n **Constraints:**\n\n - This class is intentionally: Provider-agnostic, stateless beyond\n iteration scope, read-only.",
"members": {
"iter_messages": {
"name": "iter_messages",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeReader.iter_messages",
"signature": "<bound method Function.signature of Function('iter_messages', 62, 80)>",
"docstring": "Iterate over parsed messages matching a provider query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n MailIntakeMessage:\n Fully parsed and normalized `MailIntakeMessage` instances.\n\nRaises:\n MailIntakeParsingError:\n If a message cannot be parsed."
},
"iter_threads": {
"name": "iter_threads",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeReader.iter_threads",
"signature": "<bound method Function.signature of Function('iter_threads', 82, 120)>",
"docstring": "Iterate over threads constructed from messages matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n MailIntakeThread:\n An iterator of `MailIntakeThread` instances.\n\nRaises:\n `MailIntakeParsingError`:\n If a message cannot be parsed.\n\nNotes:\n **Guarantees:**\n\n - Messages are grouped by `thread_id` and yielded as complete\n thread objects containing all associated messages."
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,248 @@
{
"module": "mail_intake.ingestion.reader",
"content": {
"path": "mail_intake.ingestion.reader",
"docstring": "# Summary\n\nHigh-level mail ingestion orchestration for Mail Intake.\n\nThis module provides the primary, provider-agnostic entry point for\nreading and processing mail data.\n\nIt coordinates:\n\n- Mail adapter access.\n- Message and thread iteration.\n- Header and body parsing.\n- Normalization and model construction.\n\nNo provider-specific logic or API semantics are permitted in this layer.",
"objects": {
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mail_intake.ingestion.reader.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"Iterator": {
"name": "Iterator",
"kind": "alias",
"path": "mail_intake.ingestion.reader.Iterator",
"signature": "<bound method Alias.signature of Alias('Iterator', 'typing.Iterator')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.ingestion.reader.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.ingestion.reader.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"MailIntakeAdapter": {
"name": "MailIntakeAdapter",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeAdapter",
"signature": "<bound method Alias.signature of Alias('MailIntakeAdapter', 'mail_intake.adapters.base.MailIntakeAdapter')>",
"docstring": "Base adapter interface for mail providers.\n\nNotes:\n **Guarantees:**\n\n - Discover messages matching a query.\n - Retrieve full message payloads.\n - Retrieve full thread payloads.\n\n **Lifecycle:**\n\n - Adapters are intentionally read-only and must not mutate provider state.",
"members": {
"iter_message_refs": {
"name": "iter_message_refs",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeAdapter.iter_message_refs",
"signature": "<bound method Alias.signature of Alias('iter_message_refs', 'mail_intake.adapters.base.MailIntakeAdapter.iter_message_refs')>",
"docstring": "Iterate over lightweight message references matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n Dict[str, str]:\n Dictionaries containing message and thread identifiers.\n\nNotes:\n **Guarantees:**\n\n - Implementations must yield dictionaries containing at least\n `message_id` and `thread_id`.\n\nExample:\n Typical yield:\n\n ```python\n {\n \"message_id\": \"...\",\n \"thread_id\": \"...\"\n }\n ```"
},
"fetch_message": {
"name": "fetch_message",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeAdapter.fetch_message",
"signature": "<bound method Alias.signature of Alias('fetch_message', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_message')>",
"docstring": "Fetch a full raw message by message identifier.\n\nArgs:\n message_id (str):\n Provider-specific message identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native message payload (e.g., Gmail message JSON structure)."
},
"fetch_thread": {
"name": "fetch_thread",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeAdapter.fetch_thread",
"signature": "<bound method Alias.signature of Alias('fetch_thread', 'mail_intake.adapters.base.MailIntakeAdapter.fetch_thread')>",
"docstring": "Fetch a full raw thread by thread identifier.\n\nArgs:\n thread_id (str):\n Provider-specific thread identifier.\n\nReturns:\n Dict[str, Any]:\n Provider-native thread payload."
}
}
},
"MailIntakeMessage": {
"name": "MailIntakeMessage",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeMessage",
"signature": "<bound method Alias.signature of Alias('MailIntakeMessage', 'mail_intake.models.message.MailIntakeMessage')>",
"docstring": "Canonical internal representation of a single email message.\n\nNotes:\n **Guarantees:**\n\n - This model represents a fully parsed and normalized email message.\n - It is intentionally provider-agnostic and suitable for\n persistence, indexing, and downstream processing.\n\n **Constraints:**\n\n - No provider-specific identifiers, payloads, or API semantics\n should appear in this model.",
"members": {
"message_id": {
"name": "message_id",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.message_id",
"signature": "<bound method Alias.signature of Alias('message_id', 'mail_intake.models.message.MailIntakeMessage.message_id')>",
"docstring": "Provider-specific message identifier."
},
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.thread_id",
"signature": "<bound method Alias.signature of Alias('thread_id', 'mail_intake.models.message.MailIntakeMessage.thread_id')>",
"docstring": "Provider-specific thread identifier to which this message belongs."
},
"timestamp": {
"name": "timestamp",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.timestamp",
"signature": "<bound method Alias.signature of Alias('timestamp', 'mail_intake.models.message.MailIntakeMessage.timestamp')>",
"docstring": "Message timestamp as a timezone-naive UTC datetime."
},
"from_email": {
"name": "from_email",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.from_email",
"signature": "<bound method Alias.signature of Alias('from_email', 'mail_intake.models.message.MailIntakeMessage.from_email')>",
"docstring": "Sender email address."
},
"from_name": {
"name": "from_name",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.from_name",
"signature": "<bound method Alias.signature of Alias('from_name', 'mail_intake.models.message.MailIntakeMessage.from_name')>",
"docstring": "Optional human-readable sender name."
},
"subject": {
"name": "subject",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.subject",
"signature": "<bound method Alias.signature of Alias('subject', 'mail_intake.models.message.MailIntakeMessage.subject')>",
"docstring": "Raw subject line of the message."
},
"body_text": {
"name": "body_text",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.body_text",
"signature": "<bound method Alias.signature of Alias('body_text', 'mail_intake.models.message.MailIntakeMessage.body_text')>",
"docstring": "Extracted plain-text body content of the message."
},
"snippet": {
"name": "snippet",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.snippet",
"signature": "<bound method Alias.signature of Alias('snippet', 'mail_intake.models.message.MailIntakeMessage.snippet')>",
"docstring": "Short provider-supplied preview snippet of the message."
},
"raw_headers": {
"name": "raw_headers",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeMessage.raw_headers",
"signature": "<bound method Alias.signature of Alias('raw_headers', 'mail_intake.models.message.MailIntakeMessage.raw_headers')>",
"docstring": "Normalized mapping of message headers (header name → value)."
}
}
},
"MailIntakeThread": {
"name": "MailIntakeThread",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeThread",
"signature": "<bound method Alias.signature of Alias('MailIntakeThread', 'mail_intake.models.thread.MailIntakeThread')>",
"docstring": "Canonical internal representation of an email thread.\n\nNotes:\n **Guarantees:**\n\n - A thread groups multiple related messages under a single subject\n and participant set.\n - It is designed to support reasoning over conversational context\n such as job applications, interviews, follow-ups, and ongoing discussions.\n - This model is provider-agnostic and safe to persist.",
"members": {
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.thread_id",
"signature": "<bound method Alias.signature of Alias('thread_id', 'mail_intake.models.thread.MailIntakeThread.thread_id')>",
"docstring": "Provider-specific thread identifier."
},
"normalized_subject": {
"name": "normalized_subject",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.normalized_subject",
"signature": "<bound method Alias.signature of Alias('normalized_subject', 'mail_intake.models.thread.MailIntakeThread.normalized_subject')>",
"docstring": "Normalized subject line used to group related messages."
},
"participants": {
"name": "participants",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.participants",
"signature": "<bound method Alias.signature of Alias('participants', 'mail_intake.models.thread.MailIntakeThread.participants')>",
"docstring": "Set of unique participant email addresses observed in the thread."
},
"messages": {
"name": "messages",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.messages",
"signature": "<bound method Alias.signature of Alias('messages', 'mail_intake.models.thread.MailIntakeThread.messages')>",
"docstring": "Ordered list of messages belonging to this thread."
},
"last_activity_at": {
"name": "last_activity_at",
"kind": "attribute",
"path": "mail_intake.ingestion.reader.MailIntakeThread.last_activity_at",
"signature": "<bound method Alias.signature of Alias('last_activity_at', 'mail_intake.models.thread.MailIntakeThread.last_activity_at')>",
"docstring": "Timestamp of the most recent message in the thread."
},
"add_message": {
"name": "add_message",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeThread.add_message",
"signature": "<bound method Alias.signature of Alias('add_message', 'mail_intake.models.thread.MailIntakeThread.add_message')>",
"docstring": "Add a message to the thread and update derived fields.\n\nArgs:\n message (MailIntakeMessage):\n Parsed mail message to add to the thread.\n\nNotes:\n **Responsibilities:**\n\n - Appends the message to the thread.\n - Tracks unique participants.\n - Updates the last activity timestamp."
}
}
},
"parse_headers": {
"name": "parse_headers",
"kind": "function",
"path": "mail_intake.ingestion.reader.parse_headers",
"signature": "<bound method Alias.signature of Alias('parse_headers', 'mail_intake.parsers.headers.parse_headers')>",
"docstring": "Convert a list of Gmail-style headers into a normalized dict.\n\nArgs:\n raw_headers (List[Dict[str, str]]):\n List of header dictionaries, each containing `name` and `value` keys.\n\nReturns:\n Dict[str, str]:\n Dictionary mapping lowercase header names to stripped values.\n\nNotes:\n **Guarantees:**\n\n - Provider payloads (such as Gmail) typically represent headers as a\n list of name/value mappings.\n - This function normalizes them into a case-insensitive dictionary\n keyed by lowercase header names.\n\nExample:\n Typical usage:\n\n ```python\n Input:\n [\n {\"name\": \"From\", \"value\": \"John Doe <john@example.com>\"},\n {\"name\": \"Subject\", \"value\": \"Re: Interview Update\"},\n ]\n\n Output:\n {\n \"from\": \"John Doe <john@example.com>\",\n \"subject\": \"Re: Interview Update\",\n }\n ```"
},
"extract_sender": {
"name": "extract_sender",
"kind": "function",
"path": "mail_intake.ingestion.reader.extract_sender",
"signature": "<bound method Alias.signature of Alias('extract_sender', 'mail_intake.parsers.headers.extract_sender')>",
"docstring": "Extract sender email and optional display name from headers.\n\nArgs:\n headers (Dict[str, str]):\n Normalized header dictionary as returned by `parse_headers()`.\n\nReturns:\n Tuple[str, Optional[str]]:\n A tuple `(email, name)` where `email` is the sender email address\n and `name` is the display name, or `None` if unavailable.\n\nNotes:\n **Responsibilities:**\n\n - This function parses the `From` header and attempts to extract\n sender email address and optional human-readable display name.\n\nExample:\n Typical values:\n\n - `\"John Doe <john@example.com>\"` -> `(\"john@example.com\", \"John Doe\")`\n - `\"john@example.com\"` -> `(\"john@example.com\", None)`"
},
"extract_body": {
"name": "extract_body",
"kind": "function",
"path": "mail_intake.ingestion.reader.extract_body",
"signature": "<bound method Alias.signature of Alias('extract_body', 'mail_intake.parsers.body.extract_body')>",
"docstring": "Extract the best-effort message body from a Gmail payload.\n\nPriority:\n\n1. `text/plain`\n2. `text/html` (stripped to text)\n3. Single-part body\n4. Empty string (if nothing usable found)\n\nArgs:\n payload (Dict[str, Any]):\n Provider-native message payload dictionary.\n\nReturns:\n str:\n Extracted plain-text message body."
},
"normalize_subject": {
"name": "normalize_subject",
"kind": "function",
"path": "mail_intake.ingestion.reader.normalize_subject",
"signature": "<bound method Alias.signature of Alias('normalize_subject', 'mail_intake.parsers.subject.normalize_subject')>",
"docstring": "Normalize an email subject for thread-level comparison.\n\nArgs:\n subject (str):\n Raw subject line from a message header.\n\nReturns:\n str:\n Normalized subject string suitable for thread grouping.\n\nNotes:\n **Responsibilities:**\n\n - Strips common prefixes such as `Re:`, `Fwd:`, and `FW:`.\n - Repeats prefix stripping to handle stacked prefixes.\n - Collapses excessive whitespace.\n - Preserves original casing (no lowercasing).\n\n **Guarantees:**\n\n - This function is intentionally conservative and avoids aggressive\n transformations that could alter the semantic meaning of the subject."
},
"MailIntakeParsingError": {
"name": "MailIntakeParsingError",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeParsingError",
"signature": "<bound method Alias.signature of Alias('MailIntakeParsingError', 'mail_intake.exceptions.MailIntakeParsingError')>",
"docstring": "Errors encountered while parsing message content.\n\nNotes:\n **Lifecycle:**\n\n - Raised when raw provider payloads cannot be interpreted or\n normalized into internal domain models."
},
"MailIntakeReader": {
"name": "MailIntakeReader",
"kind": "class",
"path": "mail_intake.ingestion.reader.MailIntakeReader",
"signature": "<bound method Class.signature of Class('MailIntakeReader', 31, 171)>",
"docstring": "High-level read-only ingestion interface.\n\nNotes:\n **Responsibilities:**\n\n - This class is the primary entry point for consumers of the\n Mail Intake library.\n - It orchestrates the full ingestion pipeline:\n - Querying the adapter for message references.\n - Fetching raw provider messages.\n - Parsing and normalizing message data.\n - Constructing domain models.\n\n **Constraints:**\n\n - This class is intentionally: Provider-agnostic, stateless beyond\n iteration scope, read-only.",
"members": {
"iter_messages": {
"name": "iter_messages",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeReader.iter_messages",
"signature": "<bound method Function.signature of Function('iter_messages', 62, 80)>",
"docstring": "Iterate over parsed messages matching a provider query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n MailIntakeMessage:\n Fully parsed and normalized `MailIntakeMessage` instances.\n\nRaises:\n MailIntakeParsingError:\n If a message cannot be parsed."
},
"iter_threads": {
"name": "iter_threads",
"kind": "function",
"path": "mail_intake.ingestion.reader.MailIntakeReader.iter_threads",
"signature": "<bound method Function.signature of Function('iter_threads', 82, 120)>",
"docstring": "Iterate over threads constructed from messages matching a query.\n\nArgs:\n query (str):\n Provider-specific query string used to filter messages.\n\nYields:\n MailIntakeThread:\n An iterator of `MailIntakeThread` instances.\n\nRaises:\n `MailIntakeParsingError`:\n If a message cannot be parsed.\n\nNotes:\n **Guarantees:**\n\n - Messages are grouped by `thread_id` and yielded as complete\n thread objects containing all associated messages."
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,415 @@
{
"module": "mail_intake.models",
"content": {
"path": "mail_intake.models",
"docstring": "# Summary\n\nDomain models for Mail Intake.\n\nThis package defines the **canonical, provider-agnostic data models**\nused throughout the Mail Intake ingestion pipeline.\n\nModels in this package:\n\n- Represent fully parsed and normalized mail data.\n- Are safe to persist, serialize, and index.\n- Contain no provider-specific payloads or API semantics.\n- Serve as stable inputs for downstream processing and analysis.\n\nThese models form the core internal data contract of the library.\n\n---\n\n# Public API\n\n- `MailIntakeMessage`\n- `MailIntakeThread`\n\n---",
"objects": {
"MailIntakeMessage": {
"name": "MailIntakeMessage",
"kind": "class",
"path": "mail_intake.models.MailIntakeMessage",
"signature": "<bound method Alias.signature of Alias('MailIntakeMessage', 'mail_intake.models.message.MailIntakeMessage')>",
"docstring": "Canonical internal representation of a single email message.\n\nNotes:\n **Guarantees:**\n\n - This model represents a fully parsed and normalized email message.\n - It is intentionally provider-agnostic and suitable for\n persistence, indexing, and downstream processing.\n\n **Constraints:**\n\n - No provider-specific identifiers, payloads, or API semantics\n should appear in this model.",
"members": {
"message_id": {
"name": "message_id",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.message_id",
"signature": "<bound method Alias.signature of Alias('message_id', 'mail_intake.models.message.MailIntakeMessage.message_id')>",
"docstring": "Provider-specific message identifier."
},
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.thread_id",
"signature": "<bound method Alias.signature of Alias('thread_id', 'mail_intake.models.message.MailIntakeMessage.thread_id')>",
"docstring": "Provider-specific thread identifier to which this message belongs."
},
"timestamp": {
"name": "timestamp",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.timestamp",
"signature": "<bound method Alias.signature of Alias('timestamp', 'mail_intake.models.message.MailIntakeMessage.timestamp')>",
"docstring": "Message timestamp as a timezone-naive UTC datetime."
},
"from_email": {
"name": "from_email",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.from_email",
"signature": "<bound method Alias.signature of Alias('from_email', 'mail_intake.models.message.MailIntakeMessage.from_email')>",
"docstring": "Sender email address."
},
"from_name": {
"name": "from_name",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.from_name",
"signature": "<bound method Alias.signature of Alias('from_name', 'mail_intake.models.message.MailIntakeMessage.from_name')>",
"docstring": "Optional human-readable sender name."
},
"subject": {
"name": "subject",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.subject",
"signature": "<bound method Alias.signature of Alias('subject', 'mail_intake.models.message.MailIntakeMessage.subject')>",
"docstring": "Raw subject line of the message."
},
"body_text": {
"name": "body_text",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.body_text",
"signature": "<bound method Alias.signature of Alias('body_text', 'mail_intake.models.message.MailIntakeMessage.body_text')>",
"docstring": "Extracted plain-text body content of the message."
},
"snippet": {
"name": "snippet",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.snippet",
"signature": "<bound method Alias.signature of Alias('snippet', 'mail_intake.models.message.MailIntakeMessage.snippet')>",
"docstring": "Short provider-supplied preview snippet of the message."
},
"raw_headers": {
"name": "raw_headers",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeMessage.raw_headers",
"signature": "<bound method Alias.signature of Alias('raw_headers', 'mail_intake.models.message.MailIntakeMessage.raw_headers')>",
"docstring": "Normalized mapping of message headers (header name → value)."
}
}
},
"MailIntakeThread": {
"name": "MailIntakeThread",
"kind": "class",
"path": "mail_intake.models.MailIntakeThread",
"signature": "<bound method Alias.signature of Alias('MailIntakeThread', 'mail_intake.models.thread.MailIntakeThread')>",
"docstring": "Canonical internal representation of an email thread.\n\nNotes:\n **Guarantees:**\n\n - A thread groups multiple related messages under a single subject\n and participant set.\n - It is designed to support reasoning over conversational context\n such as job applications, interviews, follow-ups, and ongoing discussions.\n - This model is provider-agnostic and safe to persist.",
"members": {
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeThread.thread_id",
"signature": "<bound method Alias.signature of Alias('thread_id', 'mail_intake.models.thread.MailIntakeThread.thread_id')>",
"docstring": "Provider-specific thread identifier."
},
"normalized_subject": {
"name": "normalized_subject",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeThread.normalized_subject",
"signature": "<bound method Alias.signature of Alias('normalized_subject', 'mail_intake.models.thread.MailIntakeThread.normalized_subject')>",
"docstring": "Normalized subject line used to group related messages."
},
"participants": {
"name": "participants",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeThread.participants",
"signature": "<bound method Alias.signature of Alias('participants', 'mail_intake.models.thread.MailIntakeThread.participants')>",
"docstring": "Set of unique participant email addresses observed in the thread."
},
"messages": {
"name": "messages",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeThread.messages",
"signature": "<bound method Alias.signature of Alias('messages', 'mail_intake.models.thread.MailIntakeThread.messages')>",
"docstring": "Ordered list of messages belonging to this thread."
},
"last_activity_at": {
"name": "last_activity_at",
"kind": "attribute",
"path": "mail_intake.models.MailIntakeThread.last_activity_at",
"signature": "<bound method Alias.signature of Alias('last_activity_at', 'mail_intake.models.thread.MailIntakeThread.last_activity_at')>",
"docstring": "Timestamp of the most recent message in the thread."
},
"add_message": {
"name": "add_message",
"kind": "function",
"path": "mail_intake.models.MailIntakeThread.add_message",
"signature": "<bound method Alias.signature of Alias('add_message', 'mail_intake.models.thread.MailIntakeThread.add_message')>",
"docstring": "Add a message to the thread and update derived fields.\n\nArgs:\n message (MailIntakeMessage):\n Parsed mail message to add to the thread.\n\nNotes:\n **Responsibilities:**\n\n - Appends the message to the thread.\n - Tracks unique participants.\n - Updates the last activity timestamp."
}
}
},
"message": {
"name": "message",
"kind": "module",
"path": "mail_intake.models.message",
"signature": null,
"docstring": "# Summary\n\nMessage domain models for Mail Intake.\n\nThis module defines the **canonical, provider-agnostic representation**\nof an individual email message as used internally by the Mail Intake\ningestion pipeline.\n\nModels in this module are safe to persist and must not contain any\nprovider-specific fields or semantics.",
"members": {
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mail_intake.models.message.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mail_intake.models.message.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.models.message.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.models.message.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"MailIntakeMessage": {
"name": "MailIntakeMessage",
"kind": "class",
"path": "mail_intake.models.message.MailIntakeMessage",
"signature": "<bound method Class.signature of Class('MailIntakeMessage', 19, 80)>",
"docstring": "Canonical internal representation of a single email message.\n\nNotes:\n **Guarantees:**\n\n - This model represents a fully parsed and normalized email message.\n - It is intentionally provider-agnostic and suitable for\n persistence, indexing, and downstream processing.\n\n **Constraints:**\n\n - No provider-specific identifiers, payloads, or API semantics\n should appear in this model.",
"members": {
"message_id": {
"name": "message_id",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.message_id",
"signature": null,
"docstring": "Provider-specific message identifier."
},
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.thread_id",
"signature": null,
"docstring": "Provider-specific thread identifier to which this message belongs."
},
"timestamp": {
"name": "timestamp",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.timestamp",
"signature": null,
"docstring": "Message timestamp as a timezone-naive UTC datetime."
},
"from_email": {
"name": "from_email",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.from_email",
"signature": null,
"docstring": "Sender email address."
},
"from_name": {
"name": "from_name",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.from_name",
"signature": null,
"docstring": "Optional human-readable sender name."
},
"subject": {
"name": "subject",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.subject",
"signature": null,
"docstring": "Raw subject line of the message."
},
"body_text": {
"name": "body_text",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.body_text",
"signature": null,
"docstring": "Extracted plain-text body content of the message."
},
"snippet": {
"name": "snippet",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.snippet",
"signature": null,
"docstring": "Short provider-supplied preview snippet of the message."
},
"raw_headers": {
"name": "raw_headers",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.raw_headers",
"signature": null,
"docstring": "Normalized mapping of message headers (header name → value)."
}
}
}
}
},
"thread": {
"name": "thread",
"kind": "module",
"path": "mail_intake.models.thread",
"signature": null,
"docstring": "# Summary\n\nThread domain models for Mail Intake.\n\nThis module defines the **canonical, provider-agnostic representation**\nof an email thread as used internally by the Mail Intake ingestion pipeline.\n\nThreads group related messages and serve as the primary unit of reasoning\nfor higher-level correspondence workflows.",
"members": {
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mail_intake.models.thread.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"field": {
"name": "field",
"kind": "alias",
"path": "mail_intake.models.thread.field",
"signature": "<bound method Alias.signature of Alias('field', 'dataclasses.field')>",
"docstring": null
},
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mail_intake.models.thread.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mail_intake.models.thread.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Set": {
"name": "Set",
"kind": "alias",
"path": "mail_intake.models.thread.Set",
"signature": "<bound method Alias.signature of Alias('Set', 'typing.Set')>",
"docstring": null
},
"MailIntakeMessage": {
"name": "MailIntakeMessage",
"kind": "class",
"path": "mail_intake.models.thread.MailIntakeMessage",
"signature": "<bound method Alias.signature of Alias('MailIntakeMessage', 'mail_intake.models.message.MailIntakeMessage')>",
"docstring": "Canonical internal representation of a single email message.\n\nNotes:\n **Guarantees:**\n\n - This model represents a fully parsed and normalized email message.\n - It is intentionally provider-agnostic and suitable for\n persistence, indexing, and downstream processing.\n\n **Constraints:**\n\n - No provider-specific identifiers, payloads, or API semantics\n should appear in this model.",
"members": {
"message_id": {
"name": "message_id",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.message_id",
"signature": "<bound method Alias.signature of Alias('message_id', 'mail_intake.models.message.MailIntakeMessage.message_id')>",
"docstring": "Provider-specific message identifier."
},
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.thread_id",
"signature": "<bound method Alias.signature of Alias('thread_id', 'mail_intake.models.message.MailIntakeMessage.thread_id')>",
"docstring": "Provider-specific thread identifier to which this message belongs."
},
"timestamp": {
"name": "timestamp",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.timestamp",
"signature": "<bound method Alias.signature of Alias('timestamp', 'mail_intake.models.message.MailIntakeMessage.timestamp')>",
"docstring": "Message timestamp as a timezone-naive UTC datetime."
},
"from_email": {
"name": "from_email",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.from_email",
"signature": "<bound method Alias.signature of Alias('from_email', 'mail_intake.models.message.MailIntakeMessage.from_email')>",
"docstring": "Sender email address."
},
"from_name": {
"name": "from_name",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.from_name",
"signature": "<bound method Alias.signature of Alias('from_name', 'mail_intake.models.message.MailIntakeMessage.from_name')>",
"docstring": "Optional human-readable sender name."
},
"subject": {
"name": "subject",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.subject",
"signature": "<bound method Alias.signature of Alias('subject', 'mail_intake.models.message.MailIntakeMessage.subject')>",
"docstring": "Raw subject line of the message."
},
"body_text": {
"name": "body_text",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.body_text",
"signature": "<bound method Alias.signature of Alias('body_text', 'mail_intake.models.message.MailIntakeMessage.body_text')>",
"docstring": "Extracted plain-text body content of the message."
},
"snippet": {
"name": "snippet",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.snippet",
"signature": "<bound method Alias.signature of Alias('snippet', 'mail_intake.models.message.MailIntakeMessage.snippet')>",
"docstring": "Short provider-supplied preview snippet of the message."
},
"raw_headers": {
"name": "raw_headers",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.raw_headers",
"signature": "<bound method Alias.signature of Alias('raw_headers', 'mail_intake.models.message.MailIntakeMessage.raw_headers')>",
"docstring": "Normalized mapping of message headers (header name → value)."
}
}
},
"MailIntakeThread": {
"name": "MailIntakeThread",
"kind": "class",
"path": "mail_intake.models.thread.MailIntakeThread",
"signature": "<bound method Class.signature of Class('MailIntakeThread', 20, 81)>",
"docstring": "Canonical internal representation of an email thread.\n\nNotes:\n **Guarantees:**\n\n - A thread groups multiple related messages under a single subject\n and participant set.\n - It is designed to support reasoning over conversational context\n such as job applications, interviews, follow-ups, and ongoing discussions.\n - This model is provider-agnostic and safe to persist.",
"members": {
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.thread_id",
"signature": null,
"docstring": "Provider-specific thread identifier."
},
"normalized_subject": {
"name": "normalized_subject",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.normalized_subject",
"signature": null,
"docstring": "Normalized subject line used to group related messages."
},
"participants": {
"name": "participants",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.participants",
"signature": null,
"docstring": "Set of unique participant email addresses observed in the thread."
},
"messages": {
"name": "messages",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.messages",
"signature": null,
"docstring": "Ordered list of messages belonging to this thread."
},
"last_activity_at": {
"name": "last_activity_at",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.last_activity_at",
"signature": null,
"docstring": "Timestamp of the most recent message in the thread."
},
"add_message": {
"name": "add_message",
"kind": "function",
"path": "mail_intake.models.thread.MailIntakeThread.add_message",
"signature": "<bound method Function.signature of Function('add_message', 60, 81)>",
"docstring": "Add a message to the thread and update derived fields.\n\nArgs:\n message (MailIntakeMessage):\n Parsed mail message to add to the thread.\n\nNotes:\n **Responsibilities:**\n\n - Appends the message to the thread.\n - Tracks unique participants.\n - Updates the last activity timestamp."
}
}
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.models.thread.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
}
}
}
}
}
}

View File

@@ -0,0 +1,109 @@
{
"module": "mail_intake.models.message",
"content": {
"path": "mail_intake.models.message",
"docstring": "# Summary\n\nMessage domain models for Mail Intake.\n\nThis module defines the **canonical, provider-agnostic representation**\nof an individual email message as used internally by the Mail Intake\ningestion pipeline.\n\nModels in this module are safe to persist and must not contain any\nprovider-specific fields or semantics.",
"objects": {
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mail_intake.models.message.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mail_intake.models.message.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.models.message.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.models.message.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"MailIntakeMessage": {
"name": "MailIntakeMessage",
"kind": "class",
"path": "mail_intake.models.message.MailIntakeMessage",
"signature": "<bound method Class.signature of Class('MailIntakeMessage', 19, 80)>",
"docstring": "Canonical internal representation of a single email message.\n\nNotes:\n **Guarantees:**\n\n - This model represents a fully parsed and normalized email message.\n - It is intentionally provider-agnostic and suitable for\n persistence, indexing, and downstream processing.\n\n **Constraints:**\n\n - No provider-specific identifiers, payloads, or API semantics\n should appear in this model.",
"members": {
"message_id": {
"name": "message_id",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.message_id",
"signature": null,
"docstring": "Provider-specific message identifier."
},
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.thread_id",
"signature": null,
"docstring": "Provider-specific thread identifier to which this message belongs."
},
"timestamp": {
"name": "timestamp",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.timestamp",
"signature": null,
"docstring": "Message timestamp as a timezone-naive UTC datetime."
},
"from_email": {
"name": "from_email",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.from_email",
"signature": null,
"docstring": "Sender email address."
},
"from_name": {
"name": "from_name",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.from_name",
"signature": null,
"docstring": "Optional human-readable sender name."
},
"subject": {
"name": "subject",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.subject",
"signature": null,
"docstring": "Raw subject line of the message."
},
"body_text": {
"name": "body_text",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.body_text",
"signature": null,
"docstring": "Extracted plain-text body content of the message."
},
"snippet": {
"name": "snippet",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.snippet",
"signature": null,
"docstring": "Short provider-supplied preview snippet of the message."
},
"raw_headers": {
"name": "raw_headers",
"kind": "attribute",
"path": "mail_intake.models.message.MailIntakeMessage.raw_headers",
"signature": null,
"docstring": "Normalized mapping of message headers (header name → value)."
}
}
}
}
}
}

View File

@@ -0,0 +1,174 @@
{
"module": "mail_intake.models.thread",
"content": {
"path": "mail_intake.models.thread",
"docstring": "# Summary\n\nThread domain models for Mail Intake.\n\nThis module defines the **canonical, provider-agnostic representation**\nof an email thread as used internally by the Mail Intake ingestion pipeline.\n\nThreads group related messages and serve as the primary unit of reasoning\nfor higher-level correspondence workflows.",
"objects": {
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mail_intake.models.thread.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"field": {
"name": "field",
"kind": "alias",
"path": "mail_intake.models.thread.field",
"signature": "<bound method Alias.signature of Alias('field', 'dataclasses.field')>",
"docstring": null
},
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mail_intake.models.thread.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mail_intake.models.thread.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Set": {
"name": "Set",
"kind": "alias",
"path": "mail_intake.models.thread.Set",
"signature": "<bound method Alias.signature of Alias('Set', 'typing.Set')>",
"docstring": null
},
"MailIntakeMessage": {
"name": "MailIntakeMessage",
"kind": "class",
"path": "mail_intake.models.thread.MailIntakeMessage",
"signature": "<bound method Alias.signature of Alias('MailIntakeMessage', 'mail_intake.models.message.MailIntakeMessage')>",
"docstring": "Canonical internal representation of a single email message.\n\nNotes:\n **Guarantees:**\n\n - This model represents a fully parsed and normalized email message.\n - It is intentionally provider-agnostic and suitable for\n persistence, indexing, and downstream processing.\n\n **Constraints:**\n\n - No provider-specific identifiers, payloads, or API semantics\n should appear in this model.",
"members": {
"message_id": {
"name": "message_id",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.message_id",
"signature": "<bound method Alias.signature of Alias('message_id', 'mail_intake.models.message.MailIntakeMessage.message_id')>",
"docstring": "Provider-specific message identifier."
},
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.thread_id",
"signature": "<bound method Alias.signature of Alias('thread_id', 'mail_intake.models.message.MailIntakeMessage.thread_id')>",
"docstring": "Provider-specific thread identifier to which this message belongs."
},
"timestamp": {
"name": "timestamp",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.timestamp",
"signature": "<bound method Alias.signature of Alias('timestamp', 'mail_intake.models.message.MailIntakeMessage.timestamp')>",
"docstring": "Message timestamp as a timezone-naive UTC datetime."
},
"from_email": {
"name": "from_email",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.from_email",
"signature": "<bound method Alias.signature of Alias('from_email', 'mail_intake.models.message.MailIntakeMessage.from_email')>",
"docstring": "Sender email address."
},
"from_name": {
"name": "from_name",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.from_name",
"signature": "<bound method Alias.signature of Alias('from_name', 'mail_intake.models.message.MailIntakeMessage.from_name')>",
"docstring": "Optional human-readable sender name."
},
"subject": {
"name": "subject",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.subject",
"signature": "<bound method Alias.signature of Alias('subject', 'mail_intake.models.message.MailIntakeMessage.subject')>",
"docstring": "Raw subject line of the message."
},
"body_text": {
"name": "body_text",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.body_text",
"signature": "<bound method Alias.signature of Alias('body_text', 'mail_intake.models.message.MailIntakeMessage.body_text')>",
"docstring": "Extracted plain-text body content of the message."
},
"snippet": {
"name": "snippet",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.snippet",
"signature": "<bound method Alias.signature of Alias('snippet', 'mail_intake.models.message.MailIntakeMessage.snippet')>",
"docstring": "Short provider-supplied preview snippet of the message."
},
"raw_headers": {
"name": "raw_headers",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeMessage.raw_headers",
"signature": "<bound method Alias.signature of Alias('raw_headers', 'mail_intake.models.message.MailIntakeMessage.raw_headers')>",
"docstring": "Normalized mapping of message headers (header name → value)."
}
}
},
"MailIntakeThread": {
"name": "MailIntakeThread",
"kind": "class",
"path": "mail_intake.models.thread.MailIntakeThread",
"signature": "<bound method Class.signature of Class('MailIntakeThread', 20, 81)>",
"docstring": "Canonical internal representation of an email thread.\n\nNotes:\n **Guarantees:**\n\n - A thread groups multiple related messages under a single subject\n and participant set.\n - It is designed to support reasoning over conversational context\n such as job applications, interviews, follow-ups, and ongoing discussions.\n - This model is provider-agnostic and safe to persist.",
"members": {
"thread_id": {
"name": "thread_id",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.thread_id",
"signature": null,
"docstring": "Provider-specific thread identifier."
},
"normalized_subject": {
"name": "normalized_subject",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.normalized_subject",
"signature": null,
"docstring": "Normalized subject line used to group related messages."
},
"participants": {
"name": "participants",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.participants",
"signature": null,
"docstring": "Set of unique participant email addresses observed in the thread."
},
"messages": {
"name": "messages",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.messages",
"signature": null,
"docstring": "Ordered list of messages belonging to this thread."
},
"last_activity_at": {
"name": "last_activity_at",
"kind": "attribute",
"path": "mail_intake.models.thread.MailIntakeThread.last_activity_at",
"signature": null,
"docstring": "Timestamp of the most recent message in the thread."
},
"add_message": {
"name": "add_message",
"kind": "function",
"path": "mail_intake.models.thread.MailIntakeThread.add_message",
"signature": "<bound method Function.signature of Function('add_message', 60, 81)>",
"docstring": "Add a message to the thread and update derived fields.\n\nArgs:\n message (MailIntakeMessage):\n Parsed mail message to add to the thread.\n\nNotes:\n **Responsibilities:**\n\n - Appends the message to the thread.\n - Tracks unique participants.\n - Updates the last activity timestamp."
}
}
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.models.thread.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
}
}
}
}

View File

@@ -0,0 +1,58 @@
{
"module": "mail_intake.parsers.body",
"content": {
"path": "mail_intake.parsers.body",
"docstring": "# Summary\n\nMessage body extraction utilities for Mail Intake.\n\nThis module contains helper functions for extracting a best-effort\nplain-text body from provider-native message payloads.\n\nThe logic is intentionally tolerant of malformed or partial data and\nprefers human-readable text over fidelity to original formatting.",
"objects": {
"base64": {
"name": "base64",
"kind": "alias",
"path": "mail_intake.parsers.body.base64",
"signature": "<bound method Alias.signature of Alias('base64', 'base64')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.parsers.body.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.parsers.body.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.parsers.body.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"BeautifulSoup": {
"name": "BeautifulSoup",
"kind": "alias",
"path": "mail_intake.parsers.body.BeautifulSoup",
"signature": "<bound method Alias.signature of Alias('BeautifulSoup', 'bs4.BeautifulSoup')>",
"docstring": null
},
"MailIntakeParsingError": {
"name": "MailIntakeParsingError",
"kind": "class",
"path": "mail_intake.parsers.body.MailIntakeParsingError",
"signature": "<bound method Alias.signature of Alias('MailIntakeParsingError', 'mail_intake.exceptions.MailIntakeParsingError')>",
"docstring": "Errors encountered while parsing message content.\n\nNotes:\n **Lifecycle:**\n\n - Raised when raw provider payloads cannot be interpreted or\n normalized into internal domain models."
},
"extract_body": {
"name": "extract_body",
"kind": "function",
"path": "mail_intake.parsers.body.extract_body",
"signature": "<bound method Function.signature of Function('extract_body', 85, 133)>",
"docstring": "Extract the best-effort message body from a Gmail payload.\n\nPriority:\n\n1. `text/plain`\n2. `text/html` (stripped to text)\n3. Single-part body\n4. Empty string (if nothing usable found)\n\nArgs:\n payload (Dict[str, Any]):\n Provider-native message payload dictionary.\n\nReturns:\n str:\n Extracted plain-text message body."
}
}
}
}

View File

@@ -0,0 +1,51 @@
{
"module": "mail_intake.parsers.headers",
"content": {
"path": "mail_intake.parsers.headers",
"docstring": "# Summary\n\nMessage header parsing utilities for Mail Intake.\n\nThis module provides helper functions for normalizing and extracting\nuseful information from provider-native message headers.\n\nThe functions here are intentionally simple and tolerant of malformed\nor incomplete header data.",
"objects": {
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.parsers.headers.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mail_intake.parsers.headers.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Tuple": {
"name": "Tuple",
"kind": "alias",
"path": "mail_intake.parsers.headers.Tuple",
"signature": "<bound method Alias.signature of Alias('Tuple', 'typing.Tuple')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.parsers.headers.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"parse_headers": {
"name": "parse_headers",
"kind": "function",
"path": "mail_intake.parsers.headers.parse_headers",
"signature": "<bound method Function.signature of Function('parse_headers', 16, 64)>",
"docstring": "Convert a list of Gmail-style headers into a normalized dict.\n\nArgs:\n raw_headers (List[Dict[str, str]]):\n List of header dictionaries, each containing `name` and `value` keys.\n\nReturns:\n Dict[str, str]:\n Dictionary mapping lowercase header names to stripped values.\n\nNotes:\n **Guarantees:**\n\n - Provider payloads (such as Gmail) typically represent headers as a\n list of name/value mappings.\n - This function normalizes them into a case-insensitive dictionary\n keyed by lowercase header names.\n\nExample:\n Typical usage:\n\n ```python\n Input:\n [\n {\"name\": \"From\", \"value\": \"John Doe <john@example.com>\"},\n {\"name\": \"Subject\", \"value\": \"Re: Interview Update\"},\n ]\n\n Output:\n {\n \"from\": \"John Doe <john@example.com>\",\n \"subject\": \"Re: Interview Update\",\n }\n ```"
},
"extract_sender": {
"name": "extract_sender",
"kind": "function",
"path": "mail_intake.parsers.headers.extract_sender",
"signature": "<bound method Function.signature of Function('extract_sender', 67, 102)>",
"docstring": "Extract sender email and optional display name from headers.\n\nArgs:\n headers (Dict[str, str]):\n Normalized header dictionary as returned by `parse_headers()`.\n\nReturns:\n Tuple[str, Optional[str]]:\n A tuple `(email, name)` where `email` is the sender email address\n and `name` is the display name, or `None` if unavailable.\n\nNotes:\n **Responsibilities:**\n\n - This function parses the `From` header and attempts to extract\n sender email address and optional human-readable display name.\n\nExample:\n Typical values:\n\n - `\"John Doe <john@example.com>\"` -> `(\"john@example.com\", \"John Doe\")`\n - `\"john@example.com\"` -> `(\"john@example.com\", None)`"
}
}
}
}

View File

@@ -0,0 +1,169 @@
{
"module": "mail_intake.parsers",
"content": {
"path": "mail_intake.parsers",
"docstring": "# Summary\n\nMessage parsing utilities for Mail Intake.\n\nThis package contains **provider-aware but adapter-agnostic parsing helpers**\nused to extract and normalize structured information from raw mail payloads.\n\nParsers in this package are responsible for:\n\n- Interpreting provider-native message structures.\n- Extracting meaningful fields such as headers, body text, and subjects.\n- Normalizing data into consistent internal representations.\n\nThis package does not:\n\n- Perform network or IO operations.\n- Contain provider API logic.\n- Construct domain models directly.\n\nParsing functions are designed to be composable and are orchestrated by the\ningestion layer.\n\n---\n\n# Public API\n\n- `extract_body`\n- `parse_headers`\n- `extract_sender`\n- `normalize_subject`\n\n---",
"objects": {
"extract_body": {
"name": "extract_body",
"kind": "function",
"path": "mail_intake.parsers.extract_body",
"signature": "<bound method Alias.signature of Alias('extract_body', 'mail_intake.parsers.body.extract_body')>",
"docstring": "Extract the best-effort message body from a Gmail payload.\n\nPriority:\n\n1. `text/plain`\n2. `text/html` (stripped to text)\n3. Single-part body\n4. Empty string (if nothing usable found)\n\nArgs:\n payload (Dict[str, Any]):\n Provider-native message payload dictionary.\n\nReturns:\n str:\n Extracted plain-text message body."
},
"parse_headers": {
"name": "parse_headers",
"kind": "function",
"path": "mail_intake.parsers.parse_headers",
"signature": "<bound method Alias.signature of Alias('parse_headers', 'mail_intake.parsers.headers.parse_headers')>",
"docstring": "Convert a list of Gmail-style headers into a normalized dict.\n\nArgs:\n raw_headers (List[Dict[str, str]]):\n List of header dictionaries, each containing `name` and `value` keys.\n\nReturns:\n Dict[str, str]:\n Dictionary mapping lowercase header names to stripped values.\n\nNotes:\n **Guarantees:**\n\n - Provider payloads (such as Gmail) typically represent headers as a\n list of name/value mappings.\n - This function normalizes them into a case-insensitive dictionary\n keyed by lowercase header names.\n\nExample:\n Typical usage:\n\n ```python\n Input:\n [\n {\"name\": \"From\", \"value\": \"John Doe <john@example.com>\"},\n {\"name\": \"Subject\", \"value\": \"Re: Interview Update\"},\n ]\n\n Output:\n {\n \"from\": \"John Doe <john@example.com>\",\n \"subject\": \"Re: Interview Update\",\n }\n ```"
},
"extract_sender": {
"name": "extract_sender",
"kind": "function",
"path": "mail_intake.parsers.extract_sender",
"signature": "<bound method Alias.signature of Alias('extract_sender', 'mail_intake.parsers.headers.extract_sender')>",
"docstring": "Extract sender email and optional display name from headers.\n\nArgs:\n headers (Dict[str, str]):\n Normalized header dictionary as returned by `parse_headers()`.\n\nReturns:\n Tuple[str, Optional[str]]:\n A tuple `(email, name)` where `email` is the sender email address\n and `name` is the display name, or `None` if unavailable.\n\nNotes:\n **Responsibilities:**\n\n - This function parses the `From` header and attempts to extract\n sender email address and optional human-readable display name.\n\nExample:\n Typical values:\n\n - `\"John Doe <john@example.com>\"` -> `(\"john@example.com\", \"John Doe\")`\n - `\"john@example.com\"` -> `(\"john@example.com\", None)`"
},
"normalize_subject": {
"name": "normalize_subject",
"kind": "function",
"path": "mail_intake.parsers.normalize_subject",
"signature": "<bound method Alias.signature of Alias('normalize_subject', 'mail_intake.parsers.subject.normalize_subject')>",
"docstring": "Normalize an email subject for thread-level comparison.\n\nArgs:\n subject (str):\n Raw subject line from a message header.\n\nReturns:\n str:\n Normalized subject string suitable for thread grouping.\n\nNotes:\n **Responsibilities:**\n\n - Strips common prefixes such as `Re:`, `Fwd:`, and `FW:`.\n - Repeats prefix stripping to handle stacked prefixes.\n - Collapses excessive whitespace.\n - Preserves original casing (no lowercasing).\n\n **Guarantees:**\n\n - This function is intentionally conservative and avoids aggressive\n transformations that could alter the semantic meaning of the subject."
},
"body": {
"name": "body",
"kind": "module",
"path": "mail_intake.parsers.body",
"signature": null,
"docstring": "# Summary\n\nMessage body extraction utilities for Mail Intake.\n\nThis module contains helper functions for extracting a best-effort\nplain-text body from provider-native message payloads.\n\nThe logic is intentionally tolerant of malformed or partial data and\nprefers human-readable text over fidelity to original formatting.",
"members": {
"base64": {
"name": "base64",
"kind": "alias",
"path": "mail_intake.parsers.body.base64",
"signature": "<bound method Alias.signature of Alias('base64', 'base64')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.parsers.body.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mail_intake.parsers.body.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.parsers.body.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"BeautifulSoup": {
"name": "BeautifulSoup",
"kind": "alias",
"path": "mail_intake.parsers.body.BeautifulSoup",
"signature": "<bound method Alias.signature of Alias('BeautifulSoup', 'bs4.BeautifulSoup')>",
"docstring": null
},
"MailIntakeParsingError": {
"name": "MailIntakeParsingError",
"kind": "class",
"path": "mail_intake.parsers.body.MailIntakeParsingError",
"signature": "<bound method Alias.signature of Alias('MailIntakeParsingError', 'mail_intake.exceptions.MailIntakeParsingError')>",
"docstring": "Errors encountered while parsing message content.\n\nNotes:\n **Lifecycle:**\n\n - Raised when raw provider payloads cannot be interpreted or\n normalized into internal domain models."
},
"extract_body": {
"name": "extract_body",
"kind": "function",
"path": "mail_intake.parsers.body.extract_body",
"signature": "<bound method Function.signature of Function('extract_body', 85, 133)>",
"docstring": "Extract the best-effort message body from a Gmail payload.\n\nPriority:\n\n1. `text/plain`\n2. `text/html` (stripped to text)\n3. Single-part body\n4. Empty string (if nothing usable found)\n\nArgs:\n payload (Dict[str, Any]):\n Provider-native message payload dictionary.\n\nReturns:\n str:\n Extracted plain-text message body."
}
}
},
"headers": {
"name": "headers",
"kind": "module",
"path": "mail_intake.parsers.headers",
"signature": null,
"docstring": "# Summary\n\nMessage header parsing utilities for Mail Intake.\n\nThis module provides helper functions for normalizing and extracting\nuseful information from provider-native message headers.\n\nThe functions here are intentionally simple and tolerant of malformed\nor incomplete header data.",
"members": {
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mail_intake.parsers.headers.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mail_intake.parsers.headers.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Tuple": {
"name": "Tuple",
"kind": "alias",
"path": "mail_intake.parsers.headers.Tuple",
"signature": "<bound method Alias.signature of Alias('Tuple', 'typing.Tuple')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mail_intake.parsers.headers.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"parse_headers": {
"name": "parse_headers",
"kind": "function",
"path": "mail_intake.parsers.headers.parse_headers",
"signature": "<bound method Function.signature of Function('parse_headers', 16, 64)>",
"docstring": "Convert a list of Gmail-style headers into a normalized dict.\n\nArgs:\n raw_headers (List[Dict[str, str]]):\n List of header dictionaries, each containing `name` and `value` keys.\n\nReturns:\n Dict[str, str]:\n Dictionary mapping lowercase header names to stripped values.\n\nNotes:\n **Guarantees:**\n\n - Provider payloads (such as Gmail) typically represent headers as a\n list of name/value mappings.\n - This function normalizes them into a case-insensitive dictionary\n keyed by lowercase header names.\n\nExample:\n Typical usage:\n\n ```python\n Input:\n [\n {\"name\": \"From\", \"value\": \"John Doe <john@example.com>\"},\n {\"name\": \"Subject\", \"value\": \"Re: Interview Update\"},\n ]\n\n Output:\n {\n \"from\": \"John Doe <john@example.com>\",\n \"subject\": \"Re: Interview Update\",\n }\n ```"
},
"extract_sender": {
"name": "extract_sender",
"kind": "function",
"path": "mail_intake.parsers.headers.extract_sender",
"signature": "<bound method Function.signature of Function('extract_sender', 67, 102)>",
"docstring": "Extract sender email and optional display name from headers.\n\nArgs:\n headers (Dict[str, str]):\n Normalized header dictionary as returned by `parse_headers()`.\n\nReturns:\n Tuple[str, Optional[str]]:\n A tuple `(email, name)` where `email` is the sender email address\n and `name` is the display name, or `None` if unavailable.\n\nNotes:\n **Responsibilities:**\n\n - This function parses the `From` header and attempts to extract\n sender email address and optional human-readable display name.\n\nExample:\n Typical values:\n\n - `\"John Doe <john@example.com>\"` -> `(\"john@example.com\", \"John Doe\")`\n - `\"john@example.com\"` -> `(\"john@example.com\", None)`"
}
}
},
"subject": {
"name": "subject",
"kind": "module",
"path": "mail_intake.parsers.subject",
"signature": null,
"docstring": "# Summary\n\nSubject line normalization utilities for Mail Intake.\n\nThis module provides helper functions for normalizing email subject lines\nto enable reliable thread-level comparison and grouping.\n\nNormalization is intentionally conservative to avoid altering semantic\nmeaning while removing common reply and forward prefixes.",
"members": {
"re": {
"name": "re",
"kind": "alias",
"path": "mail_intake.parsers.subject.re",
"signature": "<bound method Alias.signature of Alias('re', 're')>",
"docstring": null
},
"normalize_subject": {
"name": "normalize_subject",
"kind": "function",
"path": "mail_intake.parsers.subject.normalize_subject",
"signature": "<bound method Function.signature of Function('normalize_subject', 22, 62)>",
"docstring": "Normalize an email subject for thread-level comparison.\n\nArgs:\n subject (str):\n Raw subject line from a message header.\n\nReturns:\n str:\n Normalized subject string suitable for thread grouping.\n\nNotes:\n **Responsibilities:**\n\n - Strips common prefixes such as `Re:`, `Fwd:`, and `FW:`.\n - Repeats prefix stripping to handle stacked prefixes.\n - Collapses excessive whitespace.\n - Preserves original casing (no lowercasing).\n\n **Guarantees:**\n\n - This function is intentionally conservative and avoids aggressive\n transformations that could alter the semantic meaning of the subject."
}
}
}
}
}
}

View File

@@ -0,0 +1,23 @@
{
"module": "mail_intake.parsers.subject",
"content": {
"path": "mail_intake.parsers.subject",
"docstring": "# Summary\n\nSubject line normalization utilities for Mail Intake.\n\nThis module provides helper functions for normalizing email subject lines\nto enable reliable thread-level comparison and grouping.\n\nNormalization is intentionally conservative to avoid altering semantic\nmeaning while removing common reply and forward prefixes.",
"objects": {
"re": {
"name": "re",
"kind": "alias",
"path": "mail_intake.parsers.subject.re",
"signature": "<bound method Alias.signature of Alias('re', 're')>",
"docstring": null
},
"normalize_subject": {
"name": "normalize_subject",
"kind": "function",
"path": "mail_intake.parsers.subject.normalize_subject",
"signature": "<bound method Function.signature of Function('normalize_subject', 22, 62)>",
"docstring": "Normalize an email subject for thread-level comparison.\n\nArgs:\n subject (str):\n Raw subject line from a message header.\n\nReturns:\n str:\n Normalized subject string suitable for thread grouping.\n\nNotes:\n **Responsibilities:**\n\n - Strips common prefixes such as `Re:`, `Fwd:`, and `FW:`.\n - Repeats prefix stripping to handle stacked prefixes.\n - Collapses excessive whitespace.\n - Preserves original casing (no lowercasing).\n\n **Guarantees:**\n\n - This function is intentionally conservative and avoids aggressive\n transformations that could alter the semantic meaning of the subject."
}
}
}
}

90
mcp_docs/nav.json Normal file
View File

@@ -0,0 +1,90 @@
[
{
"module": "mail_intake",
"resource": "doc://modules/mail_intake"
},
{
"module": "mail_intake.adapters",
"resource": "doc://modules/mail_intake.adapters"
},
{
"module": "mail_intake.adapters.base",
"resource": "doc://modules/mail_intake.adapters.base"
},
{
"module": "mail_intake.adapters.gmail",
"resource": "doc://modules/mail_intake.adapters.gmail"
},
{
"module": "mail_intake.auth",
"resource": "doc://modules/mail_intake.auth"
},
{
"module": "mail_intake.auth.base",
"resource": "doc://modules/mail_intake.auth.base"
},
{
"module": "mail_intake.auth.google",
"resource": "doc://modules/mail_intake.auth.google"
},
{
"module": "mail_intake.config",
"resource": "doc://modules/mail_intake.config"
},
{
"module": "mail_intake.credentials",
"resource": "doc://modules/mail_intake.credentials"
},
{
"module": "mail_intake.credentials.pickle",
"resource": "doc://modules/mail_intake.credentials.pickle"
},
{
"module": "mail_intake.credentials.redis",
"resource": "doc://modules/mail_intake.credentials.redis"
},
{
"module": "mail_intake.credentials.store",
"resource": "doc://modules/mail_intake.credentials.store"
},
{
"module": "mail_intake.exceptions",
"resource": "doc://modules/mail_intake.exceptions"
},
{
"module": "mail_intake.ingestion",
"resource": "doc://modules/mail_intake.ingestion"
},
{
"module": "mail_intake.ingestion.reader",
"resource": "doc://modules/mail_intake.ingestion.reader"
},
{
"module": "mail_intake.models",
"resource": "doc://modules/mail_intake.models"
},
{
"module": "mail_intake.models.message",
"resource": "doc://modules/mail_intake.models.message"
},
{
"module": "mail_intake.models.thread",
"resource": "doc://modules/mail_intake.models.thread"
},
{
"module": "mail_intake.parsers",
"resource": "doc://modules/mail_intake.parsers"
},
{
"module": "mail_intake.parsers.body",
"resource": "doc://modules/mail_intake.parsers.body"
},
{
"module": "mail_intake.parsers.headers",
"resource": "doc://modules/mail_intake.parsers.headers"
},
{
"module": "mail_intake.parsers.subject",
"resource": "doc://modules/mail_intake.parsers.subject"
}
]

View File

@@ -1,32 +0,0 @@
from pathlib import Path
import json
from mcp.server.fastmcp import FastMCP
MCP_ROOT = Path("mcp")
mcp = FastMCP("aetoskia-mail-intake-docs")
def read_json(path: Path):
if not path.exists():
return {"error": "not_found", "path": str(path)}
return json.loads(path.read_text())
@mcp.resource("docs://index")
def index():
return read_json(MCP_ROOT / "index.json")
@mcp.resource("docs://nav")
def nav():
return read_json(MCP_ROOT / "nav.json")
@mcp.resource("docs://module/{module}")
def module(module: str):
return read_json(MCP_ROOT / "modules" / f"{module}.json")
@mcp.tool()
def ping() -> str:
return "Pong! (fake tool executed)"
if __name__ == "__main__":
# FastMCP owns the HTTP server
mcp.run(transport="streamable-http")

View File

@@ -1,66 +1,94 @@
site_name: Aetoskia Mail Intake
site_description: Format-agnostic document reading, parsing, and scraping framework
theme: theme:
name: material name: material
palette: palette:
- scheme: slate - scheme: slate
primary: deep purple primary: deep purple
accent: cyan accent: cyan
font: font:
text: Inter text: Inter
code: JetBrains Mono code: JetBrains Mono
features: features:
- navigation.tabs - navigation.sections
- navigation.expand - navigation.expand
- navigation.top - navigation.top
- navigation.instant - navigation.instant
- content.code.copy - navigation.tracking
- content.code.annotate - navigation.indexes
- content.code.copy
- content.code.annotate
- content.tabs.link
- content.action.edit
- search.highlight
- search.share
- search.suggest
plugins: plugins:
- search - search
- mkdocstrings: - mkdocstrings:
handlers: handlers:
python: python:
paths: ["."] paths:
options: - .
docstring_style: google options:
show_source: false docstring_style: google
show_signature_annotations: true show_source: false
separate_signature: true show_signature_annotations: true
merge_init_into_class: true separate_signature: true
inherited_members: true merge_init_into_class: true
annotations_path: brief inherited_members: true
show_root_heading: true annotations_path: brief
group_by_category: true show_root_heading: true
group_by_category: true
show_category_heading: true
show_object_full_path: false
show_symbol_type_heading: true
markdown_extensions:
- pymdownx.superfences
- pymdownx.inlinehilite
- pymdownx.snippets
- admonition
- pymdownx.details
- pymdownx.superfences
- pymdownx.highlight:
linenums: true
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.tabbed:
alternate_style: true
- pymdownx.tasklist:
custom_checkbox: true
- tables
- footnotes
- pymdownx.caret
- pymdownx.tilde
- pymdownx.mark
site_name: mail_intake
nav: nav:
- Home: mail_intake/index.md - Home: index.md
- Core API:
- Adapters: - ingestion/index.md
- Base Adapter: mail_intake/adapters/base.md - ingestion/reader.md
- Gmail Adapter: mail_intake/adapters/gmail.md - Domain Models:
- models/index.md
- Auth: - models/message.md
- Base Auth: mail_intake/auth/base.md - models/thread.md
- Google Auth: mail_intake/auth/google.md - Provider Adapters:
- adapters/index.md
- Credentials Store: - adapters/base.md
- Store: mail_intake/credentials/store.md - adapters/gmail.md
- Pickle: mail_intake/credentials/pickle.md - Authentication & Storage:
- Redis: mail_intake/credentials/redis.md - auth/index.md
- auth/base.md
- Mail Reader: mail_intake/ingestion/reader.md - auth/google.md
- credentials/index.md
- Models: - credentials/store.md
- Message: mail_intake/models/message.md - credentials/pickle.md
- Thread: mail_intake/models/thread.md - credentials/redis.md
- Normalization & Parsing:
- Parsers: - parsers/index.md
- Body: mail_intake/parsers/body.md - parsers/body.md
- Headers: mail_intake/parsers/headers.md - parsers/headers.md
- Subject: mail_intake/parsers/subject.md - parsers/subject.md
- Configuration & Errors:
- Config: mail_intake/config.md - config.md
- Exceptions: mail_intake/exceptions.md - exceptions.md

View File

@@ -1,22 +0,0 @@
beautifulsoup4==4.12.0
google-api-python-client==2.187.0
google-auth-oauthlib==1.2.3
types-beautifulsoup4
mcp==1.25.0
mcp-inspector==0.1.0
fastapi
uvicorn
fastmcp
# Test Packages
pytest==7.4.0
pytest-asyncio==0.21.0
pytest-cov==4.1.0
# Doc Packages
mkdocs==1.6.1
mkdocs-material==9.6.23
neoteroi-mkdocs==1.1.3
pymdown-extensions==10.16.1
mkdocstrings[python]==1.0.1
mkdocstrings-python==2.0.1