Expand description
Event append primitive + seq recovery (design.md §1.4, §4).
Structs§
- Append
Result - Outcome of an
append_and_apply_eventcall. - Prior
Event - A prior event located by
find_prior_with_key. Carries enough to let an idempotent-retry caller both return the recordedseqand verify the retry payload matches what was originally written. - Quarantine
- Outcome of a
quarantine_corrupt_linescall that removed at least one poison line.backup_pathis the renamed copy of the original log (kept verbatim for operator forensics / hand-repair);removed_byte_offsetsare the start offsets, in that original, of every newline-terminated line that failed to parse as anEventand was excised from the recoveredevents.jsonl.
Enums§
- Append
Outcome - The three observable outcomes of an
append_and_apply_idempotentcall — the shared--idempotency-keycontract thatevent create,discussion resolve, and future keyed verbs (spinoff approve|reject,run create,node report) all answer to, lifted out of each CLI’s private log scan.
Functions§
- append_
and_ apply_ event - The one canonical mutation entry point: append a single event to
events.jsonland fold it into the projection files via the reducer, all under the run’sflock, with idempotency-key dedup. - append_
and_ apply_ idempotent - Append one keyed event idempotently: scan for a prior event with the same
kind+key, and either replay it, reject a conflicting reuse, or append fresh — the centralized--idempotency-keyprimitive (issuecore-idempotency-api). - append_
and_ apply_ unlocked - Append one event and fold it into projections. The
_witness: &LockedRunis compile-time proof the caller already holds the run’s exclusiveRunLock— obtained fromRunLock::with_lockorRunLock::witness, so this entry point cannot be reached without the lock. The sanctioned lock-held composition path: use it to fold extra logic (an idempotency-key lookup, a status precondition) or several writes (the supervisor’s derived discussion/spinoff batch) into one locked critical section. Callingappend_and_apply_eventfrom within a held lock would deadlock becauseflockblocks when a second open of the lock file from the same process tries to acquireLOCK_EX. - find_
prior_ with_ key - Stream-scan
events.jsonlfor the first event with matchingkindandidempotency_key, returning a typedPriorEvent(orNonewhen the log is missing or holds no such event). - quarantine_
corrupt_ lines - Heal a poisoned
events.jsonlby excising its corrupt physical lines. - quarantine_
corrupt_ lines_ unlocked - As
quarantine_corrupt_linesbut takes a&LockedRunwitness proving the caller already holds the run’s exclusiveRunLock— the sanctioned lock-held composition path, mirroringappend_and_apply_unlocked. Re-enteringquarantine_corrupt_linesunder a held lock would deadlock on the secondflockopen. - read_
all_ events - Read every event from
events.jsonl. Used by tests and reducer replays. - recover_
last_ seq - Read the last
seqfromevents.jsonl, or0if empty/missing.