jobq: stamp created_at on every node, beside started_at/finished_at

`Node` carried two of the three lifecycle timestamps; the third lived on
hive-c0re's `NodeKind::Dag` container payload, a core-specific wrapper the
graph knows nothing about. Give it its real home so the container's copy
becomes redundant rather than load-bearing.

Not an `Option` like its neighbours: starting and finishing are events that
may never happen, but a node that exists was created. Modelling it as
optional would encode a state the graph cannot be in.

`hive-jobq-wire::GraphNode` gains the field in the same commit — it already
carries the other two, and without this one the value cannot reach a viewer
when the container's copy is deleted.
This commit is contained in:
atlas 2026-08-03 13:31:36 +02:00
commit 24cd7f6d65
2 changed files with 19 additions and 3 deletions

View file

@ -255,9 +255,9 @@ impl State {
}
/// Wall-clock UTC now — the source for node lifecycle timestamps
/// ([`Node::started_at`] / [`Node::finished_at`]). The graph stamps its own
/// timestamps rather than threading a clock through every call, so a node's
/// timing is self-contained. Derived from `SystemTime` (the workspace `chrono`
/// ([`Node::created_at`] / [`Node::started_at`] / [`Node::finished_at`]). The
/// graph stamps its own timestamps rather than threading a clock through every
/// call, so a node's timing is self-contained. Derived from `SystemTime` (the workspace `chrono`
/// carries no `clock` feature, matching `hive_sh4re::wire_time`), truncated to
/// whole seconds; a pre-epoch or out-of-range clock clamps to the epoch.
fn now_utc() -> DateTime<Utc> {
@ -291,6 +291,14 @@ pub struct Node<N, R> {
pub deps: Vec<Dep<R>>,
/// Lifecycle state.
pub state: State,
/// UTC instant the node was inserted into the graph. Stamped by the graph.
///
/// Not an `Option`, unlike its two siblings below: starting and finishing
/// are events that may never happen, but a node that exists was created.
/// Together the three are the node's whole lifecycle — a caller asking
/// "how long did this sit before it ran" needs this end of the interval,
/// and previously had to get it from a wrapper the graph knows nothing about.
pub created_at: DateTime<Utc>,
/// UTC instant the node entered [`State::Running`] (`None` until it starts;
/// a cancelled node never ran, so it stays `None`). Stamped by the graph.
pub started_at: Option<DateTime<Utc>>,
@ -481,6 +489,7 @@ impl<N, R> Graph<N, R> {
payload,
deps,
state: State::Pending,
created_at: now_utc(),
started_at: None,
finished_at: None,
error: None,
@ -934,6 +943,7 @@ mod tests {
when: DepWhen::AFTER_OK,
}],
state: State::Pending,
created_at: now_utc(),
started_at: None,
finished_at: None,
error: None,
@ -954,6 +964,7 @@ mod tests {
payload: "x",
deps: vec![],
state: State::Pending,
created_at: now_utc(),
started_at: None,
finished_at: None,
error: None,