Commit Graph
7 Commits
Author SHA1 Message Date
Pierre Rouanet b64def7b73 updaterd: automatic rollback is off unless asked for
`[update_gate] auto_rollback` in robotd.toml, default false, a row in
`robotctl configure`. It gates every path that reverts without being
asked:

- the health gate after `update apply`, `select` and `rollback`;
- the boot counter on a trial that never confirmed;
- `robot-boot-check` handing over to `robot-rescue`.

Off, the gate still runs and decides. A release that fails stays live,
reported `Stuck` with `robotctl update rollback <component>` in the
reason; the trial is cleared, and the journal entry is aborted rather
than rolled back, so `known_bad` does not blacklist it. The boot check
names the failed units and the manual `robot-rescue --reboot`, and exits
2. `--dry-run` is unchanged, since the OS slot gate reads it.

Releases now reach robots as tested Yocto images, and a separate daemon
update is the dev-board case, where an unasked revert replacing the
code under whoever holds the robot does more damage than it prevents.
A soft deprecation: the code stays, tested, one setting away.

`updaterd` reads the key from `robotd_config` (new, defaults to
/etc/robot/robotd.toml), both layers, at the moment of deciding, like
`allow_community` and the board. Test fixtures turn it on where they
test what a revert does.

Assisted-by: Claude:claude-opus-5-5
2026-11-04 12:38:25 +01:00
Pierre Rouanet 8e497c4ed0 An update must not restart the recovery net's oneshot
`robot-boot-check.service` was in `on_apply`'s restart set:

    units_to_restart = ["configd", "padd", "robot-boot-check", "robotd"]

It asks whether the release that booted came up and hands over to `robot-rescue` if
not, so an update restarting it points a rollback check at daemons that are
legitimately mid-restart — and `robot-rescue` can answer by swapping to golden and
rebooting. Mid-update.

`hooks/postinstall` already declines to `enable --now` it, and says exactly why:
"`enable --now` on it would run a rollback check in the middle of the update that
installed it, with daemons legitimately mid-restart". The engine then read every
`*.service` and restarted it a moment later anyway. Two places, one rule, one unit,
and they disagreed.

What kept it harmless is a guard for a different caller: the script declines when
uptime is over ten minutes, and its comment names `postinstall` as the reason that
guard exists. Inside the first ten minutes of a boot — a dev board, or `auto_apply`
polling sixty seconds after `updaterd` starts — the guard does not apply and the check
evaluates its members while two of them are restarting. It needs `failed` or three
restarts to act, so it would usually decline; "usually" is not the property wanted from
the thing that reboots the robot.

Keyed on `[Install]` rather than on a name in `NEVER_RESTART`. A unit without one is
triggered by something else, so its lifecycle is not the update's to drive; and stating
it as the rule makes `postinstall` and the engine agree by construction rather than by
both being remembered. An unreadable unit counts as one to restart, because that is
more likely a permissions problem than a triggerless unit, and failing loudly beats
skipping quietly.

Demonstrated rather than argued: the fixture now ships a unit shaped like the real one,
recording each time it runs, and the harness asserts it did not. With the rule disabled
that assertion fails, printing the `ran` the unit left behind.

`install-path-gap.md` is retitled and closed. Its own body has said the gap is shut
since the artifact-install test landed, while its title and revision note still said
otherwise. `restart-order.md` gains the rule and stops calling five units the whole
set.

Assisted-by: Claude:claude-opus-5
2026-08-11 19:03:38 +02:00
Pierre Rouanet cf9c1df036 The two injections, and a gap they turned up
`systemd-run` cannot be run: the update still succeeds, the journal says why, and
`btd` and `updaterd` are left on the old release exactly as a missed timer leaves
them. Then the next `updaterd` start restarts the stale `btd` and does not restart
itself — `reconcile.rs` closing its loop for the first time outside a unit test.

A unit whose `User=` the release brings with it: `systemd-sysusers` runs before the
units, the account exists, and the unit is running as it. The other half — the same
unit with nothing creating the user — fails the update and names the unit rather than
the account.

Two of the assertions I first wrote were wrong about the code rather than the code
being wrong, and both corrections are worth keeping:

  - `ReportedOnly` is not reachable by restarting `updaterd`. A restart re-execs
    through `current`, so the successor is the active release by construction. What
    the step actually proves is the absence of a *second* restart, which in that
    process would be a loop.
  - a rollback is a successful call reporting an unsuccessful outcome, so the check is
    the reported outcome and never the exit status.

