Implementation:AI4Finance Foundation FinGPT Mandate Models
| Knowledge Sources | |
|---|---|
| Domains | Database, Fintech_Infrastructure, Authorization |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
Concrete tool for persisting the mandate delegation and authority layer (Principal → Mandate → MandateEvent) as SQLAlchemy models provided by the Finogrid platform within FinGPT.
Description
The mandate module defines the core authorization primitive of the Finogrid platform. Every agent action must be traceable to a valid, active Mandate granted by a Principal. A Mandate is immutable once activated; changes require supersession (new mandate + old archived). Scope defines corridors, assets, counterparties, amount caps, and approval thresholds. The module defines enums for `MandateStatus`, `MandateScope`, `ApprovalMode`, and `MandateEventType`.
Usage
Import these models when you need to create, query, or audit agent authorization mandates within the Finogrid platform. Every money movement must reference a valid Mandate at execution time.
Code Reference
Source Location
- Repository: AI4Finance_Foundation_FinGPT
- File: finogrid/database/models/mandate.py
- Lines: 1-249
Signature
class MandateStatus(str, PyEnum):
DRAFT = "draft"; ACTIVE = "active"; SUSPENDED = "suspended"
REVOKED = "revoked"; EXPIRED = "expired"; SUPERSEDED = "superseded"
class MandateScope(str, PyEnum):
PAYOUT = "payout"; COLLECT = "collect"; TOPUP = "topup"
FULL = "full"; READ_ONLY = "read_only"
class ApprovalMode(str, PyEnum):
AUTO = "auto"; MANUAL = "manual"; THRESHOLD = "threshold"
class MandateEventType(str, PyEnum):
CREATED = "created"; ACTIVATED = "activated"; SUSPENDED = "suspended"
RESUMED = "resumed"; REVOKED = "revoked"; EXPIRED = "expired"
SUPERSEDED = "superseded"; LIMIT_HIT = "limit_hit"
class Principal(Base, UUIDMixin, TimestampMixin):
__tablename__ = "principals"
name: Mapped[str]
email: Mapped[Optional[str]]
client_id: Mapped[Optional[uuid.UUID]]
status: Mapped[str]
kyb_status: Mapped[str]
class Mandate(Base, UUIDMixin, TimestampMixin):
__tablename__ = "mandates"
principal_id: Mapped[uuid.UUID]
agent_account_id: Mapped[uuid.UUID]
scope: Mapped[MandateScope]
status: Mapped[MandateStatus]
approval_mode: Mapped[ApprovalMode]
# ... amount caps, corridors, expires_at, etc.
class MandateEvent(Base, UUIDMixin, TimestampMixin):
__tablename__ = "mandate_events"
# Append-only audit trail of mandate lifecycle changes
Import
from finogrid.database.models.mandate import (
Principal, Mandate, MandateEvent,
MandateStatus, MandateScope, ApprovalMode, MandateEventType,
)
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| principal_id | uuid.UUID | Yes | FK to principals table |
| agent_account_id | uuid.UUID | Yes | FK to agent_accounts table |
| scope | MandateScope | Yes | What the agent may do (payout/collect/topup/full/read_only) |
| approval_mode | ApprovalMode | Yes | auto / manual / threshold |
| expires_at | datetime | No | Mandate expiry timestamp |
Outputs
| Name | Type | Description |
|---|---|---|
| Mandate instance | SQLAlchemy mapped object | Persistent authorization record |
| MandateEvent instance | SQLAlchemy mapped object | Append-only audit trail entry |
Usage Examples
Grant a Payout Mandate to an Agent
import uuid
from datetime import datetime, timezone, timedelta
from finogrid.database.models.mandate import (
Principal, Mandate, MandateEvent, MandateStatus,
MandateScope, ApprovalMode, MandateEventType,
)
from sqlalchemy.orm import Session
with Session(engine) as session:
# 1. Create or find the principal
principal = Principal(name="Acme Corp", kyb_status="verified")
session.add(principal)
session.flush()
# 2. Grant a payout mandate valid for 90 days
mandate = Mandate(
principal_id=principal.id,
agent_account_id=agent_id,
scope=MandateScope.PAYOUT,
status=MandateStatus.ACTIVE,
approval_mode=ApprovalMode.AUTO,
expires_at=datetime.now(timezone.utc) + timedelta(days=90),
)
session.add(mandate)
session.flush()
# 3. Record the activation event
event = MandateEvent(
mandate_id=mandate.id,
event_type=MandateEventType.ACTIVATED,
)
session.add(event)
session.commit()
print(f"Activated mandate {mandate.id}")