Skip to main content

RMACD Framework SDK - Policy evaluation for autonomous AI agents

Project description

RMACD Framework Python SDK

Reference implementation for the RMACD (Read, Move, Add, Change, Delete) Framework — a governance model for autonomous AI agents. The SDK supports all three model variants:

  • 3D (default) — Operations × Data Classification × Autonomy
  • 2D Operational — Operations × Autonomy (no data classification)
  • 2D Data-Classification (DC2D) — Data Classification × Autonomy (no operations axis; for orgs whose primary governance lever is data sensitivity, with operations governed by an upstream IAM/RBAC or DLP layer). See spec Appendix D.

Installation

# From PyPI
pip install rmacd-framework

# Or from source
git clone https://github.com/rmacdframework/spec.git
cd spec/sdk/python
pip install -e .

# Or using uv
uv pip install rmacd-framework

The distribution name on PyPI is rmacd-framework; the import name remains rmacd (from rmacd import ...).

Quick Start

Loading and Evaluating Profiles

from rmacd import ProfileLoader, PolicyEvaluator

# Load a profile
loader = ProfileLoader()
profile = loader.load_file("profiles/devops-agent.json")

# Create evaluator
evaluator = PolicyEvaluator(profile)

# Evaluate a policy decision (3D profile)
decision = evaluator.evaluate(
    operation="C",  # Change
    data_classification="internal",
)

print(f"Allowed: {decision.allowed}")
print(f"Autonomy Level: {decision.autonomy_level}")
print(f"Requires Approval: {decision.requires_approval}")

DC2D Profiles (Data-Classification × Autonomy)

from rmacd import (
    AutonomyLevel,
    DataAccess,
    PolicyEvaluator,
    ProfileDC2D,
    TierPolicy,
)

profile = ProfileDC2D(
    profile_id="rmacd-dc2d-support-agent-v1",
    profile_name="Support Agent",
    model="data-classification-2d",
    version="1.0",
    data_access=DataAccess(
        public=TierPolicy(allowed=True, autonomy=AutonomyLevel.AUTONOMOUS),
        internal=TierPolicy(allowed=True, autonomy=AutonomyLevel.LOGGED),
        confidential=TierPolicy(allowed=True, autonomy=AutonomyLevel.APPROVAL),
        restricted=TierPolicy(allowed=False, autonomy=AutonomyLevel.PROHIBITED),
    ),
)
evaluator = PolicyEvaluator(profile)

# DC2D requires data_classification; operation is informational only
decision = evaluator.evaluate(operation="R", data_classification="confidential")
print(decision.allowed)            # True
print(decision.autonomy_level)     # AutonomyLevel.APPROVAL
print(decision.requires_approval)  # True

Validating Profiles

from rmacd import ProfileValidator
from rmacd.validator import SchemaValidationError

# Uses the JSON schemas bundled with the package by default;
# pass schema_dir="path/to/schemas" to validate against other copies.
validator = ProfileValidator()

# Validate a profile file
try:
    validator.validate_file("my-profile.json")
    print("Profile is valid!")
except SchemaValidationError as e:
    print(f"Validation failed: {e.errors}")

# Check validity without exceptions
if validator.is_valid("my-profile.json"):
    print("Valid!")

Emergency Escalation

from rmacd import ProfileLoader, PolicyEvaluator
from rmacd.models import EvaluationContext, TriggerCondition

loader = ProfileLoader()
profile = loader.load_file("incident-responder.json")
evaluator = PolicyEvaluator(profile)

# Evaluate with emergency escalation active
context = EvaluationContext(
    emergency_active=True,
    emergency_trigger=TriggerCondition.SOC_DECLARED_INCIDENT,
)

decision = evaluator.evaluate(
    operation="C",
    data_classification="confidential",
    context=context,
)

print(f"Emergency mode: {decision.emergency_mode}")

CLI Usage

The SDK includes a command-line interface for common operations.

Validate Profiles

# Validate single profile
rmacd validate profiles/devops-agent.json

