Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,31 @@ Each is made, with how to undo it.
4. The PM stack does not yet show which rung fed each agent's task. It does
now separate hands items from choices an agent parked on the owner.
5. A `feature_slice` queue kind, so slices can also be scheduled centrally.

---

## 2026-11-21T12-45-00Z Update: nine review findings fixed

An automated review of #12227 arrived after the merge with nine findings.
Each was checked against the code, each was real, and each is fixed with a
test that fails without the fix.

| Finding | Fix |
| ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `fleet shell --build` gave the lock wrapper only the first word of a compound command | The whole command runs in one shell beneath the lock: `fleet-build-lock sh -c '<command>'`. Checked against a real shell and a recording wrapper |
| `--build` was ignored when the target was this host | A local build takes the lock where the host has one, and says so on stderr where it does not |
| A shortlist entry was handed out without checking it again | The issue is read again first. A hold, a claim, a close, a tracker or a hands item drops the entry; the next one is tried |
| An option given with no value fell back to its default (`--target=`, `--profile=`) | A blank value, a missing value, or another option where the value should be is a usage error, before anything runs |
| Two runs at the same moment could take the same priority issue | The pick and its reservation happen in one locked update. Twelve concurrent reservations over eight issues hand each out once |
| Only the first 30 issues of a rank were read | Each rank is read page by page until enough free issues are found, a short page ends it, or five pages are read |
| With one to three eligible issues the list stayed low, so every run was told to refill it | A fill records its time. For 30 minutes after a fill a low list is worked, not refilled again |
| Follow-up commands dropped a chosen `--shortlist` | `--shortlist`, `--repo` and `--profile` are carried into every follow-up command, quoted |
| `doctor` and a dry-run enrolment trusted the bridge's public health page | The mailbox is read as the agent, taking nothing. With no agent name the push rung is reported as not working, with the reason |

When GitHub cannot be asked, a listed issue is still handed out, marked
`rechecked: false` with a note to read the issue for a hold first: the
shortlist is the rung that works without the network, and withholding its
work then would defeat it.

