Stores AuditChain metadata. One chain per Mission. Entries are stored in AuditEntryModel.
| 163 | |
| 164 | |
| 165 | class AuditChainModel(BaseModel): |
| 166 | """ |
| 167 | Stores AuditChain metadata. One chain per Mission. |
| 168 | Entries are stored in AuditEntryModel. |
| 169 | """ |
| 170 | |
| 171 | __tablename__: str = "sys_orgkernel_audit_chain" |
| 172 | __table_args__ = ( |
| 173 | Index("idx_chain_mission_id", "mission_id", unique=True), |
| 174 | {"comment": "OrgKernel AuditChain — append-only hash-chained audit log header"}, |
| 175 | ) |
| 176 | |
| 177 | chain_id: Mapped[str] = mapped_column( |
| 178 | String(32), primary_key=True, comment="ac_ prefixed global ID" |
| 179 | ) |
| 180 | mission_id: Mapped[str] = mapped_column( |
| 181 | String(32), nullable=False, unique=True, index=True, |
| 182 | comment="FK -> Mission (one chain per mission)", |
| 183 | ) |
| 184 | agent_id: Mapped[str] = mapped_column( |
| 185 | String(32), nullable=False, |
| 186 | comment="FK -> sys_orgkernel_agent_identity.agent_id", |
| 187 | ) |
| 188 | initialized_at: Mapped[datetime] = mapped_column( |
| 189 | DateTime, nullable=False, |
| 190 | comment="UTC chain initialization timestamp", |
| 191 | ) |
| 192 | closed_at: Mapped[datetime | None] = mapped_column( |
| 193 | DateTime, nullable=True, |
| 194 | comment="UTC chain closure timestamp", |
| 195 | ) |
| 196 | head_hash: Mapped[str | None] = mapped_column( |
| 197 | String(64), nullable=True, |
| 198 | comment="SHA-256 hash of the most recent entry", |
| 199 | ) |
| 200 | |
| 201 | |
| 202 | class AuditEntryModel(BaseModel): |