Stores AgentIdentity records. One identity per agent_id. Not linked to sys_user (org-scoped, not user-scoped).
| 29 | |
| 30 | |
| 31 | class AgentIdentityModel(BaseModel): |
| 32 | """ |
| 33 | Stores AgentIdentity records. |
| 34 | One identity per agent_id. Not linked to sys_user (org-scoped, not user-scoped). |
| 35 | """ |
| 36 | |
| 37 | __tablename__: str = "sys_orgkernel_agent_identity" |
| 38 | __table_args__ = ( |
| 39 | Index("idx_identity_org_id", "org_id"), |
| 40 | Index("idx_identity_agent_name", "agent_name"), |
| 41 | Index("idx_identity_status", "identity_status"), |
| 42 | {"comment": "OrgKernel AgentIdentity — cryptographic org credentials for AI agents"}, |
| 43 | ) |
| 44 | |
| 45 | agent_id: Mapped[str] = mapped_column( |
| 46 | String(32), primary_key=True, comment="aid_ prefixed global ID" |
| 47 | ) |
| 48 | agent_name: Mapped[str] = mapped_column( |
| 49 | String(64), nullable=False, index=True, |
| 50 | comment="Human-readable agent name, unique per org", |
| 51 | ) |
| 52 | org_id: Mapped[str] = mapped_column( |
| 53 | String(64), nullable=False, index=True, |
| 54 | comment="Org tenant identifier", |
| 55 | ) |
| 56 | issued_by: Mapped[str] = mapped_column( |
| 57 | String(64), nullable=False, |
| 58 | comment="Org unit that authorized issuance", |
| 59 | ) |
| 60 | public_key: Mapped[str] = mapped_column( |
| 61 | Text, nullable=False, |
| 62 | comment="Ed25519 public key, Base64url encoded", |
| 63 | ) |
| 64 | org_ca_fingerprint: Mapped[str] = mapped_column( |
| 65 | String(64), nullable=False, |
| 66 | comment="SHA-256 fingerprint of signing Org CA", |
| 67 | ) |
| 68 | issued_at: Mapped[datetime] = mapped_column( |
| 69 | DateTime, nullable=False, |
| 70 | comment="UTC timestamp of issuance", |
| 71 | ) |
| 72 | valid_until: Mapped[datetime | None] = mapped_column( |
| 73 | DateTime, nullable=True, |
| 74 | comment="UTC expiry, null = no expiry", |
| 75 | ) |
| 76 | identity_status: Mapped[str] = mapped_column( |
| 77 | String(16), nullable=False, default="ACTIVE", index=True, |
| 78 | comment="ACTIVE | SUSPENDED | REVOKED | EXPIRED", |
| 79 | ) |
| 80 | revoked_at: Mapped[datetime | None] = mapped_column( |
| 81 | DateTime, nullable=True, |
| 82 | comment="UTC revocation timestamp", |
| 83 | ) |
| 84 | revoked_by: Mapped[str | None] = mapped_column( |
| 85 | String(64), nullable=True, |
| 86 | comment="Identity that revoked this credential", |
| 87 | ) |
| 88 | revocation_reason: Mapped[str | None] = mapped_column( |