refactor(job-queue): let resource_deps say (resource, units)

It never produced a `Dep::Node`, so returning `Vec<Dep<Resource>>` made
every caller match a variant that cannot occur. `running_transients`
paid for it with a two-arm match to pull the agent out of a lease edge.

`Vec<(Resource, u32)>` says the same thing in the type, and is what the
job builder's `.needs_units(name, count)` takes — the insertion path
wraps it back into a `Dep::Resource` at the one place that still speaks
in edges.
This commit is contained in:
atlas 2026-08-02 12:37:18 +02:00 committed by mara
commit 9be7731c5e
2 changed files with 18 additions and 28 deletions

View file

@ -170,7 +170,11 @@ fn insert_group(
let mut ids: Vec<NodeId> = Vec::with_capacity(nodes.len());
for ns in nodes {
let payload = ns.kind.clone();
let mut deps = payload.resource_deps();
let mut deps: Vec<Dep<Resource>> = payload
.resource_deps()
.into_iter()
.map(|(name, count)| Dep::Resource { name, count })
.collect();
for d in &ns.deps {
deps.push(Dep::Node {
id: ids[dep_index(d.on)],
@ -450,17 +454,14 @@ impl JobQueue {
.nodes()
.filter(|n| matches!(n.state, State::Running))
.filter_map(|n| {
let agent = n
.payload
.resource_deps()
.into_iter()
.find_map(|d| match d {
Dep::Resource {
name: Resource::Agent(a),
..
} => Some(a),
_ => None,
})?;
let agent =
n.payload
.resource_deps()
.into_iter()
.find_map(|(name, _)| match name {
Resource::Agent(a) => Some(a),
_ => None,
})?;
Some(RunningTransient {
agent,
label: n.payload.as_str().to_owned(),