| 1 | package turnevent |
| 2 | |
| 3 | import "reasonix/internal/event" |
| 4 | |
| 5 | // RuntimeIdentity returns the last committed lifecycle identity and watermark |
| 6 | // under one ledger lock. It performs no replay, compaction or file reads. |
| 7 | func (l *Ledger) RuntimeIdentity() (string, event.TurnStatus, uint64) { |
| 8 | if l == nil { |
| 9 | return "", "", 0 |
| 10 | } |
| 11 | l.mu.Lock() |
| 12 | defer l.mu.Unlock() |
| 13 | return l.active, l.status, l.latestLocked() |
| 14 | } |
| 15 | |
| 16 | // TodoState returns the last complete replacement committed on the current |
| 17 | // head. The boolean distinguishes an explicit empty replacement from no write. |
| 18 | func (l *Ledger) TodoState() ([]event.Todo, bool) { |
| 19 | if l == nil { |
| 20 | return nil, false |
| 21 | } |
| 22 | l.mu.Lock() |
| 23 | defer l.mu.Unlock() |
| 24 | return append([]event.Todo(nil), l.todos...), l.todoWritten |
| 25 | } |
| 26 | |
| 27 | // RecoveryStatus returns the exact durable recovery terminal. Callers must not |
| 28 | // infer its cause from a generic running flag because restart, uncertain tool |
| 29 | // effects, and an expired cancellation grace require different remediation. |
| 30 | func (l *Ledger) RecoveryStatus() *event.RecoveryStatus { |
| 31 | if l == nil { |
| 32 | return nil |
| 33 | } |
| 34 | l.mu.Lock() |
| 35 | defer l.mu.Unlock() |
| 36 | return cloneRecoveryStatus(l.recovery) |
| 37 | } |
| 38 | |
| 39 | func cloneRecoveryStatus(in *event.RecoveryStatus) *event.RecoveryStatus { |
| 40 | if in == nil { |
| 41 | return nil |
| 42 | } |
| 43 | out := *in |
| 44 | return &out |
| 45 | } |
| 46 |