Cairnloop.Governance.ToolActionEvent (cairnloop v0.1.0)

Copy Markdown View Source

Append-only audit event record for governed tool proposals.

Mirrors ReviewTaskEvent exactly (D-20, D-21). Every state transition on a ToolProposal is recorded here alongside it in the same transaction.

Append-Only Invariant

This schema is insert-only. There is no update/1 or delete/1 function. The updated_at: false timestamp option enforces this at the schema level (Pitfall 4). App discipline (no update/delete API) enforces it at the application level.

Phase 16 adds execution event types (:execution_started, :execution_succeeded, :execution_attempt_failed, :execution_failed) to @event_type_values without changing this schema's structure (D16-08).

Summary

Functions

Changeset for inserting an append-only ToolActionEvent.

Functions

changeset(event, attrs)

Changeset for inserting an append-only ToolActionEvent.

Required fields: tool_proposal_id, event_type, to_status, actor_id. from_status is optional — it is nil for proposal_created events (first event has no prior status). Nil metadata is coerced to %{}.