Skip to main content

Multi-agent system for extracting requirements from data privacy and tech regulation statutes

Project description

TechRegParser

A multi-agent system for extracting requirements from data privacy and tech regulation statutes using the Anthropic Agent SDK.

Features

  • Multi-agent architecture: Specialized agents for different tasks:

    • Statute Reader: Parses statute structure (definitions, applicability, rights, duties, exemptions, enforcement)
    • Section Analyzer: Extracts specific requirements with exact citations
    • Citation Verifier: Validates all citations against the original text
    • Requirement Classifier: Categorizes requirements (disclosure, operational, technical, enforcement)
  • Model Configuration:

    • Orchestrator: Uses Opus for complex coordination
    • Subagents: Use Sonnet for specialized tasks
  • Anti-hallucination measures:

    • Every requirement must have a direct quote from the statute
    • Two-pass verification (extract then verify)
    • Confidence scoring for citations
    • Flagging of unverified requirements
  • Diagnostics and logging:

    • Phase 1 logs section/definition counts on success, or a clear warning on failure
    • Parse failures log the raw agent response details for debugging
  • Statute interpretation skill: Incorporates statutory interpretation guidance from legal experts

  • PDF Support: Can parse both text files and PDFs (with pdfplumber or pypdf)

Installation

# Install from PyPI
pip install techreg-parser

# With PDF support
pip install techreg-parser[pdf]

# Or install locally for development
pip install -e .

Usage

Command Line

# Analyze a statute and output JSON
techreg-parser path/to/statute.txt --output results.json

# Analyze a PDF statute
techreg-parser path/to/statute.pdf --output results.json

# Output markdown report
techreg-parser path/to/statute.txt --output analysis.md --format markdown

# Skip citation verification (faster but less reliable)
techreg-parser path/to/statute.txt --no-verify

Python API

import asyncio
from TechRegParser import TechRegParserOrchestrator, OrchestratorConfig

async def main():
    config = OrchestratorConfig(
        verify_citations=True,
        classify_requirements=True,
    )

    parser = TechRegParserOrchestrator(config=config)

    result = await parser.analyze_statute(
        statute_path="path/to/texas_privacy_law.txt",
        output_format="json"
    )

    # Access results
    for req in result.requirements:
        print(f"Requirement: {req.description}")
        print(f"  Citation: {req.citation.section}")
        print(f"  Category: {req.category.value}")
        print(f"  Verified: {req.verified}")
        print()

    # Export to file
    await parser.export_results(result, "output.json", format="json")

asyncio.run(main())

Architecture

                    +-------------------+
                    |   Orchestrator    |
                    |   (Opus Model)    |
                    +--------+----------+
                             |
        +--------------------+--------------------+
        |           |              |              |
+-------v----+ +----v-----+ +-----v------+ +-----v------+
|  Statute   | | Section  | | Citation   | |Requirement |
|  Reader    | | Analyzer | | Verifier   | | Classifier |
| (Sonnet)   | | (Sonnet) | | (Python)   | | (Sonnet)   |
+------------+ +----------+ +------------+ +------------+

Requirement Categories

  • DISCLOSURE: Must be stated in privacy policy/notice
  • OPERATIONAL: Internal compliance processes (response times, procedures)
  • TECHNICAL: System/UI implementation (GPC signals, security measures, link placement, UI elements)
  • LEGAL FRAMEWORK: Enforcement mechanisms, penalties, AG authority, cure periods

Output

The analysis produces:

  • Requirements: List of all extracted requirements with citations
  • Definitions: All defined terms from the statute
  • Structure: Full statute section tree (IDs, types, titles, line ranges) — included by default in JSON export for the viewer's Structure tab
  • Verification: Status of citation verification
  • Classification: Category for each requirement

Key Principles

Based on lessons from analyzing tech regulation statutes:

  1. Start with definitions sections to anchor interpretation — defined terms control meaning throughout
  2. Separate disclosure requirements from operational and technical requirements
  3. Tech regulation statutes follow predictable architecture (definitions, scope, rights, duties, exemptions, enforcement)
  4. Obligations and defined terms vary across jurisdictions and regulatory domains — never assume uniformity
  5. Work section by section, not requirement by requirement — structure drives accurate extraction
  6. Every extracted requirement must trace back to a specific statutory provision with a verbatim quote

Requirements

  • Python 3.11+
  • Anthropic Agent SDK (claude-agent-sdk)
  • Pydantic 2.0+
  • Optional: pdfplumber or pypdf for PDF support

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

techreg_parser-0.1.0.tar.gz (69.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

techreg_parser-0.1.0-py3-none-any.whl (73.2 kB view details)

Uploaded Python 3

File details

Details for the file techreg_parser-0.1.0.tar.gz.

File metadata

  • Download URL: techreg_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 69.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for techreg_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c7fd2cb449b87fd29dd61137d89b2bb0d62e0576a66958b6660e39bf759cdbd8
MD5 1a4c5ba5045374c38f1441808eea9027
BLAKE2b-256 987a0a1b11d70c478be8c19d741e650be4b9ea0440b8c6db5788d6266a11ebf8

See more details on using hashes here.

File details

Details for the file techreg_parser-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: techreg_parser-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 73.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for techreg_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48e4511b2fa25032a93e4a594c9631c73101913e3755ca99b1110918758af04b
MD5 ac138b149d1fef12ff498d034b514df7
BLAKE2b-256 6c5c5d060cfcd307fbc74b9cbeb258ab52bc2bb053c6316ea911ff3aa9a9db43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page