Metadata-Version: 2.5
Name: mailvault-archiver
Version: 0.1.0
Summary: Local-first, human-approved email and document archiver with verifiable encrypted archives.
Author: Bhavya Gada
License: MIT License
        
        Copyright (c) 2026 Bhavya Gada
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Communications :: Email
Classifier: Topic :: System :: Archiving
Requires-Python: >=3.12
Requires-Dist: cryptography>=43
Requires-Dist: defusedxml>=0.7
Requires-Dist: pypdf>=5
Requires-Dist: pyyaml>=6.0
Requires-Dist: zstandard>=0.23
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: hypothesis>=6; extra == 'dev'
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pip-audit>=2.7; extra == 'dev'
Requires-Dist: pytest-cov>=5; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: types-defusedxml; extra == 'dev'
Requires-Dist: types-pyyaml; extra == 'dev'
Requires-Dist: vulture>=2.11; extra == 'dev'
Description-Content-Type: text/markdown

# mailvault

TL;DR: mailvault reads your email and document exports on your own Mac. It decides what to keep, archive or discard using protective rules and two local AI models. Everything worth archiving goes to your Google Drive folder as an encrypted, signed, verifiable vault. Nothing is ever deleted until you press Enter on that one item, and only after its archive copy has been re-read and checked. No mail content leaves your machine.

```mermaid
flowchart LR
  X[Takeout · IMAP · Outlook · Apple Mail · Drive/Office] --> R[rules + dedupe] --> AI[local AI, two tiers] --> G[PolicyGate]
  G -->|keep| K[stays where it is]
  G -->|archive / discard| V[(encrypted vault in Drive)]
  V --> Rev[mailvault review: you approve each deletion]
```

## Promises

1. **Never deletes without your approval.** Only `mailvault review` deletes, one item at a time, after Enter. There is no batch-delete option.
2. **Archive before delete, verified.** An item can be deleted only once its archive copy has been written, checksummed, re-read and hash-matched.
3. **Uncertain means keep.** Low confidence, model errors and unreadable files all mean the item stays.
4. **Protected categories are never touched by AI.** Banking, tax, immigration, legal, medical, government ID, employment, insurance, property and your own keep rules.
5. **Your data stays local.** The models run on your Mac (Ollama). Logs and reports hold opaque keys and hashes only.

## Quickstart

TL;DR: install, create keys, write a config, dry-run, run, then review.

```bash
pipx install mailvault-archiver            # or: uv tool install mailvault-archiver
mailvault --help
mailvault init-keys                         # keys in ~/.mailvault/keys; store RECOVERY.md offline
ollama pull qwen2.5:14b && ollama pull llama3.3:70b   # optional; without them everything is kept
```

Create `~/.mailvault/config.yaml` (it names real paths, so keep it out of any repo):

```yaml
operator: Your Name
user_addresses: [you@example.com]
state_dir: ~/.mailvault/state
archive_root: ~/Google Drive/My Drive/mailvault     # a Drive for desktop folder
tsa_url: http://timestamp.digicert.com              # optional RFC 3161 timestamps (hash only)
sources:
  - {name: gmail-takeout, kind: mbox, path: ~/Takeout/Mail, account: personal}
  - {name: drive-docs, kind: documents, path: ~/Google Drive/My Drive/Documents, account: personal}
```

```bash
mailvault run --config ~/.mailvault/config.yaml --dry-run    # decide only, write nothing
mailvault run --config ~/.mailvault/config.yaml              # archive, verify, queue for review
mailvault search "invoice" --config ~/.mailvault/config.yaml --after 2021-01-01
mailvault review --config ~/.mailvault/config.yaml --dry-run
mailvault review --config ~/.mailvault/config.yaml           # Enter deletes the one item shown
mailvault verify --archive "~/Google Drive/My Drive/mailvault" --key-dir ~/.mailvault/keys
mailvault restore ITEM_KEY --archive "~/Google Drive/My Drive/mailvault" --out ~/restored
```

An interrupted `run` resumes when you run it again (`--fresh` starts over).

## Sources

| kind | reads | deletion after approval |
|---|---|---|
| `mbox` | Google Takeout `.mbox` file or `Mail/` folder; any mbox | appended to a Gmail worklist of search links you delete by hand |
| `imap` | any IMAP account, read-only, app password in the macOS Keychain | optional (`allow_delete: true`): moved to that account's Trash |
| `olm` | Outlook for Mac export (`.pst`: convert with `readpst` to mbox) | by hand, or through an IMAP source |
| `applemail` | `~/Library/Mail` `.emlx` files | by hand, or through an IMAP source |
| `documents` | Google Drive, OneDrive or any folder: PDF, Word, Excel, PowerPoint, text | moved to `<state_dir>/trash/`, never unlinked |

Details: `knowledge/connectors/`. How decisions are made: `knowledge/pipelines/classification.md`. What the archive proves, and what it does not: `knowledge/architecture/archive.md`. The archive is forensically sound and tamper-evident, but it is not a legal certification.

## Development

TL;DR: strict TDD, 100% coverage, every decision an ADR. See `CLAUDE.md`.

```bash
uv venv --python 3.12 .venv && uv pip install --python .venv/bin/python -e ".[dev]"
.venv/bin/python -m pytest --cov
.venv/bin/python -m mailvault.devtools demo --out /tmp/mailvault-demo     # whole lifecycle on synthetic data
.venv/bin/python -m mailvault.devtools artifacts --out artifacts/local
```

MIT licensed. Distribution name `mailvault-archiver`; the import and the command are `mailvault`.
