|
1 | 1 | # Regulatory Monitoring Pipeline |
2 | 2 |
|
3 | 3 | A multi-agent system that monitors regulatory changes across jurisdictions |
4 | | -(RBI, SEBI, FDA, EU AI Act, and more), determines business impact, assigns |
5 | | -risk, and generates actionable follow-ups for the right teams. |
| 4 | +(RBI, SEBI, FDA, EU AI Act), determines business impact, assigns risk, and |
| 5 | +generates actionable follow-ups for the right teams — always with a |
| 6 | +human-in-the-loop approval gate. |
6 | 7 |
|
7 | | -> Status: early development. This commit establishes project scaffolding and |
8 | | -> tooling. Functionality lands incrementally over subsequent commits. |
9 | | -
|
10 | | -## Why |
11 | | - |
12 | | -Compliance teams cannot manually track every circular, guideline, and rule |
13 | | -change across regulators. This pipeline automates the tedious parts - |
14 | | -collection, cleaning, deduplication, summarization - and augments human |
15 | | -judgment for the parts that matter: impact analysis, risk assessment, and |
16 | | -action planning, always with a human-in-the-loop approval gate. |
17 | | - |
18 | | -## Architecture (target) |
| 8 | +## Architecture |
19 | 9 |
|
20 | 10 | ``` |
21 | | -Crawler Agent |
22 | | - -> Document Parser |
23 | | - -> Classification Agent |
24 | | - -> RAG Search |
25 | | - -> Risk Assessment Agent |
26 | | - -> Action Planner |
27 | | - -> Notification Agent |
| 11 | +┌─────────────────────────────────────────────────────────────────────┐ |
| 12 | +│ Pipeline Orchestrator │ |
| 13 | +│ │ |
| 14 | +│ ┌──────────┐ ┌────────┐ ┌───────────┐ ┌──────────────────┐ │ |
| 15 | +│ │ Crawler │──>│ Parser │──>│ Normalizer│──>│ Deduplication │ │ |
| 16 | +│ │ Agent │ │ Agent │ │ │ │ Engine │ │ |
| 17 | +│ └──────────┘ └────────┘ └───────────┘ └────────┬─────────┘ │ |
| 18 | +│ │ │ │ |
| 19 | +│ │ (adapters: RBI, SEBI, FDA, EU) unique docs │ │ |
| 20 | +│ │ ▼ │ |
| 21 | +│ ┌──────────┐ ┌────────────┐ ┌──────────┐ ┌──────────────┐ │ |
| 22 | +│ │ Notifier │<──│ Approval │<──│ Action │<──│ Risk │ │ |
| 23 | +│ │ Agent │ │ Gate (HITL)│ │ Planner │ │ Assessment │ │ |
| 24 | +│ └──────────┘ └────────────┘ └──────────┘ └──────┬───────┘ │ |
| 25 | +│ │ │ │ |
| 26 | +│ │ (Slack, Email) │ │ |
| 27 | +│ │ ┌──────────────┴───────┐ │ |
| 28 | +│ │ │ Classification Agent │ │ |
| 29 | +│ │ │ + Summarization │ │ |
| 30 | +│ │ │ + RAG Indexing │ │ |
| 31 | +│ │ └──────────────────────┘ │ |
| 32 | +│ │ │ |
| 33 | +│ ┌────┴────────────────────────────────────────────────────────┐ │ |
| 34 | +│ │ Cross-cutting: SQLite/Postgres DB │ │ |
| 35 | +│ │ Document Store │ Audit Log │ Pipeline Memory │ Approvals │ │ |
| 36 | +│ └─────────────────────────────────────────────────────────────┘ │ |
| 37 | +└─────────────────────────────────────────────────────────────────────┘ |
28 | 38 | ``` |
29 | 39 |
|
30 | | -Cross-cutting concerns: long-term memory, scheduling, human approval, and an |
31 | | -append-only audit log. |
32 | | - |
33 | | -## Project layout |
34 | | - |
35 | | -``` |
36 | | -regulatory_monitoring_pipeline/ |
37 | | -├── src/regmon/ # application package (src layout) |
38 | | -│ ├── __init__.py |
39 | | -│ └── logging_config.py # structured logging setup |
40 | | -├── tests/ # test suite |
41 | | -├── pyproject.toml # build config, dependencies, tooling |
42 | | -├── requirements.txt # runtime deps |
43 | | -├── requirements-dev.txt # dev/test deps |
44 | | -├── .env.example # configuration template |
45 | | -├── .pre-commit-config.yaml |
46 | | -├── Makefile |
47 | | -└── README.md |
48 | | -``` |
49 | | - |
50 | | -## Quickstart |
| 40 | +## Supported Jurisdictions |
| 41 | + |
| 42 | +| Jurisdiction | Regulator | Sources | |
| 43 | +|-------------|-----------|---------| |
| 44 | +| RBI | Reserve Bank of India | Notifications, Press Releases | |
| 45 | +| SEBI | Securities and Exchange Board of India | Legal Circulars | |
| 46 | +| FDA | U.S. Food and Drug Administration | Press RSS, Federal Register | |
| 47 | +| EU AI Act | European Commission | AI Act Newsroom | |
| 48 | + |
| 49 | +## Features |
| 50 | + |
| 51 | +- **Async crawler** with per-host rate limiting, robots.txt respect, retry/backoff |
| 52 | +- **Source adapters** per regulator (HTML listing + RSS/Atom feed parsing) |
| 53 | +- **Document parser** supporting HTML and PDF (via `pypdf`) |
| 54 | +- **Content normalization** — encoding repair, boilerplate stripping, language detection |
| 55 | +- **Deduplication** — exact (SHA-256) + near-duplicate (SimHash) across crawl runs |
| 56 | +- **Embeddings + vector search** — chunking, mock/OpenAI embeddings, in-memory/FAISS/Chroma stores |
| 57 | +- **RAG search service** with citations, jurisdiction filtering, score thresholding |
| 58 | +- **Classification agent** — rule-based topic/function/urgency tagging |
| 59 | +- **Summarization** — structured LLM summaries (mock offline + OpenAI) |
| 60 | +- **Risk assessment** — weighted scoring (urgency, keywords, scope, penalties) + RAG context |
| 61 | +- **Action planner** — generates owner-assigned, deadline-driven follow-up items |
| 62 | +- **Human-in-the-loop approval** — risk-threshold gate with persisted decisions |
| 63 | +- **Notifications** — Slack webhook + SMTP email with digest formatting and alert dedup |
| 64 | +- **Pipeline orchestrator** — full graph wiring with persistent run memory |
| 65 | +- **Scheduler + CLI** — `regmon run|backfill|status|sources` commands |
| 66 | +- **Append-only audit log** across all pipeline events |
| 67 | + |
| 68 | +## Quick Start |
51 | 69 |
|
52 | 70 | ```bash |
53 | 71 | # 1. Create and activate a virtual environment |
54 | 72 | python -m venv .venv |
55 | 73 | . .venv/Scripts/activate # Windows |
56 | 74 | # source .venv/bin/activate # macOS / Linux |
57 | 75 |
|
58 | | -# 2. Install (with dev tooling) |
| 76 | +# 2. Install with dev tooling |
59 | 77 | pip install -e ".[dev]" |
60 | 78 |
|
61 | 79 | # 3. Configure |
62 | 80 | cp .env.example .env |
63 | 81 |
|
64 | | -# 4. Install git hooks |
65 | | -pre-commit install |
66 | | - |
67 | | -# 5. Run checks |
| 82 | +# 4. Run checks |
68 | 83 | make lint |
69 | 84 | make test |
| 85 | + |
| 86 | +# 5. Run the pipeline |
| 87 | +regmon sources # list configured sources |
| 88 | +regmon run # one-shot pipeline run |
| 89 | +regmon run --loop --interval 60 # continuous mode |
| 90 | +regmon status # check pipeline state |
| 91 | +regmon backfill # re-process ignoring dedup |
70 | 92 | ``` |
71 | 93 |
|
72 | | -## Make targets |
| 94 | +## Project Layout |
73 | 95 |
|
74 | | -| Target | Description | |
75 | | -| ------------- | ---------------------------------------- | |
76 | | -| `make install`| Install package with dev dependencies | |
77 | | -| `make lint` | Run ruff + black (check) + mypy | |
78 | | -| `make format` | Auto-format with black + ruff --fix | |
79 | | -| `make test` | Run the test suite | |
80 | | -| `make hooks` | Install pre-commit hooks | |
81 | | -| `make clean` | Remove caches and build artifacts | |
| 96 | +``` |
| 97 | +src/regmon/ |
| 98 | +├── __init__.py, __main__.py, cli.py, scheduler.py |
| 99 | +├── config/ # Settings, secrets, source registry |
| 100 | +├── models/ # Pydantic domain models and enums |
| 101 | +├── crawler/ # Async fetcher, rate limiter, robots.txt, adapters |
| 102 | +├── parser/ # HTML/PDF extraction, metadata (dates, ref numbers) |
| 103 | +├── normalize/ # Encoding repair, boilerplate strip, language detect |
| 104 | +├── dedup/ # Content hashing, SimHash near-duplicate engine |
| 105 | +├── embeddings/ # Chunking, providers, vector stores, indexer |
| 106 | +├── rag/ # Semantic search service with citations |
| 107 | +├── classification/ # Rule-based + LLM topic/function classifier |
| 108 | +├── summarization/ # Structured LLM summaries (mock + OpenAI) |
| 109 | +├── risk/ # Risk scoring, rationale, assessment agent |
| 110 | +├── actions/ # Action planner with templates and due dates |
| 111 | +├── approval/ # Human-in-the-loop gate with persisted decisions |
| 112 | +├── notifications/ # Slack/email channels, digest formatting, dedup |
| 113 | +├── pipeline/ # Orchestrator, state tracking, run context |
| 114 | +└── db/ # SQLAlchemy engine, document store, audit log |
| 115 | +tests/ # Unit + integration test suite |
| 116 | +.github/workflows/ # CI pipeline (lint, test matrix, integration) |
| 117 | +``` |
82 | 118 |
|
83 | 119 | ## Configuration |
84 | 120 |
|
85 | 121 | All settings are read from environment variables (see `.env.example`). The |
86 | 122 | pipeline ships with `mock` LLM and embedding providers so it runs fully |
87 | | -offline by default, and a `REGMON_DRY_RUN` flag that disables outbound |
88 | | -notifications during development. |
| 123 | +offline by default. Set `REGMON_DRY_RUN=true` to suppress outbound notifications. |
| 124 | + |
| 125 | +### Optional Extras |
| 126 | + |
| 127 | +```bash |
| 128 | +pip install -e ".[faiss]" # FAISS vector store backend |
| 129 | +pip install -e ".[chroma]" # Chroma vector store backend |
| 130 | +pip install -e ".[openai]" # OpenAI embeddings + LLM |
| 131 | +``` |
| 132 | + |
| 133 | +## Testing |
| 134 | + |
| 135 | +```bash |
| 136 | +make test # unit tests |
| 137 | +pytest -m integration # integration tests |
| 138 | +pytest --cov=regmon # with coverage |
| 139 | +``` |
| 140 | + |
| 141 | +The test suite uses in-memory SQLite and `httpx.MockTransport` so no external |
| 142 | +services are needed. Integration tests are marked with `@pytest.mark.integration`. |
89 | 143 |
|
90 | | -## Roadmap |
| 144 | +## Make Targets |
91 | 145 |
|
92 | | -This project is built across 20 incremental commits, from scaffolding through |
93 | | -ingestion, storage/RAG, the agent layer, orchestration, and hardening. See the |
94 | | -commit history for the full progression. |
| 146 | +| Target | Description | |
| 147 | +|--------|-------------| |
| 148 | +| `make install` | Install package with dev dependencies | |
| 149 | +| `make lint` | Run ruff + black (check) + mypy | |
| 150 | +| `make format` | Auto-format with black + ruff --fix | |
| 151 | +| `make test` | Run the test suite | |
| 152 | +| `make test-cov` | Run tests with coverage report | |
| 153 | +| `make hooks` | Install pre-commit hooks | |
| 154 | +| `make clean` | Remove caches and build artifacts | |
95 | 155 |
|
96 | 156 | ## License |
97 | 157 |
|
|
0 commit comments