jobq: rename the builder parameters too, not just the alias

Renaming `pub type Job` fixed the definition and left every use site
reading `b` and `job` — including `job: super::JobBuilder`, where the
parameter still asserted it was a job while its type said otherwise.
The propagation is what the issue was about, so the parameters are the
half that matters at a call site.

Two spots deliberately untouched: `auto_update`'s `sort_by(|a, b| …)`
comparator, and the prose that means the job *queue* (main.rs's
"Job-queue scheduler", scheduler.rs's "not this module's job any more",
the "grown job rejected" log).

315 tests pass unchanged.
This commit is contained in:
atlas 2026-08-03 13:09:24 +02:00 committed by mara
commit 684f6da78e
6 changed files with 203 additions and 180 deletions

View file

@ -49,8 +49,8 @@ fn submit_and_emit(
/// meta input — the meta-update cascade grows its own rebuild subgraphs
/// in-DAG instead of going through this surface).
pub fn rebuild(coord: &Arc<Coordinator>, agent: &str, source: Source, reason: String) -> u64 {
submit_and_emit(coord, source, reason, |b| {
templates::rebuild(b, agent, true);
submit_and_emit(coord, source, reason, |builder| {
templates::rebuild(builder, agent, true);
})
}
@ -67,12 +67,12 @@ pub fn rebuild(coord: &Arc<Coordinator>, agent: &str, source: Source, reason: St
/// actually running (nothing to drain on a down container). The `Reconcile`
/// stays even for a down agent so a race-up between the state read and exec
/// is still stopped in-DAG.
fn stop_chain(b: &JobBuilder, agent: &str, graceful: bool, running: bool) {
fn stop_chain(builder: &JobBuilder, agent: &str, graceful: bool, running: bool) {
// `SetWanted` is the group root and owns the agent lease; the mechanical
// steps are its children (borrow the lease, run once it reaches `Finishing`,
// dep-ordered among themselves).
let a = || agent.to_owned();
let wanted = b
let wanted = builder
.node(NodeKind::SetWanted {
agent: a(),
up: false,
@ -81,22 +81,22 @@ fn stop_chain(b: &JobBuilder, agent: &str, graceful: bool, running: bool) {
// Declaration order is dependency order: the quiesce steps come first so
// the `Reconcile` that waits on them can name them.
if graceful && running {
let signal = b
let signal = builder
.node(NodeKind::Signal { agent: a() })
.needs(Resource::Agent(a()))
.part_of(wanted);
let drain = b
let drain = builder
.node(NodeKind::Drain { agent: a() })
.needs(Resource::Agent(a()))
.part_of(wanted)
.after_ok(signal);
let _ = b
let _ = builder
.node(NodeKind::Reconcile { agent: a() })
.needs(Resource::Agent(a()))
.part_of(wanted)
.after_ok(drain);
} else {
let _ = b
let _ = builder
.node(NodeKind::Reconcile { agent: a() })
.needs(Resource::Agent(a()))
.part_of(wanted);
@ -107,8 +107,8 @@ fn stop_chain(b: &JobBuilder, agent: &str, graceful: bool, running: bool) {
/// agent gets the rebuild subgraph (its tail `Reconcile` starts it on
/// current derivations), otherwise a plain `Reconcile` (which starts a down
/// agent and noops an already-running one).
fn start_chain(b: &JobBuilder, agent: &str, running: bool, stale: bool) {
let wanted = b
fn start_chain(builder: &JobBuilder, agent: &str, running: bool, stale: bool) {
let wanted = builder
.node(NodeKind::SetWanted {
agent: agent.to_owned(),
up: true,
@ -118,9 +118,9 @@ fn start_chain(b: &JobBuilder, agent: &str, running: bool, stale: bool) {
// Rebuild subtree chained behind the `SetWanted` head. `MetaSync`,
// `Prebuild` + `Reconcile` are their own group roots (top-level, per
// `rebuild_nodes`).
rebuild_nodes(b, agent, true, Some(wanted));
rebuild_nodes(builder, agent, true, Some(wanted));
} else {
let _ = b
let _ = builder
.node(NodeKind::Reconcile {
agent: agent.to_owned(),
})
@ -138,11 +138,11 @@ fn start_chain(b: &JobBuilder, agent: &str, running: bool, stale: bool) {
/// before `Reconcile`; a down agent gets just `Reconcile`, which
/// converges to intent — a stopped (`wanted = Off`) agent stays stopped,
/// a crashed (`wanted = Up`) agent comes back up.
fn restart_chain(b: &JobBuilder, agent: &str, graceful: bool, running: bool) {
fn restart_chain(builder: &JobBuilder, agent: &str, graceful: bool, running: bool) {
let a = || agent.to_owned();
if !running {
// Nothing to bounce — a lone Reconcile converges to intent.
let _ = b
let _ = builder
.node(NodeKind::Reconcile { agent: a() })
.needs(Resource::Agent(a()));
return;
@ -156,28 +156,28 @@ fn restart_chain(b: &JobBuilder, agent: &str, graceful: bool, running: bool) {
// that step *is* the root, and the parent gate already orders it — a child
// must NOT dep on its own parent (dep-scope), so it takes no sibling edge.
if graceful {
let signal = b
let signal = builder
.node(NodeKind::Signal { agent: a() })
.needs(Resource::Agent(a()));
let drain = b
let drain = builder
.node(NodeKind::Drain { agent: a() })
.needs(Resource::Agent(a()))
.part_of(signal);
let stop = b
let stop = builder
.node(NodeKind::StopForUpdate { agent: a() })
.needs(Resource::Agent(a()))
.part_of(signal)
.after_ok(drain);
let _ = b
let _ = builder
.node(NodeKind::Reconcile { agent: a() })
.needs(Resource::Agent(a()))
.part_of(signal)
.after_ok(stop);
} else {
let stop = b
let stop = builder
.node(NodeKind::StopForUpdate { agent: a() })
.needs(Resource::Agent(a()));
let _ = b
let _ = builder
.node(NodeKind::Reconcile { agent: a() })
.needs(Resource::Agent(a()))
.part_of(stop);
@ -198,9 +198,9 @@ fn restart_chain(b: &JobBuilder, agent: &str, graceful: bool, running: bool) {
// subgraph's indices onto another's used to be a function.
/// Declare the stop DAG from explicit `(agent, running)` targets.
pub(crate) fn stop_nodes(b: &JobBuilder, targets: &[(String, bool)], graceful: bool) {
pub(crate) fn stop_nodes(builder: &JobBuilder, targets: &[(String, bool)], graceful: bool) {
for (agent, running) in targets {
stop_chain(b, agent, graceful, *running);
stop_chain(builder, agent, graceful, *running);
}
}
@ -210,16 +210,16 @@ pub(crate) fn stop_nodes(b: &JobBuilder, targets: &[(String, bool)], graceful: b
/// running under its lease, so a down+stale agent that grew a rebuild subgraph
/// reports `rebuilding` during its swap and `starting` at its reconcile,
/// without the DAG having to guess one label covering every target.
pub(crate) fn start_nodes(b: &JobBuilder, targets: &[(String, bool, bool)]) {
pub(crate) fn start_nodes(builder: &JobBuilder, targets: &[(String, bool, bool)]) {
for (agent, running, stale) in targets {
start_chain(b, agent, *running, *stale);
start_chain(builder, agent, *running, *stale);
}
}
/// Declare the restart DAG from explicit `(agent, running)` targets.
pub(crate) fn restart_nodes(b: &JobBuilder, targets: &[(String, bool)], graceful: bool) {
pub(crate) fn restart_nodes(builder: &JobBuilder, targets: &[(String, bool)], graceful: bool) {
for (agent, running) in targets {
restart_chain(b, agent, graceful, *running);
restart_chain(builder, agent, graceful, *running);
}
}
@ -258,8 +258,8 @@ pub async fn restart_many(
for agent in agents {
targets.push((agent.clone(), lifecycle::is_running(agent).await));
}
submit_and_emit(coord, source, reason, |b| {
restart_nodes(b, &targets, graceful);
submit_and_emit(coord, source, reason, |builder| {
restart_nodes(builder, &targets, graceful);
})
}
@ -293,8 +293,8 @@ pub async fn start_many(
}
targets.push((agent.clone(), running, stale));
}
submit_and_emit(coord, source, reason, |b| {
start_nodes(b, &targets);
submit_and_emit(coord, source, reason, |builder| {
start_nodes(builder, &targets);
})
}
@ -331,8 +331,8 @@ pub async fn stop_many(
for agent in agents {
targets.push((agent.clone(), lifecycle::is_running(agent).await));
}
submit_and_emit(coord, source, reason, |b| {
stop_nodes(b, &targets, graceful);
submit_and_emit(coord, source, reason, |builder| {
stop_nodes(builder, &targets, graceful);
})
}
@ -344,8 +344,8 @@ pub fn perm_change(
reason: String,
payload: super::PermPayload,
) -> u64 {
submit_and_emit(coord, source, reason, |b| {
templates::perm_change(b, agent, payload);
submit_and_emit(coord, source, reason, |builder| {
templates::perm_change(builder, agent, payload);
})
}
@ -356,8 +356,8 @@ pub fn meta_update(
source: Source,
reason: String,
) -> u64 {
submit_and_emit(coord, source, reason, |b| {
templates::meta_update(b, inputs, None);
submit_and_emit(coord, source, reason, |builder| {
templates::meta_update(builder, inputs, None);
})
}
@ -374,7 +374,7 @@ pub fn reparent(
source: Source,
reason: String,
) -> u64 {
submit_and_emit(coord, source, reason, |b| {
templates::reparent(b, moves);
submit_and_emit(coord, source, reason, |builder| {
templates::reparent(builder, moves);
})
}