And a real gap, asserted as-is rather than papered over: **a failed update can fail
its own rollback.** `postinstall` overwrote the good unit file with the broken one and
by design does not put it back; when that unit is in the restart set of the release
being reverted *to*, the revert re-runs the same restart and inherits the same
failure. `RollbackFailed` is the outcome the design calls the most serious one, and it
is reachable by an ordinary bad release rather than only by the downgrade case already
recorded. The tree does revert; what is lost is the apply action.

Eighteen checks, all passing.

Assisted-by: Claude:claude-opus-5
2026-08-11 18:43:37 +02:00
Pierre Rouanet 72475f6ad0 Drive a real update against real systemd
The last item of the plan in install-path-gap.md, and the one everything else is
blind to: every other check in the tree drives the engine against a stub
`systemctl`, so none of them can see whether a restart *happened*.

`scripts/systemd-test.sh` boots systemd as pid 1, mints three signed releases
carrying real units and a real `updaterd`, installs one, applies the next through
the running daemon, and then applies one shipping a unit that cannot start. It
observes four things nothing else can:

  - `on_apply` really restarts what the release ships — asserted on the unit's main
    PID changing, not on a command having been issued;
  - the deferred transient timer really fires and really replaces `updaterd`, in
    about four seconds, and the successor runs the new release. A child process
    could not: it would sit in the cgroup being killed. That was the reason for
    `systemd-run` and, until now, an untested claim;
  - `hooks/postinstall` really installs, enables and starts a unit the board has
    never had;
  - a unit that installs cleanly and cannot start fails the update and names itself,
    rather than reverting with "not healthy within 30s: unreachable" — bug 1, and the
    only class the cheaper items cannot reach.

Docker rather than systemd-nspawn, which the plan proposed. The objection to
privileged containers *in CI* stands and this is not CI; what decided it is the
plan's own argument for ranking this last — a check that can only run on a machine
nobody develops on stops being read. Docker Desktop runs systemd as pid 1 on the
laptop this was written on. nspawn does not.

The fixture is its own example rather than a flag on `fake-release`, which
deliberately mints releases with no units because it exists to drive the engine
where systemd is not present.

Two injections are left, both cheap now the harness exists: `systemd-run` failing,
and `enable --now` on a unit whose `User=` does not exist.

Not in CI: it needs --privileged and the host's cgroup filesystem, and the `board`
job is already the slowest thing in the loop. Run it when `on_apply`, the deferred
restarts or the hook change.

