Fold one dispatch into the record, preserving `last_ok` across a later failure so a hook that has *never* succeeded is distinguishable from one that worked and then broke.
(
&mut self,
agent: &str,
display_name: &str,
verb: &str,
outcome: FireOutcome,
detail: Option<&str>,
now: &str,
)
| 107 | /// later failure so a hook that has *never* succeeded is |
| 108 | /// distinguishable from one that worked and then broke. |
| 109 | pub fn record( |
| 110 | &mut self, |
| 111 | agent: &str, |
| 112 | display_name: &str, |
| 113 | verb: &str, |
| 114 | outcome: FireOutcome, |
| 115 | detail: Option<&str>, |
| 116 | now: &str, |
| 117 | ) { |
| 118 | let entry = self |
| 119 | .agents |
| 120 | .entry(agent.to_string()) |
| 121 | .or_insert_with(|| AgentHealth { |
| 122 | display_name: display_name.to_string(), |
| 123 | verbs: BTreeMap::new(), |
| 124 | }); |
| 125 | entry.display_name = display_name.to_string(); |
| 126 | |
| 127 | fold_verb(&mut entry.verbs, verb, outcome, detail, now); |
| 128 | if observed_at(now) >= observed_at(&self.updated_at) { |
| 129 | self.updated_at = now.to_string(); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | /// Build a report from observations, including out-of-order outage replay. |
| 134 | pub fn from_events(events: Vec<crate::hook_log::SessionLogEvent>) -> Option<Self> { |