# Validate multiple profiles
rmacd validate profiles/*.json

# Quiet mode (errors only)
rmacd validate -q profiles/*.json

Evaluate Policy Decisions

# Evaluate operation on 3D profile
rmacd evaluate profiles/devops.json C --classification internal

# With emergency escalation
rmacd evaluate profiles/incident-responder.json C -c confidential --emergency

# JSON output
rmacd evaluate profiles/devops.json R -c public --json

Display Profile Information

# Show profile info
rmacd info profiles/devops.json

# JSON output
rmacd info profiles/devops.json --json

View Autonomy Matrix

# Display effective autonomy matrix
rmacd matrix profiles/devops.json

# JSON output
rmacd matrix profiles/devops.json --json

Tools Registry

The SDK includes a Tools Registry for managing and validating AI agent tool access.

Creating a Registry

from rmacd.registry import ToolsRegistry, quick_register

# Create registry
registry = ToolsRegistry("my-organization")

# Register tools
quick_register(
    registry,
    tool_id="database_query",
    tool_name="Database Query",
    rmacd_level="R",
    description="Execute read-only database queries",
    data_access="confidential",
    required_hitl="logged"
)

# Validate agent access
is_allowed, reason = registry.validate_tool_access(
    tool_id="database_query",
    allowed_levels=["R", "M"],
    data_tier="confidential"
)

print(f"Allowed: {is_allowed} - {reason}")

Risk Assessment

# Calculate workflow risk
workflow_tools = ["github_commit", "kubernetes_deploy", "slack_notify"]
risk = registry.calculate_workflow_risk(workflow_tools)

print(f"Total Risk: {risk['total_risk']}/10")
print(f"Highest RMACD: {risk['highest_rmacd']}")

MCP Integration

from rmacd.registry import MCPTool, MCPRegistryBridge

# Create MCP bridge
bridge = MCPRegistryBridge("mcp-demo")

# Register MCP tool with auto-classification
mcp_tool = MCPTool(
    name="filesystem-read",
    description="Read files from the filesystem",
    inputSchema={"type": "object", "properties": {"path": {"type": "string"}}},
    operations=["read", "list"]
)
bridge.register_mcp_tool(mcp_tool)

# Check agent access
allowed, reason = bridge.can_agent_use_tool(
    "filesystem-read",
    agent_permissions=["R", "M"],
    agent_data_tier="internal"
)

Export/Import

# Export registry to JSON
registry.export_to_json("tools_catalog.json")

# Import tools from JSON
new_registry = ToolsRegistry("imported")
new_registry.import_from_json("tools_catalog.json")

Models

Profile Types

  • Profile2D: Two-dimensional profile (operations + autonomy, no data classification)
  • Profile3D: Three-dimensional profile (operations + data classification + autonomy)
  • ProfileDC2D: Data-classification 2D profile (data classification + autonomy, no operations axis)

Core Enums

  • Operation: R (Read), M (Move), A (Add), C (Change), D (Delete)
  • DataClassification: public, internal, confidential, restricted
  • AutonomyLevel: autonomous, logged, notification, approval, elevated_approval, prohibited

Policy Decision

The PolicyDecision Pydantic model contains:

class PolicyDecision(BaseModel):
    allowed: bool                    # Whether operation is permitted
    operation: Operation             # The evaluated operation
    data_classification: DataClassification | None
    autonomy_level: AutonomyLevel    # Required autonomy level
    requires_approval: bool          # Whether human approval needed
    requires_notification: bool      # Whether notification required
    blocked_reason: str | None       # Reason if blocked
    constraints_applied: list[str]   # Constraints that were checked
    emergency_mode: bool             # Whether emergency escalation active

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy rmacd

# Linting
ruff check rmacd

License

This work is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Links

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

rmacd_framework-0.9.1.tar.gz (80.2 kB view details)

Uploaded Source

Built Distribution

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

rmacd_framework-0.9.1-py3-none-any.whl (76.9 kB view details)

Uploaded Python 3

File details

Details for the file rmacd_framework-0.9.1.tar.gz.

File metadata

  • Download URL: rmacd_framework-0.9.1.tar.gz
  • Upload date:
  • Size: 80.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rmacd_framework-0.9.1.tar.gz
Algorithm Hash digest
SHA256 166cbd083a14be188f3eb9c1bf6023a7e939ca1ee7c84b5c565f3b9c9d8260d5
MD5 bb0c98244018df1a1efba316925ba72c
BLAKE2b-256 3f13de26c25655c92e5e468ed0edab7b814a1c4a221e56b1b2462e3b6dd484eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for rmacd_framework-0.9.1.tar.gz:

Publisher: publish-sdk.yml on rmacdframework/spec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rmacd_framework-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: rmacd_framework-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 76.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rmacd_framework-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6dd96edf3bfd5d82df3174800e581ce1a2bd95cf92dd1f0fdaa7f7662b98fe17
MD5 088a7ba6f354d6421d3b595c11876f82
BLAKE2b-256 a9e724ef608f3b1f216bda1300a8e845c97e37252f405b995e80cca1c535748f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rmacd_framework-0.9.1-py3-none-any.whl:

Publisher: publish-sdk.yml on rmacdframework/spec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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