Assisted-by: Claude:claude-opus-5
2026-08-11 18:22:23 +02:00
Pierre Rouanet ef9162bb01 docs: rework for people who use the robot, and organise by audience (#48)
* docs: a README a robot user can actually start from

The README was four documents in one — pitch, dev setup, board operations
manual, dev-key plumbing, release process and status — at 457 lines. Someone
handed a robot met `robotctl monitor`'s projected-gravity paragraph before
learning how to make the thing move.

Most people joining will use the robot, not develop the shipping machinery.
So the README is now the first hour for that reader: is it alive, drive it
with a gamepad, watch the loop, run your own .onnx, put a branch on it. The
padd socket-forward recipe — pad on your laptop, robot on the bench, nothing
cross-compiled — was buried in a source comment and is now the centrepiece.

Everything else moves rather than disappears:

  docs/install-dev.md  new: the linear dev-board install, split out of
                       deploy/README.md, which stays as the reference for
                       what those steps do. Leaves a slot for the
                       regular-user install doc.
  CONTRIBUTING.md      new: building, testing, layout, conventions,
                       releasing — the daemon-developer door.
  docs/cheatsheet.md   absorbs monitor, completions, update log, and
                       select/pin/reset-to-golden with the three
                       easy-to-get-wrong notes.

Services and status were duplicated in architecture.md §1 and roadmap.md, so
they are links now rather than a third copy.

padd ships in the release but only robotctl gets a PATH symlink
(scripts/install.sh:633), so the on-robot invocation is the full path.

Assisted-by: Claude:claude-opus-5[1m]

* docs: drop self-referential commentary from the front docs

A doc that describes itself spends the reader's attention on navigation
rather than on the robot. Cut the paragraph telling the reader what the
README covers, the 'shorter door' framing, and the repeated 'read it
when' stems in the link table.

Assisted-by: Claude:claude-opus-5[1m]

* docs: plainer opening, and defer the dev-install prerequisite to its own page

The socket path and the wire format are not what a reader needs in the
first two lines; robotctl being the thing you talk to is. The branch
section likewise only needs to say the dev install is a prerequisite,
not re-explain what it consists of.

Assisted-by: Claude:claude-opus-5[1m]

* Update README.md

* Update README.md

* docs: basic update commands in the README, health contract where tools need it

The README jumped from watching the robot straight to installing branch
builds, with no answer for someone who only wants the current release.

The health rationale that came out of the README lands in architecture
§8.4, next to the version discussion it belongs beside, and the exit-code
contract is repeated in the cheat sheet where anyone scripting will look.

Assisted-by: Claude:claude-opus-5[1m]

* docs: explain apply-without-ref where the command is introduced

The warning sat two sections below the command it was about, so the
reader met the plain form first and the caveat only if they carried on
into branch builds. Stating what the stable channel means at the point
of use leaves the branch section to say what --ref adds.

Assisted-by: Claude:claude-opus-5[1m]

* docs: move the policy tensor contract into robotd-design

Tensor widths and the legacy 51-D refusal are what you need when a
policy will not load, not when you are swapping one in. They join the
rest of the load-time validation in §5.3, and the params file outliving
an update joins §7.2, which is already about that file's lifetime.

Assisted-by: Claude:claude-opus-5[1m]

* docs: dev-channel mechanics out of the README

Tag movement and version uniqueness join the --ref explanation in the
cheat sheet; the trust argument for dev builds joins install-dev, where
the reader is deciding to trust that key. 'A merge does not publish
instantly' was already in the cheat sheet, so the README keeps only the
short form.

Assisted-by: Claude:claude-opus-5[1m]

* docs: branch workflow as steps

Assisted-by: Claude:claude-opus-5[1m]

* docs: trim the update section to the commands

Assisted-by: Claude:claude-opus-5[1m]

* docs: group by audience — robot, design, project

Ten docs sat flat in docs/, so a design doc, a runbook and an open
post-mortem all looked equally authoritative. install-path-gap.md reads
as current architecture until you notice the Status line.

  robot/    cheatsheet, install-dev        — you have a robot
  design/   architecture and the three     — you are changing the daemon
            design docs
  project/  roadmap, ci-setup, and the     — dated records, stale on
            two records                      purpose

docs/README.md indexes all three. deploy/README.md stays next to the
config files it documents. Every cross-link repointed and checked.

Assisted-by: Claude:claude-opus-5[1m]

* docs: split the cheat sheet by audience, dedupe the deploy quickstart

The cheat sheet was 435 lines serving two readers: robotctl on a robot,
and btctl plus the dev channel, which need a clone and a dev board.
Split at that line — cheatsheet.md is the robot, cheatsheet-dev.md is
the dev board. 'Building and checking' was neither, so it joins the
build commands in CONTRIBUTING.

deploy/README.md kept a full copy of the dev-board provisioning walk-
through that install-dev.md now owns. It keeps the two commands and the
flags, and defers the rest.

Where next is now two groups rather than six flat rows: going further
with a robot, and contributing.

Assisted-by: Claude:claude-opus-5[1m]

* ci: follow the docs move when packaging a release

dev.yml and release.yml ship architecture.md and updater-design.md
inside the artifact, by source path. The move to docs/design/ broke
packaging on every push. The destination inside the release is
unchanged, so nothing on a board moves.

Assisted-by: Claude:claude-opus-5[1m]

* docs: repoint doc paths in comments after the move, and note --help in the README

Around ninety source comments cite docs/<name>.md by path. They break
nothing, but a path that does not resolve teaches the reader to stop
trusting the next one. Includes the rustdoc intra-doc links in
updater/src/lib.rs.

The README now says robotctl explains itself, so the commands can be
explored rather than looked up.

Assisted-by: Claude:claude-opus-5[1m]

* docs: start install-dev at flashing the board

The doc began at 'a board you can reach over ssh', which is several
steps in. Name the image and the imager profile, since setting wifi and
the user there is what makes the board reachable without a serial
console.

Assisted-by: Claude:claude-opus-5[1m]

* deploy: commit the team dev key, outside trusted_keys/

Keeping team.dev.pub out of the repository protected nothing. A board
accepts dev builds only when the key is in its own trusted_keys_dir and
allow_dev_keys is true, and signing a build needs the private half,
which has not moved. What the absence did buy was a round trip for
every new developer, asking someone for a file.

It goes in deploy/dev-key/ rather than deploy/trusted_keys/, because
install.sh copies the latter onto every robot and this must reach only
boards that opt in. provision-board.sh now falls back to the committed
copy when ~/.duck-keys/team.dev.pub is absent; your own copy still wins.

Assisted-by: Claude:claude-opus-5[1m]

* provision-board: read the dev key from the repo only

The ~/.duck-keys lookup was the primary path and the committed copy a
fallback, which is backwards now the key ships with the repo: the two
files are identical, so the home-directory branch only ever selected the
same bytes by a longer route. One default, and --dev-key for a key from
somewhere else.

Also repoints the doc paths in markdown prose that the earlier sweep
missed — it only covered .rs, .sh, .yml and .toml.

Assisted-by: Claude:claude-opus-5[1m]

* docs: repoint install-path-gap references that arrived with main

xtask/tests/artifact.rs and board-test.sh landed on main while this
branch was moving docs into groups, so they cite the old flat path.

Assisted-by: Claude:claude-opus-5[1m]
2026-08-10 12:52:45 +02:00
Pierre Rouanet 6e70c1b882 board-test: exercise the binaries that ship, not an example that doesn't (#27)
* board-test: exercise the binaries that ship, not an example that doesn't

The playground was a second implementation of the update system — publisher and
robot in one binary — written from a premise its own module doc still stated:
that `updaterd`'s socket server and `robotctl`'s transport "are not wired up
yet, so this drives `Engine` directly". They are wired up, and board-test.sh
drove them over a real unix socket forty lines below the checks that didn't.

So the board test asserted install, unhealthy rollback, tamper refusal and
boot-counter recovery against `updater/examples/playground` — which `xtask
package` never puts in a release artifact. Every one of those checks covered a
binary no robot will ever run, in a script whose stated job is to "exercise the
result on real ARM64 Linux".

The shipped daemon already has every piece needed: `install --from` for the
local-dir install a bare board does, `--inject-fault` for the failure paths,
`--check-only` for what a boot does. The only thing neither binary does is mint
a signed release to feed them, so that — and only that — becomes a
`test-support` example, reusing the same `Publisher` the tests publish with
rather than the playground's third hand-rolled copy of it (which had drifted:
no fixed tar mtime, the reproducibility property xtask relies on).

The fixture is minted host-native and mounted into the container: a release is
signed manifests and tarballs, no more architecture-dependent than the ones
GitHub serves. Releases are staged into `published/` one at a time, so what
`latest` resolves to is explicit at every step rather than a side effect of
publish order.

Two stale claims fixed while here: updater-design.md said release.yml verifies
via "`LocalDir` + `playground apply`" when it uses `updaterd install --from`,
and the README walkthrough is now the real daemon and CLI.

Assisted-by: Claude:claude-opus-5

* README: document the real update paths, drop the synthetic walkthrough

The "see the engine work" walkthrough was ceremony: mint fake releases, copy
one into a directory, start a daemon with a rigged health gate, drive it from a
second terminal. Six commands to watch a rollback that `updater/tests/apply.rs`
already asserts, and nothing a reader would ever type again.

What was actually missing from the README was how you install without a
network. `updaterd install --from <dir>` is the factory and sideload path, and
`--force` is the one escape hatch for the case that has already come up on a
board: an installed `updaterd` too old to accept the release that fixes it
being too old, rolling the new release back every time, with the binary running
that gate being the one to be replaced. Both were documented only in
`--help` text nobody reads before they need it.

`fake-release` stays — `scripts/board-test.sh` mints its fixtures with it. It
is just not something to put in front of someone reading the README.

Test count corrected to 319 while in that paragraph.

Assisted-by: Claude:claude-opus-5
2026-08-05 09:43:25 +02:00
Pierre Rouanet 1c715bdde6 Extract test-support; drop three dead-code sites
Four test files each carried their own copy of "generate a keypair, build a
.tar.zst, sign it, write a manifest, sign that" — 408 lines of it. Changing the
manifest format meant editing four fixtures, and they had already drifted: only
install.rs embedded binaries in the artifact, and only some set tar mtimes, which
is the reproducibility property xtask relies on. Both differences are now explicit
at the call site instead of buried in duplicated tar code.

The migration found the drift the hard way: install.rs's tests assert the
binaries landed, and passing a generic publish broke them. That is the point —
one fixture, and a per-suite difference has to be stated rather than diverging
silently.

net -136 lines, and any future manifest change is one edit.

Also removed: two genuinely unread fields (a test's public_key, the github
source's browser_download_url, unused since assets resolve through the API) and
one stale allow(dead_code) on a field that is very much read.

Assisted-by: Claude:claude-opus-5
2026-07-29 14:02:51 +02:00