Running the simulated duck from an agent¶
Pollen's scripts/duck-sim (in the host's Pollen checkout, named in its host file:
/work/pollen/microduck on the operator's workstation; pinned at 094d4bb4,
robots/duck/sim/pollen-pins.json) is written for a person at a terminal. Driven by an agent or a
script, from a process with no terminal, two of its habits change meaning. This page is how
robotics-lab runs it unattended: the challenge runner (lab-challenge), the evaluation, the
explorers and the probes all go through the host's reset, simhost.reset (libs/simhost,
RFC-0021).
Why: the sudo lockout (2026-11-16)¶
Every duck-sim down, the plain one included, first runs down_containers. That asks
sudo systemctl is-active about sixteen container units (duck-a … duck-p). For a person,
that is at most one password prompt. From a process with no terminal, sudo has nowhere to ask:
each of the sixteen asks is a failed password conversation (pam_unix(sudo:auth): conversation
failed in the journal). The machine's PAM counts failures with pam_faillock (deny=10
unlock_time=120 in /etc/pam.d/system-auth), so ten failures lock the user's sudo for two
minutes.
The challenge runs stop the simulator every ~70 s, so the operator's sudo stayed locked for as
long as they ran. A correct password typed at the time was refused ("Sorry, try again"), which
looked like a forgotten password. su marko -c true accepted the same password, because su
fell between the lockouts.
The duck-ether stop in plain down uses sudo -n, which fails without asking and is not
counted. Only down_containers locks.
The rule¶
An agent never runs a command that can make sudo ask with no terminal. In duck-sim that
means:
- Use only
up,down,drive,status,ctlandstand, with the patch below applied. - Never
boot,rootfsorshell. These need sudo by design (systemd-nspawn, mounts) and are a person's commands.
The patch (a local change, not sent upstream)¶
robots/duck/sim/patches/duck-sim-sudo-free-down.patch
drops sudo from the is-active check. Asking whether a unit runs needs no root. The
stop and umount that follow are reached only when a container really runs, and still prompt
a person as before. On this machine no duck-* unit exists, so they are never reached.
cd /path/to/pollen/microduck # the host file's `pollen.microduck` (`simhost show`); scripts/host-setup applies the patch itself
git apply /path/to/robotics-lab/robots/duck/sim/patches/duck-sim-sudo-free-down.patch # apply
git apply --reverse --check /path/to/robotics-lab/robots/duck/sim/patches/duck-sim-sudo-free-down.patch && echo applied
Re-apply it after any update or reset of the Pollen checkout. The operator decided on 2026-11-16 to keep it local: for a person, upstream's line is right.
The guards¶
simhost.duck_sim()refuses to run aduck-simthat still has the sudo check, and names the patch. Every runner fails at its first reset instead of locking the user out.robots/duck/tests/test_simhost.pychecks it both ways.robots/duck/sim/probes/sudo_free_down.pyruns one realdownthroughsimhost.downand fails if the user's faillock tally was written during it. It also prints the tally's records (time, service or terminal), which is how a lockout is read without root. Run it with no simulator in use: it stops the simulator.
One simulator job at a time: scripts/sim-lock¶
The simulator is one process set on fixed ports, reset by every run; two jobs at once corrupt each
other. Every simulator target (make sim-duck, sim-nxt, sim-gate-scenarios, sim-deployed) runs
under scripts/sim-lock, an exclusive fcntl.flock on one file, so a person and every agent take
the same lock without being told to.
- The file is
${XDG_RUNTIME_DIR:-/tmp}/robotics-lab-sim.lock, or the oneROBOTICS_LAB_SIM_LOCKnames. Every job on a machine must resolve to the same file: set the variable in the shell profile or the session's environment if the default differs. - A job that finds the lock held says who holds it (the holder's pid and command) and waits up to
7200 s (
--timeout, orROBOTICS_LAB_SIM_LOCK_TIMEOUT); then it exits 75 without running. With nobody holding the lock it runs at once, and the command's exit status, output and signals are its own. - Any other command:
scripts/sim-lock -- <command>.scripts/sim-lock --pathprints the file. - Nested use is safe: a recipe under
sim-lockthat startssim-lockagain does not wait for itself (ROBOTICS_LAB_SIM_LOCK_HELD). - The same lock is what
flock -w 7200 <file> <command>takes, so an old-style job and a new one exclude each other. But do not wrap amake sim-*target inflock(1)on the same file: the target's ownsim-lockcannot see that holder and waits for it. Run the target directly (it takes the lock itself), or withROBOTICS_LAB_SIM_LOCK_HELD=<the file>set under an outerflock. - Not covered: a job that runs the simulator by other means (
uv run lab-challenge, a probe script,simhost reset) is under the lock only if it is started asscripts/sim-lock -- ....
When sudo says "Sorry, try again"¶
- Read the tally:
uv run python sim/probes/sudo_free_down.py(inrobots/duck/, nothing running), or the record file/run/faillock/<user>directly. Many entries seconds apart, whose source is the servicesudorather than a terminal, mean a script is failing sudo. The operator's own attempts carry a terminal (/dev/pts/N). - Find the caller: list running
sudoprocesses with their parents (ps -o pid,ppid,args) while the failures arrive. - Stop it, wait two minutes (
unlock_time=120), then try once.