GovernedAgentBase

GovernedAgentBase is the foundation class for building governed agents. It wraps GovernanceRuntime with a simpler interface and provides the govern-execute-validate lifecycle.

Installation

pip install nomotic

Data Classes

GovResult

Returned by govern_action():

@dataclass
class GovResult:
    verdict: str      # "ALLOW", "DENY", "ESCALATE", "BLOCK"
    ucs_score: float  # 0.0–1.0 Unified Compliance Score
    record_id: str    # Audit trail record ID
    allowed: bool     # True only for "ALLOW"

OutputResult

Returned by validate_output():

@dataclass
class OutputResult:
    verdict: str       # Output validation verdict
    output: str        # Original or redacted output
    redacted: bool     # True if output was modified

GovernanceVetoError

Raised by governed_run() when the verdict is DENY or BLOCK:

Constructor

Methods

govern_action()

Pre-action governance evaluation. Does not raise on DENY — check result.allowed.

validate_output()

Post-generation output validation via the OutputGovernor (if configured):

governed_run()

Full governance lifecycle: govern, execute, validate. Raises GovernanceVetoError on DENY or BLOCK.

Complete Example

Last updated