MCPcopy Create free account
hub / github.com/MetapriseAI/OrgKernel / AuditChainModel

Class AuditChainModel

src/orgkernel/models.py:165–199  ·  view source on GitHub ↗

Stores AuditChain metadata. One chain per Mission. Entries are stored in AuditEntryModel.

Source from the content-addressed store, hash-verified

163
164
165class 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
202class AuditEntryModel(BaseModel):

Callers 1

initializeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected