Build the inbound-library core: store, IMAP intake, registries, notices.
ILIB-WP-0002-T01..T06: append-only item store, read-only IMAP intake with quarantine, file-backed registries, idempotent hub/pull/digest notices, run-due with health and the systemd user timer. 14 tests pass. Registers the intelligence topics and the intelligence-radar subscription. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 1170398@bnt-lap001 Assistant-Session: 622cd705-cb31-4322-ba08-dd42e44fa583
This commit is contained in:
parent
fe84482730
commit
d05d6ed35b
18 changed files with 1168 additions and 6 deletions
38
tools/demo.py
Normal file
38
tools/demo.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
"""Run intake, matching, notices and digests on synthetic mail in a temp root."""
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
from email.message import EmailMessage
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
from inbound_library import intake, notify # noqa: E402
|
||||
from inbound_library.__main__ import run_due # noqa: E402
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
(root / 'registry' / 'sources').mkdir(parents=True)
|
||||
(root / 'registry' / 'subscriptions').mkdir()
|
||||
(root / 'registry' / 'topics.json').write_text(json.dumps(
|
||||
{'version': 1, 'topics': {'demo.brief': 'Synthetic brief'}}))
|
||||
(root / 'registry' / 'sources' / 'demo-sender.json').write_text(json.dumps({
|
||||
'id': 'demo-sender', 'owner_repo': 'demo', 'channel': 'email',
|
||||
'match': {'from': 'brief@demo.test'}, 'topics': ['demo.brief'],
|
||||
'cadence': 'daily', 'visibility': 'shared'}))
|
||||
(root / 'registry' / 'subscriptions' / 'demo.json').write_text(json.dumps({
|
||||
'repo': 'demo', 'agent': 'demo', 'topics': ['demo.brief'],
|
||||
'channels': ['hub', 'pull', 'digest'], 'cadence': 'daily'}))
|
||||
mail = root / 'mail'
|
||||
mail.mkdir()
|
||||
for n, sender in enumerate(['brief@demo.test', 'stranger@demo.test'], 1):
|
||||
message = EmailMessage()
|
||||
message['From'], message['Subject'] = sender, f'Synthetic message {n}'
|
||||
message['Message-ID'] = f'<demo-{n}@demo.test>'
|
||||
message.set_content(f'Synthetic body {n}.')
|
||||
(mail / f'{n}.eml').write_bytes(message.as_bytes())
|
||||
sent = []
|
||||
report = run_due(root, {}, mailbox=intake.DirectoryMailbox(mail),
|
||||
post=lambda base, payload: sent.append(payload))
|
||||
print(json.dumps(report, indent=2))
|
||||
print('\nHub message (not sent):\n' + sent[0]['body'])
|
||||
print('\nHealth:\n' + json.dumps(notify.health(root), indent=2))
|
||||
Loading…
Add table
Add a link
Reference in a new issue