//! The head of a list whose last write was refused (architect, 14 Oct 2026).//!//! A write the MCP admission refuses files ONE open Feedback row per cause in//! the owner's database, with a typed `context.refused_write` naming the//! table it was for (`cotton-server`'s `RefusedWrite`). A list over that table//! says so at its head, so a sampler refused every five minutes for hours is//! seen where its rows stopped, not in a log nobody reads.//!//! The engine fills two typed readings — the refusal's `reason` and the//! moment it began, `since` — and the `feedback` definition's//! `refused_reason` and `refused_since` columns word them: every word of the//! line is the definition's, so a rewording is data.use chrono::{DateTime, Utc};usecrate::definitions::TableDefinition;usecrate::device::words::Clock;/// One open refused write, as the list head reads it.#[derive(Debug, Clone, PartialEq, Eq)]pubstructRefusedSample {/// The admission's own sentence for the refusal.pub reason: String,/// When this cause was first refused (RFC 3339).pub since: String,}/// Of the open refused writes for one table, the one the head says: the/// newest, by when it began. `None` when nothing is refused.pubfn newest(samples: implIntoIterator<Item = RefusedSample>) -> Option<RefusedSample> { samples .into_iter() .max_by_key(|sample| parse(&sample.since).map(|at| at.timestamp_millis()).unwrap_or(i64::MIN))}/// The head line for a refused write, worded by the `feedback` definition:/// `refused_reason`'s `reading` with the reason, then `refused_since`'s with/// the day and clock time it began in the reader's zone. `None` when the/// definition does not word it.pubfn head_line(definition: &TableDefinition, sample: &RefusedSample, clock: &Clock) -> Option<String> {let reading = |key: &str| definition.column(key).and_then(|column| column.reading.as_deref());letmut line = reading("refused_reason")?.replace("{value}", &sample.reason);iflet (Some(since), Some(template)) = (parse(&sample.since), reading("refused_since")) {let at = since.with_timezone(&clock.zone).format("%-d %b %H:%M").to_string(); line.push_str(&template.replace("{value}", &at)); }Some(line)}fn parse(at: &str) -> Option<DateTime<Utc>> {DateTime::parse_from_rfc3339(at).ok().map(|at| at.with_timezone(&Utc))}#[cfg(test)]#[path = "refused_write_tests.rs"]mod tests;