pub fn append(
root: &Path,
risk_id: &str,
data: EventData,
actor: &str,
agent: Option<Agent>,
ts: Option<DateTime<Utc>>,
) -> Result<AppendOutcome>Expand description
Append exactly one event to risk_id’s log under the root lock, then
refresh its index entry.
Protocol (mirrors the manifest chain + state rebuild):
- take the root lock,
- read the tail for
seqand the chain head sha, - validate the status transition (for lifecycle events) against the
status machine and the event against
risk-event.schema.json, - set
prev_sha256to the head sha andseqto tail+1, - append ONE line with
O_APPEND— existing lines are never touched, - refresh this risk’s
index.jsonentry from the freshly-folded state.
actor is the operator handle; agent is Some when an agent (not a
direct operator action) appended the event. ts lets tests pin the clock;
production callers pass None for wall-clock.