wire types: WireTime newtype for timestamps instead of adaptor-annotated i64

This commit is contained in:
damocles 2026-07-03 19:18:33 +02:00 committed by mara
commit 1e205289c5
12 changed files with 148 additions and 162 deletions

View file

@ -9,6 +9,7 @@ use serde::Serialize;
use crate::container_view::ContainerView;
use crate::dashboard::{MetaInputView, TombstoneView};
use crate::rebuild_queue::QueueEntry;
use hive_sh4re::wire_time::WireTime;
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "snake_case", tag = "kind")]
@ -38,8 +39,7 @@ pub enum DashboardEvent {
from: String,
to: String,
body: String,
#[serde(with = "hive_sh4re::wire_time::iso")]
at: i64,
at: WireTime,
#[serde(default, skip_serializing_if = "Option::is_none")]
in_reply_to: Option<i64>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@ -54,8 +54,7 @@ pub enum DashboardEvent {
from: String,
to: String,
body: String,
#[serde(with = "hive_sh4re::wire_time::iso")]
at: i64,
at: WireTime,
#[serde(default, skip_serializing_if = "Option::is_none")]
in_reply_to: Option<i64>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@ -97,8 +96,7 @@ pub enum DashboardEvent {
sha_short: Option<String>,
/// `"approved"` / `"denied"` / `"failed"`.
status: &'static str,
#[serde(with = "hive_sh4re::wire_time::iso")]
resolved_at: i64,
resolved_at: WireTime,
note: Option<String>,
description: Option<String>,
},
@ -114,10 +112,8 @@ pub enum DashboardEvent {
question: String,
options: Vec<String>,
multi: bool,
#[serde(with = "hive_sh4re::wire_time::iso")]
asked_at: i64,
#[serde(with = "hive_sh4re::wire_time::iso_opt")]
deadline_at: Option<i64>,
asked_at: WireTime,
deadline_at: Option<WireTime>,
target: Option<String>,
/// Verified file-path tokens that appear in `question`.
/// Same shape as broker `Sent`/`Delivered` events; the
@ -135,8 +131,7 @@ pub enum DashboardEvent {
id: i64,
answer: String,
answerer: String,
#[serde(with = "hive_sh4re::wire_time::iso")]
answered_at: i64,
answered_at: WireTime,
cancelled: bool,
target: Option<String>,
/// Verified file-path tokens that appear in `answer`.
@ -337,7 +332,7 @@ mod tests {
from: "a".into(),
to: "b".into(),
body: String::new(),
at: 0,
at: hive_sh4re::wire_time::WireTime(0),
in_reply_to: None,
file_refs: Vec::new(),
},
@ -347,7 +342,7 @@ mod tests {
from: "a".into(),
to: "b".into(),
body: String::new(),
at: 0,
at: hive_sh4re::wire_time::WireTime(0),
in_reply_to: None,
file_refs: Vec::new(),
},
@ -368,7 +363,7 @@ mod tests {
approval_kind: "apply_commit",
sha_short: None,
status: "approved",
resolved_at: 0,
resolved_at: hive_sh4re::wire_time::WireTime(0),
note: None,
description: None,
},
@ -379,7 +374,7 @@ mod tests {
question: String::new(),
options: Vec::new(),
multi: false,
asked_at: 0,
asked_at: hive_sh4re::wire_time::WireTime(0),
deadline_at: None,
target: None,
question_refs: Vec::new(),
@ -389,7 +384,7 @@ mod tests {
id: 1,
answer: String::new(),
answerer: "a".into(),
answered_at: 0,
answered_at: hive_sh4re::wire_time::WireTime(0),
cancelled: false,
target: None,
answer_refs: Vec::new(),
@ -452,7 +447,7 @@ mod tests {
seq: 1,
entry: crate::audit_log::AuditEntry {
id: 1,
ts_unix: 0,
ts_unix: hive_sh4re::wire_time::WireTime(0),
agent: "atlas".into(),
action: "restart_infra".into(),
target: "hive-ci".into(),
@ -481,7 +476,7 @@ mod tests {
seq: 7,
entry: crate::audit_log::AuditEntry {
id: 42,
ts_unix: 1_700_000_000,
ts_unix: hive_sh4re::wire_time::WireTime(1_700_000_000),
agent: "atlas".into(),
action: "restart_infra".into(),
target: "hive-gateway".into(),