This closes gap 3 in the list above. `fleet-agent` now has 65 tests; 16 more
hand-made faults, one per fix or more, were each caught.
3 changes: 3 additions & 0 deletions doc/agents/onboarding-an-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ fleet shell --build -- <command> # a long build: takes a build slot
fleet shell # an interactive shell
```

A whole command line works as one quoted argument, and all of it runs under
the build slot: `fleet shell --build -- 'cd pkgs/id && cargo test'`.

## What you need

HTTPS is enough for messages and for three of the four rungs. The queue rung
Expand Down
72 changes: 54 additions & 18 deletions pkgs/fleet/crates/fleet-agent/src/enroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ fn write_profile(path: &PathBuf, profile: &Profile) -> R<()> {
fs::write(path, format!("{text}\n")).map_err(down)
}

const BRIDGE_NEEDS: &str =
"HTTPS to the message bridge, and the fleet token by name through fleet secrets";

/// One leg's answer from this seat.
#[derive(Debug, Clone, PartialEq)]
pub struct Leg {
Expand All @@ -108,19 +111,34 @@ impl Leg {
}
}

/// Probe the four legs. With `register`, the bridge probe is the
/// `hello` that registers the agent; without it, a health check.
pub fn probe(world: &dyn World, register: Option<(&str, &[String])>) -> Vec<Leg> {
let bridge_call = match register {
Some((agent, groups)) => {
/// How the bridge leg is checked. The service's health answers
/// anyone, so it says nothing about whether this seat holds the fleet
/// token; only a call made as an agent does.
#[derive(Debug, Clone, Copy)]
pub enum BridgeProbe<'a> {
/// Register the agent with its groups (`bridge hello`).
Register(&'a str, &'a [String]),
/// Read the agent's mailbox without taking anything.
Read(&'a str),
/// No agent name is known: only the service can be asked.
Service,
}

/// Probe the four legs, the bridge leg as `how` says.
pub fn probe(world: &dyn World, how: BridgeProbe) -> Vec<Leg> {
let bridge_call = match how {
BridgeProbe::Register(agent, groups) => {
let mut hello = argv(&["bridge", "hello", "--agent", agent]);
if !groups.is_empty() {
hello.push("--groups".to_string());
hello.push(groups.join(","));
}
hello
}
None => argv(&["bridge", "health"]),
// A read that takes nothing: it needs the fleet token, so it
// shows this seat can really read its mailbox.
BridgeProbe::Read(agent) => argv(&["bridge", "inbox", "--agent", agent, "--limit", "1"]),
BridgeProbe::Service => argv(&["bridge", "health"]),
};
// The four legs are independent, so they are asked together.
let mut outs = world
Expand Down Expand Up @@ -157,16 +175,28 @@ pub fn probe(world: &dyn World, register: Option<(&str, &[String])>) -> Vec<Leg>
(plain, route)
};
vec![
leg(
"bridge",
&bridge_out,
if register.is_some() {
"registered"
} else {
"answers"
match how {
// The service answering is not this seat reading a
// mailbox: without an agent name the push rung is not
// shown as working.
BridgeProbe::Service => Leg {
name: "bridge",
ok: false,
detail: if bridge_out.ok() {
"the service answers, but no agent name is known to read a mailbox with: \
enrol, or pass --agent"
.to_string()
} else {
bridge_out.why()
},
needs: BRIDGE_NEEDS,
route: None,
},
"HTTPS to the message bridge, and the fleet token by name through fleet secrets",
),
BridgeProbe::Register(..) => leg("bridge", &bridge_out, "registered", BRIDGE_NEEDS),
BridgeProbe::Read(..) => {
leg("bridge", &bridge_out, "the mailbox answers", BRIDGE_NEEDS)
}
},
leg(
"queue",
&queue_out,
Expand Down Expand Up @@ -287,9 +317,9 @@ pub fn enroll(world: &dyn World, args: &[String]) -> R<(Value, i32)> {
}

let legs = if dry_run {
probe(world, None)
probe(world, BridgeProbe::Read(&name))
} else {
probe(world, Some((&name, &groups)))
probe(world, BridgeProbe::Register(&name, &groups))
};
let registered = !dry_run && leg_ok(&legs, "bridge");

Expand Down Expand Up @@ -375,7 +405,13 @@ pub fn doctor(world: &dyn World, args: &[String]) -> R<(Value, i32)> {
Some(n) => Some(check_name("--agent", &n)?),
None => None,
};
let legs = probe(world, None);
let legs = probe(
world,
match &agent {
Some(name) => BridgeProbe::Read(name),
None => BridgeProbe::Service,
},
);
let code = if any_intake(&legs) {
EXIT_OK
} else {
Expand Down
20 changes: 15 additions & 5 deletions pkgs/fleet/crates/fleet-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,24 @@ pub fn parse(args: &[String], switches: &[&str], values: &[&str]) -> R<Args> {
None => (a.clone(), None),
};
if values.contains(&name.as_str()) {
// A present option with no value is a usage error, never
// the default (the operator argument contract): a blank
// value, the end of the line, `--`, or another declared
// option where the value should be.
let declared = |token: &str| {
let head = token.split_once('=').map_or(token, |(n, _)| n);
token == "--" || values.contains(&head) || switches.contains(&head)
};
let v = match inline {
Some(v) => v,
None => it
.next()
.cloned()
.ok_or_else(|| usage(format!("{name} needs a value")))?,
None => match it.next() {
Some(v) if !declared(v) => v.clone(),
_ => return Err(usage(format!("{name} needs a value"))),
},
};
if v.trim().is_empty() {
return Err(usage(format!("{name} needs a value")));
}
out.flags.push((name, Some(v)));
} else if switches.contains(&name.as_str()) {
if inline.is_some() {
Expand All @@ -414,7 +425,6 @@ impl Args {
.find(|(n, _)| n == name)
.and_then(|(_, v)| v.clone())
.map(|v| v.trim().to_string())
.filter(|v| !v.is_empty())
}
pub fn uint(&self, name: &str) -> R<Option<u64>> {
match self.last(name) {
Expand Down
Loading