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.1.tar.gz (69.2 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.1-py3-none-any.whl (73.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: techreg_parser-0.1.1.tar.gz
  • Upload date:
  • Size: 69.2 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.1.tar.gz
Algorithm Hash digest
SHA256 0f57d8e4d917be940efdcc3f56855fadee0247f9a5f07abdd1e547a8fc9acaf2
MD5 8571a537c4b9e723ffb249430da70c00
BLAKE2b-256 6c54a2e3c834764d8547d558966262058ff0d596b4265a4b56a836e534de3827

See more details on using hashes here.

File details

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

File metadata

  • Download URL: techreg_parser-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 73.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8b0873e921e1b552470fc9809f152aa0881d22a935bd688fe9a4a1040051213
MD5 7f2816a124d2e6077f0604c1b4cffbc4
BLAKE2b-256 6717d30fb6f0d20a9b0b3df3ed62c7b3ae4004cd3b11f9d7e0c5a878d9a590f8

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